diff --git a/.eslintignore b/.eslintignore index 8f4cfb19cc..a0284d9988 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,5 @@ /dist src-script/download-artifact.js +/spa +/generated-html +/src-electron/generator/matter \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 367cf5aac7..b3c81e8534 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -62,6 +62,26 @@ module.exports = { // random rules added 'no-undef': 'off', - 'no-unused-vars': 'off' - } + 'no-unused-vars': 'off', + 'require-jsdoc': [ + 'error', + { + require: { + FunctionDeclaration: true, + MethodDefinition: true, + ClassDeclaration: false, + ArrowFunctionExpression: false, + FunctionExpression: false + } + } + ] + }, + overrides: [ + { + files: ['test/**/*.js', 'src/**/*.vue'], // Path to the directory you want to ignore + rules: { + 'require-jsdoc': 'off' // Disable the require-jsdoc rule for this directory + } + } + ] } diff --git a/.husky/pre-commit b/.husky/pre-commit index bb4491d2b5..bde26ebec7 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -5,10 +5,13 @@ echo "🚀 > Pretty quick reformat..." npx pretty-quick --staged echo "🚀 > JSdoc regen..." -npx jsdoc src-electron src-shared -r -d ./generated-html/ +node src-script/generate-all-api-docs.js +node src-script/generate-template-helper-docs.js +git add docs/api.md +git add docs/helpers.md echo "🚀 > Eslint..." -npx eslint --ext .js,.vue src src-electron src-shared src-script test +npx eslint . echo "🚀 > Reset version in package.json to 0.0.0..." src-script/zap-update-package-version.js -fake diff --git a/README.md b/README.md index 1ff3833b9d..160821f45e 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ This software is licensed under [Apache 2.0 license](LICENSE.txt). ## Detailed Developer Documentation +- [ZAP Template Helpers](docs/helpers.md) - [FAQ/Developer dependencies](docs/faq.md) - [Release instructions](docs/release.md) - [Development Instructions](docs/development-instructions.md) diff --git a/docs/api.md b/docs/api.md index aecc38f078..7601ac611e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -7,6 +7,15 @@
DB API: DB types and enums.

This module provides mappings between database columns and JS keys.

+
Renderer API: Renderer API.
+

This module provides Renderer API Exports.

+
+
REST API: REST API.
+

This module provides REST API Exports.

+
+
IPC Client API: Inter-process communication
+

This module provides IPC Client functionality.

+
JS API: low level database access

This module provides generic DB functions for performing SQL queries.

@@ -37,6 +46,12 @@
DB API: user configuration queries against the database.

This module provides queries for user configuration.

+
DB API: Data type discriminator queries against the database.
+

This module provides queries for data type discriminator

+
+
DB API: Data type queries against the database.
+

This module provides queries for data types

+
DB API: device type database access

This module provides queries for device types.

@@ -46,18 +61,24 @@
DB API: endpoint configuration queries against the database.

This module provides queries for endpoint configuration.

-
DB API: zcl database access
+
DB API: zcl database enum access

This module provides queries for enums.

DB API: event queries.

This module provides queries related to events.

+
DB API: feature related queries
+

This module provides queries for features.

+
DB API: package-based queries.

This module provides queries related to imports and exports of files.

DB API: zcl loading queries

This module provides queries for ZCL loading

+
DB API: zcl database number access
+

This module provides queries for numbers.

+
DB API: session related queries.

This module provides package notification related queries.

@@ -75,6 +96,9 @@ inside a single session. Things like:
DB API: session related queries.

This module provides session related queries.

+
DB API: zcl database strings access
+

This module provides queries for strings.

+
DB API: zcl database access

This module provides queries for enums.

@@ -90,21 +114,42 @@ across different query files.

Templating API: Access helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: Attribute helpers
+

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: C formatting helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: Command helpers
+

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
+
Templating API: Matter endpoint config helpers
+

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
+
Templating API: Future helpers
+

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
+
Templating API: SDK extension helpers
+

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: C formatting helpers

This module contains the API for accessing SDK extensions.

Templating API: user-data specific helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: Token helpers
+

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: toplevel utility helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

Templating API: static zcl helpers

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: Zigbee Specific helpers
+

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

+
Templating API: Overridable functions.

This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

@@ -114,9 +159,39 @@ across different query files.

JS API: generator logic
+
IDE Integration API: Studio REST API.
+

This module provides the APIs to Silabs Simplicity Studio's Jetty server.

+
REST API: user data

This module provides the API to access zcl specific information.

+
Export API: Exports Data into a file.
+

This module provides the functionality that reads the ZAP data from a database +and exports it into a file.

+
+
zap file
+

Formats ZAP file in a certain format.

+
+
Import API: Imports data from a file.
+

This module provides the functionality that reads a .isc file

+
+
Import API: Imports data from a file.
+

This module provides the functionality that reads a .json(.zap) file

+
+
Import API: Imports data from a file.
+

This file provides the functionality that reads the ZAP data from a JSON file +and imports it into a database.

+
+
Timer API: initializes times.
+

This module provides the APIs for initializing timers specifically +for sessions.

+
+
Startup API: initializes times.
+

This file contains various startup modes.

+
+
watchdog API: initializes times.
+

This file contains watchdogs.

+
REST API: admin functions

This module provides the REST API to the admin functions.

@@ -141,14 +216,47 @@ across different query files.

REST API: user data

This module provides the REST API to the user specific data.

+
JS API: Matter specific APIs.
+

This module contains Matter specific APIs.

+
JS API: http server

This module provides the HTTP server functionality.

+
IPC Server API: Inter-process communication
+

This module provides IPC Server functionality.

+
JS API: websocket server

This module provides the HTTP server functionality.

+
JS API: About page
+

This module provides the About page functionality for ZAP.

+
JS API: renderer API related utilities
+
JS API: UI Development
+

This file is used specifically and only for development. It installs +electron-debug & vue-devtools. There shouldn't be any need to + modify this file, but it can be used to extend your development + environment.

+
+
JS API: UI
+

Main UI

+
+
JS API: Menu for ZAP UI
+

Menu for ZAP UI

+
+
JS API: Tray for ZAP UI
+

Tray for ZAP UI

+
+
JS API: Utility module for ZAP UI
+

Utility module for ZAP UI

+
+
JS API: Window module for ZAP UI
+

Window module for ZAP UI

+
+
JS API: Arguments for ZAP
+

Arguments for ZAP

+
JS API: async reporting

This module provides the mechanism for dealing with the async reporting from backend to the UI.

@@ -157,6 +265,29 @@ from backend to the UI.

  • dirty flag
  • +
    JS API: Binary utilities
    +

    Binary utilities to deal with hex numbers and such.

    +
    +
    JS API: Environment utilities
    +

    Environment utilities for ZAP

    +
    +
    External API: External API utilities
    +

    External helper utilities for ZAP

    +
    +
    External API: External API utilities
    +

    External Registry utilities for ZAP

    +
    +
    External API: External API utilities
    +

    External helper utilities for ZAP

    +
    +
    JS API: Iterator utilities
    +

    This module provides API to access various iterator utilities that can then +be used to build iterator helpers.

    +
    +
    JS API: post-import.
    +

    This module contains the API functions for the post-load +scripting functionality.

    +
    JS API: post-import.

    This module contains the API functions for the post-load scripting functionality.

    @@ -165,6 +296,8 @@ scripting functionality.

    JS API: string utilities
    +
    JS API: Studio utilities
    +
    JS API: type related utilities
    JS API: random utilities
    @@ -172,20555 +305,26001 @@ scripting functionality.

    REST API: various zcl utilities

    This module provides the API to access various zcl utilities.

    - - -## Members - -
    -
    renderer_api
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    GLOBAL_SYMBOL_INFO
    -

    Global symbol that carries the API info metadata

    -
    -
    GLOBAL_SYMBOL_EXECUTE
    -

    Global function that can execute the APIs.

    -
    -
    GLOBAL_SYMBOL_NOTIFY
    -

    Global function that can be overloaded by jxbrowser for notifications

    -
    -
    ASYNC_DEFAULT_TIMER_INTERVAL_MS
    -

    This module provides the APIs for initializing timers specifically -for sessions.

    -
    -
    watchDogId
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    - -## Constants - -
    -
    uri
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    env
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    dbApi
    -

    This module provides queries for discriminators

    -
    -
    dbApi
    -

    This module provides queries for data types

    -
    -
    dbApi
    -

    This module provides queries for numbers

    -
    -
    dbApi
    -

    This module provides queries for strings

    -
    -
    queryAccess
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryAttribute
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryZcl
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryCommand
    -

    Copyright (c) 2021 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    cHelper
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    futureKey
    -

    Copyright (c) 2021 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    dbEnum
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    templateUtil
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    templateUtil
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryZcl
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryZcl
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    dbEnums
    -

    Copyright (c) 2023 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryPackage
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    _
    -

    Copyright (c) 2023 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    path
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    fs
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    fs
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    dbApi
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    dbApi
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    ipc
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    rendApi
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    env
    -

    This file is used specifically and only for development. It installs -electron-debug & vue-devtools. There shouldn't be any need to - modify this file, but it can be used to extend your development - environment.

    -
    -
    yargs
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    path
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryZcl
    -

    Copyright (c) 2024 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    path
    -

    Copyright (c) 2024 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    templateUtil
    -

    This module provides API to access various iterator utilities that can then -be used to build iterator helpers.

    -
    -
    path
    -

    Copyright (c) 2021 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    fs
    -

    Copyright (c) 2022 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    path
    -

    Copyright (c) 2023 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryZcl
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    -
    -
    queryPackage
    +
    Validation API: Validation APIs

    This module provides the APIs for validating inputs to the database, and returning flags indicating if things were successful or not.

    -
    queryZcl
    +
    Validation API: Validation APIs

    This module provides the APIs for validating inputs to the database, and returning flags indicating if things were successful or not.

    -
    fs
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    +
    Loader API: Loader APIs
    +

    This module provides the APIs for dotdot Loading

    -
    _
    -

    Copyright (c) 2023 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    +
    Loader API: Loader APIs
    +

    This module provides the APIs for new data model loading

    -
    fs
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    +
    Loader API: Loader APIs
    +

    This module provides the APIs for ZCL/Data-Model loading.

    -
    fs
    -

    Copyright (c) 2020 Silicon Labs

    -

    Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at

    -
       http://www.apache.org/licenses/LICENSE-2.0
    -
    -

    Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.

    +
    Loader API: Loader APIs
    +

    This module provides the APIs for for common functionality related to loading.

    -## Functions + -
    -
    initAndConnectClient() ⇒
    -

    Initializes and connects a client.

    -
    -
    on(eventType, handler)
    -

    Register a handler for the event type.

    -
    -
    lastPongData() ⇒
    -

    Get the last pong data.

    -
    -
    isClientConnected() ⇒
    -

    Returns true if client is connected.

    -
    -
    disconnectClient()
    -

    Disconnects a client asynchronously.

    -
    -
    emit(key, object)
    -

    Sends a message to server.

    -
    -
    selectAllDiscriminators(db, packageIds) ⇒
    -
    -
    selectDataTypeById(db, id) ⇒
    -

    Gathers the data type information of an entry based on data type id along -with its actual type from disciminator table.

    -
    -
    selectDataTypeByName(db, name, packageIds) ⇒
    -

    Gathers the data type information of an entry based on data type name along -with its actual type from disciminator table.

    -
    -
    selectDataTypeByNameAndClusterId(db, name, clusterId, packageIds) ⇒
    -

    Gathers the data type information based on data type name and -clusterId along with its actual type from disciminator table.

    -
    -
    selectAllDataTypes(db, packageId) ⇒
    -

    Gathers All the data types

    -
    -
    selectSizeFromType(db, packageIds, value) ⇒
    -

    Return the size of the given value whether it be a reference to it in the data -type table in the form of a number or be it the name of the type in the form -if string.

    -
    -
    selectNumberByName(db, name, packageIds) ⇒
    -

    Select an number matched by name.

    -
    -
    selectNumberByNameAndClusterId(db, name, packageIds) ⇒
    -

    Select a number matched by name and clusterId

    -
    -
    selectNumberById(db, name) ⇒
    -

    Select an number matched by id.

    -
    -
    selectAllNumbers(db, packageId) ⇒
    -

    Select all numbers.

    -
    -
    selectAllStrings(db, packageId) ⇒
    -

    Select all Strings.

    -
    -
    selectStringById(db, packageId) ⇒
    -

    Select String by ID.

    -
    -
    selectStringByName(db, name, packageIds) ⇒
    -

    Select String by name.

    -
    -
    attributeDefault() ⇒
    -

    Valid within a cluster context, requires code.

    -
    -
    if_command_arguments_exist(commandId, argument_return, no_argument_return)
    -
    -
    if_command_args_exist(commandId, options) ⇒
    -

    If helper which checks if command arguments exist for a command or not -example: -{{#if_command_args_exist commandId}} - command arguments exist for the command -{{else}} - command arguments do not exist for the command -{{/if_command_args_exist}}

    -
    -
    if_ca_always_present_with_presentif(commandArg, trueReturn, falseReturn) ⇒
    -
    -
    if_command_arg_always_present_with_presentif(commandArg, options) ⇒
    -

    If helper that checks if a command argument is always present with a -presentIf condition. -example: -{{#if_command_arg_always_present_with_presentif commandArg}} - command argument has a presentIf condition -{{else}} - command argument does not have a presentIf condition -{{/if_command_arg_always_present_with_presentif}}

    -
    -
    if_command_is_not_fixed_length_but_command_argument_is_always_present(command, commandArg, trueReturn, falseReturn) ⇒
    -
    -
    if_command_not_fixed_length_command_argument_always_present(command, commandArg, options) ⇒
    -

    If helper that checks if command is not fixed lenth and that the command is -always present. -example: -{{#if_command_not_fixed_length_command_argument_always_present commandId}} - command is not fixed length and command argument is always present -{{else}} - either command is fixed length or command argument is not always present -{{/if_command_not_fixed_length_command_argument_always_present}}

    -
    -
    if_ca_not_always_present_no_presentif(commandArg, trueReturn, falseReturn) ⇒
    -
    -
    if_command_arg_not_always_present_no_presentif(commandArg, options) ⇒
    -

    If helper that checks if a command argument is not always present because it -has a introduced in or removed in clause. The helper also checks that there -is no presentIf condition. -example: -{{#if_command_arg_not_always_present_no_presentif commandArg}} - command argument is not always present and there is no presentIf condition -{{else}} - Either command argument is always present or there is a presentIf condition -{{/if_command_arg_not_always_present_no_presentif}}

    -
    -
    if_ca_not_always_present_with_presentif(commandArg, trueReturn, falseReturn) ⇒
    -
    -
    if_command_arg_not_always_present_with_presentif(commandArg, options) ⇒
    -

    If helper that checks if a command argument is not always present because it -has a introduced in or removed in clause. The helper also checks that there -is a presentIf condition. -example: -{{#if_command_arg_not_always_present_with_presentif commandArg}} - command argument is not always present and there is a presentIf condition -{{else}} - Either command argument is always present or there is no presentIf condition -{{/if_command_arg_not_always_present_with_presentif}}

    -
    -
    if_command_is_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn)
    -
    -
    if_command_fixed_length(commandId, options)
    -

    If helper which checks if a command is fixed length or not

    -

    example: -{{#if_command_fixed_length commandId}} -command is fixed length -{{else}} -command is not fixed length -{{/if_command_fixed_length}}

    -
    -
    endpoint_type_count(options) ⇒
    -

    Returns number of endpoint types.

    -
    -
    endpoint_count(options) ⇒
    -

    Returns number of endpoints.

    -
    -
    endpoint_config_macros() ⇒
    -

    Prints out all the macros that the endpoint config -configuration depends on. These macros are created -by ZAP, because the use of these macros is also -created by ZAP.

    -
    -
    endpoint_fixed_endpoint_array(options) ⇒
    -

    Creates array of endpointId fields on endpoints

    -
    -
    endpoint_fixed_profile_id_array(options) ⇒
    -

    Creates array of profileId fields on endpoints

    -
    -
    endpoint_fixed_parent_id_array() ⇒
    -

    Creates Integer Array of parent endpoint identifier fields on endpoints. If the Parent Endpoint is not set then it will default to 0.

    -
    -
    endpoint_fixed_network_array(options) ⇒
    -

    Creates array of networkId fields on endpoints

    -
    -
    endpoint_fixed_endpoint_type_array(options) ⇒
    -

    Each element of an array contains an index into the -endpoint type array, for the appropriate endpoint.

    -
    -
    endpoint_attribute_manufacturer_codes(options) ⇒
    -

    Generates array of { index , mfgCode } pairs, matching -the indexes in attribute table.

    -
    -
    endpoint_reporting_config_defaults(options)
    -

    This helper supports an "order" CSV string, such as: - "direction,endpoint,clusterId,attributeId,mask,mfgCode,minmax" -The string above is a default value, and it determines in what order are the fields generated.

    -
    -
    collectAttributes()
    -

    Attribute collection works like this: - 1.) Go over all the clusters that exist. - 2.) If client is included on at least one endpoint add client atts. - 3.) If server is included on at least one endpoint add server atts.

    -
    -
    collectAttributeSizes(db, zclPackageIds, endpointTypes) ⇒
    -

    This function goes over all the attributes and populates sizes.

    -
    -
    collectAttributeTypeInfo(db, zclPackageIds, endpointTypes) ⇒
    -

    This function goes over all attributes and populates atomic types.

    -
    -
    endpoint_config(options) ⇒
    -

    Starts the endpoint configuration block., -longDefaults: longDefaults

    -
    -
    ifFuture(options)
    -

    Block helper resolving the block if the -value of the specified future matches.

    -
    -
    setFuture(options)
    -

    This method sets the value of the future. -Use it as: - {{set_future name="NAME" value="VALUE"}}

    -
    -
    future(options)
    -

    This method defines the future with a given name. -Use it as: {{future name="NAME"}}

    -
    -
    tokens_context()
    -

    This function builds creates a new context from the endpoint_config structure - for use in the zap-tokens.h template. The endpoint_config context provides a - list of endpoints, and endpointTypes, where each endpointType contains a list - of clusters, and each cluster contains a list of attributes. However, the - tokens template requires a list of attributes per endpoint, and per cluster, - discriminating from singletons and non-singletons, so this function performs - the required grouping.

    -

    While each attribute contains an isSingleton attribute, the database schema - allows for the same attribute to be returned both as singleton and non-singleton - in different clusters, for different endpoints. In consequence, care must be - taken to remove the singletons from the cluster and endpoint attribute lists. - This is done in two steps, the first loop creates a global (context) list of - singletons and non-singletons, and the second loop removes the singletons from - the endpoint, and clusters.

    -

    Clusters from different endpoints may have different attributes, therefore each - endpoint keeps a separate list of clusters. Additionally, a context-level - map of clusters is required in order to gather all attributes (singletons and - non-singletons) from all endpoint clusters.

    -
    -
    token_next()
    -

    The token template assigns an unique ID to each unique attribute. These IDs - span all attributes from all clusters from all endpointTypes. This helper - function allows the template to increment the token ID within the tokens context.

    -
    -
    token_attribute_util(context, options) ⇒
    -

    Util function that extracts all the token attribute information.

    -
    -
    token_attributes(endpointTypeRef, options) ⇒
    -

    Get information about all the token attributes in the configuration or this -helper can be used within an endpoint block helper to fetch the -corresponding token attributes based on endpoint type given. -Available Options: -isSingleton: 0/1, option can be used to filter attributes based on singleton -or non-singleton(Available with endpointTypeRef only)

    -
    -
    token_attribute_clusters(endpointTypeRef, options) ⇒
    -

    This helper can return all token associated clusters across endpoints or -this helper can be used within an endpoint block helper to fetch the -corresponding token associated clusters. -Available Options: -isSingleton: 0/1, option can be used to filter clusters based on singleton -or non-singleton attributes.

    -
    -
    token_attribute_endpoints(options) ⇒
    -

    Get all endpoints which have token attributes in the configuration. -AvailableOptions:

    - -
    -
    get_cli_size(size, type, allowZclTypes) ⇒
    -
    -
    zcl_command_argument_type_to_cli_data_type_util(type, cliPrefix, context, options) ⇒
    -
    -
    zcl_command_argument_type_to_cli_data_type(typeName, options)
    -

    Helper that deals with the type of the argument.

    -
    -
    zcl_command_argument_type_to_zcl_cli_data_type(typeName, options)
    -

    Helper that deals with the type of the argument.

    -
    -
    integrationEnabled(db, sessionId) ⇒
    -

    Boolean deciding whether Studio integration logic should be enabled

    -
    -
    isComponentTogglingDisabled(db, sessionId) ⇒
    -

    Resolves into true if user has actively disabled the component toggling. -By default this row doesn't even exist in the DB, but if user toggles -the toggle to turn this off, then the "disableComponentToggling" will -be set so '1' in the database.

    -
    -
    restApiUrl(api, path, queryParams) ⇒
    -

    Studio REST API path helper/generator

    -
    -
    wsApiUrl(api, path, queryParams) ⇒
    -

    Studio WebSocket API path helper/generator

    -
    -
    getProjectInfo(db, sessionId) ⇒
    -

    Send HTTP GET request to Studio Jetty server for project information.

    -
    -
    updateComponentByClusterIdAndComponentId(project, componentIds, add, db, sessionId, side) ⇒ *
    -

    Send HTTP Post to update UC component state in Studio

    -
    -
    updateComponentByComponentIds(project, componentIds, add) ⇒ *
    -

    Send HTTP Post to update UC component state in Studio

    -
    -
    wsMessageHandler(db, session, message)
    -

    Handles WebSocket messages from Studio server

    -
    -
    initIdeIntegration()
    -

    Start the dirty flag reporting interval.

    -
    -
    verifyWsConnection(db, sessionId)
    -

    Check WebSocket connections between backend and Studio jetty server. -If project is opened, verify connection is open. -If project is closed, close ws connection as well.

    -
    -
    wsConnect(sessionId, path) ⇒
    -

    Utility function for making websocket connection to Studio server

    -
    -
    isProjectActive(path)
    -

    Check if a specific Studio project (.slcp) file has been opened or not.

    -

    Context: To get proper WebSocket notification for change in project states, - that specific project needs to be opened already. Otherwise, no notification - will happen.

    -
         DependsComponent API used as a quick way to check if the project is opened or not
    -     If project is open/valid, the API will respond with "Component not found in project"
    -     Otherwise, "Project does not exists"
    -
    -
    -
    deinitIdeIntegration()
    -

    Clears up the reporting interval.

    -
    -
    sendSessionCreationErrorStatus(err)
    -

    Notify front-end that current session failed to load.

    -
    -
    sendComponentUpdateStatus(err)
    -

    Notify front-end that current session failed to load.

    -
    -
    exportEndpointTypes(db, sessionId) ⇒
    -

    Resolves to an array of endpoint types.

    -
    -
    exportSessionPackages(db, sessionId)
    -

    Resolves with data for packages.

    -
    -
    exportDataIntoFile(db, sessionId, filePath) ⇒
    -

    Toplevel file that takes a given session ID and exports the data into the file

    -
    -
    createStateFromDatabase(db, sessionId) ⇒
    -

    Given a database and a session id, this method returns a promise that -resolves with a state object that needs to be saved into a file.

    -
    -
    convertToFile(state, fileFormat)
    -

    This function gets the state from database and converts it for a given file format.

    -
    -
    updateCommands(cluster, clusterToCommandMap) ⇒
    -

    Updates the clusters with the new command format where there is isIncoming -and isEnabled instead of incoming and outgoing

    -
    -
    convertFromFile()
    -

    This function gets the JSON from the file, and converts it to the correct database state

    -
    -
    locateAttribute(state)
    -

    Locates or adds an attribute, and returns it. -at contains clusterId, attributeId, isClient, mfgCode and possibly value

    -
    -
    parseAttribute(attributeString, [value])
    -

    Parses attribute string in a form: - cl:0xABCD, at:0xABCD, di: [client|server], mf:0xABCD

    -
    -
    parseZclAfv2Line(state, line)
    -

    Logic that parses data out of an ISC file into a java object

    -
    -
    parseZclCustomizer(state, line)
    -

    Function that deals with the zcl customizer data inside the ISC file

    -
    -
    readIscData(filePath, data) ⇒
    -

    Toplevel parser that ignore anything except the two setups that are -ZCL relevant.

    -
    -
    loadEndpointType(db, sessionId, zclPackages, endpointType)
    -

    Load individual endpoint types.

    -
    -
    loadImplementedCommandsForEndpoint(db, zclPackageId, state, commandExtensions, endpointTypeId)
    -

    Loads all implemented commands for a single endpoint.

    -
    -
    loadImplementedCommandsExtensions(db, zclPackageId, state, commandExtensions, endpointTypeIdArray)
    -

    This method goes over the endpoint type and the state, and enables -commands that belong to enabled clusters and are listed in the -commandExtensions as "implemented".

    -
    -
    loadCommands(db, state, sessionId)
    -

    This method resolves promises that contain all the -queries that are needed to load the attribute state

    -
    -
    loadAttributes(db, state, sessionId)
    -

    This method resolves promises that contain all the -queries that are needed to load the attribute state

    -
    -
    loadSessionKeyValues(db, sessionId, keyValues)
    -

    Loads the session key values from the keyValues object

    -
    -
    iscDataLoader(db, state, sessionId)
    -

    Function that actually loads the data out of a state object. -Session at this point is blank, and has no packages.

    -
    -
    importSessionKeyValues(db, sessionId, keyValuePairs)
    -

    Resolves with a promise that imports session key values.

    -
    -
    autoLoadPackage(db, pkg, absPath) ⇒
    -

    Auto-load package. If succesful it returns an object. -Otherwise it throws an exception.

    -
    -
    importSinglePackage(db, pkg, zapFilePath, packageMatch, defaultZclMetafile, defaultTemplateFile) ⇒
    -

    Resolves into a { packageId:, packageType:} -object, pkg haspath, version, type. It can ALSO have pathRelativity. If pathRelativity is missing -path is considered absolute.

    -
    -
    convertPackageResult(data) ⇒
    -

    Convert the array of results into a more palatable value. -Resolves an array of { packageId:, packageType:} objects into { zclPackageId: id, templateIds: [] }

    -
    -
    importPackages(db, packages, zapFilePath, packageMatch, defaultZclMetafile, defaultTemplateFile) ⇒
    -
    -
    sortEndpoints(endpoints) ⇒
    -

    Sorts the list of endpoints

    -
    -
    importClusters(db, allZclPackageIds, endpointTypeId, clusters)
    -

    Imports the clusters for an endpoint type along with attributes, commands -and events

    -
    -
    importCommands(db, allZclPackageIds, endpointTypeId, endpointClusterId, commands)
    -

    Imports the list of commands from a cluster

    -
    -
    importAttributes(db, allZclPackageIds, endpointTypeId, endpointClusterId, attributes, cluster)
    -

    Imports the list of attributes from a cluster

    -
    -
    importEvents(db, allZclPackageIds, endpointClusterId, events)
    -

    Imports the list of events from a cluster

    -
    -
    getMandatoryClusterAttributes(db, epc, cluster, allZclPackageIds) ⇒
    -

    Retrieves the mandatory attributes of a cluster

    -
    -
    getMandatoryClusterCommands(db, epc, cluster, allZclPackageIds) ⇒
    -

    Retrieves the mandatory commands of a cluster

    -
    -
    clusterComplianceForAttributes(db, sessionId, endpointTypeAttributes, allMandatoryAttributes, endpointId, clusterSpecCheckComplianceMessage, specMessageIndent) ⇒
    -

    Adds cluster compliance warnings for attributes to the console and the -session notification table

    -
    -
    clusterComplianceForCommands(db, sessionId, endpointTypeCommands, allMandatoryCommands, endpointId, clusterSpecCheckComplianceMessage, specMessageIndent) ⇒
    -

    Adds cluster compliance warnings for commands to the console and the -session notification table

    -
    -
    deviceTypeClustersAttributesAndCommands(db, endpointTypeId) ⇒
    -

    Retrieves deviceTypeClustersOnEndpointType, deviceTypeAttributesOnEndpointType -and deviceTypeCommandsOnEndpointType for an endpoint type

    -
    -
    deviceTypeClusterToFeatureBits(deviceTypeFeaturesOnEndpointType) ⇒
    -
    -
    deviceTypeComplianceForClusters(db, endpointId, sessionId, deviceTypeClustersOnEndpointType, endpointTypeClusterRefMap, deviceTypeSpecCheckComplianceMessage, specMessageIndent) ⇒
    -

    Adds device type compliance warnings for clusters to the console and the -session notification table

    -
    -
    deviceTypeComplianceForAttributes(db, endpointId, sessionId, deviceTypeAttributesOnEndpointType, endpointTypeAttributeRefMap, deviceTypeSpecCheckComplianceMessage, specMessageIndent) ⇒
    -

    Adds device type compliance warnings for attributes to the console and the -session notification table

    -
    -
    deviceTypeComplianceForCommands(db, endpointId, sessionId, deviceTypeCommandsOnEndpointType, endpointTypeCommandRefMap, deviceTypeSpecCheckComplianceMessage, specMessageIndent) ⇒
    -

    Adds device type compliance warnings for commands to the console and the -session notification table

    -
    -
    importEndpointTypes(db, sessionId, allZclPackageIds, endpointTypes, endpoints)
    -

    Import endpointTypes

    -
    -
    jsonDataLoader(db, state, sessionId, packageMatch, defaultZclMetafile, defaultTemplateFile) ⇒
    -

    Given a state object, this method returns a promise that resolves -with the succesfull writing into the database.

    -
    -
    readJsonData(filePath, data, defaultZclMetafile, defaultTemplateFile) ⇒
    -

    Parses JSON file and creates a state object out of it, which is passed further down the chain.

    -
    -
    readDataFromFile(filePath, defaultZclMetafile, defaultTemplateFile) ⇒
    -

    Reads the data from the file and resolves with the state object if all is good.

    -
    -
    importDataFromFile(db, filePath) ⇒
    -

    Writes the data from the file into a new session. -NOTE: This function does NOT initialize session packages.

    -
    -
    initSessionTimers()
    -

    Start session specific validation.

    -
    -
    deinitSessionTimers(db, session)
    -

    Deinitalize all validation timers associated with a specific session.

    -
    -
    startNormal(uiEnabled, showUrl, uiMode, zapFiles)
    -

    Start up application in a normal mode.

    -
    -
    outputFile(inputFile, outputPattern) ⇒
    -

    Returns the output file out of input file and a pattern

    -
    -
    gatherFiles(filesArg, options)
    -

    This method gathers all the files to process.

    -
    -
    startConvert(files, output)
    -

    Perform file conversion.

    -
    -
    startRegenerateSdk(argv, options)
    -

    Performs a full SDK regeneration.

    -
    -
    startAnalyze(paths, [options])
    -

    Perform file analysis.

    -
    -
    startServer(options) ⇒
    -

    Starts zap in a server mode.

    -
    -
    startSelfCheck()
    -

    Start up applicationa in self-check mode.

    -
    -
    startGeneration() ⇒
    -

    Performs headless regeneration for given parameters.

    -
    -
    clearDatabaseFile(path)
    -

    Move database file out of the way into the backup location.

    -
    -
    shutdown()
    -

    Shuts down any servers that might be running.

    -
    -
    startUpSecondaryInstance(argv)
    -

    Startup method for the secondary instance.

    -
    -
    startUpMainInstance(quitFunction, argv)
    -

    Default startup method.

    -
    -
    start(expirationInterval, triggerFunction)
    -

    Starts a zap watchdog.

    -
    -
    reset()
    -

    Resets a zap watchdog.

    -
    -
    getForcedExternalStorage(db, packageIds) ⇒ Promise.<Array>
    -

    Fetches forced external storage settings based on the given package ID. -Utilizes the attribute access interface to query storage policies -associated with the specified package ID.

    -
    -
    computeStoragePolicyForGlobalAttributes(db, clusterId, attributes, packageId) ⇒
    -

    This function takes a clusterId (the database ID, not the specification-defined ID), an array of attributes (associated with the database defined clusterID), -and a packageId to identify the specific package the attributes belong to. It changes the global attributes (attributes with specification defined clusterId = null) to represent storage policy -based on the cluster/attribute pair in zcl.json.

    -

    Although the specification defined clusterID of the attribute is null indicating it is a global attribute, we know what the database defined clusterID is by what is passed in as a parameter.

    -

    That database defined clusterID is used to query the name of the cluster which is in turn used to compute the storage policy for that cluster/attribute pair based on the packageId.

    -
    -
    computeStorageOptionNewConfig(storagePolicy)
    -

    This asynchronous function computes and returns the new configuration for a storage option.

    -
    -
    computeStoragePolicyNewConfig(db, clusterRef, storagePolicy, forcedExternal, attributeName)
    -

    This asynchronous function computes and returns the new configuration for a storage policy.

    -
    -
    computeStorageImport(db, clusterName, storagePolicy, forcedExternal, attributeName)
    -

    This asynchronous function computes and returns the updated storage import policy.

    -
    -
    socketPath()
    -

    Returns the socket path for the IPC.

    -
    -
    preHandler()
    -

    Runs just before every time IPC request is processed.

    -
    -
    initServer(options)
    -

    IPC initialization.

    -
    -
    isServerRunning() ⇒
    -

    Returns true if server is running.

    -
    -
    shutdownServerSync(isServer)
    -

    Shuts down the IPC server.

    -
    -
    createOrShowAboutWindow(port)
    -

    Call this function to create a new or show an existing preference window.

    -
    -
    hookMainInstanceEvents()
    -

    Hook up all the events for the electron app object.

    -
    -
    doOpen(menuItem, browserWindow, event)
    -

    Perform a file->open operation.

    -
    -
    doSave(browserWindow)
    -

    Perform a save, defering to save as if file is not yet selected.

    -
    -
    doSaveAs(menuItem, browserWindow, event)
    -

    Perform save as.

    -
    -
    fileSave(db, browserWindow, filePath) ⇒
    -

    perform the save.

    -
    -
    fileOpen(db, filePaths)
    -

    Perform the do open action, possibly reading in multiple files.

    -
    -
    toggleMenu(port)
    -

    Toggling of menu

    -
    -
    initMenu(httpPort)
    -

    Initial menu show.

    -
    -
    showErrorMessage(title, err)
    -

    Simple dialog to show error messages from electron renderer scope.

    -
    -
    openFileConfiguration(db, filePath, httpPort)
    -

    Process a single file, parsing it in as JSON and then possibly opening -a new window if all is good.

    -
    -
    openNewConfiguration(httpPort, options:)
    -

    Creates a new window with a blank configuration.

    -
    -
    toggleDirtyFlag(browserWindow, dirty)
    -

    Toggles the dirty flag.

    -
    -
    openFileDialogAndReportResult(browserWindow, options)
    -

    This function should be invoked as a result of the fileBrowse -notification via the renderer API. It pops the open dialog and -reports result back through the API.

    -
    -
    initializeElectronUi(port)
    -

    Electron UI initialization.

    -

    Note: You might be tempted to pass db to this function. Don't. -That was done before and it's just a lazy way to cut through the -layers between UI and back-end. Should not be done. Any information -UI needs from the database should be retrieved via renderer API.

    -
    -
    windowCreate(port, filePath, [uiMode]) ⇒
    -

    Create a window, possibly with a given file path.

    -
    -
    processCommandLineArguments(argv) ⇒
    -

    Process the command line arguments and resets the state in this file -to the specified values.

    -
    -
    int8ToHex(value) ⇒
    -

    Takes an int8 value and turns it into a hex.

    -
    -
    int16ToHex(value) ⇒
    -

    Takes an int16 value and turns it into a hex.

    -
    -
    int32ToHex(value) ⇒
    -

    Takes an int32 value and turns it into a hex.

    -
    -
    stringToHex(value) ⇒
    -

    Converts a string to the hex value.

    -
    -
    bitCount(n) ⇒
    -

    Given a number, this function returns the number of bits set in the number

    -
    -
    hexToCBytes(value) ⇒
    -

    Takes the raw hex string, such as abcd and -converts it into a C constant array, such as -0xAB, 0xCD.

    -
    -
    bitOffset(binary)
    -

    Getting a binary string ("0001101010010") it returns the number of zero bits at the end.

    -
    -
    hexToBinary(hex)
    -

    Convert a hex number to a binary. Hex has to be in a format -as obtained by intToHex methods above: no '0x' prefix and upper-case -letters, as in "12AB".

    -
    -
    stringToOneByteLengthPrefixCBytes(value, maxLength, pad) ⇒
    -

    Returns string as C bytes, prefixed with one-byte length. -If maxLength is greater than length of value, then -the resulting array is padded with 0x00.

    -
    -
    stringToTwoByteLengthPrefixCBytes(value, maxLength, pad) ⇒
    -

    Returns string as C bytes, prefixed with two-byte length -If maxLength is greater than length of value, then -the resulting array is padded with 0x00.

    -
    -
    builtinSilabsZclMetafile() ⇒
    -
    -
    builtinSilabsZclSpecialMetafile() ⇒
    -

    Used to retrive zcl-special.json by zcl reload test in zcl-loader.test.js

    -
    -
    builtinSilabsZclGeneralXmlFile() ⇒
    -
    -
    builtinSilabsSpecialZclGeneralSpecialXmlFile() ⇒
    -

    Used to retrive general-special.xml by zcl reload test in zcl-loader.test.js

    -
    -
    setAppDirectory(path)
    -

    Set the state directory. This method is intended to be called -only at the application startup, when CLI args are being parsed. -This method honors '~/' being the first characters in its argument.

    -
    -
    appDirectory() ⇒
    -

    Returns an app directory. It creates it, if it doesn't exist

    -
    -
    zapVersionAsString()
    -

    Returns a version as a single on-line string.

    -
    -
    locateProjectResource(filePath) ⇒
    -

    This function locates a resource in the project, such as various -JSON files and zcl-builtin stuff.

    -

    It needs to adapt to a change in path that can occur when -things are copied into the dist/ directory.

    -
    -
    zapVersion() ⇒
    -

    Returns the zap version.

    -
    -
    printToStderr(msg)
    -

    Prints the data to stderr, without much fuss.

    -
    -
    log(level, msg, err)
    -

    Base level common logger.

    -
    -
    logInfo(msg, err)
    -

    Info level message.

    -
    -
    logError(msg, err)
    -

    Error level message.

    -
    -
    logWarning(msg, err)
    -

    Warning level message.

    -
    -
    logSql(msg, err)
    -

    Sql level message.

    -
    -
    logBrowser(msg, err)
    -

    Browser level message.

    -
    -
    logIpc(msg, err)
    -

    IPC level message.

    -
    -
    logDebug(msg, err)
    -

    Debug level message.

    -
    -
    versionsCheck() ⇒
    -

    Returns true if versions of node and electron are matching. -If versions are not matching, it prints out a warhing -and returns false.

    -
    -
    httpStaticContent() ⇒
    -

    Returns path to HTTP static content while taking into account DEV / PROD modes.

    -
    -
    availableClusters(context) ⇒
    -

    Returns all available clusters.

    -
    -
    availableEvents(context) ⇒
    -

    Returns all available events.

    -
    -
    availableCommands(context) ⇒
    -

    Returns all available commands.

    -
    -
    availableAttributes(context) ⇒
    -

    Returns all available attributes.

    -
    -
    helperWrapper(wrappedHelper) ⇒ function
    -

    Wraps a helper function to add usage tracking and error handling.

    -
    -
    registerHelpers(singleHelper, registerHelper, context)
    -

    Registers a helper function.

    -
    -
    executeHelperFunction(functionName, context, helper) ⇒ Promise
    -

    Executes a helper function from a script file.

    -
    -
    all_user_cluster_commands_helper()
    -

    Helper for add_user_cluster_commands that does all the work except the -collectBlocks. This allows other iterators to further filter the list -before doing collectBlocks.

    -
    -
    executeScriptFunction(functionName, db, sessionId, script)
    -

    Executes a named function from a given script. -Arguments passed to the function are: - api: which is the result of require('script-api.js') - context: which contains 'db', 'sessionId', etc.

    -
    -
    projectName(db, sessionId) ⇒
    -

    Extract project name from the Studio project path

    -
    -
    initAsyncValidation()
    -

    Start session specific validation.

    -
    -
    validateAttribute(db, endpointTypeId, attributeRef, clusterRef, zapSessionId) ⇒
    -

    Main attribute validation function. -Returns a promise of an object which stores a list of validational issues. -Such issues as "Invalid type" or "Out of Range".

    -
    -
    validateSpecificAttribute(endpointAttribute, attribute, db, zapSessionId) ⇒
    -

    Checks the attributes type then validates the incoming input string.

    -
    -
    extractIntegerValue(value) ⇒
    -

    Expects a number string , parse it back on a default base 10 if its a decimal. -If its a hexadecimal or anything else , parse it back on base 16. -Loses precision after javascripts Number.MAX_SAFE_INTEGER range.

    -
    -
    unsignedToSignedInteger(value, typeSize) ⇒
    -

    Converts an unsigned integer to its signed value. Returns the same integer if its not a signed type. -Works for both BigInts and regular numbers.

    -
    -
    getIntegerFromAttribute(attribute, typeSize, isSigned) ⇒
    -

    Converts an attribute (number string) into a decimal number without losing precision. -Accepts both decimal and hexadecimal strings (former has priority) in any bit representation. -Shifts signed hexadecimals to their correct value.

    -
    -
    getIntegerAttributeSize(db, zapSessionId, attribType) ⇒ *
    -

    Returns information about an integer type.

    -
    -
    checkAttributeBoundsInteger(attribute, endpointAttribute, db, zapSessionId) ⇒
    -

    Checks if the incoming integer is within it's attributes bound while handling signed and unsigned cases.

    -
    -
    collectDataFromLibraryXml(ctx) ⇒
    -

    Promises to read the properties file, extract all the actual xml files, and resolve with the array of files.

    -
    -
    parseZclFiles(db, ctx) ⇒
    -

    Promises to iterate over all the XML files and returns an aggregate promise -that will be resolved when all the XML files are done, or rejected if at least one fails.

    -
    -
    normalizeHexValue(value) ⇒
    -

    The Dotdot ZCL XML doesn't use the 0x prefix, but it's a nice thing to have and Silabs xml -does use this so this helper function normalizes the use of hex

    -

    TODO: Is this the right thing to do?

    -
    -
    getNumBytesFromShortName(value) ⇒
    -

    The Dotdot ZCL XML doesn't have a length but it is embedded in the short name, -we can scrape the value to get the size

    -

    TODO: Is this the right thing to do?

    -
    -
    prepareAttributes(attributes, side) ⇒
    -

    Prepare XML attributes for entry into the DB

    -
    -
    prepareCommands(commands, side, types) ⇒
    -

    Prepare XML commands for entry into the DB

    -
    -
    prepareCluster(cluster, isExtension, types) ⇒
    -

    Prepare XML cluster for insertion into the database. -This method can also prepare clusterExtensions.

    -
    -
    prepareAtomic(type) ⇒
    -

    Parses xml type into the atomic object for insertion into the DB

    -
    -
    prepareBitmap(type, isContained) ⇒
    -

    Parses xml type into the bitmap object for insertion into the DB

    -
    -
    prepareEnum(type) ⇒
    -

    Parses xml type into the enum object for insertion into the DB

    -
    -
    prepareStruct(type) ⇒
    -

    Parses xml type into the struct object for insertion into the DB

    -
    -
    prepareTypes(zclTypes, types)
    -

    Parses xml types into the types object for insertion into the DB

    -
    -
    prepareAttributeType(attribute, types, cluster)
    -

    Parses xml types into the types object for insertion into the DB

    -
    -
    prepareDeviceType(deviceType) ⇒
    -

    Preparation step for the device types.

    -
    -
    prepareDataTypeDiscriminator(a) ⇒
    -

    Prepare Data Type Discriminator for database table insertion.

    -
    -
    processDataTypeDiscriminator(db, packageId, zclDataTypes) ⇒
    -

    Processes Data Type Discriminator.

    -
    -
    prepareDataType(a, dataType, typeMap) ⇒
    -

    Prepare Data Types for database table insertion.

    -
    -
    processDataType(db, filePath, packageId, data, dataType) ⇒
    -

    Processes Data Type.

    -
    -
    prepareNumber(a, dataType) ⇒
    -

    Prepare numbers for database table insertion.

    -
    -
    processNumber(db, filePath, packageId, data) ⇒
    -

    Processes Numbers.

    -
    -
    prepareString(a, dataType) ⇒
    -

    Prepare strings for database table insertion.

    -
    -
    processString(db, filePath, packageId, data) ⇒
    -

    Processes Strings.

    -
    -
    prepareEnumsOrBitmaps(a, dataType) ⇒
    -

    Prepare enums or bitmaps for database table insertion.

    -
    -
    processEnums(db, filePath, packageId, data) ⇒
    -

    Processes the enums.

    -
    -
    processEnumItems(db, filePath, packageId, data) ⇒
    -

    Processes the enum Items.

    -
    -
    processBitmaps(db, filePath, packageId, data) ⇒
    -

    Processes the bitmaps.

    -
    -
    processBitmapFields(db, filePath, packageId, data) ⇒
    -

    Processes the bitmap fields.

    -
    -
    prepareStruct2(a, dataType) ⇒
    -

    Prepare structs for database table insertion.

    -
    -
    processStruct(db, filePath, packageId, data) ⇒
    -

    Processes the structs.

    -
    -
    processStructItems(db, filePath, packageId, data) ⇒
    -

    Processes the struct Items.

    -
    -
    prepareEnumsOrBitmapsAtomic(a, dataType) ⇒
    -

    Prepare enums or bitmaps for database table insertion.

    -
    -
    processEnumsFromAtomics(db, filePath, packageId, data) ⇒
    -

    Processes the enums.

    -
    -
    processBitmapsFromAtomics(db, filePath, packageId, data) ⇒
    -

    Processes the bitmaps.

    -
    -
    loadZclData(db, ctx) ⇒
    -

    Promises to iterate over all the XML files and returns an aggregate promise -that will be resolved when all the XML files are done, or rejected if at least one fails.

    -
    -
    loadIndividualDotDotFile(db, filePath) ⇒ *
    -

    TODO This is not supported at this time.

    -
    -
    loadToplevelXmlFile(db, ctx) ⇒
    -

    Toplevel function that loads the xml library file -and orchestrates the promise chain.

    -
    -
    parseNewXmlFiles(db, packageId, files, context) ⇒
    -

    Parses the new XML files. Returns an object containing -loaded data: - clusterIdsLoaded: array of cluster ids that were loaded

    -
    -
    collectDataFromJsonFile(ctx) ⇒
    -

    Promises to read the JSON file and resolve all the data.

    -
    -
    collectDataFromPropertiesFile(ctx) ⇒
    -

    Promises to read the properties file, extract all the actual xml files, and resolve with the array of files.

    -
    -
    maskToType(mask) ⇒
    -

    Silabs XML does not carry types with bitmap fields, but dotdot does, so they are in the schema. -Just to put some data in, we differentiate between "bool" and "enum" types here.

    -
    -
    prepareAtomic(a)
    -

    Prepare atomic to db insertion.

    -
    -
    processAtomics(db, filePath, packageId, data) ⇒
    -

    Processes atomic types for DB insertion.

    -
    -
    prepareClusterGlobalAttribute(cluster) ⇒
    -

    Prepares global attribute data.

    -
    -
    prepareCluster(cluster) ⇒
    -

    Prepare XML cluster for insertion into the database. -This method can also prepare clusterExtensions.

    -
    -
    processClusters(db, filePath, packageId, data) ⇒
    -

    Process clusters for insertion into the database.

    -
    -
    processClusterGlobalAttributes(db, filePath, packageId, data) ⇒
    -

    Processes global attributes for insertion into the database.

    -
    -
    processClusterExtensions(db, filePath, packageId, data) ⇒
    -

    Cluster Extension contains attributes and commands in a same way as regular cluster, -and it has an attribute code="0xXYZ" where code is a cluster code.

    -
    -
    processGlobals(db, filePath, packageId, data) ⇒
    -

    Processes the globals in the XML files. The global tag contains -attributes and commands in a same way as cluster or clusterExtension

    -
    -
    processDefaultAccess(db, filePath, packageId, defaultAccessList)
    -

    Process defaultAccess tag in the XML.

    -
    -
    processAccessControl(db, filePath, packageId, accessControlList)
    -

    Process accessControl tag in the XML.

    -
    -
    processTags(db, filePath, packageId, tags)
    -

    Processes the tags in the XML.

    -
    -
    prepareDomain(domain) ⇒
    -

    Convert domain from XMl to domain for DB.

    -
    -
    processDomains(db, filePath, packageId, data) ⇒
    -

    Process domains for insertion.

    -
    -
    prepareDataTypeDiscriminator(a) ⇒
    -

    Prepare Data Type Discriminator for database table insertion.

    -
    -
    processDataTypeDiscriminator(db, filePath, zclDataTypes) ⇒
    -

    Processes Data Type Discriminator.

    -
    -
    prepareDataType(a, dataType, typeMap) ⇒
    -

    Prepare Data Types for database table insertion.

    -
    -
    processDataType(db, filePath, packageId, knownPackages, data, dataType) ⇒
    -

    Processes Data Type.

    -
    -
    prepareNumber(a, dataType) ⇒
    -

    Prepare numbers for database table insertion.

    -
    -
    processNumber(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes Numbers.

    -
    -
    prepareString(a, dataType) ⇒
    -

    Prepare strings for database table insertion.

    -
    -
    processString(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes Strings.

    -
    -
    prepareEnumOrBitmapAtomic(a, dataType) ⇒
    -

    Prepare enums or bitmaps for database table insertion.

    -
    -
    processEnumAtomic(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes the enums.

    -
    -
    prepareEnumOrBitmap(a, dataType) ⇒
    -

    Prepare enums or bitmaps for database table insertion.

    -
    -
    processEnum(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes the enums.

    -
    -
    processEnumItems(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes the enum Items.

    -
    -
    processBitmapAtomic(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes the bitmaps.

    -
    -
    processBitmap(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes the bitmaps.

    -
    -
    processBitmapFields(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes the bitmap fields.

    -
    -
    prepareStruct(a, dataType) ⇒
    -

    Prepare structs for database table insertion.

    -
    -
    processStruct(db, filePath, packageId, knownPackages, data) ⇒
    -

    Processes the structs.

    -
    -
    processStructItems(db, filePath, packageIds, data) ⇒
    -

    Processes the struct Items.

    -
    -
    prepareDeviceType(deviceType) ⇒
    -

    Preparation step for the device types.

    -
    -
    processDeviceTypes(db, filePath, packageId, data, context) ⇒ Promise
    -

    Processes and inserts device types into the database. -This function logs the number of device types being processed for debugging purposes. -It maps over the provided data to prepare each device type and then iterates over each prepared device type. -If a device type has a compositionType, it inserts the endpoint composition into the database, -retrieves the endpoint composition ID, and then inserts the device composition. -Finally, it inserts all prepared device types into the database.

    -
    -
    processParsedZclData(db, argument) ⇒
    -

    After XML parser is done with the barebones parsing, this function -branches the individual toplevel tags.

    -
    -
    parseSingleZclFile(db, packageId, file) ⇒
    -

    This function is used for parsing each individual ZCL file at a grouped zcl file package level. -This should not be used for custom XML addition due to custom xmls potentially relying on existing packges.

    -
    -
    isCrcMismatchOrPackageDoesNotExist(db, packageId, files) ⇒
    -

    Checks if there is a crc mismatch on any xml file. This can be used to -decide if there is a need to reload all the xml files. Also check if the -package is not loaded before.

    -
    -
    parseZclFiles(db, packageId, zclFiles, context) ⇒
    -

    Promises to iterate over all the XML files and returns an aggregate promise -that will be resolved when all the XML files are done, or rejected if at least one fails.

    -
    -
    parseManufacturerData(db, ctx) ⇒
    -

    Parses the manufacturers xml.

    -
    -
    parseProfilesData(db, ctx) ⇒
    -

    Parses the profiles xml.

    -
    -
    parseFeatureFlags(db, packageId, featureFlags) ⇒
    -

    Inside the zcl.json can be a featureFlags key, which is -a general purpose object. It contains keys, that map to objects. -Each key is a "package option category". -Key/velues of the object itself, end up in CODE/LABEL combinations.

    -
    -
    parseUiOptions(db, packageId, featureFlags) ⇒
    -

    Inside the zcl.json can be a featureFlags key, which is -a general purpose object. It contains keys, that map to objects. -Each key is a "package option category". -Key/velues of the object itself, end up in CODE/LABEL combinations.

    -
    -
    parseOptions(db) ⇒
    -

    Parses and loads the text and boolean options.

    -
    -
    parseTextOptions(db, pkgRef, textOptions) ⇒
    -

    Parses the text options.

    -
    -
    parseBoolOptions(db, pkgRef, booleanCategories) ⇒
    -

    Parses the boolean options.

    -
    -
    parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes) ⇒ Promise.<void>
    -

    Asynchronously parses and inserts attribute access interface attributes into the database. -This function iterates over the attributeAccessInterfaceAttributes object, processing each cluster -by mapping its values to a specific structure and then inserting them into the database using -the insertOptionsKeyValues function.

    -

    The main purpose of this function is to store cluster/attribute pairs including global attributes and their cluster pair -The ATTRIBUTE table has cluster_ref as null for global attributes so this second method was necessary

    -
    -
    parseDefaults(db, ctx) ⇒
    -

    Parses the default values inside the options.

    -
    -
    loadIndividualSilabsFile(db, filePath) ⇒
    -

    Parses a single file. This function is used specifically -for adding a package through an existing session because of its reliance -on relating the new XML content to the packages associated with that session. -e.g. for ClusterExtensions.

    -
    -
    processCustomZclDeviceType(db, ctx) ⇒
    -

    If custom device is supported, then this method creates it.

    -
    -
    loadZclJsonOrProperties(db, ctx) ⇒
    -

    Toplevel function that loads the toplevel metafile -and orchestrates the promise chain.

    -
    -
    recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync) ⇒
    -

    Records the toplevel package information and resolves into packageId

    -
    -
    recordVersion(db, ctx)
    -

    Records the version into the database.

    -
    -
    loadZclMetaFilesCommon(db, metadataFile, options) ⇒
    -

    Retrieve zcl package information

    -
    -
    loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap)
    -

    Load attribute mapping table if there is multi-protocol information from a json file.

    -
    -
    loadZclMetafiles(db, metadataFile) ⇒
    -

    Toplevel function that loads the zcl file and passes it off to the correct zcl loader.

    -
    -
    loadZcl(db, metadataFile) ⇒
    -

    Loads individual zcl.json metafile.

    -
    -
    loadIndividualFile(db, filePath, sessionId)
    -

    Load individual custom XML files.

    -
    -
    qualifyZclFile(db, info, parentPackageId, isCustom) ⇒
    -

    Promises to qualify whether zcl file needs to be reloaded. -If yes, the it will resolve with {filePath, data, packageId} -If not, then it will resolve with {error}

    -
    -
    processZclPostLoading(db) ⇒
    -

    Promises to perform a post loading step.

    -
    -
    getDiscriminatorMap(db, packageIds) ⇒
    -
    -
    +## DB API: External URLs. +This module provides common external URLs. + + + +## DB API: DB types and enums. +This module provides mappings between database columns and JS keys. + + + +## Renderer API: Renderer API. +This module provides Renderer API Exports. + + +* [Renderer API: Renderer API.](#module_Renderer API_ Renderer API.) + * [.GLOBAL_SYMBOL_INFO](#module_Renderer API_ Renderer API..GLOBAL_SYMBOL_INFO) + * [.GLOBAL_SYMBOL_EXECUTE](#module_Renderer API_ Renderer API..GLOBAL_SYMBOL_EXECUTE) + * [.GLOBAL_SYMBOL_NOTIFY](#module_Renderer API_ Renderer API..GLOBAL_SYMBOL_NOTIFY) + + + +### Renderer API: Renderer API..GLOBAL\_SYMBOL\_INFO +Global symbol that carries the API info metadata + +**Kind**: static property of [Renderer API: Renderer API.](#module_Renderer API_ Renderer API.) + + +### Renderer API: Renderer API..GLOBAL\_SYMBOL\_EXECUTE +Global function that can execute the APIs. + +**Kind**: static property of [Renderer API: Renderer API.](#module_Renderer API_ Renderer API.) + + +### Renderer API: Renderer API..GLOBAL\_SYMBOL\_NOTIFY +Global function that can be overloaded by jxbrowser for notifications + +**Kind**: static property of [Renderer API: Renderer API.](#module_Renderer API_ Renderer API.) + + +## REST API: REST API. +This module provides REST API Exports. + + + +## IPC Client API: Inter-process communication +This module provides IPC Client functionality. + + +* [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) + * [~log(msg)](#module_IPC Client API_ Inter-process communication..log) + * [~initAndConnectClient()](#module_IPC Client API_ Inter-process communication..initAndConnectClient) ⇒ + * [~on(eventType, handler)](#module_IPC Client API_ Inter-process communication..on) + * [~lastPongData()](#module_IPC Client API_ Inter-process communication..lastPongData) ⇒ + * [~isClientConnected()](#module_IPC Client API_ Inter-process communication..isClientConnected) ⇒ + * [~disconnectClient()](#module_IPC Client API_ Inter-process communication..disconnectClient) + * [~emit(key, object)](#module_IPC Client API_ Inter-process communication..emit) + + + +### IPC Client API: Inter-process communication~log(msg) +Log ipc client message + +**Kind**: inner method of [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) + +| Param | Type | +| --- | --- | +| msg | \* | + + + +### IPC Client API: Inter-process communication~initAndConnectClient() ⇒ +Initializes and connects a client. + +**Kind**: inner method of [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) +**Returns**: a promise which resolves when client connects + + +### IPC Client API: Inter-process communication~on(eventType, handler) +Register a handler for the event type. + +**Kind**: inner method of [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) + +| Param | Type | +| --- | --- | +| eventType | \* | +| handler | \* | + + + +### IPC Client API: Inter-process communication~lastPongData() ⇒ +Get the last pong data. + +**Kind**: inner method of [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) +**Returns**: last pong data or null if none is available + + +### IPC Client API: Inter-process communication~isClientConnected() ⇒ +Returns true if client is connected. + +**Kind**: inner method of [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) +**Returns**: true if client is connected + + +### IPC Client API: Inter-process communication~disconnectClient() +Disconnects a client asynchronously. + +**Kind**: inner method of [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) + + +### IPC Client API: Inter-process communication~emit(key, object) +Sends a message to server. + +**Kind**: inner method of [IPC Client API: Inter-process communication](#module_IPC Client API_ Inter-process communication) + +| Param | Type | +| --- | --- | +| key | \* | +| object | \* | + + + +## JS API: low level database access +This module provides generic DB functions for performing SQL queries. + + +* [JS API: low level database access](#module_JS API_ low level database access) + * [~executeBeginTransaction(db, resolve, reject)](#module_JS API_ low level database access..executeBeginTransaction) + * [~delayBeginTransaction(db, resolve, reject)](#module_JS API_ low level database access..delayBeginTransaction) + * [~dbBeginTransaction(db)](#module_JS API_ low level database access..dbBeginTransaction) ⇒ + * [~dbCommit(db)](#module_JS API_ low level database access..dbCommit) ⇒ + * [~isTransactionActive()](#module_JS API_ low level database access..isTransactionActive) ⇒ + * [~dbRollback(db)](#module_JS API_ low level database access..dbRollback) ⇒ + * [~dbRemove(db, query, args)](#module_JS API_ low level database access..dbRemove) ⇒ + * [~dbUpdate(db, query, args)](#module_JS API_ low level database access..dbUpdate) ⇒ + * [~dbInsert(db, query, args)](#module_JS API_ low level database access..dbInsert) ⇒ + * [~dbAll(db, query, args)](#module_JS API_ low level database access..dbAll) ⇒ + * [~dbGet(db, query, args)](#module_JS API_ low level database access..dbGet) ⇒ + * [~dbMultiSelect(db, sql, arrayOfArrays)](#module_JS API_ low level database access..dbMultiSelect) + * [~dbMultiInsert(db, sql, arrayOfArrays)](#module_JS API_ low level database access..dbMultiInsert) ⇒ + * [~closeDatabase(database)](#module_JS API_ low level database access..closeDatabase) ⇒ + * [~closeDatabaseSync(database)](#module_JS API_ low level database access..closeDatabaseSync) + * [~initRamDatabase()](#module_JS API_ low level database access..initRamDatabase) ⇒ + * [~initDatabase(sqlitePath)](#module_JS API_ low level database access..initDatabase) ⇒ + * [~insertOrReplaceSetting(db, version)](#module_JS API_ low level database access..insertOrReplaceSetting) ⇒ + * [~updateSetting(db, rows)](#module_JS API_ low level database access..updateSetting) ⇒ + * [~selectSettings(db)](#module_JS API_ low level database access..selectSettings) ⇒ + * [~determineIfSchemaShouldLoad(db, context)](#module_JS API_ low level database access..determineIfSchemaShouldLoad) ⇒ + * [~updateCurrentSchemaCrc(db, filePath, crc)](#module_JS API_ low level database access..updateCurrentSchemaCrc) ⇒ + * [~performSchemaLoad(db, schemaContent)](#module_JS API_ low level database access..performSchemaLoad) ⇒ + * [~loadSchema(db, schemaPath, zapVersion)](#module_JS API_ low level database access..loadSchema) ⇒ + * [~initDatabaseAndLoadSchema(sqliteFile, schemaFile, zapVersion)](#module_JS API_ low level database access..initDatabaseAndLoadSchema) ⇒ + * [~toDbBool(value)](#module_JS API_ low level database access..toDbBool) ⇒ + * [~fromDbBool(value)](#module_JS API_ low level database access..fromDbBool) ⇒ + * [~toInClause(value)](#module_JS API_ low level database access..toInClause) ⇒ + + + +### JS API: low level database access~executeBeginTransaction(db, resolve, reject) +Begin Database transaction. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) + +| Param | Type | +| --- | --- | +| db | \* | +| resolve | \* | +| reject | \* | + + + +### JS API: low level database access~delayBeginTransaction(db, resolve, reject) +Delay database transaction. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) + +| Param | Type | +| --- | --- | +| db | \* | +| resolve | \* | +| reject | \* | + + + +### JS API: low level database access~dbBeginTransaction(db) ⇒ +Returns a promise to begin a transaction. The beginning of the +transaction will be delayed for up to 5 seconds, checking every +1/10th of a second of previous transaction is already finished. + +After 5 seconds, the code gives up and rejects the promise. + +This is to allow simultaneous calls to this function, even though +SQLite does not allow for simultaneous transactions. + +So use transactions responsibly. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves without an argument and rejects with an error from BEGIN TRANSACTION query. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### JS API: low level database access~dbCommit(db) ⇒ +Returns a promise to execute a commit. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves without an argument or rejects with an error from COMMIT query. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### JS API: low level database access~isTransactionActive() ⇒ +Not an async function, simply returns a boolean value whether +there is a currently active transaction. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: true if transaction is active, false if not. + + +### JS API: low level database access~dbRollback(db) ⇒ +Returns a promise to execute a rollback of a transaction. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves without an argument or rejects with an error from ROLLBACK query. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### JS API: low level database access~dbRemove(db, query, args) ⇒ +Returns a promise to execute a DELETE FROM query. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolve with the number of delete rows, or rejects with an error from query. + +| Param | Type | +| --- | --- | +| db | \* | +| query | \* | +| args | \* | + + + +### JS API: low level database access~dbUpdate(db, query, args) ⇒ +Returns a promise to execute an update query. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with a number of changed rows, or rejects with an error from the query. + +| Param | Type | +| --- | --- | +| db | \* | +| query | \* | +| args | \* | + + + +### JS API: low level database access~dbInsert(db, query, args) ⇒ +Returns a promise to execute an insert query. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with the rowid from the inserted row, or rejects with an error from the query. + +| Param | Type | +| --- | --- | +| db | \* | +| query | \* | +| args | \* | + + + +### JS API: low level database access~dbAll(db, query, args) ⇒ +Returns a promise to execute a query to perform a select that returns all rows that match a query. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with the rows that got retrieved from the database, or rejects with an error from the query. + +| Param | Type | +| --- | --- | +| db | \* | +| query | \* | +| args | \* | + + + +### JS API: low level database access~dbGet(db, query, args) ⇒ +Returns a promise to execute a query to perform a select that returns first row that matches a query. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with a single row that got retrieved from the database, or rejects with an error from the query. + +| Param | Type | +| --- | --- | +| db | \* | +| query | \* | +| args | \* | + + + +### JS API: low level database access~dbMultiSelect(db, sql, arrayOfArrays) +Returns a promise to perform a prepared statement, using data from array for SQL parameters. +It resolves with an array of rows, containing the data, or rejects with an error. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) + +| Param | Type | +| --- | --- | +| db | \* | +| sql | \* | +| arrayOfArrays | \* | + + + +### JS API: low level database access~dbMultiInsert(db, sql, arrayOfArrays) ⇒ +Returns a promise to perfom a prepared statement, using data from array for SQL parameters. +It resolves with an array of rowids, or rejects with an error. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with the array of rowids for the rows that got inserted, or rejects with an error from the query. + +| Param | Type | +| --- | --- | +| db | \* | +| sql | \* | +| arrayOfArrays | \* | + + + +### JS API: low level database access~closeDatabase(database) ⇒ +Returns a promise that will resolve when the database in question is closed. +Rejects with an error if closing fails. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves without an argument or rejects with error from the database closing. + +| Param | Type | +| --- | --- | +| database | \* | + + + +### JS API: low level database access~closeDatabaseSync(database) +Imediatelly closes the database. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) + +| Param | Type | +| --- | --- | +| database | \* | + + + +### JS API: low level database access~initRamDatabase() ⇒ +Create in-memory database. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: Promise that resolve with the Db. + + +### JS API: low level database access~initDatabase(sqlitePath) ⇒ +Returns a promise to initialize a database. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with the database object that got created, or rejects with an error if something went wrong. + +| Param | Type | +| --- | --- | +| sqlitePath | \* | + + + +### JS API: low level database access~insertOrReplaceSetting(db, version) ⇒ +Returns a promise to insert or replace a setting into the database. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with a rowid of created setting row or rejects with error if something goes wrong. + +| Param | Type | +| --- | --- | +| db | \* | +| version | \* | + + + +### JS API: low level database access~updateSetting(db, rows) ⇒ +Updates SETTING table with values selected + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with the SETTING table being repopulated + +| Param | Type | +| --- | --- | +| db | \* | +| rows | \* | + + + +### JS API: low level database access~selectSettings(db) ⇒ +Returns a promise resolving the entire SETTING table + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise resolving the entire SETTING table + +| Param | Type | +| --- | --- | +| db | \* | + + + +### JS API: low level database access~determineIfSchemaShouldLoad(db, context) ⇒ +Checks the state of schema. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: object containing "mustLoad" and "hasSchema" elements. + +| Param | Type | +| --- | --- | +| db | \* | +| context | \* | + + + +### JS API: low level database access~updateCurrentSchemaCrc(db, filePath, crc) ⇒ +Update the CRC of the sql schema file. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: promise of insert transaction. + +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| crc | \* | + + + +### JS API: low level database access~performSchemaLoad(db, schemaContent) ⇒ +Load SQL Schema + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: Promise of loaded schema + +| Param | Type | +| --- | --- | +| db | \* | +| schemaContent | \* | + + + +### JS API: low level database access~loadSchema(db, schemaPath, zapVersion) ⇒ +Returns a promise to load schema into a blank database, and inserts a version to the settings table.j + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: A promise that resolves with the same db that got passed in, or rejects with an error. + +| Param | Type | +| --- | --- | +| db | \* | +| schemaPath | \* | +| zapVersion | \* | + + + +### JS API: low level database access~initDatabaseAndLoadSchema(sqliteFile, schemaFile, zapVersion) ⇒ +Init database and load the schema. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: Promise that resolves into the database object. + +| Param | Type | +| --- | --- | +| sqliteFile | \* | +| schemaFile | \* | +| zapVersion | \* | + + + +### JS API: low level database access~toDbBool(value) ⇒ +Returns the data that should be stored into the DB column, from the passed JS boolean. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: Value to be stored into the database. + +| Param | Type | +| --- | --- | +| value | \* | + + + +### JS API: low level database access~fromDbBool(value) ⇒ +Returns a true or false JS boolean from the value that was read in the database. + +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: value to be used in JS after reading value from database. + +| Param | Type | +| --- | --- | +| value | \* | + + + +### JS API: low level database access~toInClause(value) ⇒ +**Kind**: inner method of [JS API: low level database access](#module_JS API_ low level database access) +**Returns**: Given value in the form of string + +| Param | Type | +| --- | --- | +| value | \* | + + + +## DB API: zcl database access +This module provides cache for commonly used static database queries. + + +* [DB API: zcl database access](#module_DB API_ zcl database access) + * [~clear()](#module_DB API_ zcl database access..clear) + * [~put(key, packageId, data)](#module_DB API_ zcl database access..put) ⇒ + * [~get(key, packageId)](#module_DB API_ zcl database access..get) ⇒ + * [~isCached(key, packageId)](#module_DB API_ zcl database access..isCached) ⇒ + * [~cacheQuery(key, packageId)](#module_DB API_ zcl database access..cacheQuery) ⇒ + * [~cacheStats()](#module_DB API_ zcl database access..cacheStats) + * [~enable()](#module_DB API_ zcl database access..enable) + * [~disable()](#module_DB API_ zcl database access..disable) + * [~selectAllAtomics(db, packageId)](#module_DB API_ zcl database access..selectAllAtomics) ⇒ + * [~selectAtomicType(db, packageId, typeName)](#module_DB API_ zcl database access..selectAtomicType) + * [~selectAtomicById(db, packageId)](#module_DB API_ zcl database access..selectAtomicById) + * [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module_DB API_ zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> + * [~selectAllBitmaps(db)](#module_DB API_ zcl database access..selectAllBitmaps) ⇒ + * [~selectBitmapByName(db, packageIds, name)](#module_DB API_ zcl database access..selectBitmapByName) ⇒ + * [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectBitmapByNameAndClusterId) ⇒ + * [~selectBitmapById(db, id)](#module_DB API_ zcl database access..selectBitmapById) ⇒ + * [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module_DB API_ zcl database access..selectSessionClusterByCode) ⇒ + * [~selectAllSessionClusters(db, sessionId)](#module_DB API_ zcl database access..selectAllSessionClusters) ⇒ + * [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module_DB API_ zcl database access..selectSessionAttributeByCode) ⇒ + * [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module_DB API_ zcl database access..selectSessionCommandByCode) ⇒ + * [~selectAllStructs(db, packageId)](#module_DB API_ zcl database access..selectAllStructs) ⇒ + * [~selectStructById(db, id)](#module_DB API_ zcl database access..selectStructById) ⇒ + * [~selectStructByName(db, name, packageIds)](#module_DB API_ zcl database access..selectStructByName) ⇒ + * [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectStructByNameAndClusterId) ⇒ + * [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module_DB API_ zcl database access..selectStructsWithClusterAssociation) ⇒ + * [~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds)](#module_DB API_ zcl database access..sqlQueryForDataTypeByNameAndClusterId) ⇒ + * [~selectClusterBitmaps(db, packageId, clusterId)](#module_DB API_ zcl database access..selectClusterBitmaps) ⇒ + * [~selectAllBitmapFieldsById(db, id)](#module_DB API_ zcl database access..selectAllBitmapFieldsById) ⇒ + * [~selectAllBitmapFields(db, packageId)](#module_DB API_ zcl database access..selectAllBitmapFields) ⇒ + * [~selectAllDomains(db)](#module_DB API_ zcl database access..selectAllDomains) ⇒ + * [~selectDomainById(db, id)](#module_DB API_ zcl database access..selectDomainById) ⇒ + * [~selectAllStructsWithItemCount(db, packageIds)](#module_DB API_ zcl database access..selectAllStructsWithItemCount) ⇒ + * [~selectStructClusters(db, structId)](#module_DB API_ zcl database access..selectStructClusters) ⇒ + * [~selectEnumClusters(db, enumId)](#module_DB API_ zcl database access..selectEnumClusters) ⇒ + * [~selectBitmapClusters(db, bitmapId)](#module_DB API_ zcl database access..selectBitmapClusters) ⇒ + * [~selectClusterStructsWithItems(db)](#module_DB API_ zcl database access..selectClusterStructsWithItems) ⇒ + * [~selectAllStructsWithItems(db)](#module_DB API_ zcl database access..selectAllStructsWithItems) ⇒ + * [~selectStructsWithItemsImpl(db, packageIds, clusterId)](#module_DB API_ zcl database access..selectStructsWithItemsImpl) ⇒ + * [~selectAllStructItemsById(db, id)](#module_DB API_ zcl database access..selectAllStructItemsById) ⇒ + * [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module_DB API_ zcl database access..selectAllStructItemsByStructName) ⇒ + * [~selectAllClusters(db)](#module_DB API_ zcl database access..selectAllClusters) ⇒ + * [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module_DB API_ zcl database access..selectClusterByCode) ⇒ + * [~selectClusterById(db, clusterId, packageId)](#module_DB API_ zcl database access..selectClusterById) ⇒ + * [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module_DB API_ zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ + * [~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side)](#module_DB API_ zcl database access..selectAttributesByClusterIdAndSideIncludingGlobal) ⇒ + * [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module_DB API_ zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ + * [~selectAttributeById(db, id)](#module_DB API_ zcl database access..selectAttributeById) ⇒ + * [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module_DB API_ zcl database access..selectAttributeByAttributeIdAndClusterRef) + * [~selectAllAttributes(db, packageIds)](#module_DB API_ zcl database access..selectAllAttributes) ⇒ + * [~selectAllAttributesBySide(db, side, packageId)](#module_DB API_ zcl database access..selectAllAttributesBySide) ⇒ + * [~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeClustersByEndpointTypeId) ⇒ + * [~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeAttributesByEndpointId) ⇒ + * [~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef)](#module_DB API_ zcl database access..selectEndpointTypeAttribute) ⇒ + * [~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeCommandsByEndpointId) ⇒ + * [~selectEndpointTypeEventsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeEventsByEndpointId) ⇒ + + + +### DB API: zcl database access~clear() +Clears the entire cache. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~put(key, packageId, data) ⇒ +Puts a data object into the cache under a given key/packageId + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Returns true on success. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl database access~get(key, packageId) ⇒ +Returns a data object under a given key/packageId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cached object or undefined if none is present or expired. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~isCached(key, packageId) ⇒ +Returns true if a given key/packageId cache exists. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~cacheQuery(key, packageId) ⇒ +Cache input / output of provided queryFunction +The queryFunction is assumed to have the following signature: + + async function queryFunction(db, ...) {...} + +The DB handle is ignored and the remaining arguments are used as the cache key. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~cacheStats() +Returns the cache statistics. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~enable() +Enable the Database Query cache + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~disable() +Disable the database cache + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~selectAllAtomics(db, packageId) ⇒ +Get all atomic data type information + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: atomic data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAtomicType(db, packageId, typeName) +Locates atomic type based on a type name. Query is not case sensitive. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| typeName | \* | + + + +### DB API: zcl database access~selectAtomicById(db, packageId) +Retrieves atomic type by a given Id. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> +Checks if a type by a given name is signed. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| name | string | The name of the type. | +| sessionPackages | Array | An array of session packages. | + + + +### DB API: zcl database access~selectAllBitmaps(db) ⇒ +Retrieves all the bitmaps in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of bitmaps. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectBitmapByName(db, packageIds, name) ⇒ +Get bitmap by name from the given package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of bitmap + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| name | \* | + + + +### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a bitmap matched by name and clusterId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: bitmap information or undefined + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectBitmapById(db, id) ⇒ +Get Bitmap information by Bitmap ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +Returns the cluster available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| code | \* | +| mfgCode | \* | + + + +### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +Returns all the clusters visible for a given session. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | + + + +### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +Returns the attribute available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| side | \* | +| attributeCode | \* | +| mfgCode | \* | + + + +### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +Returns the command available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| commandCode | \* | +| source | \* | + + + +### DB API: zcl database access~selectAllStructs(db, packageId) ⇒ +Get all structs from a given package ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Structs + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectStructById(db, id) ⇒ +Get struct details from the given struct ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectStructByName(db, name, packageIds) ⇒ +Get Struct details from the given struct name and package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a struct matched by name and clusterId + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct information or undefined + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +Get all structs which have a cluster associated with them. If a struct is +present in more than one cluster then it can be grouped by struct name to +avoid additional rows. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: structs which have an association with clusters + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| groupByStructName | \* | + + + +### DB API: zcl database access~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds) ⇒ +Formulate a sqlite query string for a data type from the given cluster ID and package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: SQLite query string + +| Param | Type | Default | +| --- | --- | --- | +| typeDiscriminator | \* | | +| clusterId | \* | | +| packageIds | \* | | + + + +### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +Retrieves all the bitmaps that are associated with a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster-related bitmaps + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllBitmapFieldsById(db, id) ⇒ +Get bitmap fields from the given bitmap ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllBitmapFields(db, packageId) ⇒ +Get all bitmap fields from the given package ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAllDomains(db) ⇒ +Retrieves all the domains in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of domains. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectDomainById(db, id) ⇒ +Get Domain details from the given domain ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of domain + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ +Retrieves all the structs in the database, including the count +of items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs. + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructClusters(db, structId) ⇒ +Returns an array of clusters that struct belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| structId | \* | + + + +### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ +Returns an array of clusters that enum belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| enumId | \* | + + + +### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ +Returns an array of clusters that bitmap belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| bitmapId | \* | + + + +### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ +Retrieves all the cluster-related structs in the database with the items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ +Retrieves all the structs in the database with the items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectStructsWithItemsImpl(db, packageIds, clusterId) ⇒ +Get Struct details along with its struct items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct details + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllStructItemsById(db, id) ⇒ +Get struct item details from the given struct item ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Stuct Items + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ +Retrieves the struct items based on struct and cluster name. +Note: By default clusterName is null. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the details of the struct items + +| Param | Default | +| --- | --- | +| db | | +| name | | +| packageIds | | +| clusterName | | + + + +### DB API: zcl database access~selectAllClusters(db) ⇒ +Retrieves all the clusters in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of clusters. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ +Finds cluster by code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster by code in a single package id. + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| db | \* | | | +| packageId | \* | | Single packageId or an array of them. | +| clusterCode | \* | | | +| mfgCode | \* | | | + + + +### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ +Returns a promise that resolves into a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into a cluster object + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ +Returns attributes for a given cluster. +IMPORTANT: + packageIds are needed to properly deal with the global attributes. + +This method will NOT only return the attributes that link to +a given cluster, but will ALSO return the attributes that have +empty clusterRef (which are global attributes), and the check +in that case will be made via packageId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of a list of attributes, including global attributes + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side) ⇒ +Get attribute details from the given information. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute details + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | +| side | \* | + + + +### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +Queries for attributes inside a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterCode | \* | +| manufacturerCode | \* | + + + +### DB API: zcl database access~selectAttributeById(db, id) ⇒ +Get attribute details from the given attribute ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| attributeId | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectAllAttributes(db, packageIds) ⇒ +Get all attributes from the given package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attributes + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +Query for attributes by side. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| side | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) ⇒ +Get the endpoint type cluster details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type clusters. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type attribute details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef) ⇒ +Get the endpoint type attribute details from the given details. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attribute. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| attributeRef | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type command details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type commands + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeEventsByEndpointId(db, endpointTypeId) ⇒ +Get endpoint type events from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type events + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +## DB API: DB mappings between columns and JS object keys. +This module provides mappings between database columns and JS keys. + + + +## DB API: access queries. +This module provides queries related to access. + + + +## DB API: zcl database access +This module provides queries for atomic type queries. + + +* [DB API: zcl database access](#module_DB API_ zcl database access) + * [~clear()](#module_DB API_ zcl database access..clear) + * [~put(key, packageId, data)](#module_DB API_ zcl database access..put) ⇒ + * [~get(key, packageId)](#module_DB API_ zcl database access..get) ⇒ + * [~isCached(key, packageId)](#module_DB API_ zcl database access..isCached) ⇒ + * [~cacheQuery(key, packageId)](#module_DB API_ zcl database access..cacheQuery) ⇒ + * [~cacheStats()](#module_DB API_ zcl database access..cacheStats) + * [~enable()](#module_DB API_ zcl database access..enable) + * [~disable()](#module_DB API_ zcl database access..disable) + * [~selectAllAtomics(db, packageId)](#module_DB API_ zcl database access..selectAllAtomics) ⇒ + * [~selectAtomicType(db, packageId, typeName)](#module_DB API_ zcl database access..selectAtomicType) + * [~selectAtomicById(db, packageId)](#module_DB API_ zcl database access..selectAtomicById) + * [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module_DB API_ zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> + * [~selectAllBitmaps(db)](#module_DB API_ zcl database access..selectAllBitmaps) ⇒ + * [~selectBitmapByName(db, packageIds, name)](#module_DB API_ zcl database access..selectBitmapByName) ⇒ + * [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectBitmapByNameAndClusterId) ⇒ + * [~selectBitmapById(db, id)](#module_DB API_ zcl database access..selectBitmapById) ⇒ + * [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module_DB API_ zcl database access..selectSessionClusterByCode) ⇒ + * [~selectAllSessionClusters(db, sessionId)](#module_DB API_ zcl database access..selectAllSessionClusters) ⇒ + * [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module_DB API_ zcl database access..selectSessionAttributeByCode) ⇒ + * [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module_DB API_ zcl database access..selectSessionCommandByCode) ⇒ + * [~selectAllStructs(db, packageId)](#module_DB API_ zcl database access..selectAllStructs) ⇒ + * [~selectStructById(db, id)](#module_DB API_ zcl database access..selectStructById) ⇒ + * [~selectStructByName(db, name, packageIds)](#module_DB API_ zcl database access..selectStructByName) ⇒ + * [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectStructByNameAndClusterId) ⇒ + * [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module_DB API_ zcl database access..selectStructsWithClusterAssociation) ⇒ + * [~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds)](#module_DB API_ zcl database access..sqlQueryForDataTypeByNameAndClusterId) ⇒ + * [~selectClusterBitmaps(db, packageId, clusterId)](#module_DB API_ zcl database access..selectClusterBitmaps) ⇒ + * [~selectAllBitmapFieldsById(db, id)](#module_DB API_ zcl database access..selectAllBitmapFieldsById) ⇒ + * [~selectAllBitmapFields(db, packageId)](#module_DB API_ zcl database access..selectAllBitmapFields) ⇒ + * [~selectAllDomains(db)](#module_DB API_ zcl database access..selectAllDomains) ⇒ + * [~selectDomainById(db, id)](#module_DB API_ zcl database access..selectDomainById) ⇒ + * [~selectAllStructsWithItemCount(db, packageIds)](#module_DB API_ zcl database access..selectAllStructsWithItemCount) ⇒ + * [~selectStructClusters(db, structId)](#module_DB API_ zcl database access..selectStructClusters) ⇒ + * [~selectEnumClusters(db, enumId)](#module_DB API_ zcl database access..selectEnumClusters) ⇒ + * [~selectBitmapClusters(db, bitmapId)](#module_DB API_ zcl database access..selectBitmapClusters) ⇒ + * [~selectClusterStructsWithItems(db)](#module_DB API_ zcl database access..selectClusterStructsWithItems) ⇒ + * [~selectAllStructsWithItems(db)](#module_DB API_ zcl database access..selectAllStructsWithItems) ⇒ + * [~selectStructsWithItemsImpl(db, packageIds, clusterId)](#module_DB API_ zcl database access..selectStructsWithItemsImpl) ⇒ + * [~selectAllStructItemsById(db, id)](#module_DB API_ zcl database access..selectAllStructItemsById) ⇒ + * [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module_DB API_ zcl database access..selectAllStructItemsByStructName) ⇒ + * [~selectAllClusters(db)](#module_DB API_ zcl database access..selectAllClusters) ⇒ + * [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module_DB API_ zcl database access..selectClusterByCode) ⇒ + * [~selectClusterById(db, clusterId, packageId)](#module_DB API_ zcl database access..selectClusterById) ⇒ + * [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module_DB API_ zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ + * [~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side)](#module_DB API_ zcl database access..selectAttributesByClusterIdAndSideIncludingGlobal) ⇒ + * [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module_DB API_ zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ + * [~selectAttributeById(db, id)](#module_DB API_ zcl database access..selectAttributeById) ⇒ + * [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module_DB API_ zcl database access..selectAttributeByAttributeIdAndClusterRef) + * [~selectAllAttributes(db, packageIds)](#module_DB API_ zcl database access..selectAllAttributes) ⇒ + * [~selectAllAttributesBySide(db, side, packageId)](#module_DB API_ zcl database access..selectAllAttributesBySide) ⇒ + * [~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeClustersByEndpointTypeId) ⇒ + * [~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeAttributesByEndpointId) ⇒ + * [~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef)](#module_DB API_ zcl database access..selectEndpointTypeAttribute) ⇒ + * [~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeCommandsByEndpointId) ⇒ + * [~selectEndpointTypeEventsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeEventsByEndpointId) ⇒ + + + +### DB API: zcl database access~clear() +Clears the entire cache. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~put(key, packageId, data) ⇒ +Puts a data object into the cache under a given key/packageId + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Returns true on success. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl database access~get(key, packageId) ⇒ +Returns a data object under a given key/packageId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cached object or undefined if none is present or expired. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~isCached(key, packageId) ⇒ +Returns true if a given key/packageId cache exists. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~cacheQuery(key, packageId) ⇒ +Cache input / output of provided queryFunction +The queryFunction is assumed to have the following signature: + + async function queryFunction(db, ...) {...} + +The DB handle is ignored and the remaining arguments are used as the cache key. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~cacheStats() +Returns the cache statistics. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~enable() +Enable the Database Query cache + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~disable() +Disable the database cache + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~selectAllAtomics(db, packageId) ⇒ +Get all atomic data type information + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: atomic data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAtomicType(db, packageId, typeName) +Locates atomic type based on a type name. Query is not case sensitive. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| typeName | \* | + + + +### DB API: zcl database access~selectAtomicById(db, packageId) +Retrieves atomic type by a given Id. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> +Checks if a type by a given name is signed. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| name | string | The name of the type. | +| sessionPackages | Array | An array of session packages. | + + + +### DB API: zcl database access~selectAllBitmaps(db) ⇒ +Retrieves all the bitmaps in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of bitmaps. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectBitmapByName(db, packageIds, name) ⇒ +Get bitmap by name from the given package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of bitmap + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| name | \* | + + + +### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a bitmap matched by name and clusterId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: bitmap information or undefined + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectBitmapById(db, id) ⇒ +Get Bitmap information by Bitmap ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +Returns the cluster available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| code | \* | +| mfgCode | \* | + + + +### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +Returns all the clusters visible for a given session. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | + + + +### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +Returns the attribute available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| side | \* | +| attributeCode | \* | +| mfgCode | \* | + + + +### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +Returns the command available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| commandCode | \* | +| source | \* | + + + +### DB API: zcl database access~selectAllStructs(db, packageId) ⇒ +Get all structs from a given package ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Structs + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectStructById(db, id) ⇒ +Get struct details from the given struct ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectStructByName(db, name, packageIds) ⇒ +Get Struct details from the given struct name and package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a struct matched by name and clusterId + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct information or undefined + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +Get all structs which have a cluster associated with them. If a struct is +present in more than one cluster then it can be grouped by struct name to +avoid additional rows. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: structs which have an association with clusters + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| groupByStructName | \* | + + + +### DB API: zcl database access~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds) ⇒ +Formulate a sqlite query string for a data type from the given cluster ID and package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: SQLite query string + +| Param | Type | Default | +| --- | --- | --- | +| typeDiscriminator | \* | | +| clusterId | \* | | +| packageIds | \* | | + + + +### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +Retrieves all the bitmaps that are associated with a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster-related bitmaps + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllBitmapFieldsById(db, id) ⇒ +Get bitmap fields from the given bitmap ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllBitmapFields(db, packageId) ⇒ +Get all bitmap fields from the given package ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAllDomains(db) ⇒ +Retrieves all the domains in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of domains. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectDomainById(db, id) ⇒ +Get Domain details from the given domain ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of domain + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ +Retrieves all the structs in the database, including the count +of items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs. + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructClusters(db, structId) ⇒ +Returns an array of clusters that struct belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| structId | \* | + + + +### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ +Returns an array of clusters that enum belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| enumId | \* | + + + +### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ +Returns an array of clusters that bitmap belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| bitmapId | \* | + + + +### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ +Retrieves all the cluster-related structs in the database with the items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ +Retrieves all the structs in the database with the items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectStructsWithItemsImpl(db, packageIds, clusterId) ⇒ +Get Struct details along with its struct items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct details + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllStructItemsById(db, id) ⇒ +Get struct item details from the given struct item ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Stuct Items + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ +Retrieves the struct items based on struct and cluster name. +Note: By default clusterName is null. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the details of the struct items + +| Param | Default | +| --- | --- | +| db | | +| name | | +| packageIds | | +| clusterName | | + + + +### DB API: zcl database access~selectAllClusters(db) ⇒ +Retrieves all the clusters in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of clusters. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ +Finds cluster by code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster by code in a single package id. + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| db | \* | | | +| packageId | \* | | Single packageId or an array of them. | +| clusterCode | \* | | | +| mfgCode | \* | | | + + + +### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ +Returns a promise that resolves into a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into a cluster object + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ +Returns attributes for a given cluster. +IMPORTANT: + packageIds are needed to properly deal with the global attributes. + +This method will NOT only return the attributes that link to +a given cluster, but will ALSO return the attributes that have +empty clusterRef (which are global attributes), and the check +in that case will be made via packageId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of a list of attributes, including global attributes + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side) ⇒ +Get attribute details from the given information. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute details + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | +| side | \* | + + + +### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +Queries for attributes inside a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterCode | \* | +| manufacturerCode | \* | + + + +### DB API: zcl database access~selectAttributeById(db, id) ⇒ +Get attribute details from the given attribute ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| attributeId | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectAllAttributes(db, packageIds) ⇒ +Get all attributes from the given package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attributes + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +Query for attributes by side. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| side | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) ⇒ +Get the endpoint type cluster details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type clusters. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type attribute details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef) ⇒ +Get the endpoint type attribute details from the given details. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attribute. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| attributeRef | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type command details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type commands + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeEventsByEndpointId(db, endpointTypeId) ⇒ +Get endpoint type events from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type events + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +## DB API: attribute queries. +This module provides queries related to attributes. + + + +## DB API: zcl database access +This module provides queries for enums. + + +* [DB API: zcl database access](#module_DB API_ zcl database access) + * [~clear()](#module_DB API_ zcl database access..clear) + * [~put(key, packageId, data)](#module_DB API_ zcl database access..put) ⇒ + * [~get(key, packageId)](#module_DB API_ zcl database access..get) ⇒ + * [~isCached(key, packageId)](#module_DB API_ zcl database access..isCached) ⇒ + * [~cacheQuery(key, packageId)](#module_DB API_ zcl database access..cacheQuery) ⇒ + * [~cacheStats()](#module_DB API_ zcl database access..cacheStats) + * [~enable()](#module_DB API_ zcl database access..enable) + * [~disable()](#module_DB API_ zcl database access..disable) + * [~selectAllAtomics(db, packageId)](#module_DB API_ zcl database access..selectAllAtomics) ⇒ + * [~selectAtomicType(db, packageId, typeName)](#module_DB API_ zcl database access..selectAtomicType) + * [~selectAtomicById(db, packageId)](#module_DB API_ zcl database access..selectAtomicById) + * [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module_DB API_ zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> + * [~selectAllBitmaps(db)](#module_DB API_ zcl database access..selectAllBitmaps) ⇒ + * [~selectBitmapByName(db, packageIds, name)](#module_DB API_ zcl database access..selectBitmapByName) ⇒ + * [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectBitmapByNameAndClusterId) ⇒ + * [~selectBitmapById(db, id)](#module_DB API_ zcl database access..selectBitmapById) ⇒ + * [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module_DB API_ zcl database access..selectSessionClusterByCode) ⇒ + * [~selectAllSessionClusters(db, sessionId)](#module_DB API_ zcl database access..selectAllSessionClusters) ⇒ + * [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module_DB API_ zcl database access..selectSessionAttributeByCode) ⇒ + * [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module_DB API_ zcl database access..selectSessionCommandByCode) ⇒ + * [~selectAllStructs(db, packageId)](#module_DB API_ zcl database access..selectAllStructs) ⇒ + * [~selectStructById(db, id)](#module_DB API_ zcl database access..selectStructById) ⇒ + * [~selectStructByName(db, name, packageIds)](#module_DB API_ zcl database access..selectStructByName) ⇒ + * [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectStructByNameAndClusterId) ⇒ + * [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module_DB API_ zcl database access..selectStructsWithClusterAssociation) ⇒ + * [~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds)](#module_DB API_ zcl database access..sqlQueryForDataTypeByNameAndClusterId) ⇒ + * [~selectClusterBitmaps(db, packageId, clusterId)](#module_DB API_ zcl database access..selectClusterBitmaps) ⇒ + * [~selectAllBitmapFieldsById(db, id)](#module_DB API_ zcl database access..selectAllBitmapFieldsById) ⇒ + * [~selectAllBitmapFields(db, packageId)](#module_DB API_ zcl database access..selectAllBitmapFields) ⇒ + * [~selectAllDomains(db)](#module_DB API_ zcl database access..selectAllDomains) ⇒ + * [~selectDomainById(db, id)](#module_DB API_ zcl database access..selectDomainById) ⇒ + * [~selectAllStructsWithItemCount(db, packageIds)](#module_DB API_ zcl database access..selectAllStructsWithItemCount) ⇒ + * [~selectStructClusters(db, structId)](#module_DB API_ zcl database access..selectStructClusters) ⇒ + * [~selectEnumClusters(db, enumId)](#module_DB API_ zcl database access..selectEnumClusters) ⇒ + * [~selectBitmapClusters(db, bitmapId)](#module_DB API_ zcl database access..selectBitmapClusters) ⇒ + * [~selectClusterStructsWithItems(db)](#module_DB API_ zcl database access..selectClusterStructsWithItems) ⇒ + * [~selectAllStructsWithItems(db)](#module_DB API_ zcl database access..selectAllStructsWithItems) ⇒ + * [~selectStructsWithItemsImpl(db, packageIds, clusterId)](#module_DB API_ zcl database access..selectStructsWithItemsImpl) ⇒ + * [~selectAllStructItemsById(db, id)](#module_DB API_ zcl database access..selectAllStructItemsById) ⇒ + * [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module_DB API_ zcl database access..selectAllStructItemsByStructName) ⇒ + * [~selectAllClusters(db)](#module_DB API_ zcl database access..selectAllClusters) ⇒ + * [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module_DB API_ zcl database access..selectClusterByCode) ⇒ + * [~selectClusterById(db, clusterId, packageId)](#module_DB API_ zcl database access..selectClusterById) ⇒ + * [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module_DB API_ zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ + * [~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side)](#module_DB API_ zcl database access..selectAttributesByClusterIdAndSideIncludingGlobal) ⇒ + * [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module_DB API_ zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ + * [~selectAttributeById(db, id)](#module_DB API_ zcl database access..selectAttributeById) ⇒ + * [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module_DB API_ zcl database access..selectAttributeByAttributeIdAndClusterRef) + * [~selectAllAttributes(db, packageIds)](#module_DB API_ zcl database access..selectAllAttributes) ⇒ + * [~selectAllAttributesBySide(db, side, packageId)](#module_DB API_ zcl database access..selectAllAttributesBySide) ⇒ + * [~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeClustersByEndpointTypeId) ⇒ + * [~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeAttributesByEndpointId) ⇒ + * [~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef)](#module_DB API_ zcl database access..selectEndpointTypeAttribute) ⇒ + * [~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeCommandsByEndpointId) ⇒ + * [~selectEndpointTypeEventsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeEventsByEndpointId) ⇒ + + + +### DB API: zcl database access~clear() +Clears the entire cache. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~put(key, packageId, data) ⇒ +Puts a data object into the cache under a given key/packageId + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Returns true on success. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl database access~get(key, packageId) ⇒ +Returns a data object under a given key/packageId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cached object or undefined if none is present or expired. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~isCached(key, packageId) ⇒ +Returns true if a given key/packageId cache exists. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~cacheQuery(key, packageId) ⇒ +Cache input / output of provided queryFunction +The queryFunction is assumed to have the following signature: + + async function queryFunction(db, ...) {...} + +The DB handle is ignored and the remaining arguments are used as the cache key. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. + +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | + + + +### DB API: zcl database access~cacheStats() +Returns the cache statistics. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~enable() +Enable the Database Query cache + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~disable() +Disable the database cache + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~selectAllAtomics(db, packageId) ⇒ +Get all atomic data type information + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: atomic data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAtomicType(db, packageId, typeName) +Locates atomic type based on a type name. Query is not case sensitive. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| typeName | \* | + + + +### DB API: zcl database access~selectAtomicById(db, packageId) +Retrieves atomic type by a given Id. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> +Checks if a type by a given name is signed. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. + +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| name | string | The name of the type. | +| sessionPackages | Array | An array of session packages. | + + + +### DB API: zcl database access~selectAllBitmaps(db) ⇒ +Retrieves all the bitmaps in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of bitmaps. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectBitmapByName(db, packageIds, name) ⇒ +Get bitmap by name from the given package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of bitmap + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| name | \* | + + + +### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a bitmap matched by name and clusterId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: bitmap information or undefined + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectBitmapById(db, id) ⇒ +Get Bitmap information by Bitmap ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +Returns the cluster available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| code | \* | +| mfgCode | \* | + + + +### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +Returns all the clusters visible for a given session. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | + + + +### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +Returns the attribute available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| side | \* | +| attributeCode | \* | +| mfgCode | \* | + + + +### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +Returns the command available to this session by the code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute + +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| commandCode | \* | +| source | \* | + + + +### DB API: zcl database access~selectAllStructs(db, packageId) ⇒ +Get all structs from a given package ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Structs + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectStructById(db, id) ⇒ +Get struct details from the given struct ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectStructByName(db, name, packageIds) ⇒ +Get Struct details from the given struct name and package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a struct matched by name and clusterId + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct information or undefined + +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +Get all structs which have a cluster associated with them. If a struct is +present in more than one cluster then it can be grouped by struct name to +avoid additional rows. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: structs which have an association with clusters + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| groupByStructName | \* | + + + +### DB API: zcl database access~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds) ⇒ +Formulate a sqlite query string for a data type from the given cluster ID and package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: SQLite query string + +| Param | Type | Default | +| --- | --- | --- | +| typeDiscriminator | \* | | +| clusterId | \* | | +| packageIds | \* | | + + + +### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +Retrieves all the bitmaps that are associated with a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster-related bitmaps + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllBitmapFieldsById(db, id) ⇒ +Get bitmap fields from the given bitmap ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllBitmapFields(db, packageId) ⇒ +Get all bitmap fields from the given package ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAllDomains(db) ⇒ +Retrieves all the domains in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of domains. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectDomainById(db, id) ⇒ +Get Domain details from the given domain ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of domain + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ +Retrieves all the structs in the database, including the count +of items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs. + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectStructClusters(db, structId) ⇒ +Returns an array of clusters that struct belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| structId | \* | + + + +### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ +Returns an array of clusters that enum belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| enumId | \* | + + + +### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ +Returns an array of clusters that bitmap belongs to. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters + +| Param | Type | +| --- | --- | +| db | \* | +| bitmapId | \* | + + + +### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ +Retrieves all the cluster-related structs in the database with the items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ +Retrieves all the structs in the database with the items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectStructsWithItemsImpl(db, packageIds, clusterId) ⇒ +Get Struct details along with its struct items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct details + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllStructItemsById(db, id) ⇒ +Get struct item details from the given struct item ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Stuct Items + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ +Retrieves the struct items based on struct and cluster name. +Note: By default clusterName is null. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the details of the struct items + +| Param | Default | +| --- | --- | +| db | | +| name | | +| packageIds | | +| clusterName | | + + + +### DB API: zcl database access~selectAllClusters(db) ⇒ +Retrieves all the clusters in the database. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of clusters. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ +Finds cluster by code. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster by code in a single package id. + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| db | \* | | | +| packageId | \* | | Single packageId or an array of them. | +| clusterCode | \* | | | +| mfgCode | \* | | | + + + +### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ +Returns a promise that resolves into a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into a cluster object + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ +Returns attributes for a given cluster. +IMPORTANT: + packageIds are needed to properly deal with the global attributes. + +This method will NOT only return the attributes that link to +a given cluster, but will ALSO return the attributes that have +empty clusterRef (which are global attributes), and the check +in that case will be made via packageId. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of a list of attributes, including global attributes + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side) ⇒ +Get attribute details from the given information. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute details + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | +| side | \* | + + + +### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +Queries for attributes inside a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterCode | \* | +| manufacturerCode | \* | + + + +### DB API: zcl database access~selectAttributeById(db, id) ⇒ +Get attribute details from the given attribute ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| attributeId | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectAllAttributes(db, packageIds) ⇒ +Get all attributes from the given package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attributes + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +Query for attributes by side. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| side | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) ⇒ +Get the endpoint type cluster details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type clusters. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type attribute details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef) ⇒ +Get the endpoint type attribute details from the given details. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attribute. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| attributeRef | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type command details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type commands + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeEventsByEndpointId(db, endpointTypeId) ⇒ +Get endpoint type events from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type events + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +## DB API: cluster queries. +This module provides queries related to cluster. + + + +## DB API: command queries. +This module provides queries related to commands. + + + +## DB API: user configuration queries against the database. +This module provides queries for user configuration. + + + +## DB API: Data type discriminator queries against the database. +This module provides queries for data type discriminator + + + +## DB API: Data type queries against the database. +This module provides queries for data types + + + +## DB API: device type database access +This module provides queries for device types. + + +* [DB API: device type database access](#module_DB API_ device type database access) + * [~selectAllDeviceTypes(db, packageId)](#module_DB API_ device type database access..selectAllDeviceTypes) ⇒ + * [~selectDeviceTypeById(db, id)](#module_DB API_ device type database access..selectDeviceTypeById) ⇒ + * [~selectDeviceTypeByCodeAndName(db, packageId, code, name)](#module_DB API_ device type database access..selectDeviceTypeByCodeAndName) ⇒ + * [~selectDeviceTypeByCode(db, packageId, code, name)](#module_DB API_ device type database access..selectDeviceTypeByCode) ⇒ + * [~selectDeviceTypeClustersByDeviceTypeRef(db, deviceTypeRef)](#module_DB API_ device type database access..selectDeviceTypeClustersByDeviceTypeRef) ⇒ + * [~selectDeviceTypeClusterByDeviceTypeClusterId(db, deviceTypeClusterId)](#module_DB API_ device type database access..selectDeviceTypeClusterByDeviceTypeClusterId) ⇒ + * [~selectDeviceTypeAttributesByDeviceTypeRef(db, deviceTypeRef)](#module_DB API_ device type database access..selectDeviceTypeAttributesByDeviceTypeRef) ⇒ + * [~selectDeviceTypeCommandsByDeviceTypeRef(db, deviceTypeRef)](#module_DB API_ device type database access..selectDeviceTypeCommandsByDeviceTypeRef) ⇒ + * [~updateClusterReferencesForDeviceTypeClusters(db)](#module_DB API_ device type database access..updateClusterReferencesForDeviceTypeClusters) ⇒ + * [~updateAttributeReferencesForDeviceTypeReferences(db)](#module_DB API_ device type database access..updateAttributeReferencesForDeviceTypeReferences) ⇒ + * [~updateCommandReferencesForDeviceTypeReferences(db)](#module_DB API_ device type database access..updateCommandReferencesForDeviceTypeReferences) ⇒ + * [~updateFeatureReferencesForDeviceTypeReferences(db)](#module_DB API_ device type database access..updateFeatureReferencesForDeviceTypeReferences) ⇒ + * [~updateDeviceTypeEntityReferences(db)](#module_DB API_ device type database access..updateDeviceTypeEntityReferences) ⇒ + * [~selectDeviceTypesWithCompositionByEndpointTypeId(db, endpointTypeId)](#module_DB API_ device type database access..selectDeviceTypesWithCompositionByEndpointTypeId) ⇒ Promise.<Array> + * [~selectDeviceTypesByEndpointTypeId(db, endpointTypeId)](#module_DB API_ device type database access..selectDeviceTypesByEndpointTypeId) ⇒ + * [~selectDeviceTypeFeaturesByEndpointTypeIdAndClusterId(db, endpointTypeId, clusterId)](#module_DB API_ device type database access..selectDeviceTypeFeaturesByEndpointTypeIdAndClusterId) ⇒ + + + +### DB API: device type database access~selectAllDeviceTypes(db, packageId) ⇒ +Retrieves all the device types in the database. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Promise that resolves with the rows of device types. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: device type database access~selectDeviceTypeById(db, id) ⇒ +Retrieves the device type by its id. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Device type + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: device type database access~selectDeviceTypeByCodeAndName(db, packageId, code, name) ⇒ +Retrieves the device type by the package, code and name. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Device type + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| code | \* | +| name | \* | + + + +### DB API: device type database access~selectDeviceTypeByCode(db, packageId, code, name) ⇒ +Retrieves the device type by the package, code and name. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Device type + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| code | \* | +| name | \* | + + + +### DB API: device type database access~selectDeviceTypeClustersByDeviceTypeRef(db, deviceTypeRef) ⇒ +Get all device type clusters from a given device type ID. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Promise of device type clusters + +| Param | Type | +| --- | --- | +| db | \* | +| deviceTypeRef | \* | + + + +### DB API: device type database access~selectDeviceTypeClusterByDeviceTypeClusterId(db, deviceTypeClusterId) ⇒ +Get device type cluster details from the device type cluster ID. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Promise of device type cluster + +| Param | Type | +| --- | --- | +| db | \* | +| deviceTypeClusterId | \* | + + + +### DB API: device type database access~selectDeviceTypeAttributesByDeviceTypeRef(db, deviceTypeRef) ⇒ +Get all device type commands from a given device type ID. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Promise of device type attributes + +| Param | Type | +| --- | --- | +| db | \* | +| deviceTypeRef | \* | + + + +### DB API: device type database access~selectDeviceTypeCommandsByDeviceTypeRef(db, deviceTypeRef) ⇒ +Get all device type commands from a given device type ID. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Promise of device type commands + +| Param | Type | +| --- | --- | +| db | \* | +| deviceTypeRef | \* | + + + +### DB API: device type database access~updateClusterReferencesForDeviceTypeClusters(db) ⇒ +After loading up device type cluster table with the names, +this method links the refererence to actual cluster reference. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: promise of completion + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: device type database access~updateAttributeReferencesForDeviceTypeReferences(db) ⇒ +After loading up device type attribute table with the names, +this method links the refererence to actual attribute reference. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: promise of completion + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: device type database access~updateCommandReferencesForDeviceTypeReferences(db) ⇒ +After loading up device type command table with the names, +this method links the refererence to actual command reference. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: promise of completion + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: device type database access~updateFeatureReferencesForDeviceTypeReferences(db) ⇒ +After loading up device type feature table with the names, +this method links the refererence to actual feature reference. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: promise of completion + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: device type database access~updateDeviceTypeEntityReferences(db) ⇒ +This method returns the promise of linking the device type clusters +commands and attributes to the correct IDs in the cluster, attribute +and command tables. + +Initial load only populates the names, so once everything is loaded, +we have to link the foreign keys. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: promise of completed linking + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: device type database access~selectDeviceTypesWithCompositionByEndpointTypeId(db, endpointTypeId) ⇒ Promise.<Array> +Asynchronously selects device types with their compositions by a specific endpoint type ID. + +This function queries the database for device types associated with a given endpoint type ID, +including details about the device type and any endpoint compositions linked to it. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: Promise.<Array> - A promise that resolves with an array of device types and their compositions. + +| Param | Type | Description | +| --- | --- | --- | +| db | Object | The database connection object. | +| endpointTypeId | number | The ID of the endpoint type used to filter the device types. | + + + +### DB API: device type database access~selectDeviceTypesByEndpointTypeId(db, endpointTypeId) ⇒ +Retrieves the zcl device type information based on an endpoint type id + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: promise with zcl device type information based on endpoint type id + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: device type database access~selectDeviceTypeFeaturesByEndpointTypeIdAndClusterId(db, endpointTypeId, clusterId) ⇒ +Retrieves the device type features associated to an endpoint type id and cluster id +Note: Use clusterId as 'all' to get all features for an endpoint type id. + +**Kind**: inner method of [DB API: device type database access](#module_DB API_ device type database access) +**Returns**: promise with zcl device type feature information based on endpoint type id and cluster id + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| clusterId | \* | + + + +## DB API: endpoint type queries against the database. +This module provides queries for endpoint type. + + + +## DB API: endpoint configuration queries against the database. +This module provides queries for endpoint configuration. + + + +## DB API: zcl database enum access +This module provides queries for enums. + + +* [DB API: zcl database enum access](#module_DB API_ zcl database enum access) + * [~selectAllEnums(db, packageId)](#module_DB API_ zcl database enum access..selectAllEnums) ⇒ + * [~selectClusterEnums(db, packageId, clusterId)](#module_DB API_ zcl database enum access..selectClusterEnums) ⇒ + * [~selectAllEnumItemsById(db, id)](#module_DB API_ zcl database enum access..selectAllEnumItemsById) ⇒ + * [~selectAllEnumItems(db, packageId)](#module_DB API_ zcl database enum access..selectAllEnumItems) ⇒ + * [~selectEnumById(db, id)](#module_DB API_ zcl database enum access..selectEnumById) ⇒ + * [~selectEnumByName(db, name, packageIds)](#module_DB API_ zcl database enum access..selectEnumByName) ⇒ + * [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database enum access..selectEnumByNameAndClusterId) ⇒ - + -## DB API: External URLs. +### DB API: zcl database enum access~selectAllEnums(db, packageId) ⇒ +Retrieves all the enums in the database. -This module provides common external URLs. +**Kind**: inner method of [DB API: zcl database enum access](#module_DB API_ zcl database enum access) +**Returns**: Promise that resolves with the rows of enums. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | -## DB API: DB types and enums. + -This module provides mappings between database columns and JS keys. +### DB API: zcl database enum access~selectClusterEnums(db, packageId, clusterId) ⇒ +Retrieves all the enums with cluster references in the database. - +**Kind**: inner method of [DB API: zcl database enum access](#module_DB API_ zcl database enum access) +**Returns**: Promise that resolves with the rows of enums. -## JS API: low level database access +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | -This module provides generic DB functions for performing SQL queries. + -- [JS API: low level database access](#module*JS API* low level database access) - - [~dbBeginTransaction(db)](#module*JS API* low level database access..dbBeginTransaction) ⇒ - - [~dbCommit(db)](#module*JS API* low level database access..dbCommit) ⇒ - - [~isTransactionActive()](#module*JS API* low level database access..isTransactionActive) ⇒ - - [~dbRollback(db)](#module*JS API* low level database access..dbRollback) ⇒ - - [~dbRemove(db, query, args)](#module*JS API* low level database access..dbRemove) ⇒ - - [~dbUpdate(db, query, args)](#module*JS API* low level database access..dbUpdate) ⇒ - - [~dbInsert(db, query, args)](#module*JS API* low level database access..dbInsert) ⇒ - - [~dbAll(db, query, args)](#module*JS API* low level database access..dbAll) ⇒ - - [~dbGet(db, query, args)](#module*JS API* low level database access..dbGet) ⇒ - - [~dbMultiSelect(db, sql, arrayOfArrays)](#module*JS API* low level database access..dbMultiSelect) - - [~dbMultiInsert(db, sql, arrayOfArrays)](#module*JS API* low level database access..dbMultiInsert) ⇒ - - [~closeDatabase(database)](#module*JS API* low level database access..closeDatabase) ⇒ - - [~closeDatabaseSync(database)](#module*JS API* low level database access..closeDatabaseSync) - - [~initRamDatabase()](#module*JS API* low level database access..initRamDatabase) ⇒ - - [~initDatabase(sqlitePath)](#module*JS API* low level database access..initDatabase) ⇒ - - [~insertOrReplaceSetting(db, version)](#module*JS API* low level database access..insertOrReplaceSetting) ⇒ - - [~updateSetting(db, rows)](#module*JS API* low level database access..updateSetting) ⇒ - - [~selectSettings(db)](#module*JS API* low level database access..selectSettings) ⇒ - - [~determineIfSchemaShouldLoad(db, context)](#module*JS API* low level database access..determineIfSchemaShouldLoad) ⇒ - - [~loadSchema(db, schemaPath, zapVersion)](#module*JS API* low level database access..loadSchema) ⇒ - - [~initDatabaseAndLoadSchema(sqliteFile, schemaFile, zapVersion)](#module*JS API* low level database access..initDatabaseAndLoadSchema) ⇒ - - [~toDbBool(value)](#module*JS API* low level database access..toDbBool) ⇒ - - [~fromDbBool(value)](#module*JS API* low level database access..fromDbBool) ⇒ - - [~toInClause(value)](#module*JS API* low level database access..toInClause) ⇒ +### DB API: zcl database enum access~selectAllEnumItemsById(db, id) ⇒ +Returns an enum by ID. - +**Kind**: inner method of [DB API: zcl database enum access](#module_DB API_ zcl database enum access) +**Returns**: enum -### JS API: low level database access~dbBeginTransaction(db) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -Returns a promise to begin a transaction. The beginning of the -transaction will be delayed for up to 5 seconds, checking every -1/10th of a second of previous transaction is already finished. + -After 5 seconds, the code gives up and rejects the promise. +### DB API: zcl database enum access~selectAllEnumItems(db, packageId) ⇒ +Select all enum items in a package. -This is to allow simultaneous calls to this function, even though -SQLite does not allow for simultaneous transactions. +**Kind**: inner method of [DB API: zcl database enum access](#module_DB API_ zcl database enum access) +**Returns**: list of enum items -So use transactions responsibly. +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves without an argument and rejects with an error from BEGIN TRANSACTION query. + -| Param | Type | -| ----- | --------------- | -| db | \* | +### DB API: zcl database enum access~selectEnumById(db, id) ⇒ +Select an enum matched by its primary key. - +**Kind**: inner method of [DB API: zcl database enum access](#module_DB API_ zcl database enum access) +**Returns**: an enum or underfined if not found -### JS API: low level database access~dbCommit(db) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -Returns a promise to execute a commit. + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves without an argument or rejects with an error from COMMIT query. +### DB API: zcl database enum access~selectEnumByName(db, name, packageIds) ⇒ +Select an enum matched by name. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [DB API: zcl database enum access](#module_DB API_ zcl database enum access) +**Returns**: enum or undefined - +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | -### JS API: low level database access~isTransactionActive() ⇒ + -Not an async function, simply returns a boolean value whether -there is a currently active transaction. +### DB API: zcl database enum access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select an enum matched by name and clusterId. -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: true if transaction is active, false if not. - +**Kind**: inner method of [DB API: zcl database enum access](#module_DB API_ zcl database enum access) +**Returns**: enum information or undefined -### JS API: low level database access~dbRollback(db) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -Returns a promise to execute a rollback of a transaction. + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves without an argument or rejects with an error from ROLLBACK query. +## DB API: event queries. +This module provides queries related to events. -| Param | Type | -| ----- | --------------- | -| db | \* | + - +## DB API: feature related queries +This module provides queries for features. -### JS API: low level database access~dbRemove(db, query, args) ⇒ + -Returns a promise to execute a DELETE FROM query. +### DB API: feature related queries~getFeaturesByDeviceTypeRefs(db, deviceTypeRefs) ⇒ +Get all device type features associated with a list of device type refs -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolve with the number of delete rows, or rejects with an error from query. +**Kind**: inner method of [DB API: feature related queries](#module_DB API_ feature related queries) +**Returns**: All feature information and device type conformance +with associated device type and cluster details -| Param | Type | -| ----- | --------------- | -| db | \* | -| query | \* | -| args | \* | +| Param | Type | +| --- | --- | +| db | \* | +| deviceTypeRefs | \* | - + -### JS API: low level database access~dbUpdate(db, query, args) ⇒ +## DB API: package-based queries. +This module provides queries related to imports and exports of files. -Returns a promise to execute an update query. + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with a number of changed rows, or rejects with an error from the query. +## DB API: zcl loading queries +This module provides queries for ZCL loading -| Param | Type | -| ----- | --------------- | -| db | \* | -| query | \* | -| args | \* | - +* [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + * [~attributeMap(clusterId, packageId, attributes)](#module_DB API_ zcl loading queries..attributeMap) ⇒ + * [~eventMap(clusterId, packageId, events)](#module_DB API_ zcl loading queries..eventMap) ⇒ + * [~commandMap(clusterId, packageId, commands)](#module_DB API_ zcl loading queries..commandMap) ⇒ + * [~fieldMap(eventId, packageId, fields)](#module_DB API_ zcl loading queries..fieldMap) ⇒ + * [~argMap(cmdId, packageId, args)](#module_DB API_ zcl loading queries..argMap) ⇒ + * [~insertAttributeAccessData(db, packageId, accessData)](#module_DB API_ zcl loading queries..insertAttributeAccessData) ⇒ + * [~insertCommandAccessData(db, packageId, accessData)](#module_DB API_ zcl loading queries..insertCommandAccessData) ⇒ + * [~insertEventAccessData(db, packageId, accessData)](#module_DB API_ zcl loading queries..insertEventAccessData) ⇒ + * [~insertAttributes(db, packageId, attributes)](#module_DB API_ zcl loading queries..insertAttributes) ⇒ + * [~insertAttributeMappings(db, data)](#module_DB API_ zcl loading queries..insertAttributeMappings) ⇒ + * [~insertEvents(db, packageId, events)](#module_DB API_ zcl loading queries..insertEvents) ⇒ + * [~insertCommands(db, packageId, commands)](#module_DB API_ zcl loading queries..insertCommands) ⇒ + * [~insertGlobals(db, packageId, data)](#module_DB API_ zcl loading queries..insertGlobals) ⇒ + * [~insertClusterExtensions(db, packageId, data)](#module_DB API_ zcl loading queries..insertClusterExtensions) ⇒ + * [~insertClusters(db, packageId, data)](#module_DB API_ zcl loading queries..insertClusters) ⇒ + * [~insertFeatures(db, packageId, data)](#module_DB API_ zcl loading queries..insertFeatures) ⇒ + * [~insertTags(db, packageId, data)](#module_DB API_ zcl loading queries..insertTags) ⇒ + * [~insertDomains(db, packageId, data)](#module_DB API_ zcl loading queries..insertDomains) ⇒ + * [~insertSpecs(db, packageId, data)](#module_DB API_ zcl loading queries..insertSpecs) ⇒ + * [~insertGlobalAttributeDefault(db, packageId, clusterData)](#module_DB API_ zcl loading queries..insertGlobalAttributeDefault) ⇒ + * [~insertAtomics(db, packageId, data)](#module_DB API_ zcl loading queries..insertAtomics) + * [~insertEndpointComposition(db, composition, context)](#module_DB API_ zcl loading queries..insertEndpointComposition) ⇒ + * [~getEndpointCompositionIdByCode(db, deviceType)](#module_DB API_ zcl loading queries..getEndpointCompositionIdByCode) ⇒ Promise.<(number\|null)> + * [~insertDeviceComposition(db, deviceType, endpointCompositionId)](#module_DB API_ zcl loading queries..insertDeviceComposition) ⇒ Promise + * [~insertDeviceTypes(db, packageId, data)](#module_DB API_ zcl loading queries..insertDeviceTypes) ⇒ + * [~insertDeviceTypeFeatures(db, dtClusterRefDataPairs)](#module_DB API_ zcl loading queries..insertDeviceTypeFeatures) + * [~insertDeviceTypeAttributes(db, dtClusterRefDataPairs)](#module_DB API_ zcl loading queries..insertDeviceTypeAttributes) + * [~insertDeviceTypeCommands(db, dtClusterRefDataPairs)](#module_DB API_ zcl loading queries..insertDeviceTypeCommands) + * [~insertAccessOperations(db, packageId, operations)](#module_DB API_ zcl loading queries..insertAccessOperations) ⇒ + * [~insertAccessRoles(db, packageId, roles)](#module_DB API_ zcl loading queries..insertAccessRoles) ⇒ + * [~insertAccessModifiers(db, packageId, modifiers)](#module_DB API_ zcl loading queries..insertAccessModifiers) ⇒ + * [~createAccessRows(db, packageId, data)](#module_DB API_ zcl loading queries..createAccessRows) + * [~insertDefaultAccess(db, packageId, defaultAccess)](#module_DB API_ zcl loading queries..insertDefaultAccess) + * [~updateDataTypeClusterReferences(db, packageId)](#module_DB API_ zcl loading queries..updateDataTypeClusterReferences) ⇒ + * [~insertDataTypeDiscriminator(db, packageId, data)](#module_DB API_ zcl loading queries..insertDataTypeDiscriminator) + * [~insertDataType(db, packageId, data)](#module_DB API_ zcl loading queries..insertDataType) + * [~insertNumber(db, packageId, data)](#module_DB API_ zcl loading queries..insertNumber) + * [~insertString(db, packageId, data)](#module_DB API_ zcl loading queries..insertString) + * [~insertEnumAtomic(db, packageId, data)](#module_DB API_ zcl loading queries..insertEnumAtomic) + * [~insertEnum(db, packageIds, data)](#module_DB API_ zcl loading queries..insertEnum) + * [~insertEnumItems(db, packageId, knownPackages, data)](#module_DB API_ zcl loading queries..insertEnumItems) + * [~insertBitmapAtomic(db, packageId, data)](#module_DB API_ zcl loading queries..insertBitmapAtomic) + * [~insertBitmap(db, packageIds, data)](#module_DB API_ zcl loading queries..insertBitmap) + * [~insertBitmapFields(db, packageId, knownPackages, data)](#module_DB API_ zcl loading queries..insertBitmapFields) + * [~insertStruct(db, packageIds, data)](#module_DB API_ zcl loading queries..insertStruct) + * [~insertStructItems(db, packageIds, data)](#module_DB API_ zcl loading queries..insertStructItems) + + + +### DB API: zcl loading queries~attributeMap(clusterId, packageId, attributes) ⇒ +Transforms the array of attributes in a certain format and returns it. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Array of attribute details + +| Param | Type | +| --- | --- | +| clusterId | \* | +| packageId | \* | +| attributes | \* | + + + +### DB API: zcl loading queries~eventMap(clusterId, packageId, events) ⇒ +Transforms the array of events in a certain format and returns it. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Array of event details + +| Param | Type | +| --- | --- | +| clusterId | \* | +| packageId | \* | +| events | \* | + + + +### DB API: zcl loading queries~commandMap(clusterId, packageId, commands) ⇒ +Transforms the array of commands in a certain format and returns it. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Array of command details + +| Param | Type | +| --- | --- | +| clusterId | \* | +| packageId | \* | +| commands | \* | + + + +### DB API: zcl loading queries~fieldMap(eventId, packageId, fields) ⇒ +Transforms the array of event fields in a certain format and returns it. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Array of event field details + +| Param | Type | +| --- | --- | +| eventId | \* | +| packageId | \* | +| fields | \* | + + + +### DB API: zcl loading queries~argMap(cmdId, packageId, args) ⇒ +Transforms the array of command args in a certain format and returns it. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Array of command arg details + +| Param | Type | +| --- | --- | +| cmdId | \* | +| packageId | \* | +| args | \* | + + + +### DB API: zcl loading queries~insertAttributeAccessData(db, packageId, accessData) ⇒ +access data is array of objects, containing id/op/role/modifier. +Insert attribute access data. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of insert on attribute access -### JS API: low level database access~dbInsert(db, query, args) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| accessData | \* | -Returns a promise to execute an insert query. + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with the rowid from the inserted row, or rejects with an error from the query. +### DB API: zcl loading queries~insertCommandAccessData(db, packageId, accessData) ⇒ +access data is array of objects, containing id/op/role/modifier. +Insert command access data. -| Param | Type | -| ----- | --------------- | -| db | \* | -| query | \* | -| args | \* | +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of insert on command access - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| accessData | \* | -### JS API: low level database access~dbAll(db, query, args) ⇒ + -Returns a promise to execute a query to perform a select that returns all rows that match a query. +### DB API: zcl loading queries~insertEventAccessData(db, packageId, accessData) ⇒ +access data is array of objects, containing id/op/role/modifier. +Insert event access data. -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with the rows that got retrieved from the database, or rejects with an error from the query. +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of insert on event access -| Param | Type | -| ----- | --------------- | -| db | \* | -| query | \* | -| args | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| accessData | \* | - + -### JS API: low level database access~dbGet(db, query, args) ⇒ +### DB API: zcl loading queries~insertAttributes(db, packageId, attributes) ⇒ +Insert attribute details. -Returns a promise to execute a query to perform a select that returns first row that matches a query. +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: None -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with a single row that got retrieved from the database, or rejects with an error from the query. +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| attributes | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | -| query | \* | -| args | \* | + - +### DB API: zcl loading queries~insertAttributeMappings(db, data) ⇒ +Load the attribute mapping table with associated attributes -### JS API: low level database access~dbMultiSelect(db, sql, arrayOfArrays) +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: attribute mapping ids of the associated attributes -Returns a promise to perform a prepared statement, using data from array for SQL parameters. -It resolves with an array of rows, containing the data, or rejects with an error. +| Param | Type | +| --- | --- | +| db | \* | +| data | \* | -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) + -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sql | \* | -| arrayOfArrays | \* | +### DB API: zcl loading queries~insertEvents(db, packageId, events) ⇒ +Insert event details. - +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: None -### JS API: low level database access~dbMultiInsert(db, sql, arrayOfArrays) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| events | \* | -Returns a promise to perfom a prepared statement, using data from array for SQL parameters. -It resolves with an array of rowids, or rejects with an error. + + +### DB API: zcl loading queries~insertCommands(db, packageId, commands) ⇒ +Insert command details + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: None + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| commands | \* | + + + +### DB API: zcl loading queries~insertGlobals(db, packageId, data) ⇒ +Inserts globals into the database. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of globals insertion. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl loading queries~insertClusterExtensions(db, packageId, data) ⇒ +Inserts cluster extensions into the database. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of cluster extension insertion. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl loading queries~insertClusters(db, packageId, data) ⇒ +Inserts clusters into the database. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of cluster insertion. + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageId | \* | | +| data | \* | an array of objects that must contain: code, name, description, define. It also contains commands: and attributes: | + + + +### DB API: zcl loading queries~insertFeatures(db, packageId, data) ⇒ +Inserts features into the database. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: A promise that resolves with array of rowids. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl loading queries~insertTags(db, packageId, data) ⇒ +Inserts tags into the database. +data is an array of objects, containing 'name' and 'description' + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: A promise that resolves with array of rowids. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl loading queries~insertDomains(db, packageId, data) ⇒ +Inserts domains into the database. +data is an array of objects that must contain: name + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: A promise that resolves with an array of rowids of all inserted domains. + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageId | \* | | +| data | \* | Data containing name and specRef | + + + +### DB API: zcl loading queries~insertSpecs(db, packageId, data) ⇒ +Inserts a spec into the database. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of insertion. + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageId | \* | | +| data | \* | Data contining specCode and specDescription. | + + + +### DB API: zcl loading queries~insertGlobalAttributeDefault(db, packageId, clusterData) ⇒ +Inserts global attribute defaults into the database. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of data insertion. + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageId | \* | | +| clusterData | \* | array of objects that contain: code, manufacturerCode and subarrays of globalAttribute[] which contain: side, code, value | + + + +### DB API: zcl loading queries~insertAtomics(db, packageId, data) +Insert atomics into the database. +Data is an array of objects that must contains: name, id, description. +Object might also contain 'size', but possibly not. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl loading queries~insertEndpointComposition(db, composition, context) ⇒ +Inserts endpoint composition data into the database based on the context's mandatory device type. +This function checks if the context's mandatory device type matches the composition code. +If they match, it performs an insert operation with a specific type from `dbEnum.mandatoryDeviceType`. +If they do not match, it performs an insert with the composition's type. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: A promise resolved with the result of the database insert operation. + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| composition | \* | The composition data to be inserted. | +| context | \* | The context containing the mandatory device type to check against. | + + + +### DB API: zcl loading queries~getEndpointCompositionIdByCode(db, deviceType) ⇒ Promise.<(number\|null)> +Retrieves the endpoint composition ID by device code. + +This function executes a SQL query to fetch the endpoint composition ID +associated with a given device code. If the query fails, an error is logged. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise.<(number\|null)> - The endpoint composition ID or null if not found. + +| Param | Type | Description | +| --- | --- | --- | +| db | Object | The database connection object. | +| deviceType | Object | The device type object containing the device code. | + + + +### DB API: zcl loading queries~insertDeviceComposition(db, deviceType, endpointCompositionId) ⇒ Promise +Inserts a device composition record into the DEVICE_COMPOSITION table. + +This function constructs an SQL INSERT query to add a new record to the +DEVICE_COMPOSITION table. It handles the insertion of the device code, +endpoint composition reference, conformance, and constraint values. +Note that the "CONSTRAINT" column name is escaped with double quotes +to avoid conflicts with the SQL reserved keyword. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise - A promise that resolves when the insertion is complete. + +| Param | Type | Description | +| --- | --- | --- | +| db | Object | The database connection object. | +| deviceType | Object | The device type object containing the data to be inserted. | +| endpointCompositionId | number | The ID of the endpoint composition. | + + + +### DB API: zcl loading queries~insertDeviceTypes(db, packageId, data) ⇒ +Inserts device types into the database. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of an insertion of device types. + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageId | \* | | +| data | \* | an array of objects that must contain: domain, code, profileId, name, description | + + + +### DB API: zcl loading queries~insertDeviceTypeFeatures(db, dtClusterRefDataPairs) +This handles the loading of device type feature requirements into the database. +There is a need to post-process to attach the actual feature ref after the fact + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | +| --- | --- | +| db | \* | +| dtClusterRefDataPairs | \* | + + + +### DB API: zcl loading queries~insertDeviceTypeAttributes(db, dtClusterRefDataPairs) +This handles the loading of device type attribute requirements into the database. +There is a need to post-process to attach the actual attribute ref after the fact + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | +| --- | --- | +| db | \* | +| dtClusterRefDataPairs | \* | + + + +### DB API: zcl loading queries~insertDeviceTypeCommands(db, dtClusterRefDataPairs) +This handles the loading of device type command requirements into the database. +There is a need to post-process to attach the actual command ref after the fact + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | +| --- | --- | +| db | \* | +| dtClusterRefDataPairs | \* | + + + +### DB API: zcl loading queries~insertAccessOperations(db, packageId, operations) ⇒ +Insert into Access operation Table. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of Access Operation insert operation. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| operations | \* | + + + +### DB API: zcl loading queries~insertAccessRoles(db, packageId, roles) ⇒ +Insert into Access Role Table. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of Access Role insert operation. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| roles | \* | + + + +### DB API: zcl loading queries~insertAccessModifiers(db, packageId, modifiers) ⇒ +Insert into Access Modifier Table. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: Promise of Access Modifier insert operation. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| modifiers | \* | + + + +### DB API: zcl loading queries~createAccessRows(db, packageId, data) +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageId | \* | | +| data | \* | array of objects that must have op/role/modifier | + + + +### DB API: zcl loading queries~insertDefaultAccess(db, packageId, defaultAccess) +Inserts a default access. +Default access is object that contains type and access array of {op,role,modifier} + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| defaultAccess | \* | + + + +### DB API: zcl loading queries~updateDataTypeClusterReferences(db, packageId) ⇒ +This function is used as a post loading action for updating the cluster +references of all the data types based on their cluster code. + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) +**Returns**: promise which updates cluster references for data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + + + +### DB API: zcl loading queries~insertDataTypeDiscriminator(db, packageId, data) +Insert Data Type Discriminator into the database. +Data is all the data types that can exist with name and whether the type is +a baseline data type or not +for eg +If we have a type called 16BitNumber which is a UINT_16(Actual representation +of 16 Bit unsigned integere) then 16BitNumber is not a baseline data type but +UINT_16 is base line data type. +Note: We have an ignore to silently ignore duplicates + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | + + + +### DB API: zcl loading queries~insertDataType(db, packageId, data) +Insert all Data Types into the database. +The Data Type Cluster table is updated with the data type reference and +cluster code. Cluster code is used later to update the cluster reference of +the Data Type Cluster table(see updateDataTypeClusterReferences). + +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) + +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageId | \* | | +| data | \* | certain data type which is inserted into the data type table based on its type | + + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with the array of rowids for the rows that got inserted, or rejects with an error from the query. +### DB API: zcl loading queries~insertNumber(db, packageId, data) +Insert all Number data types into the Number Table. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sql | \* | -| arrayOfArrays | \* | +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | -### JS API: low level database access~closeDatabase(database) ⇒ + -Returns a promise that will resolve when the database in question is closed. -Rejects with an error if closing fails. +### DB API: zcl loading queries~insertString(db, packageId, data) +Insert all String data types into the String Table. -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves without an argument or rejects with error from the database closing. +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -| Param | Type | -| -------- | --------------- | -| database | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | - + -### JS API: low level database access~closeDatabaseSync(database) +### DB API: zcl loading queries~insertEnumAtomic(db, packageId, data) +Insert all Baseline Enums into the Enum Table. +Baseline enums are enums such as ENUM8, ENUM16 defined in the xml files -Imediatelly closes the database. +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | -| Param | Type | -| -------- | --------------- | -| database | \* | + - +### DB API: zcl loading queries~insertEnum(db, packageIds, data) +Insert all Enums into the Enum Table. +Note: Unlike insertEnumAtomic this function adds the enums which are not +baseline enums. -### JS API: low level database access~initRamDatabase() ⇒ +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -Create in-memory database. +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| data | \* | -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: Promise that resolve with the Db. - + -### JS API: low level database access~initDatabase(sqlitePath) ⇒ +### DB API: zcl loading queries~insertEnumItems(db, packageId, knownPackages, data) +Insert all Enum Items into the Enum Item Table. -Returns a promise to initialize a database. +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with the database object that got created, or rejects with an error if something went wrong. +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -| Param | Type | -| ---------- | --------------- | -| sqlitePath | \* | + - +### DB API: zcl loading queries~insertBitmapAtomic(db, packageId, data) +Insert all Baseline Bitmaps into the Bitmap Table. +Baseline bitmaps are bitmaps such as BITMAP8/MAP8, BITMAP16/MAP16 defined in +the xml files -### JS API: low level database access~insertOrReplaceSetting(db, version) ⇒ +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -Returns a promise to insert or replace a setting into the database. +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| data | \* | -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with a rowid of created setting row or rejects with error if something goes wrong. + -| Param | Type | -| ------- | --------------- | -| db | \* | -| version | \* | +### DB API: zcl loading queries~insertBitmap(db, packageIds, data) +Insert all Bitmaps into the Bitmap Table. +Note: Unlike insertBitmapAtomic this function adds the bitmaps which are not +baseline bitmaps. - +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -### JS API: low level database access~updateSetting(db, rows) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| data | \* | -Updates SETTING table with values selected + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with the SETTING table being repopulated +### DB API: zcl loading queries~insertBitmapFields(db, packageId, knownPackages, data) +Insert all Bitmap fields into the Bitmap field Table. -| Param | Type | -| ----- | --------------- | -| db | \* | -| rows | \* | +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -### JS API: low level database access~selectSettings(db) ⇒ + -Returns a promise resolving the entire SETTING table +### DB API: zcl loading queries~insertStruct(db, packageIds, data) +Insert all Structs into the Struct Table. -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise resolving the entire SETTING table +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| data | \* | - + -### JS API: low level database access~determineIfSchemaShouldLoad(db, context) ⇒ +### DB API: zcl loading queries~insertStructItems(db, packageIds, data) +Insert all Struct items into the Struct Item Table. -Checks the state of schema. +**Kind**: inner method of [DB API: zcl loading queries](#module_DB API_ zcl loading queries) -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: object containing "mustLoad" and "hasSchema" elements. +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| data | \* | -| Param | Type | -| ------- | --------------- | -| db | \* | -| context | \* | + - +## DB API: zcl database number access +This module provides queries for numbers. -### JS API: low level database access~loadSchema(db, schemaPath, zapVersion) ⇒ -Returns a promise to load schema into a blank database, and inserts a version to the settings table.j +* [DB API: zcl database number access](#module_DB API_ zcl database number access) + * [~selectNumberByName(db, name, packageIds)](#module_DB API_ zcl database number access..selectNumberByName) ⇒ + * [~selectNumberByNameAndClusterId(db, name, packageIds)](#module_DB API_ zcl database number access..selectNumberByNameAndClusterId) ⇒ + * [~selectNumberById(db, name)](#module_DB API_ zcl database number access..selectNumberById) ⇒ + * [~selectAllNumbers(db, packageId)](#module_DB API_ zcl database number access..selectAllNumbers) ⇒ -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: A promise that resolves with the same db that got passed in, or rejects with an error. + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| schemaPath | \* | -| zapVersion | \* | +### DB API: zcl database number access~selectNumberByName(db, name, packageIds) ⇒ +Select an number matched by name. - +**Kind**: inner method of [DB API: zcl database number access](#module_DB API_ zcl database number access) +**Returns**: number or undefined -### JS API: low level database access~initDatabaseAndLoadSchema(sqliteFile, schemaFile, zapVersion) ⇒ +| Param | +| --- | +| db | +| name | +| packageIds | -Init database and load the schema. + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: Promise that resolves into the database object. +### DB API: zcl database number access~selectNumberByNameAndClusterId(db, name, packageIds) ⇒ +Select a number matched by name and clusterId -| Param | Type | -| ---------- | --------------- | -| sqliteFile | \* | -| schemaFile | \* | -| zapVersion | \* | +**Kind**: inner method of [DB API: zcl database number access](#module_DB API_ zcl database number access) +**Returns**: number information or undefined - +| Param | +| --- | +| db | +| name | +| packageIds | -### JS API: low level database access~toDbBool(value) ⇒ + -Returns the data that should be stored into the DB column, from the passed JS boolean. +### DB API: zcl database number access~selectNumberById(db, name) ⇒ +Select an number matched by id. -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: Value to be stored into the database. +**Kind**: inner method of [DB API: zcl database number access](#module_DB API_ zcl database number access) +**Returns**: number or undefined -| Param | Type | -| ----- | --------------- | -| value | \* | +| Param | +| --- | +| db | +| name | - + -### JS API: low level database access~fromDbBool(value) ⇒ +### DB API: zcl database number access~selectAllNumbers(db, packageId) ⇒ +Select all numbers. -Returns a true or false JS boolean from the value that was read in the database. +**Kind**: inner method of [DB API: zcl database number access](#module_DB API_ zcl database number access) +**Returns**: All numbers -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: value to be used in JS after reading value from database. +| Param | +| --- | +| db | +| packageId | -| Param | Type | -| ----- | --------------- | -| value | \* | + - +## DB API: session related queries. +This module provides package notification related queries. -### JS API: low level database access~toInClause(value) ⇒ + -**Kind**: inner method of [JS API: low level database access](#module*JS API* low level database access) -**Returns**: Given value in the form of string +## DB API: package-based queries. +This module provides queries related to packages. + + -| Param | Type | -| ----- | --------------- | -| value | \* | +## DB API: session related queries. +This module provides session notification related queries. ## DB API: zcl database access - -This module provides cache for commonly used static database queries. - -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ +This module provides queries for ZCL static entities +inside a single session. Things like: + all visible clusters, etc. + + +* [DB API: zcl database access](#module_DB API_ zcl database access) + * [~clear()](#module_DB API_ zcl database access..clear) + * [~put(key, packageId, data)](#module_DB API_ zcl database access..put) ⇒ + * [~get(key, packageId)](#module_DB API_ zcl database access..get) ⇒ + * [~isCached(key, packageId)](#module_DB API_ zcl database access..isCached) ⇒ + * [~cacheQuery(key, packageId)](#module_DB API_ zcl database access..cacheQuery) ⇒ + * [~cacheStats()](#module_DB API_ zcl database access..cacheStats) + * [~enable()](#module_DB API_ zcl database access..enable) + * [~disable()](#module_DB API_ zcl database access..disable) + * [~selectAllAtomics(db, packageId)](#module_DB API_ zcl database access..selectAllAtomics) ⇒ + * [~selectAtomicType(db, packageId, typeName)](#module_DB API_ zcl database access..selectAtomicType) + * [~selectAtomicById(db, packageId)](#module_DB API_ zcl database access..selectAtomicById) + * [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module_DB API_ zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> + * [~selectAllBitmaps(db)](#module_DB API_ zcl database access..selectAllBitmaps) ⇒ + * [~selectBitmapByName(db, packageIds, name)](#module_DB API_ zcl database access..selectBitmapByName) ⇒ + * [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectBitmapByNameAndClusterId) ⇒ + * [~selectBitmapById(db, id)](#module_DB API_ zcl database access..selectBitmapById) ⇒ + * [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module_DB API_ zcl database access..selectSessionClusterByCode) ⇒ + * [~selectAllSessionClusters(db, sessionId)](#module_DB API_ zcl database access..selectAllSessionClusters) ⇒ + * [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module_DB API_ zcl database access..selectSessionAttributeByCode) ⇒ + * [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module_DB API_ zcl database access..selectSessionCommandByCode) ⇒ + * [~selectAllStructs(db, packageId)](#module_DB API_ zcl database access..selectAllStructs) ⇒ + * [~selectStructById(db, id)](#module_DB API_ zcl database access..selectStructById) ⇒ + * [~selectStructByName(db, name, packageIds)](#module_DB API_ zcl database access..selectStructByName) ⇒ + * [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectStructByNameAndClusterId) ⇒ + * [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module_DB API_ zcl database access..selectStructsWithClusterAssociation) ⇒ + * [~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds)](#module_DB API_ zcl database access..sqlQueryForDataTypeByNameAndClusterId) ⇒ + * [~selectClusterBitmaps(db, packageId, clusterId)](#module_DB API_ zcl database access..selectClusterBitmaps) ⇒ + * [~selectAllBitmapFieldsById(db, id)](#module_DB API_ zcl database access..selectAllBitmapFieldsById) ⇒ + * [~selectAllBitmapFields(db, packageId)](#module_DB API_ zcl database access..selectAllBitmapFields) ⇒ + * [~selectAllDomains(db)](#module_DB API_ zcl database access..selectAllDomains) ⇒ + * [~selectDomainById(db, id)](#module_DB API_ zcl database access..selectDomainById) ⇒ + * [~selectAllStructsWithItemCount(db, packageIds)](#module_DB API_ zcl database access..selectAllStructsWithItemCount) ⇒ + * [~selectStructClusters(db, structId)](#module_DB API_ zcl database access..selectStructClusters) ⇒ + * [~selectEnumClusters(db, enumId)](#module_DB API_ zcl database access..selectEnumClusters) ⇒ + * [~selectBitmapClusters(db, bitmapId)](#module_DB API_ zcl database access..selectBitmapClusters) ⇒ + * [~selectClusterStructsWithItems(db)](#module_DB API_ zcl database access..selectClusterStructsWithItems) ⇒ + * [~selectAllStructsWithItems(db)](#module_DB API_ zcl database access..selectAllStructsWithItems) ⇒ + * [~selectStructsWithItemsImpl(db, packageIds, clusterId)](#module_DB API_ zcl database access..selectStructsWithItemsImpl) ⇒ + * [~selectAllStructItemsById(db, id)](#module_DB API_ zcl database access..selectAllStructItemsById) ⇒ + * [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module_DB API_ zcl database access..selectAllStructItemsByStructName) ⇒ + * [~selectAllClusters(db)](#module_DB API_ zcl database access..selectAllClusters) ⇒ + * [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module_DB API_ zcl database access..selectClusterByCode) ⇒ + * [~selectClusterById(db, clusterId, packageId)](#module_DB API_ zcl database access..selectClusterById) ⇒ + * [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module_DB API_ zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ + * [~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side)](#module_DB API_ zcl database access..selectAttributesByClusterIdAndSideIncludingGlobal) ⇒ + * [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module_DB API_ zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ + * [~selectAttributeById(db, id)](#module_DB API_ zcl database access..selectAttributeById) ⇒ + * [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module_DB API_ zcl database access..selectAttributeByAttributeIdAndClusterRef) + * [~selectAllAttributes(db, packageIds)](#module_DB API_ zcl database access..selectAllAttributes) ⇒ + * [~selectAllAttributesBySide(db, side, packageId)](#module_DB API_ zcl database access..selectAllAttributesBySide) ⇒ + * [~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeClustersByEndpointTypeId) ⇒ + * [~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeAttributesByEndpointId) ⇒ + * [~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef)](#module_DB API_ zcl database access..selectEndpointTypeAttribute) ⇒ + * [~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeCommandsByEndpointId) ⇒ + * [~selectEndpointTypeEventsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeEventsByEndpointId) ⇒ ### DB API: zcl database access~clear() - Clears the entire cache. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~put(key, packageId, data) ⇒ - Puts a data object into the cache under a given key/packageId -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Returns true on success. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | +| data | \* | ### DB API: zcl database access~get(key, packageId) ⇒ - Returns a data object under a given key/packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cached object or undefined if none is present or expired. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~isCached(key, packageId) ⇒ - Returns true if a given key/packageId cache exists. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheQuery(key, packageId) ⇒ - Cache input / output of provided queryFunction The queryFunction is assumed to have the following signature: -async function queryFunction(db, ...) {...} + async function queryFunction(db, ...) {...} The DB handle is ignored and the remaining arguments are used as the cache key. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheStats() - Returns the cache statistics. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~enable() - Enable the Database Query cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~disable() - Disable the database cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~selectAllAtomics(db, packageId) ⇒ +Get all atomic data type information + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: atomic data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + ### DB API: zcl database access~selectAtomicType(db, packageId, typeName) - Locates atomic type based on a type name. Query is not case sensitive. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| typeName | \* | ### DB API: zcl database access~selectAtomicById(db, packageId) - Retrieves atomic type by a given Id. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | ### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> - Checks if a type by a given name is signed. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| name | string | The name of the type. | +| sessionPackages | Array | An array of session packages. | ### DB API: zcl database access~selectAllBitmaps(db) ⇒ - Retrieves all the bitmaps in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. - -| Param | Type | -| ----- | --------------- | -| db | \* | - - - -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ - -Select a bitmap matched by name and clusterId. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined - -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of bitmaps. - +| Param | Type | +| --- | --- | +| db | \* | -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ + -Retrieves all the enums in the database. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### DB API: zcl database access~selectBitmapByName(db, packageIds, name) ⇒ +Get bitmap by name from the given package IDs. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of bitmap - +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| name | \* | -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ - -Retrieves all the enums with cluster references in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a bitmap matched by name and clusterId. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: bitmap information or undefined - +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ + -Returns an enum by ID. +### DB API: zcl database access~selectBitmapById(db, id) ⇒ +Get Bitmap information by Bitmap ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | - + -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ +### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +Returns the cluster available to this session by the code. -Select all enum items in a package. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| code | \* | +| mfgCode | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | + - +### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +Returns all the clusters visible for a given session. -### DB API: zcl database access~selectEnumById(db, id) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. -Select an enum matched by its primary key. +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found + -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +Returns the attribute available to this session by the code. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| side | \* | +| attributeCode | \* | +| mfgCode | \* | -Select an enum matched by name. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined +### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +Returns the command available to this session by the code. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute - +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| commandCode | \* | +| source | \* | -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select an enum matched by name and clusterId. +### DB API: zcl database access~selectAllStructs(db, packageId) ⇒ +Get all structs from a given package ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Structs -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | - + -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +### DB API: zcl database access~selectStructById(db, id) ⇒ +Get struct details from the given struct ID. -Returns the cluster available to this session by the code. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | + - +### DB API: zcl database access~selectStructByName(db, name, packageIds) ⇒ +Get Struct details from the given struct name and package IDs. -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct -Returns all the clusters visible for a given session. +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a struct matched by name and clusterId - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct information or undefined -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -Returns the attribute available to this session by the code. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +Get all structs which have a cluster associated with them. If a struct is +present in more than one cluster then it can be grouped by struct name to +avoid additional rows. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: structs which have an association with clusters - +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| groupByStructName | \* | -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ + -Returns the command available to this session by the code. +### DB API: zcl database access~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds) ⇒ +Formulate a sqlite query string for a data type from the given cluster ID and package IDs. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: SQLite query string -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | +| Param | Type | Default | +| --- | --- | --- | +| typeDiscriminator | \* | | +| clusterId | \* | | +| packageIds | \* | | - + -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +Retrieves all the bitmaps that are associated with a cluster. -Select a struct matched by name and clusterId +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster-related bitmaps -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### DB API: zcl database access~selectAllBitmapFieldsById(db, id) ⇒ +Get bitmap fields from the given bitmap ID. -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters + -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | +### DB API: zcl database access~selectAllBitmapFields(db, packageId) ⇒ +Get all bitmap fields from the given package ID. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | -Retrieves all the bitmaps that are associated with a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps +### DB API: zcl database access~selectAllDomains(db) ⇒ +Retrieves all the domains in the database. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of domains. - +| Param | Type | +| --- | --- | +| db | \* | -### DB API: zcl database access~selectAllDomains(db) ⇒ + -Retrieves all the domains in the database. +### DB API: zcl database access~selectDomainById(db, id) ⇒ +Get Domain details from the given domain ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of domain -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ - Retrieves all the structs in the database, including the count of items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | ### DB API: zcl database access~selectStructClusters(db, structId) ⇒ - Returns an array of clusters that struct belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| structId | \* | ### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ - Returns an array of clusters that enum belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| enumId | \* | ### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ - Returns an array of clusters that bitmap belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| bitmapId | \* | ### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ - Retrieves all the cluster-related structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ - Retrieves all the structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectStructsWithItemsImpl(db, packageIds, clusterId) ⇒ +Get Struct details along with its struct items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct details + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| clusterId | \* | + + -| Param | Type | -| ----- | --------------- | -| db | \* | +### DB API: zcl database access~selectAllStructItemsById(db, id) ⇒ +Get struct item details from the given struct item ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Stuct Items + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ - Retrieves the struct items based on struct and cluster name. Note: By default clusterName is null. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the details of the struct items -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +| Param | Default | +| --- | --- | +| db | | +| name | | +| packageIds | | +| clusterName | | ### DB API: zcl database access~selectAllClusters(db) ⇒ - Retrieves all the clusters in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of clusters. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ - Finds cluster by code. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster by code in a single package id. -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| db | \* | | | +| packageId | \* | | Single packageId or an array of them. | +| clusterCode | \* | | | +| mfgCode | \* | | | ### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ - Returns a promise that resolves into a cluster. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into a cluster object -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | ### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ - Returns attributes for a given cluster. IMPORTANT: -packageIds are needed to properly deal with the global attributes. + packageIds are needed to properly deal with the global attributes. This method will NOT only return the attributes that link to a given cluster, but will ALSO return the attributes that have empty clusterRef (which are global attributes), and the check in that case will be made via packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of a list of attributes, including global attributes + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side) ⇒ +Get attribute details from the given information. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute details + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | +| side | \* | + + + +### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +Queries for attributes inside a cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterCode | \* | +| manufacturerCode | \* | + + + +### DB API: zcl database access~selectAttributeById(db, id) ⇒ +Get attribute details from the given attribute ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | + + + +### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| attributeId | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectAllAttributes(db, packageIds) ⇒ +Get all attributes from the given package IDs. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attributes + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +Query for attributes by side. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| side | \* | +| packageId | \* | + + + +### DB API: zcl database access~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) ⇒ +Get the endpoint type cluster details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type clusters. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type attribute details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef) ⇒ +Get the endpoint type attribute details from the given details. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attribute. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| attributeRef | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type command details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type commands -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | - + -### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +### DB API: zcl database access~selectEndpointTypeEventsByEndpointId(db, endpointTypeId) ⇒ +Get endpoint type events from the given endpoint type ID. -Queries for attributes inside a cluster. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type events -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | + - +## DB API: session related queries. +This module provides session related queries. -### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) + -This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. +## DB API: zcl database strings access +This module provides queries for strings. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | +* [DB API: zcl database strings access](#module_DB API_ zcl database strings access) + * [~selectAllStrings(db, packageId)](#module_DB API_ zcl database strings access..selectAllStrings) ⇒ + * [~selectStringById(db, packageId)](#module_DB API_ zcl database strings access..selectStringById) ⇒ + * [~selectStringByName(db, name, packageIds)](#module_DB API_ zcl database strings access..selectStringByName) ⇒ - + -### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +### DB API: zcl database strings access~selectAllStrings(db, packageId) ⇒ +Select all Strings. -Query for attributes by side. +**Kind**: inner method of [DB API: zcl database strings access](#module_DB API_ zcl database strings access) +**Returns**: All Strings -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +| Param | +| --- | +| db | +| packageId | -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | + - +### DB API: zcl database strings access~selectStringById(db, packageId) ⇒ +Select String by ID. -## DB API: DB mappings between columns and JS object keys. +**Kind**: inner method of [DB API: zcl database strings access](#module_DB API_ zcl database strings access) +**Returns**: String -This module provides mappings between database columns and JS keys. +| Param | +| --- | +| db | +| packageId | - + -## DB API: access queries. +### DB API: zcl database strings access~selectStringByName(db, name, packageIds) ⇒ +Select String by name. -This module provides queries related to access. +**Kind**: inner method of [DB API: zcl database strings access](#module_DB API_ zcl database strings access) +**Returns**: String + +| Param | +| --- | +| db | +| name | +| packageIds | ## DB API: zcl database access +This module provides queries for enums. -This module provides queries for atomic type queries. -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ +* [DB API: zcl database access](#module_DB API_ zcl database access) + * [~clear()](#module_DB API_ zcl database access..clear) + * [~put(key, packageId, data)](#module_DB API_ zcl database access..put) ⇒ + * [~get(key, packageId)](#module_DB API_ zcl database access..get) ⇒ + * [~isCached(key, packageId)](#module_DB API_ zcl database access..isCached) ⇒ + * [~cacheQuery(key, packageId)](#module_DB API_ zcl database access..cacheQuery) ⇒ + * [~cacheStats()](#module_DB API_ zcl database access..cacheStats) + * [~enable()](#module_DB API_ zcl database access..enable) + * [~disable()](#module_DB API_ zcl database access..disable) + * [~selectAllAtomics(db, packageId)](#module_DB API_ zcl database access..selectAllAtomics) ⇒ + * [~selectAtomicType(db, packageId, typeName)](#module_DB API_ zcl database access..selectAtomicType) + * [~selectAtomicById(db, packageId)](#module_DB API_ zcl database access..selectAtomicById) + * [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module_DB API_ zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> + * [~selectAllBitmaps(db)](#module_DB API_ zcl database access..selectAllBitmaps) ⇒ + * [~selectBitmapByName(db, packageIds, name)](#module_DB API_ zcl database access..selectBitmapByName) ⇒ + * [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectBitmapByNameAndClusterId) ⇒ + * [~selectBitmapById(db, id)](#module_DB API_ zcl database access..selectBitmapById) ⇒ + * [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module_DB API_ zcl database access..selectSessionClusterByCode) ⇒ + * [~selectAllSessionClusters(db, sessionId)](#module_DB API_ zcl database access..selectAllSessionClusters) ⇒ + * [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module_DB API_ zcl database access..selectSessionAttributeByCode) ⇒ + * [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module_DB API_ zcl database access..selectSessionCommandByCode) ⇒ + * [~selectAllStructs(db, packageId)](#module_DB API_ zcl database access..selectAllStructs) ⇒ + * [~selectStructById(db, id)](#module_DB API_ zcl database access..selectStructById) ⇒ + * [~selectStructByName(db, name, packageIds)](#module_DB API_ zcl database access..selectStructByName) ⇒ + * [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectStructByNameAndClusterId) ⇒ + * [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module_DB API_ zcl database access..selectStructsWithClusterAssociation) ⇒ + * [~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds)](#module_DB API_ zcl database access..sqlQueryForDataTypeByNameAndClusterId) ⇒ + * [~selectClusterBitmaps(db, packageId, clusterId)](#module_DB API_ zcl database access..selectClusterBitmaps) ⇒ + * [~selectAllBitmapFieldsById(db, id)](#module_DB API_ zcl database access..selectAllBitmapFieldsById) ⇒ + * [~selectAllBitmapFields(db, packageId)](#module_DB API_ zcl database access..selectAllBitmapFields) ⇒ + * [~selectAllDomains(db)](#module_DB API_ zcl database access..selectAllDomains) ⇒ + * [~selectDomainById(db, id)](#module_DB API_ zcl database access..selectDomainById) ⇒ + * [~selectAllStructsWithItemCount(db, packageIds)](#module_DB API_ zcl database access..selectAllStructsWithItemCount) ⇒ + * [~selectStructClusters(db, structId)](#module_DB API_ zcl database access..selectStructClusters) ⇒ + * [~selectEnumClusters(db, enumId)](#module_DB API_ zcl database access..selectEnumClusters) ⇒ + * [~selectBitmapClusters(db, bitmapId)](#module_DB API_ zcl database access..selectBitmapClusters) ⇒ + * [~selectClusterStructsWithItems(db)](#module_DB API_ zcl database access..selectClusterStructsWithItems) ⇒ + * [~selectAllStructsWithItems(db)](#module_DB API_ zcl database access..selectAllStructsWithItems) ⇒ + * [~selectStructsWithItemsImpl(db, packageIds, clusterId)](#module_DB API_ zcl database access..selectStructsWithItemsImpl) ⇒ + * [~selectAllStructItemsById(db, id)](#module_DB API_ zcl database access..selectAllStructItemsById) ⇒ + * [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module_DB API_ zcl database access..selectAllStructItemsByStructName) ⇒ + * [~selectAllClusters(db)](#module_DB API_ zcl database access..selectAllClusters) ⇒ + * [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module_DB API_ zcl database access..selectClusterByCode) ⇒ + * [~selectClusterById(db, clusterId, packageId)](#module_DB API_ zcl database access..selectClusterById) ⇒ + * [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module_DB API_ zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ + * [~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side)](#module_DB API_ zcl database access..selectAttributesByClusterIdAndSideIncludingGlobal) ⇒ + * [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module_DB API_ zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ + * [~selectAttributeById(db, id)](#module_DB API_ zcl database access..selectAttributeById) ⇒ + * [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module_DB API_ zcl database access..selectAttributeByAttributeIdAndClusterRef) + * [~selectAllAttributes(db, packageIds)](#module_DB API_ zcl database access..selectAllAttributes) ⇒ + * [~selectAllAttributesBySide(db, side, packageId)](#module_DB API_ zcl database access..selectAllAttributesBySide) ⇒ + * [~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeClustersByEndpointTypeId) ⇒ + * [~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeAttributesByEndpointId) ⇒ + * [~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef)](#module_DB API_ zcl database access..selectEndpointTypeAttribute) ⇒ + * [~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeCommandsByEndpointId) ⇒ + * [~selectEndpointTypeEventsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeEventsByEndpointId) ⇒ ### DB API: zcl database access~clear() - Clears the entire cache. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~put(key, packageId, data) ⇒ - Puts a data object into the cache under a given key/packageId -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Returns true on success. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | +| data | \* | ### DB API: zcl database access~get(key, packageId) ⇒ - Returns a data object under a given key/packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cached object or undefined if none is present or expired. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~isCached(key, packageId) ⇒ - Returns true if a given key/packageId cache exists. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheQuery(key, packageId) ⇒ - Cache input / output of provided queryFunction The queryFunction is assumed to have the following signature: -async function queryFunction(db, ...) {...} + async function queryFunction(db, ...) {...} The DB handle is ignored and the remaining arguments are used as the cache key. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheStats() - Returns the cache statistics. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~enable() - Enable the Database Query cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~disable() - Disable the database cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~selectAllAtomics(db, packageId) ⇒ +Get all atomic data type information + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: atomic data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + ### DB API: zcl database access~selectAtomicType(db, packageId, typeName) - Locates atomic type based on a type name. Query is not case sensitive. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| typeName | \* | ### DB API: zcl database access~selectAtomicById(db, packageId) - Retrieves atomic type by a given Id. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | ### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> - Checks if a type by a given name is signed. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| name | string | The name of the type. | +| sessionPackages | Array | An array of session packages. | ### DB API: zcl database access~selectAllBitmaps(db) ⇒ - Retrieves all the bitmaps in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. - -| Param | Type | -| ----- | --------------- | -| db | \* | - - - -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ - -Select a bitmap matched by name and clusterId. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined - -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of bitmaps. - +| Param | Type | +| --- | --- | +| db | \* | -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ + -Retrieves all the enums in the database. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### DB API: zcl database access~selectBitmapByName(db, packageIds, name) ⇒ +Get bitmap by name from the given package IDs. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of bitmap - +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| name | \* | -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ - -Retrieves all the enums with cluster references in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a bitmap matched by name and clusterId. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: bitmap information or undefined - +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ + -Returns an enum by ID. +### DB API: zcl database access~selectBitmapById(db, id) ⇒ +Get Bitmap information by Bitmap ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | - + -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ +### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +Returns the cluster available to this session by the code. -Select all enum items in a package. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| code | \* | +| mfgCode | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | + - +### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +Returns all the clusters visible for a given session. -### DB API: zcl database access~selectEnumById(db, id) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. -Select an enum matched by its primary key. +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found + -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +Returns the attribute available to this session by the code. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| side | \* | +| attributeCode | \* | +| mfgCode | \* | -Select an enum matched by name. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined +### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +Returns the command available to this session by the code. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute - +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| commandCode | \* | +| source | \* | -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select an enum matched by name and clusterId. +### DB API: zcl database access~selectAllStructs(db, packageId) ⇒ +Get all structs from a given package ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Structs -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | - + -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +### DB API: zcl database access~selectStructById(db, id) ⇒ +Get struct details from the given struct ID. -Returns the cluster available to this session by the code. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | + - +### DB API: zcl database access~selectStructByName(db, name, packageIds) ⇒ +Get Struct details from the given struct name and package IDs. -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct -Returns all the clusters visible for a given session. +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a struct matched by name and clusterId - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct information or undefined -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -Returns the attribute available to this session by the code. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +Get all structs which have a cluster associated with them. If a struct is +present in more than one cluster then it can be grouped by struct name to +avoid additional rows. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: structs which have an association with clusters - +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| groupByStructName | \* | -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ + -Returns the command available to this session by the code. +### DB API: zcl database access~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds) ⇒ +Formulate a sqlite query string for a data type from the given cluster ID and package IDs. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: SQLite query string -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | +| Param | Type | Default | +| --- | --- | --- | +| typeDiscriminator | \* | | +| clusterId | \* | | +| packageIds | \* | | - + -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +Retrieves all the bitmaps that are associated with a cluster. -Select a struct matched by name and clusterId +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster-related bitmaps -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### DB API: zcl database access~selectAllBitmapFieldsById(db, id) ⇒ +Get bitmap fields from the given bitmap ID. -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters + -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | +### DB API: zcl database access~selectAllBitmapFields(db, packageId) ⇒ +Get all bitmap fields from the given package ID. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | -Retrieves all the bitmaps that are associated with a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps +### DB API: zcl database access~selectAllDomains(db) ⇒ +Retrieves all the domains in the database. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of domains. - +| Param | Type | +| --- | --- | +| db | \* | -### DB API: zcl database access~selectAllDomains(db) ⇒ + -Retrieves all the domains in the database. +### DB API: zcl database access~selectDomainById(db, id) ⇒ +Get Domain details from the given domain ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of domain -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ - Retrieves all the structs in the database, including the count of items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | ### DB API: zcl database access~selectStructClusters(db, structId) ⇒ - Returns an array of clusters that struct belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| structId | \* | ### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ - Returns an array of clusters that enum belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| enumId | \* | ### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ - Returns an array of clusters that bitmap belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| bitmapId | \* | ### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ - Retrieves all the cluster-related structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ - Retrieves all the structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectStructsWithItemsImpl(db, packageIds, clusterId) ⇒ +Get Struct details along with its struct items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct details + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| clusterId | \* | + + -| Param | Type | -| ----- | --------------- | -| db | \* | +### DB API: zcl database access~selectAllStructItemsById(db, id) ⇒ +Get struct item details from the given struct item ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Stuct Items + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ - Retrieves the struct items based on struct and cluster name. Note: By default clusterName is null. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the details of the struct items -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +| Param | Default | +| --- | --- | +| db | | +| name | | +| packageIds | | +| clusterName | | ### DB API: zcl database access~selectAllClusters(db) ⇒ - Retrieves all the clusters in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of clusters. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ - Finds cluster by code. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster by code in a single package id. -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| db | \* | | | +| packageId | \* | | Single packageId or an array of them. | +| clusterCode | \* | | | +| mfgCode | \* | | | ### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ - Returns a promise that resolves into a cluster. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into a cluster object -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | ### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ - Returns attributes for a given cluster. IMPORTANT: -packageIds are needed to properly deal with the global attributes. + packageIds are needed to properly deal with the global attributes. This method will NOT only return the attributes that link to a given cluster, but will ALSO return the attributes that have empty clusterRef (which are global attributes), and the check in that case will be made via packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of a list of attributes, including global attributes + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | + + +### DB API: zcl database access~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side) ⇒ +Get attribute details from the given information. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute details + +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | +| side | \* | ### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ - Queries for attributes inside a cluster. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterCode | \* | +| manufacturerCode | \* | + + + +### DB API: zcl database access~selectAttributeById(db, id) ⇒ +Get attribute details from the given attribute ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) - This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + +| Param | Type | +| --- | --- | +| db | \* | +| attributeId | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectAllAttributes(db, packageIds) ⇒ +Get all attributes from the given package IDs. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attributes + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | ### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ - Query for attributes by side. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| side | \* | +| packageId | \* | - + -## DB API: attribute queries. +### DB API: zcl database access~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) ⇒ +Get the endpoint type cluster details from the given endpoint type ID. -This module provides queries related to attributes. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type clusters. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type attribute details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attributes. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef) ⇒ +Get the endpoint type attribute details from the given details. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attribute. + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| attributeRef | \* | +| clusterRef | \* | + + + +### DB API: zcl database access~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type command details from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type commands + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | + + + +### DB API: zcl database access~selectEndpointTypeEventsByEndpointId(db, endpointTypeId) ⇒ +Get endpoint type events from the given endpoint type ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type events + +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | ## DB API: zcl database access +This module provides a place for creating generic queries which are common +across different query files. -This module provides queries for enums. -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ +* [DB API: zcl database access](#module_DB API_ zcl database access) + * [~clear()](#module_DB API_ zcl database access..clear) + * [~put(key, packageId, data)](#module_DB API_ zcl database access..put) ⇒ + * [~get(key, packageId)](#module_DB API_ zcl database access..get) ⇒ + * [~isCached(key, packageId)](#module_DB API_ zcl database access..isCached) ⇒ + * [~cacheQuery(key, packageId)](#module_DB API_ zcl database access..cacheQuery) ⇒ + * [~cacheStats()](#module_DB API_ zcl database access..cacheStats) + * [~enable()](#module_DB API_ zcl database access..enable) + * [~disable()](#module_DB API_ zcl database access..disable) + * [~selectAllAtomics(db, packageId)](#module_DB API_ zcl database access..selectAllAtomics) ⇒ + * [~selectAtomicType(db, packageId, typeName)](#module_DB API_ zcl database access..selectAtomicType) + * [~selectAtomicById(db, packageId)](#module_DB API_ zcl database access..selectAtomicById) + * [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module_DB API_ zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> + * [~selectAllBitmaps(db)](#module_DB API_ zcl database access..selectAllBitmaps) ⇒ + * [~selectBitmapByName(db, packageIds, name)](#module_DB API_ zcl database access..selectBitmapByName) ⇒ + * [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectBitmapByNameAndClusterId) ⇒ + * [~selectBitmapById(db, id)](#module_DB API_ zcl database access..selectBitmapById) ⇒ + * [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module_DB API_ zcl database access..selectSessionClusterByCode) ⇒ + * [~selectAllSessionClusters(db, sessionId)](#module_DB API_ zcl database access..selectAllSessionClusters) ⇒ + * [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module_DB API_ zcl database access..selectSessionAttributeByCode) ⇒ + * [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module_DB API_ zcl database access..selectSessionCommandByCode) ⇒ + * [~selectAllStructs(db, packageId)](#module_DB API_ zcl database access..selectAllStructs) ⇒ + * [~selectStructById(db, id)](#module_DB API_ zcl database access..selectStructById) ⇒ + * [~selectStructByName(db, name, packageIds)](#module_DB API_ zcl database access..selectStructByName) ⇒ + * [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectStructByNameAndClusterId) ⇒ + * [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module_DB API_ zcl database access..selectStructsWithClusterAssociation) ⇒ + * [~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds)](#module_DB API_ zcl database access..sqlQueryForDataTypeByNameAndClusterId) ⇒ + * [~selectClusterBitmaps(db, packageId, clusterId)](#module_DB API_ zcl database access..selectClusterBitmaps) ⇒ + * [~selectAllBitmapFieldsById(db, id)](#module_DB API_ zcl database access..selectAllBitmapFieldsById) ⇒ + * [~selectAllBitmapFields(db, packageId)](#module_DB API_ zcl database access..selectAllBitmapFields) ⇒ + * [~selectAllDomains(db)](#module_DB API_ zcl database access..selectAllDomains) ⇒ + * [~selectDomainById(db, id)](#module_DB API_ zcl database access..selectDomainById) ⇒ + * [~selectAllStructsWithItemCount(db, packageIds)](#module_DB API_ zcl database access..selectAllStructsWithItemCount) ⇒ + * [~selectStructClusters(db, structId)](#module_DB API_ zcl database access..selectStructClusters) ⇒ + * [~selectEnumClusters(db, enumId)](#module_DB API_ zcl database access..selectEnumClusters) ⇒ + * [~selectBitmapClusters(db, bitmapId)](#module_DB API_ zcl database access..selectBitmapClusters) ⇒ + * [~selectClusterStructsWithItems(db)](#module_DB API_ zcl database access..selectClusterStructsWithItems) ⇒ + * [~selectAllStructsWithItems(db)](#module_DB API_ zcl database access..selectAllStructsWithItems) ⇒ + * [~selectStructsWithItemsImpl(db, packageIds, clusterId)](#module_DB API_ zcl database access..selectStructsWithItemsImpl) ⇒ + * [~selectAllStructItemsById(db, id)](#module_DB API_ zcl database access..selectAllStructItemsById) ⇒ + * [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module_DB API_ zcl database access..selectAllStructItemsByStructName) ⇒ + * [~selectAllClusters(db)](#module_DB API_ zcl database access..selectAllClusters) ⇒ + * [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module_DB API_ zcl database access..selectClusterByCode) ⇒ + * [~selectClusterById(db, clusterId, packageId)](#module_DB API_ zcl database access..selectClusterById) ⇒ + * [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module_DB API_ zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ + * [~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side)](#module_DB API_ zcl database access..selectAttributesByClusterIdAndSideIncludingGlobal) ⇒ + * [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module_DB API_ zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ + * [~selectAttributeById(db, id)](#module_DB API_ zcl database access..selectAttributeById) ⇒ + * [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module_DB API_ zcl database access..selectAttributeByAttributeIdAndClusterRef) + * [~selectAllAttributes(db, packageIds)](#module_DB API_ zcl database access..selectAllAttributes) ⇒ + * [~selectAllAttributesBySide(db, side, packageId)](#module_DB API_ zcl database access..selectAllAttributesBySide) ⇒ + * [~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeClustersByEndpointTypeId) ⇒ + * [~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeAttributesByEndpointId) ⇒ + * [~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef)](#module_DB API_ zcl database access..selectEndpointTypeAttribute) ⇒ + * [~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeCommandsByEndpointId) ⇒ + * [~selectEndpointTypeEventsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeEventsByEndpointId) ⇒ ### DB API: zcl database access~clear() - Clears the entire cache. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~put(key, packageId, data) ⇒ - Puts a data object into the cache under a given key/packageId -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Returns true on success. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | +| data | \* | ### DB API: zcl database access~get(key, packageId) ⇒ - Returns a data object under a given key/packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cached object or undefined if none is present or expired. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~isCached(key, packageId) ⇒ - Returns true if a given key/packageId cache exists. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheQuery(key, packageId) ⇒ - Cache input / output of provided queryFunction The queryFunction is assumed to have the following signature: -async function queryFunction(db, ...) {...} + async function queryFunction(db, ...) {...} The DB handle is ignored and the remaining arguments are used as the cache key. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheStats() - Returns the cache statistics. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~enable() - Enable the Database Query cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~disable() - Disable the database cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~selectAllAtomics(db, packageId) ⇒ +Get all atomic data type information + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: atomic data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + ### DB API: zcl database access~selectAtomicType(db, packageId, typeName) - Locates atomic type based on a type name. Query is not case sensitive. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| typeName | \* | ### DB API: zcl database access~selectAtomicById(db, packageId) - Retrieves atomic type by a given Id. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | ### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> - Checks if a type by a given name is signed. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| name | string | The name of the type. | +| sessionPackages | Array | An array of session packages. | ### DB API: zcl database access~selectAllBitmaps(db) ⇒ - Retrieves all the bitmaps in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. - -| Param | Type | -| ----- | --------------- | -| db | \* | - - - -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ - -Select a bitmap matched by name and clusterId. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined - -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | - - - -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of bitmaps. -Retrieves all the enums in the database. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | - - +| Param | Type | +| --- | --- | +| db | \* | -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ + -Retrieves all the enums with cluster references in the database. +### DB API: zcl database access~selectBitmapByName(db, packageIds, name) ⇒ +Get bitmap by name from the given package IDs. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of bitmap -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| name | \* | - + -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ +### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a bitmap matched by name and clusterId. -Returns an enum by ID. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: bitmap information or undefined -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | + - +### DB API: zcl database access~selectBitmapById(db, id) ⇒ +Get Bitmap information by Bitmap ID. -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap -Select all enum items in a package. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +Returns the cluster available to this session by the code. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. -### DB API: zcl database access~selectEnumById(db, id) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| code | \* | +| mfgCode | \* | -Select an enum matched by its primary key. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found +### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +Returns all the clusters visible for a given session. -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. - +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ + -Select an enum matched by name. +### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +Returns the attribute available to this session by the code. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| side | \* | +| attributeCode | \* | +| mfgCode | \* | - + -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +Returns the command available to this session by the code. -Select an enum matched by name and clusterId. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| commandCode | \* | +| source | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### DB API: zcl database access~selectAllStructs(db, packageId) ⇒ +Get all structs from a given package ID. -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Structs -Returns the cluster available to this session by the code. +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | +### DB API: zcl database access~selectStructById(db, id) ⇒ +Get struct details from the given struct ID. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -Returns all the clusters visible for a given session. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +### DB API: zcl database access~selectStructByName(db, name, packageIds) ⇒ +Get Struct details from the given struct name and package IDs. -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct - +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ + -Returns the attribute available to this session by the code. +### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a struct matched by name and clusterId -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct information or undefined -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | - + -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +Get all structs which have a cluster associated with them. If a struct is +present in more than one cluster then it can be grouped by struct name to +avoid additional rows. -Returns the command available to this session by the code. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: structs which have an association with clusters -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| groupByStructName | \* | -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | + - +### DB API: zcl database access~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds) ⇒ +Formulate a sqlite query string for a data type from the given cluster ID and package IDs. -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: SQLite query string -Select a struct matched by name and clusterId +| Param | Type | Default | +| --- | --- | --- | +| typeDiscriminator | \* | | +| clusterId | \* | | +| packageIds | \* | | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +Retrieves all the bitmaps that are associated with a cluster. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster-related bitmaps -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters +### DB API: zcl database access~selectAllBitmapFieldsById(db, id) ⇒ +Get bitmap fields from the given bitmap ID. -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields - +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ + -Retrieves all the bitmaps that are associated with a cluster. +### DB API: zcl database access~selectAllBitmapFields(db, packageId) ⇒ +Get all bitmap fields from the given package ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | ### DB API: zcl database access~selectAllDomains(db) ⇒ - Retrieves all the domains in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of domains. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectDomainById(db, id) ⇒ +Get Domain details from the given domain ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of domain -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ - Retrieves all the structs in the database, including the count of items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | ### DB API: zcl database access~selectStructClusters(db, structId) ⇒ - Returns an array of clusters that struct belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| structId | \* | ### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ - Returns an array of clusters that enum belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| enumId | \* | ### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ - Returns an array of clusters that bitmap belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| bitmapId | \* | ### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ - Retrieves all the cluster-related structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ - Retrieves all the structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + -| Param | Type | -| ----- | --------------- | -| db | \* | +### DB API: zcl database access~selectStructsWithItemsImpl(db, packageIds, clusterId) ⇒ +Get Struct details along with its struct items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct details + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllStructItemsById(db, id) ⇒ +Get struct item details from the given struct item ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Stuct Items + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ - Retrieves the struct items based on struct and cluster name. Note: By default clusterName is null. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the details of the struct items -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +| Param | Default | +| --- | --- | +| db | | +| name | | +| packageIds | | +| clusterName | | ### DB API: zcl database access~selectAllClusters(db) ⇒ - Retrieves all the clusters in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of clusters. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ - Finds cluster by code. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster by code in a single package id. -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| db | \* | | | +| packageId | \* | | Single packageId or an array of them. | +| clusterCode | \* | | | +| mfgCode | \* | | | ### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ - Returns a promise that resolves into a cluster. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into a cluster object -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | ### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ - Returns attributes for a given cluster. IMPORTANT: -packageIds are needed to properly deal with the global attributes. + packageIds are needed to properly deal with the global attributes. This method will NOT only return the attributes that link to a given cluster, but will ALSO return the attributes that have empty clusterRef (which are global attributes), and the check in that case will be made via packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes - -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | - - - -### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ - -Queries for attributes inside a cluster. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. - -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | - - - -### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) - -This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | - - - -### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ - -Query for attributes by side. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | - - - -## DB API: cluster queries. - -This module provides queries related to cluster. - - - -## DB API: command queries. - -This module provides queries related to commands. - - - -## DB API: user configuration queries against the database. - -This module provides queries for user configuration. - - - -## DB API: device type database access - -This module provides queries for device types. - -- [DB API: device type database access](#module*DB API* device type database access) - - [~selectAllDeviceTypes(db, packageId)](#module*DB API* device type database access..selectAllDeviceTypes) ⇒ - - [~selectDeviceTypeById(db, id)](#module*DB API* device type database access..selectDeviceTypeById) ⇒ - - [~selectDeviceTypeByCodeAndName(db, packageId, code, name)](#module*DB API* device type database access..selectDeviceTypeByCodeAndName) ⇒ - - [~selectDeviceTypeByCode(db, packageId, code, name)](#module*DB API* device type database access..selectDeviceTypeByCode) ⇒ - - [~updateClusterReferencesForDeviceTypeClusters(db)](#module*DB API* device type database access..updateClusterReferencesForDeviceTypeClusters) ⇒ - - [~updateAttributeReferencesForDeviceTypeReferences(db)](#module*DB API* device type database access..updateAttributeReferencesForDeviceTypeReferences) ⇒ - - [~updateCommandReferencesForDeviceTypeReferences(db)](#module*DB API* device type database access..updateCommandReferencesForDeviceTypeReferences) ⇒ - - [~updateFeatureReferencesForDeviceTypeReferences(db)](#module*DB API* device type database access..updateFeatureReferencesForDeviceTypeReferences) ⇒ - - [~updateDeviceTypeEntityReferences(db)](#module*DB API* device type database access..updateDeviceTypeEntityReferences) ⇒ - - [~selectDeviceTypesWithCompositionByEndpointTypeId(db, endpointTypeId)](#module*DB API* device type database access..selectDeviceTypesWithCompositionByEndpointTypeId) ⇒ Promise.<Array> - - [~selectDeviceTypesByEndpointTypeId(db, endpointTypeId)](#module*DB API* device type database access..selectDeviceTypesByEndpointTypeId) ⇒ - - [~selectDeviceTypeFeaturesByEndpointTypeIdAndClusterId(db, endpointTypeId, clusterId)](#module*DB API* device type database access..selectDeviceTypeFeaturesByEndpointTypeIdAndClusterId) ⇒ - - - -### DB API: device type database access~selectAllDeviceTypes(db, packageId) ⇒ - -Retrieves all the device types in the database. - -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: Promise that resolves with the rows of device types. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | - - - -### DB API: device type database access~selectDeviceTypeById(db, id) ⇒ - -Retrieves the device type by its id. - -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: Device type - -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | - - - -### DB API: device type database access~selectDeviceTypeByCodeAndName(db, packageId, code, name) ⇒ - -Retrieves the device type by the package, code and name. - -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: Device type - -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| code | \* | -| name | \* | - - - -### DB API: device type database access~selectDeviceTypeByCode(db, packageId, code, name) ⇒ - -Retrieves the device type by the package, code and name. - -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: Device type - -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| code | \* | -| name | \* | - - - -### DB API: device type database access~updateClusterReferencesForDeviceTypeClusters(db) ⇒ - -After loading up device type cluster table with the names, -this method links the refererence to actual cluster reference. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of a list of attributes, including global attributes -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: promise of completion +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### DB API: zcl database access~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side) ⇒ +Get attribute details from the given information. -### DB API: device type database access~updateAttributeReferencesForDeviceTypeReferences(db) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute details -After loading up device type attribute table with the names, -this method links the refererence to actual attribute reference. +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | +| side | \* | -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: promise of completion + -| Param | Type | -| ----- | --------------- | -| db | \* | +### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +Queries for attributes inside a cluster. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. -### DB API: device type database access~updateCommandReferencesForDeviceTypeReferences(db) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterCode | \* | +| manufacturerCode | \* | -After loading up device type command table with the names, -this method links the refererence to actual command reference. + -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: promise of completion +### DB API: zcl database access~selectAttributeById(db, id) ⇒ +Get attribute details from the given attribute ID. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute - +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -### DB API: device type database access~updateFeatureReferencesForDeviceTypeReferences(db) ⇒ + -After loading up device type feature table with the names, -this method links the refererence to actual feature reference. +### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: promise of completion +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | +| attributeId | \* | +| clusterRef | \* | - + -### DB API: device type database access~updateDeviceTypeEntityReferences(db) ⇒ +### DB API: zcl database access~selectAllAttributes(db, packageIds) ⇒ +Get all attributes from the given package IDs. -This method returns the promise of linking the device type clusters -commands and attributes to the correct IDs in the cluster, attribute -and command tables. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attributes -Initial load only populates the names, so once everything is loaded, -we have to link the foreign keys. +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: promise of completed linking + -| Param | Type | -| ----- | --------------- | -| db | \* | +### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +Query for attributes by side. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. -### DB API: device type database access~selectDeviceTypesWithCompositionByEndpointTypeId(db, endpointTypeId) ⇒ Promise.<Array> +| Param | Type | +| --- | --- | +| db | \* | +| side | \* | +| packageId | \* | -Asynchronously selects device types with their compositions by a specific endpoint type ID. + -This function queries the database for device types associated with a given endpoint type ID, -including details about the device type and any endpoint compositions linked to it. +### DB API: zcl database access~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) ⇒ +Get the endpoint type cluster details from the given endpoint type ID. -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: Promise.<Array> - A promise that resolves with an array of device types and their compositions. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type clusters. -| Param | Type | Description | -| -------------- | ------------------- | ------------------------------------------------------------ | -| db | Object | The database connection object. | -| endpointTypeId | number | The ID of the endpoint type used to filter the device types. | +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | - + -### DB API: device type database access~selectDeviceTypesByEndpointTypeId(db, endpointTypeId) ⇒ +### DB API: zcl database access~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type attribute details from the given endpoint type ID. -Retrieves the zcl device type information based on an endpoint type id +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attributes. -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: promise with zcl device type information based on endpoint type id +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | -| Param | Type | -| -------------- | --------------- | -| db | \* | -| endpointTypeId | \* | + - +### DB API: zcl database access~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef) ⇒ +Get the endpoint type attribute details from the given details. -### DB API: device type database access~selectDeviceTypeFeaturesByEndpointTypeIdAndClusterId(db, endpointTypeId, clusterId) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attribute. -Retrieves the device type features associated to an endpoint type id and cluster id -Note: Use clusterId as 'all' to get all features for an endpoint type id. +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| attributeRef | \* | +| clusterRef | \* | -**Kind**: inner method of [DB API: device type database access](#module*DB API* device type database access) -**Returns**: promise with zcl device type feature information based on endpoint type id and cluster id + -| Param | Type | -| -------------- | --------------- | -| db | \* | -| endpointTypeId | \* | -| clusterId | \* | +### DB API: zcl database access~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type command details from the given endpoint type ID. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type commands -## DB API: endpoint type queries against the database. +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | -This module provides queries for endpoint type. + - +### DB API: zcl database access~selectEndpointTypeEventsByEndpointId(db, endpointTypeId) ⇒ +Get endpoint type events from the given endpoint type ID. -## DB API: endpoint configuration queries against the database. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type events -This module provides queries for endpoint configuration. +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | ## DB API: zcl database access +This module provides queries for ZCL static queries. -This module provides queries for enums. -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ +* [DB API: zcl database access](#module_DB API_ zcl database access) + * [~clear()](#module_DB API_ zcl database access..clear) + * [~put(key, packageId, data)](#module_DB API_ zcl database access..put) ⇒ + * [~get(key, packageId)](#module_DB API_ zcl database access..get) ⇒ + * [~isCached(key, packageId)](#module_DB API_ zcl database access..isCached) ⇒ + * [~cacheQuery(key, packageId)](#module_DB API_ zcl database access..cacheQuery) ⇒ + * [~cacheStats()](#module_DB API_ zcl database access..cacheStats) + * [~enable()](#module_DB API_ zcl database access..enable) + * [~disable()](#module_DB API_ zcl database access..disable) + * [~selectAllAtomics(db, packageId)](#module_DB API_ zcl database access..selectAllAtomics) ⇒ + * [~selectAtomicType(db, packageId, typeName)](#module_DB API_ zcl database access..selectAtomicType) + * [~selectAtomicById(db, packageId)](#module_DB API_ zcl database access..selectAtomicById) + * [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module_DB API_ zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> + * [~selectAllBitmaps(db)](#module_DB API_ zcl database access..selectAllBitmaps) ⇒ + * [~selectBitmapByName(db, packageIds, name)](#module_DB API_ zcl database access..selectBitmapByName) ⇒ + * [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectBitmapByNameAndClusterId) ⇒ + * [~selectBitmapById(db, id)](#module_DB API_ zcl database access..selectBitmapById) ⇒ + * [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module_DB API_ zcl database access..selectSessionClusterByCode) ⇒ + * [~selectAllSessionClusters(db, sessionId)](#module_DB API_ zcl database access..selectAllSessionClusters) ⇒ + * [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module_DB API_ zcl database access..selectSessionAttributeByCode) ⇒ + * [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module_DB API_ zcl database access..selectSessionCommandByCode) ⇒ + * [~selectAllStructs(db, packageId)](#module_DB API_ zcl database access..selectAllStructs) ⇒ + * [~selectStructById(db, id)](#module_DB API_ zcl database access..selectStructById) ⇒ + * [~selectStructByName(db, name, packageIds)](#module_DB API_ zcl database access..selectStructByName) ⇒ + * [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module_DB API_ zcl database access..selectStructByNameAndClusterId) ⇒ + * [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module_DB API_ zcl database access..selectStructsWithClusterAssociation) ⇒ + * [~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds)](#module_DB API_ zcl database access..sqlQueryForDataTypeByNameAndClusterId) ⇒ + * [~selectClusterBitmaps(db, packageId, clusterId)](#module_DB API_ zcl database access..selectClusterBitmaps) ⇒ + * [~selectAllBitmapFieldsById(db, id)](#module_DB API_ zcl database access..selectAllBitmapFieldsById) ⇒ + * [~selectAllBitmapFields(db, packageId)](#module_DB API_ zcl database access..selectAllBitmapFields) ⇒ + * [~selectAllDomains(db)](#module_DB API_ zcl database access..selectAllDomains) ⇒ + * [~selectDomainById(db, id)](#module_DB API_ zcl database access..selectDomainById) ⇒ + * [~selectAllStructsWithItemCount(db, packageIds)](#module_DB API_ zcl database access..selectAllStructsWithItemCount) ⇒ + * [~selectStructClusters(db, structId)](#module_DB API_ zcl database access..selectStructClusters) ⇒ + * [~selectEnumClusters(db, enumId)](#module_DB API_ zcl database access..selectEnumClusters) ⇒ + * [~selectBitmapClusters(db, bitmapId)](#module_DB API_ zcl database access..selectBitmapClusters) ⇒ + * [~selectClusterStructsWithItems(db)](#module_DB API_ zcl database access..selectClusterStructsWithItems) ⇒ + * [~selectAllStructsWithItems(db)](#module_DB API_ zcl database access..selectAllStructsWithItems) ⇒ + * [~selectStructsWithItemsImpl(db, packageIds, clusterId)](#module_DB API_ zcl database access..selectStructsWithItemsImpl) ⇒ + * [~selectAllStructItemsById(db, id)](#module_DB API_ zcl database access..selectAllStructItemsById) ⇒ + * [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module_DB API_ zcl database access..selectAllStructItemsByStructName) ⇒ + * [~selectAllClusters(db)](#module_DB API_ zcl database access..selectAllClusters) ⇒ + * [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module_DB API_ zcl database access..selectClusterByCode) ⇒ + * [~selectClusterById(db, clusterId, packageId)](#module_DB API_ zcl database access..selectClusterById) ⇒ + * [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module_DB API_ zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ + * [~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side)](#module_DB API_ zcl database access..selectAttributesByClusterIdAndSideIncludingGlobal) ⇒ + * [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module_DB API_ zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ + * [~selectAttributeById(db, id)](#module_DB API_ zcl database access..selectAttributeById) ⇒ + * [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module_DB API_ zcl database access..selectAttributeByAttributeIdAndClusterRef) + * [~selectAllAttributes(db, packageIds)](#module_DB API_ zcl database access..selectAllAttributes) ⇒ + * [~selectAllAttributesBySide(db, side, packageId)](#module_DB API_ zcl database access..selectAllAttributesBySide) ⇒ + * [~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeClustersByEndpointTypeId) ⇒ + * [~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeAttributesByEndpointId) ⇒ + * [~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef)](#module_DB API_ zcl database access..selectEndpointTypeAttribute) ⇒ + * [~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeCommandsByEndpointId) ⇒ + * [~selectEndpointTypeEventsByEndpointId(db, endpointTypeId)](#module_DB API_ zcl database access..selectEndpointTypeEventsByEndpointId) ⇒ ### DB API: zcl database access~clear() - Clears the entire cache. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~put(key, packageId, data) ⇒ - Puts a data object into the cache under a given key/packageId -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Returns true on success. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | +| data | \* | ### DB API: zcl database access~get(key, packageId) ⇒ - Returns a data object under a given key/packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cached object or undefined if none is present or expired. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~isCached(key, packageId) ⇒ - Returns true if a given key/packageId cache exists. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheQuery(key, packageId) ⇒ - Cache input / output of provided queryFunction The queryFunction is assumed to have the following signature: -async function queryFunction(db, ...) {...} + async function queryFunction(db, ...) {...} The DB handle is ignored and the remaining arguments are used as the cache key. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: true or false, depending on whether the cache is present. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| key | \* | +| packageId | \* | ### DB API: zcl database access~cacheStats() - Returns the cache statistics. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~enable() - Enable the Database Query cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) ### DB API: zcl database access~disable() - Disable the database cache -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) + + +### DB API: zcl database access~selectAllAtomics(db, packageId) ⇒ +Get all atomic data type information + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: atomic data types + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | + ### DB API: zcl database access~selectAtomicType(db, packageId, typeName) - Locates atomic type based on a type name. Query is not case sensitive. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| typeName | \* | ### DB API: zcl database access~selectAtomicById(db, packageId) - Retrieves atomic type by a given Id. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | ### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> - Checks if a type by a given name is signed. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| name | string | The name of the type. | +| sessionPackages | Array | An array of session packages. | ### DB API: zcl database access~selectAllBitmaps(db) ⇒ - Retrieves all the bitmaps in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. - -| Param | Type | -| ----- | --------------- | -| db | \* | - - - -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ - -Select a bitmap matched by name and clusterId. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined - -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | - - - -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of bitmaps. -Retrieves all the enums in the database. +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +### DB API: zcl database access~selectBitmapByName(db, packageIds, name) ⇒ +Get bitmap by name from the given package IDs. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of bitmap -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| name | \* | -Retrieves all the enums with cluster references in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a bitmap matched by name and clusterId. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: bitmap information or undefined - +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ + -Returns an enum by ID. +### DB API: zcl database access~selectBitmapById(db, id) ⇒ +Get Bitmap information by Bitmap ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | - + -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ +### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +Returns the cluster available to this session by the code. -Select all enum items in a package. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| code | \* | +| mfgCode | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | + - +### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +Returns all the clusters visible for a given session. -### DB API: zcl database access~selectEnumById(db, id) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: all the cluster objects for a given session. -Select an enum matched by its primary key. +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found + -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +Returns the attribute available to this session by the code. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| side | \* | +| attributeCode | \* | +| mfgCode | \* | -Select an enum matched by name. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined +### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +Returns the command available to this session by the code. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the session attribute - +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterCode | \* | +| commandCode | \* | +| source | \* | -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select an enum matched by name and clusterId. +### DB API: zcl database access~selectAllStructs(db, packageId) ⇒ +Get all structs from a given package ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Structs -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | - + -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +### DB API: zcl database access~selectStructById(db, id) ⇒ +Get struct details from the given struct ID. -Returns the cluster available to this session by the code. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | + - +### DB API: zcl database access~selectStructByName(db, name, packageIds) ⇒ +Get Struct details from the given struct name and package IDs. -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Struct -Returns all the clusters visible for a given session. +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| packageIds | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +Select a struct matched by name and clusterId - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct information or undefined -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| name | \* | +| clusterId | \* | +| packageIds | \* | -Returns the attribute available to this session by the code. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +Get all structs which have a cluster associated with them. If a struct is +present in more than one cluster then it can be grouped by struct name to +avoid additional rows. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: structs which have an association with clusters - +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| groupByStructName | \* | -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ + -Returns the command available to this session by the code. +### DB API: zcl database access~sqlQueryForDataTypeByNameAndClusterId(typeDiscriminator, clusterId, packageIds) ⇒ +Formulate a sqlite query string for a data type from the given cluster ID and package IDs. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: SQLite query string -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | +| Param | Type | Default | +| --- | --- | --- | +| typeDiscriminator | \* | | +| clusterId | \* | | +| packageIds | \* | | - + -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +Retrieves all the bitmaps that are associated with a cluster. -Select a struct matched by name and clusterId +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster-related bitmaps -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterId | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### DB API: zcl database access~selectAllBitmapFieldsById(db, id) ⇒ +Get bitmap fields from the given bitmap ID. -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters + -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | +### DB API: zcl database access~selectAllBitmapFields(db, packageId) ⇒ +Get all bitmap fields from the given package ID. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of bitmap fields -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | -Retrieves all the bitmaps that are associated with a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps +### DB API: zcl database access~selectAllDomains(db) ⇒ +Retrieves all the domains in the database. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of domains. - +| Param | Type | +| --- | --- | +| db | \* | -### DB API: zcl database access~selectAllDomains(db) ⇒ + -Retrieves all the domains in the database. +### DB API: zcl database access~selectDomainById(db, id) ⇒ +Get Domain details from the given domain ID. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of domain -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ - Retrieves all the structs in the database, including the count of items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | ### DB API: zcl database access~selectStructClusters(db, structId) ⇒ - Returns an array of clusters that struct belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| structId | \* | ### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ - Returns an array of clusters that enum belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| enumId | \* | ### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ - Returns an array of clusters that bitmap belongs to. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: clusters -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| bitmapId | \* | ### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ - Retrieves all the cluster-related structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ - Retrieves all the structs in the database with the items. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### DB API: zcl database access~selectStructsWithItemsImpl(db, packageIds, clusterId) ⇒ +Get Struct details along with its struct items. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: struct details -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | +| clusterId | \* | + + + +### DB API: zcl database access~selectAllStructItemsById(db, id) ⇒ +Get struct item details from the given struct item ID. + +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of Stuct Items + +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | ### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ - Retrieves the struct items based on struct and cluster name. Note: By default clusterName is null. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: the details of the struct items -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +| Param | Default | +| --- | --- | +| db | | +| name | | +| packageIds | | +| clusterName | | ### DB API: zcl database access~selectAllClusters(db) ⇒ - Retrieves all the clusters in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise that resolves with the rows of clusters. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | ### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ - Finds cluster by code. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: cluster by code in a single package id. -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| db | \* | | | +| packageId | \* | | Single packageId or an array of them. | +| clusterCode | \* | | | +| mfgCode | \* | | | ### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ - Returns a promise that resolves into a cluster. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into a cluster object -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | ### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ - Returns attributes for a given cluster. IMPORTANT: -packageIds are needed to properly deal with the global attributes. + packageIds are needed to properly deal with the global attributes. This method will NOT only return the attributes that link to a given cluster, but will ALSO return the attributes that have empty clusterRef (which are global attributes), and the check in that case will be made via packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes - -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | - - - -### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ - -Queries for attributes inside a cluster. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. - -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | - - - -### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) - -This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | - - - -### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ - -Query for attributes by side. - -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | - - - -## DB API: event queries. - -This module provides queries related to events. - - - -## DB API: package-based queries. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise of a list of attributes, including global attributes -This module provides queries related to imports and exports of files. +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | - + -## DB API: zcl loading queries +### DB API: zcl database access~selectAttributesByClusterIdAndSideIncludingGlobal(db, clusterId, packageIds, side) ⇒ +Get attribute details from the given information. -This module provides queries for ZCL loading +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute details -- [DB API: zcl loading queries](#module*DB API* zcl loading queries) - - [~insertAttributeMappings(db, data)](#module*DB API* zcl loading queries..insertAttributeMappings) ⇒ - - [~insertGlobals(db, packageId, data)](#module*DB API* zcl loading queries..insertGlobals) ⇒ - - [~insertClusterExtensions(db, packageId, data)](#module*DB API* zcl loading queries..insertClusterExtensions) ⇒ - - [~insertClusters(db, packageId, data)](#module*DB API* zcl loading queries..insertClusters) ⇒ - - [~insertFeatures(db, packageId, data)](#module*DB API* zcl loading queries..insertFeatures) ⇒ - - [~insertTags(db, packageId, data)](#module*DB API* zcl loading queries..insertTags) ⇒ - - [~insertDomains(db, packageId, data)](#module*DB API* zcl loading queries..insertDomains) ⇒ - - [~insertSpecs(db, packageId, data)](#module*DB API* zcl loading queries..insertSpecs) ⇒ - - [~insertGlobalAttributeDefault(db, packageId, clusterData)](#module*DB API* zcl loading queries..insertGlobalAttributeDefault) ⇒ - - [~insertAtomics(db, packageId, data)](#module*DB API* zcl loading queries..insertAtomics) - - [~insertEndpointComposition(db, composition, context)](#module*DB API* zcl loading queries..insertEndpointComposition) ⇒ - - [~getEndpointCompositionIdByCode(db, deviceType)](#module*DB API* zcl loading queries..getEndpointCompositionIdByCode) ⇒ Promise.<(number\|null)> - - [~insertDeviceComposition(db, deviceType, endpointCompositionId)](#module*DB API* zcl loading queries..insertDeviceComposition) ⇒ Promise - - [~insertDeviceTypes(db, packageId, data)](#module*DB API* zcl loading queries..insertDeviceTypes) ⇒ - - [~insertDeviceTypeFeatures(db, dtClusterRefDataPairs)](#module*DB API* zcl loading queries..insertDeviceTypeFeatures) - - [~insertDeviceTypeAttributes(db, dtClusterRefDataPairs)](#module*DB API* zcl loading queries..insertDeviceTypeAttributes) - - [~insertDeviceTypeCommands(db, dtClusterRefDataPairs)](#module*DB API* zcl loading queries..insertDeviceTypeCommands) - - [~createAccessRows(db, packageId, data)](#module*DB API* zcl loading queries..createAccessRows) - - [~insertDefaultAccess(db, packageId, defaultAccess)](#module*DB API* zcl loading queries..insertDefaultAccess) - - [~updateDataTypeClusterReferences(db, packageId)](#module*DB API* zcl loading queries..updateDataTypeClusterReferences) ⇒ - - [~insertDataTypeDiscriminator(db, packageId, data)](#module*DB API* zcl loading queries..insertDataTypeDiscriminator) - - [~insertDataType(db, packageId, data)](#module*DB API* zcl loading queries..insertDataType) - - [~insertNumber(db, packageId, data)](#module*DB API* zcl loading queries..insertNumber) - - [~insertString(db, packageId, data)](#module*DB API* zcl loading queries..insertString) - - [~insertEnumAtomic(db, packageId, data)](#module*DB API* zcl loading queries..insertEnumAtomic) - - [~insertEnum(db, packageIds, data)](#module*DB API* zcl loading queries..insertEnum) - - [~insertEnumItems(db, packageId, knownPackages, data)](#module*DB API* zcl loading queries..insertEnumItems) - - [~insertBitmapAtomic(db, packageId, data)](#module*DB API* zcl loading queries..insertBitmapAtomic) - - [~insertBitmap(db, packageIds, data)](#module*DB API* zcl loading queries..insertBitmap) - - [~insertBitmapFields(db, packageId, knownPackages, data)](#module*DB API* zcl loading queries..insertBitmapFields) - - [~insertStruct(db, packageIds, data)](#module*DB API* zcl loading queries..insertStruct) - - [~insertStructItems(db, packageIds, data)](#module*DB API* zcl loading queries..insertStructItems) +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageIds | \* | +| side | \* | - + -### DB API: zcl loading queries~insertAttributeMappings(db, data) ⇒ +### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +Queries for attributes inside a cluster. -Load the attribute mapping table with associated attributes +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: attribute mapping ids of the associated attributes +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| clusterCode | \* | +| manufacturerCode | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | -| data | \* | + - +### DB API: zcl database access~selectAttributeById(db, id) ⇒ +Get attribute details from the given attribute ID. -### DB API: zcl loading queries~insertGlobals(db, packageId, data) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attribute -Inserts globals into the database. +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise of globals insertion. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | +### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) -### DB API: zcl loading queries~insertClusterExtensions(db, packageId, data) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| attributeId | \* | +| clusterRef | \* | -Inserts cluster extensions into the database. + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise of cluster extension insertion. +### DB API: zcl database access~selectAllAttributes(db, packageIds) ⇒ +Get all attributes from the given package IDs. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of attributes - +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | -### DB API: zcl loading queries~insertClusters(db, packageId, data) ⇒ + -Inserts clusters into the database. +### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +Query for attributes by side. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise of cluster insertion. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: promise that resolves into attributes. -| Param | Type | Description | -| --------- | --------------- | ------------------------------------------------------------------------------------------------------------------ | -| db | \* | | -| packageId | \* | | -| data | \* | an array of objects that must contain: code, name, description, define. It also contains commands: and attributes: | +| Param | Type | +| --- | --- | +| db | \* | +| side | \* | +| packageId | \* | - + -### DB API: zcl loading queries~insertFeatures(db, packageId, data) ⇒ +### DB API: zcl database access~selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) ⇒ +Get the endpoint type cluster details from the given endpoint type ID. -Inserts features into the database. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type clusters. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: A promise that resolves with array of rowids. +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | + - +### DB API: zcl database access~selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type attribute details from the given endpoint type ID. -### DB API: zcl loading queries~insertTags(db, packageId, data) ⇒ +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attributes. -Inserts tags into the database. -data is an array of objects, containing 'name' and 'description' +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: A promise that resolves with array of rowids. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | +### DB API: zcl database access~selectEndpointTypeAttribute(db, endpointTypeId, attributeRef, clusterRef) ⇒ +Get the endpoint type attribute details from the given details. - +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type attribute. -### DB API: zcl loading queries~insertDomains(db, packageId, data) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | +| attributeRef | \* | +| clusterRef | \* | -Inserts domains into the database. -data is an array of objects that must contain: name + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: A promise that resolves with an array of rowids of all inserted domains. +### DB API: zcl database access~selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) ⇒ +Get the endpoint type command details from the given endpoint type ID. -| Param | Type | Description | -| --------- | --------------- | -------------------------------- | -| db | \* | | -| packageId | \* | | -| data | \* | Data containing name and specRef | +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type commands - +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | -### DB API: zcl loading queries~insertSpecs(db, packageId, data) ⇒ + -Inserts a spec into the database. +### DB API: zcl database access~selectEndpointTypeEventsByEndpointId(db, endpointTypeId) ⇒ +Get endpoint type events from the given endpoint type ID. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise of insertion. +**Kind**: inner method of [DB API: zcl database access](#module_DB API_ zcl database access) +**Returns**: Promise of endpoint type events -| Param | Type | Description | -| --------- | --------------- | -------------------------------------------- | -| db | \* | | -| packageId | \* | | -| data | \* | Data contining specCode and specDescription. | +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeId | \* | - + -### DB API: zcl loading queries~insertGlobalAttributeDefault(db, packageId, clusterData) ⇒ +## JS API: generator logic -Inserts global attribute defaults into the database. +* [JS API: generator logic](#module_JS API_ generator logic) + * [~loadGenTemplateFromFile(path)](#module_JS API_ generator logic..loadGenTemplateFromFile) ⇒ + * [~recordPackageIfNonexistent(db, packagePath, parentId, packageType, version, category, description)](#module_JS API_ generator logic..recordPackageIfNonexistent) ⇒ + * [~loadTemplateOptionsFromJsonFile(db, packageId, category, externalPath)](#module_JS API_ generator logic..loadTemplateOptionsFromJsonFile) ⇒ + * [~recordTemplatesPackage(context)](#module_JS API_ generator logic..recordTemplatesPackage) ⇒ + * [~decodePackageExtensionEntity(entityType, entity)](#module_JS API_ generator logic..decodePackageExtensionEntity) ⇒ + * [~loadZclExtensions(zclExt)](#module_JS API_ generator logic..loadZclExtensions) ⇒ + * [~loadTemplates(db, genTemplatesJsonArray)](#module_JS API_ generator logic..loadTemplates) + * [~loadGenTemplatesJsonFile(db, genTemplatesJson)](#module_JS API_ generator logic..loadGenTemplatesJsonFile) ⇒ + * [~retrievePackageMetaInfo(db, genTemplatesPkgId)](#module_JS API_ generator logic..retrievePackageMetaInfo) ⇒ + * [~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly)](#module_JS API_ generator logic..generateAllTemplates) ⇒ + * [~generateSingleTemplate(genResult, singleTemplatePkg)](#module_JS API_ generator logic..generateSingleTemplate) ⇒ + * [~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options)](#module_JS API_ generator logic..generate) ⇒ + * [~writeFileWithBackup(fileName, content, doBackup)](#module_JS API_ generator logic..writeFileWithBackup) ⇒ + * [~generateGenerationContent(genResult)](#module_JS API_ generator logic..generateGenerationContent) + * [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#module_JS API_ generator logic..generateAndWriteFiles) ⇒ + * [~createGenerationLog(logFile, genData)](#module_JS API_ generator logic..createGenerationLog) + * [~postProcessGeneratedFiles(outputDirectory, genResult)](#module_JS API_ generator logic..postProcessGeneratedFiles) ⇒ + * [~contentIndexer(content)](#module_JS API_ generator logic..contentIndexer) + * [~generateSingleFileForPreview(db, sessionId, fileName)](#module_JS API_ generator logic..generateSingleFileForPreview) ⇒ + * [~produceCompiledTemplate(singleTemplatePkg)](#module_JS API_ generator logic..produceCompiledTemplate) ⇒ + * [~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options)](#module_JS API_ generator logic..produceIterativeContent) ⇒ + * [~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:)](#module_JS API_ generator logic..produceContent) ⇒ + * [~wrapOverridable(originalFn, overrideFn)](#module_JS API_ generator logic..wrapOverridable) ⇒ + * [~loadOverridable(path)](#module_JS API_ generator logic..loadOverridable) + * [~loadPartial(path)](#module_JS API_ generator logic..loadPartial) + * [~helperWrapper(wrappedHelper)](#module_JS API_ generator logic..helperWrapper) ⇒ + * [~loadHelper(helpers)](#module_JS API_ generator logic..loadHelper) + * [~allBuiltInHelpers()](#module_JS API_ generator logic..allBuiltInHelpers) ⇒ + * [~findHelperPackageByAlias(alias)](#module_JS API_ generator logic..findHelperPackageByAlias) ⇒ + * [~initializeBuiltInHelpersForPackage()](#module_JS API_ generator logic..initializeBuiltInHelpersForPackage) + * [~hbInstance()](#module_JS API_ generator logic..hbInstance) ⇒ + * [~makeSynchronizablePromise(promise)](#module_JS API_ generator logic..makeSynchronizablePromise) + * [~collectBlocks(resultArray, options, context)](#module_JS API_ generator logic..collectBlocks) ⇒ + * [~ensureZclPackageId(context)](#module_JS API_ generator logic..ensureZclPackageId) ⇒ + * [~ensureZclPackageIds(context)](#module_JS API_ generator logic..ensureZclPackageIds) ⇒ + * [~ensureTemplatePackageCategory(context)](#module_JS API_ generator logic..ensureTemplatePackageCategory) ⇒ + * [~ensureTemplatePackageId(context)](#module_JS API_ generator logic..ensureTemplatePackageId) ⇒ + * [~ensureEndpointTypeIds(context)](#module_JS API_ generator logic..ensureEndpointTypeIds) ⇒ + * [~ensureZclClusterSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclClusterSdkExtensions) ⇒ + * [~ensureZclDeviceTypeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclDeviceTypeSdkExtensions) ⇒ + * [~ensureZclAttributeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclAttributeSdkExtensions) ⇒ + * [~ensureZclAttributeTypeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclAttributeTypeSdkExtensions) ⇒ + * [~ensureZclCommandSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclCommandSdkExtensions) ⇒ + * [~ensureZclEventSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclEventSdkExtensions) ⇒ + * [~templatePromise(global, promise)](#module_JS API_ generator logic..templatePromise) + * [~deprecatedHelper(fn, explanation)](#module_JS API_ generator logic..deprecatedHelper) ⇒ -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise of data insertion. + -| Param | Type | Description | -| ----------- | --------------- | ------------------------------------------------------------------------------------------------------------------------- | -| db | \* | | -| packageId | \* | | -| clusterData | \* | array of objects that contain: code, manufacturerCode and subarrays of globalAttribute[] which contain: side, code, value | +### JS API: generator logic~loadGenTemplateFromFile(path) ⇒ +Given a path, it will read generation template object into memory. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Object that contains: data, crc, templateData -### DB API: zcl loading queries~insertAtomics(db, packageId, data) +| Param | Type | +| --- | --- | +| path | \* | -Insert atomics into the database. -Data is an array of objects that must contains: name, id, description. -Object might also contain 'size', but possibly not. + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +### JS API: generator logic~recordPackageIfNonexistent(db, packagePath, parentId, packageType, version, category, description) ⇒ +Inserts the package details when they do not exist. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of package insertion - +| Param | Type | +| --- | --- | +| db | \* | +| packagePath | \* | +| parentId | \* | +| packageType | \* | +| version | \* | +| category | \* | +| description | \* | -### DB API: zcl loading queries~insertEndpointComposition(db, composition, context) ⇒ + -Inserts endpoint composition data into the database based on the context's mandatory device type. -This function checks if the context's mandatory device type matches the composition code. -If they match, it performs an insert operation with a specific type from `dbEnum.mandatoryDeviceType`. -If they do not match, it performs an insert with the composition's type. +### JS API: generator logic~loadTemplateOptionsFromJsonFile(db, packageId, category, externalPath) ⇒ +Insert the template options from the json meta data file. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: A promise resolved with the result of the database insert operation. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of inserted template options -| Param | Type | Description | -| ----------- | --------------- | ------------------------------------------------------------------ | -| db | \* | The database connection object. | -| composition | \* | The composition data to be inserted. | -| context | \* | The context containing the mandatory device type to check against. | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| category | \* | +| externalPath | \* | - + -### DB API: zcl loading queries~getEndpointCompositionIdByCode(db, deviceType) ⇒ Promise.<(number\|null)> +### JS API: generator logic~recordTemplatesPackage(context) ⇒ +Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context. -Asynchronously retrieves the ID of an endpoint composition based on its code. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the same context passed in, except packageId added to it -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise.<(number\|null)> - A promise that resolves with the ID of the endpoint composition if found, or null otherwise. +| Param | Type | +| --- | --- | +| context | \* | -| Param | Type | Description | -| ---------- | ------------------- | --------------------------------------------------------------------------- | -| db | Object | The database connection object. | -| deviceType | Object | An object representing the device type, which contains the 'code' property. | + - +### JS API: generator logic~decodePackageExtensionEntity(entityType, entity) ⇒ +This method takes extension data in JSON, and converts it into +an object that contains: + entityCode, entityQualifier, parentCode, manufacturerCode and value -### DB API: zcl loading queries~insertDeviceComposition(db, deviceType, endpointCompositionId) ⇒ Promise +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: object that can be used for database injection -Inserts a new device composition record into the database. +| Param | Type | +| --- | --- | +| entityType | \* | +| entity | \* | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise - A promise that resolves with the result of the database insertion operation. + -| Param | Type | Description | -| --------------------- | ------------------- | ------------------------------------------------------------------------------------ | -| db | Object | The database connection object. | -| deviceType | Object | An object representing the device type, which contains the 'childDeviceId' property. | -| endpointCompositionId | number | The ID of the endpoint composition associated with this device composition. | +### JS API: generator logic~loadZclExtensions(zclExt) ⇒ +Returns a promise that will load the zcl extensions. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of loading the zcl extensions. -### DB API: zcl loading queries~insertDeviceTypes(db, packageId, data) ⇒ +| Param | Type | +| --- | --- | +| zclExt | \* | -Inserts device types into the database. + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: Promise of an insertion of device types. +### JS API: generator logic~loadTemplates(db, genTemplatesJsonArray) +Api that loads an array of template JSON files or a single file if +you just pass in one String. -| Param | Type | Description | -| --------- | --------------- | --------------------------------------------------------------------------------- | -| db | \* | | -| packageId | \* | | -| data | \* | an array of objects that must contain: domain, code, profileId, name, description | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) - +| Param | Type | +| --- | --- | +| db | \* | +| genTemplatesJsonArray | \* | -### DB API: zcl loading queries~insertDeviceTypeFeatures(db, dtClusterRefDataPairs) + -This handles the loading of device type feature requirements into the database. -There is a need to post-process to attach the actual feature ref after the fact +### JS API: generator logic~loadGenTemplatesJsonFile(db, genTemplatesJson) ⇒ +Main API async function to load templates from a gen-template.json file. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: the loading context, contains: db, path, crc, packageId and templateData, or error -| Param | Type | -| --------------------- | --------------- | -| db | \* | -| dtClusterRefDataPairs | \* | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Database | +| genTemplatesJson | \* | Path to the JSON file or an array of paths to JSON file | - + -### DB API: zcl loading queries~insertDeviceTypeAttributes(db, dtClusterRefDataPairs) +### JS API: generator logic~retrievePackageMetaInfo(db, genTemplatesPkgId) ⇒ +Get the package information from the given package ID. -This handles the loading of device type attribute requirements into the database. -There is a need to post-process to attach the actual attribute ref after the fact +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: package information -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +| Param | Type | +| --- | --- | +| db | \* | +| genTemplatesPkgId | \* | -| Param | Type | -| --------------------- | --------------- | -| db | \* | -| dtClusterRefDataPairs | \* | + - +### JS API: generator logic~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly) ⇒ +Generates all the templates inside a toplevel package. -### DB API: zcl loading queries~insertDeviceTypeCommands(db, dtClusterRefDataPairs) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output' -This handles the loading of device type command requirements into the database. -There is a need to post-process to attach the actual command ref after the fact +| Param | Type | Description | +| --- | --- | --- | +| genResult | \* | | +| genTemplateJsonPkg | \* | Package that points to genTemplate.json file | +| generateOnly | \* | if NULL then generate all templates, else only generate template whose out file name matches this. | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) + -| Param | Type | -| --------------------- | --------------- | -| db | \* | -| dtClusterRefDataPairs | \* | +### JS API: generator logic~generateSingleTemplate(genResult, singleTemplatePkg) ⇒ +Function that generates a single package and adds it to the generation result. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the genResult, with newly generated content added. -### DB API: zcl loading queries~createAccessRows(db, packageId, data) +| Param | Type | Description | +| --- | --- | --- | +| genResult | \* | | +| singleTemplatePkg | \* | Single template package. | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) + -| Param | Type | Description | -| --------- | --------------- | ------------------------------------------------ | -| db | \* | | -| packageId | \* | | -| data | \* | array of objects that must have op/role/modifier | +### JS API: generator logic~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options) ⇒ +Main API async function to generate stuff. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into a generation result.Promise that resolves into a generation result. -### DB API: zcl loading queries~insertDefaultAccess(db, packageId, defaultAccess) +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Database | +| sessionId | \* | | +| templatePackageId | \* | packageId Template package id. It can be either single template or gen template json. | +| templateGeneratorOptions | \* | | +| options | \* | | -Inserts a default access. -Default access is object that contains type and access array of {op,role,modifier} + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +### JS API: generator logic~writeFileWithBackup(fileName, content, doBackup) ⇒ +Promise to write out a file, optionally creating a backup. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| packageId | \* | -| defaultAccess | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise of a written file. - +| Param | Type | +| --- | --- | +| fileName | \* | +| content | \* | +| doBackup | \* | -### DB API: zcl loading queries~updateDataTypeClusterReferences(db, packageId) ⇒ + -This function is used as a post loading action for updating the cluster -references of all the data types based on their cluster code. +### JS API: generator logic~generateGenerationContent(genResult) +Returns a promise that resolves into a content that should be written out to gen result file. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) -**Returns**: promise which updates cluster references for data types +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| genResult | \* | - + -### DB API: zcl loading queries~insertDataTypeDiscriminator(db, packageId, data) +### JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒ +Generate files and write them into the given directory. -Insert Data Type Discriminator into the database. -Data is all the data types that can exist with name and whether the type is -a baseline data type or not -for eg -If we have a type called 16BitNumber which is a UINT_16(Actual representation -of 16 Bit unsigned integere) then 16BitNumber is not a baseline data type but -UINT_16 is base line data type. -Note: We have an ignore to silently ignore duplicates +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: a promise which will resolve when all the files are written. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| packageId | \* | +| outputDirectory | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | + - +### JS API: generator logic~createGenerationLog(logFile, genData) +Create a generation log. -### DB API: zcl loading queries~insertDataType(db, packageId, data) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -Insert all Data Types into the database. -The Data Type Cluster table is updated with the data type reference and -cluster code. Cluster code is used later to update the cluster reference of -the Data Type Cluster table(see updateDataTypeClusterReferences). +| Param | Type | +| --- | --- | +| logFile | \* | +| genData | \* | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) + -| Param | Type | Description | -| --------- | --------------- | ------------------------------------------------------------------------------ | -| db | \* | | -| packageId | \* | | -| data | \* | certain data type which is inserted into the data type table based on its type | +### JS API: generator logic~postProcessGeneratedFiles(outputDirectory, genResult) ⇒ +Executes post processing actions as defined by the gen-templates.json - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise of a dealt-with post processing actions -### DB API: zcl loading queries~insertNumber(db, packageId, data) +| Param | Type | +| --- | --- | +| outputDirectory | \* | +| genResult | \* | -Insert all Number data types into the Number Table. + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +### JS API: generator logic~contentIndexer(content) +This async function takes a string, and resolves a preview object out of it. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) - +| Param | Type | Description | +| --- | --- | --- | +| content | \* | String to form into preview. | -### DB API: zcl loading queries~insertString(db, packageId, data) + -Insert all String data types into the String Table. +### JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒ +Generates a single file and feeds it back for preview. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves into a preview object. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| fileName | \* | - + -### DB API: zcl loading queries~insertEnumAtomic(db, packageId, data) +### JS API: generator logic~produceCompiledTemplate(singleTemplatePkg) ⇒ +Resolves into a precompiled template, either from previous precompile or freshly compiled. -Insert all Baseline Enums into the Enum Table. -Baseline enums are enums such as ENUM8, ENUM16 defined in the xml files +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: templates -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +| Param | Type | +| --- | --- | +| singleTemplatePkg | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | + - +### JS API: generator logic~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options) ⇒ +This function is reached if the template is an "iterative one", meaning +it has the iterator set to one of the valid options. -### DB API: zcl loading queries~insertEnum(db, packageIds, data) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into an array of key/content/stats objects. -Insert all Enums into the Enum Table. -Note: Unlike insertEnumAtomic this function adds the enums which are not -baseline enums. +| Param | Type | +| --- | --- | +| hb | \* | +| metaInfo | \* | +| db | \* | +| sessionId | \* | +| singleTemplatePkg | \* | +| genTemplateJsonPackage | \* | +| options | \* | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | -| data | \* | +### JS API: generator logic~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:) ⇒ +Given db connection, session and a single template package, produce the output. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into an array of key/content/stats objects. -### DB API: zcl loading queries~insertEnumItems(db, packageId, knownPackages, data) +| Param | Type | Description | +| --- | --- | --- | +| hb | \* | | +| metaInfo | \* | | +| db | \* | | +| sessionId | \* | | +| singlePkg | \* | | +| overridePath: | \* | if passed, it provides a path to the override file that can override the overridable.js | -Insert all Enum Items into the Enum Item Table. + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +### JS API: generator logic~wrapOverridable(originalFn, overrideFn) ⇒ +This function attemps to call override function, but if override function +throws an exception, it calls the original function. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: result from override function, unless it throws an exception, in which case return result from original function. - +| Param | Type | +| --- | --- | +| originalFn | \* | +| overrideFn | \* | -### DB API: zcl loading queries~insertBitmapAtomic(db, packageId, data) + -Insert all Baseline Bitmaps into the Bitmap Table. -Baseline bitmaps are bitmaps such as BITMAP8/MAP8, BITMAP16/MAP16 defined in -the xml files +### JS API: generator logic~loadOverridable(path) +This function is responsible to load the overridable function container. -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| data | \* | +| Param | Type | Description | +| --- | --- | --- | +| path | \* | of the override file | - + -### DB API: zcl loading queries~insertBitmap(db, packageIds, data) +### JS API: generator logic~loadPartial(path) +Function that loads the partials. -Insert all Bitmaps into the Bitmap Table. -Note: Unlike insertBitmapAtomic this function adds the bitmaps which are not -baseline bitmaps. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +| Param | Type | +| --- | --- | +| path | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | -| data | \* | + - +### JS API: generator logic~helperWrapper(wrappedHelper) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: function -### DB API: zcl loading queries~insertBitmapFields(db, packageId, knownPackages, data) +| Param | Type | +| --- | --- | +| wrappedHelper | \* | -Insert all Bitmap fields into the Bitmap field Table. + -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +### JS API: generator logic~loadHelper(helpers) +Function that loads the helpers. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) - +| Param | Type | Description | +| --- | --- | --- | +| helpers | \* | a string path if value is passed through CLI, the nativeRequire() is leverage the native js function instead of webpack's special sauce. a required() module if invoked by backend js code. this is required to force webpack to resolve the included files as path will be difference after being packed for production. | -### DB API: zcl loading queries~insertStruct(db, packageIds, data) + -Insert all Structs into the Struct Table. +### JS API: generator logic~allBuiltInHelpers() ⇒ +Returns an object that contains all the helper functions, keyed +by their name -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) +NOTE: This method is ONLY used for API testing. You should not use +this method for any real work inside the engine or something. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | -| data | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Object containing all the helper functions. + - +### JS API: generator logic~findHelperPackageByAlias(alias) ⇒ +Given an alias, this method finds a builtin helper package +by its alias. -### DB API: zcl loading queries~insertStructItems(db, packageIds, data) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Helper package or undefined if none was found. -Insert all Struct items into the Struct Item Table. +| Param | Type | +| --- | --- | +| alias | \* | -**Kind**: inner method of [DB API: zcl loading queries](#module*DB API* zcl loading queries) + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | -| data | \* | +### JS API: generator logic~initializeBuiltInHelpersForPackage() +Global helper initialization - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) + -## DB API: session related queries. +### JS API: generator logic~hbInstance() ⇒ +This method returns the correct instance for a given generation flow. -This module provides package notification related queries. +TBD: At this point it doesn't do anything yet, it's just +a central point to get the correct instance. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Instance of handlebars to be used. + -## DB API: package-based queries. +### JS API: generator logic~makeSynchronizablePromise(promise) +All promises used by the templates should be synchronizable. -This module provides queries related to packages. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) - +| Param | Type | +| --- | --- | +| promise | \* | -## DB API: session related queries. + -This module provides session notification related queries. +### JS API: generator logic~collectBlocks(resultArray, options, context) ⇒ +Helpful function that collects the individual blocks by using elements of an array as a context, +executing promises for each, and collecting them into the outgoing string. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves with a content string. -## DB API: zcl database access +| Param | Type | Description | +| --- | --- | --- | +| resultArray | \* | | +| options | \* | Options passed from a block helper. | +| context | \* | The context from within this was called. | -This module provides queries for ZCL static entities -inside a single session. Things like: -all visible clusters, etc. - -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ + - +### JS API: generator logic~ensureZclPackageId(context) ⇒ +Returns the promise that resolves with the ZCL properties package id. -### DB API: zcl database access~clear() +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the package id. -Clears the entire cache. +| Param | Type | +| --- | --- | +| context | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - + -### DB API: zcl database access~put(key, packageId, data) ⇒ +### JS API: generator logic~ensureZclPackageIds(context) ⇒ +Returns the promise that resolves with all ZCL package id specific to current session. -Puts a data object into the cache under a given key/packageId +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with a list of package id. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. +| Param | Type | +| --- | --- | +| context | \* | -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | + - +### JS API: generator logic~ensureTemplatePackageCategory(context) ⇒ +Returns a package category of the toplevel template package from context. -### DB API: zcl database access~get(key, packageId) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: proimise that resolves into a package category -Returns a data object under a given key/packageId. +| Param | Type | +| --- | --- | +| context | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. + -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +### JS API: generator logic~ensureTemplatePackageId(context) ⇒ +Returns the promise that resolves with the ZCL properties package id. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the package id. -### DB API: zcl database access~isCached(key, packageId) ⇒ +| Param | Type | +| --- | --- | +| context | \* | -Returns true if a given key/packageId cache exists. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +### JS API: generator logic~ensureEndpointTypeIds(context) ⇒ +Populate the endpoint type ids into the global context. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: endpoint type ids - +| Param | Type | +| --- | --- | +| context | \* | -### DB API: zcl database access~cacheQuery(key, packageId) ⇒ + -Cache input / output of provided queryFunction -The queryFunction is assumed to have the following signature: +### JS API: generator logic~ensureZclClusterSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached cluster extensions, but if they don't +exist, it will populate them. -async function queryFunction(db, ...) {...} +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with cluster extensions. -The DB handle is ignored and the remaining arguments are used as the cache key. +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. + -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +### JS API: generator logic~ensureZclDeviceTypeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached cluster extensions, but if they don't +exist, it will populate them. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with cluster extensions. -### DB API: zcl database access~cacheStats() +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -Returns the cache statistics. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +### JS API: generator logic~ensureZclAttributeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached attribute extensions, but if they don't +exist, it will populate them. -### DB API: zcl database access~enable() +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with attribute extensions. -Enable the Database Query cache +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - + -### DB API: zcl database access~disable() +### JS API: generator logic~ensureZclAttributeTypeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached attribute type extensions, but if they don't +exist, it will populate them. -Disable the database cache +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with attribute type extensions. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -### DB API: zcl database access~selectAtomicType(db, packageId, typeName) + -Locates atomic type based on a type name. Query is not case sensitive. +### JS API: generator logic~ensureZclCommandSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached command extensions, but if they don't +exist, it will populate them. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with command extensions. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | - + -### DB API: zcl database access~selectAtomicById(db, packageId) +### JS API: generator logic~ensureZclEventSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached command extensions, but if they don't +exist, it will populate them. -Retrieves atomic type by a given Id. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with command extensions. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | + - +### JS API: generator logic~templatePromise(global, promise) +Every helper that returns a promise, should +not return the promise directly. So instead of +returning the promise directly, it should return: + return templatePromise(this.global, promise) -### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> +This will ensure that after tag works as expected. -Checks if a type by a given name is signed. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. +| Param | Type | +| --- | --- | +| global | \* | +| promise | \* | -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | + - +### JS API: generator logic~deprecatedHelper(fn, explanation) ⇒ +Function wrapper that can be used when a helper is deprecated. -### DB API: zcl database access~selectAllBitmaps(db) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: a function that wraps the original function, with deprecation message. -Retrieves all the bitmaps in the database. +| Param | Type | Description | +| --- | --- | --- | +| fn | \* | | +| explanation | \* | can contain `text`, or `from`/`to`, or just be a string message itself. | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. + -| Param | Type | -| ----- | --------------- | -| db | \* | +## Templating API: Access helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} - -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +* [Templating API: Access helpers](#module_Templating API_ Access helpers) + * [~collectDefaultAccessList(ctx, entityType)](#module_Templating API_ Access helpers..collectDefaultAccessList) ⇒ + * [~collectAccesslist(ctx, options)](#module_Templating API_ Access helpers..collectAccesslist) ⇒ + * [~access_aggregate(options)](#module_Templating API_ Access helpers..access_aggregate) + * [~access(options)](#module_Templating API_ Access helpers..access) + * [~default_access(options)](#module_Templating API_ Access helpers..default_access) ⇒ -Select a bitmap matched by name and clusterId. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined +### Templating API: Access helpers~collectDefaultAccessList(ctx, entityType) ⇒ +Collects the default access list -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) +**Returns**: Promise of default access - +| Param | Type | +| --- | --- | +| ctx | \* | +| entityType | \* | -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ + -Retrieves all the enums in the database. +### Templating API: Access helpers~collectAccesslist(ctx, options) ⇒ +Get Access List based on on given options. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) +**Returns**: Access List -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| ctx | \* | +| options | \* | - + -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ +### Templating API: Access helpers~access\_aggregate(options) +This helper creates a context for the aggregates of access. -Retrieves all the enums with cluster references in the database. +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | + - +### Templating API: Access helpers~access(options) +Access helper iterates across all the access triplets associated with the element. +For each element, context contains role, operation, accessModifier. +Additionally it creates booleans hasRole, hasOperation and hasAccessModifier +and hasAtLeastOneAccessElement and hasAllAccessElements -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) -Returns an enum by ID. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum + -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +### Templating API: Access helpers~default\_access(options) ⇒ +Get the access list information. - +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) +**Returns**: access list -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Select all enum items in a package. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items +## Templating API: Attribute helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | - +* [Templating API: Attribute helpers](#module_Templating API_ Attribute helpers) + * [~featureBits(options)](#module_Templating API_ Attribute helpers..featureBits) ⇒ + * [~attributeDefault()](#module_Templating API_ Attribute helpers..attributeDefault) ⇒ -### DB API: zcl database access~selectEnumById(db, id) ⇒ + -Select an enum matched by its primary key. +### Templating API: Attribute helpers~featureBits(options) ⇒ +Get feature bits from the given context. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found +**Kind**: inner method of [Templating API: Attribute helpers](#module_Templating API_ Attribute helpers) +**Returns**: feature bits -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ +### Templating API: Attribute helpers~attributeDefault() ⇒ +Valid within a cluster context, requires code. -Select an enum matched by name. +**Kind**: inner method of [Templating API: Attribute helpers](#module_Templating API_ Attribute helpers) +**Returns**: Produces attribute defaults. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined +## Templating API: C formatting helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | - +* [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + * [~asOffset(hex)](#module_Templating API_ C formatting helpers..asOffset) + * [~asDelimitedMacro(label)](#module_Templating API_ C formatting helpers..asDelimitedMacro) + * [~asHex(label)](#module_Templating API_ C formatting helpers..asHex) ⇒ + * [~asUnderlyingTypeHelper(dataType, context, packageIds)](#module_Templating API_ C formatting helpers..asUnderlyingTypeHelper) ⇒ + * [~asUnderlyingType(value)](#module_Templating API_ C formatting helpers..asUnderlyingType) ⇒ + * [~asType(label)](#module_Templating API_ C formatting helpers..asType) ⇒ + * [~asSymbol(label)](#module_Templating API_ C formatting helpers..asSymbol) ⇒ + * [~formatValue(value, length)](#module_Templating API_ C formatting helpers..formatValue) ⇒ + * [~asBytes(value)](#module_Templating API_ C formatting helpers..asBytes) + * [~asCamelCased(str)](#module_Templating API_ C formatting helpers..asCamelCased) ⇒ + * [~cleanseLabel(label)](#module_Templating API_ C formatting helpers..cleanseLabel) + * [~asUnderscoreLowercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreLowercase) ⇒ + * [~cleanseLabelAsKebabCase(label)](#module_Templating API_ C formatting helpers..cleanseLabelAsKebabCase) + * [~asSpacedLowercase(str)](#module_Templating API_ C formatting helpers..asSpacedLowercase) ⇒ + * [~asUnderscoreUppercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreUppercase) ⇒ + * [~asCliType(size, isSigned)](#module_Templating API_ C formatting helpers..asCliType) ⇒ + * [~as_zcl_cli_type(str, optional, isSigned)](#module_Templating API_ C formatting helpers..as_zcl_cli_type) + * [~dataTypeForBitmap(db, bitmap_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForBitmap) + * [~dataTypeForEnum(db, enum_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForEnum) + * [~addOne(number)](#module_Templating API_ C formatting helpers..addOne) + * [~is_number_greater_than(num1, num2)](#module_Templating API_ C formatting helpers..is_number_greater_than) ⇒ + * [~cluster_extension(options)](#module_Templating API_ C formatting helpers..cluster_extension) ⇒ + * [~device_type_extension(options)](#module_Templating API_ C formatting helpers..device_type_extension) ⇒ + * [~attribute_type_extension(options)](#module_Templating API_ C formatting helpers..attribute_type_extension) ⇒ + * [~subentityExtension(context, prop, entityType)](#module_Templating API_ C formatting helpers..subentityExtension) ⇒ + * [~if_command_extension_true(options)](#module_Templating API_ C formatting helpers..if_command_extension_true) ⇒ + * [~if_command_extension_false(options)](#module_Templating API_ C formatting helpers..if_command_extension_false) ⇒ + * [~if_cluster_extension_true(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_true) ⇒ + * [~if_cluster_extension_false(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_false) ⇒ + * [~attribute_extension(options)](#module_Templating API_ C formatting helpers..attribute_extension) ⇒ + * [~command_extension(options)](#module_Templating API_ C formatting helpers..command_extension) ⇒ + * [~event_extension(options)](#module_Templating API_ C formatting helpers..event_extension) ⇒ -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select an enum matched by name and clusterId. +### Templating API: C formatting helpers~asOffset(hex) +Given a hex number, it prints the offset, which is the index of the first non-zero bit. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| hex | \* | - + -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +### Templating API: C formatting helpers~asDelimitedMacro(label) +Takes a label, and delimits is on camelcasing. +For example: + VerySimpleLabel will turn into VERY_SIMPLE_LABEL -Returns the cluster available to this session by the code. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +| Param | Type | +| --- | --- | +| label | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | + - +### Templating API: C formatting helpers~asHex(label) ⇒ +Formats label as a C hex constant. +If value starts as 0x or 0X it is already treated as hex, +otherwise it is assumed decimal and converted to hex. -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C hex constant. -Returns all the clusters visible for a given session. +| Param | Type | +| --- | --- | +| label | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +### Templating API: C formatting helpers~asUnderlyingTypeHelper(dataType, context, packageIds) ⇒ +This function is a helper function for asUnderlyingType and assists in +returning the correct C type for the given data type - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C type for the given data type -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +| Param | Type | +| --- | --- | +| dataType | \* | +| context | \* | +| packageIds | \* | -Returns the attribute available to this session by the code. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +### Templating API: C formatting helpers~asUnderlyingType(value) ⇒ +Converts the actual zcl type into an underlying usable C type. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C Type - +| Param | Type | +| --- | --- | +| value | \* | -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ + -Returns the command available to this session by the code. +### Templating API: C formatting helpers~asType(label) ⇒ +Formats label as a C type. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C type. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | +| Param | Type | +| --- | --- | +| label | \* | - + -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +### Templating API: C formatting helpers~asSymbol(label) ⇒ +Formats label as a C symbol. -Select a struct matched by name and clusterId +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C symbol. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined +| Param | Type | +| --- | --- | +| label | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### Templating API: C formatting helpers~formatValue(value, length) ⇒ +Formats the default value into an attribute of a given length -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Formatted value -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. +| Param | Type | +| --- | --- | +| value | \* | +| length | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters + -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | +### Templating API: C formatting helpers~asBytes(value) +Given a default value of attribute, this method converts it into bytes - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +| Param | Type | +| --- | --- | +| value | \* | -Retrieves all the bitmaps that are associated with a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps +### Templating API: C formatting helpers~asCamelCased(str) ⇒ +Given a string convert it into a camelCased string -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase - +| Param | Type | +| --- | --- | +| str | \* | -### DB API: zcl database access~selectAllDomains(db) ⇒ + -Retrieves all the domains in the database. +### Templating API: C formatting helpers~cleanseLabel(label) +returns a string after converting ':' and '-' into '_' -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| label | \* | - + -### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ +### Templating API: C formatting helpers~asUnderscoreLowercase(str) ⇒ +Given a camel case string, convert it into one with underscore and lowercase -Retrieves all the structs in the database, including the count -of items. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in lowercase with underscores -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. +| Param | Type | +| --- | --- | +| str | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | + - +### Templating API: C formatting helpers~cleanseLabelAsKebabCase(label) +returns a string after converting ':', ' ' and camel case into '-' -### DB API: zcl database access~selectStructClusters(db, structId) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -Returns an array of clusters that struct belongs to. +| Param | Type | +| --- | --- | +| label | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters + -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | +### Templating API: C formatting helpers~asSpacedLowercase(str) ⇒ +Given a camel case string convert it into one with space and lowercase - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase -### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ +| Param | Type | +| --- | --- | +| str | \* | -Returns an array of clusters that enum belongs to. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +### Templating API: C formatting helpers~asUnderscoreUppercase(str) ⇒ +Given a camel case string convert it into one with underscore and uppercase -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in uppercase with underscores - +| Param | Type | +| --- | --- | +| str | \* | -### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ + -Returns an array of clusters that bitmap belongs to. +### Templating API: C formatting helpers~asCliType(size, isSigned) ⇒ +Returns the cli type representation. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: the type representation required for CLI. -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | +| Param | +| --- | +| size | +| isSigned | - + -### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ +### Templating API: C formatting helpers~as\_zcl\_cli\_type(str, optional, isSigned) +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -Retrieves all the cluster-related structs in the database with the items. +| Param | Description | +| --- | --- | +| str | | +| optional | | +| isSigned | Return the data type of zcl cli | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + -| Param | Type | -| ----- | --------------- | -| db | \* | +### Templating API: C formatting helpers~dataTypeForBitmap(db, bitmap_name, packageIds) +Returns the type of bitmap based on the bitmap's name - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| bitmap_name | \* | +| packageIds | \* | -Retrieves all the structs in the database with the items. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +### Templating API: C formatting helpers~dataTypeForEnum(db, enum_name, packageIds) +Returns the type of enum -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) - +| Param | Type | +| --- | --- | +| db | \* | +| enum_name | \* | +| packageIds | \* | -### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ + -Retrieves the struct items based on struct and cluster name. -Note: By default clusterName is null. +### Templating API: C formatting helpers~addOne(number) +Returns the number by adding 1 to it. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +| Param | Type | +| --- | --- | +| number | \* | - + -### DB API: zcl database access~selectAllClusters(db) ⇒ +### Templating API: C formatting helpers~is\_number\_greater\_than(num1, num2) ⇒ +Return true if number1 is greater than number2 -Retrieves all the clusters in the database. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: true if num1 is greater than num2 else returns false -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +| Param | +| --- | +| num1 | +| num2 | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### Templating API: C formatting helpers~cluster\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. -### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. -Finds cluster by code. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. + -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +### Templating API: C formatting helpers~device\_type\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. -### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Returns a promise that resolves into a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +### Templating API: C formatting helpers~attribute\_type\_extension(options) ⇒ +When inside a context that contains 'type', this +helper will output the value of the attribute type extension +specified by property="propName" attribute. -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute type extension property. - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ + -Returns attributes for a given cluster. -IMPORTANT: -packageIds are needed to properly deal with the global attributes. +### Templating API: C formatting helpers~subentityExtension(context, prop, entityType) ⇒ +Get extension values for the given information. -This method will NOT only return the attributes that link to -a given cluster, but will ALSO return the attributes that have -empty clusterRef (which are global attributes), and the check -in that case will be made via packageId. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: extension default value -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes +| Param | Type | +| --- | --- | +| context | \* | +| prop | \* | +| entityType | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | + - +### Templating API: C formatting helpers~if\_command\_extension\_true(options) ⇒ +If helper for command extensions(true condition). -### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper -Queries for attributes inside a cluster. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. + -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | +### Templating API: C formatting helpers~if\_command\_extension\_false(options) ⇒ +If helper for command extensions(false condition). - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper -### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +| Param | Type | +| --- | --- | +| options | \* | -This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +### Templating API: C formatting helpers~if\_cluster\_extension\_true(options) ⇒ +If helper for cluster extensions(true condition). -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ + -Query for attributes by side. +### Templating API: C formatting helpers~if\_cluster\_extension\_false(options) ⇒ +If helper for cluster extensions(false condition). -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -## DB API: session related queries. +### Templating API: C formatting helpers~attribute\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the attribute extension +specified by property="propName" attribute. -This module provides session related queries. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute extension property. - +| Param | Type | +| --- | --- | +| options | \* | -## DB API: zcl database access + -This module provides queries for enums. +### Templating API: C formatting helpers~command\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~clear() + -Clears the entire cache. +### Templating API: C formatting helpers~event\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. -### DB API: zcl database access~put(key, packageId, data) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Puts a data object into the cache under a given key/packageId + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. +## Templating API: Command helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | - +* [Templating API: Command helpers](#module_Templating API_ Command helpers) + * [~if_command_arguments_exist(commandId, argument_return, no_argument_return)](#module_Templating API_ Command helpers..if_command_arguments_exist) + * [~if_command_args_exist(commandId, options)](#module_Templating API_ Command helpers..if_command_args_exist) ⇒ + * [~if_ca_always_present_with_presentif(commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_ca_always_present_with_presentif) ⇒ + * [~if_command_arg_always_present_with_presentif(commandArg, options)](#module_Templating API_ Command helpers..if_command_arg_always_present_with_presentif) ⇒ + * [~if_command_is_not_fixed_length_but_command_argument_is_always_present(command, commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_command_is_not_fixed_length_but_command_argument_is_always_present) ⇒ + * [~if_command_not_fixed_length_command_argument_always_present(command, commandArg, options)](#module_Templating API_ Command helpers..if_command_not_fixed_length_command_argument_always_present) ⇒ + * [~if_ca_not_always_present_no_presentif(commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_ca_not_always_present_no_presentif) ⇒ + * [~if_command_arg_not_always_present_no_presentif(commandArg, options)](#module_Templating API_ Command helpers..if_command_arg_not_always_present_no_presentif) ⇒ + * [~if_ca_not_always_present_with_presentif(commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_ca_not_always_present_with_presentif) ⇒ + * [~if_command_arg_not_always_present_with_presentif(commandArg, options)](#module_Templating API_ Command helpers..if_command_arg_not_always_present_with_presentif) ⇒ + * [~if_command_is_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn)](#module_Templating API_ Command helpers..if_command_is_fixed_length) + * [~if_command_fixed_length(commandId, options)](#module_Templating API_ Command helpers..if_command_fixed_length) + + + +### Templating API: Command helpers~if\_command\_arguments\_exist(commandId, argument_return, no_argument_return) +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) + +| Param | Type | Description | +| --- | --- | --- | +| commandId | \* | | +| argument_return | \* | | +| no_argument_return | \* | If the command arguments for a command exist then returns argument_return else returns no_argument_return Example: {{if_command_arguments_exist [command-id] "," ""}} The above will return ',' if the command arguments for a command exist and will return nothing if the command arguments for a command do not exist. | -### DB API: zcl database access~get(key, packageId) ⇒ + -Returns a data object under a given key/packageId. +### Templating API: Command helpers~if\_command\_args\_exist(commandId, options) ⇒ +If helper which checks if command arguments exist for a command or not +example: +{{#if_command_args_exist commandId}} + command arguments exist for the command +{{else}} + command arguments do not exist for the command +{{/if_command_args_exist}} -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on whether the +command arguments are present or not. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | +| --- | +| commandId | +| options | - + -### DB API: zcl database access~isCached(key, packageId) ⇒ +### Templating API: Command helpers~if\_ca\_always\_present\_with\_presentif(commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command argument is always present and there is a +presentIf condition else returns false -Returns true if a given key/packageId cache exists. +| Param | +| --- | +| commandArg | +| trueReturn | +| falseReturn | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. + -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +### Templating API: Command helpers~if\_command\_arg\_always\_present\_with\_presentif(commandArg, options) ⇒ +If helper that checks if a command argument is always present with a +presentIf condition. +example: +{{#if_command_arg_always_present_with_presentif commandArg}} + command argument has a presentIf condition +{{else}} + command argument does not have a presentIf condition +{{/if_command_arg_always_present_with_presentif}} - +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command +argument having a presentIf condition or not -### DB API: zcl database access~cacheQuery(key, packageId) ⇒ +| Param | +| --- | +| commandArg | +| options | -Cache input / output of provided queryFunction -The queryFunction is assumed to have the following signature: + -async function queryFunction(db, ...) {...} +### Templating API: Command helpers~if\_command\_is\_not\_fixed\_length\_but\_command\_argument\_is\_always\_present(command, commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command is not fixed length but command argument is +always present else returns falseReturn -The DB handle is ignored and the remaining arguments are used as the cache key. +| Param | +| --- | +| command | +| commandArg | +| trueReturn | +| falseReturn | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. + -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +### Templating API: Command helpers~if\_command\_not\_fixed\_length\_command\_argument\_always\_present(command, commandArg, options) ⇒ +If helper that checks if command is not fixed lenth and that the command is +always present. +example: +{{#if_command_not_fixed_length_command_argument_always_present commandId}} + command is not fixed length and command argument is always present +{{else}} + either command is fixed length or command argument is not always present +{{/if_command_not_fixed_length_command_argument_always_present}} - +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command being +fixed length or not and whether the command argument is always present -### DB API: zcl database access~cacheStats() +| Param | +| --- | +| command | +| commandArg | +| options | -Returns the cache statistics. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +### Templating API: Command helpers~if\_ca\_not\_always\_present\_no\_presentif(commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command argument is not always present and there is no +presentIf condition else returns false -### DB API: zcl database access~enable() +| Param | +| --- | +| commandArg | +| trueReturn | +| falseReturn | -Enable the Database Query cache + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +### Templating API: Command helpers~if\_command\_arg\_not\_always\_present\_no\_presentif(commandArg, options) ⇒ +If helper that checks if a command argument is not always present because it +has a introduced in or removed in clause. The helper also checks that there +is no presentIf condition. +example: +{{#if_command_arg_not_always_present_no_presentif commandArg}} + command argument is not always present and there is no presentIf condition +{{else}} + Either command argument is always present or there is a presentIf condition +{{/if_command_arg_not_always_present_no_presentif}} -### DB API: zcl database access~disable() +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command +argument being present and if there is a presentIf condition. -Disable the database cache +| Param | +| --- | +| commandArg | +| options | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - + -### DB API: zcl database access~selectAtomicType(db, packageId, typeName) +### Templating API: Command helpers~if\_ca\_not\_always\_present\_with\_presentif(commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command argument is not always present and there is a +presentIf condition else returns false -Locates atomic type based on a type name. Query is not case sensitive. +| Param | +| --- | +| commandArg | +| trueReturn | +| falseReturn | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | +### Templating API: Command helpers~if\_command\_arg\_not\_always\_present\_with\_presentif(commandArg, options) ⇒ +If helper that checks if a command argument is not always present because it +has a introduced in or removed in clause. The helper also checks that there +is a presentIf condition. +example: +{{#if_command_arg_not_always_present_with_presentif commandArg}} + command argument is not always present and there is a presentIf condition +{{else}} + Either command argument is always present or there is no presentIf condition +{{/if_command_arg_not_always_present_with_presentif}} - +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command +argument being present and if there is a presentIf condition. -### DB API: zcl database access~selectAtomicById(db, packageId) +| Param | +| --- | +| commandArg | +| options | -Retrieves atomic type by a given Id. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +### Templating API: Command helpers~if\_command\_is\_fixed\_length(commandId, fixedLengthReturn, notFixedLengthReturn) +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Description | +| --- | --- | +| commandId | | +| fixedLengthReturn | | +| notFixedLengthReturn | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not. Also checks if the command arguments are always present or not. | - + -### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> +### Templating API: Command helpers~if\_command\_fixed\_length(commandId, options) +If helper which checks if a command is fixed length or not -Checks if a type by a given name is signed. +example: +{{#if_command_fixed_length commandId}} +command is fixed length +{{else}} +command is not fixed length +{{/if_command_fixed_length}} -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | +| Param | Description | +| --- | --- | +| commandId | | +| options | Returns content in the handlebar template based on the command being fixed length or not as shown in the example above. | - + -### DB API: zcl database access~selectAllBitmaps(db) ⇒ +## Templating API: Matter endpoint config helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -Retrieves all the bitmaps in the database. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. +* [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) + * [~endpoint_type_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_type_count) ⇒ + * [~endpoint_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_count) ⇒ + * [~endpoint_config_macros()](#module_Templating API_ Matter endpoint config helpers..endpoint_config_macros) ⇒ + * [~endpoint_fixed_endpoint_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_endpoint_array) ⇒ + * [~endpoint_fixed_profile_id_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_profile_id_array) ⇒ + * [~endpoint_fixed_parent_id_array()](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_parent_id_array) ⇒ + * [~endpoint_fixed_network_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_network_array) ⇒ + * [~endpoint_fixed_endpoint_type_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_endpoint_type_array) ⇒ + * [~createMfgCodes(codeIndexPairs)](#module_Templating API_ Matter endpoint config helpers..createMfgCodes) ⇒ + * [~endpoint_attribute_manufacturer_codes(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_manufacturer_codes) ⇒ + * [~endpoint_attribute_manufacturer_code_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_manufacturer_code_count) ⇒ + * [~endpoint_command_manufacturer_codes(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_manufacturer_codes) ⇒ + * [~endpoint_command_manufacturer_code_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_manufacturer_code_count) ⇒ + * [~endpoint_cluster_manufacturer_codes(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_manufacturer_codes) ⇒ + * [~endpoint_cluster_manufacturer_code_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_manufacturer_code_count) ⇒ + * [~endpoint_largest_attribute_size(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_largest_attribute_size) ⇒ + * [~endpoint_singletons_size(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_singletons_size) ⇒ + * [~endpoint_total_storage_size(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_total_storage_size) ⇒ + * [~endpoint_command_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_count) ⇒ + * [~endpoint_types_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_types_list) ⇒ + * [~endpoint_cluster_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_count) ⇒ + * [~endpoint_cluster_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_list) ⇒ + * [~endpoint_command_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_list) ⇒ + * [~endpoint_attribute_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_count) ⇒ + * [~endpoint_attribute_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_list) ⇒ + * [~device_list(context, options)](#module_Templating API_ Matter endpoint config helpers..device_list) ⇒ + * [~endpoint_fixed_device_type_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_device_type_array) ⇒ + * [~endpoint_fixed_device_type_array_offsets(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_device_type_array_offsets) ⇒ + * [~endpoint_fixed_device_type_array_lengths(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_device_type_array_lengths) ⇒ + * [~endpoint_attribute_min_max_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_min_max_count) ⇒ + * [~endpoint_attribute_min_max_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_min_max_list) ⇒ + * [~endpoint_reporting_config_defaults(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_reporting_config_defaults) + * [~endpoint_reporting_config_default_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_reporting_config_default_count) ⇒ + * [~endpoint_attribute_long_defaults_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_long_defaults_count) ⇒ + * [~endpoint_attribute_long_defaults(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_long_defaults) ⇒ + * [~asMEI(manufacturerCode, code)](#module_Templating API_ Matter endpoint config helpers..asMEI) ⇒ + * [~determineAttributeDefaultValue(specifiedDefault, type, typeSize, isNullable, db, sessionId)](#module_Templating API_ Matter endpoint config helpers..determineAttributeDefaultValue) ⇒ + * [~collectAttributes()](#module_Templating API_ Matter endpoint config helpers..collectAttributes) + * [~collectAttributeSizes(db, zclPackageIds, endpointTypes)](#module_Templating API_ Matter endpoint config helpers..collectAttributeSizes) ⇒ + * [~collectAttributeTypeInfo(db, zclPackageIds, endpointTypes)](#module_Templating API_ Matter endpoint config helpers..collectAttributeTypeInfo) ⇒ + * [~isGlobalAttrExcludedFromMetadata(attr)](#module_Templating API_ Matter endpoint config helpers..isGlobalAttrExcludedFromMetadata) ⇒ + * [~endpoint_config(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_config) ⇒ + + + +### Templating API: Matter endpoint config helpers~endpoint\_type\_count(options) ⇒ +Returns number of endpoint types. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: number of endpoint types - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select a bitmap matched by name and clusterId. +### Templating API: Matter endpoint config helpers~endpoint\_count(options) ⇒ +Returns number of endpoints. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: number of endpoints -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ +### Templating API: Matter endpoint config helpers~endpoint\_config\_macros() ⇒ +Prints out all the macros that the endpoint config +configuration depends on. These macros are created +by ZAP, because the use of these macros is also +created by ZAP. -Retrieves all the enums in the database. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Macros that need to be created + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_endpoint\_array(options) ⇒ +Creates array of endpointId fields on endpoints -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ + -Retrieves all the enums with cluster references in the database. +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_profile\_id\_array(options) ⇒ +Creates array of profileId fields on endpoints -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_parent\_id\_array() ⇒ +Creates Integer Array of parent endpoint identifier fields on endpoints. If the Parent Endpoint is not set then it will default to 0. -Returns an enum by ID. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_network\_array(options) ⇒ +Creates array of networkId fields on endpoints -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ + -Select all enum items in a package. +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_endpoint\_type\_array(options) ⇒ +Each element of an array contains an index into the +endpoint type array, for the appropriate endpoint. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array of indexes, one for each endpoint. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectEnumById(db, id) ⇒ +### Templating API: Matter endpoint config helpers~createMfgCodes(codeIndexPairs) ⇒ +Get indexes and manufacturer code. -Select an enum matched by its primary key. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: String -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found +| Param | Type | +| --- | --- | +| codeIndexPairs | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | + - +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_manufacturer\_codes(options) ⇒ +Generates array of { index , mfgCode } pairs, matching +the indexes in attribute table. -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: manufacturer code array -Select an enum matched by name. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_manufacturer\_code\_count(options) ⇒ +Get count of attributes with manufacturer code. - +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of attributes with manufacturer code -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Select an enum matched by name and clusterId. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +### Templating API: Matter endpoint config helpers~endpoint\_command\_manufacturer\_codes(options) ⇒ +Get all command manufacturer codes. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: all command manufacturer codes - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ + -Returns the cluster available to this session by the code. +### Templating API: Matter endpoint config helpers~endpoint\_command\_manufacturer\_code\_count(options) ⇒ +Get count of commands with manufacturer code. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of commands with manufacturer code -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_manufacturer\_codes(options) ⇒ +Get all cluster manufacturer codes. -Returns all the clusters visible for a given session. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: all cluster manufacturer codes -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | + - +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_manufacturer\_code\_count(options) ⇒ +Get count of clusters with manufacturer code. -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of clusters with manufacturer code -Returns the attribute available to this session by the code. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute + -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +### Templating API: Matter endpoint config helpers~endpoint\_largest\_attribute\_size(options) ⇒ +Get size of largest attribute. - +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: size of largest attribute -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Returns the command available to this session by the code. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +### Templating API: Matter endpoint config helpers~endpoint\_singletons\_size(options) ⇒ +Get cumulative size of all singleton endpoint type attributes. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: cumulative size of all singleton endpoint type attributes - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select a struct matched by name and clusterId +### Templating API: Matter endpoint config helpers~endpoint\_total\_storage\_size(options) ⇒ +Get cumulative size of all endpoint type attributes. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: cumulative size of all endpoint type attributes -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +### Templating API: Matter endpoint config helpers~endpoint\_command\_count(options) ⇒ +Get count of endpoint type commands. -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of endpoint type commands -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | + - +### Templating API: Matter endpoint config helpers~endpoint\_types\_list(options) ⇒ +Get endpoint type information. -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type information -Retrieves all the bitmaps that are associated with a cluster. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_count(options) ⇒ +Get count of endpoint type clusters. - +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of endpoint type clusters -### DB API: zcl database access~selectAllDomains(db) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Retrieves all the domains in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_list(options) ⇒ +Get endpoint type cluster information. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type cluster information - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ + -Retrieves all the structs in the database, including the count -of items. +### Templating API: Matter endpoint config helpers~endpoint\_command\_list(options) ⇒ +Get endpoint type command information. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type command information -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectStructClusters(db, structId) ⇒ +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_count(options) ⇒ +Get count of endpoint type attributes. -Returns an array of clusters that struct belongs to. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of endpoint type attributes -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | + - +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_list(options) ⇒ +Get endpoint type attribute information. -### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type attribute information -Returns an array of clusters that enum belongs to. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters + -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +### Templating API: Matter endpoint config helpers~device\_list(context, options) ⇒ +Extracting device versions and identifiers from endpoint types - +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: list of device types -### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ +| Param | Type | +| --- | --- | +| context | \* | +| options | \* | -Returns an array of clusters that bitmap belongs to. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_device\_type\_array(options) ⇒ +Get all device types in the configuration. -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: device types - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ + -Retrieves all the cluster-related structs in the database with the items. +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_device\_type\_array\_offsets(options) ⇒ +Get device type offset per endpoint. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Device type offset per endpoint -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_device\_type\_array\_lengths(options) ⇒ +Get count of device types per endpoint. -Retrieves all the structs in the database with the items. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of device types per endpoint -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_min\_max\_count(options) ⇒ +Get count of total attributes with min max values listed. -### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: count of total attributes with min max values listed -Retrieves the struct items based on struct and cluster name. -Note: By default clusterName is null. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items + -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_min\_max\_list(options) ⇒ +Get all attributes with min max values defined. - +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: All attributes with min max values listed -### DB API: zcl database access~selectAllClusters(db) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Retrieves all the clusters in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +### Templating API: Matter endpoint config helpers~endpoint\_reporting\_config\_defaults(options) +This helper supports an "order" CSV string, such as: + "direction,endpoint,clusterId,attributeId,mask,mfgCode,minmax" +The string above is a default value, and it determines in what order are the fields generated. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ + -Finds cluster by code. +### Templating API: Matter endpoint config helpers~endpoint\_reporting\_config\_default\_count(options) ⇒ +Get count of total attributes with reporting enabled -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of total attributes with reporting enabled -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_long\_defaults\_count(options) ⇒ +Get long(size>2 bytes) attribute count. -Returns a promise that resolves into a cluster. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: count of long attributes -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | + - +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_long\_defaults(options) ⇒ +Get long(size>2 bytes) attribute default values based on endianness. -### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Long attribute's default values -Returns attributes for a given cluster. -IMPORTANT: -packageIds are needed to properly deal with the global attributes. +| Param | Type | +| --- | --- | +| options | \* | -This method will NOT only return the attributes that link to -a given cluster, but will ALSO return the attributes that have -empty clusterRef (which are global attributes), and the check -in that case will be made via packageId. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes +### Templating API: Matter endpoint config helpers~asMEI(manufacturerCode, code) ⇒ +Get 32 bit code from the given code and manufacturer code. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: 32 bit Hex Code. - +| Param | Type | +| --- | --- | +| manufacturerCode | \* | +| code | \* | -### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ + -Queries for attributes inside a cluster. +### Templating API: Matter endpoint config helpers~determineAttributeDefaultValue(specifiedDefault, type, typeSize, isNullable, db, sessionId) ⇒ +The representation of null depends on the type, so we can't use a single +macro that's defined elsewhere for "null value". +Get the default value of an attribute. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Attribute's default value -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | +| Param | Type | +| --- | --- | +| specifiedDefault | \* | +| type | \* | +| typeSize | \* | +| isNullable | \* | +| db | \* | +| sessionId | \* | - + -### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +### Templating API: Matter endpoint config helpers~collectAttributes() +Attribute collection works like this: + 1.) Go over all the clusters that exist. + 2.) If client is included on at least one endpoint add client atts. + 3.) If server is included on at least one endpoint add server atts. -This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +### Templating API: Matter endpoint config helpers~collectAttributeSizes(db, zclPackageIds, endpointTypes) ⇒ +This function goes over all the attributes and populates sizes. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: promise that resolves with the passed endpointTypes, after populating the attribute type sizes. - +| Param | Type | +| --- | --- | +| db | \* | +| zclPackageIds | \* | +| endpointTypes | \* | -### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ + -Query for attributes by side. +### Templating API: Matter endpoint config helpers~collectAttributeTypeInfo(db, zclPackageIds, endpointTypes) ⇒ +This function goes over all attributes and populates atomic types. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: promise that resolves with the passed endpointTypes, after populating the attribute atomic types. -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| zclPackageIds | \* | +| endpointTypes | \* | - + -## DB API: zcl database access +### Templating API: Matter endpoint config helpers~isGlobalAttrExcludedFromMetadata(attr) ⇒ +Checks if global attribute is excluded from the meta data. -This module provides a place for creating generic queries which are common -across different query files. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: boolean -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ +| Param | Type | +| --- | --- | +| attr | \* | - + -### DB API: zcl database access~clear() +### Templating API: Matter endpoint config helpers~endpoint\_config(options) ⇒ +Starts the endpoint configuration block., +longDefaults: longDefaults -Clears the entire cache. +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: a promise of a rendered block -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~put(key, packageId, data) ⇒ + -Puts a data object into the cache under a given key/packageId +## Templating API: Future helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | +* [Templating API: Future helpers](#module_Templating API_ Future helpers) + * [~ifFuture(options)](#module_Templating API_ Future helpers..ifFuture) + * [~setFuture(options)](#module_Templating API_ Future helpers..setFuture) + * [~future(options)](#module_Templating API_ Future helpers..future) - + -### DB API: zcl database access~get(key, packageId) ⇒ +### Templating API: Future helpers~ifFuture(options) +Block helper resolving the block if the +value of the specified future matches. -Returns a data object under a given key/packageId. +**Kind**: inner method of [Templating API: Future helpers](#module_Templating API_ Future helpers) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | + - +### Templating API: Future helpers~setFuture(options) +This method sets the value of the future. +Use it as: + {{set_future name="NAME" value="VALUE"}} -### DB API: zcl database access~isCached(key, packageId) ⇒ +**Kind**: inner method of [Templating API: Future helpers](#module_Templating API_ Future helpers) -Returns true if a given key/packageId cache exists. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. + -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +### Templating API: Future helpers~future(options) +This method defines the future with a given name. +Use it as: {{future name="NAME"}} - +**Kind**: inner method of [Templating API: Future helpers](#module_Templating API_ Future helpers) -### DB API: zcl database access~cacheQuery(key, packageId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Cache input / output of provided queryFunction -The queryFunction is assumed to have the following signature: + -async function queryFunction(db, ...) {...} +## Templating API: SDK extension helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -The DB handle is ignored and the remaining arguments are used as the cache key. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +## Templating API: C formatting helpers +This module contains the API for accessing SDK extensions. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | - +* [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + * [~asOffset(hex)](#module_Templating API_ C formatting helpers..asOffset) + * [~asDelimitedMacro(label)](#module_Templating API_ C formatting helpers..asDelimitedMacro) + * [~asHex(label)](#module_Templating API_ C formatting helpers..asHex) ⇒ + * [~asUnderlyingTypeHelper(dataType, context, packageIds)](#module_Templating API_ C formatting helpers..asUnderlyingTypeHelper) ⇒ + * [~asUnderlyingType(value)](#module_Templating API_ C formatting helpers..asUnderlyingType) ⇒ + * [~asType(label)](#module_Templating API_ C formatting helpers..asType) ⇒ + * [~asSymbol(label)](#module_Templating API_ C formatting helpers..asSymbol) ⇒ + * [~formatValue(value, length)](#module_Templating API_ C formatting helpers..formatValue) ⇒ + * [~asBytes(value)](#module_Templating API_ C formatting helpers..asBytes) + * [~asCamelCased(str)](#module_Templating API_ C formatting helpers..asCamelCased) ⇒ + * [~cleanseLabel(label)](#module_Templating API_ C formatting helpers..cleanseLabel) + * [~asUnderscoreLowercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreLowercase) ⇒ + * [~cleanseLabelAsKebabCase(label)](#module_Templating API_ C formatting helpers..cleanseLabelAsKebabCase) + * [~asSpacedLowercase(str)](#module_Templating API_ C formatting helpers..asSpacedLowercase) ⇒ + * [~asUnderscoreUppercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreUppercase) ⇒ + * [~asCliType(size, isSigned)](#module_Templating API_ C formatting helpers..asCliType) ⇒ + * [~as_zcl_cli_type(str, optional, isSigned)](#module_Templating API_ C formatting helpers..as_zcl_cli_type) + * [~dataTypeForBitmap(db, bitmap_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForBitmap) + * [~dataTypeForEnum(db, enum_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForEnum) + * [~addOne(number)](#module_Templating API_ C formatting helpers..addOne) + * [~is_number_greater_than(num1, num2)](#module_Templating API_ C formatting helpers..is_number_greater_than) ⇒ + * [~cluster_extension(options)](#module_Templating API_ C formatting helpers..cluster_extension) ⇒ + * [~device_type_extension(options)](#module_Templating API_ C formatting helpers..device_type_extension) ⇒ + * [~attribute_type_extension(options)](#module_Templating API_ C formatting helpers..attribute_type_extension) ⇒ + * [~subentityExtension(context, prop, entityType)](#module_Templating API_ C formatting helpers..subentityExtension) ⇒ + * [~if_command_extension_true(options)](#module_Templating API_ C formatting helpers..if_command_extension_true) ⇒ + * [~if_command_extension_false(options)](#module_Templating API_ C formatting helpers..if_command_extension_false) ⇒ + * [~if_cluster_extension_true(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_true) ⇒ + * [~if_cluster_extension_false(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_false) ⇒ + * [~attribute_extension(options)](#module_Templating API_ C formatting helpers..attribute_extension) ⇒ + * [~command_extension(options)](#module_Templating API_ C formatting helpers..command_extension) ⇒ + * [~event_extension(options)](#module_Templating API_ C formatting helpers..event_extension) ⇒ -### DB API: zcl database access~cacheStats() + -Returns the cache statistics. +### Templating API: C formatting helpers~asOffset(hex) +Given a hex number, it prints the offset, which is the index of the first non-zero bit. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -### DB API: zcl database access~enable() +| Param | Type | +| --- | --- | +| hex | \* | -Enable the Database Query cache + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +### Templating API: C formatting helpers~asDelimitedMacro(label) +Takes a label, and delimits is on camelcasing. +For example: + VerySimpleLabel will turn into VERY_SIMPLE_LABEL -### DB API: zcl database access~disable() +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -Disable the database cache +| Param | Type | +| --- | --- | +| label | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - + -### DB API: zcl database access~selectAtomicType(db, packageId, typeName) +### Templating API: C formatting helpers~asHex(label) ⇒ +Formats label as a C hex constant. +If value starts as 0x or 0X it is already treated as hex, +otherwise it is assumed decimal and converted to hex. -Locates atomic type based on a type name. Query is not case sensitive. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C hex constant. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +| Param | Type | +| --- | --- | +| label | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | + - +### Templating API: C formatting helpers~asUnderlyingTypeHelper(dataType, context, packageIds) ⇒ +This function is a helper function for asUnderlyingType and assists in +returning the correct C type for the given data type -### DB API: zcl database access~selectAtomicById(db, packageId) +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C type for the given data type -Retrieves atomic type by a given Id. +| Param | Type | +| --- | --- | +| dataType | \* | +| context | \* | +| packageIds | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +### Templating API: C formatting helpers~asUnderlyingType(value) ⇒ +Converts the actual zcl type into an underlying usable C type. - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C Type -### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> +| Param | Type | +| --- | --- | +| value | \* | -Checks if a type by a given name is signed. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. +### Templating API: C formatting helpers~asType(label) ⇒ +Formats label as a C type. -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C type. - +| Param | Type | +| --- | --- | +| label | \* | -### DB API: zcl database access~selectAllBitmaps(db) ⇒ + -Retrieves all the bitmaps in the database. +### Templating API: C formatting helpers~asSymbol(label) ⇒ +Formats label as a C symbol. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C symbol. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| label | \* | - + -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +### Templating API: C formatting helpers~formatValue(value, length) ⇒ +Formats the default value into an attribute of a given length -Select a bitmap matched by name and clusterId. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Formatted value -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined +| Param | Type | +| --- | --- | +| value | \* | +| length | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### Templating API: C formatting helpers~asBytes(value) +Given a default value of attribute, this method converts it into bytes -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -Retrieves all the enums in the database. +| Param | Type | +| --- | --- | +| value | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +### Templating API: C formatting helpers~asCamelCased(str) ⇒ +Given a string convert it into a camelCased string - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ +| Param | Type | +| --- | --- | +| str | \* | -Retrieves all the enums with cluster references in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### Templating API: C formatting helpers~cleanseLabel(label) +returns a string after converting ':' and '-' into '_' -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) - +| Param | Type | +| --- | --- | +| label | \* | -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ + -Returns an enum by ID. +### Templating API: C formatting helpers~asUnderscoreLowercase(str) ⇒ +Given a camel case string, convert it into one with underscore and lowercase -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in lowercase with underscores -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +| Param | Type | +| --- | --- | +| str | \* | - + -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ +### Templating API: C formatting helpers~cleanseLabelAsKebabCase(label) +returns a string after converting ':', ' ' and camel case into '-' -Select all enum items in a package. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items +| Param | Type | +| --- | --- | +| label | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | + - +### Templating API: C formatting helpers~asSpacedLowercase(str) ⇒ +Given a camel case string convert it into one with space and lowercase -### DB API: zcl database access~selectEnumById(db, id) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase -Select an enum matched by its primary key. +| Param | Type | +| --- | --- | +| str | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found + -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +### Templating API: C formatting helpers~asUnderscoreUppercase(str) ⇒ +Given a camel case string convert it into one with underscore and uppercase - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in uppercase with underscores -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ +| Param | Type | +| --- | --- | +| str | \* | -Select an enum matched by name. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined +### Templating API: C formatting helpers~asCliType(size, isSigned) ⇒ +Returns the cli type representation. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: the type representation required for CLI. - +| Param | +| --- | +| size | +| isSigned | -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select an enum matched by name and clusterId. +### Templating API: C formatting helpers~as\_zcl\_cli\_type(str, optional, isSigned) +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +| Param | Description | +| --- | --- | +| str | | +| optional | | +| isSigned | Return the data type of zcl cli | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### Templating API: C formatting helpers~dataTypeForBitmap(db, bitmap_name, packageIds) +Returns the type of bitmap based on the bitmap's name -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -Returns the cluster available to this session by the code. +| Param | Type | +| --- | --- | +| db | \* | +| bitmap_name | \* | +| packageIds | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | +### Templating API: C formatting helpers~dataTypeForEnum(db, enum_name, packageIds) +Returns the type of enum - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| enum_name | \* | +| packageIds | \* | -Returns all the clusters visible for a given session. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +### Templating API: C formatting helpers~addOne(number) +Returns the number by adding 1 to it. -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) - +| Param | Type | +| --- | --- | +| number | \* | -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ + -Returns the attribute available to this session by the code. +### Templating API: C formatting helpers~is\_number\_greater\_than(num1, num2) ⇒ +Return true if number1 is greater than number2 -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: true if num1 is greater than num2 else returns false -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +| Param | +| --- | +| num1 | +| num2 | - + -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ +### Templating API: C formatting helpers~cluster\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. -Returns the command available to this session by the code. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | + - +### Templating API: C formatting helpers~device\_type\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. -Select a struct matched by name and clusterId +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +### Templating API: C formatting helpers~attribute\_type\_extension(options) ⇒ +When inside a context that contains 'type', this +helper will output the value of the attribute type extension +specified by property="propName" attribute. - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute type extension property. -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters +### Templating API: C formatting helpers~subentityExtension(context, prop, entityType) ⇒ +Get extension values for the given information. -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: extension default value - +| Param | Type | +| --- | --- | +| context | \* | +| prop | \* | +| entityType | \* | -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ + -Retrieves all the bitmaps that are associated with a cluster. +### Templating API: C formatting helpers~if\_command\_extension\_true(options) ⇒ +If helper for command extensions(true condition). -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAllDomains(db) ⇒ +### Templating API: C formatting helpers~if\_command\_extension\_false(options) ⇒ +If helper for command extensions(false condition). -Retrieves all the domains in the database. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### Templating API: C formatting helpers~if\_cluster\_extension\_true(options) ⇒ +If helper for cluster extensions(true condition). -### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper -Retrieves all the structs in the database, including the count -of items. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | +### Templating API: C formatting helpers~if\_cluster\_extension\_false(options) ⇒ +If helper for cluster extensions(false condition). - +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper -### DB API: zcl database access~selectStructClusters(db, structId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Returns an array of clusters that struct belongs to. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +### Templating API: C formatting helpers~attribute\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the attribute extension +specified by property="propName" attribute. -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute extension property. - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ + -Returns an array of clusters that enum belongs to. +### Templating API: C formatting helpers~command\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ +### Templating API: C formatting helpers~event\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. -Returns an array of clusters that bitmap belongs to. +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | + - +## Templating API: user-data specific helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ -Retrieves all the cluster-related structs in the database with the items. +* [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + * [~user_endpoints(options)](#module_Templating API_ user-data specific helpers..user_endpoints) + * [~user_device_types(options)](#module_Templating API_ user-data specific helpers..user_device_types) + * [~user_endpoint_types(options)](#module_Templating API_ user-data specific helpers..user_endpoint_types) + * [~user_clusters(options)](#module_Templating API_ user-data specific helpers..user_clusters) + * [~user_cluster_attributes(options)](#module_Templating API_ user-data specific helpers..user_cluster_attributes) ⇒ + * [~user_cluster_commands(options)](#module_Templating API_ user-data specific helpers..user_cluster_commands) ⇒ + * [~user_cluster_events(options)](#module_Templating API_ user-data specific helpers..user_cluster_events) ⇒ + * [~user_endpoint_type_count()](#module_Templating API_ user-data specific helpers..user_endpoint_type_count) ⇒ + * [~user_endpoint_count_by_cluster(clusterTypeId)](#module_Templating API_ user-data specific helpers..user_endpoint_count_by_cluster) ⇒ + * [~user_all_attributes(options)](#module_Templating API_ user-data specific helpers..user_all_attributes) ⇒ + * [~all_user_cluster_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_commands) ⇒ + * [~all_user_cluster_command_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification)](#module_Templating API_ user-data specific helpers..all_user_cluster_command_util) + * [~all_user_cluster_attribute_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification)](#module_Templating API_ user-data specific helpers..all_user_cluster_attribute_util) ⇒ + * [~all_user_cluster_manufacturer_specific_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_manufacturer_specific_commands) ⇒ + * [~all_user_cluster_non_manufacturer_specific_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_non_manufacturer_specific_commands) ⇒ + * [~all_user_cluster_manufacturer_specific_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_manufacturer_specific_attributes) ⇒ + * [~all_user_cluster_non_manufacturer_specific_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_non_manufacturer_specific_attributes) ⇒ + * [~all_commands_for_user_enabled_clusters(options)](#module_Templating API_ user-data specific helpers..all_commands_for_user_enabled_clusters) ⇒ + * [~all_cli_commands_for_user_enabled_clusters(options)](#module_Templating API_ user-data specific helpers..all_cli_commands_for_user_enabled_clusters) ⇒ + * [~all_user_clusters(options)](#module_Templating API_ user-data specific helpers..all_user_clusters) ⇒ + * [~all_user_clusters_irrespective_of_side(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_irrespective_of_side) ⇒ + * [~all_user_clusters_names(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_names) ⇒ + * [~user_cluster_command_count_with_cli()](#module_Templating API_ user-data specific helpers..user_cluster_command_count_with_cli) + * [~user_cluster_commands_with_cli()](#module_Templating API_ user-data specific helpers..user_cluster_commands_with_cli) + * [~user_cluster_commands_all_endpoints(options)](#module_Templating API_ user-data specific helpers..user_cluster_commands_all_endpoints) + * [~user_cluster_has_enabled_command(name, side)](#module_Templating API_ user-data specific helpers..user_cluster_has_enabled_command) ⇒ + * [~all_user_cluster_commands_irrespective_of_manufaturing_specification(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_commands_irrespective_of_manufaturing_specification) ⇒ + * [~enabled_attributes_for_cluster_and_side(name, side, options)](#module_Templating API_ user-data specific helpers..enabled_attributes_for_cluster_and_side) ⇒ + * [~user_session_key(options)](#module_Templating API_ user-data specific helpers..user_session_key) ⇒ + * [~if_command_discovery_enabled()](#module_Templating API_ user-data specific helpers..if_command_discovery_enabled) + * [~user_manufacturer_code(options)](#module_Templating API_ user-data specific helpers..user_manufacturer_code) ⇒ + * [~user_default_response_policy(options)](#module_Templating API_ user-data specific helpers..user_default_response_policy) ⇒ + * [~is_command_default_response_enabled(command, options)](#module_Templating API_ user-data specific helpers..is_command_default_response_enabled) ⇒ + * [~is_command_default_response_disabled(command, options)](#module_Templating API_ user-data specific helpers..is_command_default_response_disabled) ⇒ + * [~endpoint_type_identifier(endpointTypeId)](#module_Templating API_ user-data specific helpers..endpoint_type_identifier) ⇒ + * [~endpoint_type_index(endpointTypeId)](#module_Templating API_ user-data specific helpers..endpoint_type_index) ⇒ + * [~all_user_cluster_attributes_for_generated_defaults(name, side, options)](#module_Templating API_ user-data specific helpers..all_user_cluster_attributes_for_generated_defaults) ⇒ + * [~all_user_cluster_generated_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_generated_attributes) ⇒ + * [~all_user_reportable_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_reportable_attributes) ⇒ + * [~all_user_cluster_generated_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_generated_commands) ⇒ + * [~all_user_clusters_with_incoming_or_outgoing_commands(options, is_incoming)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_incoming_or_outgoing_commands) ⇒ + * [~all_user_clusters_with_incoming_commands(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_incoming_commands) ⇒ + * [~all_user_clusters_with_outgoing_commands(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_outgoing_commands) ⇒ + * [~manufacturing_clusters_with_incoming_commands(clusterCode, options)](#module_Templating API_ user-data specific helpers..manufacturing_clusters_with_incoming_commands) ⇒ + * [~all_user_clusters_with_incoming_commands_combined(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_incoming_commands_combined) ⇒ + * [~all_incoming_commands_for_cluster_combined(clusterName, clientSide, serverSide, options)](#module_Templating API_ user-data specific helpers..all_incoming_commands_for_cluster_combined) ⇒ + * [~all_user_incoming_commands_for_all_clusters(options)](#module_Templating API_ user-data specific helpers..all_user_incoming_commands_for_all_clusters) ⇒ + * [~all_incoming_or_outgoing_commands_for_cluster(clusterName, clusterSide, isIncoming, options)](#module_Templating API_ user-data specific helpers..all_incoming_or_outgoing_commands_for_cluster) ⇒ + * [~all_incoming_commands_for_cluster(clusterName, options)](#module_Templating API_ user-data specific helpers..all_incoming_commands_for_cluster) ⇒ + * [~all_outgoing_commands_for_cluster(clusterName, options)](#module_Templating API_ user-data specific helpers..all_outgoing_commands_for_cluster) ⇒ + * [~generated_clustes_details(options)](#module_Templating API_ user-data specific helpers..generated_clustes_details) ⇒ + * [~generated_endpoint_type_details(options)](#module_Templating API_ user-data specific helpers..generated_endpoint_type_details) ⇒ + * [~all_user_cluster_attributes_min_max_defaults(name, side, options)](#module_Templating API_ user-data specific helpers..all_user_cluster_attributes_min_max_defaults) ⇒ + * [~checkAttributeMatch(clusterName, attributeName, attributeSide, attributeValue, attributeValueType, endpointAttributes)](#module_Templating API_ user-data specific helpers..checkAttributeMatch) ⇒ + * [~generated_defaults_index(clusterName, attributeName, attributeValueType, attributeValue, prefixReturn, postFixReturn)](#module_Templating API_ user-data specific helpers..generated_defaults_index) ⇒ + * [~generated_default_index(clusterName, attributeName, attributeSide, attributeValueType, attributeValue, prefixReturn, postFixReturn)](#module_Templating API_ user-data specific helpers..generated_default_index) ⇒ + * [~generated_attributes_min_max_index(name, side, options)](#module_Templating API_ user-data specific helpers..generated_attributes_min_max_index) ⇒ + * [~generated_attribute_min_max_index(clusterName, attributeName, attributeSide, options)](#module_Templating API_ user-data specific helpers..generated_attribute_min_max_index) ⇒ + * [~if_enabled_clusters(options)](#module_Templating API_ user-data specific helpers..if_enabled_clusters) ⇒ + * [~if_multi_protocol_attributes_enabled(options)](#module_Templating API_ user-data specific helpers..if_multi_protocol_attributes_enabled) ⇒ + * [~all_multi_protocol_attributes(options)](#module_Templating API_ user-data specific helpers..all_multi_protocol_attributes) ⇒ -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + -| Param | Type | -| ----- | --------------- | -| db | \* | +### Templating API: user-data specific helpers~user\_endpoints(options) +Creates block iterator over the endpoints. - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) -### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Retrieves all the structs in the database with the items. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +### Templating API: user-data specific helpers~user\_device\_types(options) +Creates device type iterator over an endpoint type id. +This works inside user_endpoints or user_endpoint_types. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ + -Retrieves the struct items based on struct and cluster name. -Note: By default clusterName is null. +### Templating API: user-data specific helpers~user\_endpoint\_types(options) +Creates block iterator helper over the endpoint types. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAllClusters(db) ⇒ +### Templating API: user-data specific helpers~user\_clusters(options) +Creates cluster iterator over the endpoint types. +This works ony inside user_endpoint_types. -Retrieves all the clusters in the database. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### Templating API: user-data specific helpers~user\_cluster\_attributes(options) ⇒ +Creates endpoint type cluster attribute iterator. This works only +inside user_clusters. -### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster attributes. -Finds cluster by code. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. + -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +### Templating API: user-data specific helpers~user\_cluster\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This works only inside +user_clusters. - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. -### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Returns a promise that resolves into a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +### Templating API: user-data specific helpers~user\_cluster\_events(options) ⇒ +Creates endpoint type cluster event iterator. This works only inside +user_clusters. -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster events. - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ + -Returns attributes for a given cluster. -IMPORTANT: -packageIds are needed to properly deal with the global attributes. +### Templating API: user-data specific helpers~user\_endpoint\_type\_count() ⇒ +Get count of total endpoint types. -This method will NOT only return the attributes that link to -a given cluster, but will ALSO return the attributes that have -empty clusterRef (which are global attributes), and the check -in that case will be made via packageId. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: count of total endpoint types + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes +### Templating API: user-data specific helpers~user\_endpoint\_count\_by\_cluster(clusterTypeId) ⇒ +Retrieve the number of endpoints which possess the specified +cluster type -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the number of endpoint - +| Param | Type | +| --- | --- | +| clusterTypeId | \* | -### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ + -Queries for attributes inside a cluster. +### Templating API: user-data specific helpers~user\_all\_attributes(options) ⇒ +Iterates over all attributes required by the user configuration. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) +### Templating API: user-data specific helpers~all\_user\_cluster\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +commands which have been enabled on added endpoints -This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | + - +### Templating API: user-data specific helpers~all\_user\_cluster\_command\_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification) +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) -### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +| Param | Default | Description | +| --- | --- | --- | +| name | | | +| side | | | +| options | | | +| currentContext | | | +| isManufacturingSpecific | | | +| isIrrespectiveOfManufacturingSpecification | false | Returns: Promise of the resolved blocks iterating over manufacturing specific, non-manufacturing specific or both of the cluster commands. | -Query for attributes by side. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. +### Templating API: user-data specific helpers~all\_user\_cluster\_attribute\_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification) ⇒ +Get attribute details based on given arguments. -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Attribute details - +| Param | Type | Default | +| --- | --- | --- | +| name | \* | | +| side | \* | | +| options | \* | | +| currentContext | \* | | +| isManufacturingSpecific | \* | | +| isIrrespectiveOfManufacturingSpecification | \* | false | -## DB API: zcl database access + -This module provides queries for ZCL static queries. +### Templating API: user-data specific helpers~all\_user\_cluster\_manufacturer\_specific\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +manufacturing specific commands which have been enabled on added endpoints -- [DB API: zcl database access](#module*DB API* zcl database access) - - [~clear()](#module*DB API* zcl database access..clear) - - [~put(key, packageId, data)](#module*DB API* zcl database access..put) ⇒ - - [~get(key, packageId)](#module*DB API* zcl database access..get) ⇒ - - [~isCached(key, packageId)](#module*DB API* zcl database access..isCached) ⇒ - - [~cacheQuery(key, packageId)](#module*DB API* zcl database access..cacheQuery) ⇒ - - [~cacheStats()](#module*DB API* zcl database access..cacheStats) - - [~enable()](#module*DB API* zcl database access..enable) - - [~disable()](#module*DB API* zcl database access..disable) - - [~selectAtomicType(db, packageId, typeName)](#module*DB API* zcl database access..selectAtomicType) - - [~selectAtomicById(db, packageId)](#module*DB API* zcl database access..selectAtomicById) - - [~isTypeSignedByNameAndPackage(db, name, sessionPackages)](#module*DB API* zcl database access..isTypeSignedByNameAndPackage) ⇒ Promise.<boolean> - - [~selectAllBitmaps(db)](#module*DB API* zcl database access..selectAllBitmaps) ⇒ - - [~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectBitmapByNameAndClusterId) ⇒ - - [~selectAllEnums(db, packageId)](#module*DB API* zcl database access..selectAllEnums) ⇒ - - [~selectClusterEnums(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterEnums) ⇒ - - [~selectAllEnumItemsById(db, id)](#module*DB API* zcl database access..selectAllEnumItemsById) ⇒ - - [~selectAllEnumItems(db, packageId)](#module*DB API* zcl database access..selectAllEnumItems) ⇒ - - [~selectEnumById(db, id)](#module*DB API* zcl database access..selectEnumById) ⇒ - - [~selectEnumByName(db, name, packageIds)](#module*DB API* zcl database access..selectEnumByName) ⇒ - - [~selectEnumByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectEnumByNameAndClusterId) ⇒ - - [~selectSessionClusterByCode(db, sessionId, code, mfgCode)](#module*DB API* zcl database access..selectSessionClusterByCode) ⇒ - - [~selectAllSessionClusters(db, sessionId)](#module*DB API* zcl database access..selectAllSessionClusters) ⇒ - - [~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode)](#module*DB API* zcl database access..selectSessionAttributeByCode) ⇒ - - [~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source)](#module*DB API* zcl database access..selectSessionCommandByCode) ⇒ - - [~selectStructByNameAndClusterId(db, name, clusterId, packageIds)](#module*DB API* zcl database access..selectStructByNameAndClusterId) ⇒ - - [~selectStructsWithClusterAssociation(db, packageIds, groupByStructName)](#module*DB API* zcl database access..selectStructsWithClusterAssociation) ⇒ - - [~selectClusterBitmaps(db, packageId, clusterId)](#module*DB API* zcl database access..selectClusterBitmaps) ⇒ - - [~selectAllDomains(db)](#module*DB API* zcl database access..selectAllDomains) ⇒ - - [~selectAllStructsWithItemCount(db, packageIds)](#module*DB API* zcl database access..selectAllStructsWithItemCount) ⇒ - - [~selectStructClusters(db, structId)](#module*DB API* zcl database access..selectStructClusters) ⇒ - - [~selectEnumClusters(db, enumId)](#module*DB API* zcl database access..selectEnumClusters) ⇒ - - [~selectBitmapClusters(db, bitmapId)](#module*DB API* zcl database access..selectBitmapClusters) ⇒ - - [~selectClusterStructsWithItems(db)](#module*DB API* zcl database access..selectClusterStructsWithItems) ⇒ - - [~selectAllStructsWithItems(db)](#module*DB API* zcl database access..selectAllStructsWithItems) ⇒ - - [~selectAllStructItemsByStructName(db, name, packageIds, clusterName)](#module*DB API* zcl database access..selectAllStructItemsByStructName) ⇒ - - [~selectAllClusters(db)](#module*DB API* zcl database access..selectAllClusters) ⇒ - - [~selectClusterByCode(db, packageId, clusterCode, mfgCode)](#module*DB API* zcl database access..selectClusterByCode) ⇒ - - [~selectClusterById(db, clusterId, packageId)](#module*DB API* zcl database access..selectClusterById) ⇒ - - [~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds)](#module*DB API* zcl database access..selectAttributesByClusterIdIncludingGlobal) ⇒ - - [~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode)](#module*DB API* zcl database access..selectAttributesByClusterCodeAndManufacturerCode) ⇒ - - [~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef)](#module*DB API* zcl database access..selectAttributeByAttributeIdAndClusterRef) - - [~selectAllAttributesBySide(db, side, packageId)](#module*DB API* zcl database access..selectAllAttributesBySide) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +cluster commands. - +| Param | +| --- | +| options | -### DB API: zcl database access~clear() + -Clears the entire cache. +### Templating API: user-data specific helpers~all\_user\_cluster\_non\_manufacturer\_specific\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +non-manufacturing specific commands which have been enabled on added endpoints -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over non-manufacturing specific +cluster commands. -### DB API: zcl database access~put(key, packageId, data) ⇒ +| Param | +| --- | +| options | -Puts a data object into the cache under a given key/packageId + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Returns true on success. +### Templating API: user-data specific helpers~all\_user\_cluster\_manufacturer\_specific\_attributes(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +manufacturing specific commands which have been enabled on added endpoints -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +cluster commands. - +| Param | +| --- | +| options | -### DB API: zcl database access~get(key, packageId) ⇒ + -Returns a data object under a given key/packageId. +### Templating API: user-data specific helpers~all\_user\_cluster\_non\_manufacturer\_specific\_attributes(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +non-manufacturing specific commands which have been enabled on added endpoints -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cached object or undefined if none is present or expired. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over non-manufacturing specific +cluster commands. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | +| --- | +| options | - + -### DB API: zcl database access~isCached(key, packageId) ⇒ +### Templating API: user-data specific helpers~all\_commands\_for\_user\_enabled\_clusters(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +commands which have been enabled on added endpoints -Returns true if a given key/packageId cache exists. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | + - +### Templating API: user-data specific helpers~all\_cli\_commands\_for\_user\_enabled\_clusters(options) ⇒ +This helper returns all commands which have cli within the list of enabled +clusters. -### DB API: zcl database access~cacheQuery(key, packageId) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all commands with cli from the list of enabled clusters -Cache input / output of provided queryFunction -The queryFunction is assumed to have the following signature: +| Param | +| --- | +| options | -async function queryFunction(db, ...) {...} + -The DB handle is ignored and the remaining arguments are used as the cache key. +### Templating API: user-data specific helpers~all\_user\_clusters(options) ⇒ +Creates cluster iterator for all endpoints. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: true or false, depending on whether the cache is present. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. -| Param | Type | -| --------- | --------------- | -| key | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~cacheStats() +### Templating API: user-data specific helpers~all\_user\_clusters\_irrespective\_of\_side(options) ⇒ +Creates cluster command iterator for all endpoints. -Returns the cache statistics. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~enable() + -Enable the Database Query cache +### Templating API: user-data specific helpers~all\_user\_clusters\_names(options) ⇒ +Creates cluster command iterator for all endpoints whitout any duplicates +cause by cluster side -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. -### DB API: zcl database access~disable() +| Param | Type | +| --- | --- | +| options | \* | -Disable the database cache + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) - +### Templating API: user-data specific helpers~user\_cluster\_command\_count\_with\_cli() +Get the count of the number of clusters commands with cli for a cluster. +This is used under a cluster block helper -### DB API: zcl database access~selectAtomicType(db, packageId, typeName) +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + -Locates atomic type based on a type name. Query is not case sensitive. +### Templating API: user-data specific helpers~user\_cluster\_commands\_with\_cli() +This helper works within the the cluster block helpers. It is used to get +all commands of the cluster which have cli associated with them. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +param options +Returns: all commands with cli for a cluster -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| typeName | \* | +Example: +{{#all_user_clusters_irrespective_of_side}} + {{#user_cluster_commands_with_cli}} + {{/user_cluster_commands_with_cli}} +{{/all_user_clusters_irrespective_of_side}} - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + -### DB API: zcl database access~selectAtomicById(db, packageId) +### Templating API: user-data specific helpers~user\_cluster\_commands\_all\_endpoints(options) +Creates endpoint type cluster command iterator. This works only inside +cluster block helpers. -Retrieves atomic type by a given Id. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +| Param | Description | +| --- | --- | +| options | Returns: Promise of the resolved blocks iterating over cluster commands. | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | + - +### Templating API: user-data specific helpers~user\_cluster\_has\_enabled\_command(name, side) ⇒ +Check if the cluster (name) has any enabled commands. This works only inside +cluster block helpers. -### DB API: zcl database access~isTypeSignedByNameAndPackage(db, name, sessionPackages) ⇒ Promise.<boolean> +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: True if cluster has enabled commands otherwise false -Checks if a type by a given name is signed. +| Param | Type | Description | +| --- | --- | --- | +| name | \* | : Cluster name | +| side | \* | : Cluster side | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is signed, false otherwise. + -| Param | Type | Description | -| --------------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| name | string | The name of the type. | -| sessionPackages | Array | An array of session packages. | +### Templating API: user-data specific helpers~all\_user\_cluster\_commands\_irrespective\_of\_manufaturing\_specification(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +manufacturing and non-manufaturing specific commands which have been enabled +on added endpoints - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +and non-manufacturing specific cluster commands. -### DB API: zcl database access~selectAllBitmaps(db) ⇒ +| Param | +| --- | +| options | -Retrieves all the bitmaps in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of bitmaps. +### Templating API: user-data specific helpers~enabled\_attributes\_for\_cluster\_and\_side(name, side, options) ⇒ +Creates endpoint type cluster attribute iterator. This fetches all +manufacturer-specific and standard attributes which have been enabled on +added endpoints based on the name and side of the cluster. When side +is not mentioned then client and server attributes are returned. +Available Options: +- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js) +for eg:(#enabled_attributes_for_cluster_and_side + [cluster-name], [cluster-side], removeKeys='isOptional, isNullable') +will remove 'isOptional' and 'isNullable' from the results -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +and standard cluster attributes. - +| Param | +| --- | +| name | +| side | +| options | -### DB API: zcl database access~selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select a bitmap matched by name and clusterId. +### Templating API: user-data specific helpers~user\_session\_key(options) ⇒ +Helper that resolves into a user session key value. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: bitmap information or undefined +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of value of the session key or undefined. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### DB API: zcl database access~selectAllEnums(db, packageId) ⇒ +### Templating API: user-data specific helpers~if\_command\_discovery\_enabled() +If helper that checks if command discovery is enabled -Retrieves all the enums in the database. +example: +{{#if_command_discovery_enabled}} +command discovery is enabled +{{else}} +command discovery is not enabled +{{/if_command_discovery_enabled}} -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | +### Templating API: user-data specific helpers~user\_manufacturer\_code(options) ⇒ +Get Session's manufacturer code. - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: session's manufacturer code -### DB API: zcl database access~selectClusterEnums(db, packageId, clusterId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Retrieves all the enums with cluster references in the database. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of enums. +### Templating API: user-data specific helpers~user\_default\_response\_policy(options) ⇒ +Get user's default response policy selected. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: user's default response policy selected - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAllEnumItemsById(db, id) ⇒ + -Returns an enum by ID. +### Templating API: user-data specific helpers~is\_command\_default\_response\_enabled(command, options) ⇒ +An if helper to check if default response for a command is enabled or not. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: true if the the default response policy is either always or +when the policy is not never and the command has the disable default +response policy set to false(not true) -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +| Param | Type | +| --- | --- | +| command | \* | +| options | \* | - + -### DB API: zcl database access~selectAllEnumItems(db, packageId) ⇒ +### Templating API: user-data specific helpers~is\_command\_default\_response\_disabled(command, options) ⇒ +An if helper to check if default response for a command is disabled or not. -Select all enum items in a package. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: true if the the default response policy is either never or +when the policy is not always and the command has the disable default +response policy set to true(for eg disableDefaultResponse="true" in xml). -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: list of enum items +| Param | Type | +| --- | --- | +| command | \* | +| options | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | + - +### Templating API: user-data specific helpers~endpoint\_type\_identifier(endpointTypeId) ⇒ +Get endpoint identifier from the given endpoint type ID. -### DB API: zcl database access~selectEnumById(db, id) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: the endpoint type identifier for an endpoint type -Select an enum matched by its primary key. +| Param | Type | +| --- | --- | +| endpointTypeId | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: an enum or underfined if not found + -| Param | Type | -| ----- | --------------- | -| db | \* | -| id | \* | +### Templating API: user-data specific helpers~endpoint\_type\_index(endpointTypeId) ⇒ +Get the index of the endpoint whose endpointTypeId is endpointTypeId +Will return -1 if the given endpoint type is not present. - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: integer -### DB API: zcl database access~selectEnumByName(db, name, packageIds) ⇒ +| Param | Type | +| --- | --- | +| endpointTypeId | \* | -Select an enum matched by name. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum or undefined +### Templating API: user-data specific helpers~all\_user\_cluster\_attributes\_for\_generated\_defaults(name, side, options) ⇒ +Default values for the attributes longer than a pointer. +All attribute values with size greater than 2 bytes. +Excluding 0 values and externally saved values -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Attribute values greater than 2 bytes and not 0 nor externally saved. - +| Param | +| --- | +| name | +| side | +| options | -### DB API: zcl database access~selectEnumByNameAndClusterId(db, name, clusterId, packageIds) ⇒ + -Select an enum matched by name and clusterId. +### Templating API: user-data specific helpers~all\_user\_cluster\_generated\_attributes(options) ⇒ +Entails the list of all attributes which have been enabled. Given the +cluster is enabled as well. The helper retrieves the attributes across +all endpoints. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: enum information or undefined +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: enabled attributes -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | +| Param | +| --- | +| options | - + -### DB API: zcl database access~selectSessionClusterByCode(db, sessionId, code, mfgCode) ⇒ +### Templating API: user-data specific helpers~all\_user\_reportable\_attributes(options) ⇒ +Entails the list of reportable attributes which have been enabled. Given the +cluster is enabled as well. The helper retrieves the reportable attributes +per endpoint per cluster. -Returns the cluster available to this session by the code. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Reportable attributes -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. +| Param | +| --- | +| options | -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| code | \* | -| mfgCode | \* | + - +### Templating API: user-data specific helpers~all\_user\_cluster\_generated\_commands(options) ⇒ +All available cluster commands across all endpoints and clusters. -### DB API: zcl database access~selectAllSessionClusters(db, sessionId) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All available cluster commands across all endpoints and clusters -Returns all the clusters visible for a given session. +| Param | +| --- | +| options | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: all the cluster objects for a given session. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_incoming\_or\_outgoing\_commands(options, is_incoming) ⇒ +Util function for all clusters with side that have available incoming or +outgiong commands across all endpoints. - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters with side that have available incoming or outgiong +commands across all endpoints. -### DB API: zcl database access~selectSessionAttributeByCode(db, sessionId, clusterCode, side, attributeCode, mfgCode) ⇒ +| Param | Description | +| --- | --- | +| options | | +| is_incoming | boolean to check if commands are incoming or outgoing | -Returns the attribute available to this session by the code. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_incoming\_commands(options) ⇒ +All clusters with side that have available incoming commands -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| side | \* | -| attributeCode | \* | -| mfgCode | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters with side that have available incoming commands across +all endpoints. - +| Param | +| --- | +| options | -### DB API: zcl database access~selectSessionCommandByCode(db, sessionId, clusterCode, commandCode, source) ⇒ + -Returns the command available to this session by the code. +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_outgoing\_commands(options) ⇒ +All clusters with side that have available outgoing commands -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the session attribute +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters with side that have available outgoing commands across +all endpoints. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterCode | \* | -| commandCode | \* | -| source | \* | +| Param | +| --- | +| options | - + -### DB API: zcl database access~selectStructByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +### Templating API: user-data specific helpers~manufacturing\_clusters\_with\_incoming\_commands(clusterCode, options) ⇒ +Provide all manufacturing specific clusters that have incoming commands with +the given cluster code. -Select a struct matched by name and clusterId +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Details of manufacturing specific clusters that have incoming +commands with the given cluster code -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: struct information or undefined +| Param | +| --- | +| clusterCode | +| options | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| name | \* | -| clusterId | \* | -| packageIds | \* | + - +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_incoming\_commands\_combined(options) ⇒ +All clusters that have available incoming commands. +If there is a client and server enabled on the endpoint, this combines them +into a single entry. -### DB API: zcl database access~selectStructsWithClusterAssociation(db, packageIds, groupByStructName) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters that have available incoming commands across +all endpoints. -Get all structs which have a cluster associated with them. If a struct is -present in more than one cluster then it can be grouped by struct name to -avoid additional rows. +| Param | +| --- | +| options | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: structs which have an association with clusters + -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| packageIds | \* | -| groupByStructName | \* | +### Templating API: user-data specific helpers~all\_incoming\_commands\_for\_cluster\_combined(clusterName, clientSide, serverSide, options) ⇒ +All commands that need to be parsed for a given cluster. This takes in booleans +for if the client and or server are included. - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all commands that need to be parsed for a given cluster -### DB API: zcl database access~selectClusterBitmaps(db, packageId, clusterId) ⇒ +| Param | +| --- | +| clusterName | +| clientSide | +| serverSide | +| options | -Retrieves all the bitmaps that are associated with a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster-related bitmaps +### Templating API: user-data specific helpers~all\_user\_incoming\_commands\_for\_all\_clusters(options) ⇒ +Get all incoming commands in the user configuration. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| clusterId | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all incoming commands enabled by the user. - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAllDomains(db) ⇒ + -Retrieves all the domains in the database. +### Templating API: user-data specific helpers~all\_incoming\_or\_outgoing\_commands\_for\_cluster(clusterName, clusterSide, isIncoming, options) ⇒ +A util function for all incoming or outgoing commands that need to be parsed +for a given cluster -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of domains. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All incoming or outgoing commands that need to be parsed for a given + cluster -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | +| --- | +| clusterName | +| clusterSide | +| isIncoming | +| options | - + -### DB API: zcl database access~selectAllStructsWithItemCount(db, packageIds) ⇒ +### Templating API: user-data specific helpers~all\_incoming\_commands\_for\_cluster(clusterName, options) ⇒ +All incoming commands that need to be parsed for a given cluster -Retrieves all the structs in the database, including the count -of items. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all incoming commands that need to be parsed for a given cluster -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs. +| Param | +| --- | +| clusterName | +| options | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | + - +### Templating API: user-data specific helpers~all\_outgoing\_commands\_for\_cluster(clusterName, options) ⇒ +All outgoing commands that need to be parsed for a given cluster -### DB API: zcl database access~selectStructClusters(db, structId) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all outgoing commands that need to be parsed for a given cluster -Returns an array of clusters that struct belongs to. +| Param | +| --- | +| clusterName | +| options | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters + -| Param | Type | -| -------- | --------------- | -| db | \* | -| structId | \* | +### Templating API: user-data specific helpers~generated\_clustes\_details(options) ⇒ +Entails the Cluster details per endpoint - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Cluster Details per endpoint with attribute summaries within the clusters -### DB API: zcl database access~selectEnumClusters(db, enumId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Returns an array of clusters that enum belongs to. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +### Templating API: user-data specific helpers~generated\_endpoint\_type\_details(options) ⇒ +Entails Endpoint type details along with their cluster summaries -| Param | Type | -| ------ | --------------- | -| db | \* | -| enumId | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Endpoint type details along with their cluster summaries - +| Param | +| --- | +| options | -### DB API: zcl database access~selectBitmapClusters(db, bitmapId) ⇒ + -Returns an array of clusters that bitmap belongs to. +### Templating API: user-data specific helpers~all\_user\_cluster\_attributes\_min\_max\_defaults(name, side, options) ⇒ +Returns attributes inside an endpoint type that either have a default or a +bounded attribute. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: clusters +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: endpoints with bounds or defaults -| Param | Type | -| -------- | --------------- | -| db | \* | -| bitmapId | \* | +| Param | +| --- | +| name | +| side | +| options | - + -### DB API: zcl database access~selectClusterStructsWithItems(db) ⇒ +### Templating API: user-data specific helpers~checkAttributeMatch(clusterName, attributeName, attributeSide, attributeValue, attributeValueType, endpointAttributes) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: arrayIndex -Retrieves all the cluster-related structs in the database with the items. +| Param | +| --- | +| clusterName | +| attributeName | +| attributeSide | +| attributeValue | +| attributeValueType | +| endpointAttributes | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. + -| Param | Type | -| ----- | --------------- | -| db | \* | +### Templating API: user-data specific helpers~generated\_defaults\_index(clusterName, attributeName, attributeValueType, attributeValue, prefixReturn, postFixReturn) ⇒ +Extracts the index of generated defaults array which come from +all_user_cluster_attributes_for_generated_defaults - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: index of the generated default array -### DB API: zcl database access~selectAllStructsWithItems(db) ⇒ +| Param | +| --- | +| clusterName | +| attributeName | +| attributeValueType | +| attributeValue | +| prefixReturn | +| postFixReturn | -Retrieves all the structs in the database with the items. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of structs, each one containing items field with rows of items. +### Templating API: user-data specific helpers~generated\_default\_index(clusterName, attributeName, attributeSide, attributeValueType, attributeValue, prefixReturn, postFixReturn) ⇒ +Extracts the index of generated defaults array which come from +all_user_cluster_attributes_for_generated_defaults -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: deafult value's index in the generated default array - +| Param | +| --- | +| clusterName | +| attributeName | +| attributeSide | +| attributeValueType | +| attributeValue | +| prefixReturn | +| postFixReturn | -### DB API: zcl database access~selectAllStructItemsByStructName(db, name, packageIds, clusterName) ⇒ + -Retrieves the struct items based on struct and cluster name. -Note: By default clusterName is null. +### Templating API: user-data specific helpers~generated\_attributes\_min\_max\_index(name, side, options) ⇒ +Extracts the index of generated min max defaults array which come from +all_user_cluster_attributes_min_max_defaults -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: the details of the struct items +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: index of the generated min max default array -| Param | Default | -| ----------- | ------------- | -| db | | -| name | | -| packageIds | | -| clusterName | | +| Param | +| --- | +| name | +| side | +| options | - + -### DB API: zcl database access~selectAllClusters(db) ⇒ +### Templating API: user-data specific helpers~generated\_attribute\_min\_max\_index(clusterName, attributeName, attributeSide, options) ⇒ +Extracts the index of generated min max defaults array which come from +all_user_cluster_attributes_min_max_defaults -Retrieves all the clusters in the database. +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: index of the generated min max default in the array -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: Promise that resolves with the rows of clusters. +| Param | +| --- | +| clusterName | +| attributeName | +| attributeSide | +| options | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### Templating API: user-data specific helpers~if\_enabled\_clusters(options) ⇒ +If helper that checks if there are clusters enabled +Available options: +- side: side="client/server" can be used to check if there are client or +server side clusters are available -### DB API: zcl database access~selectClusterByCode(db, packageId, clusterCode, mfgCode) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of content. -Finds cluster by code. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: cluster by code in a single package id. + -| Param | Type | Default | Description | -| ----------- | --------------- | ------------- | ------------------------------------- | -| db | \* | | | -| packageId | \* | | Single packageId or an array of them. | -| clusterCode | \* | | | -| mfgCode | \* | | | +### Templating API: user-data specific helpers~if\_multi\_protocol\_attributes\_enabled(options) ⇒ +Check if multi-protocol is enabled for the application. - +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: boolean based on existence of attribute-attribute associations. -### DB API: zcl database access~selectClusterById(db, clusterId, packageId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Returns a promise that resolves into a cluster. + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into a cluster object +### Templating API: user-data specific helpers~all\_multi\_protocol\_attributes(options) ⇒ +Retrieve all the attribute-attribute associations for the current session. -| Param | Type | -| --------- | --------------- | -| db | \* | -| clusterId | \* | -| packageId | \* | +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: attribute-attribute mapping entries - +| Param | Type | +| --- | --- | +| options | \* | -### DB API: zcl database access~selectAttributesByClusterIdIncludingGlobal(db, clusterId, packageIds) ⇒ + -Returns attributes for a given cluster. -IMPORTANT: -packageIds are needed to properly deal with the global attributes. +## Templating API: Token helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -This method will NOT only return the attributes that link to -a given cluster, but will ALSO return the attributes that have -empty clusterRef (which are global attributes), and the check -in that case will be made via packageId. -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise of a list of attributes, including global attributes +* [Templating API: Token helpers](#module_Templating API_ Token helpers) + * [~token_cluster_create(config)](#module_Templating API_ Token helpers..token_cluster_create) ⇒ + * [~tokens_context()](#module_Templating API_ Token helpers..tokens_context) + * [~token_next()](#module_Templating API_ Token helpers..token_next) + * [~debug_object(obj)](#module_Templating API_ Token helpers..debug_object) ⇒ + * [~token_attribute_util(context, options)](#module_Templating API_ Token helpers..token_attribute_util) ⇒ + * [~token_attributes(endpointTypeRef, options)](#module_Templating API_ Token helpers..token_attributes) ⇒ + * [~token_attribute_clusters(endpointTypeRef, options)](#module_Templating API_ Token helpers..token_attribute_clusters) ⇒ + * [~token_attribute_endpoints(options)](#module_Templating API_ Token helpers..token_attribute_endpoints) ⇒ -| Param | Type | -| ---------- | --------------- | -| db | \* | -| clusterId | \* | -| packageIds | \* | + - +### Templating API: Token helpers~token\_cluster\_create(config) ⇒ +Get a transformed config object. -### DB API: zcl database access~selectAttributesByClusterCodeAndManufacturerCode(db, packageId, clusterCode, manufacturerCode) ⇒ +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: object -Queries for attributes inside a cluster. +| Param | Type | +| --- | --- | +| config | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. + -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| packageId | \* | -| clusterCode | \* | -| manufacturerCode | \* | +### Templating API: Token helpers~tokens\_context() +This function builds creates a new context from the endpoint_config structure + for use in the zap-tokens.h template. The endpoint_config context provides a + list of endpoints, and endpointTypes, where each endpointType contains a list + of clusters, and each cluster contains a list of attributes. However, the + tokens template requires a list of attributes per endpoint, and per cluster, + discriminating from singletons and non-singletons, so this function performs + the required grouping. - + While each attribute contains an isSingleton attribute, the database schema + allows for the same attribute to be returned both as singleton and non-singleton + in different clusters, for different endpoints. In consequence, care must be + taken to remove the singletons from the cluster and endpoint attribute lists. + This is done in two steps, the first loop creates a global (context) list of + singletons and non-singletons, and the second loop removes the singletons from + the endpoint, and clusters. -### DB API: zcl database access~selectAttributeByAttributeIdAndClusterRef(db, attributeId, clusterRef) + Clusters from different endpoints may have different attributes, therefore each + endpoint keeps a separate list of clusters. Additionally, a context-level + map of clusters is required in order to gather all attributes (singletons and + non-singletons) from all endpoint clusters. -This async function should be used when you want to get attributes, while also resolving against any global data that may be overridden by a particular cluster. +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) + -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) +### Templating API: Token helpers~token\_next() +The token template assigns an unique ID to each unique attribute. These IDs + span all attributes from all clusters from all endpointTypes. This helper + function allows the template to increment the token ID within the tokens context. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| attributeId | \* | -| clusterRef | \* | +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) + - +### Templating API: Token helpers~debug\_object(obj) ⇒ +Get JSON stringified value of the obj. -### DB API: zcl database access~selectAllAttributesBySide(db, side, packageId) ⇒ +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: JSON string -Query for attributes by side. +| Param | Type | +| --- | --- | +| obj | \* | -**Kind**: inner method of [DB API: zcl database access](#module*DB API* zcl database access) -**Returns**: promise that resolves into attributes. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| side | \* | -| packageId | \* | +### Templating API: Token helpers~token\_attribute\_util(context, options) ⇒ +Util function that extracts all the token attribute information. - +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: Information on all token attributes in the configuration. -## JS API: generator logic +| Param | Type | +| --- | --- | +| context | \* | +| options | \* | -- [JS API: generator logic](#module*JS API* generator logic) - - [~loadGenTemplateFromFile(path)](#module*JS API* generator logic..loadGenTemplateFromFile) ⇒ - - [~recordTemplatesPackage(context)](#module*JS API* generator logic..recordTemplatesPackage) ⇒ - - [~decodePackageExtensionEntity(entityType, entity)](#module*JS API* generator logic..decodePackageExtensionEntity) ⇒ - - [~loadZclExtensions(zclExt)](#module*JS API* generator logic..loadZclExtensions) ⇒ - - [~loadTemplates(db, genTemplatesJsonArray)](#module*JS API* generator logic..loadTemplates) - - [~loadGenTemplatesJsonFile(db, genTemplatesJson)](#module*JS API* generator logic..loadGenTemplatesJsonFile) ⇒ - - [~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly)](#module*JS API* generator logic..generateAllTemplates) ⇒ - - [~generateSingleTemplate(genResult, singleTemplatePkg)](#module*JS API* generator logic..generateSingleTemplate) ⇒ - - [~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options)](#module*JS API* generator logic..generate) ⇒ - - [~writeFileWithBackup(fileName, content, doBackup)](#module*JS API* generator logic..writeFileWithBackup) ⇒ - - [~generateGenerationContent(genResult)](#module*JS API* generator logic..generateGenerationContent) - - [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#module*JS API* generator logic..generateAndWriteFiles) ⇒ - - [~postProcessGeneratedFiles(outputDirectory, genResult)](#module*JS API* generator logic..postProcessGeneratedFiles) ⇒ - - [~contentIndexer(content)](#module*JS API* generator logic..contentIndexer) - - [~generateSingleFileForPreview(db, sessionId, fileName)](#module*JS API* generator logic..generateSingleFileForPreview) ⇒ - - [~produceCompiledTemplate(singleTemplatePkg)](#module*JS API* generator logic..produceCompiledTemplate) ⇒ - - [~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options)](#module*JS API* generator logic..produceIterativeContent) ⇒ - - [~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:)](#module*JS API* generator logic..produceContent) ⇒ - - [~wrapOverridable(originalFn, overrideFn)](#module*JS API* generator logic..wrapOverridable) ⇒ - - [~loadOverridable(path)](#module*JS API* generator logic..loadOverridable) - - [~loadPartial(path)](#module*JS API* generator logic..loadPartial) - - [~loadHelper(helpers)](#module*JS API* generator logic..loadHelper) - - [~allBuiltInHelpers()](#module*JS API* generator logic..allBuiltInHelpers) ⇒ - - [~findHelperPackageByAlias(alias)](#module*JS API* generator logic..findHelperPackageByAlias) ⇒ - - [~initializeBuiltInHelpersForPackage()](#module*JS API* generator logic..initializeBuiltInHelpersForPackage) - - [~hbInstance()](#module*JS API* generator logic..hbInstance) ⇒ - - [~makeSynchronizablePromise(promise)](#module*JS API* generator logic..makeSynchronizablePromise) - - [~collectBlocks(resultArray, options, context)](#module*JS API* generator logic..collectBlocks) ⇒ - - [~ensureZclPackageId(context)](#module*JS API* generator logic..ensureZclPackageId) ⇒ - - [~ensureZclPackageIds(context)](#module*JS API* generator logic..ensureZclPackageIds) ⇒ - - [~ensureTemplatePackageCategory(context)](#module*JS API* generator logic..ensureTemplatePackageCategory) ⇒ - - [~ensureTemplatePackageId(context)](#module*JS API* generator logic..ensureTemplatePackageId) ⇒ - - [~ensureEndpointTypeIds(context)](#module*JS API* generator logic..ensureEndpointTypeIds) ⇒ - - [~ensureZclClusterSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclClusterSdkExtensions) ⇒ - - [~ensureZclDeviceTypeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclDeviceTypeSdkExtensions) ⇒ - - [~ensureZclAttributeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclAttributeSdkExtensions) ⇒ - - [~ensureZclAttributeTypeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclAttributeTypeSdkExtensions) ⇒ - - [~ensureZclCommandSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclCommandSdkExtensions) ⇒ - - [~ensureZclEventSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclEventSdkExtensions) ⇒ - - [~templatePromise(global, promise)](#module*JS API* generator logic..templatePromise) - - [~deprecatedHelper(fn, explanation)](#module*JS API* generator logic..deprecatedHelper) ⇒ + - +### Templating API: Token helpers~token\_attributes(endpointTypeRef, options) ⇒ +Get information about all the token attributes in the configuration or this +helper can be used within an endpoint block helper to fetch the +corresponding token attributes based on endpoint type given. +Available Options: +isSingleton: 0/1, option can be used to filter attributes based on singleton +or non-singleton(Available with endpointTypeRef only) -### JS API: generator logic~loadGenTemplateFromFile(path) ⇒ +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: singleton and non-singleton token attributes along with their +endpoint information. Singleton attributes are only returned once whereas +non-singleton attributes are returned per endpoint. However if used within +an endpoint block helper it returns token_attributes for a given endpoint +type. -Given a path, it will read generation template object into memory. +| Param | Type | +| --- | --- | +| endpointTypeRef | \* | +| options | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Object that contains: data, crc, templateData + -| Param | Type | -| ----- | --------------- | -| path | \* | +### Templating API: Token helpers~token\_attribute\_clusters(endpointTypeRef, options) ⇒ +This helper can return all token associated clusters across endpoints or +this helper can be used within an endpoint block helper to fetch the +corresponding token associated clusters. +Available Options: +isSingleton: 0/1, option can be used to filter clusters based on singleton +or non-singleton attributes. - +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: Token associated clusters for a particular endpoint type or all +token associated clusters across endpoints. -### JS API: generator logic~recordTemplatesPackage(context) ⇒ +| Param | Type | +| --- | --- | +| endpointTypeRef | \* | +| options | \* | -Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the same context passed in, except packageId added to it +### Templating API: Token helpers~token\_attribute\_endpoints(options) ⇒ +Get all endpoints which have token attributes in the configuration. +AvailableOptions: +- isSingleton: 0/1, option can be used to filter endpoints based on singleton +or non-singleton. -| Param | Type | -| ------- | --------------- | -| context | \* | +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: all endpoints with token attributes - +| Param | Type | +| --- | --- | +| options | \* | -### JS API: generator logic~decodePackageExtensionEntity(entityType, entity) ⇒ + -This method takes extension data in JSON, and converts it into -an object that contains: -entityCode, entityQualifier, parentCode, manufacturerCode and value +## Templating API: toplevel utility helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: object that can be used for database injection -| Param | Type | -| ---------- | --------------- | -| entityType | \* | -| entity | \* | +* [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + * [~zap_header()](#module_Templating API_ toplevel utility helpers..zap_header) ⇒ + * [~ident()](#module_Templating API_ toplevel utility helpers..ident) ⇒ + * [~new_line(cnt)](#module_Templating API_ toplevel utility helpers..new_line) ⇒ + * [~backslash()](#module_Templating API_ toplevel utility helpers..backslash) ⇒ + * [~template_options(category, options)](#module_Templating API_ toplevel utility helpers..template_options) + * [~first(options)](#module_Templating API_ toplevel utility helpers..first) ⇒ + * [~not_first(options)](#module_Templating API_ toplevel utility helpers..not_first) ⇒ + * [~last(options)](#module_Templating API_ toplevel utility helpers..last) ⇒ + * [~not_last(optionms)](#module_Templating API_ toplevel utility helpers..not_last) ⇒ + * [~middle(options)](#module_Templating API_ toplevel utility helpers..middle) ⇒ + * [~template_option_with_code(options, key)](#module_Templating API_ toplevel utility helpers..template_option_with_code) + * [~fail(options)](#module_Templating API_ toplevel utility helpers..fail) + * [~isEqual(string_a, string_b)](#module_Templating API_ toplevel utility helpers..isEqual) + * [~is_lowercase_equal(string_a, string_b)](#module_Templating API_ toplevel utility helpers..is_lowercase_equal) + * [~toggle(condition, trueResult, falseResult)](#module_Templating API_ toplevel utility helpers..toggle) ⇒ + * [~trim_string(str)](#module_Templating API_ toplevel utility helpers..trim_string) ⇒ + * [~asLastWord(str)](#module_Templating API_ toplevel utility helpers..asLastWord) + * [~iterate()](#module_Templating API_ toplevel utility helpers..iterate) + * [~addToAccumulator(accumulator, value)](#module_Templating API_ toplevel utility helpers..addToAccumulator) + * [~iterateAccumulator(options)](#module_Templating API_ toplevel utility helpers..iterateAccumulator) ⇒ + * [~waitForSynchronousPromise(pollInterval, promise, resolve, reject)](#module_Templating API_ toplevel utility helpers..waitForSynchronousPromise) + * [~promiseToResolveAllPreviousPromises(globalPromises)](#module_Templating API_ toplevel utility helpers..promiseToResolveAllPreviousPromises) + * [~after(options)](#module_Templating API_ toplevel utility helpers..after) ⇒ + * [~concatenate()](#module_Templating API_ toplevel utility helpers..concatenate) + * [~is_num_equal(numA, numB)](#module_Templating API_ toplevel utility helpers..is_num_equal) ⇒ + * [~is_defined(value)](#module_Templating API_ toplevel utility helpers..is_defined) ⇒ + * [~replace_string(mainString, replaceString, replaceWithString)](#module_Templating API_ toplevel utility helpers..replace_string) ⇒ + * [~add_prefix_to_all_strings(str, prefixStr)](#module_Templating API_ toplevel utility helpers..add_prefix_to_all_strings) ⇒ + * [~multiply()](#module_Templating API_ toplevel utility helpers..multiply) ⇒ + * [~is_string_underscored(val)](#module_Templating API_ toplevel utility helpers..is_string_underscored) ⇒ + * [~as_uppercase(val)](#module_Templating API_ toplevel utility helpers..as_uppercase) ⇒ - + -### JS API: generator logic~loadZclExtensions(zclExt) ⇒ +### Templating API: toplevel utility helpers~zap\_header() ⇒ +Produces the top-of-the-file header for a C file. -Returns a promise that will load the zcl extensions. +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: The header content + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise of loading the zcl extensions. +### Templating API: toplevel utility helpers~ident() ⇒ +Simple helper that produces an approved size of identation. -| Param | Type | -| ------ | --------------- | -| zclExt | \* | +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: whitespace that is the identation. + - +### Templating API: toplevel utility helpers~new\_line(cnt) ⇒ +Return new lines based on the given cnt parameter. -### JS API: generator logic~loadTemplates(db, genTemplatesJsonArray) +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: new line -Api that loads an array of template JSON files or a single file if -you just pass in one String. +| Param | Type | +| --- | --- | +| cnt | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) + -| Param | Type | -| --------------------- | --------------- | -| db | \* | -| genTemplatesJsonArray | \* | +### Templating API: toplevel utility helpers~backslash() ⇒ +return back slash - +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: string + -### JS API: generator logic~loadGenTemplatesJsonFile(db, genTemplatesJson) ⇒ +### Templating API: toplevel utility helpers~template\_options(category, options) +Block helper that iterates over the package options of a given category. -Main API async function to load templates from a gen-template.json file. +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: the loading context, contains: db, path, crc, packageId and templateData, or error +| Param | Type | +| --- | --- | +| category | \* | +| options | \* | -| Param | Type | Description | -| ---------------- | --------------- | ------------------------------------------------------- | -| db | \* | Database | -| genTemplatesJson | \* | Path to the JSON file or an array of paths to JSON file | + - +### Templating API: toplevel utility helpers~first(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +during the first element. -### JS API: generator logic~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the first element inside an operator, empty otherwise. -Generates all the templates inside a toplevel package. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output' + -| Param | Type | Description | -| ------------------ | --------------- | -------------------------------------------------------------------------------------------------- | -| genResult | \* | | -| genTemplateJsonPkg | \* | Package that points to genTemplate.json file | -| generateOnly | \* | if NULL then generate all templates, else only generate template whose out file name matches this. | +### Templating API: toplevel utility helpers~not\_first(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +if the element is not the first element. - +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the first element inside an operator, empty otherwise. -### JS API: generator logic~generateSingleTemplate(genResult, singleTemplatePkg) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Function that generates a single package and adds it to the generation result. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the genResult, with newly generated content added. +### Templating API: toplevel utility helpers~last(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +during the last element. -| Param | Type | Description | -| ----------------- | --------------- | ------------------------ | -| genResult | \* | | -| singleTemplatePkg | \* | Single template package. | +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the last element inside an operator, empty otherwise. - +| Param | Type | +| --- | --- | +| options | \* | -### JS API: generator logic~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options) ⇒ + -Main API async function to generate stuff. +### Templating API: toplevel utility helpers~not\_last(optionms) ⇒ +Inside an iterator. the block is output only if this is NOT the last item. +Useful for wrapping commas in the list of arguments and such. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into a generation result.Promise that resolves into a generation result. +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's not the last element inside a block, empty otherwise. -| Param | Type | Description | -| ------------------------ | --------------- | ------------------------------------------------------------------------------------- | -| db | \* | Database | -| sessionId | \* | | -| templatePackageId | \* | packageId Template package id. It can be either single template or gen template json. | -| templateGeneratorOptions | \* | | -| options | \* | | +| Param | Type | +| --- | --- | +| optionms | \* | - + -### JS API: generator logic~writeFileWithBackup(fileName, content, doBackup) ⇒ +### Templating API: toplevel utility helpers~middle(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +during the non-first and no-last element. -Promise to write out a file, optionally creating a backup. +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the middle element inside an operator, empty otherwise. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise of a written file. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| -------- | --------------- | -| fileName | \* | -| content | \* | -| doBackup | \* | + - +### Templating API: toplevel utility helpers~template\_option\_with\_code(options, key) +This fetches a promise which returns template options if provided -### JS API: generator logic~generateGenerationContent(genResult) +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) -Returns a promise that resolves into a content that should be written out to gen result file. +| Param | Type | +| --- | --- | +| options | \* | +| key | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) + -| Param | Type | -| --------- | --------------- | -| genResult | \* | +### Templating API: toplevel utility helpers~fail(options) +Forced fail halper. - +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) -### JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Generate files and write them into the given directory. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: a promise which will resolve when all the files are written. +### Templating API: toplevel utility helpers~isEqual(string_a, string_b) +This returns a boolean if the 2 strings are same -| Param | Type | -| --------------- | --------------- | -| db | \* | -| sessionId | \* | -| packageId | \* | -| outputDirectory | \* | +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) - +| Param | Type | +| --- | --- | +| string_a | \* | +| string_b | \* | -### JS API: generator logic~postProcessGeneratedFiles(outputDirectory, genResult) ⇒ + -Executes post processing actions as defined by the gen-templates.json +### Templating API: toplevel utility helpers~is\_lowercase\_equal(string_a, string_b) +This returns a boolean based on the 2 strings being equal or not given that both -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise of a dealt-with post processing actions +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) -| Param | Type | -| --------------- | --------------- | -| outputDirectory | \* | -| genResult | \* | +| Param | Type | +| --- | --- | +| string_a | \* | +| string_b | \* | - + -### JS API: generator logic~contentIndexer(content) +### Templating API: toplevel utility helpers~toggle(condition, trueResult, falseResult) ⇒ +Return true/false result based on condition. -This async function takes a string, and resolves a preview object out of it. +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: boolean -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +| Param | Type | +| --- | --- | +| condition | \* | +| trueResult | \* | +| falseResult | \* | -| Param | Type | Description | -| ------- | --------------- | ---------------------------- | -| content | \* | String to form into preview. | + - +### Templating API: toplevel utility helpers~trim\_string(str) ⇒ +Remove leading and trailing spaces from a string -### JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A string with no leading and trailing spaces -Generates a single file and feeds it back for preview. +| Param | Type | +| --- | --- | +| str | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves into a preview object. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| fileName | \* | +### Templating API: toplevel utility helpers~asLastWord(str) +Split the string based on spaces and return the last word - +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) -### JS API: generator logic~produceCompiledTemplate(singleTemplatePkg) ⇒ +| Param | Type | +| --- | --- | +| str | \* | -Resolves into a precompiled template, either from previous precompile or freshly compiled. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: templates +### Templating API: toplevel utility helpers~iterate() +Iteration block. -| Param | Type | -| ----------------- | --------------- | -| singleTemplatePkg | \* | +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + - +### Templating API: toplevel utility helpers~addToAccumulator(accumulator, value) +Add to accumulator results. -### JS API: generator logic~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) -This function is reached if the template is an "iterative one", meaning -it has the iterator set to one of the valid options. +| Param | Type | +| --- | --- | +| accumulator | \* | +| value | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into an array of key/content/stats objects. + -| Param | Type | -| ---------------------- | --------------- | -| hb | \* | -| metaInfo | \* | -| db | \* | -| sessionId | \* | -| singleTemplatePkg | \* | -| genTemplateJsonPackage | \* | -| options | \* | +### Templating API: toplevel utility helpers~iterateAccumulator(options) ⇒ +Get accumulated information from templates. - +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: accumulated details -### JS API: generator logic~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Given db connection, session and a single template package, produce the output. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into an array of key/content/stats objects. +### Templating API: toplevel utility helpers~waitForSynchronousPromise(pollInterval, promise, resolve, reject) +Waits for promise to be resolved synchronously. -| Param | Type | Description | -| ------------- | --------------- | --------------------------------------------------------------------------------------- | -| hb | \* | | -| metaInfo | \* | | -| db | \* | | -| sessionId | \* | | -| singlePkg | \* | | -| overridePath: | \* | if passed, it provides a path to the override file that can override the overridable.js | +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) - +| Param | Type | +| --- | --- | +| pollInterval | \* | +| promise | \* | +| resolve | \* | +| reject | \* | -### JS API: generator logic~wrapOverridable(originalFn, overrideFn) ⇒ + -This function attemps to call override function, but if override function -throws an exception, it calls the original function. +### Templating API: toplevel utility helpers~promiseToResolveAllPreviousPromises(globalPromises) +Resolves all the given globalPromises promises. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: result from override function, unless it throws an exception, in which case return result from original function. +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) -| Param | Type | -| ---------- | --------------- | -| originalFn | \* | -| overrideFn | \* | +| Param | Type | +| --- | --- | +| globalPromises | \* | - + -### JS API: generator logic~loadOverridable(path) +### Templating API: toplevel utility helpers~after(options) ⇒ +Resolve the after promise after all other promises in the global context +have been resolved. -This function is responsible to load the overridable function container. +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: Content after all other content has been resolved. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | Description | -| ----- | --------------- | -------------------- | -| path | \* | of the override file | + - +### Templating API: toplevel utility helpers~concatenate() +Given: A list of strings +Returns a concatenated string with spaces between each string -### JS API: generator logic~loadPartial(path) +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + -Function that loads the partials. +### Templating API: toplevel utility helpers~is\_num\_equal(numA, numB) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: true if both numbers are equal else returns false -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +| Param | +| --- | +| numA | +| numB | -| Param | Type | -| ----- | --------------- | -| path | \* | + - +### Templating API: toplevel utility helpers~is\_defined(value) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: true or false based on whether the value is undefined or not -### JS API: generator logic~loadHelper(helpers) +| Param | +| --- | +| value | -Function that loads the helpers. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +### Templating API: toplevel utility helpers~replace\_string(mainString, replaceString, replaceWithString) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A string replaced with another string in the mainString -| Param | Type | Description | -| ------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| helpers | \* | a string path if value is passed through CLI, the nativeRequire() is leverage the native js function instead of webpack's special sauce. a required() module if invoked by backend js code. this is required to force webpack to resolve the included files as path will be difference after being packed for production. | +| Param | +| --- | +| mainString | +| replaceString | +| replaceWithString | - + -### JS API: generator logic~allBuiltInHelpers() ⇒ +### Templating API: toplevel utility helpers~add\_prefix\_to\_all\_strings(str, prefixStr) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A resultant string with all string values prefixed with prefixStr -Returns an object that contains all the helper functions, keyed -by their name +| Param | +| --- | +| str | +| prefixStr | -NOTE: This method is ONLY used for API testing. You should not use -this method for any real work inside the engine or something. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Object containing all the helper functions. - +### Templating API: toplevel utility helpers~multiply() ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A number which is result of multiplying all the arguments given + -### JS API: generator logic~findHelperPackageByAlias(alias) ⇒ +### Templating API: toplevel utility helpers~is\_string\_underscored(val) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: true if a string has an underscore in it -Given an alias, this method finds a builtin helper package -by its alias. +| Param | Type | +| --- | --- | +| val | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Helper package or undefined if none was found. + -| Param | Type | -| ----- | --------------- | -| alias | \* | +### Templating API: toplevel utility helpers~as\_uppercase(val) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: val in uppercase - +| Param | Type | +| --- | --- | +| val | \* | -### JS API: generator logic~initializeBuiltInHelpersForPackage() + -Global helper initialization +## Templating API: static zcl helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) - -### JS API: generator logic~hbInstance() ⇒ +* [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + * [~zcl_bitmaps(options)](#module_Templating API_ static zcl helpers..zcl_bitmaps) ⇒ + * [~zcl_bitmap_items(options)](#module_Templating API_ static zcl helpers..zcl_bitmap_items) + * [~zcl_enums(options)](#module_Templating API_ static zcl helpers..zcl_enums) ⇒ + * [~zcl_structs(options)](#module_Templating API_ static zcl helpers..zcl_structs) ⇒ + * [~zcl_enum_items(options)](#module_Templating API_ static zcl helpers..zcl_enum_items) + * [~first_unused_enum_value(options)](#module_Templating API_ static zcl helpers..first_unused_enum_value) ⇒ + * [~zcl_struct_items(options)](#module_Templating API_ static zcl helpers..zcl_struct_items) ⇒ + * [~zcl_struct_items_by_struct_name(name, options)](#module_Templating API_ static zcl helpers..zcl_struct_items_by_struct_name) ⇒ + * [~zcl_struct_items_by_struct_and_cluster_name(name, clusterName, options)](#module_Templating API_ static zcl helpers..zcl_struct_items_by_struct_and_cluster_name) ⇒ + * [~zcl_device_types(options)](#module_Templating API_ static zcl helpers..zcl_device_types) ⇒ + * [~zcl_device_type_clusters(options)](#module_Templating API_ static zcl helpers..zcl_device_type_clusters) ⇒ + * [~zcl_device_type_cluster_commands(options)](#module_Templating API_ static zcl helpers..zcl_device_type_cluster_commands) ⇒ + * [~zcl_device_type_cluster_attributes(options)](#module_Templating API_ static zcl helpers..zcl_device_type_cluster_attributes) ⇒ + * [~zcl_clusters(options)](#module_Templating API_ static zcl helpers..zcl_clusters) ⇒ + * [~zcl_commands(options)](#module_Templating API_ static zcl helpers..zcl_commands) ⇒ + * [~zcl_command_responses(options)](#module_Templating API_ static zcl helpers..zcl_command_responses) ⇒ + * [~zcl_commands_with_cluster_info(options)](#module_Templating API_ static zcl helpers..zcl_commands_with_cluster_info) ⇒ + * [~zcl_commands_with_arguments(options)](#module_Templating API_ static zcl helpers..zcl_commands_with_arguments) + * [~zcl_commands_source_client(options)](#module_Templating API_ static zcl helpers..zcl_commands_source_client) ⇒ + * [~zcl_commands_source_server(options)](#module_Templating API_ static zcl helpers..zcl_commands_source_server) ⇒ + * [~zcl_events(options)](#module_Templating API_ static zcl helpers..zcl_events) ⇒ + * [~zcl_command_tree(options)](#module_Templating API_ static zcl helpers..zcl_command_tree) ⇒ + * [~zcl_global_commands(options)](#module_Templating API_ static zcl helpers..zcl_global_commands) ⇒ + * [~zcl_attributes(options)](#module_Templating API_ static zcl helpers..zcl_attributes) ⇒ + * [~zcl_attributes_client(options)](#module_Templating API_ static zcl helpers..zcl_attributes_client) ⇒ + * [~zcl_attributes_server(options)](#module_Templating API_ static zcl helpers..zcl_attributes_server) ⇒ + * [~zcl_atomics(options)](#module_Templating API_ static zcl helpers..zcl_atomics) ⇒ + * [~zcl_cluster_largest_label_length()](#module_Templating API_ static zcl helpers..zcl_cluster_largest_label_length) ⇒ + * [~largestLabelLength(An)](#module_Templating API_ static zcl helpers..largestLabelLength) ⇒ + * [~zcl_command_arguments_count(commandId)](#module_Templating API_ static zcl helpers..zcl_command_arguments_count) ⇒ + * [~ifCommandArgumentsHaveFixedLengthWithCurrentContext(commandId, fixedLengthReturn, notFixedLengthReturn, currentContext)](#module_Templating API_ static zcl helpers..ifCommandArgumentsHaveFixedLengthWithCurrentContext) + * [~if_command_arguments_have_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn)](#module_Templating API_ static zcl helpers..if_command_arguments_have_fixed_length) + * [~as_underlying_zcl_type_command_is_not_fixed_length_but_command_argument_is_always_present(type, command, commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_is_not_fixed_length_but_command_argument_is_always_present) ⇒ + * [~as_underlying_zcl_type_if_command_is_not_fixed_length(type, commandId, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_if_command_is_not_fixed_length) + * [~command_arguments_total_length(commandId)](#module_Templating API_ static zcl helpers..command_arguments_total_length) + * [~zcl_command_arguments(options)](#module_Templating API_ static zcl helpers..zcl_command_arguments) ⇒ + * [~zcl_event_fields(options)](#module_Templating API_ static zcl helpers..zcl_event_fields) + * [~zcl_command_argument_data_type(typeName, options)](#module_Templating API_ static zcl helpers..zcl_command_argument_data_type) + * [~asUnderlyingZclType(typeName, options)](#module_Templating API_ static zcl helpers..asUnderlyingZclType) + * [~zcl_string_type_return(type, options)](#module_Templating API_ static zcl helpers..zcl_string_type_return) + * [~is_zcl_string(type)](#module_Templating API_ static zcl helpers..is_zcl_string) + * [~if_is_number(type)](#module_Templating API_ static zcl helpers..if_is_number) ⇒ + * [~if_is_string(type)](#module_Templating API_ static zcl helpers..if_is_string) ⇒ + * [~if_is_char_string(type)](#module_Templating API_ static zcl helpers..if_is_char_string) ⇒ + * [~if_is_octet_string(type)](#module_Templating API_ static zcl helpers..if_is_octet_string) ⇒ + * [~if_is_short_string(type)](#module_Templating API_ static zcl helpers..if_is_short_string) ⇒ + * [~if_is_long_string(type)](#module_Templating API_ static zcl helpers..if_is_long_string) ⇒ + * [~if_is_atomic(type:)](#module_Templating API_ static zcl helpers..if_is_atomic) ⇒ + * [~if_is_bitmap(type)](#module_Templating API_ static zcl helpers..if_is_bitmap) ⇒ + * [~if_is_enum(type)](#module_Templating API_ static zcl helpers..if_is_enum) ⇒ + * [~if_is_struct(type)](#module_Templating API_ static zcl helpers..if_is_struct) ⇒ + * [~isClient(side)](#module_Templating API_ static zcl helpers..isClient) ⇒ + * [~isServer(side)](#module_Templating API_ static zcl helpers..isServer) ⇒ + * [~isStrEqual(str1, str2)](#module_Templating API_ static zcl helpers..isStrEqual) ⇒ + * [~isLastElement(index, count)](#module_Templating API_ static zcl helpers..isLastElement) ⇒ + * [~isFirstElement(index, count)](#module_Templating API_ static zcl helpers..isFirstElement) ⇒ + * [~isEnabled(enable)](#module_Templating API_ static zcl helpers..isEnabled) ⇒ + * [~isCommandAvailable(clusterSide, incoming, outgoing, source, name)](#module_Templating API_ static zcl helpers..isCommandAvailable) ⇒ + * [~as_underlying_zcl_type_command_argument_always_present(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_always_present) ⇒ + * [~if_command_argument_always_present(commandId, introducedInRef, removedInRef, presentIf, argumentPresentReturn, argumentNotPresentReturn)](#module_Templating API_ static zcl helpers..if_command_argument_always_present) ⇒ + * [~as_underlying_zcl_type_command_argument_not_always_present_no_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_not_always_present_no_presentif) ⇒ + * [~as_underlying_zcl_type_ca_not_always_present_no_presentif(commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_ca_not_always_present_no_presentif) ⇒ + * [~if_command_argument_not_always_present_no_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsReturn, argumentInAllVersionsReturn)](#module_Templating API_ static zcl helpers..if_command_argument_not_always_present_no_presentif) ⇒ + * [~as_underlying_zcl_type_command_argument_not_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_not_always_present_with_presentif) ⇒ + * [~as_underlying_zcl_type_ca_not_always_present_with_presentif(commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_ca_not_always_present_with_presentif) ⇒ + * [~if_command_argument_not_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn)](#module_Templating API_ static zcl helpers..if_command_argument_not_always_present_with_presentif) ⇒ + * [~as_underlying_zcl_type_command_argument_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_always_present_with_presentif) ⇒ + * [~as_underlying_zcl_type_ca_always_present_with_presentif(commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_ca_always_present_with_presentif) ⇒ + * [~if_command_argument_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn)](#module_Templating API_ static zcl helpers..if_command_argument_always_present_with_presentif) ⇒ + * [~if_manufacturing_specific_cluster(clusterId, manufacturer_specific_return, null_manufacturer_specific_return)](#module_Templating API_ static zcl helpers..if_manufacturing_specific_cluster) ⇒ + * [~if_mfg_specific_cluster(clusterId, options)](#module_Templating API_ static zcl helpers..if_mfg_specific_cluster) ⇒ + * [~as_generated_default_macro(value, attributeSize, options)](#module_Templating API_ static zcl helpers..as_generated_default_macro) ⇒ + * [~attribute_mask(writable, storageOption, minMax, mfgSpecific, clusterCode, client, isSingleton, prefixString, postfixString)](#module_Templating API_ static zcl helpers..attribute_mask) ⇒ + * [~command_mask(commmandSource, clusterSide, isIncomingEnabled, isOutgoingEnabled, manufacturingCode, prefixForMask)](#module_Templating API_ static zcl helpers..command_mask) ⇒ + * [~command_mask_sub_helper(commandMask, str)](#module_Templating API_ static zcl helpers..command_mask_sub_helper) ⇒ + * [~format_zcl_string_as_characters_for_generated_defaults(stringVal, sizeOfString)](#module_Templating API_ static zcl helpers..format_zcl_string_as_characters_for_generated_defaults) ⇒ + * [~as_type_min_value(type, options)](#module_Templating API_ static zcl helpers..as_type_min_value) ⇒ + * [~as_type_max_value(type, options)](#module_Templating API_ static zcl helpers..as_type_max_value) ⇒ + * [~structs_with_clusters(options)](#module_Templating API_ static zcl helpers..structs_with_clusters) + * [~as_zcl_type_size(type, options)](#module_Templating API_ static zcl helpers..as_zcl_type_size) ⇒ + * [~if_compare(leftValue, rightValue, options)](#module_Templating API_ static zcl helpers..if_compare) ⇒ Object + * [~if_is_data_type_signed(type, clusterId, options)](#module_Templating API_ static zcl helpers..if_is_data_type_signed) ⇒ + * [~as_zcl_data_type_size(type, clusterId, options)](#module_Templating API_ static zcl helpers..as_zcl_data_type_size) ⇒ -This method returns the correct instance for a given generation flow. + -TBD: At this point it doesn't do anything yet, it's just -a central point to get the correct instance. +### Templating API: static zcl helpers~zcl\_bitmaps(options) ⇒ +Block helper iterating over all bitmaps. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Instance of handlebars to be used. - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -### JS API: generator logic~makeSynchronizablePromise(promise) +| Param | Type | +| --- | --- | +| options | \* | -All promises used by the templates should be synchronizable. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +### Templating API: static zcl helpers~zcl\_bitmap\_items(options) +Iterates over enum items. Valid only inside zcl_enums. -| Param | Type | -| ------- | --------------- | -| promise | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) - +| Param | Type | +| --- | --- | +| options | \* | -### JS API: generator logic~collectBlocks(resultArray, options, context) ⇒ + -Helpful function that collects the individual blocks by using elements of an array as a context, -executing promises for each, and collecting them into the outgoing string. +### Templating API: static zcl helpers~zcl\_enums(options) ⇒ +Block helper iterating over all enums. +If existing independently, it iterates over ALL the enums. +Within a context of a cluster, it iterates only over the +enums belonging to a cluster. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves with a content string. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Type | Description | -| ----------- | --------------- | ---------------------------------------- | -| resultArray | \* | | -| options | \* | Options passed from a block helper. | -| context | \* | The context from within this was called. | +| Param | Type | +| --- | --- | +| options | \* | - + -### JS API: generator logic~ensureZclPackageId(context) ⇒ +### Templating API: static zcl helpers~zcl\_structs(options) ⇒ +Block helper iterating over all structs. +If existing independently, it iterates over ALL the structs. +Within a context of a cluster, it iterates only over the +structs belonging to a cluster. -Returns the promise that resolves with the ZCL properties package id. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the package id. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ------- | --------------- | -| context | \* | + - +### Templating API: static zcl helpers~zcl\_enum\_items(options) +Iterates over enum items. Valid only inside zcl_enums. -### JS API: generator logic~ensureZclPackageIds(context) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -Returns the promise that resolves with all ZCL package id specific to current session. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with a list of package id. + -| Param | Type | -| ------- | --------------- | -| context | \* | +### Templating API: static zcl helpers~first\_unused\_enum\_value(options) ⇒ +This helper prints out the first unused enum value. +It supports mode="next_larger" and +mode="first_unused" (which is the default). - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the unused enum value -### JS API: generator logic~ensureTemplatePackageCategory(context) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Returns a package category of the toplevel template package from context. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: proimise that resolves into a package category +### Templating API: static zcl helpers~zcl\_struct\_items(options) ⇒ +Block helper iterating over all struct items. Valid only inside zcl_structs. -| Param | Type | -| ------- | --------------- | -| context | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. - +| Param | Type | +| --- | --- | +| options | \* | -### JS API: generator logic~ensureTemplatePackageId(context) ⇒ + -Returns the promise that resolves with the ZCL properties package id. +### Templating API: static zcl helpers~zcl\_struct\_items\_by\_struct\_name(name, options) ⇒ +Block helper iterating over all struct items given the struct name. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the package id. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Type | -| ------- | --------------- | -| context | \* | +| Param | +| --- | +| name | +| options | - + -### JS API: generator logic~ensureEndpointTypeIds(context) ⇒ +### Templating API: static zcl helpers~zcl\_struct\_items\_by\_struct\_and\_cluster\_name(name, clusterName, options) ⇒ +Block helper iterating over all struct items given the struct name and +cluster name. The items iterated will be those that correspond to that +struct name being used within the given cluster. That means the struct name +must be either a global struct (in which case the cluster name is just +ignored), or a struct associated with the given cluster. -Populate the endpoint type ids into the global context. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: endpoint type ids +| Param | +| --- | +| name | +| clusterName | +| options | -| Param | Type | -| ------- | --------------- | -| context | \* | + - +### Templating API: static zcl helpers~zcl\_device\_types(options) ⇒ +Block helper iterating over all deviceTypes. -### JS API: generator logic~ensureZclClusterSdkExtensions(context, templatePackageId) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -Resolves with cached cluster extensions, but if they don't -exist, it will populate them. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with cluster extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +### Templating API: static zcl helpers~zcl\_device\_type\_clusters(options) ⇒ +Block helper for use inside zcl_device_types - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: blocks for clusters -### JS API: generator logic~ensureZclDeviceTypeSdkExtensions(context, templatePackageId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Resolves with cached cluster extensions, but if they don't -exist, it will populate them. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with cluster extensions. +### Templating API: static zcl helpers~zcl\_device\_type\_cluster\_commands(options) ⇒ +Block helper for use inside zcl_device_type_clusters -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: blocks for commands - +| Param | Type | +| --- | --- | +| options | \* | -### JS API: generator logic~ensureZclAttributeSdkExtensions(context, templatePackageId) ⇒ + -Resolves with cached attribute extensions, but if they don't -exist, it will populate them. +### Templating API: static zcl helpers~zcl\_device\_type\_cluster\_attributes(options) ⇒ +Block helper for use inside zcl_device_type_clusters -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with attribute extensions. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: blocks for attributes -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### JS API: generator logic~ensureZclAttributeTypeSdkExtensions(context, templatePackageId) ⇒ +### Templating API: static zcl helpers~zcl\_clusters(options) ⇒ +Block helper iterating over all clusters. -Resolves with cached attribute type extensions, but if they don't -exist, it will populate them. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with attribute type extensions. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | + - +### Templating API: static zcl helpers~zcl\_commands(options) ⇒ +Block helper iterating over all commands. +There are two modes of this helper: + when used in a global context, it iterates over ALL commands in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the commands for that cluster. -### JS API: generator logic~ensureZclCommandSdkExtensions(context, templatePackageId) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -Resolves with cached command extensions, but if they don't -exist, it will populate them. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with command extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +### Templating API: static zcl helpers~zcl\_command\_responses(options) ⇒ +Returns all commands which are command responses. +For eg, If the xml has the following: + +then newCmdResponse will be included in the list of commands returned here. - +There are two modes of this helper: +- when used in a global context, it iterates over ALL command responses in +the database. +- when used inside a `zcl_cluster` block helper, it iterates only over the +commands responses for that cluster. -### JS API: generator logic~ensureZclEventSdkExtensions(context, templatePackageId) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: all command responses -Resolves with cached command extensions, but if they don't -exist, it will populate them. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with command extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +### Templating API: static zcl helpers~zcl\_commands\_with\_cluster\_info(options) ⇒ +Block helper iterating over all commands with cluster information. +Note: Similar to zcl_commands but has cluster information as well. - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -### JS API: generator logic~templatePromise(global, promise) +| Param | Type | +| --- | --- | +| options | \* | -Every helper that returns a promise, should -not return the promise directly. So instead of -returning the promise directly, it should return: -return templatePromise(this.global, promise) + -This will ensure that after tag works as expected. +### Templating API: static zcl helpers~zcl\_commands\_with\_arguments(options) +Helper that retrieves all commands that contain arguments. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -| Param | Type | -| ------- | --------------- | -| global | \* | -| promise | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### JS API: generator logic~deprecatedHelper(fn, explanation) ⇒ +### Templating API: static zcl helpers~zcl\_commands\_source\_client(options) ⇒ +Block helper iterating over all client commands. +There are two modes of this helper: + when used in a global context, it iterates over ALL client commands in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the commands for that client cluster. -Function wrapper that can be used when a helper is deprecated. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: a function that wraps the original function, with deprecation message. +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | Description | -| ----------- | --------------- | ----------------------------------------------------------------------- | -| fn | \* | | -| explanation | \* | can contain `text`, or `from`/`to`, or just be a string message itself. | + - +### Templating API: static zcl helpers~zcl\_commands\_source\_server(options) ⇒ +Block helper iterating over all server commands. +There are two modes of this helper: + when used in a global context, it iterates over ALL server commands in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the commands for that server cluster. -## Templating API: Access helpers +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} +| Param | Type | +| --- | --- | +| options | \* | -- [Templating API: Access helpers](#module*Templating API* Access helpers) - - [~access_aggregate(options)](#module*Templating API* Access helpers..access_aggregate) - - [~access(options)](#module*Templating API* Access helpers..access) + - +### Templating API: static zcl helpers~zcl\_events(options) ⇒ +Block helper iterating over all events. +There are two modes of this helper: + when used in a global context, it iterates over ALL events in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the events for that cluster. -### Templating API: Access helpers~access_aggregate(options) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -This helper creates a context for the aggregates of access. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [Templating API: Access helpers](#module*Templating API* Access helpers) + -| Param | Type | -| ------- | --------------- | -| options | \* | +### Templating API: static zcl helpers~zcl\_command\_tree(options) ⇒ +Block helper iterating over all commands, including their arguments and clusters. - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -### Templating API: Access helpers~access(options) +| Param | Type | +| --- | --- | +| options | \* | -Access helper iterates across all the access triplets associated with the element. -For each element, context contains role, operation, accessModifier. -Additionally it creates booleans hasRole, hasOperation and hasAccessModifier -and hasAtLeastOneAccessElement and hasAllAccessElements + -**Kind**: inner method of [Templating API: Access helpers](#module*Templating API* Access helpers) +### Templating API: static zcl helpers~zcl\_global\_commands(options) ⇒ +Helper to iterate over all global commands. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of global command iteration. - +| Param | Type | +| --- | --- | +| options | \* | -## Templating API: C formatting helpers + -This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} +### Templating API: static zcl helpers~zcl\_attributes(options) ⇒ +Iterator over the attributes. If it is used at toplevel, if iterates over all the attributes +in the database. If used within zcl_cluster context, it iterates over all the attributes +that belong to that cluster. -- [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) - - [~asOffset(hex)](#module*Templating API* C formatting helpers..asOffset) - - [~asDelimitedMacro(label)](#module*Templating API* C formatting helpers..asDelimitedMacro) - - [~asHex(label)](#module*Templating API* C formatting helpers..asHex) ⇒ - - [~asUnderlyingTypeHelper(dataType, context, packageIds)](#module*Templating API* C formatting helpers..asUnderlyingTypeHelper) ⇒ - - [~asUnderlyingType(value)](#module*Templating API* C formatting helpers..asUnderlyingType) ⇒ - - [~asType(label)](#module*Templating API* C formatting helpers..asType) ⇒ - - [~asSymbol(label)](#module*Templating API* C formatting helpers..asSymbol) ⇒ - - [~asBytes(value)](#module*Templating API* C formatting helpers..asBytes) - - [~asCamelCased(str)](#module*Templating API* C formatting helpers..asCamelCased) ⇒ - - [~cleanseLabel(label)](#module*Templating API* C formatting helpers..cleanseLabel) - - [~asUnderscoreLowercase(str)](#module*Templating API* C formatting helpers..asUnderscoreLowercase) ⇒ - - [~cleanseLabelAsKebabCase(label)](#module*Templating API* C formatting helpers..cleanseLabelAsKebabCase) - - [~asSpacedLowercase(str)](#module*Templating API* C formatting helpers..asSpacedLowercase) ⇒ - - [~asUnderscoreUppercase(str)](#module*Templating API* C formatting helpers..asUnderscoreUppercase) ⇒ - - [~asCliType(size, isSigned)](#module*Templating API* C formatting helpers..asCliType) ⇒ - - [~as_zcl_cli_type(str, optional, isSigned)](#module*Templating API* C formatting helpers..as_zcl_cli_type) - - [~dataTypeForBitmap(db, bitmap_name, packageIds)](#module*Templating API* C formatting helpers..dataTypeForBitmap) - - [~dataTypeForEnum(db, enum_name, packageIds)](#module*Templating API* C formatting helpers..dataTypeForEnum) - - [~addOne(number)](#module*Templating API* C formatting helpers..addOne) - - [~is_number_greater_than(num1, num2)](#module*Templating API* C formatting helpers..is_number_greater_than) ⇒ - - [~cluster_extension(options)](#module*Templating API* C formatting helpers..cluster_extension) ⇒ - - [~device_type_extension(options)](#module*Templating API* C formatting helpers..device_type_extension) ⇒ - - [~attribute_type_extension(options)](#module*Templating API* C formatting helpers..attribute_type_extension) ⇒ - - [~attribute_extension(options)](#module*Templating API* C formatting helpers..attribute_extension) ⇒ - - [~command_extension(options)](#module*Templating API* C formatting helpers..command_extension) ⇒ - - [~event_extension(options)](#module*Templating API* C formatting helpers..event_extension) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of attribute iteration. - +| Param | Type | +| --- | --- | +| options | \* | -### Templating API: C formatting helpers~asOffset(hex) + -Given a hex number, it prints the offset, which is the index of the first non-zero bit. +### Templating API: static zcl helpers~zcl\_attributes\_client(options) ⇒ +Iterator over the client attributes. If it is used at toplevel, if iterates over all the client attributes +in the database. If used within zcl_cluster context, it iterates over all the client attributes +that belong to that cluster. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of attribute iteration. -| Param | Type | -| ----- | --------------- | -| hex | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### Templating API: C formatting helpers~asDelimitedMacro(label) +### Templating API: static zcl helpers~zcl\_attributes\_server(options) ⇒ +Iterator over the server attributes. If it is used at toplevel, if iterates over all the server attributes +in the database. If used within zcl_cluster context, it iterates over all the server attributes +that belong to that cluster. +Available Options: +- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js) +for eg: (#zcl_attributes_server removeKeys='isOptional, isNullable') will remove 'isOptional' +from the results -Takes a label, and delimits is on camelcasing. -For example: -VerySimpleLabel will turn into VERY_SIMPLE_LABEL +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of attribute iteration. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +| Param | Type | +| --- | --- | +| options | \* | -| Param | Type | -| ----- | --------------- | -| label | \* | + - +### Templating API: static zcl helpers~zcl\_atomics(options) ⇒ +Block helper iterating over all atomic types. -### Templating API: C formatting helpers~asHex(label) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -Formats label as a C hex constant. -If value starts as 0x or 0X it is already treated as hex, -otherwise it is assumed decimal and converted to hex. +| Param | Type | +| --- | --- | +| options | \* | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Label formatted as C hex constant. + -| Param | Type | -| ----- | --------------- | -| label | \* | +### Templating API: static zcl helpers~zcl\_cluster\_largest\_label\_length() ⇒ +Given: N/A - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the length of largest cluster name in a list of clusters + -### Templating API: C formatting helpers~asUnderlyingTypeHelper(dataType, context, packageIds) ⇒ +### Templating API: static zcl helpers~largestLabelLength(An) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the length of largest object name in an array. Helper for +zcl_cluster_largest_label_length -This function is a helper function for asUnderlyingType and assists in -returning the correct C type for the given data type +| Param | Type | Description | +| --- | --- | --- | +| An | \* | Array | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: The appropriate C type for the given data type + -| Param | Type | -| ---------- | --------------- | -| dataType | \* | -| context | \* | -| packageIds | \* | +### Templating API: static zcl helpers~zcl\_command\_arguments\_count(commandId) ⇒ +Helper to extract the number of command arguments in a command - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Number of command arguments as an integer -### Templating API: C formatting helpers~asUnderlyingType(value) ⇒ +| Param | Type | +| --- | --- | +| commandId | \* | -Converts the actual zcl type into an underlying usable C type. + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: The appropriate C Type +### Templating API: static zcl helpers~ifCommandArgumentsHaveFixedLengthWithCurrentContext(commandId, fixedLengthReturn, notFixedLengthReturn, currentContext) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -| Param | Type | -| ----- | --------------- | -| value | \* | +| Param | Description | +| --- | --- | +| commandId | | +| fixedLengthReturn | | +| notFixedLengthReturn | | +| currentContext | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not | - + -### Templating API: C formatting helpers~asType(label) ⇒ +### Templating API: static zcl helpers~if\_command\_arguments\_have\_fixed\_length(commandId, fixedLengthReturn, notFixedLengthReturn) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -Formats label as a C type. +| Param | Description | +| --- | --- | +| commandId | | +| fixedLengthReturn | | +| notFixedLengthReturn | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not. Does not check if command arguments are always present or not. | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Label formatted as C type. + -| Param | Type | -| ----- | --------------- | -| label | \* | +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_is\_not\_fixed\_length\_but\_command\_argument\_is\_always\_present(type, command, commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the underlying zcl type of a command argument if the argument is +not fixed length but is always present. If the condition is not met then +returns an empty string. - +| Param | +| --- | +| type | +| command | +| commandArg | +| appendString | +| options | -### Templating API: C formatting helpers~asSymbol(label) ⇒ + -Formats label as a C symbol. +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_if\_command\_is\_not\_fixed\_length(type, commandId, appendString, options) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Label formatted as C symbol. +| Param | Description | +| --- | --- | +| type | | +| commandId | | +| appendString | | +| options | Returns: Given the commandId and the type of one of its arguments, based on whether the command is fixed length or not either return nothing or return the underlying zcl type appended with the appendString. | -| Param | Type | -| ----- | --------------- | -| label | \* | + - +### Templating API: static zcl helpers~command\_arguments\_total\_length(commandId) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -### Templating API: C formatting helpers~asBytes(value) +| Param | Description | +| --- | --- | +| commandId | Returns the size of the command by calculating the sum total of the command arguments Note: This helper should be called on fixed length commands only. It should not be called with commands which do not have a fixed length. | -Given a default value of attribute, this method converts it into bytes + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +### Templating API: static zcl helpers~zcl\_command\_arguments(options) ⇒ +Block helper iterating over command arguments within a command +or a command tree. -| Param | Type | -| ----- | --------------- | -| value | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of command argument iteration. - +| Param | Type | +| --- | --- | +| options | \* | -### Templating API: C formatting helpers~asCamelCased(str) ⇒ + -Given a string convert it into a camelCased string +### Templating API: static zcl helpers~zcl\_event\_fields(options) +Block helper iterating over the event fields inside an event. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: a spaced out string in lowercase +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -| Param | Type | -| ----- | --------------- | -| str | \* | +| Param | Type | +| --- | --- | +| options | \* | - + -### Templating API: C formatting helpers~cleanseLabel(label) +### Templating API: static zcl helpers~zcl\_command\_argument\_data\_type(typeName, options) +Helper that deals with the type of the argument. -returns a string after converting ':' and '-' into '\_' +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +| Param | Type | +| --- | --- | +| typeName | \* | +| options | \* | -| Param | Type | -| ----- | --------------- | -| label | \* | + - +### Templating API: static zcl helpers~asUnderlyingZclType(typeName, options) +Helper that deals with the type of the argument. -### Templating API: C formatting helpers~asUnderscoreLowercase(str) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -Given a camel case string, convert it into one with underscore and lowercase +| Param | Type | Description | +| --- | --- | --- | +| typeName | \* | | +| options | \* | Note: If the options has zclCharFormatter set to true then the function will return the user defined data associated with the zcl data type and not the actual data type. example: {{asUnderlyingZclType [array type] array="b" one_byte="u" two_byte="v" three_byte="x" four_byte="w" short_string="s" long_string="l" default="b" zclCharFormatter="true"}} For the above if asUnderlyingZclType was given [array type] then the above will return 'b' | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: String in lowercase with underscores + -| Param | Type | -| ----- | --------------- | -| str | \* | +### Templating API: static zcl helpers~zcl\_string\_type\_return(type, options) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) - +| Param | Description | +| --- | --- | +| type | | +| options | Returns the data mentioned in the helper options based on whether the type is short string, long string or not a string Example: {{zcl_string_type_return type short_string="short string output" long_string="short string output" default="Output when not a string") | -### Templating API: C formatting helpers~cleanseLabelAsKebabCase(label) + -returns a string after converting ':', ' ' and camel case into '-' +### Templating API: static zcl helpers~is\_zcl\_string(type) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +| Param | Description | +| --- | --- | +| type | Return: true or false based on whether the type is a string or not. | -| Param | Type | -| ----- | --------------- | -| label | \* | + - +### Templating API: static zcl helpers~if\_is\_number(type) ⇒ +If helper that checks if a type is a string -### Templating API: C formatting helpers~asSpacedLowercase(str) ⇒ +example: +{{#if_is_number type}} +type is number +{{else}} +type is not number +{{/if_is_number}} -Given a camel case string convert it into one with space and lowercase +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: a spaced out string in lowercase +| Param | Type | +| --- | --- | +| type | \* | -| Param | Type | -| ----- | --------------- | -| str | \* | + - +### Templating API: static zcl helpers~if\_is\_string(type) ⇒ +If helper that checks if a type is a string -### Templating API: C formatting helpers~asUnderscoreUppercase(str) ⇒ +example: +{{#if_is_string type}} +type is string +{{else}} +type is not string +{{/if_is_string}} -Given a camel case string convert it into one with underscore and uppercase +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: String in uppercase with underscores +| Param | Type | +| --- | --- | +| type | \* | -| Param | Type | -| ----- | --------------- | -| str | \* | + - +### Templating API: static zcl helpers~if\_is\_char\_string(type) ⇒ +If helper that checks if a string type is present in the list of char strings +i.e. characterStringTypes -### Templating API: C formatting helpers~asCliType(size, isSigned) ⇒ +example: +{{#if_is_char_string type}} +type is char string +{{else}} +type is not char string +{{/if_is_char_string}} -Returns the cli type representation. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: the type representation required for CLI. +| Param | Type | +| --- | --- | +| type | \* | -| Param | -| -------- | -| size | -| isSigned | + - +### Templating API: static zcl helpers~if\_is\_octet\_string(type) ⇒ +If helper that checks if a string type is present in the list of octet strings +i.e. octetStringTypes -### Templating API: C formatting helpers~as_zcl_cli_type(str, optional, isSigned) +example: +{{#if_is_octet_string type}} +type is octet string +{{else}} +type is not octet string +{{/if_is_octet_string}} -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Description | -| -------- | ------------------------------- | -| str | | -| optional | | -| isSigned | Return the data type of zcl cli | +| Param | Type | +| --- | --- | +| type | \* | - + -### Templating API: C formatting helpers~dataTypeForBitmap(db, bitmap_name, packageIds) +### Templating API: static zcl helpers~if\_is\_short\_string(type) ⇒ +If helper that checks if a string type is present in the list of short strings +i.e. stringShortTypes -Returns the type of bitmap based on the bitmap's name +example: +{{#if_is_short_string type}} +type is short string +{{else}} +type is not short string +{{/if_is_short_string}} -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| bitmap_name | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| type | \* | - + -### Templating API: C formatting helpers~dataTypeForEnum(db, enum_name, packageIds) +### Templating API: static zcl helpers~if\_is\_long\_string(type) ⇒ +If helper that checks if a string type is present in the list of long strings +i.e. stringLongTypes -Returns the type of enum +example: +{{#if_is_long_string type}} +type is long string +{{else}} +type is not long string +{{/if_is_long_string}} -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| enum_name | \* | -| packageIds | \* | +| Param | Type | +| --- | --- | +| type | \* | - + -### Templating API: C formatting helpers~addOne(number) +### Templating API: static zcl helpers~if\_is\_atomic(type:) ⇒ +If helper that checks if a type is an atomic -Returns the number by adding 1 to it. +example: +{{#if_is_atomic type}} +type is atomic +{{else}} +type is not atomic +{{/if_is_atomic}} -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Type | -| ------ | --------------- | -| number | \* | +| Param | Type | Description | +| --- | --- | --- | +| type: | \* | string | - + -### Templating API: C formatting helpers~is_number_greater_than(num1, num2) ⇒ +### Templating API: static zcl helpers~if\_is\_bitmap(type) ⇒ +If helper that checks if a type is a bitmap -Return true if number1 is greater than number2 +example: +{{#if_is_bitmap type}} +type is bitmap +{{else}} +type is not bitmap +{{/if_is_bitmap}} -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: true if num1 is greater than num2 else returns false +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | -| ----- | -| num1 | -| num2 | +| Param | Type | +| --- | --- | +| type | \* | - + -### Templating API: C formatting helpers~cluster_extension(options) ⇒ +### Templating API: static zcl helpers~if\_is\_enum(type) ⇒ +If helper that checks if a type is an enum -When inside a context that contains 'code', this -helper will output the value of the cluster extension -specified by property="propName" attribute. +* example: +{{#if_is_enum type}} +type is enum +{{else}} +type is not enum +{{/if_is_enum}} -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the cluster extension property. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| type | \* | - + -### Templating API: C formatting helpers~device_type_extension(options) ⇒ +### Templating API: static zcl helpers~if\_is\_struct(type) ⇒ +If helper that checks if a type is an struct -When inside a context that contains 'code', this -helper will output the value of the cluster extension -specified by property="propName" attribute. +* example: +{{#if_is_struct type}} +type is struct +{{else}} +type is not struct +{{/if_is_struct}} -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the cluster extension property. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | +| --- | +| type | - + -### Templating API: C formatting helpers~attribute_type_extension(options) ⇒ +### Templating API: static zcl helpers~isClient(side) ⇒ +Checks if the side is client or not -When inside a context that contains 'type', this -helper will output the value of the attribute type extension -specified by property="propName" attribute. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the attribute type extension property. +| Param | Type | +| --- | --- | +| side | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### Templating API: static zcl helpers~isServer(side) ⇒ +Checks if the side is server or not -### Templating API: C formatting helpers~attribute_extension(options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean -When inside a context that contains 'code' and parent 'code', this -helper will output the value of the attribute extension -specified by property="propName" attribute. +| Param | Type | +| --- | --- | +| side | \* | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the attribute extension property. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### Templating API: static zcl helpers~isStrEqual(str1, str2) ⇒ +Compares 2 strings. - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean -### Templating API: C formatting helpers~command_extension(options) ⇒ +| Param | Type | +| --- | --- | +| str1 | \* | +| str2 | \* | -When inside a context that contains 'code' and parent 'code', this -helper will output the value of the command extension -specified by property="propName" attribute. + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the command extension property. +### Templating API: static zcl helpers~isLastElement(index, count) ⇒ +Returns boolean based on whether the element is the last element. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| index | \* | +| count | \* | -### Templating API: C formatting helpers~event_extension(options) ⇒ + -When inside a context that contains 'code' and parent 'code', this -helper will output the value of the command extension -specified by property="propName" attribute. +### Templating API: static zcl helpers~isFirstElement(index, count) ⇒ +Returns boolean based on whether the element is the first element. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the command extension property. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| index | \* | +| count | \* | - + -## Templating API: C formatting helpers +### Templating API: static zcl helpers~isEnabled(enable) ⇒ +Check if enable is 1. -This module contains the API for accessing SDK extensions. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean -- [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) - - [~asOffset(hex)](#module*Templating API* C formatting helpers..asOffset) - - [~asDelimitedMacro(label)](#module*Templating API* C formatting helpers..asDelimitedMacro) - - [~asHex(label)](#module*Templating API* C formatting helpers..asHex) ⇒ - - [~asUnderlyingTypeHelper(dataType, context, packageIds)](#module*Templating API* C formatting helpers..asUnderlyingTypeHelper) ⇒ - - [~asUnderlyingType(value)](#module*Templating API* C formatting helpers..asUnderlyingType) ⇒ - - [~asType(label)](#module*Templating API* C formatting helpers..asType) ⇒ - - [~asSymbol(label)](#module*Templating API* C formatting helpers..asSymbol) ⇒ - - [~asBytes(value)](#module*Templating API* C formatting helpers..asBytes) - - [~asCamelCased(str)](#module*Templating API* C formatting helpers..asCamelCased) ⇒ - - [~cleanseLabel(label)](#module*Templating API* C formatting helpers..cleanseLabel) - - [~asUnderscoreLowercase(str)](#module*Templating API* C formatting helpers..asUnderscoreLowercase) ⇒ - - [~cleanseLabelAsKebabCase(label)](#module*Templating API* C formatting helpers..cleanseLabelAsKebabCase) - - [~asSpacedLowercase(str)](#module*Templating API* C formatting helpers..asSpacedLowercase) ⇒ - - [~asUnderscoreUppercase(str)](#module*Templating API* C formatting helpers..asUnderscoreUppercase) ⇒ - - [~asCliType(size, isSigned)](#module*Templating API* C formatting helpers..asCliType) ⇒ - - [~as_zcl_cli_type(str, optional, isSigned)](#module*Templating API* C formatting helpers..as_zcl_cli_type) - - [~dataTypeForBitmap(db, bitmap_name, packageIds)](#module*Templating API* C formatting helpers..dataTypeForBitmap) - - [~dataTypeForEnum(db, enum_name, packageIds)](#module*Templating API* C formatting helpers..dataTypeForEnum) - - [~addOne(number)](#module*Templating API* C formatting helpers..addOne) - - [~is_number_greater_than(num1, num2)](#module*Templating API* C formatting helpers..is_number_greater_than) ⇒ - - [~cluster_extension(options)](#module*Templating API* C formatting helpers..cluster_extension) ⇒ - - [~device_type_extension(options)](#module*Templating API* C formatting helpers..device_type_extension) ⇒ - - [~attribute_type_extension(options)](#module*Templating API* C formatting helpers..attribute_type_extension) ⇒ - - [~attribute_extension(options)](#module*Templating API* C formatting helpers..attribute_extension) ⇒ - - [~command_extension(options)](#module*Templating API* C formatting helpers..command_extension) ⇒ - - [~event_extension(options)](#module*Templating API* C formatting helpers..event_extension) ⇒ +| Param | Type | +| --- | --- | +| enable | \* | - + -### Templating API: C formatting helpers~asOffset(hex) +### Templating API: static zcl helpers~isCommandAvailable(clusterSide, incoming, outgoing, source, name) ⇒ +Returns boolean based on command being available or not. -Given a hex number, it prints the offset, which is the index of the first non-zero bit. +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +| Param | Type | +| --- | --- | +| clusterSide | \* | +| incoming | \* | +| outgoing | \* | +| source | \* | +| name | \* | -| Param | Type | -| ----- | --------------- | -| hex | \* | + - +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_always\_present(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length and the command +argument is always present in all zcl specifications. -### Templating API: C formatting helpers~asDelimitedMacro(label) +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | -Takes a label, and delimits is on camelcasing. -For example: -VerySimpleLabel will turn into VERY_SIMPLE_LABEL + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +### Templating API: static zcl helpers~if\_command\_argument\_always\_present(commandId, introducedInRef, removedInRef, presentIf, argumentPresentReturn, argumentNotPresentReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentPresentReturn if the command is not fixed length and command +argument is always present without conditions(introducedInRef, removedInRef, +presentIf) else returns argumentNotPresentReturn -| Param | Type | -| ----- | --------------- | -| label | \* | +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentPresentReturn | +| argumentNotPresentReturn | - + -### Templating API: C formatting helpers~asHex(label) ⇒ +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_not\_always\_present\_no\_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length, the command +argument is not always present in all zcl specifications and there is no present if conditionality +on the command argument. -Formats label as a C hex constant. -If value starts as 0x or 0X it is already treated as hex, -otherwise it is assumed decimal and converted to hex. +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Label formatted as C hex constant. + -| Param | Type | -| ----- | --------------- | -| label | \* | +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_ca\_not\_always\_present\_no\_presentif(commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed +length, the command argument is not always present in all zcl specifications +and there is no present if conditionality on the command argument. - +| Param | Description | +| --- | --- | +| commandArg | command argument | +| appendString | append the string to the argument | +| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | -### Templating API: C formatting helpers~asUnderlyingTypeHelper(dataType, context, packageIds) ⇒ + -This function is a helper function for asUnderlyingType and assists in -returning the correct C type for the given data type +### Templating API: static zcl helpers~if\_command\_argument\_not\_always\_present\_no\_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsReturn, argumentInAllVersionsReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentNotInAllVersionsReturn if the command is not fixed length and command +argument is present with conditions introducedInRef or removedInRef but no presentIf +conditions else returns argumentNotPresentReturn -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: The appropriate C type for the given data type +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentNotInAllVersionsReturn | +| argumentInAllVersionsReturn | -| Param | Type | -| ---------- | --------------- | -| dataType | \* | -| context | \* | -| packageIds | \* | + - +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_not\_always\_present\_with\_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length, the command +argument is not always present in all zcl specifications and there is a present if conditionality +on the command argument. -### Templating API: C formatting helpers~asUnderlyingType(value) ⇒ +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | -Converts the actual zcl type into an underlying usable C type. + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: The appropriate C Type +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_ca\_not\_always\_present\_with\_presentif(commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed +length, the command argument is not always present in all zcl specifications +but there is a present if conditionality on the command argument. -| Param | Type | -| ----- | --------------- | -| value | \* | +| Param | Description | +| --- | --- | +| commandArg | command argument | +| appendString | append the string to the argument | +| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | - + -### Templating API: C formatting helpers~asType(label) ⇒ +### Templating API: static zcl helpers~if\_command\_argument\_not\_always\_present\_with\_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentNotInAllVersionsReturn if the command is not fixed length, command +argument is present with conditions introducedInRef or removedInRef and presentIf +conditions exist as well else returns argumentNotPresentReturn -Formats label as a C type. +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentNotInAllVersionsPresentIfReturn | +| argumentInAllVersionsReturn | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Label formatted as C type. + -| Param | Type | -| ----- | --------------- | -| label | \* | +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_always\_present\_with\_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length, the command +argument is always present in all zcl specifications and there is a present if conditionality +on the command argument. - +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | -### Templating API: C formatting helpers~asSymbol(label) ⇒ + -Formats label as a C symbol. +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_ca\_always\_present\_with\_presentif(commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed +length, the command argument is always present in all zcl specifications +but there is a present if conditionality on the command argument. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Label formatted as C symbol. +| Param | Description | +| --- | --- | +| commandArg | command argument | +| appendString | append the string to the argument | +| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | -| Param | Type | -| ----- | --------------- | -| label | \* | + - +### Templating API: static zcl helpers~if\_command\_argument\_always\_present\_with\_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentInAllVersionsPresentIfReturn if the command is not fixed length, command +argument is always present and presentIf conditions exist else returns argumentNotPresentReturn -### Templating API: C formatting helpers~asBytes(value) +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentNotInAllVersionsPresentIfReturn | +| argumentInAllVersionsReturn | -Given a default value of attribute, this method converts it into bytes + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +### Templating API: static zcl helpers~if\_manufacturing\_specific\_cluster(clusterId, manufacturer_specific_return, null_manufacturer_specific_return) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: manufacturer_specific_return if the cluster is manufacturer +specific or returns null_manufacturer_specific_return if cluster is +not manufacturer specific. -| Param | Type | -| ----- | --------------- | -| value | \* | +| Param | Type | +| --- | --- | +| clusterId | \* | +| manufacturer_specific_return | \* | +| null_manufacturer_specific_return | \* | - + -### Templating API: C formatting helpers~asCamelCased(str) ⇒ +### Templating API: static zcl helpers~if\_mfg\_specific\_cluster(clusterId, options) ⇒ +If helper which checks if cluster is manufacturing specific or not +example: +{{#if_mfg_specific_cluster clusterId}} + cluster is manufacturing specific +{{else}} + cluster is not manufacturing specific +{{/if_mfg_specific_cluster}} -Given a string convert it into a camelCased string +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Returns content in the handlebar template based on whether the +command is manufacturing specific or not. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: a spaced out string in lowercase +| Param | +| --- | +| clusterId | +| options | -| Param | Type | -| ----- | --------------- | -| str | \* | + - +### Templating API: static zcl helpers~as\_generated\_default\_macro(value, attributeSize, options) ⇒ +Given the value and size of an attribute along with endian as an option. +This helper returns the attribute value as big/little endian. +Example: {{as_generated_default_macro 0x00003840 4 endian="big"}} +will return: 0x00, 0x00, 0x38, 0x40, -### Templating API: C formatting helpers~cleanseLabel(label) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Formatted attribute value based on given arguments +Available options: +- endian: Specify 'big' or 'little' endian format +- isCommaTerminated: '0' or '1' for output to have a ',' at the end -returns a string after converting ':' and '-' into '\_' +| Param | +| --- | +| value | +| attributeSize | +| options | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) + -| Param | Type | -| ----- | --------------- | -| label | \* | +### Templating API: static zcl helpers~attribute\_mask(writable, storageOption, minMax, mfgSpecific, clusterCode, client, isSingleton, prefixString, postfixString) ⇒ +Given the attributes of a zcl attribute. Creates an attribute mask based on +the given options +Available options: +isClusterCodeMfgSpecific: 0/1, This is to determine if cluster code needs to +be used to determine if a cluster is mfg specific or not. - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: attribute mask based on given values -### Templating API: C formatting helpers~asUnderscoreLowercase(str) ⇒ +| Param | +| --- | +| writable | +| storageOption | +| minMax | +| mfgSpecific | +| clusterCode | +| client | +| isSingleton | +| prefixString | +| postfixString | -Given a camel case string, convert it into one with underscore and lowercase + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: String in lowercase with underscores +### Templating API: static zcl helpers~command\_mask(commmandSource, clusterSide, isIncomingEnabled, isOutgoingEnabled, manufacturingCode, prefixForMask) ⇒ +Given the attributes of a zcl command. Creates a command mask based on +the given options -| Param | Type | -| ----- | --------------- | -| str | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: command mask based on given values - +| Param | +| --- | +| commmandSource | +| clusterSide | +| isIncomingEnabled | +| isOutgoingEnabled | +| manufacturingCode | +| prefixForMask | -### Templating API: C formatting helpers~cleanseLabelAsKebabCase(label) + -returns a string after converting ':', ' ' and camel case into '-' +### Templating API: static zcl helpers~command\_mask\_sub\_helper(commandMask, str) ⇒ +A Sub helper api for command_mask to reduce code redundancy -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: command mask addition based on the arguments -| Param | Type | -| ----- | --------------- | -| label | \* | +| Param | +| --- | +| commandMask | +| str | - + -### Templating API: C formatting helpers~asSpacedLowercase(str) ⇒ +### Templating API: static zcl helpers~format\_zcl\_string\_as\_characters\_for\_generated\_defaults(stringVal, sizeOfString) ⇒ +This may be used within all_user_cluster_attributes_for_generated_defaults +for example: +{{format_zcl_string_as_characters_for_generated_defaults 'abc' 5}} +will return as follows: +3, 'a', 'b', 'c' 0, 0 -Given a camel case string convert it into one with space and lowercase +Available Options: +- isOctet: 0/1 can be used to return results correctly for octet strings +- isCommaTerminated: 0/1 can be used to return result with/without ',' at +the end -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: a spaced out string in lowercase +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Formatted string for generated defaults starting with the lenth of a +string then each character and then filler for the size allocated for the +string. Long strings prefixed by 2 byte length field. -| Param | Type | -| ----- | --------------- | -| str | \* | +| Param | +| --- | +| stringVal | +| sizeOfString | - + -### Templating API: C formatting helpers~asUnderscoreUppercase(str) ⇒ +### Templating API: static zcl helpers~as\_type\_min\_value(type, options) ⇒ +Given a zcl data type return the min allowed value for that zcl data type +based on the language specified in the options -Given a camel case string convert it into one with underscore and uppercase +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: max allowed value for the given zcl data type +Available Options: +- language: determines the output of the helper based on language +for eg: (as_type_min_value language='c++') will give the output specific to +the c++ language. +Note: If language is not specified then helper throws an error. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: String in uppercase with underscores +| Param | Type | +| --- | --- | +| type | \* | +| options | \* | -| Param | Type | -| ----- | --------------- | -| str | \* | + - +### Templating API: static zcl helpers~as\_type\_max\_value(type, options) ⇒ +Given a zcl data type return the max allowed value for that zcl data type +based on the language specified in the options -### Templating API: C formatting helpers~asCliType(size, isSigned) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: max allowed value for the given zcl data type +Available Options: +- language: determines the output of the helper based on language +for eg: (as_type_max_value language='c++') will give the output specific to +the c++ language. +Note: If language is not specified then the helper returns size of type in +bits. -Returns the cli type representation. +| Param | Type | +| --- | --- | +| type | \* | +| options | \* | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: the type representation required for CLI. + -| Param | -| -------- | -| size | -| isSigned | +### Templating API: static zcl helpers~structs\_with\_clusters(options) +Returns all structs which have clusters associated with them - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) -### Templating API: C formatting helpers~as_zcl_cli_type(str, optional, isSigned) +| Param | Type | Description | +| --- | --- | --- | +| options | \* | Available Options: - groupByStructName: Can group the query results based on struct name for structs which are present in more than one cluster eg Usage: {{#structs_with_clusters groupByStructName=1}}{{/structs_with_clusters}} | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) + -| Param | Description | -| -------- | ------------------------------- | -| str | | -| optional | | -| isSigned | Return the data type of zcl cli | +### Templating API: static zcl helpers~as\_zcl\_type\_size(type, options) ⇒ +Returns the size of the zcl type if possible else returns -1 - +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: size of zcl type -### Templating API: C formatting helpers~dataTypeForBitmap(db, bitmap_name, packageIds) +| Param | Type | +| --- | --- | +| type | \* | +| options | \* | -Returns the type of bitmap based on the bitmap's name + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +### Templating API: static zcl helpers~if\_compare(leftValue, rightValue, options) ⇒ Object +An if helper for comparisons -| Param | Type | -| ----------- | --------------- | -| db | \* | -| bitmap_name | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Object - Promise of content +example: checking if (4 < 5) +(if_compare 4 5 operator='<') +Content when comparison returns true - +Content when comparison returns false +(/if_compare) -### Templating API: C formatting helpers~dataTypeForEnum(db, enum_name, packageIds) +| Param | Type | +| --- | --- | +| leftValue | \* | +| rightValue | \* | +| options | \* | -Returns the type of enum + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +### Templating API: static zcl helpers~if\_is\_data\_type\_signed(type, clusterId, options) ⇒ +Check if the given type is signed or not based on the type name and cluster +id. +Note: This helper needs to be used under a block helper which has a +reference to clusterId. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| enum_name | \* | -| packageIds | \* | +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content - +| Param | Type | +| --- | --- | +| type | \* | +| clusterId | \* | +| options | \* | -### Templating API: C formatting helpers~addOne(number) + -Returns the number by adding 1 to it. +### Templating API: static zcl helpers~as\_zcl\_data\_type\_size(type, clusterId, options) ⇒ +Fetches the size of the data type based on type name and cluster id given +Note: +- Size is zero for structs +- This helper needs to be used under a block helper which has a +reference to clusterId. +Available Options: +- roundUpToPowerOfTwo: Rounds the size up to the nearest power of 2 +- sizeIn: By default size is returned in bytes but it can be returned in bits +by mentioning sizeIn="bits" -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: size of the data type -| Param | Type | -| ------ | --------------- | -| number | \* | +| Param | Type | +| --- | --- | +| type | \* | +| clusterId | \* | +| options | \* | - + -### Templating API: C formatting helpers~is_number_greater_than(num1, num2) ⇒ +## Templating API: Zigbee Specific helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} -Return true if number1 is greater than number2 -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: true if num1 is greater than num2 else returns false +* [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) + * [~get_cli_size(size, type, allowZclTypes)](#module_Templating API_ Zigbee Specific helpers..get_cli_size) ⇒ + * [~zcl_command_argument_type_to_cli_data_type_util(type, cliPrefix, context, options)](#module_Templating API_ Zigbee Specific helpers..zcl_command_argument_type_to_cli_data_type_util) ⇒ + * [~zcl_command_argument_type_to_cli_data_type(typeName, options)](#module_Templating API_ Zigbee Specific helpers..zcl_command_argument_type_to_cli_data_type) + * [~zcl_command_argument_type_to_zcl_cli_data_type(typeName, options)](#module_Templating API_ Zigbee Specific helpers..zcl_command_argument_type_to_zcl_cli_data_type) -| Param | -| ----- | -| num1 | -| num2 | + - +### Templating API: Zigbee Specific helpers~get\_cli\_size(size, type, allowZclTypes) ⇒ +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) +**Returns**: The size in bits for a cli type based on allowZclTypes -### Templating API: C formatting helpers~cluster_extension(options) ⇒ +| Param | Type | +| --- | --- | +| size | \* | +| type | \* | +| allowZclTypes | \* | -When inside a context that contains 'code', this -helper will output the value of the cluster extension -specified by property="propName" attribute. + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the cluster extension property. +### Templating API: Zigbee Specific helpers~zcl\_command\_argument\_type\_to\_cli\_data\_type\_util(type, cliPrefix, context, options) ⇒ +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) +**Returns**: the zcl cli data type string with the cli prefix given +Additional Options: +- isOptional option can be passed along with the command argument +to return optional command argument extension accordingly +eg: +#zcl_command_arguments + zcl_command_argument_type_to_zcl_cli_data_type type isOptional=isOptional +/zcl_command_arguments -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| type | \* | +| cliPrefix | \* | +| context | \* | +| options | \* | - + -### Templating API: C formatting helpers~device_type_extension(options) ⇒ +### Templating API: Zigbee Specific helpers~zcl\_command\_argument\_type\_to\_cli\_data\_type(typeName, options) +Helper that deals with the type of the argument. -When inside a context that contains 'code', this -helper will output the value of the cluster extension -specified by property="propName" attribute. +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the cluster extension property. +| Param | Type | +| --- | --- | +| typeName | \* | +| options | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### Templating API: Zigbee Specific helpers~zcl\_command\_argument\_type\_to\_zcl\_cli\_data\_type(typeName, options) +Helper that deals with the type of the argument. -### Templating API: C formatting helpers~attribute_type_extension(options) ⇒ +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) -When inside a context that contains 'type', this -helper will output the value of the attribute type extension -specified by property="propName" attribute. +| Param | Type | +| --- | --- | +| typeName | \* | +| options | \* | -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the attribute type extension property. + -| Param | Type | -| ------- | --------------- | -| options | \* | +## Templating API: Overridable functions. +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} - + -### Templating API: C formatting helpers~attribute_extension(options) ⇒ +## JS API: generator logic -When inside a context that contains 'code' and parent 'code', this -helper will output the value of the attribute extension -specified by property="propName" attribute. +* [JS API: generator logic](#module_JS API_ generator logic) + * [~loadGenTemplateFromFile(path)](#module_JS API_ generator logic..loadGenTemplateFromFile) ⇒ + * [~recordPackageIfNonexistent(db, packagePath, parentId, packageType, version, category, description)](#module_JS API_ generator logic..recordPackageIfNonexistent) ⇒ + * [~loadTemplateOptionsFromJsonFile(db, packageId, category, externalPath)](#module_JS API_ generator logic..loadTemplateOptionsFromJsonFile) ⇒ + * [~recordTemplatesPackage(context)](#module_JS API_ generator logic..recordTemplatesPackage) ⇒ + * [~decodePackageExtensionEntity(entityType, entity)](#module_JS API_ generator logic..decodePackageExtensionEntity) ⇒ + * [~loadZclExtensions(zclExt)](#module_JS API_ generator logic..loadZclExtensions) ⇒ + * [~loadTemplates(db, genTemplatesJsonArray)](#module_JS API_ generator logic..loadTemplates) + * [~loadGenTemplatesJsonFile(db, genTemplatesJson)](#module_JS API_ generator logic..loadGenTemplatesJsonFile) ⇒ + * [~retrievePackageMetaInfo(db, genTemplatesPkgId)](#module_JS API_ generator logic..retrievePackageMetaInfo) ⇒ + * [~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly)](#module_JS API_ generator logic..generateAllTemplates) ⇒ + * [~generateSingleTemplate(genResult, singleTemplatePkg)](#module_JS API_ generator logic..generateSingleTemplate) ⇒ + * [~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options)](#module_JS API_ generator logic..generate) ⇒ + * [~writeFileWithBackup(fileName, content, doBackup)](#module_JS API_ generator logic..writeFileWithBackup) ⇒ + * [~generateGenerationContent(genResult)](#module_JS API_ generator logic..generateGenerationContent) + * [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#module_JS API_ generator logic..generateAndWriteFiles) ⇒ + * [~createGenerationLog(logFile, genData)](#module_JS API_ generator logic..createGenerationLog) + * [~postProcessGeneratedFiles(outputDirectory, genResult)](#module_JS API_ generator logic..postProcessGeneratedFiles) ⇒ + * [~contentIndexer(content)](#module_JS API_ generator logic..contentIndexer) + * [~generateSingleFileForPreview(db, sessionId, fileName)](#module_JS API_ generator logic..generateSingleFileForPreview) ⇒ + * [~produceCompiledTemplate(singleTemplatePkg)](#module_JS API_ generator logic..produceCompiledTemplate) ⇒ + * [~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options)](#module_JS API_ generator logic..produceIterativeContent) ⇒ + * [~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:)](#module_JS API_ generator logic..produceContent) ⇒ + * [~wrapOverridable(originalFn, overrideFn)](#module_JS API_ generator logic..wrapOverridable) ⇒ + * [~loadOverridable(path)](#module_JS API_ generator logic..loadOverridable) + * [~loadPartial(path)](#module_JS API_ generator logic..loadPartial) + * [~helperWrapper(wrappedHelper)](#module_JS API_ generator logic..helperWrapper) ⇒ + * [~loadHelper(helpers)](#module_JS API_ generator logic..loadHelper) + * [~allBuiltInHelpers()](#module_JS API_ generator logic..allBuiltInHelpers) ⇒ + * [~findHelperPackageByAlias(alias)](#module_JS API_ generator logic..findHelperPackageByAlias) ⇒ + * [~initializeBuiltInHelpersForPackage()](#module_JS API_ generator logic..initializeBuiltInHelpersForPackage) + * [~hbInstance()](#module_JS API_ generator logic..hbInstance) ⇒ + * [~makeSynchronizablePromise(promise)](#module_JS API_ generator logic..makeSynchronizablePromise) + * [~collectBlocks(resultArray, options, context)](#module_JS API_ generator logic..collectBlocks) ⇒ + * [~ensureZclPackageId(context)](#module_JS API_ generator logic..ensureZclPackageId) ⇒ + * [~ensureZclPackageIds(context)](#module_JS API_ generator logic..ensureZclPackageIds) ⇒ + * [~ensureTemplatePackageCategory(context)](#module_JS API_ generator logic..ensureTemplatePackageCategory) ⇒ + * [~ensureTemplatePackageId(context)](#module_JS API_ generator logic..ensureTemplatePackageId) ⇒ + * [~ensureEndpointTypeIds(context)](#module_JS API_ generator logic..ensureEndpointTypeIds) ⇒ + * [~ensureZclClusterSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclClusterSdkExtensions) ⇒ + * [~ensureZclDeviceTypeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclDeviceTypeSdkExtensions) ⇒ + * [~ensureZclAttributeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclAttributeSdkExtensions) ⇒ + * [~ensureZclAttributeTypeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclAttributeTypeSdkExtensions) ⇒ + * [~ensureZclCommandSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclCommandSdkExtensions) ⇒ + * [~ensureZclEventSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclEventSdkExtensions) ⇒ + * [~templatePromise(global, promise)](#module_JS API_ generator logic..templatePromise) + * [~deprecatedHelper(fn, explanation)](#module_JS API_ generator logic..deprecatedHelper) ⇒ -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the attribute extension property. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~loadGenTemplateFromFile(path) ⇒ +Given a path, it will read generation template object into memory. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Object that contains: data, crc, templateData -### Templating API: C formatting helpers~command_extension(options) ⇒ +| Param | Type | +| --- | --- | +| path | \* | -When inside a context that contains 'code' and parent 'code', this -helper will output the value of the command extension -specified by property="propName" attribute. + -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the command extension property. +### JS API: generator logic~recordPackageIfNonexistent(db, packagePath, parentId, packageType, version, category, description) ⇒ +Inserts the package details when they do not exist. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of package insertion - +| Param | Type | +| --- | --- | +| db | \* | +| packagePath | \* | +| parentId | \* | +| packageType | \* | +| version | \* | +| category | \* | +| description | \* | -### Templating API: C formatting helpers~event_extension(options) ⇒ + -When inside a context that contains 'code' and parent 'code', this -helper will output the value of the command extension -specified by property="propName" attribute. +### JS API: generator logic~loadTemplateOptionsFromJsonFile(db, packageId, category, externalPath) ⇒ +Insert the template options from the json meta data file. -**Kind**: inner method of [Templating API: C formatting helpers](#module*Templating API* C formatting helpers) -**Returns**: Value of the command extension property. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of inserted template options -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| category | \* | +| externalPath | \* | - + -## Templating API: user-data specific helpers +### JS API: generator logic~recordTemplatesPackage(context) ⇒ +Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context. -This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the same context passed in, except packageId added to it -- [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) - - [~user_endpoints(options)](#module*Templating API* user-data specific helpers..user_endpoints) - - [~user_device_types(options)](#module*Templating API* user-data specific helpers..user_device_types) - - [~user_endpoint_types(options)](#module*Templating API* user-data specific helpers..user_endpoint_types) - - [~user_clusters(options)](#module*Templating API* user-data specific helpers..user_clusters) - - [~user_cluster_attributes(options)](#module*Templating API* user-data specific helpers..user_cluster_attributes) ⇒ - - [~user_cluster_commands(options)](#module*Templating API* user-data specific helpers..user_cluster_commands) ⇒ - - [~user_cluster_events(options)](#module*Templating API* user-data specific helpers..user_cluster_events) ⇒ - - [~user_endpoint_count_by_cluster(clusterTypeId)](#module*Templating API* user-data specific helpers..user_endpoint_count_by_cluster) ⇒ - - [~user_all_attributes(options)](#module*Templating API* user-data specific helpers..user_all_attributes) ⇒ - - [~all_user_cluster_commands(options)](#module*Templating API* user-data specific helpers..all_user_cluster_commands) ⇒ - - [~all_user_cluster_command_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification)](#module*Templating API* user-data specific helpers..all_user_cluster_command_util) - - [~all_user_cluster_manufacturer_specific_commands(options)](#module*Templating API* user-data specific helpers..all_user_cluster_manufacturer_specific_commands) ⇒ - - [~all_user_cluster_non_manufacturer_specific_commands(options)](#module*Templating API* user-data specific helpers..all_user_cluster_non_manufacturer_specific_commands) ⇒ - - [~all_user_cluster_manufacturer_specific_attributes(options)](#module*Templating API* user-data specific helpers..all_user_cluster_manufacturer_specific_attributes) ⇒ - - [~all_user_cluster_non_manufacturer_specific_attributes(options)](#module*Templating API* user-data specific helpers..all_user_cluster_non_manufacturer_specific_attributes) ⇒ - - [~all_commands_for_user_enabled_clusters(options)](#module*Templating API* user-data specific helpers..all_commands_for_user_enabled_clusters) ⇒ - - [~all_cli_commands_for_user_enabled_clusters(options)](#module*Templating API* user-data specific helpers..all_cli_commands_for_user_enabled_clusters) ⇒ - - [~all_user_clusters(options)](#module*Templating API* user-data specific helpers..all_user_clusters) ⇒ - - [~all_user_clusters_irrespective_of_side(options)](#module*Templating API* user-data specific helpers..all_user_clusters_irrespective_of_side) ⇒ - - [~all_user_clusters_names(options)](#module*Templating API* user-data specific helpers..all_user_clusters_names) ⇒ - - [~user_cluster_command_count_with_cli()](#module*Templating API* user-data specific helpers..user_cluster_command_count_with_cli) - - [~user_cluster_commands_with_cli()](#module*Templating API* user-data specific helpers..user_cluster_commands_with_cli) - - [~user_cluster_commands_all_endpoints(options)](#module*Templating API* user-data specific helpers..user_cluster_commands_all_endpoints) - - [~user_cluster_has_enabled_command(name, side)](#module*Templating API* user-data specific helpers..user_cluster_has_enabled_command) ⇒ - - [~all_user_cluster_commands_irrespective_of_manufaturing_specification(options)](#module*Templating API* user-data specific helpers..all_user_cluster_commands_irrespective_of_manufaturing_specification) ⇒ - - [~enabled_attributes_for_cluster_and_side(name, side, options)](#module*Templating API* user-data specific helpers..enabled_attributes_for_cluster_and_side) ⇒ - - [~user_session_key(options)](#module*Templating API* user-data specific helpers..user_session_key) ⇒ - - [~if_command_discovery_enabled()](#module*Templating API* user-data specific helpers..if_command_discovery_enabled) - - [~is_command_default_response_enabled(command, options)](#module*Templating API* user-data specific helpers..is_command_default_response_enabled) ⇒ - - [~is_command_default_response_disabled(command, options)](#module*Templating API* user-data specific helpers..is_command_default_response_disabled) ⇒ - - [~all_user_cluster_attributes_for_generated_defaults(name, side, options)](#module*Templating API* user-data specific helpers..all_user_cluster_attributes_for_generated_defaults) ⇒ - - [~all_user_cluster_generated_attributes(options)](#module*Templating API* user-data specific helpers..all_user_cluster_generated_attributes) ⇒ - - [~all_user_reportable_attributes(options)](#module*Templating API* user-data specific helpers..all_user_reportable_attributes) ⇒ - - [~all_user_cluster_generated_commands(options)](#module*Templating API* user-data specific helpers..all_user_cluster_generated_commands) ⇒ - - [~all_user_clusters_with_incoming_or_outgoing_commands(options, is_incoming)](#module*Templating API* user-data specific helpers..all_user_clusters_with_incoming_or_outgoing_commands) ⇒ - - [~all_user_clusters_with_incoming_commands(options)](#module*Templating API* user-data specific helpers..all_user_clusters_with_incoming_commands) ⇒ - - [~all_user_clusters_with_outgoing_commands(options)](#module*Templating API* user-data specific helpers..all_user_clusters_with_outgoing_commands) ⇒ - - [~manufacturing_clusters_with_incoming_commands(clusterCode, options)](#module*Templating API* user-data specific helpers..manufacturing_clusters_with_incoming_commands) ⇒ - - [~all_user_clusters_with_incoming_commands_combined(options)](#module*Templating API* user-data specific helpers..all_user_clusters_with_incoming_commands_combined) ⇒ - - [~all_incoming_commands_for_cluster_combined(clusterName, clientSide, serverSide, options)](#module*Templating API* user-data specific helpers..all_incoming_commands_for_cluster_combined) ⇒ - - [~all_incoming_or_outgoing_commands_for_cluster(clusterName, clusterSide, isIncoming, options)](#module*Templating API* user-data specific helpers..all_incoming_or_outgoing_commands_for_cluster) ⇒ - - [~all_incoming_commands_for_cluster(clusterName, options)](#module*Templating API* user-data specific helpers..all_incoming_commands_for_cluster) ⇒ - - [~all_outgoing_commands_for_cluster(clusterName, options)](#module*Templating API* user-data specific helpers..all_outgoing_commands_for_cluster) ⇒ - - [~generated_clustes_details(options)](#module*Templating API* user-data specific helpers..generated_clustes_details) ⇒ - - [~generated_endpoint_type_details(options)](#module*Templating API* user-data specific helpers..generated_endpoint_type_details) ⇒ - - [~all_user_cluster_attributes_min_max_defaults(name, side, options)](#module*Templating API* user-data specific helpers..all_user_cluster_attributes_min_max_defaults) ⇒ - - [~checkAttributeMatch(clusterName, attributeName, attributeSide, attributeValue, attributeValueType, endpointAttributes)](#module*Templating API* user-data specific helpers..checkAttributeMatch) ⇒ - - [~generated_defaults_index(clusterName, attributeName, attributeValueType, attributeValue, prefixReturn, postFixReturn)](#module*Templating API* user-data specific helpers..generated_defaults_index) ⇒ - - [~generated_default_index(clusterName, attributeName, attributeSide, attributeValueType, attributeValue, prefixReturn, postFixReturn)](#module*Templating API* user-data specific helpers..generated_default_index) ⇒ - - [~generated_attributes_min_max_index(name, side, options)](#module*Templating API* user-data specific helpers..generated_attributes_min_max_index) ⇒ - - [~generated_attribute_min_max_index(clusterName, attributeName, attributeSide, options)](#module*Templating API* user-data specific helpers..generated_attribute_min_max_index) ⇒ - - [~if_enabled_clusters(options)](#module*Templating API* user-data specific helpers..if_enabled_clusters) ⇒ - - [~if_multi_protocol_attributes_enabled(options)](#module*Templating API* user-data specific helpers..if_multi_protocol_attributes_enabled) ⇒ - - [~all_multi_protocol_attributes(options)](#module*Templating API* user-data specific helpers..all_multi_protocol_attributes) ⇒ +| Param | Type | +| --- | --- | +| context | \* | - + -### Templating API: user-data specific helpers~user_endpoints(options) +### JS API: generator logic~decodePackageExtensionEntity(entityType, entity) ⇒ +This method takes extension data in JSON, and converts it into +an object that contains: + entityCode, entityQualifier, parentCode, manufacturerCode and value -Creates block iterator over the endpoints. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: object that can be used for database injection -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) +| Param | Type | +| --- | --- | +| entityType | \* | +| entity | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### JS API: generator logic~loadZclExtensions(zclExt) ⇒ +Returns a promise that will load the zcl extensions. -### Templating API: user-data specific helpers~user_device_types(options) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of loading the zcl extensions. -Creates device type iterator over an endpoint type id. -This works inside user_endpoints or user_endpoint_types. +| Param | Type | +| --- | --- | +| zclExt | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~loadTemplates(db, genTemplatesJsonArray) +Api that loads an array of template JSON files or a single file if +you just pass in one String. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -### Templating API: user-data specific helpers~user_endpoint_types(options) +| Param | Type | +| --- | --- | +| db | \* | +| genTemplatesJsonArray | \* | -Creates block iterator helper over the endpoint types. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) +### JS API: generator logic~loadGenTemplatesJsonFile(db, genTemplatesJson) ⇒ +Main API async function to load templates from a gen-template.json file. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: the loading context, contains: db, path, crc, packageId and templateData, or error - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Database | +| genTemplatesJson | \* | Path to the JSON file or an array of paths to JSON file | -### Templating API: user-data specific helpers~user_clusters(options) + -Creates cluster iterator over the endpoint types. -This works ony inside user_endpoint_types. +### JS API: generator logic~retrievePackageMetaInfo(db, genTemplatesPkgId) ⇒ +Get the package information from the given package ID. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: package information -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| genTemplatesPkgId | \* | - + -### Templating API: user-data specific helpers~user_cluster_attributes(options) ⇒ +### JS API: generator logic~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly) ⇒ +Generates all the templates inside a toplevel package. -Creates endpoint type cluster attribute iterator. This works only -inside user_clusters. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output' -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster attributes. +| Param | Type | Description | +| --- | --- | --- | +| genResult | \* | | +| genTemplateJsonPkg | \* | Package that points to genTemplate.json file | +| generateOnly | \* | if NULL then generate all templates, else only generate template whose out file name matches this. | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### JS API: generator logic~generateSingleTemplate(genResult, singleTemplatePkg) ⇒ +Function that generates a single package and adds it to the generation result. -### Templating API: user-data specific helpers~user_cluster_commands(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the genResult, with newly generated content added. -Creates endpoint type cluster command iterator. This works only inside -user_clusters. +| Param | Type | Description | +| --- | --- | --- | +| genResult | \* | | +| singleTemplatePkg | \* | Single template package. | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster commands. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options) ⇒ +Main API async function to generate stuff. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into a generation result.Promise that resolves into a generation result. -### Templating API: user-data specific helpers~user_cluster_events(options) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Database | +| sessionId | \* | | +| templatePackageId | \* | packageId Template package id. It can be either single template or gen template json. | +| templateGeneratorOptions | \* | | +| options | \* | | -Creates endpoint type cluster event iterator. This works only inside -user_clusters. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster events. +### JS API: generator logic~writeFileWithBackup(fileName, content, doBackup) ⇒ +Promise to write out a file, optionally creating a backup. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise of a written file. - +| Param | Type | +| --- | --- | +| fileName | \* | +| content | \* | +| doBackup | \* | -### Templating API: user-data specific helpers~user_endpoint_count_by_cluster(clusterTypeId) ⇒ + -Retrieve the number of endpoints which possess the specified -cluster type +### JS API: generator logic~generateGenerationContent(genResult) +Returns a promise that resolves into a content that should be written out to gen result file. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the number of endpoint +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -| Param | Type | -| ------------- | --------------- | -| clusterTypeId | \* | +| Param | Type | +| --- | --- | +| genResult | \* | - + -### Templating API: user-data specific helpers~user_all_attributes(options) ⇒ +### JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒ +Generate files and write them into the given directory. -Iterates over all attributes required by the user configuration. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: a promise which will resolve when all the files are written. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster commands. +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| packageId | \* | +| outputDirectory | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### JS API: generator logic~createGenerationLog(logFile, genData) +Create a generation log. -### Templating API: user-data specific helpers~all_user_cluster_commands(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -Creates endpoint type cluster command iterator. This fetches all -commands which have been enabled on added endpoints +| Param | Type | +| --- | --- | +| logFile | \* | +| genData | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster commands. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~postProcessGeneratedFiles(outputDirectory, genResult) ⇒ +Executes post processing actions as defined by the gen-templates.json - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise of a dealt-with post processing actions -### Templating API: user-data specific helpers~all_user_cluster_command_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification) +| Param | Type | +| --- | --- | +| outputDirectory | \* | +| genResult | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) + -| Param | Default | Description | -| ------------------------------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | -| name | | | -| side | | | -| options | | | -| currentContext | | | -| isManufacturingSpecific | | | -| isIrrespectiveOfManufacturingSpecification | false | Returns: Promise of the resolved blocks iterating over manufacturing specific, non-manufacturing specific or both of the cluster commands. | +### JS API: generator logic~contentIndexer(content) +This async function takes a string, and resolves a preview object out of it. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -### Templating API: user-data specific helpers~all_user_cluster_manufacturer_specific_commands(options) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| content | \* | String to form into preview. | -Creates endpoint type cluster command iterator. This fetches all -manufacturing specific commands which have been enabled on added endpoints + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over manufacturing specific -cluster commands. +### JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒ +Generates a single file and feeds it back for preview. -| Param | -| ------- | -| options | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves into a preview object. - +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| fileName | \* | -### Templating API: user-data specific helpers~all_user_cluster_non_manufacturer_specific_commands(options) ⇒ + -Creates endpoint type cluster command iterator. This fetches all -non-manufacturing specific commands which have been enabled on added endpoints +### JS API: generator logic~produceCompiledTemplate(singleTemplatePkg) ⇒ +Resolves into a precompiled template, either from previous precompile or freshly compiled. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over non-manufacturing specific -cluster commands. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: templates -| Param | -| ------- | -| options | +| Param | Type | +| --- | --- | +| singleTemplatePkg | \* | - + -### Templating API: user-data specific helpers~all_user_cluster_manufacturer_specific_attributes(options) ⇒ +### JS API: generator logic~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options) ⇒ +This function is reached if the template is an "iterative one", meaning +it has the iterator set to one of the valid options. -Creates endpoint type cluster command iterator. This fetches all -manufacturing specific commands which have been enabled on added endpoints +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into an array of key/content/stats objects. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over manufacturing specific -cluster commands. +| Param | Type | +| --- | --- | +| hb | \* | +| metaInfo | \* | +| db | \* | +| sessionId | \* | +| singleTemplatePkg | \* | +| genTemplateJsonPackage | \* | +| options | \* | -| Param | -| ------- | -| options | + - +### JS API: generator logic~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:) ⇒ +Given db connection, session and a single template package, produce the output. -### Templating API: user-data specific helpers~all_user_cluster_non_manufacturer_specific_attributes(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into an array of key/content/stats objects. -Creates endpoint type cluster command iterator. This fetches all -non-manufacturing specific commands which have been enabled on added endpoints +| Param | Type | Description | +| --- | --- | --- | +| hb | \* | | +| metaInfo | \* | | +| db | \* | | +| sessionId | \* | | +| singlePkg | \* | | +| overridePath: | \* | if passed, it provides a path to the override file that can override the overridable.js | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over non-manufacturing specific -cluster commands. + -| Param | -| ------- | -| options | +### JS API: generator logic~wrapOverridable(originalFn, overrideFn) ⇒ +This function attemps to call override function, but if override function +throws an exception, it calls the original function. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: result from override function, unless it throws an exception, in which case return result from original function. -### Templating API: user-data specific helpers~all_commands_for_user_enabled_clusters(options) ⇒ +| Param | Type | +| --- | --- | +| originalFn | \* | +| overrideFn | \* | -Creates endpoint type cluster command iterator. This fetches all -commands which have been enabled on added endpoints + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster commands. +### JS API: generator logic~loadOverridable(path) +This function is responsible to load the overridable function container. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) - +| Param | Type | Description | +| --- | --- | --- | +| path | \* | of the override file | -### Templating API: user-data specific helpers~all_cli_commands_for_user_enabled_clusters(options) ⇒ + -This helper returns all commands which have cli within the list of enabled -clusters. +### JS API: generator logic~loadPartial(path) +Function that loads the partials. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: all commands with cli from the list of enabled clusters +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -| Param | -| ------- | -| options | +| Param | Type | +| --- | --- | +| path | \* | - + -### Templating API: user-data specific helpers~all_user_clusters(options) ⇒ +### JS API: generator logic~helperWrapper(wrappedHelper) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: function -Creates cluster iterator for all endpoints. +| Param | Type | +| --- | --- | +| wrappedHelper | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster commands. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~loadHelper(helpers) +Function that loads the helpers. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -### Templating API: user-data specific helpers~all_user_clusters_irrespective_of_side(options) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| helpers | \* | a string path if value is passed through CLI, the nativeRequire() is leverage the native js function instead of webpack's special sauce. a required() module if invoked by backend js code. this is required to force webpack to resolve the included files as path will be difference after being packed for production. | -Creates cluster command iterator for all endpoints. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster commands. +### JS API: generator logic~allBuiltInHelpers() ⇒ +Returns an object that contains all the helper functions, keyed +by their name -| Param | Type | -| ------- | --------------- | -| options | \* | +NOTE: This method is ONLY used for API testing. You should not use +this method for any real work inside the engine or something. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Object containing all the helper functions. + -### Templating API: user-data specific helpers~all_user_clusters_names(options) ⇒ +### JS API: generator logic~findHelperPackageByAlias(alias) ⇒ +Given an alias, this method finds a builtin helper package +by its alias. -Creates cluster command iterator for all endpoints whitout any duplicates -cause by cluster side +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Helper package or undefined if none was found. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over cluster commands. +| Param | Type | +| --- | --- | +| alias | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### JS API: generator logic~initializeBuiltInHelpersForPackage() +Global helper initialization -### Templating API: user-data specific helpers~user_cluster_command_count_with_cli() +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) + -Get the count of the number of clusters commands with cli for a cluster. -This is used under a cluster block helper +### JS API: generator logic~hbInstance() ⇒ +This method returns the correct instance for a given generation flow. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) - +TBD: At this point it doesn't do anything yet, it's just +a central point to get the correct instance. -### Templating API: user-data specific helpers~user_cluster_commands_with_cli() +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Instance of handlebars to be used. + -This helper works within the the cluster block helpers. It is used to get -all commands of the cluster which have cli associated with them. +### JS API: generator logic~makeSynchronizablePromise(promise) +All promises used by the templates should be synchronizable. -param options -Returns: all commands with cli for a cluster +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -Example: -{{#all_user_clusters_irrespective_of_side}} -{{#user_cluster_commands_with_cli}} -{{/user_cluster_commands_with_cli}} -{{/all_user_clusters_irrespective_of_side}} +| Param | Type | +| --- | --- | +| promise | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) - + -### Templating API: user-data specific helpers~user_cluster_commands_all_endpoints(options) +### JS API: generator logic~collectBlocks(resultArray, options, context) ⇒ +Helpful function that collects the individual blocks by using elements of an array as a context, +executing promises for each, and collecting them into the outgoing string. -Creates endpoint type cluster command iterator. This works only inside -cluster block helpers. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves with a content string. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) +| Param | Type | Description | +| --- | --- | --- | +| resultArray | \* | | +| options | \* | Options passed from a block helper. | +| context | \* | The context from within this was called. | -| Param | Description | -| ------- | ------------------------------------------------------------------------ | -| options | Returns: Promise of the resolved blocks iterating over cluster commands. | + - +### JS API: generator logic~ensureZclPackageId(context) ⇒ +Returns the promise that resolves with the ZCL properties package id. -### Templating API: user-data specific helpers~user_cluster_has_enabled_command(name, side) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the package id. -Check if the cluster (name) has any enabled commands. This works only inside -cluster block helpers. +| Param | Type | +| --- | --- | +| context | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: True if cluster has enabled commands otherwise false + -| Param | Type | Description | -| ----- | --------------- | -------------- | -| name | \* | : Cluster name | -| side | \* | : Cluster side | +### JS API: generator logic~ensureZclPackageIds(context) ⇒ +Returns the promise that resolves with all ZCL package id specific to current session. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with a list of package id. -### Templating API: user-data specific helpers~all_user_cluster_commands_irrespective_of_manufaturing_specification(options) ⇒ +| Param | Type | +| --- | --- | +| context | \* | -Creates endpoint type cluster command iterator. This fetches all -manufacturing and non-manufaturing specific commands which have been enabled -on added endpoints + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over manufacturing specific -and non-manufacturing specific cluster commands. +### JS API: generator logic~ensureTemplatePackageCategory(context) ⇒ +Returns a package category of the toplevel template package from context. -| Param | -| ------- | -| options | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: proimise that resolves into a package category - +| Param | Type | +| --- | --- | +| context | \* | -### Templating API: user-data specific helpers~enabled_attributes_for_cluster_and_side(name, side, options) ⇒ + -Creates endpoint type cluster attribute iterator. This fetches all -manufacturer-specific and standard attributes which have been enabled on -added endpoints based on the name and side of the cluster. When side -is not mentioned then client and server attributes are returned. -Available Options: +### JS API: generator logic~ensureTemplatePackageId(context) ⇒ +Returns the promise that resolves with the ZCL properties package id. -- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js) - for eg:(#enabled_attributes_for_cluster_and_side - [cluster-name], [cluster-side], removeKeys='isOptional, isNullable') - will remove 'isOptional' and 'isNullable' from the results +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the package id. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of the resolved blocks iterating over manufacturing specific -and standard cluster attributes. +| Param | Type | +| --- | --- | +| context | \* | -| Param | -| ------- | -| name | -| side | -| options | + - +### JS API: generator logic~ensureEndpointTypeIds(context) ⇒ +Populate the endpoint type ids into the global context. -### Templating API: user-data specific helpers~user_session_key(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: endpoint type ids -Helper that resolves into a user session key value. +| Param | Type | +| --- | --- | +| context | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of value of the session key or undefined. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~ensureZclClusterSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached cluster extensions, but if they don't +exist, it will populate them. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with cluster extensions. -### Templating API: user-data specific helpers~if_command_discovery_enabled() +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -If helper that checks if command discovery is enabled + -example: -{{#if_command_discovery_enabled}} -command discovery is enabled -{{else}} -command discovery is not enabled -{{/if_command_discovery_enabled}} +### JS API: generator logic~ensureZclDeviceTypeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached cluster extensions, but if they don't +exist, it will populate them. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with cluster extensions. -### Templating API: user-data specific helpers~is_command_default_response_enabled(command, options) ⇒ +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -An if helper to check if default response for a command is enabled or not. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: true if the the default response policy is either always or -when the policy is not never and the command has the disable default -response policy set to false(not true) +### JS API: generator logic~ensureZclAttributeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached attribute extensions, but if they don't +exist, it will populate them. -| Param | Type | -| ------- | --------------- | -| command | \* | -| options | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with attribute extensions. - +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -### Templating API: user-data specific helpers~is_command_default_response_disabled(command, options) ⇒ + -An if helper to check if default response for a command is disabled or not. +### JS API: generator logic~ensureZclAttributeTypeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached attribute type extensions, but if they don't +exist, it will populate them. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: true if the the default response policy is either never or -when the policy is not always and the command has the disable default -response policy set to true(for eg disableDefaultResponse="true" in xml). +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with attribute type extensions. -| Param | Type | -| ------- | --------------- | -| command | \* | -| options | \* | +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | - + -### Templating API: user-data specific helpers~all_user_cluster_attributes_for_generated_defaults(name, side, options) ⇒ +### JS API: generator logic~ensureZclCommandSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached command extensions, but if they don't +exist, it will populate them. -Default values for the attributes longer than a pointer. -All attribute values with size greater than 2 bytes. -Excluding 0 values and externally saved values +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with command extensions. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Attribute values greater than 2 bytes and not 0 nor externally saved. +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -| Param | -| ------- | -| name | -| side | -| options | + - +### JS API: generator logic~ensureZclEventSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached command extensions, but if they don't +exist, it will populate them. -### Templating API: user-data specific helpers~all_user_cluster_generated_attributes(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with command extensions. -Entails the list of all attributes which have been enabled. Given the -cluster is enabled as well. The helper retrieves the attributes across -all endpoints. +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: enabled attributes + -| Param | -| ------- | -| options | +### JS API: generator logic~templatePromise(global, promise) +Every helper that returns a promise, should +not return the promise directly. So instead of +returning the promise directly, it should return: + return templatePromise(this.global, promise) - +This will ensure that after tag works as expected. -### Templating API: user-data specific helpers~all_user_reportable_attributes(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -Entails the list of reportable attributes which have been enabled. Given the -cluster is enabled as well. The helper retrieves the reportable attributes -per endpoint per cluster. +| Param | Type | +| --- | --- | +| global | \* | +| promise | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Reportable attributes + -| Param | -| ------- | -| options | +### JS API: generator logic~deprecatedHelper(fn, explanation) ⇒ +Function wrapper that can be used when a helper is deprecated. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: a function that wraps the original function, with deprecation message. -### Templating API: user-data specific helpers~all_user_cluster_generated_commands(options) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| fn | \* | | +| explanation | \* | can contain `text`, or `from`/`to`, or just be a string message itself. | -All available cluster commands across all endpoints and clusters. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: All available cluster commands across all endpoints and clusters +## JS API: template iterators. + -| Param | -| ------- | -| options | +## JS API: generator logic - +* [JS API: generator logic](#module_JS API_ generator logic) + * [~loadGenTemplateFromFile(path)](#module_JS API_ generator logic..loadGenTemplateFromFile) ⇒ + * [~recordPackageIfNonexistent(db, packagePath, parentId, packageType, version, category, description)](#module_JS API_ generator logic..recordPackageIfNonexistent) ⇒ + * [~loadTemplateOptionsFromJsonFile(db, packageId, category, externalPath)](#module_JS API_ generator logic..loadTemplateOptionsFromJsonFile) ⇒ + * [~recordTemplatesPackage(context)](#module_JS API_ generator logic..recordTemplatesPackage) ⇒ + * [~decodePackageExtensionEntity(entityType, entity)](#module_JS API_ generator logic..decodePackageExtensionEntity) ⇒ + * [~loadZclExtensions(zclExt)](#module_JS API_ generator logic..loadZclExtensions) ⇒ + * [~loadTemplates(db, genTemplatesJsonArray)](#module_JS API_ generator logic..loadTemplates) + * [~loadGenTemplatesJsonFile(db, genTemplatesJson)](#module_JS API_ generator logic..loadGenTemplatesJsonFile) ⇒ + * [~retrievePackageMetaInfo(db, genTemplatesPkgId)](#module_JS API_ generator logic..retrievePackageMetaInfo) ⇒ + * [~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly)](#module_JS API_ generator logic..generateAllTemplates) ⇒ + * [~generateSingleTemplate(genResult, singleTemplatePkg)](#module_JS API_ generator logic..generateSingleTemplate) ⇒ + * [~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options)](#module_JS API_ generator logic..generate) ⇒ + * [~writeFileWithBackup(fileName, content, doBackup)](#module_JS API_ generator logic..writeFileWithBackup) ⇒ + * [~generateGenerationContent(genResult)](#module_JS API_ generator logic..generateGenerationContent) + * [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#module_JS API_ generator logic..generateAndWriteFiles) ⇒ + * [~createGenerationLog(logFile, genData)](#module_JS API_ generator logic..createGenerationLog) + * [~postProcessGeneratedFiles(outputDirectory, genResult)](#module_JS API_ generator logic..postProcessGeneratedFiles) ⇒ + * [~contentIndexer(content)](#module_JS API_ generator logic..contentIndexer) + * [~generateSingleFileForPreview(db, sessionId, fileName)](#module_JS API_ generator logic..generateSingleFileForPreview) ⇒ + * [~produceCompiledTemplate(singleTemplatePkg)](#module_JS API_ generator logic..produceCompiledTemplate) ⇒ + * [~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options)](#module_JS API_ generator logic..produceIterativeContent) ⇒ + * [~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:)](#module_JS API_ generator logic..produceContent) ⇒ + * [~wrapOverridable(originalFn, overrideFn)](#module_JS API_ generator logic..wrapOverridable) ⇒ + * [~loadOverridable(path)](#module_JS API_ generator logic..loadOverridable) + * [~loadPartial(path)](#module_JS API_ generator logic..loadPartial) + * [~helperWrapper(wrappedHelper)](#module_JS API_ generator logic..helperWrapper) ⇒ + * [~loadHelper(helpers)](#module_JS API_ generator logic..loadHelper) + * [~allBuiltInHelpers()](#module_JS API_ generator logic..allBuiltInHelpers) ⇒ + * [~findHelperPackageByAlias(alias)](#module_JS API_ generator logic..findHelperPackageByAlias) ⇒ + * [~initializeBuiltInHelpersForPackage()](#module_JS API_ generator logic..initializeBuiltInHelpersForPackage) + * [~hbInstance()](#module_JS API_ generator logic..hbInstance) ⇒ + * [~makeSynchronizablePromise(promise)](#module_JS API_ generator logic..makeSynchronizablePromise) + * [~collectBlocks(resultArray, options, context)](#module_JS API_ generator logic..collectBlocks) ⇒ + * [~ensureZclPackageId(context)](#module_JS API_ generator logic..ensureZclPackageId) ⇒ + * [~ensureZclPackageIds(context)](#module_JS API_ generator logic..ensureZclPackageIds) ⇒ + * [~ensureTemplatePackageCategory(context)](#module_JS API_ generator logic..ensureTemplatePackageCategory) ⇒ + * [~ensureTemplatePackageId(context)](#module_JS API_ generator logic..ensureTemplatePackageId) ⇒ + * [~ensureEndpointTypeIds(context)](#module_JS API_ generator logic..ensureEndpointTypeIds) ⇒ + * [~ensureZclClusterSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclClusterSdkExtensions) ⇒ + * [~ensureZclDeviceTypeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclDeviceTypeSdkExtensions) ⇒ + * [~ensureZclAttributeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclAttributeSdkExtensions) ⇒ + * [~ensureZclAttributeTypeSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclAttributeTypeSdkExtensions) ⇒ + * [~ensureZclCommandSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclCommandSdkExtensions) ⇒ + * [~ensureZclEventSdkExtensions(context, templatePackageId)](#module_JS API_ generator logic..ensureZclEventSdkExtensions) ⇒ + * [~templatePromise(global, promise)](#module_JS API_ generator logic..templatePromise) + * [~deprecatedHelper(fn, explanation)](#module_JS API_ generator logic..deprecatedHelper) ⇒ -### Templating API: user-data specific helpers~all_user_clusters_with_incoming_or_outgoing_commands(options, is_incoming) ⇒ + -Util function for all clusters with side that have available incoming or -outgiong commands across all endpoints. +### JS API: generator logic~loadGenTemplateFromFile(path) ⇒ +Given a path, it will read generation template object into memory. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: All clusters with side that have available incoming or outgiong -commands across all endpoints. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Object that contains: data, crc, templateData -| Param | Description | -| ----------- | ----------------------------------------------------- | -| options | | -| is_incoming | boolean to check if commands are incoming or outgoing | +| Param | Type | +| --- | --- | +| path | \* | - + -### Templating API: user-data specific helpers~all_user_clusters_with_incoming_commands(options) ⇒ +### JS API: generator logic~recordPackageIfNonexistent(db, packagePath, parentId, packageType, version, category, description) ⇒ +Inserts the package details when they do not exist. -All clusters with side that have available incoming commands +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of package insertion -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: All clusters with side that have available incoming commands across -all endpoints. +| Param | Type | +| --- | --- | +| db | \* | +| packagePath | \* | +| parentId | \* | +| packageType | \* | +| version | \* | +| category | \* | +| description | \* | -| Param | -| ------- | -| options | + - +### JS API: generator logic~loadTemplateOptionsFromJsonFile(db, packageId, category, externalPath) ⇒ +Insert the template options from the json meta data file. -### Templating API: user-data specific helpers~all_user_clusters_with_outgoing_commands(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of inserted template options -All clusters with side that have available outgoing commands +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| category | \* | +| externalPath | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: All clusters with side that have available outgoing commands across -all endpoints. + -| Param | -| ------- | -| options | +### JS API: generator logic~recordTemplatesPackage(context) ⇒ +Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the same context passed in, except packageId added to it -### Templating API: user-data specific helpers~manufacturing_clusters_with_incoming_commands(clusterCode, options) ⇒ +| Param | Type | +| --- | --- | +| context | \* | -Provide all manufacturing specific clusters that have incoming commands with -the given cluster code. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Details of manufacturing specific clusters that have incoming -commands with the given cluster code +### JS API: generator logic~decodePackageExtensionEntity(entityType, entity) ⇒ +This method takes extension data in JSON, and converts it into +an object that contains: + entityCode, entityQualifier, parentCode, manufacturerCode and value -| Param | -| ----------- | -| clusterCode | -| options | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: object that can be used for database injection - +| Param | Type | +| --- | --- | +| entityType | \* | +| entity | \* | -### Templating API: user-data specific helpers~all_user_clusters_with_incoming_commands_combined(options) ⇒ + -All clusters that have available incoming commands. -If there is a client and server enabled on the endpoint, this combines them -into a single entry. +### JS API: generator logic~loadZclExtensions(zclExt) ⇒ +Returns a promise that will load the zcl extensions. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: All clusters that have available incoming commands across -all endpoints. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise of loading the zcl extensions. -| Param | -| ------- | -| options | +| Param | Type | +| --- | --- | +| zclExt | \* | - + -### Templating API: user-data specific helpers~all_incoming_commands_for_cluster_combined(clusterName, clientSide, serverSide, options) ⇒ +### JS API: generator logic~loadTemplates(db, genTemplatesJsonArray) +Api that loads an array of template JSON files or a single file if +you just pass in one String. -All commands that need to be parsed for a given cluster. This takes in booleans -for if the client and or server are included. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: all commands that need to be parsed for a given cluster +| Param | Type | +| --- | --- | +| db | \* | +| genTemplatesJsonArray | \* | -| Param | -| ----------- | -| clusterName | -| clientSide | -| serverSide | -| options | + - +### JS API: generator logic~loadGenTemplatesJsonFile(db, genTemplatesJson) ⇒ +Main API async function to load templates from a gen-template.json file. -### Templating API: user-data specific helpers~all_incoming_or_outgoing_commands_for_cluster(clusterName, clusterSide, isIncoming, options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: the loading context, contains: db, path, crc, packageId and templateData, or error -A util function for all incoming or outgoing commands that need to be parsed -for a given cluster +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Database | +| genTemplatesJson | \* | Path to the JSON file or an array of paths to JSON file | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: All incoming or outgoing commands that need to be parsed for a given -cluster + -| Param | -| ----------- | -| clusterName | -| clusterSide | -| isIncoming | -| options | +### JS API: generator logic~retrievePackageMetaInfo(db, genTemplatesPkgId) ⇒ +Get the package information from the given package ID. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: package information -### Templating API: user-data specific helpers~all_incoming_commands_for_cluster(clusterName, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| genTemplatesPkgId | \* | -All incoming commands that need to be parsed for a given cluster + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: all incoming commands that need to be parsed for a given cluster +### JS API: generator logic~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly) ⇒ +Generates all the templates inside a toplevel package. -| Param | -| ----------- | -| clusterName | -| options | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output' - +| Param | Type | Description | +| --- | --- | --- | +| genResult | \* | | +| genTemplateJsonPkg | \* | Package that points to genTemplate.json file | +| generateOnly | \* | if NULL then generate all templates, else only generate template whose out file name matches this. | -### Templating API: user-data specific helpers~all_outgoing_commands_for_cluster(clusterName, options) ⇒ + -All outgoing commands that need to be parsed for a given cluster +### JS API: generator logic~generateSingleTemplate(genResult, singleTemplatePkg) ⇒ +Function that generates a single package and adds it to the generation result. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: all outgoing commands that need to be parsed for a given cluster +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the genResult, with newly generated content added. -| Param | -| ----------- | -| clusterName | -| options | +| Param | Type | Description | +| --- | --- | --- | +| genResult | \* | | +| singleTemplatePkg | \* | Single template package. | - + -### Templating API: user-data specific helpers~generated_clustes_details(options) ⇒ +### JS API: generator logic~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options) ⇒ +Main API async function to generate stuff. -Entails the Cluster details per endpoint +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into a generation result.Promise that resolves into a generation result. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Cluster Details per endpoint with attribute summaries within the clusters +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Database | +| sessionId | \* | | +| templatePackageId | \* | packageId Template package id. It can be either single template or gen template json. | +| templateGeneratorOptions | \* | | +| options | \* | | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### JS API: generator logic~writeFileWithBackup(fileName, content, doBackup) ⇒ +Promise to write out a file, optionally creating a backup. -### Templating API: user-data specific helpers~generated_endpoint_type_details(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise of a written file. -Entails Endpoint type details along with their cluster summaries +| Param | Type | +| --- | --- | +| fileName | \* | +| content | \* | +| doBackup | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Endpoint type details along with their cluster summaries + -| Param | -| ------- | -| options | +### JS API: generator logic~generateGenerationContent(genResult) +Returns a promise that resolves into a content that should be written out to gen result file. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -### Templating API: user-data specific helpers~all_user_cluster_attributes_min_max_defaults(name, side, options) ⇒ +| Param | Type | +| --- | --- | +| genResult | \* | -Returns attributes inside an endpoint type that either have a default or a -bounded attribute. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: endpoints with bounds or defaults +### JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒ +Generate files and write them into the given directory. -| Param | -| ------- | -| name | -| side | -| options | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: a promise which will resolve when all the files are written. - +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| packageId | \* | +| outputDirectory | \* | -### Templating API: user-data specific helpers~checkAttributeMatch(clusterName, attributeName, attributeSide, attributeValue, attributeValueType, endpointAttributes) ⇒ + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: arrayIndex +### JS API: generator logic~createGenerationLog(logFile, genData) +Create a generation log. -| Param | -| ------------------ | -| clusterName | -| attributeName | -| attributeSide | -| attributeValue | -| attributeValueType | -| endpointAttributes | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) - +| Param | Type | +| --- | --- | +| logFile | \* | +| genData | \* | -### Templating API: user-data specific helpers~generated_defaults_index(clusterName, attributeName, attributeValueType, attributeValue, prefixReturn, postFixReturn) ⇒ + -Extracts the index of generated defaults array which come from -all_user_cluster_attributes_for_generated_defaults +### JS API: generator logic~postProcessGeneratedFiles(outputDirectory, genResult) ⇒ +Executes post processing actions as defined by the gen-templates.json -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: index of the generated default array +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise of a dealt-with post processing actions -| Param | -| ------------------ | -| clusterName | -| attributeName | -| attributeValueType | -| attributeValue | -| prefixReturn | -| postFixReturn | +| Param | Type | +| --- | --- | +| outputDirectory | \* | +| genResult | \* | - + -### Templating API: user-data specific helpers~generated_default_index(clusterName, attributeName, attributeSide, attributeValueType, attributeValue, prefixReturn, postFixReturn) ⇒ +### JS API: generator logic~contentIndexer(content) +This async function takes a string, and resolves a preview object out of it. -Extracts the index of generated defaults array which come from -all_user_cluster_attributes_for_generated_defaults +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: deafult value's index in the generated default array +| Param | Type | Description | +| --- | --- | --- | +| content | \* | String to form into preview. | -| Param | -| ------------------ | -| clusterName | -| attributeName | -| attributeSide | -| attributeValueType | -| attributeValue | -| prefixReturn | -| postFixReturn | + - +### JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒ +Generates a single file and feeds it back for preview. -### Templating API: user-data specific helpers~generated_attributes_min_max_index(name, side, options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves into a preview object. -Extracts the index of generated min max defaults array which come from -all_user_cluster_attributes_min_max_defaults +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| fileName | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: index of the generated min max default array + -| Param | -| ------- | -| name | -| side | -| options | +### JS API: generator logic~produceCompiledTemplate(singleTemplatePkg) ⇒ +Resolves into a precompiled template, either from previous precompile or freshly compiled. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: templates -### Templating API: user-data specific helpers~generated_attribute_min_max_index(clusterName, attributeName, attributeSide, options) ⇒ +| Param | Type | +| --- | --- | +| singleTemplatePkg | \* | -Extracts the index of generated min max defaults array which come from -all_user_cluster_attributes_min_max_defaults + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: index of the generated min max default in the array +### JS API: generator logic~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options) ⇒ +This function is reached if the template is an "iterative one", meaning +it has the iterator set to one of the valid options. -| Param | -| ------------- | -| clusterName | -| attributeName | -| attributeSide | -| options | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into an array of key/content/stats objects. - +| Param | Type | +| --- | --- | +| hb | \* | +| metaInfo | \* | +| db | \* | +| sessionId | \* | +| singleTemplatePkg | \* | +| genTemplateJsonPackage | \* | +| options | \* | -### Templating API: user-data specific helpers~if_enabled_clusters(options) ⇒ + -If helper that checks if there are clusters enabled -Available options: +### JS API: generator logic~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:) ⇒ +Given db connection, session and a single template package, produce the output. -- side: side="client/server" can be used to check if there are client or - server side clusters are available +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves into an array of key/content/stats objects. -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: Promise of content. +| Param | Type | Description | +| --- | --- | --- | +| hb | \* | | +| metaInfo | \* | | +| db | \* | | +| sessionId | \* | | +| singlePkg | \* | | +| overridePath: | \* | if passed, it provides a path to the override file that can override the overridable.js | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### JS API: generator logic~wrapOverridable(originalFn, overrideFn) ⇒ +This function attemps to call override function, but if override function +throws an exception, it calls the original function. -### Templating API: user-data specific helpers~if_multi_protocol_attributes_enabled(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: result from override function, unless it throws an exception, in which case return result from original function. -Check if multi-protocol is enabled for the application. +| Param | Type | +| --- | --- | +| originalFn | \* | +| overrideFn | \* | -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: boolean based on existence of attribute-attribute associations. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~loadOverridable(path) +This function is responsible to load the overridable function container. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -### Templating API: user-data specific helpers~all_multi_protocol_attributes(options) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| path | \* | of the override file | -Retrieve all the attribute-attribute associations for the current session. + -**Kind**: inner method of [Templating API: user-data specific helpers](#module*Templating API* user-data specific helpers) -**Returns**: attribute-attribute mapping entries +### JS API: generator logic~loadPartial(path) +Function that loads the partials. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) - +| Param | Type | +| --- | --- | +| path | \* | -## Templating API: toplevel utility helpers + -This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} +### JS API: generator logic~helperWrapper(wrappedHelper) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: function -- [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) - - [~zap_header()](#module*Templating API* toplevel utility helpers..zap_header) ⇒ - - [~ident()](#module*Templating API* toplevel utility helpers..ident) ⇒ - - [~template_options(category, options)](#module*Templating API* toplevel utility helpers..template_options) - - [~first(options)](#module*Templating API* toplevel utility helpers..first) ⇒ - - [~not_first(options)](#module*Templating API* toplevel utility helpers..not_first) ⇒ - - [~last(options)](#module*Templating API* toplevel utility helpers..last) ⇒ - - [~not_last(optionms)](#module*Templating API* toplevel utility helpers..not_last) ⇒ - - [~middle(options)](#module*Templating API* toplevel utility helpers..middle) ⇒ - - [~template_option_with_code(options, key)](#module*Templating API* toplevel utility helpers..template_option_with_code) - - [~fail(options)](#module*Templating API* toplevel utility helpers..fail) - - [~isEqual(string_a, string_b)](#module*Templating API* toplevel utility helpers..isEqual) - - [~is_lowercase_equal(string_a, string_b)](#module*Templating API* toplevel utility helpers..is_lowercase_equal) - - [~trim_string(str)](#module*Templating API* toplevel utility helpers..trim_string) ⇒ - - [~asLastWord(str)](#module*Templating API* toplevel utility helpers..asLastWord) - - [~iterate()](#module*Templating API* toplevel utility helpers..iterate) - - [~concatenate()](#module*Templating API* toplevel utility helpers..concatenate) - - [~is_num_equal(numA, numB)](#module*Templating API* toplevel utility helpers..is_num_equal) ⇒ - - [~is_defined(value)](#module*Templating API* toplevel utility helpers..is_defined) ⇒ - - [~replace_string(mainString, replaceString, replaceWithString)](#module*Templating API* toplevel utility helpers..replace_string) ⇒ - - [~add_prefix_to_all_strings(str, prefixStr)](#module*Templating API* toplevel utility helpers..add_prefix_to_all_strings) ⇒ - - [~multiply()](#module*Templating API* toplevel utility helpers..multiply) ⇒ - - [~is_string_underscored(val)](#module*Templating API* toplevel utility helpers..is_string_underscored) ⇒ - - [~as_uppercase(val)](#module*Templating API* toplevel utility helpers..as_uppercase) ⇒ +| Param | Type | +| --- | --- | +| wrappedHelper | \* | - + -### Templating API: toplevel utility helpers~zap_header() ⇒ +### JS API: generator logic~loadHelper(helpers) +Function that loads the helpers. -Produces the top-of-the-file header for a C file. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: The header content - +| Param | Type | Description | +| --- | --- | --- | +| helpers | \* | a string path if value is passed through CLI, the nativeRequire() is leverage the native js function instead of webpack's special sauce. a required() module if invoked by backend js code. this is required to force webpack to resolve the included files as path will be difference after being packed for production. | -### Templating API: toplevel utility helpers~ident() ⇒ + -Simple helper that produces an approved size of identation. +### JS API: generator logic~allBuiltInHelpers() ⇒ +Returns an object that contains all the helper functions, keyed +by their name -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: whitespace that is the identation. - +NOTE: This method is ONLY used for API testing. You should not use +this method for any real work inside the engine or something. -### Templating API: toplevel utility helpers~template_options(category, options) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Object containing all the helper functions. + -Block helper that iterates over the package options of a given category. +### JS API: generator logic~findHelperPackageByAlias(alias) ⇒ +Given an alias, this method finds a builtin helper package +by its alias. -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Helper package or undefined if none was found. -| Param | Type | -| -------- | --------------- | -| category | \* | -| options | \* | +| Param | Type | +| --- | --- | +| alias | \* | - + -### Templating API: toplevel utility helpers~first(options) ⇒ +### JS API: generator logic~initializeBuiltInHelpersForPackage() +Global helper initialization -Inside an iterator, this helper allows you to specify the content that will be output only -during the first element. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: content, if it's the first element inside an operator, empty otherwise. +### JS API: generator logic~hbInstance() ⇒ +This method returns the correct instance for a given generation flow. -| Param | Type | -| ------- | --------------- | -| options | \* | +TBD: At this point it doesn't do anything yet, it's just +a central point to get the correct instance. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Instance of handlebars to be used. + -### Templating API: toplevel utility helpers~not_first(options) ⇒ +### JS API: generator logic~makeSynchronizablePromise(promise) +All promises used by the templates should be synchronizable. -Inside an iterator, this helper allows you to specify the content that will be output only -if the element is not the first element. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: content, if it's the first element inside an operator, empty otherwise. +| Param | Type | +| --- | --- | +| promise | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### JS API: generator logic~collectBlocks(resultArray, options, context) ⇒ +Helpful function that collects the individual blocks by using elements of an array as a context, +executing promises for each, and collecting them into the outgoing string. -### Templating API: toplevel utility helpers~last(options) ⇒ +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: Promise that resolves with a content string. -Inside an iterator, this helper allows you to specify the content that will be output only -during the last element. +| Param | Type | Description | +| --- | --- | --- | +| resultArray | \* | | +| options | \* | Options passed from a block helper. | +| context | \* | The context from within this was called. | -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: content, if it's the last element inside an operator, empty otherwise. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~ensureZclPackageId(context) ⇒ +Returns the promise that resolves with the ZCL properties package id. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the package id. -### Templating API: toplevel utility helpers~not_last(optionms) ⇒ +| Param | Type | +| --- | --- | +| context | \* | -Inside an iterator. the block is output only if this is NOT the last item. -Useful for wrapping commas in the list of arguments and such. + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: content, if it's not the last element inside a block, empty otherwise. +### JS API: generator logic~ensureZclPackageIds(context) ⇒ +Returns the promise that resolves with all ZCL package id specific to current session. -| Param | Type | -| -------- | --------------- | -| optionms | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with a list of package id. - +| Param | Type | +| --- | --- | +| context | \* | -### Templating API: toplevel utility helpers~middle(options) ⇒ + -Inside an iterator, this helper allows you to specify the content that will be output only -during the non-first and no-last element. +### JS API: generator logic~ensureTemplatePackageCategory(context) ⇒ +Returns a package category of the toplevel template package from context. -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: content, if it's the middle element inside an operator, empty otherwise. +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: proimise that resolves into a package category -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| context | \* | - + -### Templating API: toplevel utility helpers~template_option_with_code(options, key) +### JS API: generator logic~ensureTemplatePackageId(context) ⇒ +Returns the promise that resolves with the ZCL properties package id. -This fetches a promise which returns template options if provided +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with the package id. -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) +| Param | Type | +| --- | --- | +| context | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | -| key | \* | + - +### JS API: generator logic~ensureEndpointTypeIds(context) ⇒ +Populate the endpoint type ids into the global context. -### Templating API: toplevel utility helpers~fail(options) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: endpoint type ids -Forced fail halper. +| Param | Type | +| --- | --- | +| context | \* | -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) + -| Param | Type | -| ------- | --------------- | -| options | \* | +### JS API: generator logic~ensureZclClusterSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached cluster extensions, but if they don't +exist, it will populate them. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with cluster extensions. -### Templating API: toplevel utility helpers~isEqual(string_a, string_b) +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -This returns a boolean if the 2 strings are same + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) +### JS API: generator logic~ensureZclDeviceTypeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached cluster extensions, but if they don't +exist, it will populate them. -| Param | Type | -| -------- | --------------- | -| string_a | \* | -| string_b | \* | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with cluster extensions. - +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -### Templating API: toplevel utility helpers~is_lowercase_equal(string_a, string_b) + -This returns a boolean based on the 2 strings being equal or not given that both +### JS API: generator logic~ensureZclAttributeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached attribute extensions, but if they don't +exist, it will populate them. -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with attribute extensions. -| Param | Type | -| -------- | --------------- | -| string_a | \* | -| string_b | \* | +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | - + -### Templating API: toplevel utility helpers~trim_string(str) ⇒ +### JS API: generator logic~ensureZclAttributeTypeSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached attribute type extensions, but if they don't +exist, it will populate them. -Remove leading and trailing spaces from a string +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with attribute type extensions. -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: A string with no leading and trailing spaces +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -| Param | Type | -| ----- | --------------- | -| str | \* | + - +### JS API: generator logic~ensureZclCommandSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached command extensions, but if they don't +exist, it will populate them. -### Templating API: toplevel utility helpers~asLastWord(str) +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with command extensions. -Split the string based on spaces and return the last word +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) + -| Param | Type | -| ----- | --------------- | -| str | \* | +### JS API: generator logic~ensureZclEventSdkExtensions(context, templatePackageId) ⇒ +Resolves with cached command extensions, but if they don't +exist, it will populate them. - +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: promise that resolves with command extensions. -### Templating API: toplevel utility helpers~iterate() +| Param | Type | +| --- | --- | +| context | \* | +| templatePackageId | \* | -Iteration block. + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) - +### JS API: generator logic~templatePromise(global, promise) +Every helper that returns a promise, should +not return the promise directly. So instead of +returning the promise directly, it should return: + return templatePromise(this.global, promise) -### Templating API: toplevel utility helpers~concatenate() +This will ensure that after tag works as expected. -Given: A list of strings -Returns a concatenated string with spaces between each string +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) - +| Param | Type | +| --- | --- | +| global | \* | +| promise | \* | -### Templating API: toplevel utility helpers~is_num_equal(numA, numB) ⇒ + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: true if both numbers are equal else returns false +### JS API: generator logic~deprecatedHelper(fn, explanation) ⇒ +Function wrapper that can be used when a helper is deprecated. -| Param | -| ----- | -| numA | -| numB | +**Kind**: inner method of [JS API: generator logic](#module_JS API_ generator logic) +**Returns**: a function that wraps the original function, with deprecation message. - +| Param | Type | Description | +| --- | --- | --- | +| fn | \* | | +| explanation | \* | can contain `text`, or `from`/`to`, or just be a string message itself. | -### Templating API: toplevel utility helpers~is_defined(value) ⇒ + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: true or false based on whether the value is undefined or not +## IDE Integration API: Studio REST API. +This module provides the APIs to Silabs Simplicity Studio's Jetty server. -| Param | -| ----- | -| value | + - +## REST API: user data +This module provides the API to access zcl specific information. -### Templating API: toplevel utility helpers~replace_string(mainString, replaceString, replaceWithString) ⇒ -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: A string replaced with another string in the mainString +* [REST API: user data](#module_REST API_ user data) + * [~getComponentIdsByCluster(db, sessionId, clusterId, side)](#module_REST API_ user data..getComponentIdsByCluster) ⇒ \* + * [~httpGetSessionKeyValues(db)](#module_REST API_ user data..httpGetSessionKeyValues) ⇒ + * [~httpGetEndpointIds(db)](#module_REST API_ user data..httpGetEndpointIds) ⇒ + * [~httpGetDeviceTypeFeatures(db)](#module_REST API_ user data..httpGetDeviceTypeFeatures) ⇒ + * [~httpGetSessionNotifications(db)](#module_REST API_ user data..httpGetSessionNotifications) ⇒ + * [~httpDeleteSessionNotification(db)](#module_REST API_ user data..httpDeleteSessionNotification) ⇒ + * [~httpGetPackageNotifications(db)](#module_REST API_ user data..httpGetPackageNotifications) ⇒ + * [~httpGetPackageNotificationsByPackageId(db)](#module_REST API_ user data..httpGetPackageNotificationsByPackageId) ⇒ + * [~httpDeletePackageNotification(db)](#module_REST API_ user data..httpDeletePackageNotification) ⇒ + * [~httpGetUnseenNotificationCount(db)](#module_REST API_ user data..httpGetUnseenNotificationCount) ⇒ + * [~httpGetUnseenNotificationAndUpdate(db)](#module_REST API_ user data..httpGetUnseenNotificationAndUpdate) ⇒ + * [~httpPostSaveSessionKeyValue(db)](#module_REST API_ user data..httpPostSaveSessionKeyValue) ⇒ + * [~httpPostCluster(db)](#module_REST API_ user data..httpPostCluster) ⇒ + * [~httpPostForcedExternal(db)](#module_REST API_ user data..httpPostForcedExternal) ⇒ function + * [~httpPostAttributeUpdate(db)](#module_REST API_ user data..httpPostAttributeUpdate) ⇒ + * [~httpPostCommandUpdate(db)](#module_REST API_ user data..httpPostCommandUpdate) ⇒ + * [~httpPostEventUpdate(db)](#module_REST API_ user data..httpPostEventUpdate) ⇒ + * [~httpGetInitialState(db)](#module_REST API_ user data..httpGetInitialState) ⇒ + * [~httpGetOption(db)](#module_REST API_ user data..httpGetOption) ⇒ + * [~httpGetUiOptions(db)](#module_REST API_ user data..httpGetUiOptions) ⇒ + * [~httpGetPackages()](#module_REST API_ user data..httpGetPackages) + * [~httpGetAllPackages()](#module_REST API_ user data..httpGetAllPackages) + * [~httpPostAddNewPackage()](#module_REST API_ user data..httpPostAddNewPackage) + * [~httpPostShareClusterStatesAcrossEndpoints()](#module_REST API_ user data..httpPostShareClusterStatesAcrossEndpoints) + * [~commandDefaults(db, endpointTypeIdList, sharedClusterList, packageIds)](#module_REST API_ user data..commandDefaults) ⇒ + * [~writeCommandDefaults(db, defaults)](#module_REST API_ user data..writeCommandDefaults) + * [~attributeDefaults(db, endpointTypeIdList, sharedClusterList, packageIds)](#module_REST API_ user data..attributeDefaults) ⇒ + * [~writeAttributeDefaults(db, defaults)](#module_REST API_ user data..writeAttributeDefaults) + * [~commandEquals(a, b)](#module_REST API_ user data..commandEquals) ⇒ + * [~attributeEquals(a, b)](#module_REST API_ user data..attributeEquals) ⇒ + * [~httpDeleteSessionPackage(db)](#module_REST API_ user data..httpDeleteSessionPackage) ⇒ + * [~httpPostDuplicateEndpoint(db)](#module_REST API_ user data..httpPostDuplicateEndpoint) ⇒ + * [~httpPostDuplicateEndpointType(db)](#module_REST API_ user data..httpPostDuplicateEndpointType) ⇒ + * [~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId)](#module_REST API_ user data..duplicateEndpointTypeClusters) -| Param | -| ----------------- | -| mainString | -| replaceString | -| replaceWithString | + - +### REST API: user data~getComponentIdsByCluster(db, sessionId, clusterId, side) ⇒ \* +Promise that return a list of component Ids required by a specific cluster -### Templating API: toplevel utility helpers~add_prefix_to_all_strings(str, prefixStr) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: \* - array of componentIds -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: A resultant string with all string values prefixed with prefixStr +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterId | \* | +| side | \* | -| Param | -| --------- | -| str | -| prefixStr | + - +### REST API: user data~httpGetSessionKeyValues(db) ⇒ +HTTP GET: session key values -### Templating API: toplevel utility helpers~multiply() ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: A number which is result of multiplying all the arguments given - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: toplevel utility helpers~is_string_underscored(val) ⇒ + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: true if a string has an underscore in it +### REST API: user data~httpGetEndpointIds(db) ⇒ +HTTP GET: endpoint ids of endpoints within a specified session -| Param | Type | -| ----- | --------------- | -| val | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: toplevel utility helpers~as_uppercase(val) ⇒ + -**Kind**: inner method of [Templating API: toplevel utility helpers](#module*Templating API* toplevel utility helpers) -**Returns**: val in uppercase +### REST API: user data~httpGetDeviceTypeFeatures(db) ⇒ +HTTP GET: device type features -| Param | Type | -| ----- | --------------- | -| val | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -## Templating API: static zcl helpers + -This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} +### REST API: user data~httpGetSessionNotifications(db) ⇒ +HTTP GET: session get notifications -- [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) - - [~zcl_bitmaps(options)](#module*Templating API* static zcl helpers..zcl_bitmaps) ⇒ - - [~zcl_bitmap_items(options)](#module*Templating API* static zcl helpers..zcl_bitmap_items) - - [~zcl_enums(options)](#module*Templating API* static zcl helpers..zcl_enums) ⇒ - - [~zcl_structs(options)](#module*Templating API* static zcl helpers..zcl_structs) ⇒ - - [~zcl_enum_items(options)](#module*Templating API* static zcl helpers..zcl_enum_items) - - [~first_unused_enum_value(options)](#module*Templating API* static zcl helpers..first_unused_enum_value) ⇒ - - [~zcl_struct_items(options)](#module*Templating API* static zcl helpers..zcl_struct_items) ⇒ - - [~zcl_struct_items_by_struct_name(name, options)](#module*Templating API* static zcl helpers..zcl_struct_items_by_struct_name) ⇒ - - [~zcl_struct_items_by_struct_and_cluster_name(name, clusterName, options)](#module*Templating API* static zcl helpers..zcl_struct_items_by_struct_and_cluster_name) ⇒ - - [~zcl_device_types(options)](#module*Templating API* static zcl helpers..zcl_device_types) ⇒ - - [~zcl_device_type_clusters(options)](#module*Templating API* static zcl helpers..zcl_device_type_clusters) ⇒ - - [~zcl_device_type_cluster_commands(options)](#module*Templating API* static zcl helpers..zcl_device_type_cluster_commands) ⇒ - - [~zcl_device_type_cluster_attributes(options)](#module*Templating API* static zcl helpers..zcl_device_type_cluster_attributes) ⇒ - - [~zcl_clusters(options)](#module*Templating API* static zcl helpers..zcl_clusters) ⇒ - - [~zcl_commands(options)](#module*Templating API* static zcl helpers..zcl_commands) ⇒ - - [~zcl_command_responses(options)](#module*Templating API* static zcl helpers..zcl_command_responses) ⇒ - - [~zcl_commands_with_cluster_info(options)](#module*Templating API* static zcl helpers..zcl_commands_with_cluster_info) ⇒ - - [~zcl_commands_with_arguments(options)](#module*Templating API* static zcl helpers..zcl_commands_with_arguments) - - [~zcl_commands_source_client(options)](#module*Templating API* static zcl helpers..zcl_commands_source_client) ⇒ - - [~zcl_commands_source_server(options)](#module*Templating API* static zcl helpers..zcl_commands_source_server) ⇒ - - [~zcl_events(options)](#module*Templating API* static zcl helpers..zcl_events) ⇒ - - [~zcl_command_tree(options)](#module*Templating API* static zcl helpers..zcl_command_tree) ⇒ - - [~zcl_global_commands(options)](#module*Templating API* static zcl helpers..zcl_global_commands) ⇒ - - [~zcl_attributes(options)](#module*Templating API* static zcl helpers..zcl_attributes) ⇒ - - [~zcl_attributes_client(options)](#module*Templating API* static zcl helpers..zcl_attributes_client) ⇒ - - [~zcl_attributes_server(options)](#module*Templating API* static zcl helpers..zcl_attributes_server) ⇒ - - [~zcl_atomics(options)](#module*Templating API* static zcl helpers..zcl_atomics) ⇒ - - [~zcl_cluster_largest_label_length()](#module*Templating API* static zcl helpers..zcl_cluster_largest_label_length) ⇒ - - [~largestLabelLength(An)](#module*Templating API* static zcl helpers..largestLabelLength) ⇒ - - [~zcl_command_arguments_count(commandId)](#module*Templating API* static zcl helpers..zcl_command_arguments_count) ⇒ - - [~ifCommandArgumentsHaveFixedLengthWithCurrentContext(commandId, fixedLengthReturn, notFixedLengthReturn, currentContext)](#module*Templating API* static zcl helpers..ifCommandArgumentsHaveFixedLengthWithCurrentContext) - - [~if_command_arguments_have_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn)](#module*Templating API* static zcl helpers..if_command_arguments_have_fixed_length) - - [~as_underlying_zcl_type_command_is_not_fixed_length_but_command_argument_is_always_present(type, command, commandArg, appendString, options)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_command_is_not_fixed_length_but_command_argument_is_always_present) ⇒ - - [~as_underlying_zcl_type_if_command_is_not_fixed_length(type, commandId, appendString, options)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_if_command_is_not_fixed_length) - - [~command_arguments_total_length(commandId)](#module*Templating API* static zcl helpers..command_arguments_total_length) - - [~zcl_command_arguments(options)](#module*Templating API* static zcl helpers..zcl_command_arguments) ⇒ - - [~zcl_event_fields(options)](#module*Templating API* static zcl helpers..zcl_event_fields) - - [~zcl_command_argument_data_type(typeName, options)](#module*Templating API* static zcl helpers..zcl_command_argument_data_type) - - [~asUnderlyingZclType(typeName, options)](#module*Templating API* static zcl helpers..asUnderlyingZclType) - - [~zcl_string_type_return(type, options)](#module*Templating API* static zcl helpers..zcl_string_type_return) - - [~is_zcl_string(type)](#module*Templating API* static zcl helpers..is_zcl_string) - - [~if_is_number(type)](#module*Templating API* static zcl helpers..if_is_number) ⇒ - - [~if_is_string(type)](#module*Templating API* static zcl helpers..if_is_string) ⇒ - - [~if_is_char_string(type)](#module*Templating API* static zcl helpers..if_is_char_string) ⇒ - - [~if_is_octet_string(type)](#module*Templating API* static zcl helpers..if_is_octet_string) ⇒ - - [~if_is_short_string(type)](#module*Templating API* static zcl helpers..if_is_short_string) ⇒ - - [~if_is_long_string(type)](#module*Templating API* static zcl helpers..if_is_long_string) ⇒ - - [~if_is_atomic(type:)](#module*Templating API* static zcl helpers..if_is_atomic) ⇒ - - [~if_is_bitmap(type)](#module*Templating API* static zcl helpers..if_is_bitmap) ⇒ - - [~if_is_enum(type)](#module*Templating API* static zcl helpers..if_is_enum) ⇒ - - [~if_is_struct(type)](#module*Templating API* static zcl helpers..if_is_struct) ⇒ - - [~isClient(side)](#module*Templating API* static zcl helpers..isClient) ⇒ - - [~isServer(side)](#module*Templating API* static zcl helpers..isServer) ⇒ - - [~as_underlying_zcl_type_command_argument_always_present(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_command_argument_always_present) ⇒ - - [~if_command_argument_always_present(commandId, introducedInRef, removedInRef, presentIf, argumentPresentReturn, argumentNotPresentReturn)](#module*Templating API* static zcl helpers..if_command_argument_always_present) ⇒ - - [~as_underlying_zcl_type_command_argument_not_always_present_no_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_command_argument_not_always_present_no_presentif) ⇒ - - [~as_underlying_zcl_type_ca_not_always_present_no_presentif(commandArg, appendString, options)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_ca_not_always_present_no_presentif) ⇒ - - [~if_command_argument_not_always_present_no_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsReturn, argumentInAllVersionsReturn)](#module*Templating API* static zcl helpers..if_command_argument_not_always_present_no_presentif) ⇒ - - [~as_underlying_zcl_type_command_argument_not_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_command_argument_not_always_present_with_presentif) ⇒ - - [~as_underlying_zcl_type_ca_not_always_present_with_presentif(commandArg, appendString, options)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_ca_not_always_present_with_presentif) ⇒ - - [~if_command_argument_not_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn)](#module*Templating API* static zcl helpers..if_command_argument_not_always_present_with_presentif) ⇒ - - [~as_underlying_zcl_type_command_argument_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_command_argument_always_present_with_presentif) ⇒ - - [~as_underlying_zcl_type_ca_always_present_with_presentif(commandArg, appendString, options)](#module*Templating API* static zcl helpers..as_underlying_zcl_type_ca_always_present_with_presentif) ⇒ - - [~if_command_argument_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn)](#module*Templating API* static zcl helpers..if_command_argument_always_present_with_presentif) ⇒ - - [~if_manufacturing_specific_cluster(clusterId, manufacturer_specific_return, null_manufacturer_specific_return)](#module*Templating API* static zcl helpers..if_manufacturing_specific_cluster) ⇒ - - [~if_mfg_specific_cluster(clusterId, options)](#module*Templating API* static zcl helpers..if_mfg_specific_cluster) ⇒ - - [~as_generated_default_macro(value, attributeSize, options)](#module*Templating API* static zcl helpers..as_generated_default_macro) ⇒ - - [~attribute_mask(writable, storageOption, minMax, mfgSpecific, clusterCode, client, isSingleton, prefixString, postfixString)](#module*Templating API* static zcl helpers..attribute_mask) ⇒ - - [~command_mask(commmandSource, clusterSide, isIncomingEnabled, isOutgoingEnabled, manufacturingCode, prefixForMask)](#module*Templating API* static zcl helpers..command_mask) ⇒ - - [~command_mask_sub_helper(commandMask, str)](#module*Templating API* static zcl helpers..command_mask_sub_helper) ⇒ - - [~format_zcl_string_as_characters_for_generated_defaults(stringVal, sizeOfString)](#module*Templating API* static zcl helpers..format_zcl_string_as_characters_for_generated_defaults) ⇒ - - [~as_type_min_value(type, options)](#module*Templating API* static zcl helpers..as_type_min_value) ⇒ - - [~as_type_max_value(type, options)](#module*Templating API* static zcl helpers..as_type_max_value) ⇒ - - [~structs_with_clusters(options)](#module*Templating API* static zcl helpers..structs_with_clusters) - - [~as_zcl_type_size(type, options)](#module*Templating API* static zcl helpers..as_zcl_type_size) ⇒ - - [~if_compare(leftValue, rightValue, options)](#module*Templating API* static zcl helpers..if_compare) ⇒ Object - - [~if_is_data_type_signed(type, clusterId, options)](#module*Templating API* static zcl helpers..if_is_data_type_signed) ⇒ - - [~as_zcl_data_type_size(type, clusterId, options)](#module*Templating API* static zcl helpers..as_zcl_data_type_size) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: static zcl helpers~zcl_bitmaps(options) ⇒ + -Block helper iterating over all bitmaps. +### REST API: user data~httpDeleteSessionNotification(db) ⇒ +HTTP DELETE: session delete notifications -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~zcl_bitmap_items(options) +### REST API: user data~httpGetPackageNotifications(db) ⇒ +HTTP GET: package get notifications -Iterates over enum items. Valid only inside zcl_enums. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +| Param | Type | +| --- | --- | +| db | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### REST API: user data~httpGetPackageNotificationsByPackageId(db) ⇒ +HTTP GET: package get notifications -### Templating API: static zcl helpers~zcl_enums(options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -Block helper iterating over all enums. -If existing independently, it iterates over ALL the enums. -Within a context of a cluster, it iterates only over the -enums belonging to a cluster. +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### REST API: user data~httpDeletePackageNotification(db) ⇒ +HTTP DELETE: session delete notifications - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~zcl_structs(options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Block helper iterating over all structs. -If existing independently, it iterates over ALL the structs. -Within a context of a cluster, it iterates only over the -structs belonging to a cluster. + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +### REST API: user data~httpGetUnseenNotificationCount(db) ⇒ +HTTP GET: session get unseen session notification count -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: static zcl helpers~zcl_enum_items(options) + -Iterates over enum items. Valid only inside zcl_enums. +### REST API: user data~httpGetUnseenNotificationAndUpdate(db) ⇒ +HTTP GET: session update all session notifications to be SEEN -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~first_unused_enum_value(options) ⇒ +### REST API: user data~httpPostSaveSessionKeyValue(db) ⇒ +HTTP POST: save session key value -This helper prints out the first unused enum value. -It supports mode="next_larger" and -mode="first_unused" (which is the default). +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: the unused enum value +| Param | Type | +| --- | --- | +| db | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### REST API: user data~httpPostCluster(db) ⇒ +HTTP POST: cluster -### Templating API: static zcl helpers~zcl_struct_items(options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -Block helper iterating over all struct items. Valid only inside zcl_structs. +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### REST API: user data~httpPostForcedExternal(db) ⇒ function +Handles a POST request to retrieve forced external storage options. - +This function is designed to be used as a middleware in an Express.js route. It extracts the session ID from the request, +queries the database for package information associated with that session, and then retrieves forced external storage +options for the identified package. The results are sent back to the client as a JSON response. -### Templating API: static zcl helpers~zcl_struct_items_by_struct_name(name, options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: function - An asynchronous function that takes Express.js request and response objects. -Block helper iterating over all struct items given the struct name. +| Param | Type | Description | +| --- | --- | --- | +| db | Object | The database connection object. | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | -| ------- | -| name | -| options | +### REST API: user data~httpPostAttributeUpdate(db) ⇒ +HTTP POST attribute update - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~zcl_struct_items_by_struct_and_cluster_name(name, clusterName, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Block helper iterating over all struct items given the struct name and -cluster name. The items iterated will be those that correspond to that -struct name being used within the given cluster. That means the struct name -must be either a global struct (in which case the cluster name is just -ignored), or a struct associated with the given cluster. + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +### REST API: user data~httpPostCommandUpdate(db) ⇒ +HTTP POST: command update -| Param | -| ----------- | -| name | -| clusterName | -| options | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: static zcl helpers~zcl_device_types(options) ⇒ + -Block helper iterating over all deviceTypes. +### REST API: user data~httpPostEventUpdate(db) ⇒ +HTTP POST: command update -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~zcl_device_type_clusters(options) ⇒ +### REST API: user data~httpGetInitialState(db) ⇒ +HTTP GET: initial state -Block helper for use inside zcl_device_types +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: blocks for clusters +| Param | Type | +| --- | --- | +| db | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### REST API: user data~httpGetOption(db) ⇒ +HTTP GET: option -### Templating API: static zcl helpers~zcl_device_type_cluster_commands(options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -Block helper for use inside zcl_device_type_clusters +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: blocks for commands + -| Param | Type | -| ------- | --------------- | -| options | \* | +### REST API: user data~httpGetUiOptions(db) ⇒ +HTTP GET: ui_options - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: UI options from all packages. -### Templating API: static zcl helpers~zcl_device_type_cluster_attributes(options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Block helper for use inside zcl_device_type_clusters + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: blocks for attributes +### REST API: user data~httpGetPackages() +HTTP GET: Project packages -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + - +### REST API: user data~httpGetAllPackages() +HTTP GET: All Packages -### Templating API: static zcl helpers~zcl_clusters(options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + -Block helper iterating over all clusters. +### REST API: user data~httpPostAddNewPackage() +HTTP POST: Add new project package -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + -| Param | Type | -| ------- | --------------- | -| options | \* | +### REST API: user data~httpPostShareClusterStatesAcrossEndpoints() +HTTP POST: Unify all Attributes / Command states if a certain cluster is enabled + on more than one endpoint. - +1) In Zigbee world, the Attribute / Command configurations is a global singleton entity. + If one cluster is enabled by more than 1 endpoint, the attribute states (on/off) should be + identical across each endpoint. + To emulate the global singleton entity, this function ensures Attribute changes + are applied to all endpoint specific attribute fields. + When unify event is triggered, this function will align all shared Attribute/Command states + to the first matching entry from beginning of the endpoint list. +2) (native case in ZAP) In Matter, the Attribute configuration are endpoint specific. -### Templating API: static zcl helpers~zcl_commands(options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + -Block helper iterating over all commands. -There are two modes of this helper: -when used in a global context, it iterates over ALL commands in the database. -when used inside a `zcl_cluster` block helper, it iterates only over the commands for that cluster. +### REST API: user data~commandDefaults(db, endpointTypeIdList, sharedClusterList, packageIds) ⇒ +Get shared command defaults across endpoints. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: sharedCmdDefaults -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeIdList | \* | +| sharedClusterList | \* | +| packageIds | \* | - + -### Templating API: static zcl helpers~zcl_command_responses(options) ⇒ +### REST API: user data~writeCommandDefaults(db, defaults) +Insert command defaults into the database. -Returns all commands which are command responses. -For eg, If the xml has the following: - -then newCmdResponse will be included in the list of commands returned here. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) -There are two modes of this helper: +| Param | Type | +| --- | --- | +| db | \* | +| defaults | \* | -- when used in a global context, it iterates over ALL command responses in - the database. -- when used inside a `zcl_cluster` block helper, it iterates only over the - commands responses for that cluster. + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: all command responses +### REST API: user data~attributeDefaults(db, endpointTypeIdList, sharedClusterList, packageIds) ⇒ +Shared attribute defaults across endpoints. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: sharedAttributeDefaults - +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeIdList | \* | +| sharedClusterList | \* | +| packageIds | \* | -### Templating API: static zcl helpers~zcl_commands_with_cluster_info(options) ⇒ + -Block helper iterating over all commands with cluster information. -Note: Similar to zcl_commands but has cluster information as well. +### REST API: user data~writeAttributeDefaults(db, defaults) +Write attribute defaults. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| defaults | \* | - + -### Templating API: static zcl helpers~zcl_commands_with_arguments(options) +### REST API: user data~commandEquals(a, b) ⇒ +Compares 2 commands for equality. -Helper that retrieves all commands that contain arguments. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: boolean -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### REST API: user data~attributeEquals(a, b) ⇒ +Compares 2 attributes for equality. -### Templating API: static zcl helpers~zcl_commands_source_client(options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: boolean -Block helper iterating over all client commands. -There are two modes of this helper: -when used in a global context, it iterates over ALL client commands in the database. -when used inside a `zcl_cluster` block helper, it iterates only over the commands for that client cluster. +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### REST API: user data~httpDeleteSessionPackage(db) ⇒ +Delete the session package. - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: HTTP Response for delete operation -### Templating API: static zcl helpers~zcl_commands_source_server(options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Block helper iterating over all server commands. -There are two modes of this helper: -when used in a global context, it iterates over ALL server commands in the database. -when used inside a `zcl_cluster` block helper, it iterates only over the commands for that server cluster. + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +### REST API: user data~httpPostDuplicateEndpoint(db) ⇒ +Creating a duplicate for endpoint -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: newly created endpoint id - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: static zcl helpers~zcl_events(options) ⇒ + -Block helper iterating over all events. -There are two modes of this helper: -when used in a global context, it iterates over ALL events in the database. -when used inside a `zcl_cluster` block helper, it iterates only over the events for that cluster. +### REST API: user data~httpPostDuplicateEndpointType(db) ⇒ +Creating a duplicate for endpoint-type and endpoint-type-attributes -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: newly created endpoint-type id -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~zcl_command_tree(options) ⇒ +### REST API: user data~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId) +duplicate all clusters and attributes of an old endpoint type, using oldEndpointType id and newly created endpointType id -Block helper iterating over all commands, including their arguments and clusters. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +| Param | Type | +| --- | --- | +| db | \* | +| oldEndpointTypeId | \* | +| newEndpointTypeId | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +## Export API: Exports Data into a file. +This module provides the functionality that reads the ZAP data from a database +and exports it into a file. -### Templating API: static zcl helpers~zcl_global_commands(options) ⇒ + -Helper to iterate over all global commands. +## zap file +Formats ZAP file in a certain format. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of global command iteration. -| Param | Type | -| ------- | --------------- | -| options | \* | +* [zap file](#Format API_ Formats .module_zap file) + * [~unpackAttribute(a)](#Format API_ Formats .module_zap file..unpackAttribute) ⇒ + * [~packAttribute(a)](#Format API_ Formats .module_zap file..packAttribute) ⇒ + * [~unpackCommand(c)](#Format API_ Formats .module_zap file..unpackCommand) ⇒ + * [~packCommand(cmd)](#Format API_ Formats .module_zap file..packCommand) ⇒ + * [~unpackEvent(ev)](#Format API_ Formats .module_zap file..unpackEvent) ⇒ + * [~packEvent(ev)](#Format API_ Formats .module_zap file..packEvent) ⇒ + * [~unpackKeyValuePairs(keyValuePairs)](#Format API_ Formats .module_zap file..unpackKeyValuePairs) ⇒ + * [~packKeyValuePairs(keyValuePairs)](#Format API_ Formats .module_zap file..packKeyValuePairs) ⇒ + * [~cleanseCluster(c)](#Format API_ Formats .module_zap file..cleanseCluster) + * [~uncleanseCluster(c)](#Format API_ Formats .module_zap file..uncleanseCluster) + * [~convertToFile(state, fileFormat)](#Format API_ Formats .module_zap file..convertToFile) + * [~updateCommands(cluster, clusterToCommandMap)](#Format API_ Formats .module_zap file..updateCommands) ⇒ + * [~convertFromFile()](#Format API_ Formats .module_zap file..convertFromFile) - + -### Templating API: static zcl helpers~zcl_attributes(options) ⇒ +### zap file~unpackAttribute(a) ⇒ +Converts attribute storage string to internal representation -Iterator over the attributes. If it is used at toplevel, if iterates over all the attributes -in the database. If used within zcl_cluster context, it iterates over all the attributes -that belong to that cluster. +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: attribute object -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of attribute iteration. +| Param | Type | +| --- | --- | +| a | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### zap file~packAttribute(a) ⇒ +Converts attribute object for internal representation. -### Templating API: static zcl helpers~zcl_attributes_client(options) ⇒ +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: string -Iterator over the client attributes. If it is used at toplevel, if iterates over all the client attributes -in the database. If used within zcl_cluster context, it iterates over all the client attributes -that belong to that cluster. +| Param | Type | +| --- | --- | +| a | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of attribute iteration. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### zap file~unpackCommand(c) ⇒ +Converts command storage string to internal representation - +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: command object -### Templating API: static zcl helpers~zcl_attributes_server(options) ⇒ +| Param | Type | +| --- | --- | +| c | \* | -Iterator over the server attributes. If it is used at toplevel, if iterates over all the server attributes -in the database. If used within zcl_cluster context, it iterates over all the server attributes -that belong to that cluster. -Available Options: + -- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js) - for eg: (#zcl_attributes_server removeKeys='isOptional, isNullable') will remove 'isOptional' - from the results +### zap file~packCommand(cmd) ⇒ +Converts command object for file representation. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of attribute iteration. +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: string -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| cmd | \* | - + -### Templating API: static zcl helpers~zcl_atomics(options) ⇒ +### zap file~unpackEvent(ev) ⇒ +Convert string representation to internal object representation -Block helper iterating over all atomic types. +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: event object -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +| Param | Type | +| --- | --- | +| ev | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### zap file~packEvent(ev) ⇒ +Converts event object for file representation -### Templating API: static zcl helpers~zcl_cluster_largest_label_length() ⇒ +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: String -Given: N/A +| Param | Type | +| --- | --- | +| ev | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: the length of largest cluster name in a list of clusters - + -### Templating API: static zcl helpers~largestLabelLength(An) ⇒ +### zap file~unpackKeyValuePairs(keyValuePairs) ⇒ +Converts the key value pairs in the file into internal representation -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: the length of largest object name in an array. Helper for -zcl_cluster_largest_label_length +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: array of objects -| Param | Type | Description | -| ----- | --------------- | ----------- | -| An | \* | Array | +| Param | Type | +| --- | --- | +| keyValuePairs | \* | - + -### Templating API: static zcl helpers~zcl_command_arguments_count(commandId) ⇒ +### zap file~packKeyValuePairs(keyValuePairs) ⇒ +Packs key value pairs for extenrnal representation -Helper to extract the number of command arguments in a command +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: none -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Number of command arguments as an integer +| Param | Type | +| --- | --- | +| keyValuePairs | \* | -| Param | Type | -| --------- | --------------- | -| commandId | \* | + - +### zap file~cleanseCluster(c) +Cleanses toplevel cluster data. -### Templating API: static zcl helpers~ifCommandArgumentsHaveFixedLengthWithCurrentContext(commandId, fixedLengthReturn, notFixedLengthReturn, currentContext) +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +| Param | Type | +| --- | --- | +| c | \* | -| Param | Description | -| -------------------- | ----------------------------------------------------------------------------------------------------- | -| commandId | | -| fixedLengthReturn | | -| notFixedLengthReturn | | -| currentContext | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not | + - +### zap file~uncleanseCluster(c) +Uncleanses the toplevel cluster data. -### Templating API: static zcl helpers~if_command_arguments_have_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn) +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +| Param | Type | +| --- | --- | +| c | \* | -| Param | Description | -| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| commandId | | -| fixedLengthReturn | | -| notFixedLengthReturn | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not. Does not check if command arguments are always present or not. | + - +### zap file~convertToFile(state, fileFormat) +This function gets the state from database and converts it for a given file format. -### Templating API: static zcl helpers~as_underlying_zcl_type_command_is_not_fixed_length_but_command_argument_is_always_present(type, command, commandArg, appendString, options) ⇒ +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: the underlying zcl type of a command argument if the argument is -not fixed length but is always present. If the condition is not met then -returns an empty string. +| Param | Type | +| --- | --- | +| state | \* | +| fileFormat | \* | -| Param | -| ------------ | -| type | -| command | -| commandArg | -| appendString | -| options | + - +### zap file~updateCommands(cluster, clusterToCommandMap) ⇒ +Updates the clusters with the new command format where there is isIncoming +and isEnabled instead of incoming and outgoing -### Templating API: static zcl helpers~as_underlying_zcl_type_if_command_is_not_fixed_length(type, commandId, appendString, options) +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) +**Returns**: state or null -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +| Param | Type | +| --- | --- | +| cluster | \* | +| clusterToCommandMap | \* | -| Param | Description | -| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| type | | -| commandId | | -| appendString | | -| options | Returns: Given the commandId and the type of one of its arguments, based on whether the command is fixed length or not either return nothing or return the underlying zcl type appended with the appendString. | + - +### zap file~convertFromFile() +This function gets the JSON from the file, and converts it to the correct database state -### Templating API: static zcl helpers~command_arguments_total_length(commandId) +**Kind**: inner method of [zap file](#Format API_ Formats .module_zap file) + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +## Import API: Imports data from a file. +This module provides the functionality that reads a .isc file -| Param | Description | -| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| commandId | Returns the size of the command by calculating the sum total of the command arguments Note: This helper should be called on fixed length commands only. It should not be called with commands which do not have a fixed length. | + - +## Import API: Imports data from a file. +This module provides the functionality that reads a .json(.zap) file -### Templating API: static zcl helpers~zcl_command_arguments(options) ⇒ + -Block helper iterating over command arguments within a command -or a command tree. +## Import API: Imports data from a file. +This file provides the functionality that reads the ZAP data from a JSON file +and imports it into a database. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of command argument iteration. + -| Param | Type | -| ------- | --------------- | -| options | \* | +## Timer API: initializes times. +This module provides the APIs for initializing timers specifically +for sessions. - + -### Templating API: static zcl helpers~zcl_event_fields(options) +## Startup API: initializes times. +This file contains various startup modes. -Block helper iterating over the event fields inside an event. + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +## watchdog API: initializes times. +This file contains watchdogs. -| Param | Type | -| ------- | --------------- | -| options | \* | + - +## REST API: admin functions +This module provides the REST API to the admin functions. -### Templating API: static zcl helpers~zcl_command_argument_data_type(typeName, options) -Helper that deals with the type of the argument. +* [REST API: admin functions](#module_REST API_ admin functions) + * [~httpPostSql(db, app)](#module_REST API_ admin functions..httpPostSql) ⇒ + * [~httpGetVersion(db)](#module_REST API_ admin functions..httpGetVersion) ⇒ + * [~httpGetCache(db)](#module_REST API_ admin functions..httpGetCache) -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) + -| Param | Type | -| -------- | --------------- | -| typeName | \* | -| options | \* | +### REST API: admin functions~httpPostSql(db, app) ⇒ +API: /sql +Request JSON: +
    +  {
    +    sql: SQL Query
    +  }
    +
    - +Response JSON: +
    +  {
    +    result: Array of rows.
    +  }
    +
    -### Templating API: static zcl helpers~asUnderlyingZclType(typeName, options) +**Kind**: inner method of [REST API: admin functions](#module_REST API_ admin functions) +**Returns**: callback for the express uri registration -Helper that deals with the type of the argument. +| Param | Type | +| --- | --- | +| db | \* | +| app | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) + -| Param | Type | Description | -| -------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| typeName | \* | | -| options | \* | Note: If the options has zclCharFormatter set to true then the function will return the user defined data associated with the zcl data type and not the actual data type. example: {{asUnderlyingZclType [array type] array="b" one_byte="u" two_byte="v" three_byte="x" four_byte="w" short_string="s" long_string="l" default="b" zclCharFormatter="true"}} For the above if asUnderlyingZclType was given [array type] then the above will return 'b' | +### REST API: admin functions~httpGetVersion(db) ⇒ +API: /version +Response JSON: +
    +  {
    +    version: full version.
    +    featureLevel: feature level.
    +    hash: git hash code
    +    timestamp: Unix time from the last commit in the repo.
    +    date: Date of the last commit in the repo.
    +  }
    +
    - +**Kind**: inner method of [REST API: admin functions](#module_REST API_ admin functions) +**Returns**: callback for the express uri registration. -### Templating API: static zcl helpers~zcl_string_type_return(type, options) +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) + -| Param | Description | -| ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| type | | -| options | Returns the data mentioned in the helper options based on whether the type is short string, long string or not a string Example: {{zcl_string_type_return type short_string="short string output" long_string="short string output" default="Output when not a string") | +### REST API: admin functions~httpGetCache(db) +API: /cache +Response JSON: +
    +	 {
    +     keys: 0,    // global key count
    +     hits: 0,    // global hit count
    +     misses: 0,  // global miss count
    +     ksize: 0,   // global key size count in approximately bytes
    +     vsize: 0    // global value size count in approximately bytes
    +	 }
    +
    - +**Kind**: inner method of [REST API: admin functions](#module_REST API_ admin functions) -### Templating API: static zcl helpers~is_zcl_string(type) +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) + -| Param | Description | -| ----- | ------------------------------------------------------------------- | -| type | Return: true or false based on whether the type is a string or not. | +## REST API: endpoint +This module provides the REST API to the user specific data. - -### Templating API: static zcl helpers~if_is_number(type) ⇒ +* [REST API: endpoint](#module_REST API_ endpoint) + * [~httpDeleteEndpoint(db)](#module_REST API_ endpoint..httpDeleteEndpoint) ⇒ + * [~httpDeleteEndpointType(db)](#module_REST API_ endpoint..httpDeleteEndpointType) ⇒ + * [~httpPostEndpoint(db)](#module_REST API_ endpoint..httpPostEndpoint) ⇒ + * [~httpPatchEndpoint(db)](#module_REST API_ endpoint..httpPatchEndpoint) ⇒ + * [~httpPostEndpointType(db)](#module_REST API_ endpoint..httpPostEndpointType) ⇒ + * [~httpPatchEndpointType(db)](#module_REST API_ endpoint..httpPatchEndpointType) ⇒ -If helper that checks if a type is a string + -example: -{{#if_is_number type}} -type is number -{{else}} -type is not number -{{/if_is_number}} +### REST API: endpoint~httpDeleteEndpoint(db) ⇒ +HTTP DELETE: endpoint -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: endpoint](#module_REST API_ endpoint) +**Returns**: callback for the express uri registration -| Param | Type | -| ----- | --------------- | -| type | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~if_is_string(type) ⇒ +### REST API: endpoint~httpDeleteEndpointType(db) ⇒ +HTTP DELETE: endpoint type -If helper that checks if a type is a string +**Kind**: inner method of [REST API: endpoint](#module_REST API_ endpoint) +**Returns**: callback for the express uri registration -example: -{{#if_is_string type}} -type is string -{{else}} -type is not string -{{/if_is_string}} +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | -| ----- | --------------- | -| type | \* | +### REST API: endpoint~httpPostEndpoint(db) ⇒ +HTTP POST: endpoint - +**Kind**: inner method of [REST API: endpoint](#module_REST API_ endpoint) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~if_is_char_string(type) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -If helper that checks if a string type is present in the list of char strings -i.e. characterStringTypes + -example: -{{#if_is_char_string type}} -type is char string -{{else}} -type is not char string -{{/if_is_char_string}} +### REST API: endpoint~httpPatchEndpoint(db) ⇒ +HTTP POST: endpoint -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: endpoint](#module_REST API_ endpoint) +**Returns**: callback for the express uri registration -| Param | Type | -| ----- | --------------- | -| type | \* | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Main database to use for the operation. | - + -### Templating API: static zcl helpers~if_is_octet_string(type) ⇒ +### REST API: endpoint~httpPostEndpointType(db) ⇒ +HTTP POST endpoint type -If helper that checks if a string type is present in the list of octet strings -i.e. octetStringTypes +**Kind**: inner method of [REST API: endpoint](#module_REST API_ endpoint) +**Returns**: callback for the express uri registration -example: -{{#if_is_octet_string type}} -type is octet string -{{else}} -type is not octet string -{{/if_is_octet_string}} +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | -| ----- | --------------- | -| type | \* | +### REST API: endpoint~httpPatchEndpointType(db) ⇒ +HTTP POST: endpoint type update - +**Kind**: inner method of [REST API: endpoint](#module_REST API_ endpoint) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~if_is_short_string(type) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -If helper that checks if a string type is present in the list of short strings -i.e. stringShortTypes + -example: -{{#if_is_short_string type}} -type is short string -{{else}} -type is not short string -{{/if_is_short_string}} +## External IDE interface. +This module provides the interface to an extenal IDE: Simplicity Studio. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | -| ----- | --------------- | -| type | \* | +## REST API: generation functions +This module provides the REST API to the generation. - -### Templating API: static zcl helpers~if_is_long_string(type) ⇒ +* [REST API: generation functions](#module_REST API_ generation functions) + * [~httpGetPreviewNameIndex(db)](#module_REST API_ generation functions..httpGetPreviewNameIndex) ⇒ + * [~httpGetPreviewName(db)](#module_REST API_ generation functions..httpGetPreviewName) ⇒ + * [~httpGetPreview(db)](#module_REST API_ generation functions..httpGetPreview) ⇒ + * [~httpPutGenerate(db)](#module_REST API_ generation functions..httpPutGenerate) ⇒ + * [~httpGetComponentTree(db)](#module_REST API_ generation functions..httpGetComponentTree) ⇒ + * [~httpPostComponentUpdateHandler(db, request, response, add)](#module_REST API_ generation functions..httpPostComponentUpdateHandler) + * [~httpPostComponentAdd(db)](#module_REST API_ generation functions..httpPostComponentAdd) + * [~httpPostComponentRemove(db)](#module_REST API_ generation functions..httpPostComponentRemove) ⇒ -If helper that checks if a string type is present in the list of long strings -i.e. stringLongTypes + -example: -{{#if_is_long_string type}} -type is long string -{{else}} -type is not long string -{{/if_is_long_string}} +### REST API: generation functions~httpGetPreviewNameIndex(db) ⇒ +HTTP GET: preview single file with index. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -| Param | Type | -| ----- | --------------- | -| type | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~if_is_atomic(type:) ⇒ +### REST API: generation functions~httpGetPreviewName(db) ⇒ +HTTP GET: Preview a single file. -If helper that checks if a type is an atomic +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -example: -{{#if_is_atomic type}} -type is atomic -{{else}} -type is not atomic -{{/if_is_atomic}} +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | Description | -| ----- | --------------- | ----------- | -| type: | \* | string | +### REST API: generation functions~httpGetPreview(db) ⇒ +HTTP GET: total preview object. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~if_is_bitmap(type) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -If helper that checks if a type is a bitmap + -example: -{{#if_is_bitmap type}} -type is bitmap -{{else}} -type is not bitmap -{{/if_is_bitmap}} +### REST API: generation functions~httpPutGenerate(db) ⇒ +HTTP PUT: performs local generation into a specified directory. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -| Param | Type | -| ----- | --------------- | -| type | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~if_is_enum(type) ⇒ +### REST API: generation functions~httpGetComponentTree(db) ⇒ +Get component tree. -If helper that checks if a type is an enum +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: Response data -- example: - {{#if_is_enum type}} - type is enum - {{else}} - type is not enum - {{/if_is_enum}} +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. + -| Param | Type | -| ----- | --------------- | -| type | \* | +### REST API: generation functions~httpPostComponentUpdateHandler(db, request, response, add) +Update component. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) -### Templating API: static zcl helpers~if_is_struct(type) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| request | \* | +| response | \* | +| add | \* | -If helper that checks if a type is an struct + -- example: - {{#if_is_struct type}} - type is struct - {{else}} - type is not struct - {{/if_is_struct}} +### REST API: generation functions~httpPostComponentAdd(db) +Enable components by 'componentId' or corresponding components specified, via 'defaults', by 'clusterId' / 'roles' -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content. +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) -| Param | -| ----- | -| type | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~isClient(side) ⇒ +### REST API: generation functions~httpPostComponentRemove(db) ⇒ +Remove component. -Checks if the side is client or not +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: Promise of component removed -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: boolean +| Param | Type | +| --- | --- | +| db | \* | -| Param | Type | -| ----- | --------------- | -| side | \* | + - +## REST API: generation functions +This module provides the REST API to the IDE component handling. -### Templating API: static zcl helpers~isServer(side) ⇒ -Checks if the side is server or not +* [REST API: generation functions](#module_REST API_ generation functions) + * [~httpGetPreviewNameIndex(db)](#module_REST API_ generation functions..httpGetPreviewNameIndex) ⇒ + * [~httpGetPreviewName(db)](#module_REST API_ generation functions..httpGetPreviewName) ⇒ + * [~httpGetPreview(db)](#module_REST API_ generation functions..httpGetPreview) ⇒ + * [~httpPutGenerate(db)](#module_REST API_ generation functions..httpPutGenerate) ⇒ + * [~httpGetComponentTree(db)](#module_REST API_ generation functions..httpGetComponentTree) ⇒ + * [~httpPostComponentUpdateHandler(db, request, response, add)](#module_REST API_ generation functions..httpPostComponentUpdateHandler) + * [~httpPostComponentAdd(db)](#module_REST API_ generation functions..httpPostComponentAdd) + * [~httpPostComponentRemove(db)](#module_REST API_ generation functions..httpPostComponentRemove) ⇒ -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: boolean + -| Param | Type | -| ----- | --------------- | -| side | \* | +### REST API: generation functions~httpGetPreviewNameIndex(db) ⇒ +HTTP GET: preview single file with index. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~as_underlying_zcl_type_command_argument_always_present(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: A string as an underlying zcl type if the command is not fixed length and the command -argument is always present in all zcl specifications. + -| Param | Description | -| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| type: | type of argument | -| commandId: | command id | -| appendString: | append the string to the argument | -| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | -| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | -| presentIf: | If the command argument is present conditionally then this will be a condition and not null | -| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | +### REST API: generation functions~httpGetPreviewName(db) ⇒ +HTTP GET: Preview a single file. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~if_command_argument_always_present(commandId, introducedInRef, removedInRef, presentIf, argumentPresentReturn, argumentNotPresentReturn) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: argumentPresentReturn if the command is not fixed length and command -argument is always present without conditions(introducedInRef, removedInRef, -presentIf) else returns argumentNotPresentReturn + -| Param | -| ------------------------ | -| commandId | -| introducedInRef | -| removedInRef | -| presentIf | -| argumentPresentReturn | -| argumentNotPresentReturn | +### REST API: generation functions~httpGetPreview(db) ⇒ +HTTP GET: total preview object. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~as_underlying_zcl_type_command_argument_not_always_present_no_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: A string as an underlying zcl type if the command is not fixed length, the command -argument is not always present in all zcl specifications and there is no present if conditionality -on the command argument. + -| Param | Description | -| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| type: | type of argument | -| commandId: | command id | -| appendString: | append the string to the argument | -| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | -| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | -| presentIf: | If the command argument is present conditionally then this will be a condition and not null | -| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | +### REST API: generation functions~httpPutGenerate(db) ⇒ +HTTP PUT: performs local generation into a specified directory. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~as_underlying_zcl_type_ca_not_always_present_no_presentif(commandArg, appendString, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: A string as an underlying zcl type if the command is not fixed -length, the command argument is not always present in all zcl specifications -and there is no present if conditionality on the command argument. + -| Param | Description | -| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| commandArg | command argument | -| appendString | append the string to the argument | -| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | +### REST API: generation functions~httpGetComponentTree(db) ⇒ +Get component tree. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: Response data -### Templating API: static zcl helpers~if_command_argument_not_always_present_no_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsReturn, argumentInAllVersionsReturn) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: argumentNotInAllVersionsReturn if the command is not fixed length and command -argument is present with conditions introducedInRef or removedInRef but no presentIf -conditions else returns argumentNotPresentReturn + -| Param | -| ------------------------------ | -| commandId | -| introducedInRef | -| removedInRef | -| presentIf | -| argumentNotInAllVersionsReturn | -| argumentInAllVersionsReturn | +### REST API: generation functions~httpPostComponentUpdateHandler(db, request, response, add) +Update component. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) -### Templating API: static zcl helpers~as_underlying_zcl_type_command_argument_not_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| request | \* | +| response | \* | +| add | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: A string as an underlying zcl type if the command is not fixed length, the command -argument is not always present in all zcl specifications and there is a present if conditionality -on the command argument. + -| Param | Description | -| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| type: | type of argument | -| commandId: | command id | -| appendString: | append the string to the argument | -| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | -| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | -| presentIf: | If the command argument is present conditionally then this will be a condition and not null | -| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | +### REST API: generation functions~httpPostComponentAdd(db) +Enable components by 'componentId' or corresponding components specified, via 'defaults', by 'clusterId' / 'roles' - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) -### Templating API: static zcl helpers~as_underlying_zcl_type_ca_not_always_present_with_presentif(commandArg, appendString, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: A string as an underlying zcl type if the command is not fixed -length, the command argument is not always present in all zcl specifications -but there is a present if conditionality on the command argument. + -| Param | Description | -| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| commandArg | command argument | -| appendString | append the string to the argument | -| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | +### REST API: generation functions~httpPostComponentRemove(db) ⇒ +Remove component. - +**Kind**: inner method of [REST API: generation functions](#module_REST API_ generation functions) +**Returns**: Promise of component removed -### Templating API: static zcl helpers~if_command_argument_not_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: argumentNotInAllVersionsReturn if the command is not fixed length, command -argument is present with conditions introducedInRef or removedInRef and presentIf -conditions exist as well else returns argumentNotPresentReturn + -| Param | -| --------------------------------------- | -| commandId | -| introducedInRef | -| removedInRef | -| presentIf | -| argumentNotInAllVersionsPresentIfReturn | -| argumentInAllVersionsReturn | +## REST API: initialization functions +This module provides the REST API to the session initialization - -### Templating API: static zcl helpers~as_underlying_zcl_type_command_argument_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +* [REST API: initialization functions](#module_REST API_ initialization functions) + * [~sessionAttempt(db)](#module_REST API_ initialization functions..sessionAttempt) ⇒ + * [~sessionCreate(db)](#module_REST API_ initialization functions..sessionCreate) ⇒ + * [~initializeSession(db, options:)](#module_REST API_ initialization functions..initializeSession) ⇒ + * [~loadPreviousSessions(db)](#module_REST API_ initialization functions..loadPreviousSessions) ⇒ + * [~init(db)](#module_REST API_ initialization functions..init) ⇒ -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: A string as an underlying zcl type if the command is not fixed length, the command -argument is always present in all zcl specifications and there is a present if conditionality -on the command argument. + -| Param | Description | -| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| type: | type of argument | -| commandId: | command id | -| appendString: | append the string to the argument | -| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | -| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | -| presentIf: | If the command argument is present conditionally then this will be a condition and not null | -| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | +### REST API: initialization functions~sessionAttempt(db) ⇒ +This function returns Properties, Templates and Dirty-Sessions - +**Kind**: inner method of [REST API: initialization functions](#module_REST API_ initialization functions) +**Returns**: An async function that handles HTTP requests -### Templating API: static zcl helpers~as_underlying_zcl_type_ca_always_present_with_presentif(commandArg, appendString, options) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: A string as an underlying zcl type if the command is not fixed -length, the command argument is always present in all zcl specifications -but there is a present if conditionality on the command argument. + -| Param | Description | -| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| commandArg | command argument | -| appendString | append the string to the argument | -| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | +### REST API: initialization functions~sessionCreate(db) ⇒ +This function creates a new session. - +**Kind**: inner method of [REST API: initialization functions](#module_REST API_ initialization functions) +**Returns**: An async function that handles HTTP requests. The function extracts session parameters from the request, +ensures the user and session exist in the database, and populates the session options with the provided packages. -### Templating API: static zcl helpers~if_command_argument_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: argumentInAllVersionsPresentIfReturn if the command is not fixed length, command -argument is always present and presentIf conditions exist else returns argumentNotPresentReturn + -| Param | -| --------------------------------------- | -| commandId | -| introducedInRef | -| removedInRef | -| presentIf | -| argumentNotInAllVersionsPresentIfReturn | -| argumentInAllVersionsReturn | +### REST API: initialization functions~initializeSession(db, options:) ⇒ +This function creates a new session with its packages according to selected Properties and Templates - +**Kind**: inner method of [REST API: initialization functions](#module_REST API_ initialization functions) +**Returns**: A success message. -### Templating API: static zcl helpers~if_manufacturing_specific_cluster(clusterId, manufacturer_specific_return, null_manufacturer_specific_return) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| options: | \* | object containing 'zcl' and 'template' | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: manufacturer_specific_return if the cluster is manufacturer -specific or returns null_manufacturer_specific_return if cluster is -not manufacturer specific. + -| Param | Type | -| --------------------------------- | --------------- | -| clusterId | \* | -| manufacturer_specific_return | \* | -| null_manufacturer_specific_return | \* | +### REST API: initialization functions~loadPreviousSessions(db) ⇒ +This function reloads previous session by user selected session's id - +**Kind**: inner method of [REST API: initialization functions](#module_REST API_ initialization functions) +**Returns**: A success message. -### Templating API: static zcl helpers~if_mfg_specific_cluster(clusterId, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -If helper which checks if cluster is manufacturing specific or not -example: -{{#if_mfg_specific_cluster clusterId}} -cluster is manufacturing specific -{{else}} -cluster is not manufacturing specific -{{/if_mfg_specific_cluster}} + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Returns content in the handlebar template based on whether the -command is manufacturing specific or not. +### REST API: initialization functions~init(db) ⇒ +Init function from the App.vue -| Param | -| --------- | -| clusterId | -| options | +**Kind**: inner method of [REST API: initialization functions](#module_REST API_ initialization functions) +**Returns**: A success message. - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: static zcl helpers~as_generated_default_macro(value, attributeSize, options) ⇒ + -Given the value and size of an attribute along with endian as an option. -This helper returns the attribute value as big/little endian. -Example: {{as_generated_default_macro 0x00003840 4 endian="big"}} -will return: 0x00, 0x00, 0x38, 0x40, +## REST API: static zcl functions +This module provides the REST API to the static zcl queries. -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Formatted attribute value based on given arguments -Available options: -- endian: Specify 'big' or 'little' endian format -- isCommaTerminated: '0' or '1' for output to have a ',' at the end +* [REST API: static zcl functions](#module_REST API_ static zcl functions) + * [~zclEntityQuery(selectAllFunction, selectByIdFunction)](#module_REST API_ static zcl functions..zclEntityQuery) ⇒ + * [~returnZclEntitiesForClusterId(db, clusterId, packageId)](#module_REST API_ static zcl functions..returnZclEntitiesForClusterId) ⇒ + * [~mergeZclClusterAttributeCommandEventData(accumulated, currentValue)](#module_REST API_ static zcl functions..mergeZclClusterAttributeCommandEventData) ⇒ + * [~reduceAndConcatenateZclEntity(db, id, packageIdArray, zclQueryCallback, mergeFunction, defaultValue)](#module_REST API_ static zcl functions..reduceAndConcatenateZclEntity) ⇒ + * [~parseForZclData(db, entity, id, packageIdArray)](#module_REST API_ static zcl functions..parseForZclData) ⇒ + * [~httpGetZclEntity(app)](#module_REST API_ static zcl functions..httpGetZclEntity) + * [~httpGetZclExtension(db)](#module_REST API_ static zcl functions..httpGetZclExtension) ⇒ -| Param | -| ------------- | -| value | -| attributeSize | -| options | + - +### REST API: static zcl functions~zclEntityQuery(selectAllFunction, selectByIdFunction) ⇒ +This function builds a function that has the following skeleton. +This is used to simplify all the logic where we have selectAll and selectById for +each of the different ZCL entities. -### Templating API: static zcl helpers~attribute_mask(writable, storageOption, minMax, mfgSpecific, clusterCode, client, isSingleton, prefixString, postfixString) ⇒ +**Kind**: inner method of [REST API: static zcl functions](#module_REST API_ static zcl functions) +**Returns**: a certain function based on given arguments to them. -Given the attributes of a zcl attribute. Creates an attribute mask based on -the given options -Available options: -isClusterCodeMfgSpecific: 0/1, This is to determine if cluster code needs to -be used to determine if a cluster is mfg specific or not. +| Param | Type | +| --- | --- | +| selectAllFunction | \* | +| selectByIdFunction | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: attribute mask based on given values - -| Param | -| ------------- | -| writable | -| storageOption | -| minMax | -| mfgSpecific | -| clusterCode | -| client | -| isSingleton | -| prefixString | -| postfixString | + - +### REST API: static zcl functions~returnZclEntitiesForClusterId(db, clusterId, packageId) ⇒ +For the CLUSTER path, we have special handling to also sideload attributes and commands relevant to that cluster. -### Templating API: static zcl helpers~command_mask(commmandSource, clusterSide, isIncomingEnabled, isOutgoingEnabled, manufacturingCode, prefixForMask) ⇒ +**Kind**: inner method of [REST API: static zcl functions](#module_REST API_ static zcl functions) +**Returns**: zcl entities -Given the attributes of a zcl command. Creates a command mask based on -the given options +| Param | Type | +| --- | --- | +| db | \* | +| clusterId | \* | +| packageId | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: command mask based on given values + -| Param | -| ----------------- | -| commmandSource | -| clusterSide | -| isIncomingEnabled | -| isOutgoingEnabled | -| manufacturingCode | -| prefixForMask | +### REST API: static zcl functions~mergeZclClusterAttributeCommandEventData(accumulated, currentValue) ⇒ +This is the special merge function used for the CLUSTER path - +**Kind**: inner method of [REST API: static zcl functions](#module_REST API_ static zcl functions) +**Returns**: ZCL entity details object -### Templating API: static zcl helpers~command_mask_sub_helper(commandMask, str) ⇒ +| Param | Type | +| --- | --- | +| accumulated | \* | +| currentValue | \* | -A Sub helper api for command_mask to reduce code redundancy + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: command mask addition based on the arguments +### REST API: static zcl functions~reduceAndConcatenateZclEntity(db, id, packageIdArray, zclQueryCallback, mergeFunction, defaultValue) ⇒ +This maps over each packageId, and runs the query callback. -| Param | -| ----------- | -| commandMask | -| str | +**Kind**: inner method of [REST API: static zcl functions](#module_REST API_ static zcl functions) +**Returns**: zcl entities - +| Param | Type | +| --- | --- | +| db | \* | +| id | \* | +| packageIdArray | \* | +| zclQueryCallback | \* | +| mergeFunction | \* | +| defaultValue | \* | -### Templating API: static zcl helpers~format_zcl_string_as_characters_for_generated_defaults(stringVal, sizeOfString) ⇒ + -This may be used within all_user_cluster_attributes_for_generated_defaults -for example: -{{format_zcl_string_as_characters_for_generated_defaults 'abc' 5}} -will return as follows: -3, 'a', 'b', 'c' 0, 0 +### REST API: static zcl functions~parseForZclData(db, entity, id, packageIdArray) ⇒ +Get entity details absed on given information. -Available Options: +**Kind**: inner method of [REST API: static zcl functions](#module_REST API_ static zcl functions) +**Returns**: Promise of entity details -- isOctet: 0/1 can be used to return results correctly for octet strings -- isCommaTerminated: 0/1 can be used to return result with/without ',' at - the end +| Param | Type | +| --- | --- | +| db | \* | +| entity | \* | +| id | \* | +| packageIdArray | \* | -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Formatted string for generated defaults starting with the lenth of a -string then each character and then filler for the size allocated for the -string. Long strings prefixed by 2 byte length field. + -| Param | -| ------------ | -| stringVal | -| sizeOfString | +### REST API: static zcl functions~httpGetZclEntity(app) +API: /zcl/:entity/:id - +**Kind**: inner method of [REST API: static zcl functions](#module_REST API_ static zcl functions) -### Templating API: static zcl helpers~as_type_min_value(type, options) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| app | \* | Express instance. | -Given a zcl data type return the min allowed value for that zcl data type -based on the language specified in the options + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: max allowed value for the given zcl data type -Available Options: +### REST API: static zcl functions~httpGetZclExtension(db) ⇒ +API: /zclExtension/:entity/:extension -- language: determines the output of the helper based on language - for eg: (as_type_min_value language='c++') will give the output specific to - the c++ language. - Note: If language is not specified then helper throws an error. +**Kind**: inner method of [REST API: static zcl functions](#module_REST API_ static zcl functions) +**Returns**: zcl extension handler -| Param | Type | -| ------- | --------------- | -| type | \* | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~as_type_max_value(type, options) ⇒ +## REST API: user data +This module provides the REST API to the user specific data. -Given a zcl data type return the max allowed value for that zcl data type -based on the language specified in the options -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: max allowed value for the given zcl data type -Available Options: +* [REST API: user data](#module_REST API_ user data) + * [~getComponentIdsByCluster(db, sessionId, clusterId, side)](#module_REST API_ user data..getComponentIdsByCluster) ⇒ \* + * [~httpGetSessionKeyValues(db)](#module_REST API_ user data..httpGetSessionKeyValues) ⇒ + * [~httpGetEndpointIds(db)](#module_REST API_ user data..httpGetEndpointIds) ⇒ + * [~httpGetDeviceTypeFeatures(db)](#module_REST API_ user data..httpGetDeviceTypeFeatures) ⇒ + * [~httpGetSessionNotifications(db)](#module_REST API_ user data..httpGetSessionNotifications) ⇒ + * [~httpDeleteSessionNotification(db)](#module_REST API_ user data..httpDeleteSessionNotification) ⇒ + * [~httpGetPackageNotifications(db)](#module_REST API_ user data..httpGetPackageNotifications) ⇒ + * [~httpGetPackageNotificationsByPackageId(db)](#module_REST API_ user data..httpGetPackageNotificationsByPackageId) ⇒ + * [~httpDeletePackageNotification(db)](#module_REST API_ user data..httpDeletePackageNotification) ⇒ + * [~httpGetUnseenNotificationCount(db)](#module_REST API_ user data..httpGetUnseenNotificationCount) ⇒ + * [~httpGetUnseenNotificationAndUpdate(db)](#module_REST API_ user data..httpGetUnseenNotificationAndUpdate) ⇒ + * [~httpPostSaveSessionKeyValue(db)](#module_REST API_ user data..httpPostSaveSessionKeyValue) ⇒ + * [~httpPostCluster(db)](#module_REST API_ user data..httpPostCluster) ⇒ + * [~httpPostForcedExternal(db)](#module_REST API_ user data..httpPostForcedExternal) ⇒ function + * [~httpPostAttributeUpdate(db)](#module_REST API_ user data..httpPostAttributeUpdate) ⇒ + * [~httpPostCommandUpdate(db)](#module_REST API_ user data..httpPostCommandUpdate) ⇒ + * [~httpPostEventUpdate(db)](#module_REST API_ user data..httpPostEventUpdate) ⇒ + * [~httpGetInitialState(db)](#module_REST API_ user data..httpGetInitialState) ⇒ + * [~httpGetOption(db)](#module_REST API_ user data..httpGetOption) ⇒ + * [~httpGetUiOptions(db)](#module_REST API_ user data..httpGetUiOptions) ⇒ + * [~httpGetPackages()](#module_REST API_ user data..httpGetPackages) + * [~httpGetAllPackages()](#module_REST API_ user data..httpGetAllPackages) + * [~httpPostAddNewPackage()](#module_REST API_ user data..httpPostAddNewPackage) + * [~httpPostShareClusterStatesAcrossEndpoints()](#module_REST API_ user data..httpPostShareClusterStatesAcrossEndpoints) + * [~commandDefaults(db, endpointTypeIdList, sharedClusterList, packageIds)](#module_REST API_ user data..commandDefaults) ⇒ + * [~writeCommandDefaults(db, defaults)](#module_REST API_ user data..writeCommandDefaults) + * [~attributeDefaults(db, endpointTypeIdList, sharedClusterList, packageIds)](#module_REST API_ user data..attributeDefaults) ⇒ + * [~writeAttributeDefaults(db, defaults)](#module_REST API_ user data..writeAttributeDefaults) + * [~commandEquals(a, b)](#module_REST API_ user data..commandEquals) ⇒ + * [~attributeEquals(a, b)](#module_REST API_ user data..attributeEquals) ⇒ + * [~httpDeleteSessionPackage(db)](#module_REST API_ user data..httpDeleteSessionPackage) ⇒ + * [~httpPostDuplicateEndpoint(db)](#module_REST API_ user data..httpPostDuplicateEndpoint) ⇒ + * [~httpPostDuplicateEndpointType(db)](#module_REST API_ user data..httpPostDuplicateEndpointType) ⇒ + * [~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId)](#module_REST API_ user data..duplicateEndpointTypeClusters) -- language: determines the output of the helper based on language - for eg: (as_type_max_value language='c++') will give the output specific to - the c++ language. - Note: If language is not specified then the helper returns size of type in - bits. + -| Param | Type | -| ------- | --------------- | -| type | \* | -| options | \* | +### REST API: user data~getComponentIdsByCluster(db, sessionId, clusterId, side) ⇒ \* +Promise that return a list of component Ids required by a specific cluster - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: \* - array of componentIds -### Templating API: static zcl helpers~structs_with_clusters(options) +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| clusterId | \* | +| side | \* | -Returns all structs which have clusters associated with them + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) +### REST API: user data~httpGetSessionKeyValues(db) ⇒ +HTTP GET: session key values -| Param | Type | Description | -| ------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| options | \* | Available Options: - groupByStructName: Can group the query results based on struct name for structs which are present in more than one cluster eg Usage: {{#structs_with_clusters groupByStructName=1}}{{/structs_with_clusters}} | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: static zcl helpers~as_zcl_type_size(type, options) ⇒ + -Returns the size of the zcl type if possible else returns -1 +### REST API: user data~httpGetEndpointIds(db) ⇒ +HTTP GET: endpoint ids of endpoints within a specified session -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: size of zcl type +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -| Param | Type | -| ------- | --------------- | -| type | \* | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### Templating API: static zcl helpers~if_compare(leftValue, rightValue, options) ⇒ Object +### REST API: user data~httpGetDeviceTypeFeatures(db) ⇒ +HTTP GET: device type features -An if helper for comparisons +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Object - Promise of content -example: checking if (4 < 5) -(if_compare 4 5 operator='<') -Content when comparison returns true +| Param | Type | +| --- | --- | +| db | \* | -Content when comparison returns false -(/if_compare) + -| Param | Type | -| ---------- | --------------- | -| leftValue | \* | -| rightValue | \* | -| options | \* | +### REST API: user data~httpGetSessionNotifications(db) ⇒ +HTTP GET: session get notifications - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -### Templating API: static zcl helpers~if_is_data_type_signed(type, clusterId, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Check if the given type is signed or not based on the type name and cluster -id. -Note: This helper needs to be used under a block helper which has a -reference to clusterId. + -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: Promise of content +### REST API: user data~httpDeleteSessionNotification(db) ⇒ +HTTP DELETE: session delete notifications -| Param | Type | -| --------- | --------------- | -| type | \* | -| clusterId | \* | -| options | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### Templating API: static zcl helpers~as_zcl_data_type_size(type, clusterId, options) ⇒ + -Fetches the size of the data type based on type name and cluster id given -Note: +### REST API: user data~httpGetPackageNotifications(db) ⇒ +HTTP GET: package get notifications -- Size is zero for structs -- This helper needs to be used under a block helper which has a - reference to clusterId. - Available Options: -- roundUpToPowerOfTwo: Rounds the size up to the nearest power of 2 -- sizeIn: By default size is returned in bytes but it can be returned in bits - by mentioning sizeIn="bits" +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [Templating API: static zcl helpers](#module*Templating API* static zcl helpers) -**Returns**: size of the data type +| Param | Type | +| --- | --- | +| db | \* | -| Param | Type | -| --------- | --------------- | -| type | \* | -| clusterId | \* | -| options | \* | + - +### REST API: user data~httpGetPackageNotificationsByPackageId(db) ⇒ +HTTP GET: package get notifications -## Templating API: Overridable functions. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} +| Param | Type | +| --- | --- | +| db | \* | - + -## JS API: generator logic +### REST API: user data~httpDeletePackageNotification(db) ⇒ +HTTP DELETE: session delete notifications -- [JS API: generator logic](#module*JS API* generator logic) - - [~loadGenTemplateFromFile(path)](#module*JS API* generator logic..loadGenTemplateFromFile) ⇒ - - [~recordTemplatesPackage(context)](#module*JS API* generator logic..recordTemplatesPackage) ⇒ - - [~decodePackageExtensionEntity(entityType, entity)](#module*JS API* generator logic..decodePackageExtensionEntity) ⇒ - - [~loadZclExtensions(zclExt)](#module*JS API* generator logic..loadZclExtensions) ⇒ - - [~loadTemplates(db, genTemplatesJsonArray)](#module*JS API* generator logic..loadTemplates) - - [~loadGenTemplatesJsonFile(db, genTemplatesJson)](#module*JS API* generator logic..loadGenTemplatesJsonFile) ⇒ - - [~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly)](#module*JS API* generator logic..generateAllTemplates) ⇒ - - [~generateSingleTemplate(genResult, singleTemplatePkg)](#module*JS API* generator logic..generateSingleTemplate) ⇒ - - [~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options)](#module*JS API* generator logic..generate) ⇒ - - [~writeFileWithBackup(fileName, content, doBackup)](#module*JS API* generator logic..writeFileWithBackup) ⇒ - - [~generateGenerationContent(genResult)](#module*JS API* generator logic..generateGenerationContent) - - [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#module*JS API* generator logic..generateAndWriteFiles) ⇒ - - [~postProcessGeneratedFiles(outputDirectory, genResult)](#module*JS API* generator logic..postProcessGeneratedFiles) ⇒ - - [~contentIndexer(content)](#module*JS API* generator logic..contentIndexer) - - [~generateSingleFileForPreview(db, sessionId, fileName)](#module*JS API* generator logic..generateSingleFileForPreview) ⇒ - - [~produceCompiledTemplate(singleTemplatePkg)](#module*JS API* generator logic..produceCompiledTemplate) ⇒ - - [~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options)](#module*JS API* generator logic..produceIterativeContent) ⇒ - - [~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:)](#module*JS API* generator logic..produceContent) ⇒ - - [~wrapOverridable(originalFn, overrideFn)](#module*JS API* generator logic..wrapOverridable) ⇒ - - [~loadOverridable(path)](#module*JS API* generator logic..loadOverridable) - - [~loadPartial(path)](#module*JS API* generator logic..loadPartial) - - [~loadHelper(helpers)](#module*JS API* generator logic..loadHelper) - - [~allBuiltInHelpers()](#module*JS API* generator logic..allBuiltInHelpers) ⇒ - - [~findHelperPackageByAlias(alias)](#module*JS API* generator logic..findHelperPackageByAlias) ⇒ - - [~initializeBuiltInHelpersForPackage()](#module*JS API* generator logic..initializeBuiltInHelpersForPackage) - - [~hbInstance()](#module*JS API* generator logic..hbInstance) ⇒ - - [~makeSynchronizablePromise(promise)](#module*JS API* generator logic..makeSynchronizablePromise) - - [~collectBlocks(resultArray, options, context)](#module*JS API* generator logic..collectBlocks) ⇒ - - [~ensureZclPackageId(context)](#module*JS API* generator logic..ensureZclPackageId) ⇒ - - [~ensureZclPackageIds(context)](#module*JS API* generator logic..ensureZclPackageIds) ⇒ - - [~ensureTemplatePackageCategory(context)](#module*JS API* generator logic..ensureTemplatePackageCategory) ⇒ - - [~ensureTemplatePackageId(context)](#module*JS API* generator logic..ensureTemplatePackageId) ⇒ - - [~ensureEndpointTypeIds(context)](#module*JS API* generator logic..ensureEndpointTypeIds) ⇒ - - [~ensureZclClusterSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclClusterSdkExtensions) ⇒ - - [~ensureZclDeviceTypeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclDeviceTypeSdkExtensions) ⇒ - - [~ensureZclAttributeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclAttributeSdkExtensions) ⇒ - - [~ensureZclAttributeTypeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclAttributeTypeSdkExtensions) ⇒ - - [~ensureZclCommandSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclCommandSdkExtensions) ⇒ - - [~ensureZclEventSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclEventSdkExtensions) ⇒ - - [~templatePromise(global, promise)](#module*JS API* generator logic..templatePromise) - - [~deprecatedHelper(fn, explanation)](#module*JS API* generator logic..deprecatedHelper) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### JS API: generator logic~loadGenTemplateFromFile(path) ⇒ + -Given a path, it will read generation template object into memory. +### REST API: user data~httpGetUnseenNotificationCount(db) ⇒ +HTTP GET: session get unseen session notification count -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Object that contains: data, crc, templateData +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -| Param | Type | -| ----- | --------------- | -| path | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -### JS API: generator logic~recordTemplatesPackage(context) ⇒ +### REST API: user data~httpGetUnseenNotificationAndUpdate(db) ⇒ +HTTP GET: session update all session notifications to be SEEN -Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the same context passed in, except packageId added to it +| Param | Type | +| --- | --- | +| db | \* | -| Param | Type | -| ------- | --------------- | -| context | \* | + - +### REST API: user data~httpPostSaveSessionKeyValue(db) ⇒ +HTTP POST: save session key value -### JS API: generator logic~decodePackageExtensionEntity(entityType, entity) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -This method takes extension data in JSON, and converts it into -an object that contains: -entityCode, entityQualifier, parentCode, manufacturerCode and value +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: object that can be used for database injection + -| Param | Type | -| ---------- | --------------- | -| entityType | \* | -| entity | \* | +### REST API: user data~httpPostCluster(db) ⇒ +HTTP POST: cluster - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -### JS API: generator logic~loadZclExtensions(zclExt) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Returns a promise that will load the zcl extensions. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise of loading the zcl extensions. +### REST API: user data~httpPostForcedExternal(db) ⇒ function +Handles a POST request to retrieve forced external storage options. -| Param | Type | -| ------ | --------------- | -| zclExt | \* | +This function is designed to be used as a middleware in an Express.js route. It extracts the session ID from the request, +queries the database for package information associated with that session, and then retrieves forced external storage +options for the identified package. The results are sent back to the client as a JSON response. - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: function - An asynchronous function that takes Express.js request and response objects. -### JS API: generator logic~loadTemplates(db, genTemplatesJsonArray) +| Param | Type | Description | +| --- | --- | --- | +| db | Object | The database connection object. | -Api that loads an array of template JSON files or a single file if -you just pass in one String. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +### REST API: user data~httpPostAttributeUpdate(db) ⇒ +HTTP POST attribute update -| Param | Type | -| --------------------- | --------------- | -| db | \* | -| genTemplatesJsonArray | \* | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration - +| Param | Type | +| --- | --- | +| db | \* | -### JS API: generator logic~loadGenTemplatesJsonFile(db, genTemplatesJson) ⇒ + -Main API async function to load templates from a gen-template.json file. +### REST API: user data~httpPostCommandUpdate(db) ⇒ +HTTP POST: command update -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: the loading context, contains: db, path, crc, packageId and templateData, or error +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -| Param | Type | Description | -| ---------------- | --------------- | ------------------------------------------------------- | -| db | \* | Database | -| genTemplatesJson | \* | Path to the JSON file or an array of paths to JSON file | +| Param | Type | +| --- | --- | +| db | \* | - + -### JS API: generator logic~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly) ⇒ +### REST API: user data~httpPostEventUpdate(db) ⇒ +HTTP POST: command update -Generates all the templates inside a toplevel package. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output' +| Param | Type | +| --- | --- | +| db | \* | -| Param | Type | Description | -| ------------------ | --------------- | -------------------------------------------------------------------------------------------------- | -| genResult | \* | | -| genTemplateJsonPkg | \* | Package that points to genTemplate.json file | -| generateOnly | \* | if NULL then generate all templates, else only generate template whose out file name matches this. | + - +### REST API: user data~httpGetInitialState(db) ⇒ +HTTP GET: initial state -### JS API: generator logic~generateSingleTemplate(genResult, singleTemplatePkg) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -Function that generates a single package and adds it to the generation result. +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the genResult, with newly generated content added. + -| Param | Type | Description | -| ----------------- | --------------- | ------------------------ | -| genResult | \* | | -| singleTemplatePkg | \* | Single template package. | +### REST API: user data~httpGetOption(db) ⇒ +HTTP GET: option - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: callback for the express uri registration -### JS API: generator logic~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Main API async function to generate stuff. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into a generation result.Promise that resolves into a generation result. +### REST API: user data~httpGetUiOptions(db) ⇒ +HTTP GET: ui_options -| Param | Type | Description | -| ------------------------ | --------------- | ------------------------------------------------------------------------------------- | -| db | \* | Database | -| sessionId | \* | | -| templatePackageId | \* | packageId Template package id. It can be either single template or gen template json. | -| templateGeneratorOptions | \* | | -| options | \* | | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: UI options from all packages. - +| Param | Type | +| --- | --- | +| db | \* | -### JS API: generator logic~writeFileWithBackup(fileName, content, doBackup) ⇒ + -Promise to write out a file, optionally creating a backup. +### REST API: user data~httpGetPackages() +HTTP GET: Project packages -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise of a written file. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + -| Param | Type | -| -------- | --------------- | -| fileName | \* | -| content | \* | -| doBackup | \* | +### REST API: user data~httpGetAllPackages() +HTTP GET: All Packages - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + -### JS API: generator logic~generateGenerationContent(genResult) +### REST API: user data~httpPostAddNewPackage() +HTTP POST: Add new project package -Returns a promise that resolves into a content that should be written out to gen result file. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +### REST API: user data~httpPostShareClusterStatesAcrossEndpoints() +HTTP POST: Unify all Attributes / Command states if a certain cluster is enabled + on more than one endpoint. -| Param | Type | -| --------- | --------------- | -| genResult | \* | +1) In Zigbee world, the Attribute / Command configurations is a global singleton entity. + If one cluster is enabled by more than 1 endpoint, the attribute states (on/off) should be + identical across each endpoint. + To emulate the global singleton entity, this function ensures Attribute changes + are applied to all endpoint specific attribute fields. + When unify event is triggered, this function will align all shared Attribute/Command states + to the first matching entry from beginning of the endpoint list. +2) (native case in ZAP) In Matter, the Attribute configuration are endpoint specific. - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) + -### JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒ +### REST API: user data~commandDefaults(db, endpointTypeIdList, sharedClusterList, packageIds) ⇒ +Get shared command defaults across endpoints. -Generate files and write them into the given directory. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: sharedCmdDefaults -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: a promise which will resolve when all the files are written. +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeIdList | \* | +| sharedClusterList | \* | +| packageIds | \* | -| Param | Type | -| --------------- | --------------- | -| db | \* | -| sessionId | \* | -| packageId | \* | -| outputDirectory | \* | + - +### REST API: user data~writeCommandDefaults(db, defaults) +Insert command defaults into the database. -### JS API: generator logic~postProcessGeneratedFiles(outputDirectory, genResult) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) -Executes post processing actions as defined by the gen-templates.json +| Param | Type | +| --- | --- | +| db | \* | +| defaults | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise of a dealt-with post processing actions + -| Param | Type | -| --------------- | --------------- | -| outputDirectory | \* | -| genResult | \* | +### REST API: user data~attributeDefaults(db, endpointTypeIdList, sharedClusterList, packageIds) ⇒ +Shared attribute defaults across endpoints. - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: sharedAttributeDefaults -### JS API: generator logic~contentIndexer(content) +| Param | Type | +| --- | --- | +| db | \* | +| endpointTypeIdList | \* | +| sharedClusterList | \* | +| packageIds | \* | -This async function takes a string, and resolves a preview object out of it. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +### REST API: user data~writeAttributeDefaults(db, defaults) +Write attribute defaults. -| Param | Type | Description | -| ------- | --------------- | ---------------------------- | -| content | \* | String to form into preview. | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) - +| Param | Type | +| --- | --- | +| db | \* | +| defaults | \* | -### JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒ + -Generates a single file and feeds it back for preview. +### REST API: user data~commandEquals(a, b) ⇒ +Compares 2 commands for equality. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves into a preview object. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: boolean -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| fileName | \* | +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | - + -### JS API: generator logic~produceCompiledTemplate(singleTemplatePkg) ⇒ +### REST API: user data~attributeEquals(a, b) ⇒ +Compares 2 attributes for equality. -Resolves into a precompiled template, either from previous precompile or freshly compiled. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: boolean -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: templates +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | -| Param | Type | -| ----------------- | --------------- | -| singleTemplatePkg | \* | + - +### REST API: user data~httpDeleteSessionPackage(db) ⇒ +Delete the session package. -### JS API: generator logic~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options) ⇒ +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: HTTP Response for delete operation -This function is reached if the template is an "iterative one", meaning -it has the iterator set to one of the valid options. +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into an array of key/content/stats objects. + -| Param | Type | -| ---------------------- | --------------- | -| hb | \* | -| metaInfo | \* | -| db | \* | -| sessionId | \* | -| singleTemplatePkg | \* | -| genTemplateJsonPackage | \* | -| options | \* | +### REST API: user data~httpPostDuplicateEndpoint(db) ⇒ +Creating a duplicate for endpoint - +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: newly created endpoint id -### JS API: generator logic~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:) ⇒ +| Param | Type | +| --- | --- | +| db | \* | -Given db connection, session and a single template package, produce the output. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into an array of key/content/stats objects. +### REST API: user data~httpPostDuplicateEndpointType(db) ⇒ +Creating a duplicate for endpoint-type and endpoint-type-attributes -| Param | Type | Description | -| ------------- | --------------- | --------------------------------------------------------------------------------------- | -| hb | \* | | -| metaInfo | \* | | -| db | \* | | -| sessionId | \* | | -| singlePkg | \* | | -| overridePath: | \* | if passed, it provides a path to the override file that can override the overridable.js | +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) +**Returns**: newly created endpoint-type id - +| Param | Type | +| --- | --- | +| db | \* | -### JS API: generator logic~wrapOverridable(originalFn, overrideFn) ⇒ + -This function attemps to call override function, but if override function -throws an exception, it calls the original function. +### REST API: user data~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId) +duplicate all clusters and attributes of an old endpoint type, using oldEndpointType id and newly created endpointType id -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: result from override function, unless it throws an exception, in which case return result from original function. +**Kind**: inner method of [REST API: user data](#module_REST API_ user data) -| Param | Type | -| ---------- | --------------- | -| originalFn | \* | -| overrideFn | \* | +| Param | Type | +| --- | --- | +| db | \* | +| oldEndpointTypeId | \* | +| newEndpointTypeId | \* | - + -### JS API: generator logic~loadOverridable(path) +## JS API: Matter specific APIs. +This module contains Matter specific APIs. -This function is responsible to load the overridable function container. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +## JS API: http server +This module provides the HTTP server functionality. -| Param | Type | Description | -| ----- | --------------- | -------------------- | -| path | \* | of the override file | - +* [JS API: http server](#module_JS API_ http server) + * [~registerRestApi(filename, db, app)](#module_JS API_ http server..registerRestApi) + * [~registerAllRestModules(db, app)](#module_JS API_ http server..registerAllRestModules) + * [~initHttpServer(db, port)](#module_JS API_ http server..initHttpServer) ⇒ + * [~userSessionHandler(db, options)](#module_JS API_ http server..userSessionHandler) ⇒ + * [~shutdownHttpServer()](#module_JS API_ http server..shutdownHttpServer) ⇒ + * [~shutdownHttpServerSync()](#module_JS API_ http server..shutdownHttpServerSync) ⇒ + * [~httpServerPort()](#module_JS API_ http server..httpServerPort) ⇒ + * [~httpServerUrl()](#module_JS API_ http server..httpServerUrl) ⇒ + * [~httpServerStartupMessage()](#module_JS API_ http server..httpServerStartupMessage) -### JS API: generator logic~loadPartial(path) + -Function that loads the partials. +### JS API: http server~registerRestApi(filename, db, app) +This function is used to register a rest module, which exports +get/post/etc. arrays. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) -| Param | Type | -| ----- | --------------- | -| path | \* | +| Param | Type | +| --- | --- | +| filename | \* | +| db | \* | +| app | \* | - + -### JS API: generator logic~loadHelper(helpers) +### JS API: http server~registerAllRestModules(db, app) +Register all REST modeules. -Function that loads the helpers. +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +| Param | Type | +| --- | --- | +| db | \* | +| app | \* | -| Param | Type | Description | -| ------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| helpers | \* | a string path if value is passed through CLI, the nativeRequire() is leverage the native js function instead of webpack's special sauce. a required() module if invoked by backend js code. this is required to force webpack to resolve the included files as path will be difference after being packed for production. | + - +### JS API: http server~initHttpServer(db, port) ⇒ +Promises to initialize the http server on a given port +using a given database. -### JS API: generator logic~allBuiltInHelpers() ⇒ +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) +**Returns**: A promise that resolves with an express app. -Returns an object that contains all the helper functions, keyed -by their name +| Param | Type | Description | +| --- | --- | --- | +| db | \* | Database object to use. | +| port | \* | Port for the HTTP server. | -NOTE: This method is ONLY used for API testing. You should not use -this method for any real work inside the engine or something. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Object containing all the helper functions. - +### JS API: http server~userSessionHandler(db, options) ⇒ +Handle user session. -### JS API: generator logic~findHelperPackageByAlias(alias) ⇒ +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) +**Returns**: function -Given an alias, this method finds a builtin helper package -by its alias. +| Param | Type | +| --- | --- | +| db | \* | +| options | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Helper package or undefined if none was found. + -| Param | Type | -| ----- | --------------- | -| alias | \* | +### JS API: http server~shutdownHttpServer() ⇒ +Promises to shut down the http server. - +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) +**Returns**: Promise that resolves when server is shut down. + -### JS API: generator logic~initializeBuiltInHelpersForPackage() +### JS API: http server~shutdownHttpServerSync() ⇒ +Promises to shut down the http server. -Global helper initialization +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) +**Returns**: Promise that resolves when server is shut down. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) - +### JS API: http server~httpServerPort() ⇒ +Port http server is listening on. -### JS API: generator logic~hbInstance() ⇒ +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) +**Returns**: port + -This method returns the correct instance for a given generation flow. +### JS API: http server~httpServerUrl() ⇒ +Returns the URL of the server. -TBD: At this point it doesn't do anything yet, it's just -a central point to get the correct instance. +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) +**Returns**: the server URL + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Instance of handlebars to be used. - +### JS API: http server~httpServerStartupMessage() +Returns the startup message that needs to be printed out. -### JS API: generator logic~makeSynchronizablePromise(promise) +**Kind**: inner method of [JS API: http server](#module_JS API_ http server) + -All promises used by the templates should be synchronizable. +## IPC Server API: Inter-process communication +This module provides IPC Server functionality. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -| Param | Type | -| ------- | --------------- | -| promise | \* | +* [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) + * [~socketPath()](#module_IPC Server API_ Inter-process communication..socketPath) + * [~log(msg)](#module_IPC Server API_ Inter-process communication..log) + * [~handlerPing(context, data)](#module_IPC Server API_ Inter-process communication..handlerPing) + * [~handlerServerStatus(context)](#module_IPC Server API_ Inter-process communication..handlerServerStatus) + * [~handlerConvert(context, data)](#module_IPC Server API_ Inter-process communication..handlerConvert) + * [~handlerStop(context, data)](#module_IPC Server API_ Inter-process communication..handlerStop) + * [~handlerGenerate(context, data)](#module_IPC Server API_ Inter-process communication..handlerGenerate) ⇒ + * [~preHandler()](#module_IPC Server API_ Inter-process communication..preHandler) + * [~initServer(options)](#module_IPC Server API_ Inter-process communication..initServer) + * [~isServerRunning()](#module_IPC Server API_ Inter-process communication..isServerRunning) ⇒ + * [~shutdownServerSync(isServer)](#module_IPC Server API_ Inter-process communication..shutdownServerSync) - + -### JS API: generator logic~collectBlocks(resultArray, options, context) ⇒ +### IPC Server API: Inter-process communication~socketPath() +Returns the socket path for the IPC. -Helpful function that collects the individual blocks by using elements of an array as a context, -executing promises for each, and collecting them into the outgoing string. +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves with a content string. +### IPC Server API: Inter-process communication~log(msg) +Log IPC message. -| Param | Type | Description | -| ----------- | --------------- | ---------------------------------------- | -| resultArray | \* | | -| options | \* | Options passed from a block helper. | -| context | \* | The context from within this was called. | +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) - +| Param | Type | +| --- | --- | +| msg | \* | -### JS API: generator logic~ensureZclPackageId(context) ⇒ + -Returns the promise that resolves with the ZCL properties package id. +### IPC Server API: Inter-process communication~handlerPing(context, data) +Ping IPC server. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the package id. +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) -| Param | Type | -| ------- | --------------- | -| context | \* | +| Param | Type | +| --- | --- | +| context | \* | +| data | \* | - + -### JS API: generator logic~ensureZclPackageIds(context) ⇒ +### IPC Server API: Inter-process communication~handlerServerStatus(context) +Get IPC server status. -Returns the promise that resolves with all ZCL package id specific to current session. +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with a list of package id. +| Param | Type | +| --- | --- | +| context | \* | -| Param | Type | -| ------- | --------------- | -| context | \* | + - +### IPC Server API: Inter-process communication~handlerConvert(context, data) +Convert zap files. -### JS API: generator logic~ensureTemplatePackageCategory(context) ⇒ +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) -Returns a package category of the toplevel template package from context. +| Param | Type | +| --- | --- | +| context | \* | +| data | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: proimise that resolves into a package category + -| Param | Type | -| ------- | --------------- | -| context | \* | +### IPC Server API: Inter-process communication~handlerStop(context, data) +Shut down IPC server. - +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) -### JS API: generator logic~ensureTemplatePackageId(context) ⇒ +| Param | Type | +| --- | --- | +| context | \* | +| data | \* | -Returns the promise that resolves with the ZCL properties package id. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the package id. +### IPC Server API: Inter-process communication~handlerGenerate(context, data) ⇒ +Data contains: zapFileArray, outputPattern, zcl, template -| Param | Type | -| ------- | --------------- | -| context | \* | +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) +**Returns**: Promise of generation - +| Param | Type | +| --- | --- | +| context | \* | +| data | \* | -### JS API: generator logic~ensureEndpointTypeIds(context) ⇒ + -Populate the endpoint type ids into the global context. +### IPC Server API: Inter-process communication~preHandler() +Runs just before every time IPC request is processed. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: endpoint type ids +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) + -| Param | Type | -| ------- | --------------- | -| context | \* | +### IPC Server API: Inter-process communication~initServer(options) +IPC initialization. - +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) +**Parem**: \* isServer 'true' if this is a server, 'false' for client. -### JS API: generator logic~ensureZclClusterSdkExtensions(context, templatePackageId) ⇒ +| Param | Type | +| --- | --- | +| options | \* | -Resolves with cached cluster extensions, but if they don't -exist, it will populate them. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with cluster extensions. +### IPC Server API: Inter-process communication~isServerRunning() ⇒ +Returns true if server is running. -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) +**Returns**: true if server is running. + - +### IPC Server API: Inter-process communication~shutdownServerSync(isServer) +Shuts down the IPC server. -### JS API: generator logic~ensureZclDeviceTypeSdkExtensions(context, templatePackageId) ⇒ +**Kind**: inner method of [IPC Server API: Inter-process communication](#module_IPC Server API_ Inter-process communication) -Resolves with cached cluster extensions, but if they don't -exist, it will populate them. +| Param | Type | +| --- | --- | +| isServer | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with cluster extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +## JS API: websocket server +This module provides the HTTP server functionality. - -### JS API: generator logic~ensureZclAttributeSdkExtensions(context, templatePackageId) ⇒ +* [JS API: websocket server](#module_JS API_ websocket server) + * [~initializeWebSocket(httpServer)](#module_JS API_ websocket server..initializeWebSocket) + * [~clientSocket(sessionUuid)](#module_JS API_ websocket server..clientSocket) + * [~sendTick(socket)](#module_JS API_ websocket server..sendTick) + * [~doSend(socket, object)](#module_JS API_ websocket server..doSend) + * [~sendWebSocketData(category, payload)](#module_JS API_ websocket server..sendWebSocketData) + * [~sendWebSocketMessage(msg)](#module_JS API_ websocket server..sendWebSocketMessage) + * [~onWebSocket(category, listener)](#module_JS API_ websocket server..onWebSocket) -Resolves with cached attribute extensions, but if they don't -exist, it will populate them. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with attribute extensions. +### JS API: websocket server~initializeWebSocket(httpServer) +Initialize a websocket, and register listeners to the +websocket connection and the message receipt. -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +**Kind**: inner method of [JS API: websocket server](#module_JS API_ websocket server) - +| Param | Type | +| --- | --- | +| httpServer | \* | -### JS API: generator logic~ensureZclAttributeTypeSdkExtensions(context, templatePackageId) ⇒ + -Resolves with cached attribute type extensions, but if they don't -exist, it will populate them. +### JS API: websocket server~clientSocket(sessionUuid) +Method that returns the websocket for a given session key. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with attribute type extensions. +**Kind**: inner method of [JS API: websocket server](#module_JS API_ websocket server) -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +| Param | Type | +| --- | --- | +| sessionUuid | \* | - + -### JS API: generator logic~ensureZclCommandSdkExtensions(context, templatePackageId) ⇒ +### JS API: websocket server~sendTick(socket) +Send websocket payload with the tick category. -Resolves with cached command extensions, but if they don't -exist, it will populate them. +**Kind**: inner method of [JS API: websocket server](#module_JS API_ websocket server) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with command extensions. +| Param | Type | +| --- | --- | +| socket | \* | -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | + - +### JS API: websocket server~doSend(socket, object) +Bottom-most function that sends an object over a socket. -### JS API: generator logic~ensureZclEventSdkExtensions(context, templatePackageId) ⇒ +**Kind**: inner method of [JS API: websocket server](#module_JS API_ websocket server) -Resolves with cached command extensions, but if they don't -exist, it will populate them. +| Param | Type | +| --- | --- | +| socket | \* | +| object | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with command extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +### JS API: websocket server~sendWebSocketData(category, payload) +Send websocket payload with a given category. - +**Kind**: inner method of [JS API: websocket server](#module_JS API_ websocket server) -### JS API: generator logic~templatePromise(global, promise) +| Param | Type | +| --- | --- | +| category | \* | +| payload | \* | -Every helper that returns a promise, should -not return the promise directly. So instead of -returning the promise directly, it should return: -return templatePromise(this.global, promise) + -This will ensure that after tag works as expected. +### JS API: websocket server~sendWebSocketMessage(msg) +This can be used to send unstructured websocket message. +On the receiving end, the event will contain category +'generic'. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +**Kind**: inner method of [JS API: websocket server](#module_JS API_ websocket server) -| Param | Type | -| ------- | --------------- | -| global | \* | -| promise | \* | +| Param | Type | +| --- | --- | +| msg | \* | - + -### JS API: generator logic~deprecatedHelper(fn, explanation) ⇒ +### JS API: websocket server~onWebSocket(category, listener) +If you wish to register to a specific category of websocket +messages, you can use this function. Listener will be executed with +a given socket and data object. -Function wrapper that can be used when a helper is deprecated. +**Kind**: inner method of [JS API: websocket server](#module_JS API_ websocket server) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: a function that wraps the original function, with deprecation message. +| Param | Type | Description | +| --- | --- | --- | +| category | \* | category of message. | +| listener | \* | function that receives socket, data. | -| Param | Type | Description | -| ----------- | --------------- | ----------------------------------------------------------------------- | -| fn | \* | | -| explanation | \* | can contain `text`, or `from`/`to`, or just be a string message itself. | + - +## JS API: About page +This module provides the About page functionality for ZAP. -## JS API: template iterators. - +* [JS API: About page](#module_JS API_ About page) + * [~createAboutWindow(parentWindow, port)](#module_JS API_ About page..createAboutWindow) + * [~createOrShowAboutWindow(port)](#module_JS API_ About page..createOrShowAboutWindow) -## JS API: generator logic + -- [JS API: generator logic](#module*JS API* generator logic) - - [~loadGenTemplateFromFile(path)](#module*JS API* generator logic..loadGenTemplateFromFile) ⇒ - - [~recordTemplatesPackage(context)](#module*JS API* generator logic..recordTemplatesPackage) ⇒ - - [~decodePackageExtensionEntity(entityType, entity)](#module*JS API* generator logic..decodePackageExtensionEntity) ⇒ - - [~loadZclExtensions(zclExt)](#module*JS API* generator logic..loadZclExtensions) ⇒ - - [~loadTemplates(db, genTemplatesJsonArray)](#module*JS API* generator logic..loadTemplates) - - [~loadGenTemplatesJsonFile(db, genTemplatesJson)](#module*JS API* generator logic..loadGenTemplatesJsonFile) ⇒ - - [~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly)](#module*JS API* generator logic..generateAllTemplates) ⇒ - - [~generateSingleTemplate(genResult, singleTemplatePkg)](#module*JS API* generator logic..generateSingleTemplate) ⇒ - - [~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options)](#module*JS API* generator logic..generate) ⇒ - - [~writeFileWithBackup(fileName, content, doBackup)](#module*JS API* generator logic..writeFileWithBackup) ⇒ - - [~generateGenerationContent(genResult)](#module*JS API* generator logic..generateGenerationContent) - - [~generateAndWriteFiles(db, sessionId, packageId, outputDirectory)](#module*JS API* generator logic..generateAndWriteFiles) ⇒ - - [~postProcessGeneratedFiles(outputDirectory, genResult)](#module*JS API* generator logic..postProcessGeneratedFiles) ⇒ - - [~contentIndexer(content)](#module*JS API* generator logic..contentIndexer) - - [~generateSingleFileForPreview(db, sessionId, fileName)](#module*JS API* generator logic..generateSingleFileForPreview) ⇒ - - [~produceCompiledTemplate(singleTemplatePkg)](#module*JS API* generator logic..produceCompiledTemplate) ⇒ - - [~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options)](#module*JS API* generator logic..produceIterativeContent) ⇒ - - [~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:)](#module*JS API* generator logic..produceContent) ⇒ - - [~wrapOverridable(originalFn, overrideFn)](#module*JS API* generator logic..wrapOverridable) ⇒ - - [~loadOverridable(path)](#module*JS API* generator logic..loadOverridable) - - [~loadPartial(path)](#module*JS API* generator logic..loadPartial) - - [~loadHelper(helpers)](#module*JS API* generator logic..loadHelper) - - [~allBuiltInHelpers()](#module*JS API* generator logic..allBuiltInHelpers) ⇒ - - [~findHelperPackageByAlias(alias)](#module*JS API* generator logic..findHelperPackageByAlias) ⇒ - - [~initializeBuiltInHelpersForPackage()](#module*JS API* generator logic..initializeBuiltInHelpersForPackage) - - [~hbInstance()](#module*JS API* generator logic..hbInstance) ⇒ - - [~makeSynchronizablePromise(promise)](#module*JS API* generator logic..makeSynchronizablePromise) - - [~collectBlocks(resultArray, options, context)](#module*JS API* generator logic..collectBlocks) ⇒ - - [~ensureZclPackageId(context)](#module*JS API* generator logic..ensureZclPackageId) ⇒ - - [~ensureZclPackageIds(context)](#module*JS API* generator logic..ensureZclPackageIds) ⇒ - - [~ensureTemplatePackageCategory(context)](#module*JS API* generator logic..ensureTemplatePackageCategory) ⇒ - - [~ensureTemplatePackageId(context)](#module*JS API* generator logic..ensureTemplatePackageId) ⇒ - - [~ensureEndpointTypeIds(context)](#module*JS API* generator logic..ensureEndpointTypeIds) ⇒ - - [~ensureZclClusterSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclClusterSdkExtensions) ⇒ - - [~ensureZclDeviceTypeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclDeviceTypeSdkExtensions) ⇒ - - [~ensureZclAttributeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclAttributeSdkExtensions) ⇒ - - [~ensureZclAttributeTypeSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclAttributeTypeSdkExtensions) ⇒ - - [~ensureZclCommandSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclCommandSdkExtensions) ⇒ - - [~ensureZclEventSdkExtensions(context, templatePackageId)](#module*JS API* generator logic..ensureZclEventSdkExtensions) ⇒ - - [~templatePromise(global, promise)](#module*JS API* generator logic..templatePromise) - - [~deprecatedHelper(fn, explanation)](#module*JS API* generator logic..deprecatedHelper) ⇒ +### JS API: About page~createAboutWindow(parentWindow, port) +Create the about window in ZAP. - +**Kind**: inner method of [JS API: About page](#module_JS API_ About page) -### JS API: generator logic~loadGenTemplateFromFile(path) ⇒ +| Param | Type | +| --- | --- | +| parentWindow | \* | +| port | \* | -Given a path, it will read generation template object into memory. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Object that contains: data, crc, templateData +### JS API: About page~createOrShowAboutWindow(port) +Call this function to create a new or show an existing preference window. -| Param | Type | -| ----- | --------------- | -| path | \* | +**Kind**: inner method of [JS API: About page](#module_JS API_ About page) - +| Param | Type | +| --- | --- | +| port | \* | -### JS API: generator logic~recordTemplatesPackage(context) ⇒ + -Given a loading context, it records the package into the packages table and adds the packageId field into the resolved context. +## JS API: renderer API related utilities -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the same context passed in, except packageId added to it +* [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) + * [~getSessionUuidFromBrowserWindow(browserWindow)](#module_JS API_ renderer API related utilities..getSessionUuidFromBrowserWindow) ⇒ + * [~getRendererApiInformation(browserWindow)](#module_JS API_ renderer API related utilities..getRendererApiInformation) ⇒ + * [~execRendererApi(browserWindow, rendererApiCommand, ...theArgs)](#module_JS API_ renderer API related utilities..execRendererApi) + * [~execFileOpen(browserWindow, filePath)](#module_JS API_ renderer API related utilities..execFileOpen) ⇒ + * [~processRendererNotify(message)](#module_JS API_ renderer API related utilities..processRendererNotify) ⇒ + * [~reportFiles(browserWindow, result)](#module_JS API_ renderer API related utilities..reportFiles) + * [~getUserKeyFromCookieValue(cookieValue)](#module_JS API_ renderer API related utilities..getUserKeyFromCookieValue) ⇒ + * [~getUserKeyFromBrowserCookie(browserCookie)](#module_JS API_ renderer API related utilities..getUserKeyFromBrowserCookie) + * [~getUserKeyFromBrowserWindow(browserWindow)](#module_JS API_ renderer API related utilities..getUserKeyFromBrowserWindow) -| Param | Type | -| ------- | --------------- | -| context | \* | + - +### JS API: renderer API related utilities~getSessionUuidFromBrowserWindow(browserWindow) ⇒ +This method returns the global session UUID from the browser window that is set by the front-end. -### JS API: generator logic~decodePackageExtensionEntity(entityType, entity) ⇒ +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) +**Returns**: session UUID -This method takes extension data in JSON, and converts it into -an object that contains: -entityCode, entityQualifier, parentCode, manufacturerCode and value +| Param | Type | +| --- | --- | +| browserWindow | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: object that can be used for database injection + -| Param | Type | -| ---------- | --------------- | -| entityType | \* | -| entity | \* | +### JS API: renderer API related utilities~getRendererApiInformation(browserWindow) ⇒ +Returns descriptive text about renderer api. - +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) +**Returns**: description of renderer api -### JS API: generator logic~loadZclExtensions(zclExt) ⇒ +| Param | Type | +| --- | --- | +| browserWindow | \* | -Returns a promise that will load the zcl extensions. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise of loading the zcl extensions. +### JS API: renderer API related utilities~execRendererApi(browserWindow, rendererApiCommand, ...theArgs) +Execute RendererApi commands -| Param | Type | -| ------ | --------------- | -| zclExt | \* | +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) - +| Param | Type | +| --- | --- | +| browserWindow | \* | +| rendererApiCommand | \* | +| ...theArgs | any | -### JS API: generator logic~loadTemplates(db, genTemplatesJsonArray) + -Api that loads an array of template JSON files or a single file if -you just pass in one String. +### JS API: renderer API related utilities~execFileOpen(browserWindow, filePath) ⇒ +Executes the file open renderer API action. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) +**Returns**: Result of file open call. -| Param | Type | -| --------------------- | --------------- | -| db | \* | -| genTemplatesJsonArray | \* | +| Param | Type | +| --- | --- | +| browserWindow | \* | +| filePath | \* | - + -### JS API: generator logic~loadGenTemplatesJsonFile(db, genTemplatesJson) ⇒ +### JS API: renderer API related utilities~processRendererNotify(message) ⇒ +This method takes a message and checks if it's a renderer API +notification call. If it is, it processe it and returns true. +If it's not it returns false. -Main API async function to load templates from a gen-template.json file. +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) +**Returns**: true if message was a notify message and was consumed. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: the loading context, contains: db, path, crc, packageId and templateData, or error +| Param | Type | +| --- | --- | +| message | \* | -| Param | Type | Description | -| ---------------- | --------------- | ------------------------------------------------------- | -| db | \* | Database | -| genTemplatesJson | \* | Path to the JSON file or an array of paths to JSON file | + - +### JS API: renderer API related utilities~reportFiles(browserWindow, result) +This method calls the reportFiles renderer API call. -### JS API: generator logic~generateAllTemplates(genResult, genTemplateJsonPkg, generateOnly) ⇒ +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) -Generates all the templates inside a toplevel package. +| Param | Type | +| --- | --- | +| browserWindow | \* | +| result | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves with genResult, that contains all the generated templates, keyed by their 'output' + -| Param | Type | Description | -| ------------------ | --------------- | -------------------------------------------------------------------------------------------------- | -| genResult | \* | | -| genTemplateJsonPkg | \* | Package that points to genTemplate.json file | -| generateOnly | \* | if NULL then generate all templates, else only generate template whose out file name matches this. | +### JS API: renderer API related utilities~getUserKeyFromCookieValue(cookieValue) ⇒ +Returns cookie for user identification. - +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) +**Returns**: cookie value used for user identification -### JS API: generator logic~generateSingleTemplate(genResult, singleTemplatePkg) ⇒ +| Param | Type | +| --- | --- | +| cookieValue | \* | -Function that generates a single package and adds it to the generation result. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the genResult, with newly generated content added. +### JS API: renderer API related utilities~getUserKeyFromBrowserCookie(browserCookie) +Returns the session key -| Param | Type | Description | -| ----------------- | --------------- | ------------------------ | -| genResult | \* | | -| singleTemplatePkg | \* | Single template package. | +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) - +| Param | Type | Description | +| --- | --- | --- | +| browserCookie | \* | object | -### JS API: generator logic~generate(db, sessionId, templatePackageId, templateGeneratorOptions, options) ⇒ + -Main API async function to generate stuff. +### JS API: renderer API related utilities~getUserKeyFromBrowserWindow(browserWindow) +Returns a promise that resolves into the session key. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into a generation result.Promise that resolves into a generation result. +**Kind**: inner method of [JS API: renderer API related utilities](#module_JS API_ renderer API related utilities) -| Param | Type | Description | -| ------------------------ | --------------- | ------------------------------------------------------------------------------------- | -| db | \* | Database | -| sessionId | \* | | -| templatePackageId | \* | packageId Template package id. It can be either single template or gen template json. | -| templateGeneratorOptions | \* | | -| options | \* | | +| Param | Type | +| --- | --- | +| browserWindow | \* | - + -### JS API: generator logic~writeFileWithBackup(fileName, content, doBackup) ⇒ +## JS API: UI Development +This file is used specifically and only for development. It installs +`electron-debug` & `vue-devtools`. There shouldn't be any need to + modify this file, but it can be used to extend your development + environment. -Promise to write out a file, optionally creating a backup. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise of a written file. +## JS API: UI +Main UI -| Param | Type | -| -------- | --------------- | -| fileName | \* | -| content | \* | -| doBackup | \* | - +* [JS API: UI](#module_JS API_ UI) + * [~hookSecondInstanceEvents(argv)](#module_JS API_ UI..hookSecondInstanceEvents) + * [~hookMainInstanceEvents()](#module_JS API_ UI..hookMainInstanceEvents) -### JS API: generator logic~generateGenerationContent(genResult) + -Returns a promise that resolves into a content that should be written out to gen result file. +### JS API: UI~hookSecondInstanceEvents(argv) +Hook second instance. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +**Kind**: inner method of [JS API: UI](#module_JS API_ UI) -| Param | Type | -| --------- | --------------- | -| genResult | \* | +| Param | Type | +| --- | --- | +| argv | \* | - + -### JS API: generator logic~generateAndWriteFiles(db, sessionId, packageId, outputDirectory) ⇒ +### JS API: UI~hookMainInstanceEvents() +Hook up all the events for the electron app object. -Generate files and write them into the given directory. +**Kind**: inner method of [JS API: UI](#module_JS API_ UI) + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: a promise which will resolve when all the files are written. +## JS API: Menu for ZAP UI +Menu for ZAP UI -| Param | Type | -| --------------- | --------------- | -| db | \* | -| sessionId | \* | -| packageId | \* | -| outputDirectory | \* | - +* [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) + * [~getUserSessionInfoMessage(browserWindow)](#module_JS API_ Menu for ZAP UI..getUserSessionInfoMessage) ⇒ + * [~doOpen(menuItem, browserWindow, event)](#module_JS API_ Menu for ZAP UI..doOpen) + * [~doSave(browserWindow)](#module_JS API_ Menu for ZAP UI..doSave) + * [~doSaveAs(menuItem, browserWindow, event)](#module_JS API_ Menu for ZAP UI..doSaveAs) + * [~fileSave(db, browserWindow, filePath)](#module_JS API_ Menu for ZAP UI..fileSave) ⇒ + * [~fileOpen(db, filePaths)](#module_JS API_ Menu for ZAP UI..fileOpen) + * [~showMenu(httpPort)](#module_JS API_ Menu for ZAP UI..showMenu) + * [~hideMenu(httpPort)](#module_JS API_ Menu for ZAP UI..hideMenu) + * [~toggleMenu(port)](#module_JS API_ Menu for ZAP UI..toggleMenu) + * [~initMenu(httpPort)](#module_JS API_ Menu for ZAP UI..initMenu) -### JS API: generator logic~postProcessGeneratedFiles(outputDirectory, genResult) ⇒ + -Executes post processing actions as defined by the gen-templates.json +### JS API: Menu for ZAP UI~getUserSessionInfoMessage(browserWindow) ⇒ +Get the user session information details in a string. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise of a dealt-with post processing actions +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) +**Returns**: string -| Param | Type | -| --------------- | --------------- | -| outputDirectory | \* | -| genResult | \* | +| Param | Type | +| --- | --- | +| browserWindow | \* | - + -### JS API: generator logic~contentIndexer(content) +### JS API: Menu for ZAP UI~doOpen(menuItem, browserWindow, event) +Perform a file->open operation. -This async function takes a string, and resolves a preview object out of it. +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +| Param | Type | +| --- | --- | +| menuItem | \* | +| browserWindow | \* | +| event | \* | -| Param | Type | Description | -| ------- | --------------- | ---------------------------- | -| content | \* | String to form into preview. | + - +### JS API: Menu for ZAP UI~doSave(browserWindow) +Perform a save, defering to save as if file is not yet selected. -### JS API: generator logic~generateSingleFileForPreview(db, sessionId, fileName) ⇒ +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) -Generates a single file and feeds it back for preview. +| Param | Type | +| --- | --- | +| browserWindow | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves into a preview object. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| fileName | \* | +### JS API: Menu for ZAP UI~doSaveAs(menuItem, browserWindow, event) +Perform save as. - +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) -### JS API: generator logic~produceCompiledTemplate(singleTemplatePkg) ⇒ +| Param | Type | +| --- | --- | +| menuItem | \* | +| browserWindow | \* | +| event | \* | -Resolves into a precompiled template, either from previous precompile or freshly compiled. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: templates +### JS API: Menu for ZAP UI~fileSave(db, browserWindow, filePath) ⇒ +perform the save. -| Param | Type | -| ----------------- | --------------- | -| singleTemplatePkg | \* | +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) +**Returns**: Promise of saving. - +| Param | Type | +| --- | --- | +| db | \* | +| browserWindow | \* | +| filePath | \* | -### JS API: generator logic~produceIterativeContent(hb, metaInfo, db, sessionId, singleTemplatePkg, genTemplateJsonPackage, options) ⇒ + -This function is reached if the template is an "iterative one", meaning -it has the iterator set to one of the valid options. +### JS API: Menu for ZAP UI~fileOpen(db, filePaths) +Perform the do open action, possibly reading in multiple files. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into an array of key/content/stats objects. +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) -| Param | Type | -| ---------------------- | --------------- | -| hb | \* | -| metaInfo | \* | -| db | \* | -| sessionId | \* | -| singleTemplatePkg | \* | -| genTemplateJsonPackage | \* | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePaths | \* | - + -### JS API: generator logic~produceContent(hb, metaInfo, db, sessionId, singlePkg, overridePath:) ⇒ +### JS API: Menu for ZAP UI~showMenu(httpPort) +Show the menu. -Given db connection, session and a single template package, produce the output. +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves into an array of key/content/stats objects. +| Param | Type | +| --- | --- | +| httpPort | \* | -| Param | Type | Description | -| ------------- | --------------- | --------------------------------------------------------------------------------------- | -| hb | \* | | -| metaInfo | \* | | -| db | \* | | -| sessionId | \* | | -| singlePkg | \* | | -| overridePath: | \* | if passed, it provides a path to the override file that can override the overridable.js | + - +### JS API: Menu for ZAP UI~hideMenu(httpPort) +Hide the menu. -### JS API: generator logic~wrapOverridable(originalFn, overrideFn) ⇒ +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) -This function attemps to call override function, but if override function -throws an exception, it calls the original function. +| Param | Type | +| --- | --- | +| httpPort | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: result from override function, unless it throws an exception, in which case return result from original function. + -| Param | Type | -| ---------- | --------------- | -| originalFn | \* | -| overrideFn | \* | +### JS API: Menu for ZAP UI~toggleMenu(port) +Toggling of menu - +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) -### JS API: generator logic~loadOverridable(path) +| Param | Type | +| --- | --- | +| port | \* | -This function is responsible to load the overridable function container. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +### JS API: Menu for ZAP UI~initMenu(httpPort) +Initial menu show. -| Param | Type | Description | -| ----- | --------------- | -------------------- | -| path | \* | of the override file | +**Kind**: inner method of [JS API: Menu for ZAP UI](#module_JS API_ Menu for ZAP UI) - +| Param | Type | +| --- | --- | +| httpPort | \* | -### JS API: generator logic~loadPartial(path) + -Function that loads the partials. +## JS API: Tray for ZAP UI +Tray for ZAP UI -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) + -| Param | Type | -| ----- | --------------- | -| path | \* | +### JS API: Tray for ZAP UI~initTray(port) ⇒ +Initialize tray. - +**Kind**: inner method of [JS API: Tray for ZAP UI](#module_JS API_ Tray for ZAP UI) +**Returns**: none -### JS API: generator logic~loadHelper(helpers) +| Param | Type | +| --- | --- | +| port | \* | -Function that loads the helpers. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +## JS API: Utility module for ZAP UI +Utility module for ZAP UI -| Param | Type | Description | -| ------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| helpers | \* | a string path if value is passed through CLI, the nativeRequire() is leverage the native js function instead of webpack's special sauce. a required() module if invoked by backend js code. this is required to force webpack to resolve the included files as path will be difference after being packed for production. | - +* [JS API: Utility module for ZAP UI](#module_JS API_ Utility module for ZAP UI) + * [~showErrorMessage(title, err)](#module_JS API_ Utility module for ZAP UI..showErrorMessage) + * [~openFileConfiguration(db, filePath, httpPort)](#module_JS API_ Utility module for ZAP UI..openFileConfiguration) + * [~openNewConfiguration(httpPort, options:)](#module_JS API_ Utility module for ZAP UI..openNewConfiguration) + * [~toggleDirtyFlag(browserWindow, dirty)](#module_JS API_ Utility module for ZAP UI..toggleDirtyFlag) + * [~openFileDialogAndReportResult(browserWindow, options)](#module_JS API_ Utility module for ZAP UI..openFileDialogAndReportResult) + * [~enableUi(port, zapFiles, uiMode, standalone)](#module_JS API_ Utility module for ZAP UI..enableUi) ⇒ -### JS API: generator logic~allBuiltInHelpers() ⇒ + -Returns an object that contains all the helper functions, keyed -by their name +### JS API: Utility module for ZAP UI~showErrorMessage(title, err) +Simple dialog to show error messages from electron renderer scope. -NOTE: This method is ONLY used for API testing. You should not use -this method for any real work inside the engine or something. +**Kind**: inner method of [JS API: Utility module for ZAP UI](#module_JS API_ Utility module for ZAP UI) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Object containing all the helper functions. - +| Param | Type | +| --- | --- | +| title | \* | +| err | \* | -### JS API: generator logic~findHelperPackageByAlias(alias) ⇒ + -Given an alias, this method finds a builtin helper package -by its alias. +### JS API: Utility module for ZAP UI~openFileConfiguration(db, filePath, httpPort) +Process a single file, parsing it in as JSON and then possibly opening +a new window if all is good. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Helper package or undefined if none was found. +**Kind**: inner method of [JS API: Utility module for ZAP UI](#module_JS API_ Utility module for ZAP UI) -| Param | Type | -| ----- | --------------- | -| alias | \* | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| filePath | \* | | +| httpPort | \* | Server port for the URL that will be constructed. | - + -### JS API: generator logic~initializeBuiltInHelpersForPackage() +### JS API: Utility module for ZAP UI~openNewConfiguration(httpPort, options:) +Creates a new window with a blank configuration. -Global helper initialization +**Kind**: inner method of [JS API: Utility module for ZAP UI](#module_JS API_ Utility module for ZAP UI) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) - +| Param | Type | Description | +| --- | --- | --- | +| httpPort | \* | | +| options: | \* | uiMode, debugNavBar | -### JS API: generator logic~hbInstance() ⇒ + -This method returns the correct instance for a given generation flow. +### JS API: Utility module for ZAP UI~toggleDirtyFlag(browserWindow, dirty) +Toggles the dirty flag. -TBD: At this point it doesn't do anything yet, it's just -a central point to get the correct instance. +**Kind**: inner method of [JS API: Utility module for ZAP UI](#module_JS API_ Utility module for ZAP UI) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Instance of handlebars to be used. - +| Param | Type | Description | +| --- | --- | --- | +| browserWindow | \* | window to affect | +| dirty | \* | true if this windows is now dirty, false if otherwise | -### JS API: generator logic~makeSynchronizablePromise(promise) + -All promises used by the templates should be synchronizable. +### JS API: Utility module for ZAP UI~openFileDialogAndReportResult(browserWindow, options) +This function should be invoked as a result of the fileBrowse +notification via the renderer API. It pops the open dialog and +reports result back through the API. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +**Kind**: inner method of [JS API: Utility module for ZAP UI](#module_JS API_ Utility module for ZAP UI) -| Param | Type | -| ------- | --------------- | -| promise | \* | +| Param | Type | Description | +| --- | --- | --- | +| browserWindow | \* | | +| options | \* | 'key', 'title', 'mode', 'defaultPath' | - + -### JS API: generator logic~collectBlocks(resultArray, options, context) ⇒ +### JS API: Utility module for ZAP UI~enableUi(port, zapFiles, uiMode, standalone) ⇒ +Enable the UI open using the given arguments. -Helpful function that collects the individual blocks by using elements of an array as a context, -executing promises for each, and collecting them into the outgoing string. +**Kind**: inner method of [JS API: Utility module for ZAP UI](#module_JS API_ Utility module for ZAP UI) +**Returns**: promise of a file open configuration -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: Promise that resolves with a content string. +| Param | Type | +| --- | --- | +| port | \* | +| zapFiles | \* | +| uiMode | \* | +| standalone | \* | -| Param | Type | Description | -| ----------- | --------------- | ---------------------------------------- | -| resultArray | \* | | -| options | \* | Options passed from a block helper. | -| context | \* | The context from within this was called. | + - +## JS API: Window module for ZAP UI +Window module for ZAP UI -### JS API: generator logic~ensureZclPackageId(context) ⇒ -Returns the promise that resolves with the ZCL properties package id. +* [JS API: Window module for ZAP UI](#module_JS API_ Window module for ZAP UI) + * _static_ + * [.initializeElectronUi(port)](#module_JS API_ Window module for ZAP UI.initializeElectronUi) + * [.windowCreateIfNotThere(port)](#module_JS API_ Window module for ZAP UI.windowCreateIfNotThere) + * [.windowCreate(port, filePath, [uiMode])](#module_JS API_ Window module for ZAP UI.windowCreate) ⇒ + * _inner_ + * [~createQueryString(uiMode, standalone, isNew, filePath, restPort)](#module_JS API_ Window module for ZAP UI..createQueryString) ⇒ -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the package id. + -| Param | Type | -| ------- | --------------- | -| context | \* | +### JS API: Window module for ZAP UI.initializeElectronUi(port) +Electron UI initialization. - +Note: You might be tempted to pass `db` to this function. Don't. +That was done before and it's just a lazy way to cut through the +layers between UI and back-end. Should not be done. Any information +UI needs from the database should be retrieved via renderer API. -### JS API: generator logic~ensureZclPackageIds(context) ⇒ +**Kind**: static method of [JS API: Window module for ZAP UI](#module_JS API_ Window module for ZAP UI) -Returns the promise that resolves with all ZCL package id specific to current session. +| Param | Type | +| --- | --- | +| port | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with a list of package id. + -| Param | Type | -| ------- | --------------- | -| context | \* | +### JS API: Window module for ZAP UI.windowCreateIfNotThere(port) +Create a window if none present. - +**Kind**: static method of [JS API: Window module for ZAP UI](#module_JS API_ Window module for ZAP UI) -### JS API: generator logic~ensureTemplatePackageCategory(context) ⇒ +| Param | Type | +| --- | --- | +| port | \* | -Returns a package category of the toplevel template package from context. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: proimise that resolves into a package category +### JS API: Window module for ZAP UI.windowCreate(port, filePath, [uiMode]) ⇒ +Create a window, possibly with a given file path. -| Param | Type | -| ------- | --------------- | -| context | \* | +**Kind**: static method of [JS API: Window module for ZAP UI](#module_JS API_ Window module for ZAP UI) +**Returns**: BrowserWindow that got created - +| Param | Type | Default | +| --- | --- | --- | +| port | \* | | +| filePath | \* | | +| [uiMode] | \* | | -### JS API: generator logic~ensureTemplatePackageId(context) ⇒ + -Returns the promise that resolves with the ZCL properties package id. +### JS API: Window module for ZAP UI~createQueryString(uiMode, standalone, isNew, filePath, restPort) ⇒ +Get url string. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with the package id. +**Kind**: inner method of [JS API: Window module for ZAP UI](#module_JS API_ Window module for ZAP UI) +**Returns**: String -| Param | Type | -| ------- | --------------- | -| context | \* | +| Param | Type | +| --- | --- | +| uiMode | \* | +| standalone | \* | +| isNew | \* | +| filePath | \* | +| restPort | \* | - + -### JS API: generator logic~ensureEndpointTypeIds(context) ⇒ +## JS API: Arguments for ZAP +Arguments for ZAP -Populate the endpoint type ids into the global context. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: endpoint type ids +* [JS API: Arguments for ZAP](#module_JS API_ Arguments for ZAP) + * _static_ + * [.processCommandLineArguments(argv)](#module_JS API_ Arguments for ZAP.processCommandLineArguments) ⇒ + * _inner_ + * [~environmentVariablesDescription()](#module_JS API_ Arguments for ZAP..environmentVariablesDescription) ⇒ -| Param | Type | -| ------- | --------------- | -| context | \* | + - +### JS API: Arguments for ZAP.processCommandLineArguments(argv) ⇒ +Process the command line arguments and resets the state in this file +to the specified values. -### JS API: generator logic~ensureZclClusterSdkExtensions(context, templatePackageId) ⇒ +**Kind**: static method of [JS API: Arguments for ZAP](#module_JS API_ Arguments for ZAP) +**Returns**: parsed argv object -Resolves with cached cluster extensions, but if they don't -exist, it will populate them. +| Param | Type | +| --- | --- | +| argv | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with cluster extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +### JS API: Arguments for ZAP~environmentVariablesDescription() ⇒ +Get environment variable details. - +**Kind**: inner method of [JS API: Arguments for ZAP](#module_JS API_ Arguments for ZAP) +**Returns**: environment varibale details + -### JS API: generator logic~ensureZclDeviceTypeSdkExtensions(context, templatePackageId) ⇒ +## JS API: async reporting +This module provides the mechanism for dealing with the async reporting +from backend to the UI. -Resolves with cached cluster extensions, but if they don't -exist, it will populate them. +This mechanism takes care of: + - dirty flag -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with cluster extensions. -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +* [JS API: async reporting](#module_JS API_ async reporting) + * [~sendDirtyFlagStatus(db, session)](#module_JS API_ async reporting..sendDirtyFlagStatus) + * [~sendNotificationUpdate(db, session)](#module_JS API_ async reporting..sendNotificationUpdate) + * [~startAsyncReporting(db, intervalMs)](#module_JS API_ async reporting..startAsyncReporting) + * [~stopAsyncReporting()](#module_JS API_ async reporting..stopAsyncReporting) - + -### JS API: generator logic~ensureZclAttributeSdkExtensions(context, templatePackageId) ⇒ +### JS API: async reporting~sendDirtyFlagStatus(db, session) +Sends a dirty flag status for a single session. -Resolves with cached attribute extensions, but if they don't -exist, it will populate them. +**Kind**: inner method of [JS API: async reporting](#module_JS API_ async reporting) -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with attribute extensions. +| Param | Type | +| --- | --- | +| db | \* | +| session | \* | -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | + - +### JS API: async reporting~sendNotificationUpdate(db, session) +Sends a dirty flag status for a single session. -### JS API: generator logic~ensureZclAttributeTypeSdkExtensions(context, templatePackageId) ⇒ +**Kind**: inner method of [JS API: async reporting](#module_JS API_ async reporting) -Resolves with cached attribute type extensions, but if they don't -exist, it will populate them. +| Param | Type | +| --- | --- | +| db | \* | +| session | \* | -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with attribute type extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +### JS API: async reporting~startAsyncReporting(db, intervalMs) +Start the interval that will check and report dirty flags. - +**Kind**: inner method of [JS API: async reporting](#module_JS API_ async reporting) -### JS API: generator logic~ensureZclCommandSdkExtensions(context, templatePackageId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| intervalMs | \* | -Resolves with cached command extensions, but if they don't -exist, it will populate them. + -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with command extensions. +### JS API: async reporting~stopAsyncReporting() +Stop the interval that will check and report dirty flags -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +**Kind**: inner method of [JS API: async reporting](#module_JS API_ async reporting) + - +## JS API: Binary utilities +Binary utilities to deal with hex numbers and such. -### JS API: generator logic~ensureZclEventSdkExtensions(context, templatePackageId) ⇒ -Resolves with cached command extensions, but if they don't -exist, it will populate them. +* [JS API: Binary utilities](#module_JS API_ Binary utilities) + * [~int8ToHex(value)](#module_JS API_ Binary utilities..int8ToHex) ⇒ + * [~int16ToHex(value)](#module_JS API_ Binary utilities..int16ToHex) ⇒ + * [~int32ToHex(value)](#module_JS API_ Binary utilities..int32ToHex) ⇒ + * [~stringToHex(value)](#module_JS API_ Binary utilities..stringToHex) ⇒ + * [~bitCount(n)](#module_JS API_ Binary utilities..bitCount) ⇒ + * [~hexToCBytes(value)](#module_JS API_ Binary utilities..hexToCBytes) ⇒ + * [~bitOffset(binary)](#module_JS API_ Binary utilities..bitOffset) + * [~hexToBinary(hex)](#module_JS API_ Binary utilities..hexToBinary) + * [~stringToOneByteLengthPrefixCBytes(value, maxLength, pad)](#module_JS API_ Binary utilities..stringToOneByteLengthPrefixCBytes) ⇒ + * [~stringToTwoByteLengthPrefixCBytes(value, maxLength, pad)](#module_JS API_ Binary utilities..stringToTwoByteLengthPrefixCBytes) ⇒ -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: promise that resolves with command extensions. + -| Param | Type | -| ----------------- | --------------- | -| context | \* | -| templatePackageId | \* | +### JS API: Binary utilities~int8ToHex(value) ⇒ +Takes an int8 value and turns it into a hex. - +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: hex string, 2 characters long without '0x' -### JS API: generator logic~templatePromise(global, promise) +| Param | Type | +| --- | --- | +| value | \* | -Every helper that returns a promise, should -not return the promise directly. So instead of -returning the promise directly, it should return: -return templatePromise(this.global, promise) + -This will ensure that after tag works as expected. +### JS API: Binary utilities~int16ToHex(value) ⇒ +Takes an int16 value and turns it into a hex. -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: hex string, 4 characters long without '0x' -| Param | Type | -| ------- | --------------- | -| global | \* | -| promise | \* | +| Param | Type | +| --- | --- | +| value | \* | - + -### JS API: generator logic~deprecatedHelper(fn, explanation) ⇒ +### JS API: Binary utilities~int32ToHex(value) ⇒ +Takes an int32 value and turns it into a hex. -Function wrapper that can be used when a helper is deprecated. +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: hex string, 8 characters long without '0x' -**Kind**: inner method of [JS API: generator logic](#module*JS API* generator logic) -**Returns**: a function that wraps the original function, with deprecation message. +| Param | Type | +| --- | --- | +| value | \* | -| Param | Type | Description | -| ----------- | --------------- | ----------------------------------------------------------------------- | -| fn | \* | | -| explanation | \* | can contain `text`, or `from`/`to`, or just be a string message itself. | + - +### JS API: Binary utilities~stringToHex(value) ⇒ +Converts a string to the hex value. -## REST API: user data +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: hex string, value.length * 2 + 2 characters long. It appends the terminating NULL, so 0x00 is at the end. -This module provides the API to access zcl specific information. +| Param | Type | +| --- | --- | +| value | \* | -- [REST API: user data](#module*REST API* user data) - - [~getComponentIdsByCluster(db, sessionId, clusterId, side)](#module*REST API* user data..getComponentIdsByCluster) ⇒ \* - - [~httpGetSessionKeyValues(db)](#module*REST API* user data..httpGetSessionKeyValues) ⇒ - - [~httpGetEndpointIds(db)](#module*REST API* user data..httpGetEndpointIds) ⇒ - - [~httpGetSessionNotifications(db)](#module*REST API* user data..httpGetSessionNotifications) ⇒ - - [~httpDeleteSessionNotification(db)](#module*REST API* user data..httpDeleteSessionNotification) ⇒ - - [~httpGetPackageNotifications(db)](#module*REST API* user data..httpGetPackageNotifications) ⇒ - - [~httpGetPackageNotificationsByPackageId(db)](#module*REST API* user data..httpGetPackageNotificationsByPackageId) ⇒ - - [~httpDeletePackageNotification(db)](#module*REST API* user data..httpDeletePackageNotification) ⇒ - - [~httpGetUnseenNotificationCount(db)](#module*REST API* user data..httpGetUnseenNotificationCount) ⇒ - - [~httpGetUnseenNotificationAndUpdate(db)](#module*REST API* user data..httpGetUnseenNotificationAndUpdate) ⇒ - - [~httpPostSaveSessionKeyValue(db)](#module*REST API* user data..httpPostSaveSessionKeyValue) ⇒ - - [~httpPostCluster(db)](#module*REST API* user data..httpPostCluster) ⇒ - - [~httpPostForcedExternal(db)](#module*REST API* user data..httpPostForcedExternal) ⇒ function - - [~httpPostAttributeUpdate(db)](#module*REST API* user data..httpPostAttributeUpdate) ⇒ - - [~httpPostCommandUpdate(db)](#module*REST API* user data..httpPostCommandUpdate) ⇒ - - [~httpPostEventUpdate(db)](#module*REST API* user data..httpPostEventUpdate) ⇒ - - [~httpGetInitialState(db)](#module*REST API* user data..httpGetInitialState) ⇒ - - [~httpGetOption(db)](#module*REST API* user data..httpGetOption) ⇒ - - [~httpGetUiOptions(db)](#module*REST API* user data..httpGetUiOptions) ⇒ - - [~httpGetPackages()](#module*REST API* user data..httpGetPackages) - - [~httpGetAllPackages()](#module*REST API* user data..httpGetAllPackages) - - [~httpPostAddNewPackage()](#module*REST API* user data..httpPostAddNewPackage) - - [~httpPostShareClusterStatesAcrossEndpoints()](#module*REST API* user data..httpPostShareClusterStatesAcrossEndpoints) - - [~httpPostDuplicateEndpoint(db)](#module*REST API* user data..httpPostDuplicateEndpoint) ⇒ - - [~httpPostDuplicateEndpointType(db)](#module*REST API* user data..httpPostDuplicateEndpointType) ⇒ - - [~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId)](#module*REST API* user data..duplicateEndpointTypeClusters) + - +### JS API: Binary utilities~bitCount(n) ⇒ +Given a number, this function returns the number of bits set in the number -### REST API: user data~getComponentIdsByCluster(db, sessionId, clusterId, side) ⇒ \* +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: number of bits set. -Promise that return a list of component Ids required by a specific cluster +| Param | Type | +| --- | --- | +| n | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: \* - array of componentIds + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterId | \* | -| side | \* | +### JS API: Binary utilities~hexToCBytes(value) ⇒ +Takes the raw hex string, such as `abcd` and +converts it into a C constant array, such as +`0xAB, 0xCD`. - +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: C byte array -### REST API: user data~httpGetSessionKeyValues(db) ⇒ +| Param | Type | +| --- | --- | +| value | \* | -HTTP GET: session key values + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: Binary utilities~bitOffset(binary) +Getting a binary string ("0001101010010") it returns the number of zero bits at the end. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) - +| Param | Type | +| --- | --- | +| binary | \* | -### REST API: user data~httpGetEndpointIds(db) ⇒ + -HTTP GET: endpoint ids of endpoints within a specified session +### JS API: Binary utilities~hexToBinary(hex) +Convert a hex number to a binary. Hex has to be in a format +as obtained by intToHex methods above: no '0x' prefix and upper-case +letters, as in "12AB". -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| hex | \* | - + -### REST API: user data~httpGetSessionNotifications(db) ⇒ +### JS API: Binary utilities~stringToOneByteLengthPrefixCBytes(value, maxLength, pad) ⇒ +Returns string as C bytes, prefixed with one-byte length. +If maxLength is greater than length of value, then +the resulting array is padded with 0x00. -HTTP GET: session get notifications +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: Object containing 'length' and 'content', where length +is number of bytes used and content is actual content in C format. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| value | \* | | | +| maxLength | \* | | the maximum length of the used memory in bytes | +| pad | \* | true | If true, then pad with 0x00 until maxLength bytes. | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: Binary utilities~stringToTwoByteLengthPrefixCBytes(value, maxLength, pad) ⇒ +Returns string as C bytes, prefixed with two-byte length +If maxLength is greater than length of value, then +the resulting array is padded with 0x00. -### REST API: user data~httpDeleteSessionNotification(db) ⇒ +**Kind**: inner method of [JS API: Binary utilities](#module_JS API_ Binary utilities) +**Returns**: Object containing 'length' and 'content', where length +is number of bytes used and content is actual content in C format. + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| value | \* | | | +| maxLength | \* | | the maximum length of the used memory in bytes | +| pad | \* | true | If true, then pad with 0x00 until maxLength bytes. | + + + +## JS API: Environment utilities +Environment utilities for ZAP + + +* [JS API: Environment utilities](#module_JS API_ Environment utilities) + * [.setSaveFileFormat(n)](#module_JS API_ Environment utilities.setSaveFileFormat) + * [.defaultFileFormat()](#module_JS API_ Environment utilities.defaultFileFormat) ⇒ + * [.builtinSilabsZclMetafile()](#module_JS API_ Environment utilities.builtinSilabsZclMetafile) ⇒ + * [.builtinSilabsZclSpecialMetafile()](#module_JS API_ Environment utilities.builtinSilabsZclSpecialMetafile) ⇒ + * [.builtinSilabsZclGeneralXmlFile()](#module_JS API_ Environment utilities.builtinSilabsZclGeneralXmlFile) ⇒ + * [.builtinSilabsSpecialZclGeneralSpecialXmlFile()](#module_JS API_ Environment utilities.builtinSilabsSpecialZclGeneralSpecialXmlFile) ⇒ + * [.builtinMatterZclMetafile()](#module_JS API_ Environment utilities.builtinMatterZclMetafile) ⇒ + * [.builtinNewMatterZclMetafile()](#module_JS API_ Environment utilities.builtinNewMatterZclMetafile) ⇒ + * [.builtinDotdotZclMetafile()](#module_JS API_ Environment utilities.builtinDotdotZclMetafile) ⇒ + * [.builtinMatterZclMetafile2()](#module_JS API_ Environment utilities.builtinMatterZclMetafile2) ⇒ + * [.builtinTemplateMetafile()](#module_JS API_ Environment utilities.builtinTemplateMetafile) ⇒ + * [.setDevelopmentEnv()](#module_JS API_ Environment utilities.setDevelopmentEnv) + * [.setProductionEnv()](#module_JS API_ Environment utilities.setProductionEnv) + * [.logInitStdout()](#module_JS API_ Environment utilities.logInitStdout) + * [.logInitLogFile()](#module_JS API_ Environment utilities.logInitLogFile) + * [.setAppDirectory(path)](#module_JS API_ Environment utilities.setAppDirectory) + * [.appDirectory()](#module_JS API_ Environment utilities.appDirectory) ⇒ + * [.iconsDirectory()](#module_JS API_ Environment utilities.iconsDirectory) ⇒ + * [.schemaFile()](#module_JS API_ Environment utilities.schemaFile) ⇒ + * [.sqliteFile(filename)](#module_JS API_ Environment utilities.sqliteFile) ⇒ + * [.sqliteTestFile(id, deleteExistingFile)](#module_JS API_ Environment utilities.sqliteTestFile) ⇒ + * [.zapVersionAsString()](#module_JS API_ Environment utilities.zapVersionAsString) + * [.locateProjectResource(filePath)](#module_JS API_ Environment utilities.locateProjectResource) ⇒ + * [.zapVersion()](#module_JS API_ Environment utilities.zapVersion) ⇒ + * [.baseUrl()](#module_JS API_ Environment utilities.baseUrl) ⇒ + * [.printToStderr(msg)](#module_JS API_ Environment utilities.printToStderr) + * [.log(level, msg, err)](#module_JS API_ Environment utilities.log) + * [.logInfo(msg, err)](#module_JS API_ Environment utilities.logInfo) + * [.logError(msg, err)](#module_JS API_ Environment utilities.logError) + * [.logWarning(msg, err)](#module_JS API_ Environment utilities.logWarning) + * [.logSql(msg, err)](#module_JS API_ Environment utilities.logSql) + * [.logBrowser(msg, err)](#module_JS API_ Environment utilities.logBrowser) + * [.logIpc(msg, err)](#module_JS API_ Environment utilities.logIpc) + * [.logDebug(msg, err)](#module_JS API_ Environment utilities.logDebug) + * [.isMatchingVersion(versionsArray, providedVersion)](#module_JS API_ Environment utilities.isMatchingVersion) ⇒ + * [.versionsCheck()](#module_JS API_ Environment utilities.versionsCheck) ⇒ + * [.httpStaticContent()](#module_JS API_ Environment utilities.httpStaticContent) ⇒ + + + +### JS API: Environment utilities.setSaveFileFormat(n) +Set save file format. + +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) + +| Param | Type | +| --- | --- | +| n | \* | + + + +### JS API: Environment utilities.defaultFileFormat() ⇒ +Get save file format. + +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: saveFileFormat + + +### JS API: Environment utilities.builtinSilabsZclMetafile() ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: path to zcl.json file + -HTTP DELETE: session delete notifications +### JS API: Environment utilities.builtinSilabsZclSpecialMetafile() ⇒ +Used to retrive zcl-special.json by zcl reload test in zcl-loader.test.js -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: path to zcl-special.json file used by zcl-loader.test.js + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: Environment utilities.builtinSilabsZclGeneralXmlFile() ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: path to general.xml file + - +### JS API: Environment utilities.builtinSilabsSpecialZclGeneralSpecialXmlFile() ⇒ +Used to retrive general-special.xml by zcl reload test in zcl-loader.test.js -### REST API: user data~httpGetPackageNotifications(db) ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: path to general-special.xml file used by zcl-loader.test.js + -HTTP GET: package get notifications +### JS API: Environment utilities.builtinMatterZclMetafile() ⇒ +Get builtin matter ZCL json file -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: matter ZCL json file + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: Environment utilities.builtinNewMatterZclMetafile() ⇒ +Get builtin matter ZCL json file - +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: matter ZCL json file + -### REST API: user data~httpGetPackageNotificationsByPackageId(db) ⇒ +### JS API: Environment utilities.builtinDotdotZclMetafile() ⇒ +Get builtin dotdot ZCL json file -HTTP GET: package get notifications +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: dotdot ZCL json file + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: Environment utilities.builtinMatterZclMetafile2() ⇒ +Get builtin Matter ZCL json file -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: matter ZCL json file + - +### JS API: Environment utilities.builtinTemplateMetafile() ⇒ +No builtin meta template file. -### REST API: user data~httpDeletePackageNotification(db) ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: null + -HTTP DELETE: session delete notifications +### JS API: Environment utilities.setDevelopmentEnv() +Set up the devlopment environment. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: Environment utilities.setProductionEnv() +Set up the production environment. - +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) + -### REST API: user data~httpGetUnseenNotificationCount(db) ⇒ +### JS API: Environment utilities.logInitStdout() +set explicit_logger_set -HTTP GET: session get unseen session notification count +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: Environment utilities.logInitLogFile() +Create zap.log file for logging. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) + - +### JS API: Environment utilities.setAppDirectory(path) +Set the state directory. This method is intended to be called +only at the application startup, when CLI args are being parsed. +This method honors '~/' being the first characters in its argument. -### REST API: user data~httpGetUnseenNotificationAndUpdate(db) ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -HTTP GET: session update all session notifications to be SEEN +| Param | Type | Description | +| --- | --- | --- | +| path | \* | Absolute path. Typically '~/.zap'. | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: Environment utilities.appDirectory() ⇒ +Returns an app directory. It creates it, if it doesn't exist - +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: state directory, which is guaranteed to be already existing + -### REST API: user data~httpPostSaveSessionKeyValue(db) ⇒ +### JS API: Environment utilities.iconsDirectory() ⇒ +Get path to icons directory. -HTTP POST: save session key value +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: path to icons directory + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: Environment utilities.schemaFile() ⇒ +Get path to sqlite schema file. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: path to sqlite schema file + - +### JS API: Environment utilities.sqliteFile(filename) ⇒ +Get sqlite file path relative to app directory. -### REST API: user data~httpPostCluster(db) ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: sqlite file path -HTTP POST: cluster +| Param | Type | +| --- | --- | +| filename | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: Environment utilities.sqliteTestFile(id, deleteExistingFile) ⇒ +Get sqlite test file name. - +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: sqlite test file name -### REST API: user data~httpPostForcedExternal(db) ⇒ function +| Param | Type | +| --- | --- | +| id | \* | +| deleteExistingFile | \* | -Handles a POST request to retrieve forced external storage options. + -This function is designed to be used as a middleware in an Express.js route. It extracts the session ID from the request, -queries the database for package information associated with that session, and then retrieves forced external storage -options for the identified package. The results are sent back to the client as a JSON response. +### JS API: Environment utilities.zapVersionAsString() +Returns a version as a single on-line string. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: function - An asynchronous function that takes Express.js request and response objects. +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) + -| Param | Type | Description | -| ----- | ------------------- | ------------------------------- | -| db | Object | The database connection object. | +### JS API: Environment utilities.locateProjectResource(filePath) ⇒ +This function locates a resource in the project, such as various +JSON files and zcl-builtin stuff. - +It needs to adapt to a change in path that can occur when +things are copied into the dist/ directory. -### REST API: user data~httpPostAttributeUpdate(db) ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: located project resource -HTTP POST attribute update +| Param | +| --- | +| filePath | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: Environment utilities.zapVersion() ⇒ +Returns the zap version. - +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: zap version, which is an object that +contains 'version', 'featureLevel', 'hash', 'timestamp' and 'date' + -### REST API: user data~httpPostCommandUpdate(db) ⇒ +### JS API: Environment utilities.baseUrl() ⇒ +Get zapBaseUrl. -HTTP POST: command update +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: zapBaseUrl + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: Environment utilities.printToStderr(msg) +Prints the data to stderr, without much fuss. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) - +| Param | +| --- | +| msg | -### REST API: user data~httpPostEventUpdate(db) ⇒ + -HTTP POST: command update +### JS API: Environment utilities.log(level, msg, err) +Base level common logger. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| level | \* | +| msg | \* | +| err | \* | - + -### REST API: user data~httpGetInitialState(db) ⇒ +### JS API: Environment utilities.logInfo(msg, err) +Info level message. -HTTP GET: initial state +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| msg | \* | +| err | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: Environment utilities.logError(msg, err) +Error level message. -### REST API: user data~httpGetOption(db) ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -HTTP GET: option +| Param | Type | +| --- | --- | +| msg | \* | +| err | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: Environment utilities.logWarning(msg, err) +Warning level message. - +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -### REST API: user data~httpGetUiOptions(db) ⇒ +| Param | Type | +| --- | --- | +| msg | \* | +| err | \* | -HTTP GET: ui_options + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: UI options from all packages. +### JS API: Environment utilities.logSql(msg, err) +Sql level message. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) - +| Param | Type | +| --- | --- | +| msg | \* | +| err | \* | -### REST API: user data~httpGetPackages() + -HTTP GET: Project packages +### JS API: Environment utilities.logBrowser(msg, err) +Browser level message. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -### REST API: user data~httpGetAllPackages() +| Param | Type | +| --- | --- | +| msg | \* | +| err | \* | -HTTP GET: All Packages + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - +### JS API: Environment utilities.logIpc(msg, err) +IPC level message. -### REST API: user data~httpPostAddNewPackage() +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -HTTP POST: Add new project package +| Param | Type | +| --- | --- | +| msg | \* | +| err | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - + -### REST API: user data~httpPostShareClusterStatesAcrossEndpoints() +### JS API: Environment utilities.logDebug(msg, err) +Debug level message. -HTTP POST: Unify all Attributes / Command states if a certain cluster is enabled -on more than one endpoint. +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) -1. In Zigbee world, the Attribute / Command configurations is a global singleton entity. - If one cluster is enabled by more than 1 endpoint, the attribute states (on/off) should be - identical across each endpoint. - To emulate the global singleton entity, this function ensures Attribute changes - are applied to all endpoint specific attribute fields. - When unify event is triggered, this function will align all shared Attribute/Command states - to the first matching entry from beginning of the endpoint list. -2. (native case in ZAP) In Matter, the Attribute configuration are endpoint specific. +| Param | Type | +| --- | --- | +| msg | \* | +| err | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - + -### REST API: user data~httpPostDuplicateEndpoint(db) ⇒ +### JS API: Environment utilities.isMatchingVersion(versionsArray, providedVersion) ⇒ +Returns true if major or minor component of versions is different. -Creating a duplicate for endpoint +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: boolean -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: newly created endpoint id +| Param | Type | +| --- | --- | +| versionsArray | \* | +| providedVersion | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: Environment utilities.versionsCheck() ⇒ +Returns true if versions of node and electron are matching. +If versions are not matching, it prints out a warhing +and returns false. -### REST API: user data~httpPostDuplicateEndpointType(db) ⇒ +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: true or false, depending on match + -Creating a duplicate for endpoint-type and endpoint-type-attributes +### JS API: Environment utilities.httpStaticContent() ⇒ +Returns path to HTTP static content while taking into account DEV / PROD modes. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: newly created endpoint-type id +**Kind**: static method of [JS API: Environment utilities](#module_JS API_ Environment utilities) +**Returns**: full path to HTTP static content + -| Param | Type | -| ----- | --------------- | -| db | \* | +## External API: External API utilities +External helper utilities for ZAP - -### REST API: user data~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId) +* [External API: External API utilities](#module_External API_ External API utilities) + * [~availableClusters(context)](#module_External API_ External API utilities..availableClusters) ⇒ + * [~availableEvents(context)](#module_External API_ External API utilities..availableEvents) ⇒ + * [~availableCommands(context)](#module_External API_ External API utilities..availableCommands) ⇒ + * [~availableAttributes(context)](#module_External API_ External API utilities..availableAttributes) ⇒ + * [~helperWrapper(wrappedHelper)](#module_External API_ External API utilities..helperWrapper) ⇒ function + * [~registerHelpers(singleHelper, registerHelper, context)](#module_External API_ External API utilities..registerHelpers) + * [~executeHelperFunction(functionName, context, helper)](#module_External API_ External API utilities..executeHelperFunction) ⇒ Promise -duplicate all clusters and attributes of an old endpoint type, using oldEndpointType id and newly created endpointType id + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) +### External API: External API utilities~availableClusters(context) ⇒ +Returns all available clusters. -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| oldEndpointTypeId | \* | -| newEndpointTypeId | \* | +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available clusters - +| Param | Type | +| --- | --- | +| context | \* | -## REST API: admin functions + -This module provides the REST API to the admin functions. +### External API: External API utilities~availableEvents(context) ⇒ +Returns all available events. -- [REST API: admin functions](#module*REST API* admin functions) - - [~httpPostSql(db, app)](#module*REST API* admin functions..httpPostSql) ⇒ - - [~httpGetVersion(db)](#module*REST API* admin functions..httpGetVersion) ⇒ - - [~httpGetCache(db)](#module*REST API* admin functions..httpGetCache) +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available events - +| Param | Type | +| --- | --- | +| context | \* | -### REST API: admin functions~httpPostSql(db, app) ⇒ + -API: /sql -Request JSON: +### External API: External API utilities~availableCommands(context) ⇒ +Returns all available commands. -
    -  {
    -    sql: SQL Query
    -  }
    -
    +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available ccommands -Response JSON: +| Param | Type | +| --- | --- | +| context | \* | -
    -  {
    -    result: Array of rows.
    -  }
    -
    + -**Kind**: inner method of [REST API: admin functions](#module*REST API* admin functions) -**Returns**: callback for the express uri registration +### External API: External API utilities~availableAttributes(context) ⇒ +Returns all available attributes. -| Param | Type | -| ----- | --------------- | -| db | \* | -| app | \* | +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available attributes - +| Param | Type | +| --- | --- | +| context | \* | -### REST API: admin functions~httpGetVersion(db) ⇒ + -API: /version -Response JSON: +### External API: External API utilities~helperWrapper(wrappedHelper) ⇒ function +Wraps a helper function to add usage tracking and error handling. -
    -  {
    -    version: full version.
    -    featureLevel: feature level.
    -    hash: git hash code
    -    timestamp: Unix time from the last commit in the repo.
    -    date: Date of the last commit in the repo.
    -  }
    -
    +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: function - - The wrapped helper function. -**Kind**: inner method of [REST API: admin functions](#module*REST API* admin functions) -**Returns**: callback for the express uri registration. +| Param | Type | Description | +| --- | --- | --- | +| wrappedHelper | function | The helper function to wrap. | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### External API: External API utilities~registerHelpers(singleHelper, registerHelper, context) +Registers a helper function. -### REST API: admin functions~httpGetCache(db) +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) -API: /cache -Response JSON: +| Param | Type | Description | +| --- | --- | --- | +| singleHelper | string | The name of the helper function. | +| registerHelper | function | The helper function to register. | +| context | Object | The context object. | -
    -	 {
    -     keys: 0,    // global key count
    -     hits: 0,    // global hit count
    -     misses: 0,  // global miss count
    -     ksize: 0,   // global key size count in approximately bytes
    -     vsize: 0    // global value size count in approximately bytes
    -	 }
    -
    + -**Kind**: inner method of [REST API: admin functions](#module*REST API* admin functions) +### External API: External API utilities~executeHelperFunction(functionName, context, helper) ⇒ Promise +Executes a helper function from a script file. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: Promise - - A Promise that resolves with the result of the helper function. - +| Param | Type | Description | +| --- | --- | --- | +| functionName | string | The name of the helper function to execute. | +| context | Object | The context object to pass to the helper function. | +| helper | string | The path to the helper file containing the helper functions. | -## REST API: endpoint + -This module provides the REST API to the user specific data. +## External API: External API utilities +External Registry utilities for ZAP -- [REST API: endpoint](#module*REST API* endpoint) - - [~httpDeleteEndpoint(db)](#module*REST API* endpoint..httpDeleteEndpoint) ⇒ - - [~httpDeleteEndpointType(db)](#module*REST API* endpoint..httpDeleteEndpointType) ⇒ - - [~httpPostEndpoint(db)](#module*REST API* endpoint..httpPostEndpoint) ⇒ - - [~httpPatchEndpoint(db)](#module*REST API* endpoint..httpPatchEndpoint) ⇒ - - [~httpPostEndpointType(db)](#module*REST API* endpoint..httpPostEndpointType) ⇒ - - [~httpPatchEndpointType(db)](#module*REST API* endpoint..httpPatchEndpointType) ⇒ - +* [External API: External API utilities](#module_External API_ External API utilities) + * [~availableClusters(context)](#module_External API_ External API utilities..availableClusters) ⇒ + * [~availableEvents(context)](#module_External API_ External API utilities..availableEvents) ⇒ + * [~availableCommands(context)](#module_External API_ External API utilities..availableCommands) ⇒ + * [~availableAttributes(context)](#module_External API_ External API utilities..availableAttributes) ⇒ + * [~helperWrapper(wrappedHelper)](#module_External API_ External API utilities..helperWrapper) ⇒ function + * [~registerHelpers(singleHelper, registerHelper, context)](#module_External API_ External API utilities..registerHelpers) + * [~executeHelperFunction(functionName, context, helper)](#module_External API_ External API utilities..executeHelperFunction) ⇒ Promise -### REST API: endpoint~httpDeleteEndpoint(db) ⇒ + -HTTP DELETE: endpoint +### External API: External API utilities~availableClusters(context) ⇒ +Returns all available clusters. -**Kind**: inner method of [REST API: endpoint](#module*REST API* endpoint) -**Returns**: callback for the express uri registration +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available clusters -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| context | \* | - + -### REST API: endpoint~httpDeleteEndpointType(db) ⇒ +### External API: External API utilities~availableEvents(context) ⇒ +Returns all available events. -HTTP DELETE: endpoint type +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available events -**Kind**: inner method of [REST API: endpoint](#module*REST API* endpoint) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| context | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### External API: External API utilities~availableCommands(context) ⇒ +Returns all available commands. -### REST API: endpoint~httpPostEndpoint(db) ⇒ +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available ccommands -HTTP POST: endpoint +| Param | Type | +| --- | --- | +| context | \* | -**Kind**: inner method of [REST API: endpoint](#module*REST API* endpoint) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### External API: External API utilities~availableAttributes(context) ⇒ +Returns all available attributes. - +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available attributes -### REST API: endpoint~httpPatchEndpoint(db) ⇒ +| Param | Type | +| --- | --- | +| context | \* | -HTTP POST: endpoint + -**Kind**: inner method of [REST API: endpoint](#module*REST API* endpoint) -**Returns**: callback for the express uri registration +### External API: External API utilities~helperWrapper(wrappedHelper) ⇒ function +Wraps a helper function to add usage tracking and error handling. -| Param | Type | Description | -| ----- | --------------- | --------------------------------------- | -| db | \* | Main database to use for the operation. | +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: function - - The wrapped helper function. - +| Param | Type | Description | +| --- | --- | --- | +| wrappedHelper | function | The helper function to wrap. | -### REST API: endpoint~httpPostEndpointType(db) ⇒ + -HTTP POST endpoint type +### External API: External API utilities~registerHelpers(singleHelper, registerHelper, context) +Registers a helper function. -**Kind**: inner method of [REST API: endpoint](#module*REST API* endpoint) -**Returns**: callback for the express uri registration +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | Description | +| --- | --- | --- | +| singleHelper | string | The name of the helper function. | +| registerHelper | function | The helper function to register. | +| context | Object | The context object. | - + -### REST API: endpoint~httpPatchEndpointType(db) ⇒ +### External API: External API utilities~executeHelperFunction(functionName, context, helper) ⇒ Promise +Executes a helper function from a script file. -HTTP POST: endpoint type update +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: Promise - - A Promise that resolves with the result of the helper function. -**Kind**: inner method of [REST API: endpoint](#module*REST API* endpoint) -**Returns**: callback for the express uri registration +| Param | Type | Description | +| --- | --- | --- | +| functionName | string | The name of the helper function to execute. | +| context | Object | The context object to pass to the helper function. | +| helper | string | The path to the helper file containing the helper functions. | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +## External API: External API utilities +External helper utilities for ZAP -## External IDE interface. -This module provides the interface to an extenal IDE: Simplicity Studio. +* [External API: External API utilities](#module_External API_ External API utilities) + * [~availableClusters(context)](#module_External API_ External API utilities..availableClusters) ⇒ + * [~availableEvents(context)](#module_External API_ External API utilities..availableEvents) ⇒ + * [~availableCommands(context)](#module_External API_ External API utilities..availableCommands) ⇒ + * [~availableAttributes(context)](#module_External API_ External API utilities..availableAttributes) ⇒ + * [~helperWrapper(wrappedHelper)](#module_External API_ External API utilities..helperWrapper) ⇒ function + * [~registerHelpers(singleHelper, registerHelper, context)](#module_External API_ External API utilities..registerHelpers) + * [~executeHelperFunction(functionName, context, helper)](#module_External API_ External API utilities..executeHelperFunction) ⇒ Promise - + -## REST API: generation functions +### External API: External API utilities~availableClusters(context) ⇒ +Returns all available clusters. -This module provides the REST API to the generation. +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available clusters -- [REST API: generation functions](#module*REST API* generation functions) - - [~httpGetPreviewNameIndex(db)](#module*REST API* generation functions..httpGetPreviewNameIndex) ⇒ - - [~httpGetPreviewName(db)](#module*REST API* generation functions..httpGetPreviewName) ⇒ - - [~httpGetPreview(db)](#module*REST API* generation functions..httpGetPreview) ⇒ - - [~httpPutGenerate(db)](#module*REST API* generation functions..httpPutGenerate) ⇒ - - [~httpPostComponentAdd(db)](#module*REST API* generation functions..httpPostComponentAdd) +| Param | Type | +| --- | --- | +| context | \* | - + -### REST API: generation functions~httpGetPreviewNameIndex(db) ⇒ +### External API: External API utilities~availableEvents(context) ⇒ +Returns all available events. -HTTP GET: preview single file with index. +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available events -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| context | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### External API: External API utilities~availableCommands(context) ⇒ +Returns all available commands. -### REST API: generation functions~httpGetPreviewName(db) ⇒ +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available ccommands -HTTP GET: Preview a single file. +| Param | Type | +| --- | --- | +| context | \* | -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### External API: External API utilities~availableAttributes(context) ⇒ +Returns all available attributes. - +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: all available attributes -### REST API: generation functions~httpGetPreview(db) ⇒ +| Param | Type | +| --- | --- | +| context | \* | -HTTP GET: total preview object. + -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration +### External API: External API utilities~helperWrapper(wrappedHelper) ⇒ function +Wraps a helper function to add usage tracking and error handling. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: function - - The wrapped helper function. - +| Param | Type | Description | +| --- | --- | --- | +| wrappedHelper | function | The helper function to wrap. | -### REST API: generation functions~httpPutGenerate(db) ⇒ + -HTTP PUT: performs local generation into a specified directory. +### External API: External API utilities~registerHelpers(singleHelper, registerHelper, context) +Registers a helper function. -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | Description | +| --- | --- | --- | +| singleHelper | string | The name of the helper function. | +| registerHelper | function | The helper function to register. | +| context | Object | The context object. | - + -### REST API: generation functions~httpPostComponentAdd(db) +### External API: External API utilities~executeHelperFunction(functionName, context, helper) ⇒ Promise +Executes a helper function from a script file. -Enable components by 'componentId' or corresponding components specified, via 'defaults', by 'clusterId' / 'roles' +**Kind**: inner method of [External API: External API utilities](#module_External API_ External API utilities) +**Returns**: Promise - - A Promise that resolves with the result of the helper function. -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) +| Param | Type | Description | +| --- | --- | --- | +| functionName | string | The name of the helper function to execute. | +| context | Object | The context object to pass to the helper function. | +| helper | string | The path to the helper file containing the helper functions. | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +## JS API: Iterator utilities +This module provides API to access various iterator utilities that can then +be used to build iterator helpers. -## REST API: generation functions + -This module provides the REST API to the IDE component handling. +### JS API: Iterator utilities~all\_user\_cluster\_commands\_helper() +Helper for add_user_cluster_commands that does all the work except the +collectBlocks. This allows other iterators to further filter the list +before doing collectBlocks. -- [REST API: generation functions](#module*REST API* generation functions) - - [~httpGetPreviewNameIndex(db)](#module*REST API* generation functions..httpGetPreviewNameIndex) ⇒ - - [~httpGetPreviewName(db)](#module*REST API* generation functions..httpGetPreviewName) ⇒ - - [~httpGetPreview(db)](#module*REST API* generation functions..httpGetPreview) ⇒ - - [~httpPutGenerate(db)](#module*REST API* generation functions..httpPutGenerate) ⇒ - - [~httpPostComponentAdd(db)](#module*REST API* generation functions..httpPostComponentAdd) +**Kind**: inner method of [JS API: Iterator utilities](#module_JS API_ Iterator utilities) + - +## JS API: post-import. +This module contains the API functions for the post-load +scripting functionality. -### REST API: generation functions~httpGetPreviewNameIndex(db) ⇒ + -HTTP GET: preview single file with index. +## JS API: post-import. +This module contains the API functions for the post-load +scripting functionality. -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +## JS API: SDK utilities + - +### JS API: SDK utilities~readSdkJson(sdkPath, logger) +This function reads in the sdk.json that is passed as sdkPath, +and resolve the promise with the sdk object. +logger is used for printouts. -### REST API: generation functions~httpGetPreviewName(db) ⇒ +**Kind**: inner method of [JS API: SDK utilities](#module_JS API_ SDK utilities) -HTTP GET: Preview a single file. +| Param | Type | +| --- | --- | +| sdkPath | \* | +| logger | \* | -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +## JS API: string utilities - +* [JS API: string utilities](#module_JS API_ string utilities) + * [~toCamelCase(str)](#module_JS API_ string utilities..toCamelCase) ⇒ + * [~toSpacedLowercase(str)](#module_JS API_ string utilities..toSpacedLowercase) ⇒ + * [~toSnakeCaseAllCaps(label)](#module_JS API_ string utilities..toSnakeCaseAllCaps) + * [~toSnakeCase(str)](#module_JS API_ string utilities..toSnakeCase) ⇒ + * [~toCleanSymbol(label)](#module_JS API_ string utilities..toCleanSymbol) + * [~toCleanSymbolAsKebabCase(label)](#module_JS API_ string utilities..toCleanSymbolAsKebabCase) + * [~toCleanMacro(label)](#module_JS API_ string utilities..toCleanMacro) ⇒ + * [~isDigit(ch)](#module_JS API_ string utilities..isDigit) -### REST API: generation functions~httpGetPreview(db) ⇒ + -HTTP GET: total preview object. +### JS API: string utilities~toCamelCase(str) ⇒ +Given a string convert it into a camelCased string -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) +**Returns**: a spaced out string in lowercase +**Parem**: \* firstLower if True the it starts with lowecase. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| str | \* | - + -### REST API: generation functions~httpPutGenerate(db) ⇒ +### JS API: string utilities~toSpacedLowercase(str) ⇒ +Get spaced out lower case string from the given string. -HTTP PUT: performs local generation into a specified directory. +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) +**Returns**: spaced out lower case string -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| str | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: string utilities~toSnakeCaseAllCaps(label) +Takes a label, and delimits is on camelcasing. +For example: + VerySimpleLabel will turn into VERY_SIMPLE_LABEL -### REST API: generation functions~httpPostComponentAdd(db) +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) -Enable components by 'componentId' or corresponding components specified, via 'defaults', by 'clusterId' / 'roles' +| Param | Type | +| --- | --- | +| label | \* | -**Kind**: inner method of [REST API: generation functions](#module*REST API* generation functions) + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: string utilities~toSnakeCase(str) ⇒ +Get snake case string from the given string. - +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) +**Returns**: snake case string -## REST API: initialization functions +| Param | Type | +| --- | --- | +| str | \* | -This module provides the REST API to the session initialization + -- [REST API: initialization functions](#module*REST API* initialization functions) - - [~sessionAttempt(db)](#module*REST API* initialization functions..sessionAttempt) ⇒ - - [~sessionCreate(db)](#module*REST API* initialization functions..sessionCreate) ⇒ - - [~initializeSession(db, options:)](#module*REST API* initialization functions..initializeSession) ⇒ - - [~loadPreviousSessions(db)](#module*REST API* initialization functions..loadPreviousSessions) ⇒ - - [~init(db)](#module*REST API* initialization functions..init) ⇒ +### JS API: string utilities~toCleanSymbol(label) +returns a string after converting ':' and '-' into '_' - +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) -### REST API: initialization functions~sessionAttempt(db) ⇒ +| Param | Type | +| --- | --- | +| label | \* | -This function returns Properties, Templates and Dirty-Sessions + -**Kind**: inner method of [REST API: initialization functions](#module*REST API* initialization functions) -**Returns**: An async function that handles HTTP requests +### JS API: string utilities~toCleanSymbolAsKebabCase(label) +returns a string after converting ':' and '_' into '-' -| Param | Type | Description | -| ----- | --------------- | ------------------------------ | -| db | \* | The database connection object | +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) - +| Param | Type | +| --- | --- | +| label | \* | -### REST API: initialization functions~sessionCreate(db) ⇒ + -This function creates a new session. +### JS API: string utilities~toCleanMacro(label) ⇒ +Formats label as a C macro. This method performs a very simply substition +of illegal characters, such as ' ', ':' and such into a '_' character. -**Kind**: inner method of [REST API: initialization functions](#module*REST API* initialization functions) -**Returns**: An async function that handles HTTP requests. The function extracts session parameters from the request, -ensures the user and session exist in the database, and populates the session options with the provided packages. +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) +**Returns**: Label formatted as C macro. -| Param | Type | Description | -| ----- | --------------- | ------------------------------ | -| db | \* | The database connection object | +| Param | Type | +| --- | --- | +| label | \* | - + -### REST API: initialization functions~initializeSession(db, options:) ⇒ +### JS API: string utilities~isDigit(ch) +Returns true if given character is a digit. -This function creates a new session with its packages according to selected Properties and Templates +**Kind**: inner method of [JS API: string utilities](#module_JS API_ string utilities) -**Kind**: inner method of [REST API: initialization functions](#module*REST API* initialization functions) -**Returns**: A success message. +| Param | Type | +| --- | --- | +| ch | \* | -| Param | Type | Description | -| -------- | --------------- | -------------------------------------- | -| db | \* | | -| options: | \* | object containing 'zcl' and 'template' | + - +## JS API: Studio utilities + -### REST API: initialization functions~loadPreviousSessions(db) ⇒ +### JS API: Studio utilities~projectName(db, sessionId) ⇒ +Extract project name from the Studio project path -This function reloads previous session by user selected session's id +**Kind**: inner method of [JS API: Studio utilities](#module_JS API_ Studio utilities) +**Returns**: '' if parsing fails -**Kind**: inner method of [REST API: initialization functions](#module*REST API* initialization functions) -**Returns**: A success message. +| Param | Type | +| --- | --- | +| db | | +| sessionId | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +## JS API: type related utilities -### REST API: initialization functions~init(db) ⇒ +* [JS API: type related utilities](#module_JS API_ type related utilities) + * [~typeSize(db, zclPackageId, type)](#module_JS API_ type related utilities..typeSize) + * [~typeSizeAttribute(db, zclPackageIds, at, [defaultValue])](#module_JS API_ type related utilities..typeSizeAttribute) ⇒ + * [~convertFloatToBigEndian(value, size)](#module_JS API_ type related utilities..convertFloatToBigEndian) ⇒ + * [~convertIntToBigEndian(value, size)](#module_JS API_ type related utilities..convertIntToBigEndian) ⇒ + * [~longTypeDefaultValue(size, type, value)](#module_JS API_ type related utilities..longTypeDefaultValue) ⇒ + * [~convertToCliType(str)](#module_JS API_ type related utilities..convertToCliType) ⇒ + * [~isString(type)](#module_JS API_ type related utilities..isString) ⇒ + * [~isFloat(type)](#module_JS API_ type related utilities..isFloat) ⇒ + * [~isSignedInteger(db, sessionId, type)](#module_JS API_ type related utilities..isSignedInteger) ⇒ Promise.<boolean> + * [~isOneBytePrefixedString(type)](#module_JS API_ type related utilities..isOneBytePrefixedString) ⇒ + * [~isTwoBytePrefixedString(type)](#module_JS API_ type related utilities..isTwoBytePrefixedString) ⇒ + * [~nullStringDefaultValue(type)](#module_JS API_ type related utilities..nullStringDefaultValue) ⇒ string + * [~getSignAndSizeOfZclType(type, context, options)](#module_JS API_ type related utilities..getSignAndSizeOfZclType) ⇒ + * [~intToHexString(n, byteCount)](#module_JS API_ type related utilities..intToHexString) ⇒ + * [~hexStringToInt(s)](#module_JS API_ type related utilities..hexStringToInt) ⇒ -Init function from the App.vue + -**Kind**: inner method of [REST API: initialization functions](#module*REST API* initialization functions) -**Returns**: A success message. +### JS API: type related utilities~typeSize(db, zclPackageId, type) +This function resolves with the size of a given type. +-1 means that this size is variable. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) - +| Param | Type | +| --- | --- | +| db | \* | +| zclPackageId | \* | +| type | \* | -## REST API: static zcl functions + -This module provides the REST API to the static zcl queries. +### JS API: type related utilities~typeSizeAttribute(db, zclPackageIds, at, [defaultValue]) ⇒ +Returns the size of a real attribute, taking type size and defaults +into consideration, so that strings are properly sized. -- [REST API: static zcl functions](#module*REST API* static zcl functions) - - [~httpGetZclEntity(app)](#module*REST API* static zcl functions..httpGetZclEntity) - - [~httpGetZclExtension(db)](#module*REST API* static zcl functions..httpGetZclExtension) ⇒ +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: Promise that resolves into the size of the attribute. - +| Param | Type | Default | +| --- | --- | --- | +| db | \* | | +| zclPackageIds | \* | | +| at | \* | | +| [defaultValue] | \* | | -### REST API: static zcl functions~httpGetZclEntity(app) + -API: /zcl/:entity/:id +### JS API: type related utilities~convertFloatToBigEndian(value, size) ⇒ +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: The big endian value for a given float value padded with +the given size. The value is returned in hex format and prefixed with '0x'. -**Kind**: inner method of [REST API: static zcl functions](#module*REST API* static zcl functions) +| Param | Type | +| --- | --- | +| value | \* | +| size | \* | -| Param | Type | Description | -| ----- | --------------- | ----------------- | -| app | \* | Express instance. | + - +### JS API: type related utilities~convertIntToBigEndian(value, size) ⇒ +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: The big endian value for a given integer value padded with +the given size. The value is returned in hex format and prefixed with '0x'. -### REST API: static zcl functions~httpGetZclExtension(db) ⇒ +| Param | Type | +| --- | --- | +| value | \* | +| size | \* | -API: /zclExtension/:entity/:extension + -**Kind**: inner method of [REST API: static zcl functions](#module*REST API* static zcl functions) -**Returns**: zcl extension handler +### JS API: type related utilities~longTypeDefaultValue(size, type, value) ⇒ +If the type is more than 2 bytes long, then this method creates +the default byte array. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: string which is a C-formatted byte array. - +| Param | Type | Description | +| --- | --- | --- | +| size | \* | Size of bytes generated. | +| type | \* | Type of the object. | +| value | \* | Default value. | -## REST API: user data + -This module provides the REST API to the user specific data. +### JS API: type related utilities~convertToCliType(str) ⇒ +Conversion to a CLI type. THis is here temporarily until we come up +with a proper type engine. -- [REST API: user data](#module*REST API* user data) - - [~getComponentIdsByCluster(db, sessionId, clusterId, side)](#module*REST API* user data..getComponentIdsByCluster) ⇒ \* - - [~httpGetSessionKeyValues(db)](#module*REST API* user data..httpGetSessionKeyValues) ⇒ - - [~httpGetEndpointIds(db)](#module*REST API* user data..httpGetEndpointIds) ⇒ - - [~httpGetSessionNotifications(db)](#module*REST API* user data..httpGetSessionNotifications) ⇒ - - [~httpDeleteSessionNotification(db)](#module*REST API* user data..httpDeleteSessionNotification) ⇒ - - [~httpGetPackageNotifications(db)](#module*REST API* user data..httpGetPackageNotifications) ⇒ - - [~httpGetPackageNotificationsByPackageId(db)](#module*REST API* user data..httpGetPackageNotificationsByPackageId) ⇒ - - [~httpDeletePackageNotification(db)](#module*REST API* user data..httpDeletePackageNotification) ⇒ - - [~httpGetUnseenNotificationCount(db)](#module*REST API* user data..httpGetUnseenNotificationCount) ⇒ - - [~httpGetUnseenNotificationAndUpdate(db)](#module*REST API* user data..httpGetUnseenNotificationAndUpdate) ⇒ - - [~httpPostSaveSessionKeyValue(db)](#module*REST API* user data..httpPostSaveSessionKeyValue) ⇒ - - [~httpPostCluster(db)](#module*REST API* user data..httpPostCluster) ⇒ - - [~httpPostForcedExternal(db)](#module*REST API* user data..httpPostForcedExternal) ⇒ function - - [~httpPostAttributeUpdate(db)](#module*REST API* user data..httpPostAttributeUpdate) ⇒ - - [~httpPostCommandUpdate(db)](#module*REST API* user data..httpPostCommandUpdate) ⇒ - - [~httpPostEventUpdate(db)](#module*REST API* user data..httpPostEventUpdate) ⇒ - - [~httpGetInitialState(db)](#module*REST API* user data..httpGetInitialState) ⇒ - - [~httpGetOption(db)](#module*REST API* user data..httpGetOption) ⇒ - - [~httpGetUiOptions(db)](#module*REST API* user data..httpGetUiOptions) ⇒ - - [~httpGetPackages()](#module*REST API* user data..httpGetPackages) - - [~httpGetAllPackages()](#module*REST API* user data..httpGetAllPackages) - - [~httpPostAddNewPackage()](#module*REST API* user data..httpPostAddNewPackage) - - [~httpPostShareClusterStatesAcrossEndpoints()](#module*REST API* user data..httpPostShareClusterStatesAcrossEndpoints) - - [~httpPostDuplicateEndpoint(db)](#module*REST API* user data..httpPostDuplicateEndpoint) ⇒ - - [~httpPostDuplicateEndpointType(db)](#module*REST API* user data..httpPostDuplicateEndpointType) ⇒ - - [~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId)](#module*REST API* user data..duplicateEndpointTypeClusters) +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: converted type - +| Param | Type | +| --- | --- | +| str | \* | -### REST API: user data~getComponentIdsByCluster(db, sessionId, clusterId, side) ⇒ \* + -Promise that return a list of component Ids required by a specific cluster +### JS API: type related utilities~isString(type) ⇒ +Returns true if a given ZCL type is a string type. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: \* - array of componentIds +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: true if type is string, false otherwise -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| clusterId | \* | -| side | \* | +| Param | Type | +| --- | --- | +| type | \* | - + -### REST API: user data~httpGetSessionKeyValues(db) ⇒ +### JS API: type related utilities~isFloat(type) ⇒ +Returns true if a given ZCL type is a float type. -HTTP GET: session key values +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: true if type is float, false otherwise -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| type | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: type related utilities~isSignedInteger(db, sessionId, type) ⇒ Promise.<boolean> +Checks if a given ZCL type is a signed integer. -### REST API: user data~httpGetEndpointIds(db) ⇒ +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is a signed integer, false otherwise. -HTTP GET: endpoint ids of endpoints within a specified session +| Param | Type | Description | +| --- | --- | --- | +| db | object | The database connection object. | +| sessionId | string | The session ID. | +| type | string | The name of the ZCL type. | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: type related utilities~isOneBytePrefixedString(type) ⇒ +Checks if type is a one-byte lengh string. - +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: true if the said type is a string prefixed by one byte length -### REST API: user data~httpGetSessionNotifications(db) ⇒ +| Param | Type | +| --- | --- | +| type | \* | -HTTP GET: session get notifications + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: type related utilities~isTwoBytePrefixedString(type) ⇒ +Checks if type is a two-byte lengh string. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: true if the said type is a string prefixed by two byte length - +| Param | Type | +| --- | --- | +| type | \* | -### REST API: user data~httpDeleteSessionNotification(db) ⇒ + -HTTP DELETE: session delete notifications +### JS API: type related utilities~nullStringDefaultValue(type) ⇒ string +Generates a default value for a null string based on its type. +This function is designed to abstract away the specific null representation +of strings from the longTypeDefaultValue function, ensuring that the latter +does not need to be aware of these details. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: string - The default value for a null string of the specified type. +**Throws**: -| Param | Type | -| ----- | --------------- | -| db | \* | +- Error Throws an error if the string type is unknown. - -### REST API: user data~httpGetPackageNotifications(db) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| type | string | The type of the string, which determines its null representation. | -HTTP GET: package get notifications + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: type related utilities~getSignAndSizeOfZclType(type, context, options) ⇒ +Given a zcl device type returns its sign, size and zcl data type info stored +in the database table. +Note: Enums and Bitmaps are considered to be unsigned. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: returns sign, size and info of zcl device type +Available Options: +- size: Determine whether to calculate the size of zcl device type in bits +or bytes +for eg: getSignAndSizeOfZclType('int8u' this size='bits') will return +the size in bits which will be 8. If not mentioned then it will return the size +in bytes i.e. 1 in this case. - +| Param | Type | +| --- | --- | +| type | \* | +| context | \* | +| options | \* | -### REST API: user data~httpGetPackageNotificationsByPackageId(db) ⇒ + -HTTP GET: package get notifications +### JS API: type related utilities~intToHexString(n, byteCount) ⇒ +Converts a JS number to a hex representation with padding. +intToHexString(17, 2) => 0x0011 . -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: hex string -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| n | \* | +| byteCount | \* | - + -### REST API: user data~httpDeletePackageNotification(db) ⇒ +### JS API: type related utilities~hexStringToInt(s) ⇒ +Converts a hex representation created by the intToHexString +back into a JS integer. -HTTP DELETE: session delete notifications +**Kind**: inner method of [JS API: type related utilities](#module_JS API_ type related utilities) +**Returns**: integer -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| s | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +## JS API: random utilities -### REST API: user data~httpGetUnseenNotificationCount(db) ⇒ +* [JS API: random utilities](#module_JS API_ random utilities) + * [~checksum(data)](#module_JS API_ random utilities..checksum) ⇒ + * [~ensurePackagesAndPopulateSessionOptions(db, sessionId, options:, selectedZclPropertyPackage, selectedGenTemplatePackages)](#module_JS API_ random utilities..ensurePackagesAndPopulateSessionOptions) ⇒ + * [~populateSessionPackageOptions(db, sessionId, packages)](#module_JS API_ random utilities..populateSessionPackageOptions) ⇒ + * [~createBackupFile(filePath)](#module_JS API_ random utilities..createBackupFile) + * [~matchFeatureLevel(featureLevel)](#module_JS API_ random utilities..matchFeatureLevel) + * [~sessionReport(db, sessionId)](#module_JS API_ random utilities..sessionReport) ⇒ + * [~sessionDump(db, sessionId)](#module_JS API_ random utilities..sessionDump) ⇒ + * [~executePromisesSequentially(arrayOfData, promiseCreator)](#module_JS API_ random utilities..executePromisesSequentially) + * [~createAbsolutePath(relativePath, relativity, zapFilePath)](#module_JS API_ random utilities..createAbsolutePath) + * [~locateRelativeFilePath(rootFileLocations, relativeFilePath)](#module_JS API_ random utilities..locateRelativeFilePath) ⇒ + * [~executeExternalProgram(cmd)](#module_JS API_ random utilities..executeExternalProgram) + * [~getClusterExtensionDefault(extensions, extensionId, clusterCode)](#module_JS API_ random utilities..getClusterExtensionDefault) ⇒ + * [~getClusterExtension(extensions, property, clusterCode)](#module_JS API_ random utilities..getClusterExtension) ⇒ + * [~createUuid()](#module_JS API_ random utilities..createUuid) + * [~waitFor(time)](#module_JS API_ random utilities..waitFor) + * [~parseXml(fileContent)](#module_JS API_ random utilities..parseXml) ⇒ + * [~readFileContentAndCrc(metadata)](#module_JS API_ random utilities..readFileContentAndCrc) ⇒ + * [~duration(nsDifference)](#module_JS API_ random utilities..duration) ⇒ + * [~mainOrSecondaryInstance()](#module_JS API_ random utilities..mainOrSecondaryInstance) + * [~disable(testName)](#module_JS API_ random utilities..disable) + * [~collectJsonData(jsonFile)](#module_JS API_ random utilities..collectJsonData) + * [~patternFormat(pattern, data)](#module_JS API_ random utilities..patternFormat) -HTTP GET: session get unseen session notification count + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: random utilities~checksum(data) ⇒ +Returns the CRC of the data that is passed. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: Calculated CRC of a data. - +| Param | Type | +| --- | --- | +| data | \* | -### REST API: user data~httpGetUnseenNotificationAndUpdate(db) ⇒ + -HTTP GET: session update all session notifications to be SEEN +### JS API: random utilities~ensurePackagesAndPopulateSessionOptions(db, sessionId, options:, selectedZclPropertyPackage, selectedGenTemplatePackages) ⇒ +This function assigns a proper package ID to the session if there +are no packages present. It will also populate session options. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: Promise that resolves with the packages array. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| sessionId | \* | | +| options: | \* | object containing 'zcl' and 'template' | +| selectedZclPropertyPackage | \* | | +| selectedGenTemplatePackages | \* | | - + -### REST API: user data~httpPostSaveSessionKeyValue(db) ⇒ +### JS API: random utilities~populateSessionPackageOptions(db, sessionId, packages) ⇒ +Insert session package options. -HTTP POST: save session key value +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: Promise array on inserting session package options -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | +| packages | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: random utilities~createBackupFile(filePath) +Move database file out of the way into the backup location. -### REST API: user data~httpPostCluster(db) ⇒ +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -HTTP POST: cluster +| Param | Type | +| --- | --- | +| filePath | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: random utilities~matchFeatureLevel(featureLevel) +Returns an object that contains: + match: true or false if featureLevel is matched or not. + message: in case of missmatch, the message shown to user. - +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -### REST API: user data~httpPostForcedExternal(db) ⇒ function +| Param | Type | +| --- | --- | +| featureLevel | \* | -Handles a POST request to retrieve forced external storage options. + -This function is designed to be used as a middleware in an Express.js route. It extracts the session ID from the request, -queries the database for package information associated with that session, and then retrieves forced external storage -options for the identified package. The results are sent back to the client as a JSON response. +### JS API: random utilities~sessionReport(db, sessionId) ⇒ +Produces a text dump of a session data for human consumption. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: function - An asynchronous function that takes Express.js request and response objects. +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: promise that resolves into a text report for the session. -| Param | Type | Description | -| ----- | ------------------- | ------------------------------- | -| db | Object | The database connection object. | +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | - + -### REST API: user data~httpPostAttributeUpdate(db) ⇒ +### JS API: random utilities~sessionDump(db, sessionId) ⇒ +Produces a text dump of a session data for human consumption. -HTTP POST attribute update +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: promise that resolves into a text report for the session. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +| Param | Type | +| --- | --- | +| db | \* | +| sessionId | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: random utilities~executePromisesSequentially(arrayOfData, promiseCreator) +If you have an array of arguments, and a function that creates +a promise out of each of those arguments, this function +executes them sequentially, one by one. -### REST API: user data~httpPostCommandUpdate(db) ⇒ +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -HTTP POST: command update +| Param | Type | +| --- | --- | +| arrayOfData | \* | +| promiseCreator | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration + -| Param | Type | -| ----- | --------------- | -| db | \* | +### JS API: random utilities~createAbsolutePath(relativePath, relativity, zapFilePath) +This function creates absolute path out of relative path and its relativity - +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -### REST API: user data~httpPostEventUpdate(db) ⇒ +| Param | Type | +| --- | --- | +| relativePath | \* | +| relativity | \* | +| zapFilePath | \* | -HTTP POST: command update + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: random utilities~locateRelativeFilePath(rootFileLocations, relativeFilePath) ⇒ +This method takes an array of root locations and a relative path. +It will attempt to locate an absolute file at the path, combining +the root location and a relative path, until a file is found and returned. -| Param | Type | -| ----- | --------------- | -| db | \* | +If none of the combined root locations and relative paths results +in an actual file, null is returned. - +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: A fully resolved path that exists, or null if none is available. -### REST API: user data~httpGetInitialState(db) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| rootFileLocations | \* | Array of root file locations, typically directories | +| relativeFilePath | \* | Relative path | -HTTP GET: initial state + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +### JS API: random utilities~executeExternalProgram(cmd) +Returns a promise of an execution of an external program. -| Param | Type | -| ----- | --------------- | -| db | \* | +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) - +| Param | Type | +| --- | --- | +| cmd | \* | -### REST API: user data~httpGetOption(db) ⇒ + -HTTP GET: option +### JS API: random utilities~getClusterExtensionDefault(extensions, extensionId, clusterCode) ⇒ +Retrieve specific entry from extensions defaults(array) via 'clusterCode' key fields -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: callback for the express uri registration +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: Value of the cluster extension property. +**Parem**: \* clusterRole: one of server/client enums, or null for either. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | Description | +| --- | --- | --- | +| extensions | \* | | +| extensionId | \* | field name under specific extension | +| clusterCode | \* | search key | - + -### REST API: user data~httpGetUiOptions(db) ⇒ +### JS API: random utilities~getClusterExtension(extensions, property, clusterCode) ⇒ +Retrieve specific entry from extensions defaults(array) via 'clusterCode' key fields -HTTP GET: ui_options +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: Object containing all attribuetes specific to the extension -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: UI options from all packages. +| Param | Type | Description | +| --- | --- | --- | +| extensions | \* | | +| property | \* | field name under specific extension | +| clusterCode | \* | search key | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: random utilities~createUuid() +Global way how to get an UUID. -### REST API: user data~httpGetPackages() +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) + -HTTP GET: Project packages +### JS API: random utilities~waitFor(time) +Returns a promise that resolves after time milliseconds -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -### REST API: user data~httpGetAllPackages() +| Param | +| --- | +| time | -HTTP GET: All Packages + -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - +### JS API: random utilities~parseXml(fileContent) ⇒ +Returns a promise that resolve into a parsed XML object. -### REST API: user data~httpPostAddNewPackage() +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: promise that resolves into parsed object. -HTTP POST: Add new project package +| Param | Type | +| --- | --- | +| fileContent | \* | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - + -### REST API: user data~httpPostShareClusterStatesAcrossEndpoints() +### JS API: random utilities~readFileContentAndCrc(metadata) ⇒ +Reads the properties file and returns object containing +'data', 'filePath' and 'crc' -HTTP POST: Unify all Attributes / Command states if a certain cluster is enabled -on more than one endpoint. +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: Promise to populate data, filePath and crc into the context. -1. In Zigbee world, the Attribute / Command configurations is a global singleton entity. - If one cluster is enabled by more than 1 endpoint, the attribute states (on/off) should be - identical across each endpoint. - To emulate the global singleton entity, this function ensures Attribute changes - are applied to all endpoint specific attribute fields. - When unify event is triggered, this function will align all shared Attribute/Command states - to the first matching entry from beginning of the endpoint list. -2. (native case in ZAP) In Matter, the Attribute configuration are endpoint specific. +| Param | Type | Description | +| --- | --- | --- | +| metadata | \* | file | -**Kind**: inner method of [REST API: user data](#module*REST API* user data) - + -### REST API: user data~httpPostDuplicateEndpoint(db) ⇒ +### JS API: random utilities~duration(nsDifference) ⇒ +This method takes a nanosecond duration and prints out +decently human readable time out of it. -Creating a duplicate for endpoint +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) +**Returns**: String with human readable time duration. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: newly created endpoint id +| Param | Type | +| --- | --- | +| nsDifference | \* | -| Param | Type | -| ----- | --------------- | -| db | \* | + - +### JS API: random utilities~mainOrSecondaryInstance() +This method returns true if the running instance is the first +and main instance of the zap, and false if zap instance is already +running. -### REST API: user data~httpPostDuplicateEndpointType(db) ⇒ +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) + -Creating a duplicate for endpoint-type and endpoint-type-attributes +### JS API: random utilities~disable(testName) +Disable test. -**Kind**: inner method of [REST API: user data](#module*REST API* user data) -**Returns**: newly created endpoint-type id +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| testName | \* | - + -### REST API: user data~duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId) +### JS API: random utilities~collectJsonData(jsonFile) +Utility method that collects data from a JSON file. -duplicate all clusters and attributes of an old endpoint type, using oldEndpointType id and newly created endpointType id +JSON file is formatted as a bunch of keyed strings: + "someKey": [ "a", "b", "c"] +Then it supports following special keys: + "include": "path/to/json/file" - includes the said JSON file + "disable": [ "x", "y" ...] - disables the specified data points + "collection": ["key", "key2", ...] - collects final list of data points -**Kind**: inner method of [REST API: user data](#module*REST API* user data) +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| oldEndpointTypeId | \* | -| newEndpointTypeId | \* | +| Param | Type | +| --- | --- | +| jsonFile | \* | - + -## JS API: http server +### JS API: random utilities~patternFormat(pattern, data) +This function receives pattern and data, and it formats pattern +by applyind data to it via it's keys. +For example, if pattern is "{a}" and data.a is 1, then this prints out "1". -This module provides the HTTP server functionality. +**Kind**: inner method of [JS API: random utilities](#module_JS API_ random utilities) -- [JS API: http server](#module*JS API* http server) - - [~registerRestApi(filename, db, app)](#module*JS API* http server..registerRestApi) - - [~initHttpServer(db, port)](#module*JS API* http server..initHttpServer) ⇒ - - [~shutdownHttpServer()](#module*JS API* http server..shutdownHttpServer) ⇒ - - [~shutdownHttpServerSync()](#module*JS API* http server..shutdownHttpServerSync) ⇒ - - [~httpServerPort()](#module*JS API* http server..httpServerPort) ⇒ - - [~httpServerUrl()](#module*JS API* http server..httpServerUrl) ⇒ - - [~httpServerStartupMessage()](#module*JS API* http server..httpServerStartupMessage) +| Param | Type | +| --- | --- | +| pattern | \* | +| data | \* | - + -### JS API: http server~registerRestApi(filename, db, app) +## REST API: various zcl utilities +This module provides the API to access various zcl utilities. -This function is used to register a rest module, which exports -get/post/etc. arrays. -**Kind**: inner method of [JS API: http server](#module*JS API* http server) +* [REST API: various zcl utilities](#module_REST API_ various zcl utilities) + * [~clusterComparator(a, b)](#module_REST API_ various zcl utilities..clusterComparator) ⇒ + * [~attributeComparator(a, b)](#module_REST API_ various zcl utilities..attributeComparator) ⇒ + * [~commandComparator(a, b)](#module_REST API_ various zcl utilities..commandComparator) ⇒ + * [~eventComparator(a, b)](#module_REST API_ various zcl utilities..eventComparator) ⇒ + * [~findStructByName(structs, name)](#module_REST API_ various zcl utilities..findStructByName) ⇒ + * [~sortStructsByDependency(structs)](#module_REST API_ various zcl utilities..sortStructsByDependency) ⇒ + * [~calculateBytes(res, options, db, packageIds, isStructType)](#module_REST API_ various zcl utilities..calculateBytes) + * [~optionsHashOrDefault(options, optionsKey, defaultValue)](#module_REST API_ various zcl utilities..optionsHashOrDefault) + * [~calculateBytesForTypes(res, options, db, packageIds)](#module_REST API_ various zcl utilities..calculateBytesForTypes) ⇒ + * [~calculateBytesForStructs(res, options, db, packageIds)](#module_REST API_ various zcl utilities..calculateBytesForStructs) ⇒ + * [~returnOptionsForTypes(size, res, options)](#module_REST API_ various zcl utilities..returnOptionsForTypes) ⇒ + * [~dataTypeCharacterFormatter(db, packageIds, type, options, resType)](#module_REST API_ various zcl utilities..dataTypeCharacterFormatter) + * [~isEnum(db, enum_name, packageIds)](#module_REST API_ various zcl utilities..isEnum) ⇒ + * [~isStruct(db, struct_name, packageIds)](#module_REST API_ various zcl utilities..isStruct) ⇒ + * [~isEvent(db, event_name, packageId)](#module_REST API_ various zcl utilities..isEvent) ⇒ + * [~isBitmap(db, bitmap_name, packageIds)](#module_REST API_ various zcl utilities..isBitmap) ⇒ + * [~defaultMessageForTypeConversion(fromType, toType, noWarning)](#module_REST API_ various zcl utilities..defaultMessageForTypeConversion) + * [~dataTypeHelper(type, options, packageIds, db, resolvedType, overridable)](#module_REST API_ various zcl utilities..dataTypeHelper) ⇒ + * [~asUnderlyingZclTypeWithPackageId(type, options, packageIds, currentInstance)](#module_REST API_ various zcl utilities..asUnderlyingZclTypeWithPackageId) + * [~determineType(db, type, packageIds)](#module_REST API_ various zcl utilities..determineType) + * [~createCommandSignature(db, packageId, cmd)](#module_REST API_ various zcl utilities..createCommandSignature) ⇒ + * [~zcl_data_type_size_and_sign(type, dataType, clusterId, packageIds, context)](#module_REST API_ various zcl utilities..zcl_data_type_size_and_sign) ⇒ -| Param | Type | -| -------- | --------------- | -| filename | \* | -| db | \* | -| app | \* | + - +### REST API: various zcl utilities~clusterComparator(a, b) ⇒ +Comparator for sorting clusters. -### JS API: http server~initHttpServer(db, port) ⇒ +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: -1, 0 or 1 -Promises to initialize the http server on a given port -using a given database. +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | -**Kind**: inner method of [JS API: http server](#module*JS API* http server) -**Returns**: A promise that resolves with an express app. + -| Param | Type | Description | -| ----- | --------------- | ------------------------- | -| db | \* | Database object to use. | -| port | \* | Port for the HTTP server. | +### REST API: various zcl utilities~attributeComparator(a, b) ⇒ +Comparator for sorting attribute. - +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: -1, 0 or 1 -### JS API: http server~shutdownHttpServer() ⇒ +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | -Promises to shut down the http server. + -**Kind**: inner method of [JS API: http server](#module*JS API* http server) -**Returns**: Promise that resolves when server is shut down. - +### REST API: various zcl utilities~commandComparator(a, b) ⇒ +Comparator for sorting commands. -### JS API: http server~shutdownHttpServerSync() ⇒ +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: -1, 0 or 1 -Promises to shut down the http server. +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | -**Kind**: inner method of [JS API: http server](#module*JS API* http server) -**Returns**: Promise that resolves when server is shut down. - + -### JS API: http server~httpServerPort() ⇒ +### REST API: various zcl utilities~eventComparator(a, b) ⇒ +Comparator for sorting events. -Port http server is listening on. +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: -1, 0 or 1 -**Kind**: inner method of [JS API: http server](#module*JS API* http server) -**Returns**: port - +| Param | Type | +| --- | --- | +| a | \* | +| b | \* | -### JS API: http server~httpServerUrl() ⇒ + -Returns the URL of the server. +### REST API: various zcl utilities~findStructByName(structs, name) ⇒ +Find struct by name from the given list of structs. -**Kind**: inner method of [JS API: http server](#module*JS API* http server) -**Returns**: the server URL - +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: struct -### JS API: http server~httpServerStartupMessage() +| Param | Type | +| --- | --- | +| structs | \* | +| name | \* | -Returns the startup message that needs to be printed out. + -**Kind**: inner method of [JS API: http server](#module*JS API* http server) - +### REST API: various zcl utilities~sortStructsByDependency(structs) ⇒ +This method retrieves a bunch of structs sorted +alphabetically. It's expected to resort the structs into a list +where they are sorted in a way where dependency is observed. -## JS API: websocket server +It uses the DFS-based topological sort algorithm. -This module provides the HTTP server functionality. +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: sorted structs according to topological search. -- [JS API: websocket server](#module*JS API* websocket server) - - [~initializeWebSocket(httpServer)](#module*JS API* websocket server..initializeWebSocket) - - [~clientSocket(sessionUuid)](#module*JS API* websocket server..clientSocket) - - [~doSend(socket, object)](#module*JS API* websocket server..doSend) - - [~sendWebSocketData(category, payload)](#module*JS API* websocket server..sendWebSocketData) - - [~sendWebSocketMessage(msg)](#module*JS API* websocket server..sendWebSocketMessage) - - [~onWebSocket(category, listener)](#module*JS API* websocket server..onWebSocket) +| Param | Type | +| --- | --- | +| structs | \* | - + -### JS API: websocket server~initializeWebSocket(httpServer) +### REST API: various zcl utilities~calculateBytes(res, options, db, packageIds, isStructType) +This function calculates the number of bytes in the data type and based on +that returns the option specified in the template. +for eg: Given that options are as follows: +options.hash.array="b" +options.hash.one_byte="u" +options.hash.two_byte="v" +options.hash.three_byte="x" +options.hash.four_byte="w" +options.hash.short_string="s" +options.hash.long_string="l" +options.hash.default="b" -Initialize a websocket, and register listeners to the -websocket connection and the message receipt. +calculateBytes("char_string", options) +will return 's' -**Kind**: inner method of [JS API: websocket server](#module*JS API* websocket server) +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) -| Param | Type | -| ---------- | --------------- | -| httpServer | \* | +| Param | Type | +| --- | --- | +| res | \* | +| options | \* | +| db | \* | +| packageIds | \* | +| isStructType | \* | - + -### JS API: websocket server~clientSocket(sessionUuid) +### REST API: various zcl utilities~optionsHashOrDefault(options, optionsKey, defaultValue) +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) -Method that returns the websocket for a given session key. +| Param | Description | +| --- | --- | +| options | | +| optionsKey | | +| defaultValue | Given the values determine to give the user defined value or the calculated value | -**Kind**: inner method of [JS API: websocket server](#module*JS API* websocket server) + -| Param | Type | -| ----------- | --------------- | -| sessionUuid | \* | +### REST API: various zcl utilities~calculateBytesForTypes(res, options, db, packageIds) ⇒ +Get the size of the type given. - +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: size of type -### JS API: websocket server~doSend(socket, object) +| Param | Type | +| --- | --- | +| res | \* | +| options | \* | +| db | \* | +| packageIds | \* | -Bottom-most function that sends an object over a socket. + -**Kind**: inner method of [JS API: websocket server](#module*JS API* websocket server) +### REST API: various zcl utilities~calculateBytesForStructs(res, options, db, packageIds) ⇒ +Get size of struct. Also allow user to specifiy a default if calculation is not needed. -| Param | Type | -| ------ | --------------- | -| socket | \* | -| object | \* | +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: size of struct - +| Param | Type | +| --- | --- | +| res | \* | +| options | \* | +| db | \* | +| packageIds | \* | -### JS API: websocket server~sendWebSocketData(category, payload) + -Send websocket payload with a given category. +### REST API: various zcl utilities~returnOptionsForTypes(size, res, options) ⇒ +Get user defined values from the template for a given size or else return defaults specified. -**Kind**: inner method of [JS API: websocket server](#module*JS API* websocket server) +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: user defined or default value based on size -| Param | Type | -| -------- | --------------- | -| category | \* | -| payload | \* | +| Param | Type | +| --- | --- | +| size | \* | +| res | \* | +| options | \* | - + -### JS API: websocket server~sendWebSocketMessage(msg) +### REST API: various zcl utilities~dataTypeCharacterFormatter(db, packageIds, type, options, resType) +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) -This can be used to send unstructured websocket message. -On the receiving end, the event will contain category -'generic'. +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| packageIds | \* | | +| type | \* | | +| options | \* | | +| resType | \* | Character associated to a zcl/c data type. | -**Kind**: inner method of [JS API: websocket server](#module*JS API* websocket server) + -| Param | Type | -| ----- | --------------- | -| msg | \* | +### REST API: various zcl utilities~isEnum(db, enum_name, packageIds) ⇒ +Local function that checks if an enum by the name exists - +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: Promise of content. -### JS API: websocket server~onWebSocket(category, listener) +| Param | Type | +| --- | --- | +| db | \* | +| enum_name | \* | +| packageIds | \* | -If you wish to register to a specific category of websocket -messages, you can use this function. Listener will be executed with -a given socket and data object. + -**Kind**: inner method of [JS API: websocket server](#module*JS API* websocket server) +### REST API: various zcl utilities~isStruct(db, struct_name, packageIds) ⇒ +Local function that checks if a struct by the name exists -| Param | Type | Description | -| -------- | --------------- | ------------------------------------ | -| category | \* | category of message. | -| listener | \* | function that receives socket, data. | +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: Promise of content. - +| Param | Type | +| --- | --- | +| db | \* | +| struct_name | \* | +| packageIds | \* | -## JS API: renderer API related utilities + -- [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) - - [~getSessionUuidFromBrowserWindow(browserWindow)](#module*JS API* renderer API related utilities..getSessionUuidFromBrowserWindow) ⇒ - - [~getRendererApiInformation(browserWindow)](#module*JS API* renderer API related utilities..getRendererApiInformation) ⇒ - - [~execRendererApi(browserWindow, rendererApiCommand, ...theArgs)](#module*JS API* renderer API related utilities..execRendererApi) - - [~execFileOpen(browserWindow, filePath)](#module*JS API* renderer API related utilities..execFileOpen) ⇒ - - [~processRendererNotify(message)](#module*JS API* renderer API related utilities..processRendererNotify) ⇒ - - [~reportFiles(browserWindow, result)](#module*JS API* renderer API related utilities..reportFiles) - - [~getUserKeyFromCookieValue(cookieValue)](#module*JS API* renderer API related utilities..getUserKeyFromCookieValue) ⇒ - - [~getUserKeyFromBrowserCookie(browserCookie)](#module*JS API* renderer API related utilities..getUserKeyFromBrowserCookie) - - [~getUserKeyFromBrowserWindow(browserWindow)](#module*JS API* renderer API related utilities..getUserKeyFromBrowserWindow) +### REST API: various zcl utilities~isEvent(db, event_name, packageId) ⇒ +Function that checks if a given thing is an avent. - +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: Promise of content. -### JS API: renderer API related utilities~getSessionUuidFromBrowserWindow(browserWindow) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| event_name | \* | +| packageId | \* | -This method returns the global session UUID from the browser window that is set by the front-end. + -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) -**Returns**: session UUID +### REST API: various zcl utilities~isBitmap(db, bitmap_name, packageIds) ⇒ +Local function that checks if a bitmap by the name exists -| Param | Type | -| ------------- | --------------- | -| browserWindow | \* | +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: Promise of content. - +| Param | Type | +| --- | --- | +| db | \* | +| bitmap_name | \* | +| packageIds | \* | -### JS API: renderer API related utilities~getRendererApiInformation(browserWindow) ⇒ + -Returns descriptive text about renderer api. +### REST API: various zcl utilities~defaultMessageForTypeConversion(fromType, toType, noWarning) +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) -**Returns**: description of renderer api +| Param | Type | Description | +| --- | --- | --- | +| fromType | \* | | +| toType | \* | | +| noWarning | \* | Type warning message. If noWarning is set to true then the warning message will not be shown. | -| Param | Type | -| ------------- | --------------- | -| browserWindow | \* | + - +### REST API: various zcl utilities~dataTypeHelper(type, options, packageIds, db, resolvedType, overridable) ⇒ +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: the data type associated with the resolvedType + +| Param | Type | +| --- | --- | +| type | \* | +| options | \* | +| packageIds | \* | +| db | \* | +| resolvedType | \* | +| overridable | \* | -### JS API: renderer API related utilities~execRendererApi(browserWindow, rendererApiCommand, ...theArgs) + -Execute RendererApi commands +### REST API: various zcl utilities~asUnderlyingZclTypeWithPackageId(type, options, packageIds, currentInstance) +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) +| Param | Description | +| --- | --- | +| type | | +| options | | +| packageIds | | +| currentInstance | Note: If the options has zclCharFormatter set to true then the function will return the user defined data associated with the zcl data type and not the actual data type. It can also be used to calculate the size of the data types This is a utility function which is called from other helper functions using ut current instance. See comments in asUnderlyingZclType for usage instructions. | -| Param | Type | -| ------------------ | ---------------- | -| browserWindow | \* | -| rendererApiCommand | \* | -| ...theArgs | any | + - +### REST API: various zcl utilities~determineType(db, type, packageIds) +Returns a promise that resolves into an object containing: + type: + atomicType: +Base type for struct is a null. -### JS API: renderer API related utilities~execFileOpen(browserWindow, filePath) ⇒ +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) -Executes the file open renderer API action. +| Param | Type | +| --- | --- | +| db | \* | +| type | \* | +| packageIds | \* | -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) -**Returns**: Result of file open call. + -| Param | Type | -| ------------- | --------------- | -| browserWindow | \* | -| filePath | \* | +### REST API: various zcl utilities~createCommandSignature(db, packageId, cmd) ⇒ +Get command signature of a command. - +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: object -### JS API: renderer API related utilities~processRendererNotify(message) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| cmd | \* | -This method takes a message and checks if it's a renderer API -notification call. If it is, it processe it and returns true. -If it's not it returns false. + -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) -**Returns**: true if message was a notify message and was consumed. +### REST API: various zcl utilities~zcl\_data\_type\_size\_and\_sign(type, dataType, clusterId, packageIds, context) ⇒ +**Kind**: inner method of [REST API: various zcl utilities](#module_REST API_ various zcl utilities) +**Returns**: The size and sign of a zcl data type -| Param | Type | -| ------- | --------------- | -| message | \* | +| Param | Type | +| --- | --- | +| type | \* | +| dataType | \* | +| clusterId | \* | +| packageIds | \* | +| context | \* | - + -### JS API: renderer API related utilities~reportFiles(browserWindow, result) +## Validation API: Validation APIs +This module provides the APIs for validating inputs to the database, and returning flags indicating if +things were successful or not. -This method calls the reportFiles renderer API call. -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) +* [Validation API: Validation APIs](#module_Validation API_ Validation APIs) + * _static_ + * [.initAsyncValidation()](#module_Validation API_ Validation APIs.initAsyncValidation) + * _inner_ + * [~zigbeeEnforceCommonClusterSpecInit(session)](#module_Validation API_ Validation APIs..zigbeeEnforceCommonClusterSpecInit) ⇒ + * [~zigbeeEnforceCommonClusterSpecCallback(session)](#module_Validation API_ Validation APIs..zigbeeEnforceCommonClusterSpecCallback) + * [~validateAttribute(db, endpointTypeId, attributeRef, clusterRef, zapSessionId)](#module_Validation API_ Validation APIs..validateAttribute) ⇒ + * [~validateEndpoint(db, endpointId)](#module_Validation API_ Validation APIs..validateEndpoint) ⇒ + * [~validateNoDuplicateEndpoints(db, endpointIdentifier, sessionRef)](#module_Validation API_ Validation APIs..validateNoDuplicateEndpoints) ⇒ + * [~validateSpecificAttribute(endpointAttribute, attribute, db, zapSessionId)](#module_Validation API_ Validation APIs..validateSpecificAttribute) ⇒ + * [~validateSpecificEndpoint(endpoint)](#module_Validation API_ Validation APIs..validateSpecificEndpoint) ⇒ + * [~isValidNumberString(value)](#module_Validation API_ Validation APIs..isValidNumberString) ⇒ + * [~isValidSignedNumberString(value)](#module_Validation API_ Validation APIs..isValidSignedNumberString) ⇒ + * [~isValidHexString(value)](#module_Validation API_ Validation APIs..isValidHexString) ⇒ + * [~isValidDecimalString(value)](#module_Validation API_ Validation APIs..isValidDecimalString) ⇒ + * [~isValidFloat(value)](#module_Validation API_ Validation APIs..isValidFloat) ⇒ + * [~extractFloatValue(value)](#module_Validation API_ Validation APIs..extractFloatValue) ⇒ + * [~extractIntegerValue(value)](#module_Validation API_ Validation APIs..extractIntegerValue) ⇒ + * [~extractBigIntegerValue(value)](#module_Validation API_ Validation APIs..extractBigIntegerValue) ⇒ + * [~isBigInteger(bits)](#module_Validation API_ Validation APIs..isBigInteger) ⇒ + * [~getBoundsInteger(attribute, typeSize, isSigned)](#module_Validation API_ Validation APIs..getBoundsInteger) ⇒ + * [~unsignedToSignedInteger(value, typeSize)](#module_Validation API_ Validation APIs..unsignedToSignedInteger) ⇒ + * [~getIntegerFromAttribute(attribute, typeSize, isSigned)](#module_Validation API_ Validation APIs..getIntegerFromAttribute) ⇒ + * [~getIntegerAttributeSize(db, zapSessionId, attribType)](#module_Validation API_ Validation APIs..getIntegerAttributeSize) ⇒ \* + * [~checkAttributeBoundsInteger(attribute, endpointAttribute, db, zapSessionId)](#module_Validation API_ Validation APIs..checkAttributeBoundsInteger) ⇒ + * [~checkBoundsInteger(defaultValue, min, max)](#module_Validation API_ Validation APIs..checkBoundsInteger) ⇒ + * [~checkAttributeBoundsFloat(attribute, endpointAttribute)](#module_Validation API_ Validation APIs..checkAttributeBoundsFloat) ⇒ + * [~getBoundsFloat(attribute)](#module_Validation API_ Validation APIs..getBoundsFloat) ⇒ + * [~checkBoundsFloat(defaultValue, min, max)](#module_Validation API_ Validation APIs..checkBoundsFloat) ⇒ + + + +### Validation API: Validation APIs.initAsyncValidation() +Start session specific validation. -| Param | Type | -| ------------- | --------------- | -| browserWindow | \* | -| result | \* | +**Kind**: static method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) + - +### Validation API: Validation APIs~zigbeeEnforceCommonClusterSpecInit(session) ⇒ +Enforce zigbee specific common cluster initialization. -### JS API: renderer API related utilities~getUserKeyFromCookieValue(cookieValue) ⇒ +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object -Returns cookie for user identification. +| Param | Type | +| --- | --- | +| session | \* | -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) -**Returns**: cookie value used for user identification + -| Param | Type | -| ----------- | --------------- | -| cookieValue | \* | +### Validation API: Validation APIs~zigbeeEnforceCommonClusterSpecCallback(session) +Enforce zigbee specific common cluster initialization. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) -### JS API: renderer API related utilities~getUserKeyFromBrowserCookie(browserCookie) +| Param | Type | +| --- | --- | +| session | \* | -Returns the session key + -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) +### Validation API: Validation APIs~validateAttribute(db, endpointTypeId, attributeRef, clusterRef, zapSessionId) ⇒ +Main attribute validation function. +Returns a promise of an object which stores a list of validational issues. +Such issues as "Invalid type" or "Out of Range". -| Param | Type | Description | -| ------------- | --------------- | ----------- | -| browserCookie | \* | object | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: Promise of the list of issues - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | db reference | +| endpointTypeId | \* | endpoint reference | +| attributeRef | \* | attribute reference | +| clusterRef | \* | cluster reference | +| zapSessionId | \* | session reference | -### JS API: renderer API related utilities~getUserKeyFromBrowserWindow(browserWindow) + -Returns a promise that resolves into the session key. +### Validation API: Validation APIs~validateEndpoint(db, endpointId) ⇒ +Get issues in an endpoint. -**Kind**: inner method of [JS API: renderer API related utilities](#module*JS API* renderer API related utilities) +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object -| Param | Type | -| ------------- | --------------- | -| browserWindow | \* | +| Param | Type | +| --- | --- | +| db | \* | +| endpointId | \* | - + -## JS API: async reporting +### Validation API: Validation APIs~validateNoDuplicateEndpoints(db, endpointIdentifier, sessionRef) ⇒ +Check if there are no duplicate endpoints. -This module provides the mechanism for dealing with the async reporting -from backend to the UI. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -This mechanism takes care of: +| Param | Type | +| --- | --- | +| db | \* | +| endpointIdentifier | \* | +| sessionRef | \* | -- dirty flag + -* [JS API: async reporting](#module*JS API* async reporting) - - [~sendDirtyFlagStatus(db, session)](#module*JS API* async reporting..sendDirtyFlagStatus) - - [~sendNotificationUpdate(db, session)](#module*JS API* async reporting..sendNotificationUpdate) - - [~startAsyncReporting(db, intervalMs)](#module*JS API* async reporting..startAsyncReporting) - - [~stopAsyncReporting()](#module*JS API* async reporting..stopAsyncReporting) +### Validation API: Validation APIs~validateSpecificAttribute(endpointAttribute, attribute, db, zapSessionId) ⇒ +Checks the attributes type then validates the incoming input string. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: List of issues wrapped in an object -### JS API: async reporting~sendDirtyFlagStatus(db, session) +| Param | Type | +| --- | --- | +| endpointAttribute | \* | +| attribute | \* | +| db | \* | +| zapSessionId | \* | -Sends a dirty flag status for a single session. + -**Kind**: inner method of [JS API: async reporting](#module*JS API* async reporting) +### Validation API: Validation APIs~validateSpecificEndpoint(endpoint) ⇒ +Get endpoint and newtork issue on an endpoint. -| Param | Type | -| ------- | --------------- | -| db | \* | -| session | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object - +| Param | Type | +| --- | --- | +| endpoint | \* | -### JS API: async reporting~sendNotificationUpdate(db, session) + -Sends a dirty flag status for a single session. +### Validation API: Validation APIs~isValidNumberString(value) ⇒ +Check if value is a valid number in string form. +This applies to both actual numbers as well as octet strings. -**Kind**: inner method of [JS API: async reporting](#module*JS API* async reporting) +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -| Param | Type | -| ------- | --------------- | -| db | \* | -| session | \* | +| Param | Type | +| --- | --- | +| value | \* | - + -### JS API: async reporting~startAsyncReporting(db, intervalMs) +### Validation API: Validation APIs~isValidSignedNumberString(value) ⇒ +Check if value is a valid signed number in string form. -Start the interval that will check and report dirty flags. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -**Kind**: inner method of [JS API: async reporting](#module*JS API* async reporting) +| Param | Type | +| --- | --- | +| value | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| intervalMs | \* | + - +### Validation API: Validation APIs~isValidHexString(value) ⇒ +Check if value is a valid hex string. -### JS API: async reporting~stopAsyncReporting() +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -Stop the interval that will check and report dirty flags +| Param | Type | +| --- | --- | +| value | \* | -**Kind**: inner method of [JS API: async reporting](#module*JS API* async reporting) - + -## JS API: post-import. +### Validation API: Validation APIs~isValidDecimalString(value) ⇒ +Check if value is a valid decimal string. -This module contains the API functions for the post-load -scripting functionality. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| value | \* | -## JS API: SDK utilities + - +### Validation API: Validation APIs~isValidFloat(value) ⇒ +Check if value is a valid float value. -### JS API: SDK utilities~readSdkJson(sdkPath, logger) +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -This function reads in the sdk.json that is passed as sdkPath, -and resolve the promise with the sdk object. -logger is used for printouts. +| Param | Type | +| --- | --- | +| value | \* | -**Kind**: inner method of [JS API: SDK utilities](#module*JS API* SDK utilities) + -| Param | Type | -| ------- | --------------- | -| sdkPath | \* | -| logger | \* | +### Validation API: Validation APIs~extractFloatValue(value) ⇒ +Get float value from the given value. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: float value -## JS API: string utilities +| Param | Type | +| --- | --- | +| value | \* | -- [JS API: string utilities](#module*JS API* string utilities) - - [~toCamelCase(str)](#module*JS API* string utilities..toCamelCase) ⇒ - - [~toSnakeCaseAllCaps(label)](#module*JS API* string utilities..toSnakeCaseAllCaps) - - [~toCleanSymbol(label)](#module*JS API* string utilities..toCleanSymbol) - - [~toCleanSymbolAsKebabCase(label)](#module*JS API* string utilities..toCleanSymbolAsKebabCase) - - [~toCleanMacro(label)](#module*JS API* string utilities..toCleanMacro) ⇒ - - [~isDigit(ch)](#module*JS API* string utilities..isDigit) + - +### Validation API: Validation APIs~extractIntegerValue(value) ⇒ +Expects a number string , parse it back on a default base 10 if its a decimal. +If its a hexadecimal or anything else , parse it back on base 16. +Loses precision after javascripts Number.MAX_SAFE_INTEGER range. -### JS API: string utilities~toCamelCase(str) ⇒ +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: A decimal number -Given a string convert it into a camelCased string +| Param | Type | +| --- | --- | +| value | \* | -**Kind**: inner method of [JS API: string utilities](#module*JS API* string utilities) -**Returns**: a spaced out string in lowercase -**Parem**: \* firstLower if True the it starts with lowecase. + -| Param | Type | -| ----- | --------------- | -| str | \* | +### Validation API: Validation APIs~extractBigIntegerValue(value) ⇒ +Get value of bit integer. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: BigInt -### JS API: string utilities~toSnakeCaseAllCaps(label) +| Param | Type | +| --- | --- | +| value | \* | -Takes a label, and delimits is on camelcasing. -For example: -VerySimpleLabel will turn into VERY_SIMPLE_LABEL + -**Kind**: inner method of [JS API: string utilities](#module*JS API* string utilities) +### Validation API: Validation APIs~isBigInteger(bits) ⇒ +Check if integer is greater than 4 bytes. -| Param | Type | -| ----- | --------------- | -| label | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| bits | \* | -### JS API: string utilities~toCleanSymbol(label) + -returns a string after converting ':' and '-' into '\_' +### Validation API: Validation APIs~getBoundsInteger(attribute, typeSize, isSigned) ⇒ +Get the integer attribute's bounds. -**Kind**: inner method of [JS API: string utilities](#module*JS API* string utilities) +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object -| Param | Type | -| ----- | --------------- | -| label | \* | +| Param | Type | +| --- | --- | +| attribute | \* | +| typeSize | \* | +| isSigned | \* | - + -### JS API: string utilities~toCleanSymbolAsKebabCase(label) +### Validation API: Validation APIs~unsignedToSignedInteger(value, typeSize) ⇒ +Converts an unsigned integer to its signed value. Returns the same integer if its not a signed type. +Works for both BigInts and regular numbers. -returns a string after converting ':' and '\_' into '-' +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: A decimal number -**Kind**: inner method of [JS API: string utilities](#module*JS API* string utilities) +| Param | Type | Description | +| --- | --- | --- | +| value | \* | integer to convert | +| typeSize | \* | bit representation | -| Param | Type | -| ----- | --------------- | -| label | \* | + - +### Validation API: Validation APIs~getIntegerFromAttribute(attribute, typeSize, isSigned) ⇒ +Converts an attribute (number string) into a decimal number without losing precision. +Accepts both decimal and hexadecimal strings (former has priority) in any bit representation. +Shifts signed hexadecimals to their correct value. -### JS API: string utilities~toCleanMacro(label) ⇒ +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: A decimal number -Formats label as a C macro. This method performs a very simply substition -of illegal characters, such as ' ', ':' and such into a '\_' character. +| Param | Type | Description | +| --- | --- | --- | +| attribute | \* | attribute to convert | +| typeSize | \* | bit representation size | +| isSigned | \* | is type is signed | -**Kind**: inner method of [JS API: string utilities](#module*JS API* string utilities) -**Returns**: Label formatted as C macro. + -| Param | Type | -| ----- | --------------- | -| label | \* | +### Validation API: Validation APIs~getIntegerAttributeSize(db, zapSessionId, attribType) ⇒ \* +Returns information about an integer type. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: \* - { size: bit representation , isSigned: is signed type } -### JS API: string utilities~isDigit(ch) +| Param | Type | +| --- | --- | +| db | \* | +| zapSessionId | \* | +| attribType | \* | -Returns true if given character is a digit. + -**Kind**: inner method of [JS API: string utilities](#module*JS API* string utilities) +### Validation API: Validation APIs~checkAttributeBoundsInteger(attribute, endpointAttribute, db, zapSessionId) ⇒ +Checks if the incoming integer is within it's attributes bound while handling signed and unsigned cases. -| Param | Type | -| ----- | --------------- | -| ch | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| attribute | \* | +| endpointAttribute | \* | +| db | \* | +| zapSessionId | \* | -## JS API: type related utilities + -- [JS API: type related utilities](#module*JS API* type related utilities) - - [~typeSize(db, zclPackageId, type)](#module*JS API* type related utilities..typeSize) - - [~typeSizeAttribute(db, zclPackageIds, at, [defaultValue])](#module*JS API* type related utilities..typeSizeAttribute) ⇒ - - [~convertFloatToBigEndian(value, size)](#module*JS API* type related utilities..convertFloatToBigEndian) ⇒ - - [~convertIntToBigEndian(value, size)](#module*JS API* type related utilities..convertIntToBigEndian) ⇒ - - [~longTypeDefaultValue(size, type, value)](#module*JS API* type related utilities..longTypeDefaultValue) ⇒ - - [~convertToCliType(str)](#module*JS API* type related utilities..convertToCliType) ⇒ - - [~isString(type)](#module*JS API* type related utilities..isString) ⇒ - - [~isFloat(type)](#module*JS API* type related utilities..isFloat) ⇒ - - [~isSignedInteger(db, sessionId, type)](#module*JS API* type related utilities..isSignedInteger) ⇒ Promise.<boolean> - - [~isOneBytePrefixedString(type)](#module*JS API* type related utilities..isOneBytePrefixedString) ⇒ - - [~isTwoBytePrefixedString(type)](#module*JS API* type related utilities..isTwoBytePrefixedString) ⇒ - - [~nullStringDefaultValue(type)](#module*JS API* type related utilities..nullStringDefaultValue) ⇒ string - - [~getSignAndSizeOfZclType(type, context, options)](#module*JS API* type related utilities..getSignAndSizeOfZclType) ⇒ +### Validation API: Validation APIs~checkBoundsInteger(defaultValue, min, max) ⇒ +Check if an integer value is within the bounds. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -### JS API: type related utilities~typeSize(db, zclPackageId, type) +| Param | Type | +| --- | --- | +| defaultValue | \* | +| min | \* | +| max | \* | -This function resolves with the size of a given type. --1 means that this size is variable. + -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) +### Validation API: Validation APIs~checkAttributeBoundsFloat(attribute, endpointAttribute) ⇒ +Check if float attribute's value is within the bounds. -| Param | Type | -| ------------ | --------------- | -| db | \* | -| zclPackageId | \* | -| type | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| attribute | \* | +| endpointAttribute | \* | -### JS API: type related utilities~typeSizeAttribute(db, zclPackageIds, at, [defaultValue]) ⇒ + -Returns the size of a real attribute, taking type size and defaults -into consideration, so that strings are properly sized. +### Validation API: Validation APIs~getBoundsFloat(attribute) ⇒ +Get the bounds on a float attribute's value. -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: Promise that resolves into the size of the attribute. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object -| Param | Type | Default | -| -------------- | --------------- | ------------- | -| db | \* | | -| zclPackageIds | \* | | -| at | \* | | -| [defaultValue] | \* | | +| Param | Type | +| --- | --- | +| attribute | \* | - + -### JS API: type related utilities~convertFloatToBigEndian(value, size) ⇒ +### Validation API: Validation APIs~checkBoundsFloat(defaultValue, min, max) ⇒ +Check if float value is within the min/max bounds. -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: The big endian value for a given float value padded with -the given size. The value is returned in hex format and prefixed with '0x'. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -| Param | Type | -| ----- | --------------- | -| value | \* | -| size | \* | +| Param | Type | +| --- | --- | +| defaultValue | \* | +| min | \* | +| max | \* | - + -### JS API: type related utilities~convertIntToBigEndian(value, size) ⇒ +## Validation API: Validation APIs +This module provides the APIs for validating inputs to the database, and returning flags indicating if +things were successful or not. -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: The big endian value for a given integer value padded with -the given size. The value is returned in hex format and prefixed with '0x'. -| Param | Type | -| ----- | --------------- | -| value | \* | -| size | \* | +* [Validation API: Validation APIs](#module_Validation API_ Validation APIs) + * _static_ + * [.initAsyncValidation()](#module_Validation API_ Validation APIs.initAsyncValidation) + * _inner_ + * [~zigbeeEnforceCommonClusterSpecInit(session)](#module_Validation API_ Validation APIs..zigbeeEnforceCommonClusterSpecInit) ⇒ + * [~zigbeeEnforceCommonClusterSpecCallback(session)](#module_Validation API_ Validation APIs..zigbeeEnforceCommonClusterSpecCallback) + * [~validateAttribute(db, endpointTypeId, attributeRef, clusterRef, zapSessionId)](#module_Validation API_ Validation APIs..validateAttribute) ⇒ + * [~validateEndpoint(db, endpointId)](#module_Validation API_ Validation APIs..validateEndpoint) ⇒ + * [~validateNoDuplicateEndpoints(db, endpointIdentifier, sessionRef)](#module_Validation API_ Validation APIs..validateNoDuplicateEndpoints) ⇒ + * [~validateSpecificAttribute(endpointAttribute, attribute, db, zapSessionId)](#module_Validation API_ Validation APIs..validateSpecificAttribute) ⇒ + * [~validateSpecificEndpoint(endpoint)](#module_Validation API_ Validation APIs..validateSpecificEndpoint) ⇒ + * [~isValidNumberString(value)](#module_Validation API_ Validation APIs..isValidNumberString) ⇒ + * [~isValidSignedNumberString(value)](#module_Validation API_ Validation APIs..isValidSignedNumberString) ⇒ + * [~isValidHexString(value)](#module_Validation API_ Validation APIs..isValidHexString) ⇒ + * [~isValidDecimalString(value)](#module_Validation API_ Validation APIs..isValidDecimalString) ⇒ + * [~isValidFloat(value)](#module_Validation API_ Validation APIs..isValidFloat) ⇒ + * [~extractFloatValue(value)](#module_Validation API_ Validation APIs..extractFloatValue) ⇒ + * [~extractIntegerValue(value)](#module_Validation API_ Validation APIs..extractIntegerValue) ⇒ + * [~extractBigIntegerValue(value)](#module_Validation API_ Validation APIs..extractBigIntegerValue) ⇒ + * [~isBigInteger(bits)](#module_Validation API_ Validation APIs..isBigInteger) ⇒ + * [~getBoundsInteger(attribute, typeSize, isSigned)](#module_Validation API_ Validation APIs..getBoundsInteger) ⇒ + * [~unsignedToSignedInteger(value, typeSize)](#module_Validation API_ Validation APIs..unsignedToSignedInteger) ⇒ + * [~getIntegerFromAttribute(attribute, typeSize, isSigned)](#module_Validation API_ Validation APIs..getIntegerFromAttribute) ⇒ + * [~getIntegerAttributeSize(db, zapSessionId, attribType)](#module_Validation API_ Validation APIs..getIntegerAttributeSize) ⇒ \* + * [~checkAttributeBoundsInteger(attribute, endpointAttribute, db, zapSessionId)](#module_Validation API_ Validation APIs..checkAttributeBoundsInteger) ⇒ + * [~checkBoundsInteger(defaultValue, min, max)](#module_Validation API_ Validation APIs..checkBoundsInteger) ⇒ + * [~checkAttributeBoundsFloat(attribute, endpointAttribute)](#module_Validation API_ Validation APIs..checkAttributeBoundsFloat) ⇒ + * [~getBoundsFloat(attribute)](#module_Validation API_ Validation APIs..getBoundsFloat) ⇒ + * [~checkBoundsFloat(defaultValue, min, max)](#module_Validation API_ Validation APIs..checkBoundsFloat) ⇒ + + + +### Validation API: Validation APIs.initAsyncValidation() +Start session specific validation. - +**Kind**: static method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) + -### JS API: type related utilities~longTypeDefaultValue(size, type, value) ⇒ +### Validation API: Validation APIs~zigbeeEnforceCommonClusterSpecInit(session) ⇒ +Enforce zigbee specific common cluster initialization. -If the type is more than 2 bytes long, then this method creates -the default byte array. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: string which is a C-formatted byte array. +| Param | Type | +| --- | --- | +| session | \* | -| Param | Type | Description | -| ----- | --------------- | ------------------------ | -| size | \* | Size of bytes generated. | -| type | \* | Type of the object. | -| value | \* | Default value. | + - +### Validation API: Validation APIs~zigbeeEnforceCommonClusterSpecCallback(session) +Enforce zigbee specific common cluster initialization. -### JS API: type related utilities~convertToCliType(str) ⇒ +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) -Conversion to a CLI type. THis is here temporarily until we come up -with a proper type engine. +| Param | Type | +| --- | --- | +| session | \* | -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: converted type + -| Param | Type | -| ----- | --------------- | -| str | \* | +### Validation API: Validation APIs~validateAttribute(db, endpointTypeId, attributeRef, clusterRef, zapSessionId) ⇒ +Main attribute validation function. +Returns a promise of an object which stores a list of validational issues. +Such issues as "Invalid type" or "Out of Range". - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: Promise of the list of issues -### JS API: type related utilities~isString(type) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | db reference | +| endpointTypeId | \* | endpoint reference | +| attributeRef | \* | attribute reference | +| clusterRef | \* | cluster reference | +| zapSessionId | \* | session reference | -Returns true if a given ZCL type is a string type. + -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: true if type is string, false otherwise +### Validation API: Validation APIs~validateEndpoint(db, endpointId) ⇒ +Get issues in an endpoint. -| Param | Type | -| ----- | --------------- | -| type | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object - +| Param | Type | +| --- | --- | +| db | \* | +| endpointId | \* | -### JS API: type related utilities~isFloat(type) ⇒ + -Returns true if a given ZCL type is a float type. +### Validation API: Validation APIs~validateNoDuplicateEndpoints(db, endpointIdentifier, sessionRef) ⇒ +Check if there are no duplicate endpoints. -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: true if type is float, false otherwise +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -| Param | Type | -| ----- | --------------- | -| type | \* | +| Param | Type | +| --- | --- | +| db | \* | +| endpointIdentifier | \* | +| sessionRef | \* | - + -### JS API: type related utilities~isSignedInteger(db, sessionId, type) ⇒ Promise.<boolean> +### Validation API: Validation APIs~validateSpecificAttribute(endpointAttribute, attribute, db, zapSessionId) ⇒ +Checks the attributes type then validates the incoming input string. -Checks if a given ZCL type is a signed integer. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: List of issues wrapped in an object -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: Promise.<boolean> - - A promise that resolves to true if the type is a signed integer, false otherwise. +| Param | Type | +| --- | --- | +| endpointAttribute | \* | +| attribute | \* | +| db | \* | +| zapSessionId | \* | -| Param | Type | Description | -| --------- | ------------------- | ------------------------------- | -| db | object | The database connection object. | -| sessionId | string | The session ID. | -| type | string | The name of the ZCL type. | + - +### Validation API: Validation APIs~validateSpecificEndpoint(endpoint) ⇒ +Get endpoint and newtork issue on an endpoint. -### JS API: type related utilities~isOneBytePrefixedString(type) ⇒ +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object -Checks if type is a one-byte lengh string. +| Param | Type | +| --- | --- | +| endpoint | \* | -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: true if the said type is a string prefixed by one byte length + -| Param | Type | -| ----- | --------------- | -| type | \* | +### Validation API: Validation APIs~isValidNumberString(value) ⇒ +Check if value is a valid number in string form. +This applies to both actual numbers as well as octet strings. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -### JS API: type related utilities~isTwoBytePrefixedString(type) ⇒ +| Param | Type | +| --- | --- | +| value | \* | -Checks if type is a two-byte lengh string. + -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: true if the said type is a string prefixed by two byte length +### Validation API: Validation APIs~isValidSignedNumberString(value) ⇒ +Check if value is a valid signed number in string form. -| Param | Type | -| ----- | --------------- | -| type | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| value | \* | -### JS API: type related utilities~nullStringDefaultValue(type) ⇒ string + -Generates a default value for a null string based on its type. -This function is designed to abstract away the specific null representation -of strings from the longTypeDefaultValue function, ensuring that the latter -does not need to be aware of these details. +### Validation API: Validation APIs~isValidHexString(value) ⇒ +Check if value is a valid hex string. -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: string - The default value for a null string of the specified type. -**Throws**: +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -- Error Throws an error if the string type is unknown. +| Param | Type | +| --- | --- | +| value | \* | -| Param | Type | Description | -| ----- | ------------------- | ----------------------------------------------------------------- | -| type | string | The type of the string, which determines its null representation. | + - +### Validation API: Validation APIs~isValidDecimalString(value) ⇒ +Check if value is a valid decimal string. -### JS API: type related utilities~getSignAndSizeOfZclType(type, context, options) ⇒ +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -Given a zcl device type returns its sign, size and zcl data type info stored -in the database table. -Note: Enums and Bitmaps are considered to be unsigned. +| Param | Type | +| --- | --- | +| value | \* | -**Kind**: inner method of [JS API: type related utilities](#module*JS API* type related utilities) -**Returns**: returns sign, size and info of zcl device type -Available Options: + -- size: Determine whether to calculate the size of zcl device type in bits - or bytes - for eg: getSignAndSizeOfZclType('int8u' this size='bits') will return - the size in bits which will be 8. If not mentioned then it will return the size - in bytes i.e. 1 in this case. +### Validation API: Validation APIs~isValidFloat(value) ⇒ +Check if value is a valid float value. -| Param | Type | -| ------- | --------------- | -| type | \* | -| context | \* | -| options | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| value | \* | -## JS API: random utilities + -- [JS API: random utilities](#module*JS API* random utilities) - - [~checksum(data)](#module*JS API* random utilities..checksum) ⇒ - - [~ensurePackagesAndPopulateSessionOptions(db, sessionId, options:, selectedZclPropertyPackage, selectedGenTemplatePackages)](#module*JS API* random utilities..ensurePackagesAndPopulateSessionOptions) ⇒ - - [~createBackupFile(filePath)](#module*JS API* random utilities..createBackupFile) - - [~matchFeatureLevel(featureLevel)](#module*JS API* random utilities..matchFeatureLevel) - - [~sessionReport(db, sessionId)](#module*JS API* random utilities..sessionReport) ⇒ - - [~sessionDump(db, sessionId)](#module*JS API* random utilities..sessionDump) ⇒ - - [~executePromisesSequentially(arrayOfData, promiseCreator)](#module*JS API* random utilities..executePromisesSequentially) - - [~createAbsolutePath(relativePath, relativity, zapFilePath)](#module*JS API* random utilities..createAbsolutePath) - - [~locateRelativeFilePath(rootFileLocations, relativeFilePath)](#module*JS API* random utilities..locateRelativeFilePath) ⇒ - - [~executeExternalProgram(cmd)](#module*JS API* random utilities..executeExternalProgram) - - [~getClusterExtensionDefault(extensions, extensionId, clusterCode)](#module*JS API* random utilities..getClusterExtensionDefault) ⇒ - - [~getClusterExtension(extensions, property, clusterCode)](#module*JS API* random utilities..getClusterExtension) ⇒ - - [~createUuid()](#module*JS API* random utilities..createUuid) - - [~waitFor(time)](#module*JS API* random utilities..waitFor) - - [~parseXml(fileContent)](#module*JS API* random utilities..parseXml) ⇒ - - [~readFileContentAndCrc(metadata)](#module*JS API* random utilities..readFileContentAndCrc) ⇒ - - [~duration(nsDifference)](#module*JS API* random utilities..duration) ⇒ - - [~mainOrSecondaryInstance()](#module*JS API* random utilities..mainOrSecondaryInstance) - - [~collectJsonData(jsonFile)](#module*JS API* random utilities..collectJsonData) - - [~patternFormat(pattern, data)](#module*JS API* random utilities..patternFormat) +### Validation API: Validation APIs~extractFloatValue(value) ⇒ +Get float value from the given value. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: float value -### JS API: random utilities~checksum(data) ⇒ +| Param | Type | +| --- | --- | +| value | \* | -Returns the CRC of the data that is passed. + -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: Calculated CRC of a data. +### Validation API: Validation APIs~extractIntegerValue(value) ⇒ +Expects a number string , parse it back on a default base 10 if its a decimal. +If its a hexadecimal or anything else , parse it back on base 16. +Loses precision after javascripts Number.MAX_SAFE_INTEGER range. -| Param | Type | -| ----- | --------------- | -| data | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: A decimal number - +| Param | Type | +| --- | --- | +| value | \* | -### JS API: random utilities~ensurePackagesAndPopulateSessionOptions(db, sessionId, options:, selectedZclPropertyPackage, selectedGenTemplatePackages) ⇒ + -This function assigns a proper package ID to the session if there -are no packages present. It will also populate session options. +### Validation API: Validation APIs~extractBigIntegerValue(value) ⇒ +Get value of bit integer. -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: Promise that resolves with the packages array. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: BigInt -| Param | Type | Description | -| --------------------------- | --------------- | -------------------------------------- | -| db | \* | | -| sessionId | \* | | -| options: | \* | object containing 'zcl' and 'template' | -| selectedZclPropertyPackage | \* | | -| selectedGenTemplatePackages | \* | | +| Param | Type | +| --- | --- | +| value | \* | - + -### JS API: random utilities~createBackupFile(filePath) +### Validation API: Validation APIs~isBigInteger(bits) ⇒ +Check if integer is greater than 4 bytes. -Move database file out of the way into the backup location. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) +| Param | Type | +| --- | --- | +| bits | \* | -| Param | Type | -| -------- | --------------- | -| filePath | \* | + - +### Validation API: Validation APIs~getBoundsInteger(attribute, typeSize, isSigned) ⇒ +Get the integer attribute's bounds. -### JS API: random utilities~matchFeatureLevel(featureLevel) +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object -Returns an object that contains: -match: true or false if featureLevel is matched or not. -message: in case of missmatch, the message shown to user. +| Param | Type | +| --- | --- | +| attribute | \* | +| typeSize | \* | +| isSigned | \* | -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) + -| Param | Type | -| ------------ | --------------- | -| featureLevel | \* | +### Validation API: Validation APIs~unsignedToSignedInteger(value, typeSize) ⇒ +Converts an unsigned integer to its signed value. Returns the same integer if its not a signed type. +Works for both BigInts and regular numbers. - +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: A decimal number -### JS API: random utilities~sessionReport(db, sessionId) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| value | \* | integer to convert | +| typeSize | \* | bit representation | -Produces a text dump of a session data for human consumption. + -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: promise that resolves into a text report for the session. +### Validation API: Validation APIs~getIntegerFromAttribute(attribute, typeSize, isSigned) ⇒ +Converts an attribute (number string) into a decimal number without losing precision. +Accepts both decimal and hexadecimal strings (former has priority) in any bit representation. +Shifts signed hexadecimals to their correct value. -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: A decimal number - +| Param | Type | Description | +| --- | --- | --- | +| attribute | \* | attribute to convert | +| typeSize | \* | bit representation size | +| isSigned | \* | is type is signed | -### JS API: random utilities~sessionDump(db, sessionId) ⇒ + -Produces a text dump of a session data for human consumption. +### Validation API: Validation APIs~getIntegerAttributeSize(db, zapSessionId, attribType) ⇒ \* +Returns information about an integer type. -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: promise that resolves into a text report for the session. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: \* - { size: bit representation , isSigned: is signed type } -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| zapSessionId | \* | +| attribType | \* | - + -### JS API: random utilities~executePromisesSequentially(arrayOfData, promiseCreator) +### Validation API: Validation APIs~checkAttributeBoundsInteger(attribute, endpointAttribute, db, zapSessionId) ⇒ +Checks if the incoming integer is within it's attributes bound while handling signed and unsigned cases. -If you have an array of arguments, and a function that creates -a promise out of each of those arguments, this function -executes them sequentially, one by one. +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| attribute | \* | +| endpointAttribute | \* | +| db | \* | +| zapSessionId | \* | + + + +### Validation API: Validation APIs~checkBoundsInteger(defaultValue, min, max) ⇒ +Check if an integer value is within the bounds. + +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| defaultValue | \* | +| min | \* | +| max | \* | + + + +### Validation API: Validation APIs~checkAttributeBoundsFloat(attribute, endpointAttribute) ⇒ +Check if float attribute's value is within the bounds. + +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| attribute | \* | +| endpointAttribute | \* | + + + +### Validation API: Validation APIs~getBoundsFloat(attribute) ⇒ +Get the bounds on a float attribute's value. + +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: object + +| Param | Type | +| --- | --- | +| attribute | \* | + + + +### Validation API: Validation APIs~checkBoundsFloat(defaultValue, min, max) ⇒ +Check if float value is within the min/max bounds. + +**Kind**: inner method of [Validation API: Validation APIs](#module_Validation API_ Validation APIs) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| defaultValue | \* | +| min | \* | +| max | \* | + + + +## Loader API: Loader APIs +This module provides the APIs for dotdot Loading + + +* [Loader API: Loader APIs](#module_Loader API_ Loader APIs) + * [~collectDataFromLibraryXml(ctx)](#module_Loader API_ Loader APIs..collectDataFromLibraryXml) ⇒ + * [~tagContainsEnum(tag)](#module_Loader API_ Loader APIs..tagContainsEnum) ⇒ + * [~tagContainsStruct(tag)](#module_Loader API_ Loader APIs..tagContainsStruct) ⇒ + * [~tagContainsBitmap(tag)](#module_Loader API_ Loader APIs..tagContainsBitmap) ⇒ + * [~parseSingleZclFile(db, ctx, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~parseZclFiles(db, ctx)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~normalizeHexValue(value)](#module_Loader API_ Loader APIs..normalizeHexValue) ⇒ + * [~getNumBytesFromShortName(value)](#module_Loader API_ Loader APIs..getNumBytesFromShortName) ⇒ + * [~prepareAttributes(attributes, side)](#module_Loader API_ Loader APIs..prepareAttributes) ⇒ + * [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒ + * [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒ + * [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒ + * [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒ + * [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~prepareTypes(zclTypes, types)](#module_Loader API_ Loader APIs..prepareTypes) + * [~prepareAttributeType(attribute, types, cluster)](#module_Loader API_ Loader APIs..prepareAttributeType) + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, packageId, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumsOrBitmaps(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmaps) ⇒ + * [~processEnums(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnums) ⇒ + * [~processEnumItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmaps(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmaps) ⇒ + * [~processBitmapFields(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct2(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct2) ⇒ + * [~processStruct(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareEnumsOrBitmapsAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmapsAtomic) ⇒ + * [~processEnumsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumsFromAtomics) ⇒ + * [~processBitmapsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapsFromAtomics) ⇒ + * [~loadZclData(db, ctx)](#module_Loader API_ Loader APIs..loadZclData) ⇒ + * [~loadIndividualDotDotFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualDotDotFile) ⇒ \* + * [~loadToplevelXmlFile(db, ctx)](#module_Loader API_ Loader APIs..loadToplevelXmlFile) ⇒ + * [~parseNewXmlFiles(db, packageId, files, context)](#module_Loader API_ Loader APIs..parseNewXmlFiles) ⇒ + * [~prepXmlFeature(f)](#module_Loader API_ Loader APIs..prepXmlFeature) ⇒ + * [~prepXmlAttribute(a)](#module_Loader API_ Loader APIs..prepXmlAttribute) ⇒ + * [~prepXmlCommand(c)](#module_Loader API_ Loader APIs..prepXmlCommand) ⇒ + * [~prepXmlEvent(e)](#module_Loader API_ Loader APIs..prepXmlEvent) ⇒ + * [~parseSingleNewXmlFile(f)](#module_Loader API_ Loader APIs..parseSingleNewXmlFile) ⇒ + * [~collectDataFromJsonFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromJsonFile) ⇒ + * [~collectDataFromPropertiesFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromPropertiesFile) ⇒ + * [~maskToType(mask)](#module_Loader API_ Loader APIs..maskToType) ⇒ + * [~prepareAtomic(a)](#module_Loader API_ Loader APIs..prepareAtomic) + * [~processAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processAtomics) ⇒ + * [~prepareClusterGlobalAttribute(cluster)](#module_Loader API_ Loader APIs..prepareClusterGlobalAttribute) ⇒ + * [~extractAccessTag(ac)](#module_Loader API_ Loader APIs..extractAccessTag) ⇒ + * [~extractAccessIntoArray(xmlElement)](#module_Loader API_ Loader APIs..extractAccessIntoArray) ⇒ + * [~prepareCluster(cluster)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~processClusters(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusters) ⇒ + * [~processClusterGlobalAttributes(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterGlobalAttributes) ⇒ + * [~processClusterExtensions(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterExtensions) ⇒ + * [~processGlobals(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processGlobals) ⇒ + * [~prepareTag(tag)](#module_Loader API_ Loader APIs..prepareTag) ⇒ + * [~processDefaultAccess(db, filePath, packageId, defaultAccessList)](#module_Loader API_ Loader APIs..processDefaultAccess) + * [~processAccessControl(db, filePath, packageId, accessControlList)](#module_Loader API_ Loader APIs..processAccessControl) + * [~processTags(db, filePath, packageId, tags)](#module_Loader API_ Loader APIs..processTags) + * [~prepareDomain(domain)](#module_Loader API_ Loader APIs..prepareDomain) ⇒ + * [~processDomains(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processDomains) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, filePath, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, knownPackages, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumOrBitmapAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmapAtomic) ⇒ + * [~processEnumAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumAtomic) ⇒ + * [~prepareEnumOrBitmap(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmap) ⇒ + * [~processEnum(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnum) ⇒ + * [~processEnumItems(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmapAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapAtomic) ⇒ + * [~processBitmap(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmap) ⇒ + * [~processBitmapFields(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~processStruct(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageIds, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ Object + * [~processDeviceTypes(db, filePath, packageId, data, context)](#module_Loader API_ Loader APIs..processDeviceTypes) ⇒ Promise + * [~processParsedZclData(db, argument)](#module_Loader API_ Loader APIs..processParsedZclData) ⇒ + * [~parseSingleZclFile(db, packageId, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~isCrcMismatchOrPackageDoesNotExist(db, packageId, files)](#module_Loader API_ Loader APIs..isCrcMismatchOrPackageDoesNotExist) ⇒ + * [~parseZclFiles(db, packageId, zclFiles, context)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~parseManufacturerData(db, ctx)](#module_Loader API_ Loader APIs..parseManufacturerData) ⇒ + * [~parseProfilesData(db, ctx)](#module_Loader API_ Loader APIs..parseProfilesData) ⇒ + * [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒ + * [~parseFeatureConformance(operand)](#module_Loader API_ Loader APIs..parseFeatureConformance) ⇒ + * [~parseAndOrConformanceTerms(operand, joinChar)](#module_Loader API_ Loader APIs..parseAndOrConformanceTerms) ⇒ + * [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒ + * [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒ + * [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒ + * [~parseBoolOptions(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolOptions) ⇒ + * [~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes)](#module_Loader API_ Loader APIs..parseattributeAccessInterfaceAttributes) ⇒ Promise.<void> + * [~parseDefaults(db, ctx)](#module_Loader API_ Loader APIs..parseDefaults) ⇒ + * [~parseTextDefaults(db, pkgRef, textDefaults)](#module_Loader API_ Loader APIs..parseTextDefaults) ⇒ + * [~parseBoolDefaults(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolDefaults) ⇒ + * [~loadIndividualSilabsFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualSilabsFile) ⇒ + * [~processCustomZclDeviceType(db, ctx)](#module_Loader API_ Loader APIs..processCustomZclDeviceType) ⇒ + * [~loadZclJson(db, metafile)](#module_Loader API_ Loader APIs..loadZclJson) ⇒ + * [~loadZclProperties(db, metafile)](#module_Loader API_ Loader APIs..loadZclProperties) ⇒ + * [~loadZclJsonOrProperties(db, ctx)](#module_Loader API_ Loader APIs..loadZclJsonOrProperties) ⇒ + * [~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync)](#module_Loader API_ Loader APIs..recordToplevelPackage) ⇒ + * [~recordVersion(db, ctx)](#module_Loader API_ Loader APIs..recordVersion) + * [~loadZclMetaFilesCommon(db, metadataFile, options)](#module_Loader API_ Loader APIs..loadZclMetaFilesCommon) ⇒ + * [~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap)](#module_Loader API_ Loader APIs..loadAttributeMappingForMultiProtocol) + * [~loadZclMetafiles(db, metadataFile)](#module_Loader API_ Loader APIs..loadZclMetafiles) ⇒ + * [~loadZcl(db, metadataFile)](#module_Loader API_ Loader APIs..loadZcl) ⇒ + * [~loadIndividualFile(db, filePath, sessionId)](#module_Loader API_ Loader APIs..loadIndividualFile) + * [~qualifyZclFile(db, info, parentPackageId, isCustom)](#module_Loader API_ Loader APIs..qualifyZclFile) ⇒ + * [~processZclPostLoading(db)](#module_Loader API_ Loader APIs..processZclPostLoading) ⇒ + * [~getDiscriminatorMap(db, packageIds)](#module_Loader API_ Loader APIs..getDiscriminatorMap) ⇒ + + + +### Loader API: Loader APIs~collectDataFromLibraryXml(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. -| Param | Type | -| -------------- | --------------- | -| arrayOfData | \* | -| promiseCreator | \* | +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the metadataFiles and data | - + -### JS API: random utilities~createAbsolutePath(relativePath, relativity, zapFilePath) +### Loader API: Loader APIs~tagContainsEnum(tag) ⇒ +Check if tag contains enum. -This function creates absolute path out of relative path and its relativity +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) +| Param | Type | +| --- | --- | +| tag | \* | -| Param | Type | -| ------------ | --------------- | -| relativePath | \* | -| relativity | \* | -| zapFilePath | \* | + - +### Loader API: Loader APIs~tagContainsStruct(tag) ⇒ +Check if tag contains struct. -### JS API: random utilities~locateRelativeFilePath(rootFileLocations, relativeFilePath) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -This method takes an array of root locations and a relative path. -It will attempt to locate an absolute file at the path, combining -the root location and a relative path, until a file is found and returned. +| Param | Type | +| --- | --- | +| tag | \* | -If none of the combined root locations and relative paths results -in an actual file, null is returned. + -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: A fully resolved path that exists, or null if none is available. +### Loader API: Loader APIs~tagContainsBitmap(tag) ⇒ +Check if tag contains Bitmap. -| Param | Type | Description | -| ----------------- | --------------- | --------------------------------------------------- | -| rootFileLocations | \* | Array of root file locations, typically directories | -| relativeFilePath | \* | Relative path | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| tag | \* | -### JS API: random utilities~executeExternalProgram(cmd) + -Returns a promise of an execution of an external program. +### Loader API: Loader APIs~parseSingleZclFile(db, ctx, file) ⇒ +Parses ZCL xml file. -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: empty array -| Param | Type | -| ----- | --------------- | -| cmd | \* | +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | +| file | \* | - + -### JS API: random utilities~getClusterExtensionDefault(extensions, extensionId, clusterCode) ⇒ +### Loader API: Loader APIs~parseZclFiles(db, ctx) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -Retrieve specific entry from extensions defaults(array) via 'clusterCode' key fields +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: Value of the cluster extension property. -**Parem**: \* clusterRole: one of server/client enums, or null for either. +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -| Param | Type | Description | -| ----------- | --------------- | ----------------------------------- | -| extensions | \* | | -| extensionId | \* | field name under specific extension | -| clusterCode | \* | search key | + - +### Loader API: Loader APIs~normalizeHexValue(value) ⇒ +The Dotdot ZCL XML doesn't use the 0x prefix, but it's a nice thing to have and Silabs xml +does use this so this helper function normalizes the use of hex -### JS API: random utilities~getClusterExtension(extensions, property, clusterCode) ⇒ +TODO: Is this the right thing to do? -Retrieve specific entry from extensions defaults(array) via 'clusterCode' key fields +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Either the normalized hex string (with the 0x prefix) or the original -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: Object containing all attribuetes specific to the extension +| Param | Type | Description | +| --- | --- | --- | +| value | \* | the string value to be normalized | -| Param | Type | Description | -| ----------- | --------------- | ----------------------------------- | -| extensions | \* | | -| property | \* | field name under specific extension | -| clusterCode | \* | search key | + - +### Loader API: Loader APIs~getNumBytesFromShortName(value) ⇒ +The Dotdot ZCL XML doesn't have a length but it is embedded in the short name, +we can scrape the value to get the size -### JS API: random utilities~createUuid() +TODO: Is this the right thing to do? -Global way how to get an UUID. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: size in bytes or 0 if the # of bytes could not be determined -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) - +| Param | Type | Description | +| --- | --- | --- | +| value | \* | the string value to be scraped | -### JS API: random utilities~waitFor(time) + -Returns a promise that resolves after time milliseconds +### Loader API: Loader APIs~prepareAttributes(attributes, side) ⇒ +Prepare XML attributes for entry into the DB -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted into the DB. -| Param | -| ----- | -| time | +| Param | Type | Description | +| --- | --- | --- | +| attributes | \* | an array of attributes | +| side | \* | the side the attribute is on either "client" or "server" | - + -### JS API: random utilities~parseXml(fileContent) ⇒ +### Loader API: Loader APIs~prepareCommands(commands, side, types) ⇒ +Prepare XML commands for entry into the DB -Returns a promise that resolve into a parsed XML object. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted in to the DB. -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: promise that resolves into parsed object. +| Param | Type | Description | +| --- | --- | --- | +| commands | \* | an array of commands | +| side | \* | the side the command is on either "client" or "server" | +| types | \* | contained for types, where bitmaps are going to be inserted. | -| Param | Type | -| ----------- | --------------- | -| fileContent | \* | + - +### Loader API: Loader APIs~prepareCluster(cluster, isExtension, types) ⇒ +Prepare XML cluster for insertion into the database. +This method can also prepare clusterExtensions. -### JS API: random utilities~readFileContentAndCrc(metadata) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. -Reads the properties file and returns object containing -'data', 'filePath' and 'crc' +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| cluster | \* | | | +| isExtension | \* | false | if this is an extension or not (there are none in dotdot xml) | +| types | \* | | types object into which cluster can put types it might have | -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: Promise to populate data, filePath and crc into the context. + -| Param | Type | Description | -| -------- | --------------- | ----------- | -| metadata | \* | file | +### Loader API: Loader APIs~prepareAtomic(type) ⇒ +Parses xml type into the atomic object for insertion into the DB - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -### JS API: random utilities~duration(nsDifference) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the atomic format in the dotdot xml | -This method takes a nanosecond duration and prints out -decently human readable time out of it. + -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) -**Returns**: String with human readable time duration. +### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒ +Parses xml type into the bitmap object for insertion into the DB -| Param | Type | -| ------------ | --------------- | -| nsDifference | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB - +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| type | \* | | an xml object which conforms to the bitmap format in the dotdot xml | +| isContained | \* | false | a boolean indicating if this is coming from a contained tag or not | -### JS API: random utilities~mainOrSecondaryInstance() + -This method returns true if the running instance is the first -and main instance of the zap, and false if zap instance is already -running. +### Loader API: Loader APIs~prepareEnum(type) ⇒ +Parses xml type into the enum object for insertion into the DB -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -### JS API: random utilities~collectJsonData(jsonFile) +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the enum format in the dotdot xml | -Utility method that collects data from a JSON file. + -JSON file is formatted as a bunch of keyed strings: -"someKey": [ "a", "b", "c"] -Then it supports following special keys: -"include": "path/to/json/file" - includes the said JSON file -"disable": [ "x", "y" ...] - disables the specified data points -"collection": ["key", "key2", ...] - collects final list of data points +### Loader API: Loader APIs~prepareStruct(type) ⇒ +Parses xml type into the struct object for insertion into the DB -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -| Param | Type | -| -------- | --------------- | -| jsonFile | \* | +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the struct format in the dotdot xml | - + -### JS API: random utilities~patternFormat(pattern, data) +### Loader API: Loader APIs~prepareTypes(zclTypes, types) +Parses xml types into the types object for insertion into the DB -This function receives pattern and data, and it formats pattern -by applyind data to it via it's keys. -For example, if pattern is "{a}" and data.a is 1, then this prints out "1". +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -**Kind**: inner method of [JS API: random utilities](#module*JS API* random utilities) +| Param | Type | Description | +| --- | --- | --- | +| zclTypes | \* | an array of xml types | +| types | \* | an object which includes arrays for enums, bitmaps etc... | -| Param | Type | -| ------- | --------------- | -| pattern | \* | -| data | \* | + - +### Loader API: Loader APIs~prepareAttributeType(attribute, types, cluster) +Parses xml types into the types object for insertion into the DB -## REST API: various zcl utilities +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -This module provides the API to access various zcl utilities. +| Param | Type | Description | +| --- | --- | --- | +| attribute | \* | an attribute with the type in it | +| types | \* | an object which includes arrays for enums, bitmaps etc... | +| cluster | \* | the cluster that the attribute belongs to (used presently for uniqueness of the type name) | -- [REST API: various zcl utilities](#module*REST API* various zcl utilities) - - [~clusterComparator(a, b)](#module*REST API* various zcl utilities..clusterComparator) ⇒ - - [~attributeComparator(a, b)](#module*REST API* various zcl utilities..attributeComparator) ⇒ - - [~commandComparator(a, b)](#module*REST API* various zcl utilities..commandComparator) ⇒ - - [~eventComparator(a, b)](#module*REST API* various zcl utilities..eventComparator) ⇒ - - [~sortStructsByDependency(structs)](#module*REST API* various zcl utilities..sortStructsByDependency) ⇒ - - [~calculateBytes(res, options, db, packageIds, isStructType)](#module*REST API* various zcl utilities..calculateBytes) - - [~optionsHashOrDefault(options, optionsKey, defaultValue)](#module*REST API* various zcl utilities..optionsHashOrDefault) - - [~dataTypeCharacterFormatter(db, packageIds, type, options, resType)](#module*REST API* various zcl utilities..dataTypeCharacterFormatter) - - [~isEnum(db, enum_name, packageIds)](#module*REST API* various zcl utilities..isEnum) ⇒ - - [~isStruct(db, struct_name, packageIds)](#module*REST API* various zcl utilities..isStruct) ⇒ - - [~isEvent(db, event_name, packageId)](#module*REST API* various zcl utilities..isEvent) ⇒ - - [~isBitmap(db, bitmap_name, packageIds)](#module*REST API* various zcl utilities..isBitmap) ⇒ - - [~defaultMessageForTypeConversion(fromType, toType, noWarning)](#module*REST API* various zcl utilities..defaultMessageForTypeConversion) - - [~dataTypeHelper(type, options, packageIds, db, resolvedType, overridable)](#module*REST API* various zcl utilities..dataTypeHelper) ⇒ - - [~asUnderlyingZclTypeWithPackageId(type, options, packageIds, currentInstance)](#module*REST API* various zcl utilities..asUnderlyingZclTypeWithPackageId) - - [~determineType(db, type, packageIds)](#module*REST API* various zcl utilities..determineType) - - [~zcl_data_type_size_and_sign(type, dataType, clusterId, packageIds, context)](#module*REST API* various zcl utilities..zcl_data_type_size_and_sign) ⇒ + - +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ +Preparation step for the device types. -### REST API: various zcl utilities~clusterComparator(a, b) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: an object containing the prepared device types. -Comparator for sorting clusters. +| Param | Type | +| --- | --- | +| deviceType | \* | -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: -1, 0 or 1 + -| Param | Type | -| ----- | --------------- | -| a | \* | -| b | \* | +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ +Prepare Data Type Discriminator for database table insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -### REST API: various zcl utilities~attributeComparator(a, b) ⇒ +| Param | Type | +| --- | --- | +| a | \* | -Comparator for sorting attribute. + -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: -1, 0 or 1 +### Loader API: Loader APIs~processDataTypeDiscriminator(db, packageId, zclDataTypes) ⇒ +Processes Data Type Discriminator. -| Param | Type | -| ----- | --------------- | -| a | \* | -| b | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclDataTypes | \* | -### REST API: various zcl utilities~commandComparator(a, b) ⇒ + -Comparator for sorting commands. +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ +Prepare Data Types for database table insertion. -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: -1, 0 or 1 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| ----- | --------------- | -| a | \* | -| b | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | - + -### REST API: various zcl utilities~eventComparator(a, b) ⇒ +### Loader API: Loader APIs~processDataType(db, filePath, packageId, data, dataType) ⇒ +Processes Data Type. -Comparator for sorting events. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: -1, 0 or 1 +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | +| dataType | \* | -| Param | Type | -| ----- | --------------- | -| a | \* | -| b | \* | + - +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ +Prepare numbers for database table insertion. -### REST API: various zcl utilities~sortStructsByDependency(structs) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -This method retrieves a bunch of structs sorted -alphabetically. It's expected to resort the structs into a list -where they are sorted in a way where dependency is observed. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -It uses the DFS-based topological sort algorithm. + -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: sorted structs according to topological search. +### Loader API: Loader APIs~processNumber(db, filePath, packageId, data) ⇒ +Processes Numbers. -| Param | Type | -| ------- | --------------- | -| structs | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -### REST API: various zcl utilities~calculateBytes(res, options, db, packageIds, isStructType) + -This function calculates the number of bytes in the data type and based on -that returns the option specified in the template. -for eg: Given that options are as follows: -options.hash.array="b" -options.hash.one_byte="u" -options.hash.two_byte="v" -options.hash.three_byte="x" -options.hash.four_byte="w" -options.hash.short_string="s" -options.hash.long_string="l" -options.hash.default="b" +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ +Prepare strings for database table insertion. -calculateBytes("char_string", options) -will return 's' +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -| Param | Type | -| ------------ | --------------- | -| res | \* | -| options | \* | -| db | \* | -| packageIds | \* | -| isStructType | \* | + - +### Loader API: Loader APIs~processString(db, filePath, packageId, data) ⇒ +Processes Strings. -### REST API: various zcl utilities~optionsHashOrDefault(options, optionsKey, defaultValue) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Description | -| ------------ | --------------------------------------------------------------------------------- | -| options | | -| optionsKey | | -| defaultValue | Given the values determine to give the user defined value or the calculated value | + - +### Loader API: Loader APIs~prepareEnumsOrBitmaps(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -### REST API: various zcl utilities~dataTypeCharacterFormatter(db, packageIds, type, options, resType) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -| Param | Type | Description | -| ---------- | --------------- | ------------------------------------------ | -| db | \* | | -| packageIds | \* | | -| type | \* | | -| options | \* | | -| resType | \* | Character associated to a zcl/c data type. | + - +### Loader API: Loader APIs~processEnums(db, filePath, packageId, data) ⇒ +Processes the enums. -### REST API: various zcl utilities~isEnum(db, enum_name, packageIds) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -Local function that checks if an enum by the name exists +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: Promise of content. + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| enum_name | \* | -| packageIds | \* | +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, data) ⇒ +Processes the enum Items. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. -### REST API: various zcl utilities~isStruct(db, struct_name, packageIds) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Local function that checks if a struct by the name exists + -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: Promise of content. +### Loader API: Loader APIs~processBitmaps(db, filePath, packageId, data) ⇒ +Processes the bitmaps. -| Param | Type | -| ----------- | --------------- | -| db | \* | -| struct_name | \* | -| packageIds | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -### REST API: various zcl utilities~isEvent(db, event_name, packageId) ⇒ + -Function that checks if a given thing is an avent. +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, data) ⇒ +Processes the bitmap fields. -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: Promise of content. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| event_name | \* | -| packageId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - + -### REST API: various zcl utilities~isBitmap(db, bitmap_name, packageIds) ⇒ +### Loader API: Loader APIs~prepareStruct2(a, dataType) ⇒ +Prepare structs for database table insertion. -Local function that checks if a bitmap by the name exists +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: Promise of content. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -| Param | Type | -| ----------- | --------------- | -| db | \* | -| bitmap_name | \* | -| packageIds | \* | + - +### Loader API: Loader APIs~processStruct(db, filePath, packageId, data) ⇒ +Processes the structs. -### REST API: various zcl utilities~defaultMessageForTypeConversion(fromType, toType, noWarning) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | Description | -| --------- | --------------- | --------------------------------------------------------------------------------------------- | -| fromType | \* | | -| toType | \* | | -| noWarning | \* | Type warning message. If noWarning is set to true then the warning message will not be shown. | + - +### Loader API: Loader APIs~processStructItems(db, filePath, packageId, data) ⇒ +Processes the struct Items. -### REST API: various zcl utilities~dataTypeHelper(type, options, packageIds, db, resolvedType, overridable) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: the data type associated with the resolvedType +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | -| ------------ | --------------- | -| type | \* | -| options | \* | -| packageIds | \* | -| db | \* | -| resolvedType | \* | -| overridable | \* | + - +### Loader API: Loader APIs~prepareEnumsOrBitmapsAtomic(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -### REST API: various zcl utilities~asUnderlyingZclTypeWithPackageId(type, options, packageIds, currentInstance) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -| Param | Description | -| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| type | | -| options | | -| packageIds | | -| currentInstance | Note: If the options has zclCharFormatter set to true then the function will return the user defined data associated with the zcl data type and not the actual data type. It can also be used to calculate the size of the data types This is a utility function which is called from other helper functions using ut current instance. See comments in asUnderlyingZclType for usage instructions. | + - +### Loader API: Loader APIs~processEnumsFromAtomics(db, filePath, packageId, data) ⇒ +Processes the enums. -### REST API: various zcl utilities~determineType(db, type, packageIds) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -Returns a promise that resolves into an object containing: -type: -atomicType: -Base type for struct is a null. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) + -| Param | Type | -| ---------- | --------------- | -| db | \* | -| type | \* | -| packageIds | \* | +### Loader API: Loader APIs~processBitmapsFromAtomics(db, filePath, packageId, data) ⇒ +Processes the bitmaps. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -### REST API: various zcl utilities~zcl_data_type_size_and_sign(type, dataType, clusterId, packageIds, context) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: inner method of [REST API: various zcl utilities](#module*REST API* various zcl utilities) -**Returns**: The size and sign of a zcl data type + -| Param | Type | -| ---------- | --------------- | -| type | \* | -| dataType | \* | -| clusterId | \* | -| packageIds | \* | -| context | \* | +### Loader API: Loader APIs~loadZclData(db, ctx) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -## renderer_api +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~loadIndividualDotDotFile(db, filePath) ⇒ \* +TODO This is not supported at this time. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: \* - object w/ following: { packageId: pkgId } or { err: err } -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | -**Kind**: global variable - + -## GLOBAL_SYMBOL_INFO +### Loader API: Loader APIs~loadToplevelXmlFile(db, ctx) ⇒ +Toplevel function that loads the xml library file +and orchestrates the promise chain. -Global symbol that carries the API info metadata +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. -**Kind**: global variable - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | Context of loading. | -## GLOBAL_SYMBOL_EXECUTE + -Global function that can execute the APIs. +### Loader API: Loader APIs~parseNewXmlFiles(db, packageId, files, context) ⇒ +Parses the new XML files. Returns an object containing +loaded data: + clusterIdsLoaded: array of cluster ids that were loaded -**Kind**: global variable - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the new XML data is loaded. -## GLOBAL_SYMBOL_NOTIFY +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | +| context | \* | -Global function that can be overloaded by jxbrowser for notifications + -**Kind**: global variable - +### Loader API: Loader APIs~prepXmlFeature(f) ⇒ +Prepare features from xml. -## ASYNC_DEFAULT_TIMER_INTERVAL_MS +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature information -This module provides the APIs for initializing timers specifically -for sessions. +| Param | Type | +| --- | --- | +| f | \* | -**Kind**: global variable - + -## watchDogId +### Loader API: Loader APIs~prepXmlAttribute(a) ⇒ +Prepare attributes from xml. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: attribute information -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| a | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~prepXmlCommand(c) ⇒ +Prepare commands from xml. -**Kind**: global variable - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: command information -## uri +| Param | Type | +| --- | --- | +| c | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~prepXmlEvent(e) ⇒ +Prepare events from xml - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: event information -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| e | \* | -**Kind**: global constant - + -## env +### Loader API: Loader APIs~parseSingleNewXmlFile(f) ⇒ +Parse xml file. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: xml information from file -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| f | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~collectDataFromJsonFile(ctx) ⇒ +Promises to read the JSON file and resolve all the data. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved file. -## dbApi +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context containing information about the file | -This module provides queries for discriminators + -**Kind**: global constant - +### Loader API: Loader APIs~collectDataFromPropertiesFile(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. -## dbApi +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. -This module provides queries for data types +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the propertiesFiles and data | -**Kind**: global constant - + -## dbApi +### Loader API: Loader APIs~maskToType(mask) ⇒ +Silabs XML does not carry types with bitmap fields, but dotdot does, so they are in the schema. +Just to put some data in, we differentiate between "bool" and "enum" types here. -This module provides queries for numbers +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: bool or corresponding enum -**Kind**: global constant - +| Param | Type | +| --- | --- | +| mask | \* | -## dbApi + -This module provides queries for strings +### Loader API: Loader APIs~prepareAtomic(a) +Prepare atomic to db insertion. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## queryAccess +| Param | Type | +| --- | --- | +| a | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processAtomics(db, filePath, packageId, data) ⇒ +Processes atomic types for DB insertion. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted bitmaps -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global constant - + -## queryAttribute +### Loader API: Loader APIs~prepareClusterGlobalAttribute(cluster) ⇒ +Prepares global attribute data. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing the data from XML. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| cluster | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~extractAccessTag(ac) ⇒ +Extract access information -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: access tag information -## queryZcl +| Param | Type | +| --- | --- | +| ac | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~extractAccessIntoArray(xmlElement) ⇒ +Extract list of access information - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of access information -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| xmlElement | \* | -**Kind**: global constant - + -## queryCommand +### Loader API: Loader APIs~prepareCluster(cluster) ⇒ +Prepare XML cluster for insertion into the database. +This method can also prepare clusterExtensions. -Copyright (c) 2021 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| cluster | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~processClusters(db, filePath, packageId, data) ⇒ +Process clusters for insertion into the database. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of cluster insertion. -## cHelper +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processClusterGlobalAttributes(db, filePath, packageId, data) ⇒ +Processes global attributes for insertion into the database. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted data. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global constant - + -## futureKey +### Loader API: Loader APIs~processClusterExtensions(db, filePath, packageId, data) ⇒ +Cluster Extension contains attributes and commands in a same way as regular cluster, +and it has an attribute code="0xXYZ" where code is a cluster code. -Copyright (c) 2021 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the clusterExtension tags -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~processGlobals(db, filePath, packageId, data) ⇒ +Processes the globals in the XML files. The `global` tag contains +attributes and commands in a same way as cluster or clusterExtension -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the globals -## dbEnum +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~prepareTag(tag) ⇒ +Prepare tag object from tag - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: tag information -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| tag | \* | -**Kind**: global constant - + -## templateUtil +### Loader API: Loader APIs~processDefaultAccess(db, filePath, packageId, defaultAccessList) +Process defaultAccess tag in the XML. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| defaultAccessList | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~processAccessControl(db, filePath, packageId, accessControlList) +Process accessControl tag in the XML. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## templateUtil +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| accessControlList | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processTags(db, filePath, packageId, tags) +Processes the tags in the XML. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| tags | \* | -**Kind**: global constant - + -## queryZcl +### Loader API: Loader APIs~prepareDomain(domain) ⇒ +Convert domain from XMl to domain for DB. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Domain object for DB. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| domain | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~processDomains(db, filePath, packageId, data) ⇒ +Process domains for insertion. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of database insertion of domains. -## queryZcl +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ +Prepare Data Type Discriminator for database table insertion. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| a | \* | -**Kind**: global constant - + -## dbEnums +### Loader API: Loader APIs~processDataTypeDiscriminator(db, filePath, zclDataTypes) ⇒ +Processes Data Type Discriminator. -Copyright (c) 2023 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| zclDataTypes | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ +Prepare Data Types for database table insertion. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -## queryPackage +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processDataType(db, filePath, packageId, knownPackages, data, dataType) ⇒ +Processes Data Type. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | +| dataType | \* | -**Kind**: global constant - + -## \_ +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ +Prepare numbers for database table insertion. -Copyright (c) 2023 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~processNumber(db, filePath, packageId, knownPackages, data) ⇒ +Processes Numbers. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. -## path +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ +Prepare strings for database table insertion. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -**Kind**: global constant - + -## fs +### Loader API: Loader APIs~processString(db, filePath, packageId, knownPackages, data) ⇒ +Processes Strings. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~prepareEnumOrBitmapAtomic(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -## fs +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processEnumAtomic(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enums. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -**Kind**: global constant - + -## dbApi +### Loader API: Loader APIs~prepareEnumOrBitmap(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~processEnum(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enums. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -## dbApi +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enum Items. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -**Kind**: global constant - + -## ipc +### Loader API: Loader APIs~processBitmapAtomic(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmaps. -Copyright (c) 2020 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~processBitmap(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmaps. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -## rendApi +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmap fields. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -**Kind**: global constant - + -## env +### Loader API: Loader APIs~prepareStruct(a, dataType) ⇒ +Prepare structs for database table insertion. -This file is used specifically and only for development. It installs -`electron-debug` & `vue-devtools`. There shouldn't be any need to -modify this file, but it can be used to extend your development -environment. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: global constant - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## yargs + -Copyright (c) 2020 Silicon Labs +### Loader API: Loader APIs~processStruct(db, filePath, packageId, knownPackages, data) ⇒ +Processes the structs. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. - http://www.apache.org/licenses/LICENSE-2.0 +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + -**Kind**: global constant - +### Loader API: Loader APIs~processStructItems(db, filePath, packageIds, data) ⇒ +Processes the struct Items. -## path +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. -Copyright (c) 2020 Silicon Labs +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageIds | \* | +| data | \* | -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + - http://www.apache.org/licenses/LICENSE-2.0 +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ Object +Prepares a device type object by extracting and transforming its properties. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +This function takes a device type object and processes its properties to create +a new object with a specific structure. It handles various properties such as +device ID, profile ID, domain, name, description, class, scope, and superset. +Additionally, it processes endpoint compositions and clusters if they exist. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object - The prepared device type object with transformed properties. -## queryZcl +| Param | Type | Description | +| --- | --- | --- | +| deviceType | Object | The device type object to be prepared. | -Copyright (c) 2024 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~processDeviceTypes(db, filePath, packageId, data, context) ⇒ Promise +Processes and inserts device types into the database. +This function logs the number of device types being processed for debugging purposes. +It maps over the provided data to prepare each device type and then iterates over each prepared device type. +If a device type has a compositionType, it inserts the endpoint composition into the database, +retrieves the endpoint composition ID, and then inserts the device composition. +Finally, it inserts all prepared device types into the database. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise - A promise that resolves after all device types have been inserted into the database. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| filePath | string | The file path from which the device types are being processed. | +| packageId | \* | The package ID associated with the device types. | +| data | Array | The array of device types to be processed. | +| context | \* | Additional context that might be required for processing. | -**Kind**: global constant - + -## path +### Loader API: Loader APIs~processParsedZclData(db, argument) ⇒ +After XML parser is done with the barebones parsing, this function +branches the individual toplevel tags. -Copyright (c) 2024 Silicon Labs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise that resolves when all the subtags are parsed. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +| Param | Type | +| --- | --- | +| db | \* | +| argument | \* | - http://www.apache.org/licenses/LICENSE-2.0 + -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +### Loader API: Loader APIs~parseSingleZclFile(db, packageId, file) ⇒ +This function is used for parsing each individual ZCL file at a grouped zcl file package level. +This should _not_ be used for custom XML addition due to custom xmls potentially relying on existing packges. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise for when the last stage of the loading pipeline finishes. -## templateUtil +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| file | \* | -This module provides API to access various iterator utilities that can then -be used to build iterator helpers. + -**Kind**: global constant - +### Loader API: Loader APIs~isCrcMismatchOrPackageDoesNotExist(db, packageId, files) ⇒ +Checks if there is a crc mismatch on any xml file. This can be used to +decide if there is a need to reload all the xml files. Also check if the +package is not loaded before. -## path +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: the status of crc mismatch and whether a package is present in an +object -Copyright (c) 2021 Silicon Labs +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + - http://www.apache.org/licenses/LICENSE-2.0 +### Loader API: Loader APIs~parseZclFiles(db, packageId, zclFiles, context) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -**Kind**: global constant - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclFiles | \* | +| context | \* | -## fs + -Copyright (c) 2022 Silicon Labs +### Loader API: Loader APIs~parseManufacturerData(db, ctx) ⇒ +Parses the manufacturers xml. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed manufacturers file. - http://www.apache.org/licenses/LICENSE-2.0 +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + -**Kind**: global constant - +### Loader API: Loader APIs~parseProfilesData(db, ctx) ⇒ +Parses the profiles xml. -## path +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed profiles file. -Copyright (c) 2023 Silicon Labs +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + - http://www.apache.org/licenses/LICENSE-2.0 +### Loader API: Loader APIs~parseFeatureFlags(db, packageId, featureFlags) ⇒ +Inside the `zcl.json` can be a `featureFlags` key, which is +a general purpose object. It contains keys, that map to objects. +Each key is a "package option category". +Key/velues of the object itself, end up in CODE/LABEL combinations. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of feature flags + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | + + + +### Loader API: Loader APIs~parseFeatureConformance(operand) ⇒ +Parses feature conformance or an operand in feature conformance recursively from xml data. + +An example of parsing the conformance of 'User' device type feature: + +Input operand from xml data: +{ + "$": {"code": "USR", "name": "User"}, + "mandatoryConform": [ + { "andTerm": [ + { + "condition": [{"$": {"name": "Matter"}}], + "orTerm": [ + { "feature": [ + { "$": {"name": "PIN"}}, + { "$": {"name": "RID"}}, + { "$": {"name": "FPG"}}, + { "$": {"name": "FACE"}} + ] + } + ] + } + ] + } + ] +} + +Output device type feature conformance string: + "Matter & (PIN | RID | FPG | FACE)" + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: The feature conformance string. + +| Param | Type | Description | +| --- | --- | --- | +| operand | \* | The operand to be parsed. | + + + +### Loader API: Loader APIs~parseAndOrConformanceTerms(operand, joinChar) ⇒ +Helper function to parse andTerm or orTerm from xml data + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature conformance string + +| Param | Type | +| --- | --- | +| operand | \* | +| joinChar | \* | + + + +### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒ +Inside the `zcl.json` can be a `featureFlags` key, which is +a general purpose object. It contains keys, that map to objects. +Each key is a "package option category". +Key/velues of the object itself, end up in CODE/LABEL combinations. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that loads the uiOptions object into the database. -## queryZcl +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~parseOptions(db) ⇒ +Parses and loads the text and boolean options. - http://www.apache.org/licenses/LICENSE-2.0 +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise of parsed options -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +| Param | Type | +| --- | --- | +| db | \* | -**Kind**: global constant - + -## queryPackage +### Loader API: Loader APIs~parseTextOptions(db, pkgRef, textOptions) ⇒ +Parses the text options. -This module provides the APIs for validating inputs to the database, and returning flags indicating if -things were successful or not. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed text options. -**Kind**: global constant - +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textOptions | \* | -## queryZcl + -This module provides the APIs for validating inputs to the database, and returning flags indicating if -things were successful or not. +### Loader API: Loader APIs~parseBoolOptions(db, pkgRef, booleanCategories) ⇒ +Parses the boolean options. -**Kind**: global constant - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed boolean options. -## fs +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | -Copyright (c) 2020 Silicon Labs + -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +### Loader API: Loader APIs~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes) ⇒ Promise.<void> +Asynchronously parses and inserts attribute access interface attributes into the database. +This function iterates over the attributeAccessInterfaceAttributes object, processing each cluster +by mapping its values to a specific structure and then inserting them into the database using +the insertOptionsKeyValues function. - http://www.apache.org/licenses/LICENSE-2.0 +The main purpose of this function is to store cluster/attribute pairs including global attributes and their cluster pair +The ATTRIBUTE table has cluster_ref as null for global attributes so this second method was necessary -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise.<void> - A promise that resolves when all attributes have been processed and inserted. -**Kind**: global constant - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| pkgRef | \* | The package reference id for which the attributes are being parsed. | +| attributeAccessInterfaceAttributes | \* | An object containing the attribute access interface attributes, structured by cluster. | -## \_ + -Copyright (c) 2023 Silicon Labs +### Loader API: Loader APIs~parseDefaults(db, ctx) ⇒ +Parses the default values inside the options. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promised of parsed text and bool defaults. - http://www.apache.org/licenses/LICENSE-2.0 +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + -**Kind**: global constant - +### Loader API: Loader APIs~parseTextDefaults(db, pkgRef, textDefaults) ⇒ +Parse text defaults from default options. -## fs +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of promises -Copyright (c) 2020 Silicon Labs +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textDefaults | \* | -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + - http://www.apache.org/licenses/LICENSE-2.0 +### Loader API: Loader APIs~parseBoolDefaults(db, pkgRef, booleanCategories) ⇒ +Parse the boolean defaults inside options. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: List of promises -**Kind**: global constant - +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | -## fs + -Copyright (c) 2020 Silicon Labs +### Loader API: Loader APIs~loadIndividualSilabsFile(db, filePath) ⇒ +Parses a single file. This function is used specifically +for adding a package through an existing session because of its reliance +on relating the new XML content to the packages associated with that session. +e.g. for ClusterExtensions. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a loaded file. - http://www.apache.org/licenses/LICENSE-2.0 +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + -**Kind**: global constant - +### Loader API: Loader APIs~processCustomZclDeviceType(db, ctx) ⇒ +If custom device is supported, then this method creates it. -## initAndConnectClient() ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: context -Initializes and connects a client. +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -**Kind**: global function -**Returns**: a promise which resolves when client connects - + -## on(eventType, handler) +### Loader API: Loader APIs~loadZclJson(db, metafile) ⇒ +Load ZCL metadata -Register a handler for the event type. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl json file -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | -| Param | Type | -| --------- | --------------- | -| eventType | \* | -| handler | \* | + - +### Loader API: Loader APIs~loadZclProperties(db, metafile) ⇒ +Load ZCL metadata -## lastPongData() ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl properties file -Get the last pong data. +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | -**Kind**: global function -**Returns**: last pong data or null if none is available - + -## isClientConnected() ⇒ +### Loader API: Loader APIs~loadZclJsonOrProperties(db, ctx) ⇒ +Toplevel function that loads the toplevel metafile +and orchestrates the promise chain. -Returns true if client is connected. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. -**Kind**: global function -**Returns**: true if client is connected - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | The context of loading. | -## disconnectClient() + -Disconnects a client asynchronously. +### Loader API: Loader APIs~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync) ⇒ +Records the toplevel package information and resolves into packageId -**Kind**: global function - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: packageId -## emit(key, object) +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| crc | \* | +| isTopLevelPackageInSync | \* | -Sends a message to server. + -**Kind**: global function +### Loader API: Loader APIs~recordVersion(db, ctx) +Records the version into the database. -| Param | Type | -| ------ | --------------- | -| key | \* | -| object | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## selectAllDiscriminators(db, packageIds) ⇒ + -**Kind**: global function -**Returns**: all the data type discriminator information +### Loader API: Loader APIs~loadZclMetaFilesCommon(db, metadataFile, options) ⇒ +Retrieve zcl package information -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: package zcl package information - +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| options | \* | -## selectDataTypeById(db, id) ⇒ + -Gathers the data type information of an entry based on data type id along -with its actual type from disciminator table. +### Loader API: Loader APIs~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap) +Load attribute mapping table if there is multi-protocol information from a json file. -**Kind**: global function -**Returns**: Data type information +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -| Param | -| ----- | -| db | -| id | +| Param | Type | +| --- | --- | +| db | \* | +| multiProtcolInfo | \* | +| categoryToPackageIdMap | \* | - + -## selectDataTypeByName(db, name, packageIds) ⇒ +### Loader API: Loader APIs~loadZclMetafiles(db, metadataFile) ⇒ +Toplevel function that loads the zcl file and passes it off to the correct zcl loader. -Gathers the data type information of an entry based on data type name along -with its actual type from disciminator table. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of loaded packageIds. -**Kind**: global function -**Returns**: Data type information +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| metadataFile | \* | array of paths | -| Param | -| ---------- | -| db | -| name | -| packageIds | + - +### Loader API: Loader APIs~loadZcl(db, metadataFile) ⇒ +Loads individual zcl.json metafile. -## selectDataTypeByNameAndClusterId(db, name, clusterId, packageIds) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Context object that contains .db and .packageId -Gathers the data type information based on data type name and -clusterId along with its actual type from disciminator table. +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | -**Kind**: global function -**Returns**: Data type information + -| Param | -| ---------- | -| db | -| name | -| clusterId | -| packageIds | +### Loader API: Loader APIs~loadIndividualFile(db, filePath, sessionId) +Load individual custom XML files. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## selectAllDataTypes(db, packageId) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| filePath | \* | | +| sessionId | \* | Current session within which we're loading this file. | -Gathers All the data types + -**Kind**: global function -**Returns**: All data types +### Loader API: Loader APIs~qualifyZclFile(db, info, parentPackageId, isCustom) ⇒ +Promises to qualify whether zcl file needs to be reloaded. +If yes, the it will resolve with {filePath, data, packageId} +If not, then it will resolve with {error} -| Param | -| --------- | -| db | -| packageId | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves int he object of data. - +| Param | Type | +| --- | --- | +| db | \* | +| info | \* | +| parentPackageId | \* | +| isCustom | \* | -## selectSizeFromType(db, packageIds, value) ⇒ + -Return the size of the given value whether it be a reference to it in the data -type table in the form of a number or be it the name of the type in the form -if string. +### Loader API: Loader APIs~processZclPostLoading(db) ⇒ +Promises to perform a post loading step. -**Kind**: global function -**Returns**: The size of the given value +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise to deal with the post-loading cleanup. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### Loader API: Loader APIs~getDiscriminatorMap(db, packageIds) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: data type discriminator map + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +## Loader API: Loader APIs +This module provides the APIs for new data model loading + + +* [Loader API: Loader APIs](#module_Loader API_ Loader APIs) + * [~collectDataFromLibraryXml(ctx)](#module_Loader API_ Loader APIs..collectDataFromLibraryXml) ⇒ + * [~tagContainsEnum(tag)](#module_Loader API_ Loader APIs..tagContainsEnum) ⇒ + * [~tagContainsStruct(tag)](#module_Loader API_ Loader APIs..tagContainsStruct) ⇒ + * [~tagContainsBitmap(tag)](#module_Loader API_ Loader APIs..tagContainsBitmap) ⇒ + * [~parseSingleZclFile(db, ctx, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~parseZclFiles(db, ctx)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~normalizeHexValue(value)](#module_Loader API_ Loader APIs..normalizeHexValue) ⇒ + * [~getNumBytesFromShortName(value)](#module_Loader API_ Loader APIs..getNumBytesFromShortName) ⇒ + * [~prepareAttributes(attributes, side)](#module_Loader API_ Loader APIs..prepareAttributes) ⇒ + * [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒ + * [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒ + * [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒ + * [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒ + * [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~prepareTypes(zclTypes, types)](#module_Loader API_ Loader APIs..prepareTypes) + * [~prepareAttributeType(attribute, types, cluster)](#module_Loader API_ Loader APIs..prepareAttributeType) + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, packageId, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumsOrBitmaps(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmaps) ⇒ + * [~processEnums(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnums) ⇒ + * [~processEnumItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmaps(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmaps) ⇒ + * [~processBitmapFields(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct2(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct2) ⇒ + * [~processStruct(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareEnumsOrBitmapsAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmapsAtomic) ⇒ + * [~processEnumsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumsFromAtomics) ⇒ + * [~processBitmapsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapsFromAtomics) ⇒ + * [~loadZclData(db, ctx)](#module_Loader API_ Loader APIs..loadZclData) ⇒ + * [~loadIndividualDotDotFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualDotDotFile) ⇒ \* + * [~loadToplevelXmlFile(db, ctx)](#module_Loader API_ Loader APIs..loadToplevelXmlFile) ⇒ + * [~parseNewXmlFiles(db, packageId, files, context)](#module_Loader API_ Loader APIs..parseNewXmlFiles) ⇒ + * [~prepXmlFeature(f)](#module_Loader API_ Loader APIs..prepXmlFeature) ⇒ + * [~prepXmlAttribute(a)](#module_Loader API_ Loader APIs..prepXmlAttribute) ⇒ + * [~prepXmlCommand(c)](#module_Loader API_ Loader APIs..prepXmlCommand) ⇒ + * [~prepXmlEvent(e)](#module_Loader API_ Loader APIs..prepXmlEvent) ⇒ + * [~parseSingleNewXmlFile(f)](#module_Loader API_ Loader APIs..parseSingleNewXmlFile) ⇒ + * [~collectDataFromJsonFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromJsonFile) ⇒ + * [~collectDataFromPropertiesFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromPropertiesFile) ⇒ + * [~maskToType(mask)](#module_Loader API_ Loader APIs..maskToType) ⇒ + * [~prepareAtomic(a)](#module_Loader API_ Loader APIs..prepareAtomic) + * [~processAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processAtomics) ⇒ + * [~prepareClusterGlobalAttribute(cluster)](#module_Loader API_ Loader APIs..prepareClusterGlobalAttribute) ⇒ + * [~extractAccessTag(ac)](#module_Loader API_ Loader APIs..extractAccessTag) ⇒ + * [~extractAccessIntoArray(xmlElement)](#module_Loader API_ Loader APIs..extractAccessIntoArray) ⇒ + * [~prepareCluster(cluster)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~processClusters(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusters) ⇒ + * [~processClusterGlobalAttributes(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterGlobalAttributes) ⇒ + * [~processClusterExtensions(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterExtensions) ⇒ + * [~processGlobals(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processGlobals) ⇒ + * [~prepareTag(tag)](#module_Loader API_ Loader APIs..prepareTag) ⇒ + * [~processDefaultAccess(db, filePath, packageId, defaultAccessList)](#module_Loader API_ Loader APIs..processDefaultAccess) + * [~processAccessControl(db, filePath, packageId, accessControlList)](#module_Loader API_ Loader APIs..processAccessControl) + * [~processTags(db, filePath, packageId, tags)](#module_Loader API_ Loader APIs..processTags) + * [~prepareDomain(domain)](#module_Loader API_ Loader APIs..prepareDomain) ⇒ + * [~processDomains(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processDomains) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, filePath, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, knownPackages, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumOrBitmapAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmapAtomic) ⇒ + * [~processEnumAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumAtomic) ⇒ + * [~prepareEnumOrBitmap(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmap) ⇒ + * [~processEnum(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnum) ⇒ + * [~processEnumItems(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmapAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapAtomic) ⇒ + * [~processBitmap(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmap) ⇒ + * [~processBitmapFields(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~processStruct(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageIds, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ Object + * [~processDeviceTypes(db, filePath, packageId, data, context)](#module_Loader API_ Loader APIs..processDeviceTypes) ⇒ Promise + * [~processParsedZclData(db, argument)](#module_Loader API_ Loader APIs..processParsedZclData) ⇒ + * [~parseSingleZclFile(db, packageId, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~isCrcMismatchOrPackageDoesNotExist(db, packageId, files)](#module_Loader API_ Loader APIs..isCrcMismatchOrPackageDoesNotExist) ⇒ + * [~parseZclFiles(db, packageId, zclFiles, context)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~parseManufacturerData(db, ctx)](#module_Loader API_ Loader APIs..parseManufacturerData) ⇒ + * [~parseProfilesData(db, ctx)](#module_Loader API_ Loader APIs..parseProfilesData) ⇒ + * [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒ + * [~parseFeatureConformance(operand)](#module_Loader API_ Loader APIs..parseFeatureConformance) ⇒ + * [~parseAndOrConformanceTerms(operand, joinChar)](#module_Loader API_ Loader APIs..parseAndOrConformanceTerms) ⇒ + * [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒ + * [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒ + * [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒ + * [~parseBoolOptions(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolOptions) ⇒ + * [~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes)](#module_Loader API_ Loader APIs..parseattributeAccessInterfaceAttributes) ⇒ Promise.<void> + * [~parseDefaults(db, ctx)](#module_Loader API_ Loader APIs..parseDefaults) ⇒ + * [~parseTextDefaults(db, pkgRef, textDefaults)](#module_Loader API_ Loader APIs..parseTextDefaults) ⇒ + * [~parseBoolDefaults(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolDefaults) ⇒ + * [~loadIndividualSilabsFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualSilabsFile) ⇒ + * [~processCustomZclDeviceType(db, ctx)](#module_Loader API_ Loader APIs..processCustomZclDeviceType) ⇒ + * [~loadZclJson(db, metafile)](#module_Loader API_ Loader APIs..loadZclJson) ⇒ + * [~loadZclProperties(db, metafile)](#module_Loader API_ Loader APIs..loadZclProperties) ⇒ + * [~loadZclJsonOrProperties(db, ctx)](#module_Loader API_ Loader APIs..loadZclJsonOrProperties) ⇒ + * [~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync)](#module_Loader API_ Loader APIs..recordToplevelPackage) ⇒ + * [~recordVersion(db, ctx)](#module_Loader API_ Loader APIs..recordVersion) + * [~loadZclMetaFilesCommon(db, metadataFile, options)](#module_Loader API_ Loader APIs..loadZclMetaFilesCommon) ⇒ + * [~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap)](#module_Loader API_ Loader APIs..loadAttributeMappingForMultiProtocol) + * [~loadZclMetafiles(db, metadataFile)](#module_Loader API_ Loader APIs..loadZclMetafiles) ⇒ + * [~loadZcl(db, metadataFile)](#module_Loader API_ Loader APIs..loadZcl) ⇒ + * [~loadIndividualFile(db, filePath, sessionId)](#module_Loader API_ Loader APIs..loadIndividualFile) + * [~qualifyZclFile(db, info, parentPackageId, isCustom)](#module_Loader API_ Loader APIs..qualifyZclFile) ⇒ + * [~processZclPostLoading(db)](#module_Loader API_ Loader APIs..processZclPostLoading) ⇒ + * [~getDiscriminatorMap(db, packageIds)](#module_Loader API_ Loader APIs..getDiscriminatorMap) ⇒ + + + +### Loader API: Loader APIs~collectDataFromLibraryXml(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | -| value | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. - +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the metadataFiles and data | -## selectNumberByName(db, name, packageIds) ⇒ + -Select an number matched by name. +### Loader API: Loader APIs~tagContainsEnum(tag) ⇒ +Check if tag contains enum. -**Kind**: global function -**Returns**: number or undefined +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -| Param | -| ---------- | -| db | -| name | -| packageIds | +| Param | Type | +| --- | --- | +| tag | \* | - + -## selectNumberByNameAndClusterId(db, name, packageIds) ⇒ +### Loader API: Loader APIs~tagContainsStruct(tag) ⇒ +Check if tag contains struct. -Select a number matched by name and clusterId +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -**Kind**: global function -**Returns**: number information or undefined +| Param | Type | +| --- | --- | +| tag | \* | -| Param | -| ---------- | -| db | -| name | -| packageIds | + - +### Loader API: Loader APIs~tagContainsBitmap(tag) ⇒ +Check if tag contains Bitmap. -## selectNumberById(db, name) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -Select an number matched by id. +| Param | Type | +| --- | --- | +| tag | \* | -**Kind**: global function -**Returns**: number or undefined + -| Param | -| ----- | -| db | -| name | +### Loader API: Loader APIs~parseSingleZclFile(db, ctx, file) ⇒ +Parses ZCL xml file. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: empty array -## selectAllNumbers(db, packageId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | +| file | \* | -Select all numbers. + -**Kind**: global function -**Returns**: All numbers +### Loader API: Loader APIs~parseZclFiles(db, ctx) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -| Param | -| --------- | -| db | -| packageId | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## selectAllStrings(db, packageId) ⇒ + -Select all Strings. +### Loader API: Loader APIs~normalizeHexValue(value) ⇒ +The Dotdot ZCL XML doesn't use the 0x prefix, but it's a nice thing to have and Silabs xml +does use this so this helper function normalizes the use of hex -**Kind**: global function -**Returns**: All Strings +TODO: Is this the right thing to do? -| Param | -| --------- | -| db | -| packageId | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Either the normalized hex string (with the 0x prefix) or the original - +| Param | Type | Description | +| --- | --- | --- | +| value | \* | the string value to be normalized | -## selectStringById(db, packageId) ⇒ + -Select String by ID. +### Loader API: Loader APIs~getNumBytesFromShortName(value) ⇒ +The Dotdot ZCL XML doesn't have a length but it is embedded in the short name, +we can scrape the value to get the size -**Kind**: global function -**Returns**: String +TODO: Is this the right thing to do? -| Param | -| --------- | -| db | -| packageId | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: size in bytes or 0 if the # of bytes could not be determined - +| Param | Type | Description | +| --- | --- | --- | +| value | \* | the string value to be scraped | -## selectStringByName(db, name, packageIds) ⇒ + -Select String by name. +### Loader API: Loader APIs~prepareAttributes(attributes, side) ⇒ +Prepare XML attributes for entry into the DB -**Kind**: global function -**Returns**: String +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted into the DB. -| Param | -| ---------- | -| db | -| name | -| packageIds | +| Param | Type | Description | +| --- | --- | --- | +| attributes | \* | an array of attributes | +| side | \* | the side the attribute is on either "client" or "server" | - + -## attributeDefault() ⇒ +### Loader API: Loader APIs~prepareCommands(commands, side, types) ⇒ +Prepare XML commands for entry into the DB -Valid within a cluster context, requires code. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted in to the DB. -**Kind**: global function -**Returns**: Produces attribute defaults. - +| Param | Type | Description | +| --- | --- | --- | +| commands | \* | an array of commands | +| side | \* | the side the command is on either "client" or "server" | +| types | \* | contained for types, where bitmaps are going to be inserted. | -## if_command_arguments_exist(commandId, argument_return, no_argument_return) + -**Kind**: global function +### Loader API: Loader APIs~prepareCluster(cluster, isExtension, types) ⇒ +Prepare XML cluster for insertion into the database. +This method can also prepare clusterExtensions. -| Param | Type | Description | -| ------------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| commandId | \* | | -| argument_return | \* | | -| no_argument_return | \* | If the command arguments for a command exist then returns argument_return else returns no_argument_return Example: {{if_command_arguments_exist [command-id] "," ""}} The above will return ',' if the command arguments for a command exist and will return nothing if the command arguments for a command do not exist. | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. - +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| cluster | \* | | | +| isExtension | \* | false | if this is an extension or not (there are none in dotdot xml) | +| types | \* | | types object into which cluster can put types it might have | -## if_command_args_exist(commandId, options) ⇒ + -If helper which checks if command arguments exist for a command or not -example: -{{#if_command_args_exist commandId}} -command arguments exist for the command -{{else}} -command arguments do not exist for the command -{{/if_command_args_exist}} +### Loader API: Loader APIs~prepareAtomic(type) ⇒ +Parses xml type into the atomic object for insertion into the DB -**Kind**: global function -**Returns**: Returns content in the handlebar template based on whether the -command arguments are present or not. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -| Param | -| --------- | -| commandId | -| options | +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the atomic format in the dotdot xml | - + -## if_ca_always_present_with_presentif(commandArg, trueReturn, falseReturn) ⇒ +### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒ +Parses xml type into the bitmap object for insertion into the DB -**Kind**: global function -**Returns**: trueReturn if command argument is always present and there is a -presentIf condition else returns false +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -| Param | -| ----------- | -| commandArg | -| trueReturn | -| falseReturn | +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| type | \* | | an xml object which conforms to the bitmap format in the dotdot xml | +| isContained | \* | false | a boolean indicating if this is coming from a contained tag or not | - + -## if_command_arg_always_present_with_presentif(commandArg, options) ⇒ +### Loader API: Loader APIs~prepareEnum(type) ⇒ +Parses xml type into the enum object for insertion into the DB -If helper that checks if a command argument is always present with a -presentIf condition. -example: -{{#if_command_arg_always_present_with_presentif commandArg}} -command argument has a presentIf condition -{{else}} -command argument does not have a presentIf condition -{{/if_command_arg_always_present_with_presentif}} +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -**Kind**: global function -**Returns**: Returns content in the handlebar template based on the command -argument having a presentIf condition or not +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the enum format in the dotdot xml | -| Param | -| ---------- | -| commandArg | -| options | + - +### Loader API: Loader APIs~prepareStruct(type) ⇒ +Parses xml type into the struct object for insertion into the DB -## if_command_is_not_fixed_length_but_command_argument_is_always_present(command, commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -**Kind**: global function -**Returns**: trueReturn if command is not fixed length but command argument is -always present else returns falseReturn +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the struct format in the dotdot xml | -| Param | -| ----------- | -| command | -| commandArg | -| trueReturn | -| falseReturn | + - +### Loader API: Loader APIs~prepareTypes(zclTypes, types) +Parses xml types into the types object for insertion into the DB -## if_command_not_fixed_length_command_argument_always_present(command, commandArg, options) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -If helper that checks if command is not fixed lenth and that the command is -always present. -example: -{{#if_command_not_fixed_length_command_argument_always_present commandId}} -command is not fixed length and command argument is always present -{{else}} -either command is fixed length or command argument is not always present -{{/if_command_not_fixed_length_command_argument_always_present}} +| Param | Type | Description | +| --- | --- | --- | +| zclTypes | \* | an array of xml types | +| types | \* | an object which includes arrays for enums, bitmaps etc... | -**Kind**: global function -**Returns**: Returns content in the handlebar template based on the command being -fixed length or not and whether the command argument is always present + -| Param | -| ---------- | -| command | -| commandArg | -| options | +### Loader API: Loader APIs~prepareAttributeType(attribute, types, cluster) +Parses xml types into the types object for insertion into the DB - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## if_ca_not_always_present_no_presentif(commandArg, trueReturn, falseReturn) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| attribute | \* | an attribute with the type in it | +| types | \* | an object which includes arrays for enums, bitmaps etc... | +| cluster | \* | the cluster that the attribute belongs to (used presently for uniqueness of the type name) | -**Kind**: global function -**Returns**: trueReturn if command argument is not always present and there is no -presentIf condition else returns false + -| Param | -| ----------- | -| commandArg | -| trueReturn | -| falseReturn | +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ +Preparation step for the device types. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: an object containing the prepared device types. -## if_command_arg_not_always_present_no_presentif(commandArg, options) ⇒ +| Param | Type | +| --- | --- | +| deviceType | \* | -If helper that checks if a command argument is not always present because it -has a introduced in or removed in clause. The helper also checks that there -is no presentIf condition. -example: -{{#if_command_arg_not_always_present_no_presentif commandArg}} -command argument is not always present and there is no presentIf condition -{{else}} -Either command argument is always present or there is a presentIf condition -{{/if_command_arg_not_always_present_no_presentif}} + -**Kind**: global function -**Returns**: Returns content in the handlebar template based on the command -argument being present and if there is a presentIf condition. +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ +Prepare Data Type Discriminator for database table insertion. -| Param | -| ---------- | -| commandArg | -| options | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | -## if_ca_not_always_present_with_presentif(commandArg, trueReturn, falseReturn) ⇒ + -**Kind**: global function -**Returns**: trueReturn if command argument is not always present and there is a -presentIf condition else returns false +### Loader API: Loader APIs~processDataTypeDiscriminator(db, packageId, zclDataTypes) ⇒ +Processes Data Type Discriminator. -| Param | -| ----------- | -| commandArg | -| trueReturn | -| falseReturn | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclDataTypes | \* | -## if_command_arg_not_always_present_with_presentif(commandArg, options) ⇒ + -If helper that checks if a command argument is not always present because it -has a introduced in or removed in clause. The helper also checks that there -is a presentIf condition. -example: -{{#if_command_arg_not_always_present_with_presentif commandArg}} -command argument is not always present and there is a presentIf condition -{{else}} -Either command argument is always present or there is no presentIf condition -{{/if_command_arg_not_always_present_with_presentif}} +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ +Prepare Data Types for database table insertion. -**Kind**: global function -**Returns**: Returns content in the handlebar template based on the command -argument being present and if there is a presentIf condition. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | -| ---------- | -| commandArg | -| options | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | - + -## if_command_is_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn) +### Loader API: Loader APIs~processDataType(db, filePath, packageId, data, dataType) ⇒ +Processes Data Type. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. -| Param | Description | -| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| commandId | | -| fixedLengthReturn | | -| notFixedLengthReturn | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not. Also checks if the command arguments are always present or not. | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | +| dataType | \* | - + -## if_command_fixed_length(commandId, options) +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ +Prepare numbers for database table insertion. -If helper which checks if a command is fixed length or not +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -example: -{{#if_command_fixed_length commandId}} -command is fixed length -{{else}} -command is not fixed length -{{/if_command_fixed_length}} +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -**Kind**: global function + -| Param | Description | -| --------- | ----------------------------------------------------------------------------------------------------------------------- | -| commandId | | -| options | Returns content in the handlebar template based on the command being fixed length or not as shown in the example above. | +### Loader API: Loader APIs~processNumber(db, filePath, packageId, data) ⇒ +Processes Numbers. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. -## endpoint_type_count(options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Returns number of endpoint types. + -**Kind**: global function -**Returns**: number of endpoint types +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ +Prepare strings for database table insertion. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## endpoint_count(options) ⇒ + -Returns number of endpoints. +### Loader API: Loader APIs~processString(db, filePath, packageId, data) ⇒ +Processes Strings. -**Kind**: global function -**Returns**: number of endpoints +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - + -## endpoint_config_macros() ⇒ +### Loader API: Loader APIs~prepareEnumsOrBitmaps(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -Prints out all the macros that the endpoint config -configuration depends on. These macros are created -by ZAP, because the use of these macros is also -created by ZAP. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: global function -**Returns**: Macros that need to be created - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## endpoint_fixed_endpoint_array(options) ⇒ + -Creates array of endpointId fields on endpoints +### Loader API: Loader APIs~processEnums(db, filePath, packageId, data) ⇒ +Processes the enums. -**Kind**: global function -**Returns**: C array including the brackets +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - + -## endpoint_fixed_profile_id_array(options) ⇒ +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, data) ⇒ +Processes the enum Items. -Creates array of profileId fields on endpoints +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. -**Kind**: global function -**Returns**: C array including the brackets +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### Loader API: Loader APIs~processBitmaps(db, filePath, packageId, data) ⇒ +Processes the bitmaps. -## endpoint_fixed_parent_id_array() ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -Creates Integer Array of parent endpoint identifier fields on endpoints. If the Parent Endpoint is not set then it will default to 0. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global function -**Returns**: C array including the brackets - + -## endpoint_fixed_network_array(options) ⇒ +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, data) ⇒ +Processes the bitmap fields. -Creates array of networkId fields on endpoints +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. -**Kind**: global function -**Returns**: C array including the brackets +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### Loader API: Loader APIs~prepareStruct2(a, dataType) ⇒ +Prepare structs for database table insertion. -## endpoint_fixed_endpoint_type_array(options) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Each element of an array contains an index into the -endpoint type array, for the appropriate endpoint. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -**Kind**: global function -**Returns**: C array of indexes, one for each endpoint. + -| Param | Type | -| ------- | --------------- | -| options | \* | +### Loader API: Loader APIs~processStruct(db, filePath, packageId, data) ⇒ +Processes the structs. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. -## endpoint_attribute_manufacturer_codes(options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Generates array of { index , mfgCode } pairs, matching -the indexes in attribute table. + -**Kind**: global function -**Returns**: manufacturer code array +### Loader API: Loader APIs~processStructItems(db, filePath, packageId, data) ⇒ +Processes the struct Items. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## endpoint_reporting_config_defaults(options) + -This helper supports an "order" CSV string, such as: -"direction,endpoint,clusterId,attributeId,mask,mfgCode,minmax" -The string above is a default value, and it determines in what order are the fields generated. +### Loader API: Loader APIs~prepareEnumsOrBitmapsAtomic(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - + -## collectAttributes() +### Loader API: Loader APIs~processEnumsFromAtomics(db, filePath, packageId, data) ⇒ +Processes the enums. -Attribute collection works like this: -1.) Go over all the clusters that exist. -2.) If client is included on at least one endpoint add client atts. -3.) If server is included on at least one endpoint add server atts. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -**Kind**: global function - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## collectAttributeSizes(db, zclPackageIds, endpointTypes) ⇒ + -This function goes over all the attributes and populates sizes. +### Loader API: Loader APIs~processBitmapsFromAtomics(db, filePath, packageId, data) ⇒ +Processes the bitmaps. -**Kind**: global function -**Returns**: promise that resolves with the passed endpointTypes, after populating the attribute type sizes. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| zclPackageIds | \* | -| endpointTypes | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - + -## collectAttributeTypeInfo(db, zclPackageIds, endpointTypes) ⇒ +### Loader API: Loader APIs~loadZclData(db, ctx) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -This function goes over all attributes and populates atomic types. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -**Kind**: global function -**Returns**: promise that resolves with the passed endpointTypes, after populating the attribute atomic types. +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -| Param | Type | -| ------------- | --------------- | -| db | \* | -| zclPackageIds | \* | -| endpointTypes | \* | + - +### Loader API: Loader APIs~loadIndividualDotDotFile(db, filePath) ⇒ \* +TODO This is not supported at this time. -## endpoint_config(options) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: \* - object w/ following: { packageId: pkgId } or { err: err } -Starts the endpoint configuration block., -longDefaults: longDefaults +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | -**Kind**: global function -**Returns**: a promise of a rendered block + -| Param | Type | -| ------- | --------------- | -| options | \* | +### Loader API: Loader APIs~loadToplevelXmlFile(db, ctx) ⇒ +Toplevel function that loads the xml library file +and orchestrates the promise chain. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. -## ifFuture(options) +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | Context of loading. | -Block helper resolving the block if the -value of the specified future matches. + -**Kind**: global function +### Loader API: Loader APIs~parseNewXmlFiles(db, packageId, files, context) ⇒ +Parses the new XML files. Returns an object containing +loaded data: + clusterIdsLoaded: array of cluster ids that were loaded -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the new XML data is loaded. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | +| context | \* | -## setFuture(options) + -This method sets the value of the future. -Use it as: -{{set_future name="NAME" value="VALUE"}} +### Loader API: Loader APIs~prepXmlFeature(f) ⇒ +Prepare features from xml. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature information -| Param | Type | -| ------- | --------------- | -| options | \* | +| Param | Type | +| --- | --- | +| f | \* | - + -## future(options) +### Loader API: Loader APIs~prepXmlAttribute(a) ⇒ +Prepare attributes from xml. -This method defines the future with a given name. -Use it as: {{future name="NAME"}} +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: attribute information -**Kind**: global function +| Param | Type | +| --- | --- | +| a | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### Loader API: Loader APIs~prepXmlCommand(c) ⇒ +Prepare commands from xml. -## tokens_context() +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: command information -This function builds creates a new context from the endpoint_config structure -for use in the zap-tokens.h template. The endpoint_config context provides a -list of endpoints, and endpointTypes, where each endpointType contains a list -of clusters, and each cluster contains a list of attributes. However, the -tokens template requires a list of attributes per endpoint, and per cluster, -discriminating from singletons and non-singletons, so this function performs -the required grouping. - -While each attribute contains an isSingleton attribute, the database schema -allows for the same attribute to be returned both as singleton and non-singleton -in different clusters, for different endpoints. In consequence, care must be -taken to remove the singletons from the cluster and endpoint attribute lists. -This is done in two steps, the first loop creates a global (context) list of -singletons and non-singletons, and the second loop removes the singletons from -the endpoint, and clusters. - -Clusters from different endpoints may have different attributes, therefore each -endpoint keeps a separate list of clusters. Additionally, a context-level -map of clusters is required in order to gather all attributes (singletons and -non-singletons) from all endpoint clusters. - -**Kind**: global function - - -## token_next() +| Param | Type | +| --- | --- | +| c | \* | -The token template assigns an unique ID to each unique attribute. These IDs -span all attributes from all clusters from all endpointTypes. This helper -function allows the template to increment the token ID within the tokens context. + -**Kind**: global function - +### Loader API: Loader APIs~prepXmlEvent(e) ⇒ +Prepare events from xml -## token_attribute_util(context, options) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: event information -Util function that extracts all the token attribute information. +| Param | Type | +| --- | --- | +| e | \* | -**Kind**: global function -**Returns**: Information on all token attributes in the configuration. + -| Param | Type | -| ------- | --------------- | -| context | \* | -| options | \* | +### Loader API: Loader APIs~parseSingleNewXmlFile(f) ⇒ +Parse xml file. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: xml information from file -## token_attributes(endpointTypeRef, options) ⇒ +| Param | Type | +| --- | --- | +| f | \* | -Get information about all the token attributes in the configuration or this -helper can be used within an endpoint block helper to fetch the -corresponding token attributes based on endpoint type given. -Available Options: -isSingleton: 0/1, option can be used to filter attributes based on singleton -or non-singleton(Available with endpointTypeRef only) + -**Kind**: global function -**Returns**: singleton and non-singleton token attributes along with their -endpoint information. Singleton attributes are only returned once whereas -non-singleton attributes are returned per endpoint. However if used within -an endpoint block helper it returns token_attributes for a given endpoint -type. +### Loader API: Loader APIs~collectDataFromJsonFile(ctx) ⇒ +Promises to read the JSON file and resolve all the data. -| Param | Type | -| --------------- | --------------- | -| endpointTypeRef | \* | -| options | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved file. - +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context containing information about the file | -## token_attribute_clusters(endpointTypeRef, options) ⇒ + -This helper can return all token associated clusters across endpoints or -this helper can be used within an endpoint block helper to fetch the -corresponding token associated clusters. -Available Options: -isSingleton: 0/1, option can be used to filter clusters based on singleton -or non-singleton attributes. +### Loader API: Loader APIs~collectDataFromPropertiesFile(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. -**Kind**: global function -**Returns**: Token associated clusters for a particular endpoint type or all -token associated clusters across endpoints. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. -| Param | Type | -| --------------- | --------------- | -| endpointTypeRef | \* | -| options | \* | +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the propertiesFiles and data | - + -## token_attribute_endpoints(options) ⇒ +### Loader API: Loader APIs~maskToType(mask) ⇒ +Silabs XML does not carry types with bitmap fields, but dotdot does, so they are in the schema. +Just to put some data in, we differentiate between "bool" and "enum" types here. -Get all endpoints which have token attributes in the configuration. -AvailableOptions: +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: bool or corresponding enum -- isSingleton: 0/1, option can be used to filter endpoints based on singleton - or non-singleton. +| Param | Type | +| --- | --- | +| mask | \* | -**Kind**: global function -**Returns**: all endpoints with token attributes + -| Param | Type | -| ------- | --------------- | -| options | \* | +### Loader API: Loader APIs~prepareAtomic(a) +Prepare atomic to db insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## get_cli_size(size, type, allowZclTypes) ⇒ +| Param | Type | +| --- | --- | +| a | \* | -**Kind**: global function -**Returns**: The size in bits for a cli type based on allowZclTypes + -| Param | Type | -| ------------- | --------------- | -| size | \* | -| type | \* | -| allowZclTypes | \* | +### Loader API: Loader APIs~processAtomics(db, filePath, packageId, data) ⇒ +Processes atomic types for DB insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted bitmaps -## zcl_command_argument_type_to_cli_data_type_util(type, cliPrefix, context, options) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global function -**Returns**: the zcl cli data type string with the cli prefix given -Additional Options: + -- isOptional option can be passed along with the command argument - to return optional command argument extension accordingly - eg: - #zcl_command_arguments - zcl_command_argument_type_to_zcl_cli_data_type type isOptional=isOptional - /zcl_command_arguments +### Loader API: Loader APIs~prepareClusterGlobalAttribute(cluster) ⇒ +Prepares global attribute data. -| Param | Type | -| --------- | --------------- | -| type | \* | -| cliPrefix | \* | -| context | \* | -| options | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing the data from XML. - +| Param | Type | +| --- | --- | +| cluster | \* | -## zcl_command_argument_type_to_cli_data_type(typeName, options) + -Helper that deals with the type of the argument. +### Loader API: Loader APIs~extractAccessTag(ac) ⇒ +Extract access information -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: access tag information -| Param | Type | -| -------- | --------------- | -| typeName | \* | -| options | \* | +| Param | Type | +| --- | --- | +| ac | \* | - + -## zcl_command_argument_type_to_zcl_cli_data_type(typeName, options) +### Loader API: Loader APIs~extractAccessIntoArray(xmlElement) ⇒ +Extract list of access information -Helper that deals with the type of the argument. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of access information -**Kind**: global function +| Param | Type | +| --- | --- | +| xmlElement | \* | -| Param | Type | -| -------- | --------------- | -| typeName | \* | -| options | \* | + - +### Loader API: Loader APIs~prepareCluster(cluster) ⇒ +Prepare XML cluster for insertion into the database. +This method can also prepare clusterExtensions. -## integrationEnabled(db, sessionId) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. -Boolean deciding whether Studio integration logic should be enabled +| Param | Type | +| --- | --- | +| cluster | \* | -**Kind**: global function -**Returns**: Promise to studio project path + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +### Loader API: Loader APIs~processClusters(db, filePath, packageId, data) ⇒ +Process clusters for insertion into the database. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of cluster insertion. -## isComponentTogglingDisabled(db, sessionId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Resolves into true if user has actively disabled the component toggling. -By default this row doesn't even exist in the DB, but if user toggles -the toggle to turn this off, then the "disableComponentToggling" will -be set so '1' in the database. + -**Kind**: global function -**Returns**: promise that resolves into a true or false, depending on whether the component toggling has been disabled manually. +### Loader API: Loader APIs~processClusterGlobalAttributes(db, filePath, packageId, data) ⇒ +Processes global attributes for insertion into the database. -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted data. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## restApiUrl(api, path, queryParams) ⇒ + -Studio REST API path helper/generator +### Loader API: Loader APIs~processClusterExtensions(db, filePath, packageId, data) ⇒ +Cluster Extension contains attributes and commands in a same way as regular cluster, +and it has an attribute code="0xXYZ" where code is a cluster code. -**Kind**: global function -**Returns**: URL for rest api. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the clusterExtension tags -| Param | -| ----------- | -| api | -| path | -| queryParams | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - + -## wsApiUrl(api, path, queryParams) ⇒ +### Loader API: Loader APIs~processGlobals(db, filePath, packageId, data) ⇒ +Processes the globals in the XML files. The `global` tag contains +attributes and commands in a same way as cluster or clusterExtension -Studio WebSocket API path helper/generator +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the globals -**Kind**: global function -**Returns**: URL for WS +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | -| ----------- | -| api | -| path | -| queryParams | + - +### Loader API: Loader APIs~prepareTag(tag) ⇒ +Prepare tag object from tag -## getProjectInfo(db, sessionId) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: tag information -Send HTTP GET request to Studio Jetty server for project information. +| Param | Type | +| --- | --- | +| tag | \* | -**Kind**: global function -**Returns**: - HTTP RESP with project info in JSON form + -| Param | Type | -| --------- | --------------- | -| db | | -| sessionId | \* | +### Loader API: Loader APIs~processDefaultAccess(db, filePath, packageId, defaultAccessList) +Process defaultAccess tag in the XML. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## updateComponentByClusterIdAndComponentId(project, componentIds, add, db, sessionId, side) ⇒ \* +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| defaultAccessList | \* | -Send HTTP Post to update UC component state in Studio + -**Kind**: global function -**Returns**: \* - - [{id, status, data }] -id - string, -status - boolean. true if HTTP REQ status code is OK, -data - HTTP response data field +### Loader API: Loader APIs~processAccessControl(db, filePath, packageId, accessControlList) +Process accessControl tag in the XML. -| Param | Type | -| ------------ | --------------- | -| project | \* | -| componentIds | \* | -| add | \* | -| db | \* | -| sessionId | \* | -| side | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| accessControlList | \* | -## updateComponentByComponentIds(project, componentIds, add) ⇒ \* + -Send HTTP Post to update UC component state in Studio +### Loader API: Loader APIs~processTags(db, filePath, packageId, tags) +Processes the tags in the XML. -**Kind**: global function -**Returns**: \* - - [{id, status, data }] -id - string, -status - boolean. true if HTTP REQ status code is OK, -data - HTTP response data field +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -| Param | Type | Description | -| ------------ | --------------- | -------------------------------------------- | -| project | \* | local Studio project path | -| componentIds | \* | a list of component Ids | -| add | \* | true if adding component, false if removing. | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| tags | \* | - + -## wsMessageHandler(db, session, message) +### Loader API: Loader APIs~prepareDomain(domain) ⇒ +Convert domain from XMl to domain for DB. -Handles WebSocket messages from Studio server +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Domain object for DB. -**Kind**: global function +| Param | Type | +| --- | --- | +| domain | \* | -| Param | -| ------- | -| db | -| session | -| message | + - +### Loader API: Loader APIs~processDomains(db, filePath, packageId, data) ⇒ +Process domains for insertion. -## initIdeIntegration() +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of database insertion of domains. -Start the dirty flag reporting interval. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global function - + -## verifyWsConnection(db, sessionId) +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ +Prepare Data Type Discriminator for database table insertion. -Check WebSocket connections between backend and Studio jetty server. -If project is opened, verify connection is open. -If project is closed, close ws connection as well. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: global function +| Param | Type | +| --- | --- | +| a | \* | -| Param | -| --------- | -| db | -| sessionId | + - +### Loader API: Loader APIs~processDataTypeDiscriminator(db, filePath, zclDataTypes) ⇒ +Processes Data Type Discriminator. -## wsConnect(sessionId, path) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. -Utility function for making websocket connection to Studio server +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| zclDataTypes | \* | -**Kind**: global function -**Returns**: websocket + -| Param | -| --------- | -| sessionId | -| path | +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ +Prepare Data Types for database table insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -## isProjectActive(path) +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | -Check if a specific Studio project (.slcp) file has been opened or not. + -Context: To get proper WebSocket notification for change in project states, -that specific project needs to be opened already. Otherwise, no notification -will happen. +### Loader API: Loader APIs~processDataType(db, filePath, packageId, knownPackages, data, dataType) ⇒ +Processes Data Type. - DependsComponent API used as a quick way to check if the project is opened or not - If project is open/valid, the API will respond with "Component not found in project" - Otherwise, "Project does not exists" +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | +| dataType | \* | -| Param | -| ----- | -| path | + - +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ +Prepare numbers for database table insertion. -## deinitIdeIntegration() +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Clears up the reporting interval. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -**Kind**: global function - + -## sendSessionCreationErrorStatus(err) +### Loader API: Loader APIs~processNumber(db, filePath, packageId, knownPackages, data) ⇒ +Processes Numbers. -Notify front-end that current session failed to load. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -| Param | -| ----- | -| err | + - +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ +Prepare strings for database table insertion. -## sendComponentUpdateStatus(err) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Notify front-end that current session failed to load. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -**Kind**: global function + -| Param | Type | -| ----- | --------------- | -| err | \* | +### Loader API: Loader APIs~processString(db, filePath, packageId, knownPackages, data) ⇒ +Processes Strings. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. -## exportEndpointTypes(db, sessionId) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -Resolves to an array of endpoint types. + -**Kind**: global function -**Returns**: Promise to retrieve all endpoint types. +### Loader API: Loader APIs~prepareEnumOrBitmapAtomic(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## exportSessionPackages(db, sessionId) + -Resolves with data for packages. +### Loader API: Loader APIs~processEnumAtomic(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enums. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | - + -## exportDataIntoFile(db, sessionId, filePath) ⇒ +### Loader API: Loader APIs~prepareEnumOrBitmap(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -Toplevel file that takes a given session ID and exports the data into the file +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: global function -**Returns**: A promise that resolves with the path of the file written. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| filePath | \* | + - +### Loader API: Loader APIs~processEnum(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enums. -## createStateFromDatabase(db, sessionId) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -Given a database and a session id, this method returns a promise that -resolves with a state object that needs to be saved into a file. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -**Kind**: global function -**Returns**: state object that needs to be saved into a file. + -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enum Items. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. -## convertToFile(state, fileFormat) +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -This function gets the state from database and converts it for a given file format. + -**Kind**: global function +### Loader API: Loader APIs~processBitmapAtomic(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmaps. -| Param | Type | -| ---------- | --------------- | -| state | \* | -| fileFormat | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## updateCommands(cluster, clusterToCommandMap) ⇒ + -Updates the clusters with the new command format where there is isIncoming -and isEnabled instead of incoming and outgoing +### Loader API: Loader APIs~processBitmap(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmaps. -**Kind**: global function -**Returns**: state or null +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -| Param | Type | -| ------------------- | --------------- | -| cluster | \* | -| clusterToCommandMap | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | - + -## convertFromFile() +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmap fields. -This function gets the JSON from the file, and converts it to the correct database state +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. -**Kind**: global function - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## locateAttribute(state) + -Locates or adds an attribute, and returns it. -at contains clusterId, attributeId, isClient, mfgCode and possibly value +### Loader API: Loader APIs~prepareStruct(a, dataType) ⇒ +Prepare structs for database table insertion. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| ----- | --------------- | -| state | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - + -## parseAttribute(attributeString, [value]) +### Loader API: Loader APIs~processStruct(db, filePath, packageId, knownPackages, data) ⇒ +Processes the structs. -Parses attribute string in a form: -cl:0xABCD, at:0xABCD, di: [client|server], mf:0xABCD +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -| Param | Type | Default | -| --------------- | --------------- | ------------- | -| attributeString | \* | | -| [value] | \* | | + - +### Loader API: Loader APIs~processStructItems(db, filePath, packageIds, data) ⇒ +Processes the struct Items. -## parseZclAfv2Line(state, line) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. -Logic that parses data out of an ISC file into a java object +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageIds | \* | +| data | \* | -**Kind**: global function + -| Param | Type | -| ----- | --------------- | -| state | \* | -| line | \* | +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ Object +Prepares a device type object by extracting and transforming its properties. - +This function takes a device type object and processes its properties to create +a new object with a specific structure. It handles various properties such as +device ID, profile ID, domain, name, description, class, scope, and superset. +Additionally, it processes endpoint compositions and clusters if they exist. -## parseZclCustomizer(state, line) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object - The prepared device type object with transformed properties. -Function that deals with the zcl customizer data inside the ISC file +| Param | Type | Description | +| --- | --- | --- | +| deviceType | Object | The device type object to be prepared. | -**Kind**: global function + -| Param | Type | -| ----- | --------------- | -| state | \* | -| line | \* | +### Loader API: Loader APIs~processDeviceTypes(db, filePath, packageId, data, context) ⇒ Promise +Processes and inserts device types into the database. +This function logs the number of device types being processed for debugging purposes. +It maps over the provided data to prepare each device type and then iterates over each prepared device type. +If a device type has a compositionType, it inserts the endpoint composition into the database, +retrieves the endpoint composition ID, and then inserts the device composition. +Finally, it inserts all prepared device types into the database. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise - A promise that resolves after all device types have been inserted into the database. -## readIscData(filePath, data) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| filePath | string | The file path from which the device types are being processed. | +| packageId | \* | The package ID associated with the device types. | +| data | Array | The array of device types to be processed. | +| context | \* | Additional context that might be required for processing. | -Toplevel parser that ignore anything except the two setups that are -ZCL relevant. + -**Kind**: global function -**Returns**: promise of read ISC data +### Loader API: Loader APIs~processParsedZclData(db, argument) ⇒ +After XML parser is done with the barebones parsing, this function +branches the individual toplevel tags. -| Param | Type | -| -------- | --------------- | -| filePath | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise that resolves when all the subtags are parsed. - +| Param | Type | +| --- | --- | +| db | \* | +| argument | \* | -## loadEndpointType(db, sessionId, zclPackages, endpointType) + -Load individual endpoint types. +### Loader API: Loader APIs~parseSingleZclFile(db, packageId, file) ⇒ +This function is used for parsing each individual ZCL file at a grouped zcl file package level. +This should _not_ be used for custom XML addition due to custom xmls potentially relying on existing packges. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise for when the last stage of the loading pipeline finishes. -| Param | Type | Description | -| ------------ | --------------- | ------------------------------------- | -| db | \* | | -| sessionId | \* | | -| zclPackages | \* | Array of package IDs for zcl queries. | -| endpointType | \* | | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| file | \* | - + -## loadImplementedCommandsForEndpoint(db, zclPackageId, state, commandExtensions, endpointTypeId) +### Loader API: Loader APIs~isCrcMismatchOrPackageDoesNotExist(db, packageId, files) ⇒ +Checks if there is a crc mismatch on any xml file. This can be used to +decide if there is a need to reload all the xml files. Also check if the +package is not loaded before. -Loads all implemented commands for a single endpoint. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: the status of crc mismatch and whether a package is present in an +object -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| zclPackageId | \* | -| state | \* | -| commandExtensions | \* | -| endpointTypeId | \* | + - +### Loader API: Loader APIs~parseZclFiles(db, packageId, zclFiles, context) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -## loadImplementedCommandsExtensions(db, zclPackageId, state, commandExtensions, endpointTypeIdArray) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -This method goes over the endpoint type and the state, and enables -commands that belong to enabled clusters and are listed in the -commandExtensions as "implemented". +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclFiles | \* | +| context | \* | -**Kind**: global function + -| Param | Type | -| ------------------- | --------------- | -| db | \* | -| zclPackageId | \* | -| state | \* | -| commandExtensions | \* | -| endpointTypeIdArray | \* | +### Loader API: Loader APIs~parseManufacturerData(db, ctx) ⇒ +Parses the manufacturers xml. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed manufacturers file. -## loadCommands(db, state, sessionId) +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -This method resolves promises that contain all the -queries that are needed to load the attribute state + -**Kind**: global function +### Loader API: Loader APIs~parseProfilesData(db, ctx) ⇒ +Parses the profiles xml. -| Param | Type | -| --------- | --------------- | -| db | \* | -| state | \* | -| sessionId | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed profiles file. - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## loadAttributes(db, state, sessionId) + -This method resolves promises that contain all the -queries that are needed to load the attribute state +### Loader API: Loader APIs~parseFeatureFlags(db, packageId, featureFlags) ⇒ +Inside the `zcl.json` can be a `featureFlags` key, which is +a general purpose object. It contains keys, that map to objects. +Each key is a "package option category". +Key/velues of the object itself, end up in CODE/LABEL combinations. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of feature flags + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | + + + +### Loader API: Loader APIs~parseFeatureConformance(operand) ⇒ +Parses feature conformance or an operand in feature conformance recursively from xml data. + +An example of parsing the conformance of 'User' device type feature: + +Input operand from xml data: +{ + "$": {"code": "USR", "name": "User"}, + "mandatoryConform": [ + { "andTerm": [ + { + "condition": [{"$": {"name": "Matter"}}], + "orTerm": [ + { "feature": [ + { "$": {"name": "PIN"}}, + { "$": {"name": "RID"}}, + { "$": {"name": "FPG"}}, + { "$": {"name": "FACE"}} + ] + } + ] + } + ] + } + ] +} + +Output device type feature conformance string: + "Matter & (PIN | RID | FPG | FACE)" + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: The feature conformance string. + +| Param | Type | Description | +| --- | --- | --- | +| operand | \* | The operand to be parsed. | + + + +### Loader API: Loader APIs~parseAndOrConformanceTerms(operand, joinChar) ⇒ +Helper function to parse andTerm or orTerm from xml data + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature conformance string + +| Param | Type | +| --- | --- | +| operand | \* | +| joinChar | \* | + + + +### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒ +Inside the `zcl.json` can be a `featureFlags` key, which is +a general purpose object. It contains keys, that map to objects. +Each key is a "package option category". +Key/velues of the object itself, end up in CODE/LABEL combinations. -| Param | Type | -| --------- | --------------- | -| db | \* | -| state | \* | -| sessionId | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that loads the uiOptions object into the database. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | -## loadSessionKeyValues(db, sessionId, keyValues) + -Loads the session key values from the keyValues object +### Loader API: Loader APIs~parseOptions(db) ⇒ +Parses and loads the text and boolean options. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise of parsed options -| Param | Type | -| --------- | --------------- | -| db | \* | -| sessionId | \* | -| keyValues | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -## iscDataLoader(db, state, sessionId) +### Loader API: Loader APIs~parseTextOptions(db, pkgRef, textOptions) ⇒ +Parses the text options. -Function that actually loads the data out of a state object. -Session at this point is blank, and has no packages. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed text options. -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textOptions | \* | -| Param | Type | -| --------- | --------------- | -| db | \* | -| state | \* | -| sessionId | \* | + - +### Loader API: Loader APIs~parseBoolOptions(db, pkgRef, booleanCategories) ⇒ +Parses the boolean options. -## importSessionKeyValues(db, sessionId, keyValuePairs) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed boolean options. -Resolves with a promise that imports session key values. +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | -**Kind**: global function + -| Param | Type | -| ------------- | --------------- | -| db | \* | -| sessionId | \* | -| keyValuePairs | \* | +### Loader API: Loader APIs~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes) ⇒ Promise.<void> +Asynchronously parses and inserts attribute access interface attributes into the database. +This function iterates over the attributeAccessInterfaceAttributes object, processing each cluster +by mapping its values to a specific structure and then inserting them into the database using +the insertOptionsKeyValues function. - +The main purpose of this function is to store cluster/attribute pairs including global attributes and their cluster pair +The ATTRIBUTE table has cluster_ref as null for global attributes so this second method was necessary -## autoLoadPackage(db, pkg, absPath) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise.<void> - A promise that resolves when all attributes have been processed and inserted. -Auto-load package. If succesful it returns an object. -Otherwise it throws an exception. +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| pkgRef | \* | The package reference id for which the attributes are being parsed. | +| attributeAccessInterfaceAttributes | \* | An object containing the attribute access interface attributes, structured by cluster. | -**Kind**: global function -**Returns**: object containing packageId and packageType. + -| Param | Type | -| ------- | --------------- | -| db | \* | -| pkg | \* | -| absPath | \* | +### Loader API: Loader APIs~parseDefaults(db, ctx) ⇒ +Parses the default values inside the options. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promised of parsed text and bool defaults. -## importSinglePackage(db, pkg, zapFilePath, packageMatch, defaultZclMetafile, defaultTemplateFile) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -Resolves into a { packageId:, packageType:} -object, pkg has`path`, `version`, `type`. It can ALSO have pathRelativity. If pathRelativity is missing -path is considered absolute. + -**Kind**: global function -**Returns**: pkg information based on a match +### Loader API: Loader APIs~parseTextDefaults(db, pkgRef, textDefaults) ⇒ +Parse text defaults from default options. -| Param | Type | Default | -| ------------------- | --------------- | ------------- | -| db | \* | | -| pkg | \* | | -| zapFilePath | \* | | -| packageMatch | \* | | -| defaultZclMetafile | \* | | -| defaultTemplateFile | \* | | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of promises - +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textDefaults | \* | -## convertPackageResult(data) ⇒ + -Convert the array of results into a more palatable value. -Resolves an array of { packageId:, packageType:} objects into { zclPackageId: id, templateIds: [] } +### Loader API: Loader APIs~parseBoolDefaults(db, pkgRef, booleanCategories) ⇒ +Parse the boolean defaults inside options. -**Kind**: global function -**Returns**: an object that contains session ids. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: List of promises -| Param | Type | -| ----- | --------------- | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | - + -## importPackages(db, packages, zapFilePath, packageMatch, defaultZclMetafile, defaultTemplateFile) ⇒ +### Loader API: Loader APIs~loadIndividualSilabsFile(db, filePath) ⇒ +Parses a single file. This function is used specifically +for adding a package through an existing session because of its reliance +on relating the new XML content to the packages associated with that session. +e.g. for ClusterExtensions. -**Kind**: global function -**Returns**: a promise that resolves into an object containing: packageId and otherIds +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a loaded file. -| Param | Type | Default | -| ------------------- | --------------- | ------------- | -| db | \* | | -| packages | \* | | -| zapFilePath | \* | | -| packageMatch | \* | | -| defaultZclMetafile | \* | | -| defaultTemplateFile | \* | | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | - + -## sortEndpoints(endpoints) ⇒ +### Loader API: Loader APIs~processCustomZclDeviceType(db, ctx) ⇒ +If custom device is supported, then this method creates it. -Sorts the list of endpoints +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: context -**Kind**: global function -**Returns**: list or sorted endpoints based on endpoint type index +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -| Param | Type | -| --------- | --------------- | -| endpoints | \* | + - +### Loader API: Loader APIs~loadZclJson(db, metafile) ⇒ +Load ZCL metadata -## importClusters(db, allZclPackageIds, endpointTypeId, clusters) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl json file -Imports the clusters for an endpoint type along with attributes, commands -and events +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | -**Kind**: global function + -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| allZclPackageIds | \* | -| endpointTypeId | \* | -| clusters | \* | +### Loader API: Loader APIs~loadZclProperties(db, metafile) ⇒ +Load ZCL metadata - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl properties file -## importCommands(db, allZclPackageIds, endpointTypeId, endpointClusterId, commands) +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | -Imports the list of commands from a cluster + -**Kind**: global function +### Loader API: Loader APIs~loadZclJsonOrProperties(db, ctx) ⇒ +Toplevel function that loads the toplevel metafile +and orchestrates the promise chain. -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| allZclPackageIds | \* | -| endpointTypeId | \* | -| endpointClusterId | \* | -| commands | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | The context of loading. | -## importAttributes(db, allZclPackageIds, endpointTypeId, endpointClusterId, attributes, cluster) + -Imports the list of attributes from a cluster +### Loader API: Loader APIs~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync) ⇒ +Records the toplevel package information and resolves into packageId -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: packageId -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| allZclPackageIds | \* | -| endpointTypeId | \* | -| endpointClusterId | \* | -| attributes | \* | -| cluster | \* | +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| crc | \* | +| isTopLevelPackageInSync | \* | - + -## importEvents(db, allZclPackageIds, endpointClusterId, events) +### Loader API: Loader APIs~recordVersion(db, ctx) +Records the version into the database. -Imports the list of events from a cluster +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| allZclPackageIds | \* | -| endpointClusterId | \* | -| events | \* | + - +### Loader API: Loader APIs~loadZclMetaFilesCommon(db, metadataFile, options) ⇒ +Retrieve zcl package information -## getMandatoryClusterAttributes(db, epc, cluster, allZclPackageIds) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: package zcl package information -Retrieves the mandatory attributes of a cluster +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| options | \* | -**Kind**: global function -**Returns**: mandatory attributes of a cluster + -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| epc | \* | -| cluster | \* | -| allZclPackageIds | \* | +### Loader API: Loader APIs~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap) +Load attribute mapping table if there is multi-protocol information from a json file. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## getMandatoryClusterCommands(db, epc, cluster, allZclPackageIds) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| multiProtcolInfo | \* | +| categoryToPackageIdMap | \* | -Retrieves the mandatory commands of a cluster + -**Kind**: global function -**Returns**: mandatory commands of a cluster +### Loader API: Loader APIs~loadZclMetafiles(db, metadataFile) ⇒ +Toplevel function that loads the zcl file and passes it off to the correct zcl loader. -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| epc | \* | -| cluster | \* | -| allZclPackageIds | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of loaded packageIds. - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| metadataFile | \* | array of paths | -## clusterComplianceForAttributes(db, sessionId, endpointTypeAttributes, allMandatoryAttributes, endpointId, clusterSpecCheckComplianceMessage, specMessageIndent) ⇒ + -Adds cluster compliance warnings for attributes to the console and the -session notification table +### Loader API: Loader APIs~loadZcl(db, metadataFile) ⇒ +Loads individual zcl.json metafile. -**Kind**: global function -**Returns**: clusterSpecCheckComplianceMessage by concatenating all -clusterSpecComplianceMessageForAttributes +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Context object that contains .db and .packageId -| Param | Type | -| --------------------------------- | --------------- | -| db | \* | -| sessionId | \* | -| endpointTypeAttributes | \* | -| allMandatoryAttributes | \* | -| endpointId | \* | -| clusterSpecCheckComplianceMessage | \* | -| specMessageIndent | \* | +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | - + -## clusterComplianceForCommands(db, sessionId, endpointTypeCommands, allMandatoryCommands, endpointId, clusterSpecCheckComplianceMessage, specMessageIndent) ⇒ +### Loader API: Loader APIs~loadIndividualFile(db, filePath, sessionId) +Load individual custom XML files. -Adds cluster compliance warnings for commands to the console and the -session notification table +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -**Kind**: global function -**Returns**: clusterSpecCheckComplianceMessage by concatenating all -clusterSpecComplianceMessageForAttributes +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| filePath | \* | | +| sessionId | \* | Current session within which we're loading this file. | -| Param | Type | -| --------------------------------- | --------------- | -| db | \* | -| sessionId | \* | -| endpointTypeCommands | \* | -| allMandatoryCommands | \* | -| endpointId | \* | -| clusterSpecCheckComplianceMessage | \* | -| specMessageIndent | \* | + - +### Loader API: Loader APIs~qualifyZclFile(db, info, parentPackageId, isCustom) ⇒ +Promises to qualify whether zcl file needs to be reloaded. +If yes, the it will resolve with {filePath, data, packageId} +If not, then it will resolve with {error} -## deviceTypeClustersAttributesAndCommands(db, endpointTypeId) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves int he object of data. -Retrieves deviceTypeClustersOnEndpointType, deviceTypeAttributesOnEndpointType -and deviceTypeCommandsOnEndpointType for an endpoint type +| Param | Type | +| --- | --- | +| db | \* | +| info | \* | +| parentPackageId | \* | +| isCustom | \* | -**Kind**: global function -**Returns**: deviceTypeClustersOnEndpointType, deviceTypeAttributesOnEndpointType -and deviceTypeCommandsOnEndpointType for an endpoint type + -| Param | Type | -| -------------- | --------------- | -| db | \* | -| endpointTypeId | \* | +### Loader API: Loader APIs~processZclPostLoading(db) ⇒ +Promises to perform a post loading step. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise to deal with the post-loading cleanup. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### Loader API: Loader APIs~getDiscriminatorMap(db, packageIds) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: data type discriminator map + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +## Loader API: Loader APIs +This module provides the APIs for ZCL/Data-Model loading. + + +* [Loader API: Loader APIs](#module_Loader API_ Loader APIs) + * [~collectDataFromLibraryXml(ctx)](#module_Loader API_ Loader APIs..collectDataFromLibraryXml) ⇒ + * [~tagContainsEnum(tag)](#module_Loader API_ Loader APIs..tagContainsEnum) ⇒ + * [~tagContainsStruct(tag)](#module_Loader API_ Loader APIs..tagContainsStruct) ⇒ + * [~tagContainsBitmap(tag)](#module_Loader API_ Loader APIs..tagContainsBitmap) ⇒ + * [~parseSingleZclFile(db, ctx, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~parseZclFiles(db, ctx)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~normalizeHexValue(value)](#module_Loader API_ Loader APIs..normalizeHexValue) ⇒ + * [~getNumBytesFromShortName(value)](#module_Loader API_ Loader APIs..getNumBytesFromShortName) ⇒ + * [~prepareAttributes(attributes, side)](#module_Loader API_ Loader APIs..prepareAttributes) ⇒ + * [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒ + * [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒ + * [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒ + * [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒ + * [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~prepareTypes(zclTypes, types)](#module_Loader API_ Loader APIs..prepareTypes) + * [~prepareAttributeType(attribute, types, cluster)](#module_Loader API_ Loader APIs..prepareAttributeType) + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, packageId, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumsOrBitmaps(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmaps) ⇒ + * [~processEnums(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnums) ⇒ + * [~processEnumItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmaps(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmaps) ⇒ + * [~processBitmapFields(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct2(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct2) ⇒ + * [~processStruct(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareEnumsOrBitmapsAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmapsAtomic) ⇒ + * [~processEnumsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumsFromAtomics) ⇒ + * [~processBitmapsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapsFromAtomics) ⇒ + * [~loadZclData(db, ctx)](#module_Loader API_ Loader APIs..loadZclData) ⇒ + * [~loadIndividualDotDotFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualDotDotFile) ⇒ \* + * [~loadToplevelXmlFile(db, ctx)](#module_Loader API_ Loader APIs..loadToplevelXmlFile) ⇒ + * [~parseNewXmlFiles(db, packageId, files, context)](#module_Loader API_ Loader APIs..parseNewXmlFiles) ⇒ + * [~prepXmlFeature(f)](#module_Loader API_ Loader APIs..prepXmlFeature) ⇒ + * [~prepXmlAttribute(a)](#module_Loader API_ Loader APIs..prepXmlAttribute) ⇒ + * [~prepXmlCommand(c)](#module_Loader API_ Loader APIs..prepXmlCommand) ⇒ + * [~prepXmlEvent(e)](#module_Loader API_ Loader APIs..prepXmlEvent) ⇒ + * [~parseSingleNewXmlFile(f)](#module_Loader API_ Loader APIs..parseSingleNewXmlFile) ⇒ + * [~collectDataFromJsonFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromJsonFile) ⇒ + * [~collectDataFromPropertiesFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromPropertiesFile) ⇒ + * [~maskToType(mask)](#module_Loader API_ Loader APIs..maskToType) ⇒ + * [~prepareAtomic(a)](#module_Loader API_ Loader APIs..prepareAtomic) + * [~processAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processAtomics) ⇒ + * [~prepareClusterGlobalAttribute(cluster)](#module_Loader API_ Loader APIs..prepareClusterGlobalAttribute) ⇒ + * [~extractAccessTag(ac)](#module_Loader API_ Loader APIs..extractAccessTag) ⇒ + * [~extractAccessIntoArray(xmlElement)](#module_Loader API_ Loader APIs..extractAccessIntoArray) ⇒ + * [~prepareCluster(cluster)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~processClusters(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusters) ⇒ + * [~processClusterGlobalAttributes(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterGlobalAttributes) ⇒ + * [~processClusterExtensions(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterExtensions) ⇒ + * [~processGlobals(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processGlobals) ⇒ + * [~prepareTag(tag)](#module_Loader API_ Loader APIs..prepareTag) ⇒ + * [~processDefaultAccess(db, filePath, packageId, defaultAccessList)](#module_Loader API_ Loader APIs..processDefaultAccess) + * [~processAccessControl(db, filePath, packageId, accessControlList)](#module_Loader API_ Loader APIs..processAccessControl) + * [~processTags(db, filePath, packageId, tags)](#module_Loader API_ Loader APIs..processTags) + * [~prepareDomain(domain)](#module_Loader API_ Loader APIs..prepareDomain) ⇒ + * [~processDomains(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processDomains) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, filePath, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, knownPackages, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumOrBitmapAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmapAtomic) ⇒ + * [~processEnumAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumAtomic) ⇒ + * [~prepareEnumOrBitmap(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmap) ⇒ + * [~processEnum(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnum) ⇒ + * [~processEnumItems(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmapAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapAtomic) ⇒ + * [~processBitmap(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmap) ⇒ + * [~processBitmapFields(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~processStruct(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageIds, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ Object + * [~processDeviceTypes(db, filePath, packageId, data, context)](#module_Loader API_ Loader APIs..processDeviceTypes) ⇒ Promise + * [~processParsedZclData(db, argument)](#module_Loader API_ Loader APIs..processParsedZclData) ⇒ + * [~parseSingleZclFile(db, packageId, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~isCrcMismatchOrPackageDoesNotExist(db, packageId, files)](#module_Loader API_ Loader APIs..isCrcMismatchOrPackageDoesNotExist) ⇒ + * [~parseZclFiles(db, packageId, zclFiles, context)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~parseManufacturerData(db, ctx)](#module_Loader API_ Loader APIs..parseManufacturerData) ⇒ + * [~parseProfilesData(db, ctx)](#module_Loader API_ Loader APIs..parseProfilesData) ⇒ + * [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒ + * [~parseFeatureConformance(operand)](#module_Loader API_ Loader APIs..parseFeatureConformance) ⇒ + * [~parseAndOrConformanceTerms(operand, joinChar)](#module_Loader API_ Loader APIs..parseAndOrConformanceTerms) ⇒ + * [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒ + * [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒ + * [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒ + * [~parseBoolOptions(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolOptions) ⇒ + * [~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes)](#module_Loader API_ Loader APIs..parseattributeAccessInterfaceAttributes) ⇒ Promise.<void> + * [~parseDefaults(db, ctx)](#module_Loader API_ Loader APIs..parseDefaults) ⇒ + * [~parseTextDefaults(db, pkgRef, textDefaults)](#module_Loader API_ Loader APIs..parseTextDefaults) ⇒ + * [~parseBoolDefaults(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolDefaults) ⇒ + * [~loadIndividualSilabsFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualSilabsFile) ⇒ + * [~processCustomZclDeviceType(db, ctx)](#module_Loader API_ Loader APIs..processCustomZclDeviceType) ⇒ + * [~loadZclJson(db, metafile)](#module_Loader API_ Loader APIs..loadZclJson) ⇒ + * [~loadZclProperties(db, metafile)](#module_Loader API_ Loader APIs..loadZclProperties) ⇒ + * [~loadZclJsonOrProperties(db, ctx)](#module_Loader API_ Loader APIs..loadZclJsonOrProperties) ⇒ + * [~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync)](#module_Loader API_ Loader APIs..recordToplevelPackage) ⇒ + * [~recordVersion(db, ctx)](#module_Loader API_ Loader APIs..recordVersion) + * [~loadZclMetaFilesCommon(db, metadataFile, options)](#module_Loader API_ Loader APIs..loadZclMetaFilesCommon) ⇒ + * [~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap)](#module_Loader API_ Loader APIs..loadAttributeMappingForMultiProtocol) + * [~loadZclMetafiles(db, metadataFile)](#module_Loader API_ Loader APIs..loadZclMetafiles) ⇒ + * [~loadZcl(db, metadataFile)](#module_Loader API_ Loader APIs..loadZcl) ⇒ + * [~loadIndividualFile(db, filePath, sessionId)](#module_Loader API_ Loader APIs..loadIndividualFile) + * [~qualifyZclFile(db, info, parentPackageId, isCustom)](#module_Loader API_ Loader APIs..qualifyZclFile) ⇒ + * [~processZclPostLoading(db)](#module_Loader API_ Loader APIs..processZclPostLoading) ⇒ + * [~getDiscriminatorMap(db, packageIds)](#module_Loader API_ Loader APIs..getDiscriminatorMap) ⇒ + + + +### Loader API: Loader APIs~collectDataFromLibraryXml(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. -## deviceTypeClusterToFeatureBits(deviceTypeFeaturesOnEndpointType) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. -**Kind**: global function -**Returns**: a map between device type's cluster id to feature bits for that cluster +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the metadataFiles and data | -| Param | Type | -| -------------------------------- | --------------- | -| deviceTypeFeaturesOnEndpointType | \* | + - +### Loader API: Loader APIs~tagContainsEnum(tag) ⇒ +Check if tag contains enum. -## deviceTypeComplianceForClusters(db, endpointId, sessionId, deviceTypeClustersOnEndpointType, endpointTypeClusterRefMap, deviceTypeSpecCheckComplianceMessage, specMessageIndent) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -Adds device type compliance warnings for clusters to the console and the -session notification table +| Param | Type | +| --- | --- | +| tag | \* | -**Kind**: global function -**Returns**: deviceTypeSpecCheckComplianceMessage by concatenating all -clusterSpecComplianceMessages + -| Param | Type | -| ------------------------------------ | --------------- | -| db | \* | -| endpointId | \* | -| sessionId | \* | -| deviceTypeClustersOnEndpointType | \* | -| endpointTypeClusterRefMap | \* | -| deviceTypeSpecCheckComplianceMessage | \* | -| specMessageIndent | \* | +### Loader API: Loader APIs~tagContainsStruct(tag) ⇒ +Check if tag contains struct. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -## deviceTypeComplianceForAttributes(db, endpointId, sessionId, deviceTypeAttributesOnEndpointType, endpointTypeAttributeRefMap, deviceTypeSpecCheckComplianceMessage, specMessageIndent) ⇒ +| Param | Type | +| --- | --- | +| tag | \* | -Adds device type compliance warnings for attributes to the console and the -session notification table + -**Kind**: global function -**Returns**: deviceTypeSpecCheckComplianceMessage by concatenating all -attributeSpecComplianceMessages +### Loader API: Loader APIs~tagContainsBitmap(tag) ⇒ +Check if tag contains Bitmap. -| Param | Type | -| ------------------------------------ | --------------- | -| db | \* | -| endpointId | \* | -| sessionId | \* | -| deviceTypeAttributesOnEndpointType | \* | -| endpointTypeAttributeRefMap | \* | -| deviceTypeSpecCheckComplianceMessage | \* | -| specMessageIndent | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean - +| Param | Type | +| --- | --- | +| tag | \* | -## deviceTypeComplianceForCommands(db, endpointId, sessionId, deviceTypeCommandsOnEndpointType, endpointTypeCommandRefMap, deviceTypeSpecCheckComplianceMessage, specMessageIndent) ⇒ + -Adds device type compliance warnings for commands to the console and the -session notification table +### Loader API: Loader APIs~parseSingleZclFile(db, ctx, file) ⇒ +Parses ZCL xml file. -**Kind**: global function -**Returns**: deviceTypeSpecCheckComplianceMessage by concatenating all -commandSpecComplianceMessages +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: empty array -| Param | Type | -| ------------------------------------ | --------------- | -| db | \* | -| endpointId | \* | -| sessionId | \* | -| deviceTypeCommandsOnEndpointType | \* | -| endpointTypeCommandRefMap | \* | -| deviceTypeSpecCheckComplianceMessage | \* | -| specMessageIndent | \* | +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | +| file | \* | - + -## importEndpointTypes(db, sessionId, allZclPackageIds, endpointTypes, endpoints) +### Loader API: Loader APIs~parseZclFiles(db, ctx) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -Import endpointTypes +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -| Param | Type | -| ---------------- | --------------- | -| db | \* | -| sessionId | \* | -| allZclPackageIds | \* | -| endpointTypes | \* | -| endpoints | \* | + - +### Loader API: Loader APIs~normalizeHexValue(value) ⇒ +The Dotdot ZCL XML doesn't use the 0x prefix, but it's a nice thing to have and Silabs xml +does use this so this helper function normalizes the use of hex -### importEndpointTypes~endpointTypeClusters +TODO: Is this the right thing to do? -The following code looks into the spec conformance coming from the xml -loading. This involves compliance of between device types, clusters, -commands and attributes on an endpoint. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Either the normalized hex string (with the 0x prefix) or the original -**Kind**: inner property of [importEndpointTypes](#importEndpointTypes) - +| Param | Type | Description | +| --- | --- | --- | +| value | \* | the string value to be normalized | -## jsonDataLoader(db, state, sessionId, packageMatch, defaultZclMetafile, defaultTemplateFile) ⇒ + -Given a state object, this method returns a promise that resolves -with the succesfull writing into the database. +### Loader API: Loader APIs~getNumBytesFromShortName(value) ⇒ +The Dotdot ZCL XML doesn't have a length but it is embedded in the short name, +we can scrape the value to get the size -**Kind**: global function -**Returns**: a promise that resolves into a sessionId that was created. +TODO: Is this the right thing to do? -| Param | Type | Description | -| ------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -| db | \* | | -| state | \* | | -| sessionId | \* | If null, then new session will get created, otherwise it loads the data into an existing session. Previous session data is not deleted. | -| packageMatch | \* | One of the package match strategies. See dbEnum.packageMatch | -| defaultZclMetafile | \* | | -| defaultTemplateFile | \* | | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: size in bytes or 0 if the # of bytes could not be determined - +| Param | Type | Description | +| --- | --- | --- | +| value | \* | the string value to be scraped | -## readJsonData(filePath, data, defaultZclMetafile, defaultTemplateFile) ⇒ + -Parses JSON file and creates a state object out of it, which is passed further down the chain. +### Loader API: Loader APIs~prepareAttributes(attributes, side) ⇒ +Prepare XML attributes for entry into the DB -**Kind**: global function -**Returns**: Promise of parsed JSON object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted into the DB. -| Param | Type | -| ------------------- | --------------- | -| filePath | \* | -| data | \* | -| defaultZclMetafile | \* | -| defaultTemplateFile | \* | +| Param | Type | Description | +| --- | --- | --- | +| attributes | \* | an array of attributes | +| side | \* | the side the attribute is on either "client" or "server" | - + -## readDataFromFile(filePath, defaultZclMetafile, defaultTemplateFile) ⇒ +### Loader API: Loader APIs~prepareCommands(commands, side, types) ⇒ +Prepare XML commands for entry into the DB -Reads the data from the file and resolves with the state object if all is good. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted in to the DB. -**Kind**: global function -**Returns**: Promise of file reading. +| Param | Type | Description | +| --- | --- | --- | +| commands | \* | an array of commands | +| side | \* | the side the command is on either "client" or "server" | +| types | \* | contained for types, where bitmaps are going to be inserted. | -| Param | Type | -| ------------------- | --------------- | -| filePath | \* | -| defaultZclMetafile | \* | -| defaultTemplateFile | \* | + - +### Loader API: Loader APIs~prepareCluster(cluster, isExtension, types) ⇒ +Prepare XML cluster for insertion into the database. +This method can also prepare clusterExtensions. -## importDataFromFile(db, filePath) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. -Writes the data from the file into a new session. -NOTE: This function does NOT initialize session packages. +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| cluster | \* | | | +| isExtension | \* | false | if this is an extension or not (there are none in dotdot xml) | +| types | \* | | types object into which cluster can put types it might have | -**Kind**: global function -**Returns**: a promise that resolves with the import result object that contains: sessionId, errors, warnings. + -| Param | Type | -| -------- | --------------- | -| db | \* | -| filePath | \* | +### Loader API: Loader APIs~prepareAtomic(type) ⇒ +Parses xml type into the atomic object for insertion into the DB - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -## initSessionTimers() +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the atomic format in the dotdot xml | -Start session specific validation. + -**Kind**: global function - +### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒ +Parses xml type into the bitmap object for insertion into the DB -## deinitSessionTimers(db, session) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -Deinitalize all validation timers associated with a specific session. +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| type | \* | | an xml object which conforms to the bitmap format in the dotdot xml | +| isContained | \* | false | a boolean indicating if this is coming from a contained tag or not | -**Kind**: global function + -| Param | -| ------- | -| db | -| session | +### Loader API: Loader APIs~prepareEnum(type) ⇒ +Parses xml type into the enum object for insertion into the DB - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -## startNormal(uiEnabled, showUrl, uiMode, zapFiles) +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the enum format in the dotdot xml | -Start up application in a normal mode. + -**Kind**: global function +### Loader API: Loader APIs~prepareStruct(type) ⇒ +Parses xml type into the struct object for insertion into the DB -| Param | Type | Description | -| --------- | --------------- | --------------------------------------------- | -| uiEnabled | \* | | -| showUrl | \* | | -| uiMode | \* | | -| zapFiles | \* | An array of .zap files to open, can be empty. | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB - +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the struct format in the dotdot xml | -## outputFile(inputFile, outputPattern) ⇒ + -Returns the output file out of input file and a pattern +### Loader API: Loader APIs~prepareTypes(zclTypes, types) +Parses xml types into the types object for insertion into the DB -**Kind**: global function -**Returns**: the path to the output file. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -| Param | Type | -| ------------- | --------------- | -| inputFile | \* | -| outputPattern | \* | +| Param | Type | Description | +| --- | --- | --- | +| zclTypes | \* | an array of xml types | +| types | \* | an object which includes arrays for enums, bitmaps etc... | - + -## gatherFiles(filesArg, options) +### Loader API: Loader APIs~prepareAttributeType(attribute, types, cluster) +Parses xml types into the types object for insertion into the DB -This method gathers all the files to process. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -**Kind**: global function +| Param | Type | Description | +| --- | --- | --- | +| attribute | \* | an attribute with the type in it | +| types | \* | an object which includes arrays for enums, bitmaps etc... | +| cluster | \* | the cluster that the attribute belongs to (used presently for uniqueness of the type name) | -| Param | Type | Description | -| -------- | --------------- | ------------------------ | -| filesArg | \* | array of files arguments | -| options | \* | | + - +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ +Preparation step for the device types. -## startConvert(files, output) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: an object containing the prepared device types. -Perform file conversion. +| Param | Type | +| --- | --- | +| deviceType | \* | -**Kind**: global function + -| Param | Type | -| ------ | --------------- | -| files | \* | -| output | \* | +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ +Prepare Data Type Discriminator for database table insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -## startRegenerateSdk(argv, options) +| Param | Type | +| --- | --- | +| a | \* | -Performs a full SDK regeneration. + -**Kind**: global function +### Loader API: Loader APIs~processDataTypeDiscriminator(db, packageId, zclDataTypes) ⇒ +Processes Data Type Discriminator. -| Param | Type | -| ------- | --------------- | -| argv | \* | -| options | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclDataTypes | \* | -## startAnalyze(paths, [options]) + -Perform file analysis. +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ +Prepare Data Types for database table insertion. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | Default | Description | -| --------- | -------------------- | -------------------------------------- | ------------------------ | -| paths | \* | | List of paths to analyze | -| [options] | boolean | { log: true, quit: true } | | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | - + -## startServer(options) ⇒ +### Loader API: Loader APIs~processDataType(db, filePath, packageId, data, dataType) ⇒ +Processes Data Type. -Starts zap in a server mode. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. -**Kind**: global function -**Returns**: promise of a startup +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | +| dataType | \* | -| Param | Type | -| ------- | --------------- | -| options | \* | + - +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ +Prepare numbers for database table insertion. -## startSelfCheck() +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Start up applicationa in self-check mode. +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -**Kind**: global function - + -## startGeneration() ⇒ +### Loader API: Loader APIs~processNumber(db, filePath, packageId, data) ⇒ +Processes Numbers. -Performs headless regeneration for given parameters. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. -**Kind**: global function -**Returns**: Nothing, triggers quit function - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## clearDatabaseFile(path) + -Move database file out of the way into the backup location. +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ +Prepare strings for database table insertion. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| ----- | --------------- | -| path | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - + -## shutdown() +### Loader API: Loader APIs~processString(db, filePath, packageId, data) ⇒ +Processes Strings. -Shuts down any servers that might be running. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. -**Kind**: global function - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## startUpSecondaryInstance(argv) + -Startup method for the secondary instance. +### Loader API: Loader APIs~prepareEnumsOrBitmaps(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| ----- | --------------- | -| argv | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - + -## startUpMainInstance(quitFunction, argv) +### Loader API: Loader APIs~processEnums(db, filePath, packageId, data) ⇒ +Processes the enums. -Default startup method. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | -| ------------ | --------------- | -| quitFunction | \* | -| argv | \* | + - +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, data) ⇒ +Processes the enum Items. -## start(expirationInterval, triggerFunction) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. -Starts a zap watchdog. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global function + -| Param | Type | -| ------------------ | --------------- | -| expirationInterval | \* | -| triggerFunction | \* | +### Loader API: Loader APIs~processBitmaps(db, filePath, packageId, data) ⇒ +Processes the bitmaps. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -## reset() +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -Resets a zap watchdog. + -**Kind**: global function - +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, data) ⇒ +Processes the bitmap fields. -## getForcedExternalStorage(db, packageIds) ⇒ Promise.<Array> +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. -Fetches forced external storage settings based on the given package ID. -Utilizes the attribute access interface to query storage policies -associated with the specified package ID. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global function -**Returns**: Promise.<Array> - A promise that resolves to an array of forced external storage settings. + -| Param | Type | Description | -| ---------- | ------------------- | -------------------------------- | -| db | Object | Database connection object. | -| packageIds | Number | The ID of the packages to query. | +### Loader API: Loader APIs~prepareStruct2(a, dataType) ⇒ +Prepare structs for database table insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -## computeStoragePolicyForGlobalAttributes(db, clusterId, attributes, packageId) ⇒ +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -This function takes a clusterId (the database ID, not the specification-defined ID), an array of attributes (associated with the database defined clusterID), -and a packageId to identify the specific package the attributes belong to. It changes the global attributes (attributes with specification defined clusterId = null) to represent storage policy -based on the cluster/attribute pair in zcl.json. + -Although the specification defined clusterID of the attribute is null indicating it is a global attribute, we know what the database defined clusterID is by what is passed in as a parameter. +### Loader API: Loader APIs~processStruct(db, filePath, packageId, data) ⇒ +Processes the structs. -That database defined clusterID is used to query the name of the cluster which is in turn used to compute the storage policy for that cluster/attribute pair based on the packageId. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. -**Kind**: global function -**Returns**: an array of objects representing attributes in the database +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | Description | -| ---------- | --------------- | ---------------------------------------------------------------------------------------------------------------- | -| db | \* | | -| clusterId | \* | (database defined) the clusterId representing a cluster from the database being used in the application | -| attributes | \* | an array of objects representing the attributes associated with the cluster | -| packageId | \* | the ID of the package to which the attributes belong, used to determine storage policies specific to the package | + - +### Loader API: Loader APIs~processStructItems(db, filePath, packageId, data) ⇒ +Processes the struct Items. -## computeStorageOptionNewConfig(storagePolicy) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. -This asynchronous function computes and returns the new configuration for a storage option. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global function + -| Param | Type | Description | -| ------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| storagePolicy | String | The current storage policy. The function first initializes the storageOption. Then it checks the storagePolicy: - If it's 'attributeAccessInterface', it sets the storageOption to 'external'. - If it's 'any', it sets the storageOption to 'ram'. If the storagePolicy is neither of these, it throws an error 'check storage policy'. Finally, it returns the updated storage option. | +### Loader API: Loader APIs~prepareEnumsOrBitmapsAtomic(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -## computeStoragePolicyNewConfig(db, clusterRef, storagePolicy, forcedExternal, attributeName) +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -This asynchronous function computes and returns the new configuration for a storage policy. + -**Kind**: global function +### Loader API: Loader APIs~processEnumsFromAtomics(db, filePath, packageId, data) ⇒ +Processes the enums. -| Param | Type | Description | -| -------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| db | Object | The database instance. | -| clusterRef | Number | The reference to the cluster. | -| storagePolicy | String | The current storage policy. | -| forcedExternal | Array | An array of external options. | -| attributeName | String | The name of the attribute. The function first queries to get the cluster name using the cluster reference. Then it iterates over each option in the forcedExternal array. If the option's category matches the cluster name and the option's label matches the attribute name, it updates the storage policy to attributeAccessInterface. Finally, it returns the updated storage policy. | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## computeStorageImport(db, clusterName, storagePolicy, forcedExternal, attributeName) + -This asynchronous function computes and returns the updated storage import policy. +### Loader API: Loader APIs~processBitmapsFromAtomics(db, filePath, packageId, data) ⇒ +Processes the bitmaps. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -| Param | Type | Description | -| -------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| db | Object | The database instance. | -| clusterName | String | The name of the cluster. | -| storagePolicy | String | The current storage policy. | -| forcedExternal | Array | An array of external options. | -| attributeName | String | The name of the attribute. The function first initializes the updatedStoragePolicy with the current storage policy. Then it iterates over each option in the forcedExternal array. If the option's category matches the cluster name and the option's label matches the attribute name, it updates the updatedStoragePolicy to attributeAccessInterface and stops the iteration. Finally, it returns the updated storage policy. | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - + -## socketPath() +### Loader API: Loader APIs~loadZclData(db, ctx) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -Returns the socket path for the IPC. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -**Kind**: global function - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## preHandler() + -Runs just before every time IPC request is processed. +### Loader API: Loader APIs~loadIndividualDotDotFile(db, filePath) ⇒ \* +TODO This is not supported at this time. -**Kind**: global function - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: \* - object w/ following: { packageId: pkgId } or { err: err } -## initServer(options) +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | -IPC initialization. + -**Kind**: global function -**Parem**: \* isServer 'true' if this is a server, 'false' for client. +### Loader API: Loader APIs~loadToplevelXmlFile(db, ctx) ⇒ +Toplevel function that loads the xml library file +and orchestrates the promise chain. -| Param | Type | -| ------- | --------------- | -| options | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | Context of loading. | -## isServerRunning() ⇒ + -Returns true if server is running. +### Loader API: Loader APIs~parseNewXmlFiles(db, packageId, files, context) ⇒ +Parses the new XML files. Returns an object containing +loaded data: + clusterIdsLoaded: array of cluster ids that were loaded -**Kind**: global function -**Returns**: true if server is running. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the new XML data is loaded. -## shutdownServerSync(isServer) +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | +| context | \* | -Shuts down the IPC server. + -**Kind**: global function +### Loader API: Loader APIs~prepXmlFeature(f) ⇒ +Prepare features from xml. -| Param | Type | -| -------- | --------------- | -| isServer | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature information - +| Param | Type | +| --- | --- | +| f | \* | -## createOrShowAboutWindow(port) + -Call this function to create a new or show an existing preference window. +### Loader API: Loader APIs~prepXmlAttribute(a) ⇒ +Prepare attributes from xml. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: attribute information -| Param | Type | -| ----- | --------------- | -| port | \* | +| Param | Type | +| --- | --- | +| a | \* | - + -## hookMainInstanceEvents() +### Loader API: Loader APIs~prepXmlCommand(c) ⇒ +Prepare commands from xml. -Hook up all the events for the electron app object. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: command information -**Kind**: global function - +| Param | Type | +| --- | --- | +| c | \* | -## doOpen(menuItem, browserWindow, event) + -Perform a file->open operation. +### Loader API: Loader APIs~prepXmlEvent(e) ⇒ +Prepare events from xml -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: event information -| Param | Type | -| ------------- | --------------- | -| menuItem | \* | -| browserWindow | \* | -| event | \* | +| Param | Type | +| --- | --- | +| e | \* | - + -## doSave(browserWindow) +### Loader API: Loader APIs~parseSingleNewXmlFile(f) ⇒ +Parse xml file. -Perform a save, defering to save as if file is not yet selected. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: xml information from file -**Kind**: global function +| Param | Type | +| --- | --- | +| f | \* | -| Param | Type | -| ------------- | --------------- | -| browserWindow | \* | + - +### Loader API: Loader APIs~collectDataFromJsonFile(ctx) ⇒ +Promises to read the JSON file and resolve all the data. -## doSaveAs(menuItem, browserWindow, event) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved file. -Perform save as. +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context containing information about the file | -**Kind**: global function + -| Param | Type | -| ------------- | --------------- | -| menuItem | \* | -| browserWindow | \* | -| event | \* | +### Loader API: Loader APIs~collectDataFromPropertiesFile(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. -## fileSave(db, browserWindow, filePath) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the propertiesFiles and data | -perform the save. + -**Kind**: global function -**Returns**: Promise of saving. +### Loader API: Loader APIs~maskToType(mask) ⇒ +Silabs XML does not carry types with bitmap fields, but dotdot does, so they are in the schema. +Just to put some data in, we differentiate between "bool" and "enum" types here. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| browserWindow | \* | -| filePath | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: bool or corresponding enum - +| Param | Type | +| --- | --- | +| mask | \* | -## fileOpen(db, filePaths) + -Perform the do open action, possibly reading in multiple files. +### Loader API: Loader APIs~prepareAtomic(a) +Prepare atomic to db insertion. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePaths | \* | +| Param | Type | +| --- | --- | +| a | \* | - + -## toggleMenu(port) +### Loader API: Loader APIs~processAtomics(db, filePath, packageId, data) ⇒ +Processes atomic types for DB insertion. -Toggling of menu +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted bitmaps -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | -| ----- | --------------- | -| port | \* | + - +### Loader API: Loader APIs~prepareClusterGlobalAttribute(cluster) ⇒ +Prepares global attribute data. -## initMenu(httpPort) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing the data from XML. -Initial menu show. +| Param | Type | +| --- | --- | +| cluster | \* | -**Kind**: global function + -| Param | Type | -| -------- | --------------- | -| httpPort | \* | +### Loader API: Loader APIs~extractAccessTag(ac) ⇒ +Extract access information - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: access tag information -## showErrorMessage(title, err) +| Param | Type | +| --- | --- | +| ac | \* | -Simple dialog to show error messages from electron renderer scope. + -**Kind**: global function +### Loader API: Loader APIs~extractAccessIntoArray(xmlElement) ⇒ +Extract list of access information -| Param | Type | -| ----- | --------------- | -| title | \* | -| err | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of access information - +| Param | Type | +| --- | --- | +| xmlElement | \* | -## openFileConfiguration(db, filePath, httpPort) + -Process a single file, parsing it in as JSON and then possibly opening -a new window if all is good. +### Loader API: Loader APIs~prepareCluster(cluster) ⇒ +Prepare XML cluster for insertion into the database. +This method can also prepare clusterExtensions. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. -| Param | Type | Description | -| -------- | --------------- | ------------------------------------------------- | -| db | \* | | -| filePath | \* | | -| httpPort | \* | Server port for the URL that will be constructed. | +| Param | Type | +| --- | --- | +| cluster | \* | - + -## openNewConfiguration(httpPort, options:) +### Loader API: Loader APIs~processClusters(db, filePath, packageId, data) ⇒ +Process clusters for insertion into the database. -Creates a new window with a blank configuration. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of cluster insertion. -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | Description | -| -------- | --------------- | ------------------- | -| httpPort | \* | | -| options: | \* | uiMode, debugNavBar | + - +### Loader API: Loader APIs~processClusterGlobalAttributes(db, filePath, packageId, data) ⇒ +Processes global attributes for insertion into the database. -## toggleDirtyFlag(browserWindow, dirty) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted data. -Toggles the dirty flag. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -**Kind**: global function + -| Param | Type | Description | -| ------------- | --------------- | ----------------------------------------------------- | -| browserWindow | \* | window to affect | -| dirty | \* | true if this windows is now dirty, false if otherwise | +### Loader API: Loader APIs~processClusterExtensions(db, filePath, packageId, data) ⇒ +Cluster Extension contains attributes and commands in a same way as regular cluster, +and it has an attribute code="0xXYZ" where code is a cluster code. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the clusterExtension tags -## openFileDialogAndReportResult(browserWindow, options) +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -This function should be invoked as a result of the fileBrowse -notification via the renderer API. It pops the open dialog and -reports result back through the API. + -**Kind**: global function +### Loader API: Loader APIs~processGlobals(db, filePath, packageId, data) ⇒ +Processes the globals in the XML files. The `global` tag contains +attributes and commands in a same way as cluster or clusterExtension -| Param | Type | Description | -| ------------- | --------------- | ------------------------------------- | -| browserWindow | \* | | -| options | \* | 'key', 'title', 'mode', 'defaultPath' | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the globals - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## initializeElectronUi(port) + -Electron UI initialization. +### Loader API: Loader APIs~prepareTag(tag) ⇒ +Prepare tag object from tag -Note: You might be tempted to pass `db` to this function. Don't. -That was done before and it's just a lazy way to cut through the -layers between UI and back-end. Should not be done. Any information -UI needs from the database should be retrieved via renderer API. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: tag information -**Kind**: global function +| Param | Type | +| --- | --- | +| tag | \* | -| Param | Type | -| ----- | --------------- | -| port | \* | + - +### Loader API: Loader APIs~processDefaultAccess(db, filePath, packageId, defaultAccessList) +Process defaultAccess tag in the XML. -## windowCreate(port, filePath, [uiMode]) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -Create a window, possibly with a given file path. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| defaultAccessList | \* | -**Kind**: global function -**Returns**: BrowserWindow that got created + -| Param | Type | Default | -| -------- | --------------- | ------------- | -| port | \* | | -| filePath | \* | | -| [uiMode] | \* | | +### Loader API: Loader APIs~processAccessControl(db, filePath, packageId, accessControlList) +Process accessControl tag in the XML. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## processCommandLineArguments(argv) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| accessControlList | \* | -Process the command line arguments and resets the state in this file -to the specified values. + -**Kind**: global function -**Returns**: parsed argv object +### Loader API: Loader APIs~processTags(db, filePath, packageId, tags) +Processes the tags in the XML. -| Param | Type | -| ----- | --------------- | -| argv | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| tags | \* | -## int8ToHex(value) ⇒ + -Takes an int8 value and turns it into a hex. +### Loader API: Loader APIs~prepareDomain(domain) ⇒ +Convert domain from XMl to domain for DB. -**Kind**: global function -**Returns**: hex string, 2 characters long without '0x' +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Domain object for DB. -| Param | Type | -| ----- | --------------- | -| value | \* | +| Param | Type | +| --- | --- | +| domain | \* | - + -## int16ToHex(value) ⇒ +### Loader API: Loader APIs~processDomains(db, filePath, packageId, data) ⇒ +Process domains for insertion. -Takes an int16 value and turns it into a hex. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of database insertion of domains. -**Kind**: global function -**Returns**: hex string, 4 characters long without '0x' +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -| Param | Type | -| ----- | --------------- | -| value | \* | + - +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ +Prepare Data Type Discriminator for database table insertion. -## int32ToHex(value) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -Takes an int32 value and turns it into a hex. +| Param | Type | +| --- | --- | +| a | \* | -**Kind**: global function -**Returns**: hex string, 8 characters long without '0x' + -| Param | Type | -| ----- | --------------- | -| value | \* | +### Loader API: Loader APIs~processDataTypeDiscriminator(db, filePath, zclDataTypes) ⇒ +Processes Data Type Discriminator. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. -## stringToHex(value) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| zclDataTypes | \* | -Converts a string to the hex value. + -**Kind**: global function -**Returns**: hex string, value.length \* 2 + 2 characters long. It appends the terminating NULL, so 0x00 is at the end. +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ +Prepare Data Types for database table insertion. -| Param | Type | -| ----- | --------------- | -| value | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | -## bitCount(n) ⇒ + -Given a number, this function returns the number of bits set in the number +### Loader API: Loader APIs~processDataType(db, filePath, packageId, knownPackages, data, dataType) ⇒ +Processes Data Type. -**Kind**: global function -**Returns**: number of bits set. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. -| Param | Type | -| ----- | --------------- | -| n | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | +| dataType | \* | - + -## hexToCBytes(value) ⇒ +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ +Prepare numbers for database table insertion. -Takes the raw hex string, such as `abcd` and -converts it into a C constant array, such as -`0xAB, 0xCD`. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: global function -**Returns**: C byte array +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -| Param | Type | -| ----- | --------------- | -| value | \* | + - +### Loader API: Loader APIs~processNumber(db, filePath, packageId, knownPackages, data) ⇒ +Processes Numbers. -## bitOffset(binary) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. -Getting a binary string ("0001101010010") it returns the number of zero bits at the end. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -**Kind**: global function + -| Param | Type | -| ------ | --------------- | -| binary | \* | +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ +Prepare strings for database table insertion. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -## hexToBinary(hex) +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -Convert a hex number to a binary. Hex has to be in a format -as obtained by intToHex methods above: no '0x' prefix and upper-case -letters, as in "12AB". + -**Kind**: global function +### Loader API: Loader APIs~processString(db, filePath, packageId, knownPackages, data) ⇒ +Processes Strings. -| Param | Type | -| ----- | --------------- | -| hex | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## stringToOneByteLengthPrefixCBytes(value, maxLength, pad) ⇒ + -Returns string as C bytes, prefixed with one-byte length. -If maxLength is greater than length of value, then -the resulting array is padded with 0x00. +### Loader API: Loader APIs~prepareEnumOrBitmapAtomic(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -**Kind**: global function -**Returns**: Object containing 'length' and 'content', where length -is number of bytes used and content is actual content in C format. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | Default | Description | -| --------- | --------------- | ----------------- | -------------------------------------------------- | -| value | \* | | | -| maxLength | \* | | the maximum length of the used memory in bytes | -| pad | \* | true | If true, then pad with 0x00 until maxLength bytes. | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - + -## stringToTwoByteLengthPrefixCBytes(value, maxLength, pad) ⇒ +### Loader API: Loader APIs~processEnumAtomic(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enums. -Returns string as C bytes, prefixed with two-byte length -If maxLength is greater than length of value, then -the resulting array is padded with 0x00. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -**Kind**: global function -**Returns**: Object containing 'length' and 'content', where length -is number of bytes used and content is actual content in C format. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -| Param | Type | Default | Description | -| --------- | --------------- | ----------------- | -------------------------------------------------- | -| value | \* | | | -| maxLength | \* | | the maximum length of the used memory in bytes | -| pad | \* | true | If true, then pad with 0x00 until maxLength bytes. | + - +### Loader API: Loader APIs~prepareEnumOrBitmap(a, dataType) ⇒ +Prepare enums or bitmaps for database table insertion. -## builtinSilabsZclMetafile() ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -**Kind**: global function -**Returns**: path to zcl.json file - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## builtinSilabsZclSpecialMetafile() ⇒ + -Used to retrive zcl-special.json by zcl reload test in zcl-loader.test.js +### Loader API: Loader APIs~processEnum(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enums. -**Kind**: global function -**Returns**: path to zcl-special.json file used by zcl-loader.test.js - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -## builtinSilabsZclGeneralXmlFile() ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -**Kind**: global function -**Returns**: path to general.xml file - + -## builtinSilabsSpecialZclGeneralSpecialXmlFile() ⇒ +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, knownPackages, data) ⇒ +Processes the enum Items. -Used to retrive general-special.xml by zcl reload test in zcl-loader.test.js +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. -**Kind**: global function -**Returns**: path to general-special.xml file used by zcl-loader.test.js - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## setAppDirectory(path) + -Set the state directory. This method is intended to be called -only at the application startup, when CLI args are being parsed. -This method honors '~/' being the first characters in its argument. +### Loader API: Loader APIs~processBitmapAtomic(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmaps. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -| Param | Type | Description | -| ----- | --------------- | ---------------------------------- | -| path | \* | Absolute path. Typically '~/.zap'. | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | - + -## appDirectory() ⇒ +### Loader API: Loader APIs~processBitmap(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmaps. -Returns an app directory. It creates it, if it doesn't exist +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -**Kind**: global function -**Returns**: state directory, which is guaranteed to be already existing - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## zapVersionAsString() + -Returns a version as a single on-line string. +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, knownPackages, data) ⇒ +Processes the bitmap fields. -**Kind**: global function - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. -## locateProjectResource(filePath) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -This function locates a resource in the project, such as various -JSON files and zcl-builtin stuff. + -It needs to adapt to a change in path that can occur when -things are copied into the dist/ directory. +### Loader API: Loader APIs~prepareStruct(a, dataType) ⇒ +Prepare structs for database table insertion. -**Kind**: global function -**Returns**: located project resource +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | -| -------- | -| filePath | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - + -## zapVersion() ⇒ +### Loader API: Loader APIs~processStruct(db, filePath, packageId, knownPackages, data) ⇒ +Processes the structs. -Returns the zap version. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. -**Kind**: global function -**Returns**: zap version, which is an object that -contains 'version', 'featureLevel', 'hash', 'timestamp' and 'date' - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## printToStderr(msg) + -Prints the data to stderr, without much fuss. +### Loader API: Loader APIs~processStructItems(db, filePath, packageIds, data) ⇒ +Processes the struct Items. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. -| Param | -| ----- | -| msg | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageIds | \* | +| data | \* | - + -## log(level, msg, err) +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ Object +Prepares a device type object by extracting and transforming its properties. -Base level common logger. +This function takes a device type object and processes its properties to create +a new object with a specific structure. It handles various properties such as +device ID, profile ID, domain, name, description, class, scope, and superset. +Additionally, it processes endpoint compositions and clusters if they exist. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object - The prepared device type object with transformed properties. -| Param | Type | -| ----- | --------------- | -| level | \* | -| msg | \* | -| err | \* | +| Param | Type | Description | +| --- | --- | --- | +| deviceType | Object | The device type object to be prepared. | - + + +### Loader API: Loader APIs~processDeviceTypes(db, filePath, packageId, data, context) ⇒ Promise +Processes and inserts device types into the database. +This function logs the number of device types being processed for debugging purposes. +It maps over the provided data to prepare each device type and then iterates over each prepared device type. +If a device type has a compositionType, it inserts the endpoint composition into the database, +retrieves the endpoint composition ID, and then inserts the device composition. +Finally, it inserts all prepared device types into the database. -## logInfo(msg, err) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise - A promise that resolves after all device types have been inserted into the database. -Info level message. +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| filePath | string | The file path from which the device types are being processed. | +| packageId | \* | The package ID associated with the device types. | +| data | Array | The array of device types to be processed. | +| context | \* | Additional context that might be required for processing. | -**Kind**: global function + -| Param | Type | -| ----- | --------------- | -| msg | \* | -| err | \* | +### Loader API: Loader APIs~processParsedZclData(db, argument) ⇒ +After XML parser is done with the barebones parsing, this function +branches the individual toplevel tags. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise that resolves when all the subtags are parsed. -## logError(msg, err) +| Param | Type | +| --- | --- | +| db | \* | +| argument | \* | -Error level message. + -**Kind**: global function +### Loader API: Loader APIs~parseSingleZclFile(db, packageId, file) ⇒ +This function is used for parsing each individual ZCL file at a grouped zcl file package level. +This should _not_ be used for custom XML addition due to custom xmls potentially relying on existing packges. -| Param | Type | -| ----- | --------------- | -| msg | \* | -| err | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise for when the last stage of the loading pipeline finishes. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| file | \* | -## logWarning(msg, err) + -Warning level message. +### Loader API: Loader APIs~isCrcMismatchOrPackageDoesNotExist(db, packageId, files) ⇒ +Checks if there is a crc mismatch on any xml file. This can be used to +decide if there is a need to reload all the xml files. Also check if the +package is not loaded before. + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: the status of crc mismatch and whether a package is present in an +object -**Kind**: global function +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | -| Param | Type | -| ----- | --------------- | -| msg | \* | -| err | \* | + - +### Loader API: Loader APIs~parseZclFiles(db, packageId, zclFiles, context) ⇒ +Promises to iterate over all the XML files and returns an aggregate promise +that will be resolved when all the XML files are done, or rejected if at least one fails. -## logSql(msg, err) +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -Sql level message. +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclFiles | \* | +| context | \* | -**Kind**: global function + -| Param | Type | -| ----- | --------------- | -| msg | \* | -| err | \* | +### Loader API: Loader APIs~parseManufacturerData(db, ctx) ⇒ +Parses the manufacturers xml. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed manufacturers file. -## logBrowser(msg, err) +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -Browser level message. + -**Kind**: global function +### Loader API: Loader APIs~parseProfilesData(db, ctx) ⇒ +Parses the profiles xml. -| Param | Type | -| ----- | --------------- | -| msg | \* | -| err | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed profiles file. - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## logIpc(msg, err) + -IPC level message. +### Loader API: Loader APIs~parseFeatureFlags(db, packageId, featureFlags) ⇒ +Inside the `zcl.json` can be a `featureFlags` key, which is +a general purpose object. It contains keys, that map to objects. +Each key is a "package option category". +Key/velues of the object itself, end up in CODE/LABEL combinations. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of feature flags + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | + + + +### Loader API: Loader APIs~parseFeatureConformance(operand) ⇒ +Parses feature conformance or an operand in feature conformance recursively from xml data. + +An example of parsing the conformance of 'User' device type feature: + +Input operand from xml data: +{ + "$": {"code": "USR", "name": "User"}, + "mandatoryConform": [ + { "andTerm": [ + { + "condition": [{"$": {"name": "Matter"}}], + "orTerm": [ + { "feature": [ + { "$": {"name": "PIN"}}, + { "$": {"name": "RID"}}, + { "$": {"name": "FPG"}}, + { "$": {"name": "FACE"}} + ] + } + ] + } + ] + } + ] +} + +Output device type feature conformance string: + "Matter & (PIN | RID | FPG | FACE)" + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: The feature conformance string. + +| Param | Type | Description | +| --- | --- | --- | +| operand | \* | The operand to be parsed. | + + + +### Loader API: Loader APIs~parseAndOrConformanceTerms(operand, joinChar) ⇒ +Helper function to parse andTerm or orTerm from xml data + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature conformance string + +| Param | Type | +| --- | --- | +| operand | \* | +| joinChar | \* | + + + +### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒ +Inside the `zcl.json` can be a `featureFlags` key, which is +a general purpose object. It contains keys, that map to objects. +Each key is a "package option category". +Key/velues of the object itself, end up in CODE/LABEL combinations. -| Param | Type | -| ----- | --------------- | -| msg | \* | -| err | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that loads the uiOptions object into the database. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | -## logDebug(msg, err) + -Debug level message. +### Loader API: Loader APIs~parseOptions(db) ⇒ +Parses and loads the text and boolean options. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise of parsed options -| Param | Type | -| ----- | --------------- | -| msg | \* | -| err | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -## versionsCheck() ⇒ +### Loader API: Loader APIs~parseTextOptions(db, pkgRef, textOptions) ⇒ +Parses the text options. -Returns true if versions of node and electron are matching. -If versions are not matching, it prints out a warhing -and returns false. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed text options. -**Kind**: global function -**Returns**: true or false, depending on match - +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textOptions | \* | -## httpStaticContent() ⇒ + -Returns path to HTTP static content while taking into account DEV / PROD modes. +### Loader API: Loader APIs~parseBoolOptions(db, pkgRef, booleanCategories) ⇒ +Parses the boolean options. -**Kind**: global function -**Returns**: full path to HTTP static content - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed boolean options. -## availableClusters(context) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | -Returns all available clusters. + -**Kind**: global function -**Returns**: all available clusters +### Loader API: Loader APIs~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes) ⇒ Promise.<void> +Asynchronously parses and inserts attribute access interface attributes into the database. +This function iterates over the attributeAccessInterfaceAttributes object, processing each cluster +by mapping its values to a specific structure and then inserting them into the database using +the insertOptionsKeyValues function. -| Param | Type | -| ------- | --------------- | -| context | \* | +The main purpose of this function is to store cluster/attribute pairs including global attributes and their cluster pair +The ATTRIBUTE table has cluster_ref as null for global attributes so this second method was necessary - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise.<void> - A promise that resolves when all attributes have been processed and inserted. -## availableEvents(context) ⇒ +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| pkgRef | \* | The package reference id for which the attributes are being parsed. | +| attributeAccessInterfaceAttributes | \* | An object containing the attribute access interface attributes, structured by cluster. | -Returns all available events. + -**Kind**: global function -**Returns**: all available events +### Loader API: Loader APIs~parseDefaults(db, ctx) ⇒ +Parses the default values inside the options. -| Param | Type | -| ------- | --------------- | -| context | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promised of parsed text and bool defaults. - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## availableCommands(context) ⇒ + -Returns all available commands. +### Loader API: Loader APIs~parseTextDefaults(db, pkgRef, textDefaults) ⇒ +Parse text defaults from default options. -**Kind**: global function -**Returns**: all available ccommands +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of promises -| Param | Type | -| ------- | --------------- | -| context | \* | +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textDefaults | \* | - + -## availableAttributes(context) ⇒ +### Loader API: Loader APIs~parseBoolDefaults(db, pkgRef, booleanCategories) ⇒ +Parse the boolean defaults inside options. -Returns all available attributes. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: List of promises -**Kind**: global function -**Returns**: all available attributes +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | -| Param | Type | -| ------- | --------------- | -| context | \* | + - +### Loader API: Loader APIs~loadIndividualSilabsFile(db, filePath) ⇒ +Parses a single file. This function is used specifically +for adding a package through an existing session because of its reliance +on relating the new XML content to the packages associated with that session. +e.g. for ClusterExtensions. -## helperWrapper(wrappedHelper) ⇒ function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a loaded file. -Wraps a helper function to add usage tracking and error handling. +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | -**Kind**: global function -**Returns**: function - - The wrapped helper function. + -| Param | Type | Description | -| ------------- | --------------------- | ---------------------------- | -| wrappedHelper | function | The helper function to wrap. | +### Loader API: Loader APIs~processCustomZclDeviceType(db, ctx) ⇒ +If custom device is supported, then this method creates it. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: context -## registerHelpers(singleHelper, registerHelper, context) +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -Registers a helper function. + -**Kind**: global function +### Loader API: Loader APIs~loadZclJson(db, metafile) ⇒ +Load ZCL metadata -| Param | Type | Description | -| -------------- | --------------------- | -------------------------------- | -| singleHelper | string | The name of the helper function. | -| registerHelper | function | The helper function to register. | -| context | Object | The context object. | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl json file - +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | -## executeHelperFunction(functionName, context, helper) ⇒ Promise + -Executes a helper function from a script file. +### Loader API: Loader APIs~loadZclProperties(db, metafile) ⇒ +Load ZCL metadata -**Kind**: global function -**Returns**: Promise - - A Promise that resolves with the result of the helper function. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl properties file -| Param | Type | Description | -| ------------ | ------------------- | ------------------------------------------------------------ | -| functionName | string | The name of the helper function to execute. | -| context | Object | The context object to pass to the helper function. | -| helper | string | The path to the helper file containing the helper functions. | +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | - + -## all_user_cluster_commands_helper() +### Loader API: Loader APIs~loadZclJsonOrProperties(db, ctx) ⇒ +Toplevel function that loads the toplevel metafile +and orchestrates the promise chain. -Helper for add_user_cluster_commands that does all the work except the -collectBlocks. This allows other iterators to further filter the list -before doing collectBlocks. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. -**Kind**: global function - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | The context of loading. | -## executeScriptFunction(functionName, db, sessionId, script) + -Executes a named function from a given script. -Arguments passed to the function are: -api: which is the result of require('script-api.js') -context: which contains 'db', 'sessionId', etc. +### Loader API: Loader APIs~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync) ⇒ +Records the toplevel package information and resolves into packageId -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: packageId -| Param | Type | -| ------------ | --------------- | -| functionName | \* | -| db | \* | -| sessionId | \* | -| script | \* | +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| crc | \* | +| isTopLevelPackageInSync | \* | - + -## projectName(db, sessionId) ⇒ +### Loader API: Loader APIs~recordVersion(db, ctx) +Records the version into the database. -Extract project name from the Studio project path +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -**Kind**: global function -**Returns**: '' if parsing fails +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -| Param | Type | -| --------- | --------------- | -| db | | -| sessionId | \* | + - +### Loader API: Loader APIs~loadZclMetaFilesCommon(db, metadataFile, options) ⇒ +Retrieve zcl package information -## initAsyncValidation() +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: package zcl package information -Start session specific validation. +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| options | \* | -**Kind**: global function - + -## validateAttribute(db, endpointTypeId, attributeRef, clusterRef, zapSessionId) ⇒ +### Loader API: Loader APIs~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap) +Load attribute mapping table if there is multi-protocol information from a json file. -Main attribute validation function. -Returns a promise of an object which stores a list of validational issues. -Such issues as "Invalid type" or "Out of Range". +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -**Kind**: global function -**Returns**: Promise of the list of issues +| Param | Type | +| --- | --- | +| db | \* | +| multiProtcolInfo | \* | +| categoryToPackageIdMap | \* | -| Param | Type | Description | -| -------------- | --------------- | ------------------- | -| db | \* | db reference | -| endpointTypeId | \* | endpoint reference | -| attributeRef | \* | attribute reference | -| clusterRef | \* | cluster reference | -| zapSessionId | \* | session reference | + - +### Loader API: Loader APIs~loadZclMetafiles(db, metadataFile) ⇒ +Toplevel function that loads the zcl file and passes it off to the correct zcl loader. -## validateSpecificAttribute(endpointAttribute, attribute, db, zapSessionId) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of loaded packageIds. -Checks the attributes type then validates the incoming input string. +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| metadataFile | \* | array of paths | -**Kind**: global function -**Returns**: List of issues wrapped in an object + -| Param | Type | -| ----------------- | --------------- | -| endpointAttribute | \* | -| attribute | \* | -| db | \* | -| zapSessionId | \* | +### Loader API: Loader APIs~loadZcl(db, metadataFile) ⇒ +Loads individual zcl.json metafile. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Context object that contains .db and .packageId -## extractIntegerValue(value) ⇒ +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | -Expects a number string , parse it back on a default base 10 if its a decimal. -If its a hexadecimal or anything else , parse it back on base 16. -Loses precision after javascripts Number.MAX_SAFE_INTEGER range. + -**Kind**: global function -**Returns**: A decimal number +### Loader API: Loader APIs~loadIndividualFile(db, filePath, sessionId) +Load individual custom XML files. -| Param | Type | -| ----- | --------------- | -| value | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| filePath | \* | | +| sessionId | \* | Current session within which we're loading this file. | -## unsignedToSignedInteger(value, typeSize) ⇒ + -Converts an unsigned integer to its signed value. Returns the same integer if its not a signed type. -Works for both BigInts and regular numbers. +### Loader API: Loader APIs~qualifyZclFile(db, info, parentPackageId, isCustom) ⇒ +Promises to qualify whether zcl file needs to be reloaded. +If yes, the it will resolve with {filePath, data, packageId} +If not, then it will resolve with {error} -**Kind**: global function -**Returns**: A decimal number +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves int he object of data. -| Param | Type | Description | -| -------- | --------------- | ------------------ | -| value | \* | integer to convert | -| typeSize | \* | bit representation | +| Param | Type | +| --- | --- | +| db | \* | +| info | \* | +| parentPackageId | \* | +| isCustom | \* | - + -## getIntegerFromAttribute(attribute, typeSize, isSigned) ⇒ +### Loader API: Loader APIs~processZclPostLoading(db) ⇒ +Promises to perform a post loading step. -Converts an attribute (number string) into a decimal number without losing precision. -Accepts both decimal and hexadecimal strings (former has priority) in any bit representation. -Shifts signed hexadecimals to their correct value. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise to deal with the post-loading cleanup. + +| Param | Type | +| --- | --- | +| db | \* | + + + +### Loader API: Loader APIs~getDiscriminatorMap(db, packageIds) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: data type discriminator map + +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | + + + +## Loader API: Loader APIs +This module provides the APIs for for common functionality related to loading. + + +* [Loader API: Loader APIs](#module_Loader API_ Loader APIs) + * [~collectDataFromLibraryXml(ctx)](#module_Loader API_ Loader APIs..collectDataFromLibraryXml) ⇒ + * [~tagContainsEnum(tag)](#module_Loader API_ Loader APIs..tagContainsEnum) ⇒ + * [~tagContainsStruct(tag)](#module_Loader API_ Loader APIs..tagContainsStruct) ⇒ + * [~tagContainsBitmap(tag)](#module_Loader API_ Loader APIs..tagContainsBitmap) ⇒ + * [~parseSingleZclFile(db, ctx, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~parseZclFiles(db, ctx)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~normalizeHexValue(value)](#module_Loader API_ Loader APIs..normalizeHexValue) ⇒ + * [~getNumBytesFromShortName(value)](#module_Loader API_ Loader APIs..getNumBytesFromShortName) ⇒ + * [~prepareAttributes(attributes, side)](#module_Loader API_ Loader APIs..prepareAttributes) ⇒ + * [~prepareCommands(commands, side, types)](#module_Loader API_ Loader APIs..prepareCommands) ⇒ + * [~prepareCluster(cluster, isExtension, types)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~prepareAtomic(type)](#module_Loader API_ Loader APIs..prepareAtomic) ⇒ + * [~prepareBitmap(type, isContained)](#module_Loader API_ Loader APIs..prepareBitmap) ⇒ + * [~prepareEnum(type)](#module_Loader API_ Loader APIs..prepareEnum) ⇒ + * [~prepareStruct(type)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~prepareTypes(zclTypes, types)](#module_Loader API_ Loader APIs..prepareTypes) + * [~prepareAttributeType(attribute, types, cluster)](#module_Loader API_ Loader APIs..prepareAttributeType) + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, packageId, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumsOrBitmaps(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmaps) ⇒ + * [~processEnums(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnums) ⇒ + * [~processEnumItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmaps(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmaps) ⇒ + * [~processBitmapFields(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct2(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct2) ⇒ + * [~processStruct(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareEnumsOrBitmapsAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumsOrBitmapsAtomic) ⇒ + * [~processEnumsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processEnumsFromAtomics) ⇒ + * [~processBitmapsFromAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processBitmapsFromAtomics) ⇒ + * [~loadZclData(db, ctx)](#module_Loader API_ Loader APIs..loadZclData) ⇒ + * [~loadIndividualDotDotFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualDotDotFile) ⇒ \* + * [~loadToplevelXmlFile(db, ctx)](#module_Loader API_ Loader APIs..loadToplevelXmlFile) ⇒ + * [~parseNewXmlFiles(db, packageId, files, context)](#module_Loader API_ Loader APIs..parseNewXmlFiles) ⇒ + * [~prepXmlFeature(f)](#module_Loader API_ Loader APIs..prepXmlFeature) ⇒ + * [~prepXmlAttribute(a)](#module_Loader API_ Loader APIs..prepXmlAttribute) ⇒ + * [~prepXmlCommand(c)](#module_Loader API_ Loader APIs..prepXmlCommand) ⇒ + * [~prepXmlEvent(e)](#module_Loader API_ Loader APIs..prepXmlEvent) ⇒ + * [~parseSingleNewXmlFile(f)](#module_Loader API_ Loader APIs..parseSingleNewXmlFile) ⇒ + * [~collectDataFromJsonFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromJsonFile) ⇒ + * [~collectDataFromPropertiesFile(ctx)](#module_Loader API_ Loader APIs..collectDataFromPropertiesFile) ⇒ + * [~maskToType(mask)](#module_Loader API_ Loader APIs..maskToType) ⇒ + * [~prepareAtomic(a)](#module_Loader API_ Loader APIs..prepareAtomic) + * [~processAtomics(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processAtomics) ⇒ + * [~prepareClusterGlobalAttribute(cluster)](#module_Loader API_ Loader APIs..prepareClusterGlobalAttribute) ⇒ + * [~extractAccessTag(ac)](#module_Loader API_ Loader APIs..extractAccessTag) ⇒ + * [~extractAccessIntoArray(xmlElement)](#module_Loader API_ Loader APIs..extractAccessIntoArray) ⇒ + * [~prepareCluster(cluster)](#module_Loader API_ Loader APIs..prepareCluster) ⇒ + * [~processClusters(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusters) ⇒ + * [~processClusterGlobalAttributes(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterGlobalAttributes) ⇒ + * [~processClusterExtensions(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processClusterExtensions) ⇒ + * [~processGlobals(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processGlobals) ⇒ + * [~prepareTag(tag)](#module_Loader API_ Loader APIs..prepareTag) ⇒ + * [~processDefaultAccess(db, filePath, packageId, defaultAccessList)](#module_Loader API_ Loader APIs..processDefaultAccess) + * [~processAccessControl(db, filePath, packageId, accessControlList)](#module_Loader API_ Loader APIs..processAccessControl) + * [~processTags(db, filePath, packageId, tags)](#module_Loader API_ Loader APIs..processTags) + * [~prepareDomain(domain)](#module_Loader API_ Loader APIs..prepareDomain) ⇒ + * [~processDomains(db, filePath, packageId, data)](#module_Loader API_ Loader APIs..processDomains) ⇒ + * [~prepareDataTypeDiscriminator(a)](#module_Loader API_ Loader APIs..prepareDataTypeDiscriminator) ⇒ + * [~processDataTypeDiscriminator(db, filePath, zclDataTypes)](#module_Loader API_ Loader APIs..processDataTypeDiscriminator) ⇒ + * [~prepareDataType(a, dataType, typeMap)](#module_Loader API_ Loader APIs..prepareDataType) ⇒ + * [~processDataType(db, filePath, packageId, knownPackages, data, dataType)](#module_Loader API_ Loader APIs..processDataType) ⇒ + * [~prepareNumber(a, dataType)](#module_Loader API_ Loader APIs..prepareNumber) ⇒ + * [~processNumber(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processNumber) ⇒ + * [~prepareString(a, dataType)](#module_Loader API_ Loader APIs..prepareString) ⇒ + * [~processString(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processString) ⇒ + * [~prepareEnumOrBitmapAtomic(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmapAtomic) ⇒ + * [~processEnumAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumAtomic) ⇒ + * [~prepareEnumOrBitmap(a, dataType)](#module_Loader API_ Loader APIs..prepareEnumOrBitmap) ⇒ + * [~processEnum(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnum) ⇒ + * [~processEnumItems(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processEnumItems) ⇒ + * [~processBitmapAtomic(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapAtomic) ⇒ + * [~processBitmap(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmap) ⇒ + * [~processBitmapFields(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processBitmapFields) ⇒ + * [~prepareStruct(a, dataType)](#module_Loader API_ Loader APIs..prepareStruct) ⇒ + * [~processStruct(db, filePath, packageId, knownPackages, data)](#module_Loader API_ Loader APIs..processStruct) ⇒ + * [~processStructItems(db, filePath, packageIds, data)](#module_Loader API_ Loader APIs..processStructItems) ⇒ + * [~prepareDeviceType(deviceType)](#module_Loader API_ Loader APIs..prepareDeviceType) ⇒ Object + * [~processDeviceTypes(db, filePath, packageId, data, context)](#module_Loader API_ Loader APIs..processDeviceTypes) ⇒ Promise + * [~processParsedZclData(db, argument)](#module_Loader API_ Loader APIs..processParsedZclData) ⇒ + * [~parseSingleZclFile(db, packageId, file)](#module_Loader API_ Loader APIs..parseSingleZclFile) ⇒ + * [~isCrcMismatchOrPackageDoesNotExist(db, packageId, files)](#module_Loader API_ Loader APIs..isCrcMismatchOrPackageDoesNotExist) ⇒ + * [~parseZclFiles(db, packageId, zclFiles, context)](#module_Loader API_ Loader APIs..parseZclFiles) ⇒ + * [~parseManufacturerData(db, ctx)](#module_Loader API_ Loader APIs..parseManufacturerData) ⇒ + * [~parseProfilesData(db, ctx)](#module_Loader API_ Loader APIs..parseProfilesData) ⇒ + * [~parseFeatureFlags(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseFeatureFlags) ⇒ + * [~parseFeatureConformance(operand)](#module_Loader API_ Loader APIs..parseFeatureConformance) ⇒ + * [~parseAndOrConformanceTerms(operand, joinChar)](#module_Loader API_ Loader APIs..parseAndOrConformanceTerms) ⇒ + * [~parseUiOptions(db, packageId, featureFlags)](#module_Loader API_ Loader APIs..parseUiOptions) ⇒ + * [~parseOptions(db)](#module_Loader API_ Loader APIs..parseOptions) ⇒ + * [~parseTextOptions(db, pkgRef, textOptions)](#module_Loader API_ Loader APIs..parseTextOptions) ⇒ + * [~parseBoolOptions(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolOptions) ⇒ + * [~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes)](#module_Loader API_ Loader APIs..parseattributeAccessInterfaceAttributes) ⇒ Promise.<void> + * [~parseDefaults(db, ctx)](#module_Loader API_ Loader APIs..parseDefaults) ⇒ + * [~parseTextDefaults(db, pkgRef, textDefaults)](#module_Loader API_ Loader APIs..parseTextDefaults) ⇒ + * [~parseBoolDefaults(db, pkgRef, booleanCategories)](#module_Loader API_ Loader APIs..parseBoolDefaults) ⇒ + * [~loadIndividualSilabsFile(db, filePath)](#module_Loader API_ Loader APIs..loadIndividualSilabsFile) ⇒ + * [~processCustomZclDeviceType(db, ctx)](#module_Loader API_ Loader APIs..processCustomZclDeviceType) ⇒ + * [~loadZclJson(db, metafile)](#module_Loader API_ Loader APIs..loadZclJson) ⇒ + * [~loadZclProperties(db, metafile)](#module_Loader API_ Loader APIs..loadZclProperties) ⇒ + * [~loadZclJsonOrProperties(db, ctx)](#module_Loader API_ Loader APIs..loadZclJsonOrProperties) ⇒ + * [~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync)](#module_Loader API_ Loader APIs..recordToplevelPackage) ⇒ + * [~recordVersion(db, ctx)](#module_Loader API_ Loader APIs..recordVersion) + * [~loadZclMetaFilesCommon(db, metadataFile, options)](#module_Loader API_ Loader APIs..loadZclMetaFilesCommon) ⇒ + * [~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap)](#module_Loader API_ Loader APIs..loadAttributeMappingForMultiProtocol) + * [~loadZclMetafiles(db, metadataFile)](#module_Loader API_ Loader APIs..loadZclMetafiles) ⇒ + * [~loadZcl(db, metadataFile)](#module_Loader API_ Loader APIs..loadZcl) ⇒ + * [~loadIndividualFile(db, filePath, sessionId)](#module_Loader API_ Loader APIs..loadIndividualFile) + * [~qualifyZclFile(db, info, parentPackageId, isCustom)](#module_Loader API_ Loader APIs..qualifyZclFile) ⇒ + * [~processZclPostLoading(db)](#module_Loader API_ Loader APIs..processZclPostLoading) ⇒ + * [~getDiscriminatorMap(db, packageIds)](#module_Loader API_ Loader APIs..getDiscriminatorMap) ⇒ + + + +### Loader API: Loader APIs~collectDataFromLibraryXml(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. -**Kind**: global function -**Returns**: A decimal number +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. -| Param | Type | Description | -| --------- | --------------- | ----------------------- | -| attribute | \* | attribute to convert | -| typeSize | \* | bit representation size | -| isSigned | \* | is type is signed | +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the metadataFiles and data | - + -## getIntegerAttributeSize(db, zapSessionId, attribType) ⇒ \* +### Loader API: Loader APIs~tagContainsEnum(tag) ⇒ +Check if tag contains enum. -Returns information about an integer type. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -**Kind**: global function -**Returns**: \* - { size: bit representation , isSigned: is signed type } +| Param | Type | +| --- | --- | +| tag | \* | -| Param | Type | -| ------------ | --------------- | -| db | \* | -| zapSessionId | \* | -| attribType | \* | + - +### Loader API: Loader APIs~tagContainsStruct(tag) ⇒ +Check if tag contains struct. -## checkAttributeBoundsInteger(attribute, endpointAttribute, db, zapSessionId) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -Checks if the incoming integer is within it's attributes bound while handling signed and unsigned cases. +| Param | Type | +| --- | --- | +| tag | \* | -**Kind**: global function -**Returns**: boolean + -| Param | Type | -| ----------------- | --------------- | -| attribute | \* | -| endpointAttribute | \* | -| db | \* | -| zapSessionId | \* | +### Loader API: Loader APIs~tagContainsBitmap(tag) ⇒ +Check if tag contains Bitmap. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: boolean -## collectDataFromLibraryXml(ctx) ⇒ +| Param | Type | +| --- | --- | +| tag | \* | -Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. + -**Kind**: global function -**Returns**: Promise of resolved files. +### Loader API: Loader APIs~parseSingleZclFile(db, ctx, file) ⇒ +Parses ZCL xml file. -| Param | Type | Description | -| ----- | --------------- | ------------------------------------------------------------------- | -| ctx | \* | Context which contains information about the metadataFiles and data | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: empty array - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | +| file | \* | -## parseZclFiles(db, ctx) ⇒ + +### Loader API: Loader APIs~parseZclFiles(db, ctx) ⇒ Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails. -**Kind**: global function -**Returns**: Promise that resolves when all the individual promises of each file pass. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -| Param | Type | -| ----- | --------------- | -| db | \* | -| ctx | \* | +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | - - -## normalizeHexValue(value) ⇒ + +### Loader API: Loader APIs~normalizeHexValue(value) ⇒ The Dotdot ZCL XML doesn't use the 0x prefix, but it's a nice thing to have and Silabs xml does use this so this helper function normalizes the use of hex TODO: Is this the right thing to do? -**Kind**: global function -**Returns**: Either the normalized hex string (with the 0x prefix) or the original +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Either the normalized hex string (with the 0x prefix) or the original -| Param | Type | Description | -| ----- | --------------- | --------------------------------- | +| Param | Type | Description | +| --- | --- | --- | | value | \* | the string value to be normalized | - - -## getNumBytesFromShortName(value) ⇒ + +### Loader API: Loader APIs~getNumBytesFromShortName(value) ⇒ The Dotdot ZCL XML doesn't have a length but it is embedded in the short name, we can scrape the value to get the size TODO: Is this the right thing to do? -**Kind**: global function -**Returns**: size in bytes or 0 if the # of bytes could not be determined +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: size in bytes or 0 if the # of bytes could not be determined -| Param | Type | Description | -| ----- | --------------- | ------------------------------ | +| Param | Type | Description | +| --- | --- | --- | | value | \* | the string value to be scraped | - - -## prepareAttributes(attributes, side) ⇒ + +### Loader API: Loader APIs~prepareAttributes(attributes, side) ⇒ Prepare XML attributes for entry into the DB -**Kind**: global function -**Returns**: Array containing all data from XML ready to be inserted into the DB. - -| Param | Type | Description | -| ---------- | --------------- | -------------------------------------------------------- | -| attributes | \* | an array of attributes | -| side | \* | the side the attribute is on either "client" or "server" | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted into the DB. - +| Param | Type | Description | +| --- | --- | --- | +| attributes | \* | an array of attributes | +| side | \* | the side the attribute is on either "client" or "server" | -## prepareCommands(commands, side, types) ⇒ + +### Loader API: Loader APIs~prepareCommands(commands, side, types) ⇒ Prepare XML commands for entry into the DB -**Kind**: global function -**Returns**: Array containing all data from XML ready to be inserted in to the DB. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array containing all data from XML ready to be inserted in to the DB. -| Param | Type | Description | -| -------- | --------------- | ------------------------------------------------------------ | -| commands | \* | an array of commands | -| side | \* | the side the command is on either "client" or "server" | -| types | \* | contained for types, where bitmaps are going to be inserted. | +| Param | Type | Description | +| --- | --- | --- | +| commands | \* | an array of commands | +| side | \* | the side the command is on either "client" or "server" | +| types | \* | contained for types, where bitmaps are going to be inserted. | - - -## prepareCluster(cluster, isExtension, types) ⇒ + +### Loader API: Loader APIs~prepareCluster(cluster, isExtension, types) ⇒ Prepare XML cluster for insertion into the database. This method can also prepare clusterExtensions. -**Kind**: global function -**Returns**: Object containing all data from XML. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. -| Param | Type | Default | Description | -| ----------- | --------------- | ------------------ | ------------------------------------------------------------- | -| cluster | \* | | | +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| cluster | \* | | | | isExtension | \* | false | if this is an extension or not (there are none in dotdot xml) | -| types | \* | | types object into which cluster can put types it might have | - - +| types | \* | | types object into which cluster can put types it might have | -## prepareAtomic(type) ⇒ + +### Loader API: Loader APIs~prepareAtomic(type) ⇒ Parses xml type into the atomic object for insertion into the DB -**Kind**: global function -**Returns**: object ready for insertion into the DB +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -| Param | Type | Description | -| ----- | --------------- | ------------------------------------------------------------------- | -| type | \* | an xml object which conforms to the atomic format in the dotdot xml | +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the atomic format in the dotdot xml | - - -## prepareBitmap(type, isContained) ⇒ + +### Loader API: Loader APIs~prepareBitmap(type, isContained) ⇒ Parses xml type into the bitmap object for insertion into the DB -**Kind**: global function -**Returns**: object ready for insertion into the DB - -| Param | Type | Default | Description | -| ----------- | --------------- | ------------------ | ------------------------------------------------------------------- | -| type | \* | | an xml object which conforms to the bitmap format in the dotdot xml | -| isContained | \* | false | a boolean indicating if this is coming from a contained tag or not | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB - +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| type | \* | | an xml object which conforms to the bitmap format in the dotdot xml | +| isContained | \* | false | a boolean indicating if this is coming from a contained tag or not | -## prepareEnum(type) ⇒ + +### Loader API: Loader APIs~prepareEnum(type) ⇒ Parses xml type into the enum object for insertion into the DB -**Kind**: global function -**Returns**: object ready for insertion into the DB +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB -| Param | Type | Description | -| ----- | --------------- | ----------------------------------------------------------------- | -| type | \* | an xml object which conforms to the enum format in the dotdot xml | +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the enum format in the dotdot xml | - - -## prepareStruct(type) ⇒ + +### Loader API: Loader APIs~prepareStruct(type) ⇒ Parses xml type into the struct object for insertion into the DB -**Kind**: global function -**Returns**: object ready for insertion into the DB - -| Param | Type | Description | -| ----- | --------------- | ------------------------------------------------------------------- | -| type | \* | an xml object which conforms to the struct format in the dotdot xml | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: object ready for insertion into the DB - +| Param | Type | Description | +| --- | --- | --- | +| type | \* | an xml object which conforms to the struct format in the dotdot xml | -## prepareTypes(zclTypes, types) + +### Loader API: Loader APIs~prepareTypes(zclTypes, types) Parses xml types into the types object for insertion into the DB -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -| Param | Type | Description | -| -------- | --------------- | --------------------------------------------------------- | -| zclTypes | \* | an array of xml types | -| types | \* | an object which includes arrays for enums, bitmaps etc... | +| Param | Type | Description | +| --- | --- | --- | +| zclTypes | \* | an array of xml types | +| types | \* | an object which includes arrays for enums, bitmaps etc... | - - -## prepareAttributeType(attribute, types, cluster) + +### Loader API: Loader APIs~prepareAttributeType(attribute, types, cluster) Parses xml types into the types object for insertion into the DB -**Kind**: global function - -| Param | Type | Description | -| --------- | --------------- | ------------------------------------------------------------------------------------------ | -| attribute | \* | an attribute with the type in it | -| types | \* | an object which includes arrays for enums, bitmaps etc... | -| cluster | \* | the cluster that the attribute belongs to (used presently for uniqueness of the type name) | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | Description | +| --- | --- | --- | +| attribute | \* | an attribute with the type in it | +| types | \* | an object which includes arrays for enums, bitmaps etc... | +| cluster | \* | the cluster that the attribute belongs to (used presently for uniqueness of the type name) | -## prepareDeviceType(deviceType) ⇒ + +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ Preparation step for the device types. -**Kind**: global function -**Returns**: an object containing the prepared device types. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: an object containing the prepared device types. -| Param | Type | -| ---------- | --------------- | -| deviceType | \* | +| Param | Type | +| --- | --- | +| deviceType | \* | - - -## prepareDataTypeDiscriminator(a) ⇒ + +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ Prepare Data Type Discriminator for database table insertion. -**Kind**: global function -**Returns**: An Object - -| Param | Type | -| ----- | --------------- | -| a | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | -## processDataTypeDiscriminator(db, packageId, zclDataTypes) ⇒ + +### Loader API: Loader APIs~processDataTypeDiscriminator(db, packageId, zclDataTypes) ⇒ Processes Data Type Discriminator. -**Kind**: global function -**Returns**: Promise of inserted Data Type Discriminators. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. -| Param | Type | -| ------------ | --------------- | -| db | \* | -| packageId | \* | -| zclDataTypes | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclDataTypes | \* | - - -## prepareDataType(a, dataType, typeMap) ⇒ + +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ Prepare Data Types for database table insertion. -**Kind**: global function -**Returns**: An Object - -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | -| typeMap | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | -## processDataType(db, filePath, packageId, data, dataType) ⇒ + +### Loader API: Loader APIs~processDataType(db, filePath, packageId, data, dataType) ⇒ Processes Data Type. -**Kind**: global function -**Returns**: Promise of inserted Data Types into the Data Type table. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | -| dataType | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | +| dataType | \* | - - -## prepareNumber(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ Prepare numbers for database table insertion. -**Kind**: global function -**Returns**: An Object - -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## processNumber(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processNumber(db, filePath, packageId, data) ⇒ Processes Numbers. -**Kind**: global function -**Returns**: Promise of inserted numbers into the number table. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## prepareString(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ Prepare strings for database table insertion. -**Kind**: global function -**Returns**: An Object - -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## processString(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processString(db, filePath, packageId, data) ⇒ Processes Strings. -**Kind**: global function -**Returns**: Promise of inserted strings into the String table. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## prepareEnumsOrBitmaps(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareEnumsOrBitmaps(a, dataType) ⇒ Prepare enums or bitmaps for database table insertion. -**Kind**: global function -**Returns**: An Object - -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## processEnums(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processEnums(db, filePath, packageId, data) ⇒ Processes the enums. -**Kind**: global function -**Returns**: A promise of inserted enums. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## processEnumItems(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, data) ⇒ Processes the enum Items. -**Kind**: global function -**Returns**: A promise of inserted enum items. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## processBitmaps(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processBitmaps(db, filePath, packageId, data) ⇒ Processes the bitmaps. -**Kind**: global function -**Returns**: A promise of inserted bitmaps. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## processBitmapFields(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, data) ⇒ Processes the bitmap fields. -**Kind**: global function -**Returns**: A promise of inserted bitmap fields. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## prepareStruct2(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareStruct2(a, dataType) ⇒ Prepare structs for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - - -## processStruct(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processStruct(db, filePath, packageId, data) ⇒ Processes the structs. -**Kind**: global function -**Returns**: A promise of inserted structs. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## processStructItems(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processStructItems(db, filePath, packageId, data) ⇒ Processes the struct Items. -**Kind**: global function -**Returns**: A promise of inserted struct items. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## prepareEnumsOrBitmapsAtomic(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareEnumsOrBitmapsAtomic(a, dataType) ⇒ Prepare enums or bitmaps for database table insertion. -**Kind**: global function -**Returns**: An Object - -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object - +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | -## processEnumsFromAtomics(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processEnumsFromAtomics(db, filePath, packageId, data) ⇒ Processes the enums. -**Kind**: global function -**Returns**: A promise of inserted enums. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## processBitmapsFromAtomics(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processBitmapsFromAtomics(db, filePath, packageId, data) ⇒ Processes the bitmaps. -**Kind**: global function -**Returns**: A promise of inserted bitmaps. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## loadZclData(db, ctx) ⇒ + +### Loader API: Loader APIs~loadZclData(db, ctx) ⇒ Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails. -**Kind**: global function -**Returns**: Promise that resolves when all the individual promises of each file pass. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -| Param | Type | -| ----- | --------------- | -| db | \* | -| ctx | \* | +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | - - -## loadIndividualDotDotFile(db, filePath) ⇒ \* + +### Loader API: Loader APIs~loadIndividualDotDotFile(db, filePath) ⇒ \* TODO This is not supported at this time. -**Kind**: global function -**Returns**: \* - object w/ following: { packageId: pkgId } or { err: err } - -| Param | Type | -| -------- | --------------- | -| db | \* | -| filePath | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: \* - object w/ following: { packageId: pkgId } or { err: err } - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | -## loadToplevelXmlFile(db, ctx) ⇒ + +### Loader API: Loader APIs~loadToplevelXmlFile(db, ctx) ⇒ Toplevel function that loads the xml library file and orchestrates the promise chain. -**Kind**: global function -**Returns**: a Promise that resolves with the db. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. -| Param | Type | Description | -| ----- | --------------- | ------------------- | -| db | \* | | -| ctx | \* | Context of loading. | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | Context of loading. | - - -## parseNewXmlFiles(db, packageId, files, context) ⇒ + +### Loader API: Loader APIs~parseNewXmlFiles(db, packageId, files, context) ⇒ Parses the new XML files. Returns an object containing loaded data: -clusterIdsLoaded: array of cluster ids that were loaded + clusterIdsLoaded: array of cluster ids that were loaded -**Kind**: global function -**Returns**: Promise that resolves when all the new XML data is loaded. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the new XML data is loaded. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| files | \* | -| context | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | +| context | \* | - + -## collectDataFromJsonFile(ctx) ⇒ +### Loader API: Loader APIs~prepXmlFeature(f) ⇒ +Prepare features from xml. -Promises to read the JSON file and resolve all the data. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature information -**Kind**: global function -**Returns**: Promise of resolved file. +| Param | Type | +| --- | --- | +| f | \* | -| Param | Type | Description | -| ----- | --------------- | --------------------------------------------- | -| ctx | \* | Context containing information about the file | + - +### Loader API: Loader APIs~prepXmlAttribute(a) ⇒ +Prepare attributes from xml. -## collectDataFromPropertiesFile(ctx) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: attribute information -Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. +| Param | Type | +| --- | --- | +| a | \* | + + + +### Loader API: Loader APIs~prepXmlCommand(c) ⇒ +Prepare commands from xml. + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: command information + +| Param | Type | +| --- | --- | +| c | \* | + + -**Kind**: global function -**Returns**: Promise of resolved files. +### Loader API: Loader APIs~prepXmlEvent(e) ⇒ +Prepare events from xml -| Param | Type | Description | -| ----- | --------------- | --------------------------------------------------------------------- | -| ctx | \* | Context which contains information about the propertiesFiles and data | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: event information - +| Param | Type | +| --- | --- | +| e | \* | -## maskToType(mask) ⇒ + +### Loader API: Loader APIs~parseSingleNewXmlFile(f) ⇒ +Parse xml file. + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: xml information from file + +| Param | Type | +| --- | --- | +| f | \* | + + + +### Loader API: Loader APIs~collectDataFromJsonFile(ctx) ⇒ +Promises to read the JSON file and resolve all the data. + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved file. + +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context containing information about the file | + + + +### Loader API: Loader APIs~collectDataFromPropertiesFile(ctx) ⇒ +Promises to read the properties file, extract all the actual xml files, and resolve with the array of files. + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of resolved files. + +| Param | Type | Description | +| --- | --- | --- | +| ctx | \* | Context which contains information about the propertiesFiles and data | + + + +### Loader API: Loader APIs~maskToType(mask) ⇒ Silabs XML does not carry types with bitmap fields, but dotdot does, so they are in the schema. Just to put some data in, we differentiate between "bool" and "enum" types here. -**Kind**: global function -**Returns**: bool or corresponding enum +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: bool or corresponding enum -| Param | Type | -| ----- | --------------- | -| mask | \* | +| Param | Type | +| --- | --- | +| mask | \* | - - -## prepareAtomic(a) + +### Loader API: Loader APIs~prepareAtomic(a) Prepare atomic to db insertion. -**Kind**: global function - -| Param | Type | -| ----- | --------------- | -| a | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| a | \* | -## processAtomics(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processAtomics(db, filePath, packageId, data) ⇒ Processes atomic types for DB insertion. -**Kind**: global function -**Returns**: Promise of inserted bitmaps +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted bitmaps -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## prepareClusterGlobalAttribute(cluster) ⇒ + +### Loader API: Loader APIs~prepareClusterGlobalAttribute(cluster) ⇒ Prepares global attribute data. -**Kind**: global function -**Returns**: Object containing the data from XML. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing the data from XML. + +| Param | Type | +| --- | --- | +| cluster | \* | + + + +### Loader API: Loader APIs~extractAccessTag(ac) ⇒ +Extract access information + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: access tag information + +| Param | Type | +| --- | --- | +| ac | \* | + + + +### Loader API: Loader APIs~extractAccessIntoArray(xmlElement) ⇒ +Extract list of access information -| Param | Type | -| ------- | --------------- | -| cluster | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of access information - +| Param | Type | +| --- | --- | +| xmlElement | \* | -## prepareCluster(cluster) ⇒ + +### Loader API: Loader APIs~prepareCluster(cluster) ⇒ Prepare XML cluster for insertion into the database. This method can also prepare clusterExtensions. -**Kind**: global function -**Returns**: Object containing all data from XML. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object containing all data from XML. -| Param | Type | -| ------- | --------------- | -| cluster | \* | +| Param | Type | +| --- | --- | +| cluster | \* | - - -## processClusters(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processClusters(db, filePath, packageId, data) ⇒ Process clusters for insertion into the database. -**Kind**: global function -**Returns**: Promise of cluster insertion. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of cluster insertion. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## processClusterGlobalAttributes(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processClusterGlobalAttributes(db, filePath, packageId, data) ⇒ Processes global attributes for insertion into the database. -**Kind**: global function -**Returns**: Promise of inserted data. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted data. -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - - -## processClusterExtensions(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processClusterExtensions(db, filePath, packageId, data) ⇒ Cluster Extension contains attributes and commands in a same way as regular cluster, and it has an attribute code="0xXYZ" where code is a cluster code. -**Kind**: global function -**Returns**: promise to resolve the clusterExtension tags - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the clusterExtension tags - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## processGlobals(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processGlobals(db, filePath, packageId, data) ⇒ Processes the globals in the XML files. The `global` tag contains attributes and commands in a same way as cluster or clusterExtension -**Kind**: global function -**Returns**: promise to resolve the globals +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise to resolve the globals -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | - + -## processDefaultAccess(db, filePath, packageId, defaultAccessList) +### Loader API: Loader APIs~prepareTag(tag) ⇒ +Prepare tag object from tag -Process defaultAccess tag in the XML. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: tag information + +| Param | Type | +| --- | --- | +| tag | \* | -**Kind**: global function + -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| defaultAccessList | \* | +### Loader API: Loader APIs~processDefaultAccess(db, filePath, packageId, defaultAccessList) +Process defaultAccess tag in the XML. - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -## processAccessControl(db, filePath, packageId, accessControlList) +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| defaultAccessList | \* | -Process accessControl tag in the XML. + -**Kind**: global function +### Loader API: Loader APIs~processAccessControl(db, filePath, packageId, accessControlList) +Process accessControl tag in the XML. -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| accessControlList | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| accessControlList | \* | -## processTags(db, filePath, packageId, tags) + +### Loader API: Loader APIs~processTags(db, filePath, packageId, tags) Processes the tags in the XML. -**Kind**: global function - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| tags | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| tags | \* | -## prepareDomain(domain) ⇒ + +### Loader API: Loader APIs~prepareDomain(domain) ⇒ Convert domain from XMl to domain for DB. -**Kind**: global function -**Returns**: Domain object for DB. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Domain object for DB. -| Param | Type | -| ------ | --------------- | -| domain | \* | +| Param | Type | +| --- | --- | +| domain | \* | - - -## processDomains(db, filePath, packageId, data) ⇒ + +### Loader API: Loader APIs~processDomains(db, filePath, packageId, data) ⇒ Process domains for insertion. -**Kind**: global function -**Returns**: Promise of database insertion of domains. - -| Param | Type | -| --------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of database insertion of domains. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| data | \* | -## prepareDataTypeDiscriminator(a) ⇒ + +### Loader API: Loader APIs~prepareDataTypeDiscriminator(a) ⇒ Prepare Data Type Discriminator for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| ----- | --------------- | -| a | \* | +| Param | Type | +| --- | --- | +| a | \* | - - -## processDataTypeDiscriminator(db, filePath, zclDataTypes) ⇒ + +### Loader API: Loader APIs~processDataTypeDiscriminator(db, filePath, zclDataTypes) ⇒ Processes Data Type Discriminator. -**Kind**: global function -**Returns**: Promise of inserted Data Type Discriminators. - -| Param | Type | -| ------------ | --------------- | -| db | \* | -| filePath | \* | -| zclDataTypes | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Type Discriminators. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| zclDataTypes | \* | -## prepareDataType(a, dataType, typeMap) ⇒ + +### Loader API: Loader APIs~prepareDataType(a, dataType, typeMap) ⇒ Prepare Data Types for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | -| typeMap | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | +| typeMap | \* | - - -## processDataType(db, filePath, packageId, knownPackages, data, dataType) ⇒ + +### Loader API: Loader APIs~processDataType(db, filePath, packageId, knownPackages, data, dataType) ⇒ Processes Data Type. -**Kind**: global function -**Returns**: Promise of inserted Data Types into the Data Type table. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | -| dataType | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted Data Types into the Data Type table. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | +| dataType | \* | -## prepareNumber(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareNumber(a, dataType) ⇒ Prepare numbers for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - - -## processNumber(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processNumber(db, filePath, packageId, knownPackages, data) ⇒ Processes Numbers. -**Kind**: global function -**Returns**: Promise of inserted numbers into the number table. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted numbers into the number table. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## prepareString(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareString(a, dataType) ⇒ Prepare strings for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - - -## processString(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processString(db, filePath, packageId, knownPackages, data) ⇒ Processes Strings. -**Kind**: global function -**Returns**: Promise of inserted strings into the String table. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of inserted strings into the String table. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## prepareEnumOrBitmapAtomic(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareEnumOrBitmapAtomic(a, dataType) ⇒ Prepare enums or bitmaps for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - - -## processEnumAtomic(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processEnumAtomic(db, filePath, packageId, knownPackages, data) ⇒ Processes the enums. -**Kind**: global function -**Returns**: A promise of inserted enums. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## prepareEnumOrBitmap(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareEnumOrBitmap(a, dataType) ⇒ Prepare enums or bitmaps for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - - -## processEnum(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processEnum(db, filePath, packageId, knownPackages, data) ⇒ Processes the enums. -**Kind**: global function -**Returns**: A promise of inserted enums. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enums. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## processEnumItems(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processEnumItems(db, filePath, packageId, knownPackages, data) ⇒ Processes the enum Items. -**Kind**: global function -**Returns**: A promise of inserted enum items. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted enum items. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | - - -## processBitmapAtomic(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processBitmapAtomic(db, filePath, packageId, knownPackages, data) ⇒ Processes the bitmaps. -**Kind**: global function -**Returns**: A promise of inserted bitmaps. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## processBitmap(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processBitmap(db, filePath, packageId, knownPackages, data) ⇒ Processes the bitmaps. -**Kind**: global function -**Returns**: A promise of inserted bitmaps. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmaps. -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | - - -## processBitmapFields(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processBitmapFields(db, filePath, packageId, knownPackages, data) ⇒ Processes the bitmap fields. -**Kind**: global function -**Returns**: A promise of inserted bitmap fields. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted bitmap fields. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## prepareStruct(a, dataType) ⇒ + +### Loader API: Loader APIs~prepareStruct(a, dataType) ⇒ Prepare structs for database table insertion. -**Kind**: global function -**Returns**: An Object +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: An Object -| Param | Type | -| -------- | --------------- | -| a | \* | -| dataType | \* | +| Param | Type | +| --- | --- | +| a | \* | +| dataType | \* | - - -## processStruct(db, filePath, packageId, knownPackages, data) ⇒ + +### Loader API: Loader APIs~processStruct(db, filePath, packageId, knownPackages, data) ⇒ Processes the structs. -**Kind**: global function -**Returns**: A promise of inserted structs. - -| Param | Type | -| ------------- | --------------- | -| db | \* | -| filePath | \* | -| packageId | \* | -| knownPackages | \* | -| data | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted structs. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageId | \* | +| knownPackages | \* | +| data | \* | -## processStructItems(db, filePath, packageIds, data) ⇒ + +### Loader API: Loader APIs~processStructItems(db, filePath, packageIds, data) ⇒ Processes the struct Items. -**Kind**: global function -**Returns**: A promise of inserted struct items. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise of inserted struct items. -| Param | Type | -| ---------- | --------------- | -| db | \* | -| filePath | \* | -| packageIds | \* | -| data | \* | +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | +| packageIds | \* | +| data | \* | - + -## prepareDeviceType(deviceType) ⇒ - -Preparation step for the device types. +### Loader API: Loader APIs~prepareDeviceType(deviceType) ⇒ Object +Prepares a device type object by extracting and transforming its properties. -**Kind**: global function -**Returns**: an object containing the prepared device types. +This function takes a device type object and processes its properties to create +a new object with a specific structure. It handles various properties such as +device ID, profile ID, domain, name, description, class, scope, and superset. +Additionally, it processes endpoint compositions and clusters if they exist. -| Param | Type | -| ---------- | --------------- | -| deviceType | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Object - The prepared device type object with transformed properties. - +| Param | Type | Description | +| --- | --- | --- | +| deviceType | Object | The device type object to be prepared. | -## processDeviceTypes(db, filePath, packageId, data, context) ⇒ Promise + +### Loader API: Loader APIs~processDeviceTypes(db, filePath, packageId, data, context) ⇒ Promise Processes and inserts device types into the database. This function logs the number of device types being processed for debugging purposes. It maps over the provided data to prepare each device type and then iterates over each prepared device type. @@ -20728,194 +26307,234 @@ If a device type has a compositionType, it inserts the endpoint composition into retrieves the endpoint composition ID, and then inserts the device composition. Finally, it inserts all prepared device types into the database. -**Kind**: global function -**Returns**: Promise - A promise that resolves after all device types have been inserted into the database. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise - A promise that resolves after all device types have been inserted into the database. -| Param | Type | Description | -| --------- | ------------------- | -------------------------------------------------------------- | -| db | \* | The database connection object. | -| filePath | string | The file path from which the device types are being processed. | -| packageId | \* | The package ID associated with the device types. | -| data | Array | The array of device types to be processed. | -| context | \* | Additional context that might be required for processing. | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| filePath | string | The file path from which the device types are being processed. | +| packageId | \* | The package ID associated with the device types. | +| data | Array | The array of device types to be processed. | +| context | \* | Additional context that might be required for processing. | - - -## processParsedZclData(db, argument) ⇒ + +### Loader API: Loader APIs~processParsedZclData(db, argument) ⇒ After XML parser is done with the barebones parsing, this function branches the individual toplevel tags. -**Kind**: global function -**Returns**: promise that resolves when all the subtags are parsed. - -| Param | Type | -| -------- | --------------- | -| db | \* | -| argument | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise that resolves when all the subtags are parsed. - +| Param | Type | +| --- | --- | +| db | \* | +| argument | \* | -## parseSingleZclFile(db, packageId, file) ⇒ + +### Loader API: Loader APIs~parseSingleZclFile(db, packageId, file) ⇒ This function is used for parsing each individual ZCL file at a grouped zcl file package level. This should _not_ be used for custom XML addition due to custom xmls potentially relying on existing packges. -**Kind**: global function -**Returns**: A promise for when the last stage of the loading pipeline finishes. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: A promise for when the last stage of the loading pipeline finishes. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| file | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| file | \* | - - -## isCrcMismatchOrPackageDoesNotExist(db, packageId, files) ⇒ + +### Loader API: Loader APIs~isCrcMismatchOrPackageDoesNotExist(db, packageId, files) ⇒ Checks if there is a crc mismatch on any xml file. This can be used to decide if there is a need to reload all the xml files. Also check if the package is not loaded before. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) **Returns**: the status of crc mismatch and whether a package is present in an -object - -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| files | \* | +object - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| files | \* | -## parseZclFiles(db, packageId, zclFiles, context) ⇒ + +### Loader API: Loader APIs~parseZclFiles(db, packageId, zclFiles, context) ⇒ Promises to iterate over all the XML files and returns an aggregate promise that will be resolved when all the XML files are done, or rejected if at least one fails. -**Kind**: global function -**Returns**: Promise that resolves when all the individual promises of each file pass. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves when all the individual promises of each file pass. -| Param | Type | -| --------- | --------------- | -| db | \* | -| packageId | \* | -| zclFiles | \* | -| context | \* | +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| zclFiles | \* | +| context | \* | - - -## parseManufacturerData(db, ctx) ⇒ + +### Loader API: Loader APIs~parseManufacturerData(db, ctx) ⇒ Parses the manufacturers xml. -**Kind**: global function -**Returns**: Promise of a parsed manufacturers file. - -| Param | Type | -| ----- | --------------- | -| db | \* | -| ctx | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed manufacturers file. - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## parseProfilesData(db, ctx) ⇒ + +### Loader API: Loader APIs~parseProfilesData(db, ctx) ⇒ Parses the profiles xml. -**Kind**: global function -**Returns**: Promise of a parsed profiles file. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed profiles file. -| Param | Type | -| ----- | --------------- | -| db | \* | -| ctx | \* | +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | - - -## parseFeatureFlags(db, packageId, featureFlags) ⇒ + +### Loader API: Loader APIs~parseFeatureFlags(db, packageId, featureFlags) ⇒ Inside the `zcl.json` can be a `featureFlags` key, which is a general purpose object. It contains keys, that map to objects. Each key is a "package option category". Key/velues of the object itself, end up in CODE/LABEL combinations. -**Kind**: global function -**Returns**: array of feature flags - -| Param | Type | -| ------------ | --------------- | -| db | \* | -| packageId | \* | -| featureFlags | \* | - - - -## parseUiOptions(db, packageId, featureFlags) ⇒ - +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: array of feature flags + +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | + + + +### Loader API: Loader APIs~parseFeatureConformance(operand) ⇒ +Parses feature conformance or an operand in feature conformance recursively from xml data. + +An example of parsing the conformance of 'User' device type feature: + +Input operand from xml data: +{ + "$": {"code": "USR", "name": "User"}, + "mandatoryConform": [ + { "andTerm": [ + { + "condition": [{"$": {"name": "Matter"}}], + "orTerm": [ + { "feature": [ + { "$": {"name": "PIN"}}, + { "$": {"name": "RID"}}, + { "$": {"name": "FPG"}}, + { "$": {"name": "FACE"}} + ] + } + ] + } + ] + } + ] +} + +Output device type feature conformance string: + "Matter & (PIN | RID | FPG | FACE)" + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: The feature conformance string. + +| Param | Type | Description | +| --- | --- | --- | +| operand | \* | The operand to be parsed. | + + + +### Loader API: Loader APIs~parseAndOrConformanceTerms(operand, joinChar) ⇒ +Helper function to parse andTerm or orTerm from xml data + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: feature conformance string + +| Param | Type | +| --- | --- | +| operand | \* | +| joinChar | \* | + + + +### Loader API: Loader APIs~parseUiOptions(db, packageId, featureFlags) ⇒ Inside the `zcl.json` can be a `featureFlags` key, which is a general purpose object. It contains keys, that map to objects. Each key is a "package option category". Key/velues of the object itself, end up in CODE/LABEL combinations. -**Kind**: global function -**Returns**: Promise that loads the uiOptions object into the database. - -| Param | Type | -| ------------ | --------------- | -| db | \* | -| packageId | \* | -| featureFlags | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that loads the uiOptions object into the database. - +| Param | Type | +| --- | --- | +| db | \* | +| packageId | \* | +| featureFlags | \* | -## parseOptions(db) ⇒ + +### Loader API: Loader APIs~parseOptions(db) ⇒ Parses and loads the text and boolean options. -**Kind**: global function -**Returns**: promise of parsed options +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: promise of parsed options -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | - - -## parseTextOptions(db, pkgRef, textOptions) ⇒ + +### Loader API: Loader APIs~parseTextOptions(db, pkgRef, textOptions) ⇒ Parses the text options. -**Kind**: global function -**Returns**: Promise of a parsed text options. - -| Param | Type | -| ----------- | --------------- | -| db | \* | -| pkgRef | \* | -| textOptions | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed text options. - +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textOptions | \* | -## parseBoolOptions(db, pkgRef, booleanCategories) ⇒ + +### Loader API: Loader APIs~parseBoolOptions(db, pkgRef, booleanCategories) ⇒ Parses the boolean options. -**Kind**: global function -**Returns**: Promise of a parsed boolean options. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a parsed boolean options. -| Param | Type | -| ----------------- | --------------- | -| db | \* | -| pkgRef | \* | -| booleanCategories | \* | +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | - - -## parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes) ⇒ Promise.<void> + +### Loader API: Loader APIs~parseattributeAccessInterfaceAttributes(db, pkgRef, attributeAccessInterfaceAttributes) ⇒ Promise.<void> Asynchronously parses and inserts attribute access interface attributes into the database. This function iterates over the attributeAccessInterfaceAttributes object, processing each cluster by mapping its values to a specific structure and then inserting them into the database using @@ -20924,214 +26543,255 @@ the insertOptionsKeyValues function. The main purpose of this function is to store cluster/attribute pairs including global attributes and their cluster pair The ATTRIBUTE table has cluster_ref as null for global attributes so this second method was necessary -**Kind**: global function -**Returns**: Promise.<void> - A promise that resolves when all attributes have been processed and inserted. - -| Param | Type | Description | -| ---------------------------------- | --------------- | -------------------------------------------------------------------------------------- | -| db | \* | The database connection object. | -| pkgRef | \* | The package reference id for which the attributes are being parsed. | -| attributeAccessInterfaceAttributes | \* | An object containing the attribute access interface attributes, structured by cluster. | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise.<void> - A promise that resolves when all attributes have been processed and inserted. - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | The database connection object. | +| pkgRef | \* | The package reference id for which the attributes are being parsed. | +| attributeAccessInterfaceAttributes | \* | An object containing the attribute access interface attributes, structured by cluster. | -## parseDefaults(db, ctx) ⇒ + +### Loader API: Loader APIs~parseDefaults(db, ctx) ⇒ Parses the default values inside the options. -**Kind**: global function -**Returns**: Promised of parsed text and bool defaults. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promised of parsed text and bool defaults. -| Param | Type | -| ----- | --------------- | -| db | \* | -| ctx | \* | +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | - + -## loadIndividualSilabsFile(db, filePath) ⇒ +### Loader API: Loader APIs~parseTextDefaults(db, pkgRef, textDefaults) ⇒ +Parse text defaults from default options. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of promises + +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| textDefaults | \* | + + + +### Loader API: Loader APIs~parseBoolDefaults(db, pkgRef, booleanCategories) ⇒ +Parse the boolean defaults inside options. + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: List of promises + +| Param | Type | +| --- | --- | +| db | \* | +| pkgRef | \* | +| booleanCategories | \* | + + + +### Loader API: Loader APIs~loadIndividualSilabsFile(db, filePath) ⇒ Parses a single file. This function is used specifically for adding a package through an existing session because of its reliance on relating the new XML content to the packages associated with that session. e.g. for ClusterExtensions. -**Kind**: global function -**Returns**: Promise of a loaded file. - -| Param | Type | -| -------- | --------------- | -| db | \* | -| filePath | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of a loaded file. - +| Param | Type | +| --- | --- | +| db | \* | +| filePath | \* | -## processCustomZclDeviceType(db, ctx) ⇒ + +### Loader API: Loader APIs~processCustomZclDeviceType(db, ctx) ⇒ If custom device is supported, then this method creates it. -**Kind**: global function -**Returns**: context +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: context -| Param | Type | -| ----- | --------------- | -| db | \* | -| ctx | \* | +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | - + -## loadZclJsonOrProperties(db, ctx) ⇒ +### Loader API: Loader APIs~loadZclJson(db, metafile) ⇒ +Load ZCL metadata +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl json file + +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | + + + +### Loader API: Loader APIs~loadZclProperties(db, metafile) ⇒ +Load ZCL metadata + +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise of loaded zcl properties file + +| Param | Type | +| --- | --- | +| db | \* | +| metafile | \* | + + + +### Loader API: Loader APIs~loadZclJsonOrProperties(db, ctx) ⇒ Toplevel function that loads the toplevel metafile and orchestrates the promise chain. -**Kind**: global function -**Returns**: a Promise that resolves with the db. - -| Param | Type | Description | -| ----- | --------------- | ----------------------- | -| db | \* | | -| ctx | \* | The context of loading. | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: a Promise that resolves with the db. - +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| ctx | \* | The context of loading. | -## recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync) ⇒ + +### Loader API: Loader APIs~recordToplevelPackage(db, metadataFile, crc, isTopLevelPackageInSync) ⇒ Records the toplevel package information and resolves into packageId -**Kind**: global function -**Returns**: packageId +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: packageId -| Param | Type | -| ----------------------- | --------------- | -| db | \* | -| metadataFile | \* | -| crc | \* | -| isTopLevelPackageInSync | \* | +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| crc | \* | +| isTopLevelPackageInSync | \* | - - -## recordVersion(db, ctx) + +### Loader API: Loader APIs~recordVersion(db, ctx) Records the version into the database. -**Kind**: global function - -| Param | Type | -| ----- | --------------- | -| db | \* | -| ctx | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| db | \* | +| ctx | \* | -## loadZclMetaFilesCommon(db, metadataFile, options) ⇒ + +### Loader API: Loader APIs~loadZclMetaFilesCommon(db, metadataFile, options) ⇒ Retrieve zcl package information -**Kind**: global function -**Returns**: package zcl package information +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: package zcl package information -| Param | Type | -| ------------ | --------------- | -| db | \* | -| metadataFile | \* | -| options | \* | +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | +| options | \* | - - -## loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap) + +### Loader API: Loader APIs~loadAttributeMappingForMultiProtocol(db, multiProtcolInfo, categoryToPackageIdMap) Load attribute mapping table if there is multi-protocol information from a json file. -**Kind**: global function - -| Param | Type | -| ---------------------- | --------------- | -| db | \* | -| multiProtcolInfo | \* | -| categoryToPackageIdMap | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) - +| Param | Type | +| --- | --- | +| db | \* | +| multiProtcolInfo | \* | +| categoryToPackageIdMap | \* | -## loadZclMetafiles(db, metadataFile) ⇒ + +### Loader API: Loader APIs~loadZclMetafiles(db, metadataFile) ⇒ Toplevel function that loads the zcl file and passes it off to the correct zcl loader. -**Kind**: global function -**Returns**: Array of loaded packageIds. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Array of loaded packageIds. -| Param | Type | Description | -| ------------ | --------------- | -------------- | -| db | \* | | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | | metadataFile | \* | array of paths | - - -## loadZcl(db, metadataFile) ⇒ + +### Loader API: Loader APIs~loadZcl(db, metadataFile) ⇒ Loads individual zcl.json metafile. -**Kind**: global function -**Returns**: Context object that contains .db and .packageId - -| Param | Type | -| ------------ | --------------- | -| db | \* | -| metadataFile | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Context object that contains .db and .packageId - +| Param | Type | +| --- | --- | +| db | \* | +| metadataFile | \* | -## loadIndividualFile(db, filePath, sessionId) + +### Loader API: Loader APIs~loadIndividualFile(db, filePath, sessionId) Load individual custom XML files. -**Kind**: global function +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) -| Param | Type | Description | -| --------- | --------------- | ----------------------------------------------------- | -| db | \* | | -| filePath | \* | | +| Param | Type | Description | +| --- | --- | --- | +| db | \* | | +| filePath | \* | | | sessionId | \* | Current session within which we're loading this file. | - - -## qualifyZclFile(db, info, parentPackageId, isCustom) ⇒ + +### Loader API: Loader APIs~qualifyZclFile(db, info, parentPackageId, isCustom) ⇒ Promises to qualify whether zcl file needs to be reloaded. If yes, the it will resolve with {filePath, data, packageId} If not, then it will resolve with {error} -**Kind**: global function -**Returns**: Promise that resolves int he object of data. - -| Param | Type | -| --------------- | --------------- | -| db | \* | -| info | \* | -| parentPackageId | \* | -| isCustom | \* | +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise that resolves int he object of data. - +| Param | Type | +| --- | --- | +| db | \* | +| info | \* | +| parentPackageId | \* | +| isCustom | \* | -## processZclPostLoading(db) ⇒ + +### Loader API: Loader APIs~processZclPostLoading(db) ⇒ Promises to perform a post loading step. -**Kind**: global function -**Returns**: Promise to deal with the post-loading cleanup. +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: Promise to deal with the post-loading cleanup. -| Param | Type | -| ----- | --------------- | -| db | \* | +| Param | Type | +| --- | --- | +| db | \* | - + -## getDiscriminatorMap(db, packageIds) ⇒ +### Loader API: Loader APIs~getDiscriminatorMap(db, packageIds) ⇒ +**Kind**: inner method of [Loader API: Loader APIs](#module_Loader API_ Loader APIs) +**Returns**: data type discriminator map -**Kind**: global function -**Returns**: data type discriminator map +| Param | Type | +| --- | --- | +| db | \* | +| packageIds | \* | -| Param | Type | -| ---------- | --------------- | -| db | \* | -| packageIds | \* | diff --git a/docs/helpers.md b/docs/helpers.md new file mode 100644 index 0000000000..edd407d2b4 --- /dev/null +++ b/docs/helpers.md @@ -0,0 +1,4692 @@ +## Modules + +
    +
    Templating API: Access helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: Attribute helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: C formatting helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: Command helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: Matter endpoint config helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: Future helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: SDK extension helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: C formatting helpers
    +

    This module contains the API for accessing SDK extensions.

    +
    +
    Templating API: user-data specific helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: Token helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: toplevel utility helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: static zcl helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    Templating API: Zigbee Specific helpers
    +

    This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial}

    +
    +
    + + + +## Templating API: Access helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: Access helpers](#module_Templating API_ Access helpers) + * [~collectDefaultAccessList(ctx, entityType)](#module_Templating API_ Access helpers..collectDefaultAccessList) ⇒ + * [~collectAccesslist(ctx, options)](#module_Templating API_ Access helpers..collectAccesslist) ⇒ + * [~access_aggregate(options)](#module_Templating API_ Access helpers..access_aggregate) + * [~access(options)](#module_Templating API_ Access helpers..access) + * [~default_access(options)](#module_Templating API_ Access helpers..default_access) ⇒ + + + +### Templating API: Access helpers~collectDefaultAccessList(ctx, entityType) ⇒ +Collects the default access list + +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) +**Returns**: Promise of default access + +| Param | Type | +| --- | --- | +| ctx | \* | +| entityType | \* | + + + +### Templating API: Access helpers~collectAccesslist(ctx, options) ⇒ +Get Access List based on on given options. + +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) +**Returns**: Access List + +| Param | Type | +| --- | --- | +| ctx | \* | +| options | \* | + + + +### Templating API: Access helpers~access\_aggregate(options) +This helper creates a context for the aggregates of access. + +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Access helpers~access(options) +Access helper iterates across all the access triplets associated with the element. +For each element, context contains role, operation, accessModifier. +Additionally it creates booleans hasRole, hasOperation and hasAccessModifier +and hasAtLeastOneAccessElement and hasAllAccessElements + +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Access helpers~default\_access(options) ⇒ +Get the access list information. + +**Kind**: inner method of [Templating API: Access helpers](#module_Templating API_ Access helpers) +**Returns**: access list + +| Param | Type | +| --- | --- | +| options | \* | + + + +## Templating API: Attribute helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: Attribute helpers](#module_Templating API_ Attribute helpers) + * [~featureBits(options)](#module_Templating API_ Attribute helpers..featureBits) ⇒ + * [~attributeDefault()](#module_Templating API_ Attribute helpers..attributeDefault) ⇒ + + + +### Templating API: Attribute helpers~featureBits(options) ⇒ +Get feature bits from the given context. + +**Kind**: inner method of [Templating API: Attribute helpers](#module_Templating API_ Attribute helpers) +**Returns**: feature bits + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Attribute helpers~attributeDefault() ⇒ +Valid within a cluster context, requires code. + +**Kind**: inner method of [Templating API: Attribute helpers](#module_Templating API_ Attribute helpers) +**Returns**: Produces attribute defaults. + + +## Templating API: C formatting helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + * [~asOffset(hex)](#module_Templating API_ C formatting helpers..asOffset) + * [~asDelimitedMacro(label)](#module_Templating API_ C formatting helpers..asDelimitedMacro) + * [~asHex(label)](#module_Templating API_ C formatting helpers..asHex) ⇒ + * [~asUnderlyingTypeHelper(dataType, context, packageIds)](#module_Templating API_ C formatting helpers..asUnderlyingTypeHelper) ⇒ + * [~asUnderlyingType(value)](#module_Templating API_ C formatting helpers..asUnderlyingType) ⇒ + * [~asType(label)](#module_Templating API_ C formatting helpers..asType) ⇒ + * [~asSymbol(label)](#module_Templating API_ C formatting helpers..asSymbol) ⇒ + * [~formatValue(value, length)](#module_Templating API_ C formatting helpers..formatValue) ⇒ + * [~asBytes(value)](#module_Templating API_ C formatting helpers..asBytes) + * [~asCamelCased(str)](#module_Templating API_ C formatting helpers..asCamelCased) ⇒ + * [~cleanseLabel(label)](#module_Templating API_ C formatting helpers..cleanseLabel) + * [~asUnderscoreLowercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreLowercase) ⇒ + * [~cleanseLabelAsKebabCase(label)](#module_Templating API_ C formatting helpers..cleanseLabelAsKebabCase) + * [~asSpacedLowercase(str)](#module_Templating API_ C formatting helpers..asSpacedLowercase) ⇒ + * [~asUnderscoreUppercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreUppercase) ⇒ + * [~asCliType(size, isSigned)](#module_Templating API_ C formatting helpers..asCliType) ⇒ + * [~as_zcl_cli_type(str, optional, isSigned)](#module_Templating API_ C formatting helpers..as_zcl_cli_type) + * [~dataTypeForBitmap(db, bitmap_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForBitmap) + * [~dataTypeForEnum(db, enum_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForEnum) + * [~addOne(number)](#module_Templating API_ C formatting helpers..addOne) + * [~is_number_greater_than(num1, num2)](#module_Templating API_ C formatting helpers..is_number_greater_than) ⇒ + * [~cluster_extension(options)](#module_Templating API_ C formatting helpers..cluster_extension) ⇒ + * [~device_type_extension(options)](#module_Templating API_ C formatting helpers..device_type_extension) ⇒ + * [~attribute_type_extension(options)](#module_Templating API_ C formatting helpers..attribute_type_extension) ⇒ + * [~subentityExtension(context, prop, entityType)](#module_Templating API_ C formatting helpers..subentityExtension) ⇒ + * [~if_command_extension_true(options)](#module_Templating API_ C formatting helpers..if_command_extension_true) ⇒ + * [~if_command_extension_false(options)](#module_Templating API_ C formatting helpers..if_command_extension_false) ⇒ + * [~if_cluster_extension_true(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_true) ⇒ + * [~if_cluster_extension_false(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_false) ⇒ + * [~attribute_extension(options)](#module_Templating API_ C formatting helpers..attribute_extension) ⇒ + * [~command_extension(options)](#module_Templating API_ C formatting helpers..command_extension) ⇒ + * [~event_extension(options)](#module_Templating API_ C formatting helpers..event_extension) ⇒ + + + +### Templating API: C formatting helpers~asOffset(hex) +Given a hex number, it prints the offset, which is the index of the first non-zero bit. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| hex | \* | + + + +### Templating API: C formatting helpers~asDelimitedMacro(label) +Takes a label, and delimits is on camelcasing. +For example: + VerySimpleLabel will turn into VERY_SIMPLE_LABEL + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asHex(label) ⇒ +Formats label as a C hex constant. +If value starts as 0x or 0X it is already treated as hex, +otherwise it is assumed decimal and converted to hex. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C hex constant. + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asUnderlyingTypeHelper(dataType, context, packageIds) ⇒ +This function is a helper function for asUnderlyingType and assists in +returning the correct C type for the given data type + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C type for the given data type + +| Param | Type | +| --- | --- | +| dataType | \* | +| context | \* | +| packageIds | \* | + + + +### Templating API: C formatting helpers~asUnderlyingType(value) ⇒ +Converts the actual zcl type into an underlying usable C type. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C Type + +| Param | Type | +| --- | --- | +| value | \* | + + + +### Templating API: C formatting helpers~asType(label) ⇒ +Formats label as a C type. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C type. + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asSymbol(label) ⇒ +Formats label as a C symbol. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C symbol. + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~formatValue(value, length) ⇒ +Formats the default value into an attribute of a given length + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Formatted value + +| Param | Type | +| --- | --- | +| value | \* | +| length | \* | + + + +### Templating API: C formatting helpers~asBytes(value) +Given a default value of attribute, this method converts it into bytes + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| value | \* | + + + +### Templating API: C formatting helpers~asCamelCased(str) ⇒ +Given a string convert it into a camelCased string + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~cleanseLabel(label) +returns a string after converting ':' and '-' into '_' + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asUnderscoreLowercase(str) ⇒ +Given a camel case string, convert it into one with underscore and lowercase + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in lowercase with underscores + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~cleanseLabelAsKebabCase(label) +returns a string after converting ':', ' ' and camel case into '-' + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asSpacedLowercase(str) ⇒ +Given a camel case string convert it into one with space and lowercase + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~asUnderscoreUppercase(str) ⇒ +Given a camel case string convert it into one with underscore and uppercase + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in uppercase with underscores + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~asCliType(size, isSigned) ⇒ +Returns the cli type representation. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: the type representation required for CLI. + +| Param | +| --- | +| size | +| isSigned | + + + +### Templating API: C formatting helpers~as\_zcl\_cli\_type(str, optional, isSigned) +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Description | +| --- | --- | +| str | | +| optional | | +| isSigned | Return the data type of zcl cli | + + + +### Templating API: C formatting helpers~dataTypeForBitmap(db, bitmap_name, packageIds) +Returns the type of bitmap based on the bitmap's name + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| db | \* | +| bitmap_name | \* | +| packageIds | \* | + + + +### Templating API: C formatting helpers~dataTypeForEnum(db, enum_name, packageIds) +Returns the type of enum + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| db | \* | +| enum_name | \* | +| packageIds | \* | + + + +### Templating API: C formatting helpers~addOne(number) +Returns the number by adding 1 to it. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| number | \* | + + + +### Templating API: C formatting helpers~is\_number\_greater\_than(num1, num2) ⇒ +Return true if number1 is greater than number2 + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: true if num1 is greater than num2 else returns false + +| Param | +| --- | +| num1 | +| num2 | + + + +### Templating API: C formatting helpers~cluster\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~device\_type\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~attribute\_type\_extension(options) ⇒ +When inside a context that contains 'type', this +helper will output the value of the attribute type extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute type extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~subentityExtension(context, prop, entityType) ⇒ +Get extension values for the given information. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: extension default value + +| Param | Type | +| --- | --- | +| context | \* | +| prop | \* | +| entityType | \* | + + + +### Templating API: C formatting helpers~if\_command\_extension\_true(options) ⇒ +If helper for command extensions(true condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~if\_command\_extension\_false(options) ⇒ +If helper for command extensions(false condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~if\_cluster\_extension\_true(options) ⇒ +If helper for cluster extensions(true condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~if\_cluster\_extension\_false(options) ⇒ +If helper for cluster extensions(false condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~attribute\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the attribute extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~command\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~event\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +## Templating API: Command helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: Command helpers](#module_Templating API_ Command helpers) + * [~if_command_arguments_exist(commandId, argument_return, no_argument_return)](#module_Templating API_ Command helpers..if_command_arguments_exist) + * [~if_command_args_exist(commandId, options)](#module_Templating API_ Command helpers..if_command_args_exist) ⇒ + * [~if_ca_always_present_with_presentif(commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_ca_always_present_with_presentif) ⇒ + * [~if_command_arg_always_present_with_presentif(commandArg, options)](#module_Templating API_ Command helpers..if_command_arg_always_present_with_presentif) ⇒ + * [~if_command_is_not_fixed_length_but_command_argument_is_always_present(command, commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_command_is_not_fixed_length_but_command_argument_is_always_present) ⇒ + * [~if_command_not_fixed_length_command_argument_always_present(command, commandArg, options)](#module_Templating API_ Command helpers..if_command_not_fixed_length_command_argument_always_present) ⇒ + * [~if_ca_not_always_present_no_presentif(commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_ca_not_always_present_no_presentif) ⇒ + * [~if_command_arg_not_always_present_no_presentif(commandArg, options)](#module_Templating API_ Command helpers..if_command_arg_not_always_present_no_presentif) ⇒ + * [~if_ca_not_always_present_with_presentif(commandArg, trueReturn, falseReturn)](#module_Templating API_ Command helpers..if_ca_not_always_present_with_presentif) ⇒ + * [~if_command_arg_not_always_present_with_presentif(commandArg, options)](#module_Templating API_ Command helpers..if_command_arg_not_always_present_with_presentif) ⇒ + * [~if_command_is_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn)](#module_Templating API_ Command helpers..if_command_is_fixed_length) + * [~if_command_fixed_length(commandId, options)](#module_Templating API_ Command helpers..if_command_fixed_length) + + + +### Templating API: Command helpers~if\_command\_arguments\_exist(commandId, argument_return, no_argument_return) +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) + +| Param | Type | Description | +| --- | --- | --- | +| commandId | \* | | +| argument_return | \* | | +| no_argument_return | \* | If the command arguments for a command exist then returns argument_return else returns no_argument_return Example: {{if_command_arguments_exist [command-id] "," ""}} The above will return ',' if the command arguments for a command exist and will return nothing if the command arguments for a command do not exist. | + + + +### Templating API: Command helpers~if\_command\_args\_exist(commandId, options) ⇒ +If helper which checks if command arguments exist for a command or not +example: +{{#if_command_args_exist commandId}} + command arguments exist for the command +{{else}} + command arguments do not exist for the command +{{/if_command_args_exist}} + +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on whether the +command arguments are present or not. + +| Param | +| --- | +| commandId | +| options | + + + +### Templating API: Command helpers~if\_ca\_always\_present\_with\_presentif(commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command argument is always present and there is a +presentIf condition else returns false + +| Param | +| --- | +| commandArg | +| trueReturn | +| falseReturn | + + + +### Templating API: Command helpers~if\_command\_arg\_always\_present\_with\_presentif(commandArg, options) ⇒ +If helper that checks if a command argument is always present with a +presentIf condition. +example: +{{#if_command_arg_always_present_with_presentif commandArg}} + command argument has a presentIf condition +{{else}} + command argument does not have a presentIf condition +{{/if_command_arg_always_present_with_presentif}} + +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command +argument having a presentIf condition or not + +| Param | +| --- | +| commandArg | +| options | + + + +### Templating API: Command helpers~if\_command\_is\_not\_fixed\_length\_but\_command\_argument\_is\_always\_present(command, commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command is not fixed length but command argument is +always present else returns falseReturn + +| Param | +| --- | +| command | +| commandArg | +| trueReturn | +| falseReturn | + + + +### Templating API: Command helpers~if\_command\_not\_fixed\_length\_command\_argument\_always\_present(command, commandArg, options) ⇒ +If helper that checks if command is not fixed lenth and that the command is +always present. +example: +{{#if_command_not_fixed_length_command_argument_always_present commandId}} + command is not fixed length and command argument is always present +{{else}} + either command is fixed length or command argument is not always present +{{/if_command_not_fixed_length_command_argument_always_present}} + +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command being +fixed length or not and whether the command argument is always present + +| Param | +| --- | +| command | +| commandArg | +| options | + + + +### Templating API: Command helpers~if\_ca\_not\_always\_present\_no\_presentif(commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command argument is not always present and there is no +presentIf condition else returns false + +| Param | +| --- | +| commandArg | +| trueReturn | +| falseReturn | + + + +### Templating API: Command helpers~if\_command\_arg\_not\_always\_present\_no\_presentif(commandArg, options) ⇒ +If helper that checks if a command argument is not always present because it +has a introduced in or removed in clause. The helper also checks that there +is no presentIf condition. +example: +{{#if_command_arg_not_always_present_no_presentif commandArg}} + command argument is not always present and there is no presentIf condition +{{else}} + Either command argument is always present or there is a presentIf condition +{{/if_command_arg_not_always_present_no_presentif}} + +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command +argument being present and if there is a presentIf condition. + +| Param | +| --- | +| commandArg | +| options | + + + +### Templating API: Command helpers~if\_ca\_not\_always\_present\_with\_presentif(commandArg, trueReturn, falseReturn) ⇒ +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: trueReturn if command argument is not always present and there is a +presentIf condition else returns false + +| Param | +| --- | +| commandArg | +| trueReturn | +| falseReturn | + + + +### Templating API: Command helpers~if\_command\_arg\_not\_always\_present\_with\_presentif(commandArg, options) ⇒ +If helper that checks if a command argument is not always present because it +has a introduced in or removed in clause. The helper also checks that there +is a presentIf condition. +example: +{{#if_command_arg_not_always_present_with_presentif commandArg}} + command argument is not always present and there is a presentIf condition +{{else}} + Either command argument is always present or there is no presentIf condition +{{/if_command_arg_not_always_present_with_presentif}} + +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) +**Returns**: Returns content in the handlebar template based on the command +argument being present and if there is a presentIf condition. + +| Param | +| --- | +| commandArg | +| options | + + + +### Templating API: Command helpers~if\_command\_is\_fixed\_length(commandId, fixedLengthReturn, notFixedLengthReturn) +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) + +| Param | Description | +| --- | --- | +| commandId | | +| fixedLengthReturn | | +| notFixedLengthReturn | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not. Also checks if the command arguments are always present or not. | + + + +### Templating API: Command helpers~if\_command\_fixed\_length(commandId, options) +If helper which checks if a command is fixed length or not + +example: +{{#if_command_fixed_length commandId}} +command is fixed length +{{else}} +command is not fixed length +{{/if_command_fixed_length}} + +**Kind**: inner method of [Templating API: Command helpers](#module_Templating API_ Command helpers) + +| Param | Description | +| --- | --- | +| commandId | | +| options | Returns content in the handlebar template based on the command being fixed length or not as shown in the example above. | + + + +## Templating API: Matter endpoint config helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) + * [~endpoint_type_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_type_count) ⇒ + * [~endpoint_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_count) ⇒ + * [~endpoint_config_macros()](#module_Templating API_ Matter endpoint config helpers..endpoint_config_macros) ⇒ + * [~endpoint_fixed_endpoint_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_endpoint_array) ⇒ + * [~endpoint_fixed_profile_id_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_profile_id_array) ⇒ + * [~endpoint_fixed_parent_id_array()](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_parent_id_array) ⇒ + * [~endpoint_fixed_network_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_network_array) ⇒ + * [~endpoint_fixed_endpoint_type_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_endpoint_type_array) ⇒ + * [~createMfgCodes(codeIndexPairs)](#module_Templating API_ Matter endpoint config helpers..createMfgCodes) ⇒ + * [~endpoint_attribute_manufacturer_codes(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_manufacturer_codes) ⇒ + * [~endpoint_attribute_manufacturer_code_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_manufacturer_code_count) ⇒ + * [~endpoint_command_manufacturer_codes(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_manufacturer_codes) ⇒ + * [~endpoint_command_manufacturer_code_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_manufacturer_code_count) ⇒ + * [~endpoint_cluster_manufacturer_codes(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_manufacturer_codes) ⇒ + * [~endpoint_cluster_manufacturer_code_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_manufacturer_code_count) ⇒ + * [~endpoint_largest_attribute_size(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_largest_attribute_size) ⇒ + * [~endpoint_singletons_size(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_singletons_size) ⇒ + * [~endpoint_total_storage_size(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_total_storage_size) ⇒ + * [~endpoint_command_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_count) ⇒ + * [~endpoint_types_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_types_list) ⇒ + * [~endpoint_cluster_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_count) ⇒ + * [~endpoint_cluster_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_cluster_list) ⇒ + * [~endpoint_command_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_command_list) ⇒ + * [~endpoint_attribute_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_count) ⇒ + * [~endpoint_attribute_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_list) ⇒ + * [~device_list(context, options)](#module_Templating API_ Matter endpoint config helpers..device_list) ⇒ + * [~endpoint_fixed_device_type_array(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_device_type_array) ⇒ + * [~endpoint_fixed_device_type_array_offsets(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_device_type_array_offsets) ⇒ + * [~endpoint_fixed_device_type_array_lengths(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_fixed_device_type_array_lengths) ⇒ + * [~endpoint_attribute_min_max_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_min_max_count) ⇒ + * [~endpoint_attribute_min_max_list(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_min_max_list) ⇒ + * [~endpoint_reporting_config_defaults(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_reporting_config_defaults) + * [~endpoint_reporting_config_default_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_reporting_config_default_count) ⇒ + * [~endpoint_attribute_long_defaults_count(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_long_defaults_count) ⇒ + * [~endpoint_attribute_long_defaults(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_attribute_long_defaults) ⇒ + * [~asMEI(manufacturerCode, code)](#module_Templating API_ Matter endpoint config helpers..asMEI) ⇒ + * [~determineAttributeDefaultValue(specifiedDefault, type, typeSize, isNullable, db, sessionId)](#module_Templating API_ Matter endpoint config helpers..determineAttributeDefaultValue) ⇒ + * [~collectAttributes()](#module_Templating API_ Matter endpoint config helpers..collectAttributes) + * [~collectAttributeSizes(db, zclPackageIds, endpointTypes)](#module_Templating API_ Matter endpoint config helpers..collectAttributeSizes) ⇒ + * [~collectAttributeTypeInfo(db, zclPackageIds, endpointTypes)](#module_Templating API_ Matter endpoint config helpers..collectAttributeTypeInfo) ⇒ + * [~isGlobalAttrExcludedFromMetadata(attr)](#module_Templating API_ Matter endpoint config helpers..isGlobalAttrExcludedFromMetadata) ⇒ + * [~endpoint_config(options)](#module_Templating API_ Matter endpoint config helpers..endpoint_config) ⇒ + + + +### Templating API: Matter endpoint config helpers~endpoint\_type\_count(options) ⇒ +Returns number of endpoint types. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: number of endpoint types + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_count(options) ⇒ +Returns number of endpoints. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: number of endpoints + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_config\_macros() ⇒ +Prints out all the macros that the endpoint config +configuration depends on. These macros are created +by ZAP, because the use of these macros is also +created by ZAP. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Macros that need to be created + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_endpoint\_array(options) ⇒ +Creates array of endpointId fields on endpoints + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_profile\_id\_array(options) ⇒ +Creates array of profileId fields on endpoints + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_parent\_id\_array() ⇒ +Creates Integer Array of parent endpoint identifier fields on endpoints. If the Parent Endpoint is not set then it will default to 0. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_network\_array(options) ⇒ +Creates array of networkId fields on endpoints + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array including the brackets + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_endpoint\_type\_array(options) ⇒ +Each element of an array contains an index into the +endpoint type array, for the appropriate endpoint. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: C array of indexes, one for each endpoint. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~createMfgCodes(codeIndexPairs) ⇒ +Get indexes and manufacturer code. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: String + +| Param | Type | +| --- | --- | +| codeIndexPairs | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_manufacturer\_codes(options) ⇒ +Generates array of { index , mfgCode } pairs, matching +the indexes in attribute table. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: manufacturer code array + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_manufacturer\_code\_count(options) ⇒ +Get count of attributes with manufacturer code. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of attributes with manufacturer code + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_command\_manufacturer\_codes(options) ⇒ +Get all command manufacturer codes. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: all command manufacturer codes + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_command\_manufacturer\_code\_count(options) ⇒ +Get count of commands with manufacturer code. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of commands with manufacturer code + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_manufacturer\_codes(options) ⇒ +Get all cluster manufacturer codes. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: all cluster manufacturer codes + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_manufacturer\_code\_count(options) ⇒ +Get count of clusters with manufacturer code. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of clusters with manufacturer code + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_largest\_attribute\_size(options) ⇒ +Get size of largest attribute. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: size of largest attribute + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_singletons\_size(options) ⇒ +Get cumulative size of all singleton endpoint type attributes. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: cumulative size of all singleton endpoint type attributes + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_total\_storage\_size(options) ⇒ +Get cumulative size of all endpoint type attributes. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: cumulative size of all endpoint type attributes + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_command\_count(options) ⇒ +Get count of endpoint type commands. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of endpoint type commands + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_types\_list(options) ⇒ +Get endpoint type information. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type information + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_count(options) ⇒ +Get count of endpoint type clusters. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of endpoint type clusters + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_cluster\_list(options) ⇒ +Get endpoint type cluster information. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type cluster information + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_command\_list(options) ⇒ +Get endpoint type command information. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type command information + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_count(options) ⇒ +Get count of endpoint type attributes. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of endpoint type attributes + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_list(options) ⇒ +Get endpoint type attribute information. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: endpoint type attribute information + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~device\_list(context, options) ⇒ +Extracting device versions and identifiers from endpoint types + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: list of device types + +| Param | Type | +| --- | --- | +| context | \* | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_device\_type\_array(options) ⇒ +Get all device types in the configuration. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: device types + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_device\_type\_array\_offsets(options) ⇒ +Get device type offset per endpoint. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Device type offset per endpoint + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_fixed\_device\_type\_array\_lengths(options) ⇒ +Get count of device types per endpoint. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of device types per endpoint + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_min\_max\_count(options) ⇒ +Get count of total attributes with min max values listed. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: count of total attributes with min max values listed + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_min\_max\_list(options) ⇒ +Get all attributes with min max values defined. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: All attributes with min max values listed + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_reporting\_config\_defaults(options) +This helper supports an "order" CSV string, such as: + "direction,endpoint,clusterId,attributeId,mask,mfgCode,minmax" +The string above is a default value, and it determines in what order are the fields generated. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_reporting\_config\_default\_count(options) ⇒ +Get count of total attributes with reporting enabled + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Count of total attributes with reporting enabled + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_long\_defaults\_count(options) ⇒ +Get long(size>2 bytes) attribute count. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: count of long attributes + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_attribute\_long\_defaults(options) ⇒ +Get long(size>2 bytes) attribute default values based on endianness. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Long attribute's default values + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Matter endpoint config helpers~asMEI(manufacturerCode, code) ⇒ +Get 32 bit code from the given code and manufacturer code. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: 32 bit Hex Code. + +| Param | Type | +| --- | --- | +| manufacturerCode | \* | +| code | \* | + + + +### Templating API: Matter endpoint config helpers~determineAttributeDefaultValue(specifiedDefault, type, typeSize, isNullable, db, sessionId) ⇒ +The representation of null depends on the type, so we can't use a single +macro that's defined elsewhere for "null value". +Get the default value of an attribute. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: Attribute's default value + +| Param | Type | +| --- | --- | +| specifiedDefault | \* | +| type | \* | +| typeSize | \* | +| isNullable | \* | +| db | \* | +| sessionId | \* | + + + +### Templating API: Matter endpoint config helpers~collectAttributes() +Attribute collection works like this: + 1.) Go over all the clusters that exist. + 2.) If client is included on at least one endpoint add client atts. + 3.) If server is included on at least one endpoint add server atts. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) + + +### Templating API: Matter endpoint config helpers~collectAttributeSizes(db, zclPackageIds, endpointTypes) ⇒ +This function goes over all the attributes and populates sizes. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: promise that resolves with the passed endpointTypes, after populating the attribute type sizes. + +| Param | Type | +| --- | --- | +| db | \* | +| zclPackageIds | \* | +| endpointTypes | \* | + + + +### Templating API: Matter endpoint config helpers~collectAttributeTypeInfo(db, zclPackageIds, endpointTypes) ⇒ +This function goes over all attributes and populates atomic types. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: promise that resolves with the passed endpointTypes, after populating the attribute atomic types. + +| Param | Type | +| --- | --- | +| db | \* | +| zclPackageIds | \* | +| endpointTypes | \* | + + + +### Templating API: Matter endpoint config helpers~isGlobalAttrExcludedFromMetadata(attr) ⇒ +Checks if global attribute is excluded from the meta data. + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| attr | \* | + + + +### Templating API: Matter endpoint config helpers~endpoint\_config(options) ⇒ +Starts the endpoint configuration block., +longDefaults: longDefaults + +**Kind**: inner method of [Templating API: Matter endpoint config helpers](#module_Templating API_ Matter endpoint config helpers) +**Returns**: a promise of a rendered block + +| Param | Type | +| --- | --- | +| options | \* | + + + +## Templating API: Future helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: Future helpers](#module_Templating API_ Future helpers) + * [~ifFuture(options)](#module_Templating API_ Future helpers..ifFuture) + * [~setFuture(options)](#module_Templating API_ Future helpers..setFuture) + * [~future(options)](#module_Templating API_ Future helpers..future) + + + +### Templating API: Future helpers~ifFuture(options) +Block helper resolving the block if the +value of the specified future matches. + +**Kind**: inner method of [Templating API: Future helpers](#module_Templating API_ Future helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Future helpers~setFuture(options) +This method sets the value of the future. +Use it as: + {{set_future name="NAME" value="VALUE"}} + +**Kind**: inner method of [Templating API: Future helpers](#module_Templating API_ Future helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: Future helpers~future(options) +This method defines the future with a given name. +Use it as: {{future name="NAME"}} + +**Kind**: inner method of [Templating API: Future helpers](#module_Templating API_ Future helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +## Templating API: SDK extension helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + + +## Templating API: C formatting helpers +This module contains the API for accessing SDK extensions. + + +* [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + * [~asOffset(hex)](#module_Templating API_ C formatting helpers..asOffset) + * [~asDelimitedMacro(label)](#module_Templating API_ C formatting helpers..asDelimitedMacro) + * [~asHex(label)](#module_Templating API_ C formatting helpers..asHex) ⇒ + * [~asUnderlyingTypeHelper(dataType, context, packageIds)](#module_Templating API_ C formatting helpers..asUnderlyingTypeHelper) ⇒ + * [~asUnderlyingType(value)](#module_Templating API_ C formatting helpers..asUnderlyingType) ⇒ + * [~asType(label)](#module_Templating API_ C formatting helpers..asType) ⇒ + * [~asSymbol(label)](#module_Templating API_ C formatting helpers..asSymbol) ⇒ + * [~formatValue(value, length)](#module_Templating API_ C formatting helpers..formatValue) ⇒ + * [~asBytes(value)](#module_Templating API_ C formatting helpers..asBytes) + * [~asCamelCased(str)](#module_Templating API_ C formatting helpers..asCamelCased) ⇒ + * [~cleanseLabel(label)](#module_Templating API_ C formatting helpers..cleanseLabel) + * [~asUnderscoreLowercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreLowercase) ⇒ + * [~cleanseLabelAsKebabCase(label)](#module_Templating API_ C formatting helpers..cleanseLabelAsKebabCase) + * [~asSpacedLowercase(str)](#module_Templating API_ C formatting helpers..asSpacedLowercase) ⇒ + * [~asUnderscoreUppercase(str)](#module_Templating API_ C formatting helpers..asUnderscoreUppercase) ⇒ + * [~asCliType(size, isSigned)](#module_Templating API_ C formatting helpers..asCliType) ⇒ + * [~as_zcl_cli_type(str, optional, isSigned)](#module_Templating API_ C formatting helpers..as_zcl_cli_type) + * [~dataTypeForBitmap(db, bitmap_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForBitmap) + * [~dataTypeForEnum(db, enum_name, packageIds)](#module_Templating API_ C formatting helpers..dataTypeForEnum) + * [~addOne(number)](#module_Templating API_ C formatting helpers..addOne) + * [~is_number_greater_than(num1, num2)](#module_Templating API_ C formatting helpers..is_number_greater_than) ⇒ + * [~cluster_extension(options)](#module_Templating API_ C formatting helpers..cluster_extension) ⇒ + * [~device_type_extension(options)](#module_Templating API_ C formatting helpers..device_type_extension) ⇒ + * [~attribute_type_extension(options)](#module_Templating API_ C formatting helpers..attribute_type_extension) ⇒ + * [~subentityExtension(context, prop, entityType)](#module_Templating API_ C formatting helpers..subentityExtension) ⇒ + * [~if_command_extension_true(options)](#module_Templating API_ C formatting helpers..if_command_extension_true) ⇒ + * [~if_command_extension_false(options)](#module_Templating API_ C formatting helpers..if_command_extension_false) ⇒ + * [~if_cluster_extension_true(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_true) ⇒ + * [~if_cluster_extension_false(options)](#module_Templating API_ C formatting helpers..if_cluster_extension_false) ⇒ + * [~attribute_extension(options)](#module_Templating API_ C formatting helpers..attribute_extension) ⇒ + * [~command_extension(options)](#module_Templating API_ C formatting helpers..command_extension) ⇒ + * [~event_extension(options)](#module_Templating API_ C formatting helpers..event_extension) ⇒ + + + +### Templating API: C formatting helpers~asOffset(hex) +Given a hex number, it prints the offset, which is the index of the first non-zero bit. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| hex | \* | + + + +### Templating API: C formatting helpers~asDelimitedMacro(label) +Takes a label, and delimits is on camelcasing. +For example: + VerySimpleLabel will turn into VERY_SIMPLE_LABEL + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asHex(label) ⇒ +Formats label as a C hex constant. +If value starts as 0x or 0X it is already treated as hex, +otherwise it is assumed decimal and converted to hex. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C hex constant. + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asUnderlyingTypeHelper(dataType, context, packageIds) ⇒ +This function is a helper function for asUnderlyingType and assists in +returning the correct C type for the given data type + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C type for the given data type + +| Param | Type | +| --- | --- | +| dataType | \* | +| context | \* | +| packageIds | \* | + + + +### Templating API: C formatting helpers~asUnderlyingType(value) ⇒ +Converts the actual zcl type into an underlying usable C type. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: The appropriate C Type + +| Param | Type | +| --- | --- | +| value | \* | + + + +### Templating API: C formatting helpers~asType(label) ⇒ +Formats label as a C type. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C type. + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asSymbol(label) ⇒ +Formats label as a C symbol. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Label formatted as C symbol. + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~formatValue(value, length) ⇒ +Formats the default value into an attribute of a given length + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Formatted value + +| Param | Type | +| --- | --- | +| value | \* | +| length | \* | + + + +### Templating API: C formatting helpers~asBytes(value) +Given a default value of attribute, this method converts it into bytes + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| value | \* | + + + +### Templating API: C formatting helpers~asCamelCased(str) ⇒ +Given a string convert it into a camelCased string + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~cleanseLabel(label) +returns a string after converting ':' and '-' into '_' + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asUnderscoreLowercase(str) ⇒ +Given a camel case string, convert it into one with underscore and lowercase + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in lowercase with underscores + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~cleanseLabelAsKebabCase(label) +returns a string after converting ':', ' ' and camel case into '-' + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| label | \* | + + + +### Templating API: C formatting helpers~asSpacedLowercase(str) ⇒ +Given a camel case string convert it into one with space and lowercase + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: a spaced out string in lowercase + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~asUnderscoreUppercase(str) ⇒ +Given a camel case string convert it into one with underscore and uppercase + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: String in uppercase with underscores + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: C formatting helpers~asCliType(size, isSigned) ⇒ +Returns the cli type representation. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: the type representation required for CLI. + +| Param | +| --- | +| size | +| isSigned | + + + +### Templating API: C formatting helpers~as\_zcl\_cli\_type(str, optional, isSigned) +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Description | +| --- | --- | +| str | | +| optional | | +| isSigned | Return the data type of zcl cli | + + + +### Templating API: C formatting helpers~dataTypeForBitmap(db, bitmap_name, packageIds) +Returns the type of bitmap based on the bitmap's name + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| db | \* | +| bitmap_name | \* | +| packageIds | \* | + + + +### Templating API: C formatting helpers~dataTypeForEnum(db, enum_name, packageIds) +Returns the type of enum + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| db | \* | +| enum_name | \* | +| packageIds | \* | + + + +### Templating API: C formatting helpers~addOne(number) +Returns the number by adding 1 to it. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) + +| Param | Type | +| --- | --- | +| number | \* | + + + +### Templating API: C formatting helpers~is\_number\_greater\_than(num1, num2) ⇒ +Return true if number1 is greater than number2 + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: true if num1 is greater than num2 else returns false + +| Param | +| --- | +| num1 | +| num2 | + + + +### Templating API: C formatting helpers~cluster\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~device\_type\_extension(options) ⇒ +When inside a context that contains 'code', this +helper will output the value of the cluster extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the cluster extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~attribute\_type\_extension(options) ⇒ +When inside a context that contains 'type', this +helper will output the value of the attribute type extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute type extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~subentityExtension(context, prop, entityType) ⇒ +Get extension values for the given information. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: extension default value + +| Param | Type | +| --- | --- | +| context | \* | +| prop | \* | +| entityType | \* | + + + +### Templating API: C formatting helpers~if\_command\_extension\_true(options) ⇒ +If helper for command extensions(true condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~if\_command\_extension\_false(options) ⇒ +If helper for command extensions(false condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~if\_cluster\_extension\_true(options) ⇒ +If helper for cluster extensions(true condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~if\_cluster\_extension\_false(options) ⇒ +If helper for cluster extensions(false condition). + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: content like an if handlebar helper + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~attribute\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the attribute extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the attribute extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~command\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: C formatting helpers~event\_extension(options) ⇒ +When inside a context that contains 'code' and parent 'code', this +helper will output the value of the command extension +specified by property="propName" attribute. + +**Kind**: inner method of [Templating API: C formatting helpers](#module_Templating API_ C formatting helpers) +**Returns**: Value of the command extension property. + +| Param | Type | +| --- | --- | +| options | \* | + + + +## Templating API: user-data specific helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + * [~user_endpoints(options)](#module_Templating API_ user-data specific helpers..user_endpoints) + * [~user_device_types(options)](#module_Templating API_ user-data specific helpers..user_device_types) + * [~user_endpoint_types(options)](#module_Templating API_ user-data specific helpers..user_endpoint_types) + * [~user_clusters(options)](#module_Templating API_ user-data specific helpers..user_clusters) + * [~user_cluster_attributes(options)](#module_Templating API_ user-data specific helpers..user_cluster_attributes) ⇒ + * [~user_cluster_commands(options)](#module_Templating API_ user-data specific helpers..user_cluster_commands) ⇒ + * [~user_cluster_events(options)](#module_Templating API_ user-data specific helpers..user_cluster_events) ⇒ + * [~user_endpoint_type_count()](#module_Templating API_ user-data specific helpers..user_endpoint_type_count) ⇒ + * [~user_endpoint_count_by_cluster(clusterTypeId)](#module_Templating API_ user-data specific helpers..user_endpoint_count_by_cluster) ⇒ + * [~user_all_attributes(options)](#module_Templating API_ user-data specific helpers..user_all_attributes) ⇒ + * [~all_user_cluster_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_commands) ⇒ + * [~all_user_cluster_command_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification)](#module_Templating API_ user-data specific helpers..all_user_cluster_command_util) + * [~all_user_cluster_attribute_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification)](#module_Templating API_ user-data specific helpers..all_user_cluster_attribute_util) ⇒ + * [~all_user_cluster_manufacturer_specific_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_manufacturer_specific_commands) ⇒ + * [~all_user_cluster_non_manufacturer_specific_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_non_manufacturer_specific_commands) ⇒ + * [~all_user_cluster_manufacturer_specific_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_manufacturer_specific_attributes) ⇒ + * [~all_user_cluster_non_manufacturer_specific_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_non_manufacturer_specific_attributes) ⇒ + * [~all_commands_for_user_enabled_clusters(options)](#module_Templating API_ user-data specific helpers..all_commands_for_user_enabled_clusters) ⇒ + * [~all_cli_commands_for_user_enabled_clusters(options)](#module_Templating API_ user-data specific helpers..all_cli_commands_for_user_enabled_clusters) ⇒ + * [~all_user_clusters(options)](#module_Templating API_ user-data specific helpers..all_user_clusters) ⇒ + * [~all_user_clusters_irrespective_of_side(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_irrespective_of_side) ⇒ + * [~all_user_clusters_names(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_names) ⇒ + * [~user_cluster_command_count_with_cli()](#module_Templating API_ user-data specific helpers..user_cluster_command_count_with_cli) + * [~user_cluster_commands_with_cli()](#module_Templating API_ user-data specific helpers..user_cluster_commands_with_cli) + * [~user_cluster_commands_all_endpoints(options)](#module_Templating API_ user-data specific helpers..user_cluster_commands_all_endpoints) + * [~user_cluster_has_enabled_command(name, side)](#module_Templating API_ user-data specific helpers..user_cluster_has_enabled_command) ⇒ + * [~all_user_cluster_commands_irrespective_of_manufaturing_specification(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_commands_irrespective_of_manufaturing_specification) ⇒ + * [~enabled_attributes_for_cluster_and_side(name, side, options)](#module_Templating API_ user-data specific helpers..enabled_attributes_for_cluster_and_side) ⇒ + * [~user_session_key(options)](#module_Templating API_ user-data specific helpers..user_session_key) ⇒ + * [~if_command_discovery_enabled()](#module_Templating API_ user-data specific helpers..if_command_discovery_enabled) + * [~user_manufacturer_code(options)](#module_Templating API_ user-data specific helpers..user_manufacturer_code) ⇒ + * [~user_default_response_policy(options)](#module_Templating API_ user-data specific helpers..user_default_response_policy) ⇒ + * [~is_command_default_response_enabled(command, options)](#module_Templating API_ user-data specific helpers..is_command_default_response_enabled) ⇒ + * [~is_command_default_response_disabled(command, options)](#module_Templating API_ user-data specific helpers..is_command_default_response_disabled) ⇒ + * [~endpoint_type_identifier(endpointTypeId)](#module_Templating API_ user-data specific helpers..endpoint_type_identifier) ⇒ + * [~endpoint_type_index(endpointTypeId)](#module_Templating API_ user-data specific helpers..endpoint_type_index) ⇒ + * [~all_user_cluster_attributes_for_generated_defaults(name, side, options)](#module_Templating API_ user-data specific helpers..all_user_cluster_attributes_for_generated_defaults) ⇒ + * [~all_user_cluster_generated_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_generated_attributes) ⇒ + * [~all_user_reportable_attributes(options)](#module_Templating API_ user-data specific helpers..all_user_reportable_attributes) ⇒ + * [~all_user_cluster_generated_commands(options)](#module_Templating API_ user-data specific helpers..all_user_cluster_generated_commands) ⇒ + * [~all_user_clusters_with_incoming_or_outgoing_commands(options, is_incoming)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_incoming_or_outgoing_commands) ⇒ + * [~all_user_clusters_with_incoming_commands(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_incoming_commands) ⇒ + * [~all_user_clusters_with_outgoing_commands(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_outgoing_commands) ⇒ + * [~manufacturing_clusters_with_incoming_commands(clusterCode, options)](#module_Templating API_ user-data specific helpers..manufacturing_clusters_with_incoming_commands) ⇒ + * [~all_user_clusters_with_incoming_commands_combined(options)](#module_Templating API_ user-data specific helpers..all_user_clusters_with_incoming_commands_combined) ⇒ + * [~all_incoming_commands_for_cluster_combined(clusterName, clientSide, serverSide, options)](#module_Templating API_ user-data specific helpers..all_incoming_commands_for_cluster_combined) ⇒ + * [~all_user_incoming_commands_for_all_clusters(options)](#module_Templating API_ user-data specific helpers..all_user_incoming_commands_for_all_clusters) ⇒ + * [~all_incoming_or_outgoing_commands_for_cluster(clusterName, clusterSide, isIncoming, options)](#module_Templating API_ user-data specific helpers..all_incoming_or_outgoing_commands_for_cluster) ⇒ + * [~all_incoming_commands_for_cluster(clusterName, options)](#module_Templating API_ user-data specific helpers..all_incoming_commands_for_cluster) ⇒ + * [~all_outgoing_commands_for_cluster(clusterName, options)](#module_Templating API_ user-data specific helpers..all_outgoing_commands_for_cluster) ⇒ + * [~generated_clustes_details(options)](#module_Templating API_ user-data specific helpers..generated_clustes_details) ⇒ + * [~generated_endpoint_type_details(options)](#module_Templating API_ user-data specific helpers..generated_endpoint_type_details) ⇒ + * [~all_user_cluster_attributes_min_max_defaults(name, side, options)](#module_Templating API_ user-data specific helpers..all_user_cluster_attributes_min_max_defaults) ⇒ + * [~checkAttributeMatch(clusterName, attributeName, attributeSide, attributeValue, attributeValueType, endpointAttributes)](#module_Templating API_ user-data specific helpers..checkAttributeMatch) ⇒ + * [~generated_defaults_index(clusterName, attributeName, attributeValueType, attributeValue, prefixReturn, postFixReturn)](#module_Templating API_ user-data specific helpers..generated_defaults_index) ⇒ + * [~generated_default_index(clusterName, attributeName, attributeSide, attributeValueType, attributeValue, prefixReturn, postFixReturn)](#module_Templating API_ user-data specific helpers..generated_default_index) ⇒ + * [~generated_attributes_min_max_index(name, side, options)](#module_Templating API_ user-data specific helpers..generated_attributes_min_max_index) ⇒ + * [~generated_attribute_min_max_index(clusterName, attributeName, attributeSide, options)](#module_Templating API_ user-data specific helpers..generated_attribute_min_max_index) ⇒ + * [~if_enabled_clusters(options)](#module_Templating API_ user-data specific helpers..if_enabled_clusters) ⇒ + * [~if_multi_protocol_attributes_enabled(options)](#module_Templating API_ user-data specific helpers..if_multi_protocol_attributes_enabled) ⇒ + * [~all_multi_protocol_attributes(options)](#module_Templating API_ user-data specific helpers..all_multi_protocol_attributes) ⇒ + + + +### Templating API: user-data specific helpers~user\_endpoints(options) +Creates block iterator over the endpoints. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_device\_types(options) +Creates device type iterator over an endpoint type id. +This works inside user_endpoints or user_endpoint_types. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_endpoint\_types(options) +Creates block iterator helper over the endpoint types. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_clusters(options) +Creates cluster iterator over the endpoint types. +This works ony inside user_endpoint_types. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_cluster\_attributes(options) ⇒ +Creates endpoint type cluster attribute iterator. This works only +inside user_clusters. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster attributes. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_cluster\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This works only inside +user_clusters. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_cluster\_events(options) ⇒ +Creates endpoint type cluster event iterator. This works only inside +user_clusters. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster events. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_endpoint\_type\_count() ⇒ +Get count of total endpoint types. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: count of total endpoint types + + +### Templating API: user-data specific helpers~user\_endpoint\_count\_by\_cluster(clusterTypeId) ⇒ +Retrieve the number of endpoints which possess the specified +cluster type + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the number of endpoint + +| Param | Type | +| --- | --- | +| clusterTypeId | \* | + + + +### Templating API: user-data specific helpers~user\_all\_attributes(options) ⇒ +Iterates over all attributes required by the user configuration. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +commands which have been enabled on added endpoints + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_command\_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification) +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + +| Param | Default | Description | +| --- | --- | --- | +| name | | | +| side | | | +| options | | | +| currentContext | | | +| isManufacturingSpecific | | | +| isIrrespectiveOfManufacturingSpecification | false | Returns: Promise of the resolved blocks iterating over manufacturing specific, non-manufacturing specific or both of the cluster commands. | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_attribute\_util(name, side, options, currentContext, isManufacturingSpecific, isIrrespectiveOfManufacturingSpecification) ⇒ +Get attribute details based on given arguments. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Attribute details + +| Param | Type | Default | +| --- | --- | --- | +| name | \* | | +| side | \* | | +| options | \* | | +| currentContext | \* | | +| isManufacturingSpecific | \* | | +| isIrrespectiveOfManufacturingSpecification | \* | false | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_manufacturer\_specific\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +manufacturing specific commands which have been enabled on added endpoints + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +cluster commands. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_non\_manufacturer\_specific\_commands(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +non-manufacturing specific commands which have been enabled on added endpoints + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over non-manufacturing specific +cluster commands. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_manufacturer\_specific\_attributes(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +manufacturing specific commands which have been enabled on added endpoints + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +cluster commands. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_non\_manufacturer\_specific\_attributes(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +non-manufacturing specific commands which have been enabled on added endpoints + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over non-manufacturing specific +cluster commands. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_commands\_for\_user\_enabled\_clusters(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +commands which have been enabled on added endpoints + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~all\_cli\_commands\_for\_user\_enabled\_clusters(options) ⇒ +This helper returns all commands which have cli within the list of enabled +clusters. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all commands with cli from the list of enabled clusters + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_clusters(options) ⇒ +Creates cluster iterator for all endpoints. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~all\_user\_clusters\_irrespective\_of\_side(options) ⇒ +Creates cluster command iterator for all endpoints. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~all\_user\_clusters\_names(options) ⇒ +Creates cluster command iterator for all endpoints whitout any duplicates +cause by cluster side + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over cluster commands. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_cluster\_command\_count\_with\_cli() +Get the count of the number of clusters commands with cli for a cluster. +This is used under a cluster block helper + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + + +### Templating API: user-data specific helpers~user\_cluster\_commands\_with\_cli() +This helper works within the the cluster block helpers. It is used to get +all commands of the cluster which have cli associated with them. + +param options +Returns: all commands with cli for a cluster + +Example: +{{#all_user_clusters_irrespective_of_side}} + {{#user_cluster_commands_with_cli}} + {{/user_cluster_commands_with_cli}} +{{/all_user_clusters_irrespective_of_side}} + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + + +### Templating API: user-data specific helpers~user\_cluster\_commands\_all\_endpoints(options) +Creates endpoint type cluster command iterator. This works only inside +cluster block helpers. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + +| Param | Description | +| --- | --- | +| options | Returns: Promise of the resolved blocks iterating over cluster commands. | + + + +### Templating API: user-data specific helpers~user\_cluster\_has\_enabled\_command(name, side) ⇒ +Check if the cluster (name) has any enabled commands. This works only inside +cluster block helpers. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: True if cluster has enabled commands otherwise false + +| Param | Type | Description | +| --- | --- | --- | +| name | \* | : Cluster name | +| side | \* | : Cluster side | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_commands\_irrespective\_of\_manufaturing\_specification(options) ⇒ +Creates endpoint type cluster command iterator. This fetches all +manufacturing and non-manufaturing specific commands which have been enabled +on added endpoints + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +and non-manufacturing specific cluster commands. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~enabled\_attributes\_for\_cluster\_and\_side(name, side, options) ⇒ +Creates endpoint type cluster attribute iterator. This fetches all +manufacturer-specific and standard attributes which have been enabled on +added endpoints based on the name and side of the cluster. When side +is not mentioned then client and server attributes are returned. +Available Options: +- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js) +for eg:(#enabled_attributes_for_cluster_and_side + [cluster-name], [cluster-side], removeKeys='isOptional, isNullable') +will remove 'isOptional' and 'isNullable' from the results + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of the resolved blocks iterating over manufacturing specific +and standard cluster attributes. + +| Param | +| --- | +| name | +| side | +| options | + + + +### Templating API: user-data specific helpers~user\_session\_key(options) ⇒ +Helper that resolves into a user session key value. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of value of the session key or undefined. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~if\_command\_discovery\_enabled() +If helper that checks if command discovery is enabled + +example: +{{#if_command_discovery_enabled}} +command discovery is enabled +{{else}} +command discovery is not enabled +{{/if_command_discovery_enabled}} + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) + + +### Templating API: user-data specific helpers~user\_manufacturer\_code(options) ⇒ +Get Session's manufacturer code. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: session's manufacturer code + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~user\_default\_response\_policy(options) ⇒ +Get user's default response policy selected. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: user's default response policy selected + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~is\_command\_default\_response\_enabled(command, options) ⇒ +An if helper to check if default response for a command is enabled or not. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: true if the the default response policy is either always or +when the policy is not never and the command has the disable default +response policy set to false(not true) + +| Param | Type | +| --- | --- | +| command | \* | +| options | \* | + + + +### Templating API: user-data specific helpers~is\_command\_default\_response\_disabled(command, options) ⇒ +An if helper to check if default response for a command is disabled or not. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: true if the the default response policy is either never or +when the policy is not always and the command has the disable default +response policy set to true(for eg disableDefaultResponse="true" in xml). + +| Param | Type | +| --- | --- | +| command | \* | +| options | \* | + + + +### Templating API: user-data specific helpers~endpoint\_type\_identifier(endpointTypeId) ⇒ +Get endpoint identifier from the given endpoint type ID. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: the endpoint type identifier for an endpoint type + +| Param | Type | +| --- | --- | +| endpointTypeId | \* | + + + +### Templating API: user-data specific helpers~endpoint\_type\_index(endpointTypeId) ⇒ +Get the index of the endpoint whose endpointTypeId is endpointTypeId +Will return -1 if the given endpoint type is not present. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: integer + +| Param | Type | +| --- | --- | +| endpointTypeId | \* | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_attributes\_for\_generated\_defaults(name, side, options) ⇒ +Default values for the attributes longer than a pointer. +All attribute values with size greater than 2 bytes. +Excluding 0 values and externally saved values + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Attribute values greater than 2 bytes and not 0 nor externally saved. + +| Param | +| --- | +| name | +| side | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_generated\_attributes(options) ⇒ +Entails the list of all attributes which have been enabled. Given the +cluster is enabled as well. The helper retrieves the attributes across +all endpoints. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: enabled attributes + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_reportable\_attributes(options) ⇒ +Entails the list of reportable attributes which have been enabled. Given the +cluster is enabled as well. The helper retrieves the reportable attributes +per endpoint per cluster. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Reportable attributes + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_generated\_commands(options) ⇒ +All available cluster commands across all endpoints and clusters. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All available cluster commands across all endpoints and clusters + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_incoming\_or\_outgoing\_commands(options, is_incoming) ⇒ +Util function for all clusters with side that have available incoming or +outgiong commands across all endpoints. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters with side that have available incoming or outgiong +commands across all endpoints. + +| Param | Description | +| --- | --- | +| options | | +| is_incoming | boolean to check if commands are incoming or outgoing | + + + +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_incoming\_commands(options) ⇒ +All clusters with side that have available incoming commands + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters with side that have available incoming commands across +all endpoints. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_outgoing\_commands(options) ⇒ +All clusters with side that have available outgoing commands + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters with side that have available outgoing commands across +all endpoints. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~manufacturing\_clusters\_with\_incoming\_commands(clusterCode, options) ⇒ +Provide all manufacturing specific clusters that have incoming commands with +the given cluster code. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Details of manufacturing specific clusters that have incoming +commands with the given cluster code + +| Param | +| --- | +| clusterCode | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_clusters\_with\_incoming\_commands\_combined(options) ⇒ +All clusters that have available incoming commands. +If there is a client and server enabled on the endpoint, this combines them +into a single entry. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All clusters that have available incoming commands across +all endpoints. + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_incoming\_commands\_for\_cluster\_combined(clusterName, clientSide, serverSide, options) ⇒ +All commands that need to be parsed for a given cluster. This takes in booleans +for if the client and or server are included. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all commands that need to be parsed for a given cluster + +| Param | +| --- | +| clusterName | +| clientSide | +| serverSide | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_incoming\_commands\_for\_all\_clusters(options) ⇒ +Get all incoming commands in the user configuration. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all incoming commands enabled by the user. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~all\_incoming\_or\_outgoing\_commands\_for\_cluster(clusterName, clusterSide, isIncoming, options) ⇒ +A util function for all incoming or outgoing commands that need to be parsed +for a given cluster + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: All incoming or outgoing commands that need to be parsed for a given + cluster + +| Param | +| --- | +| clusterName | +| clusterSide | +| isIncoming | +| options | + + + +### Templating API: user-data specific helpers~all\_incoming\_commands\_for\_cluster(clusterName, options) ⇒ +All incoming commands that need to be parsed for a given cluster + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all incoming commands that need to be parsed for a given cluster + +| Param | +| --- | +| clusterName | +| options | + + + +### Templating API: user-data specific helpers~all\_outgoing\_commands\_for\_cluster(clusterName, options) ⇒ +All outgoing commands that need to be parsed for a given cluster + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: all outgoing commands that need to be parsed for a given cluster + +| Param | +| --- | +| clusterName | +| options | + + + +### Templating API: user-data specific helpers~generated\_clustes\_details(options) ⇒ +Entails the Cluster details per endpoint + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Cluster Details per endpoint with attribute summaries within the clusters + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~generated\_endpoint\_type\_details(options) ⇒ +Entails Endpoint type details along with their cluster summaries + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Endpoint type details along with their cluster summaries + +| Param | +| --- | +| options | + + + +### Templating API: user-data specific helpers~all\_user\_cluster\_attributes\_min\_max\_defaults(name, side, options) ⇒ +Returns attributes inside an endpoint type that either have a default or a +bounded attribute. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: endpoints with bounds or defaults + +| Param | +| --- | +| name | +| side | +| options | + + + +### Templating API: user-data specific helpers~checkAttributeMatch(clusterName, attributeName, attributeSide, attributeValue, attributeValueType, endpointAttributes) ⇒ +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: arrayIndex + +| Param | +| --- | +| clusterName | +| attributeName | +| attributeSide | +| attributeValue | +| attributeValueType | +| endpointAttributes | + + + +### Templating API: user-data specific helpers~generated\_defaults\_index(clusterName, attributeName, attributeValueType, attributeValue, prefixReturn, postFixReturn) ⇒ +Extracts the index of generated defaults array which come from +all_user_cluster_attributes_for_generated_defaults + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: index of the generated default array + +| Param | +| --- | +| clusterName | +| attributeName | +| attributeValueType | +| attributeValue | +| prefixReturn | +| postFixReturn | + + + +### Templating API: user-data specific helpers~generated\_default\_index(clusterName, attributeName, attributeSide, attributeValueType, attributeValue, prefixReturn, postFixReturn) ⇒ +Extracts the index of generated defaults array which come from +all_user_cluster_attributes_for_generated_defaults + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: deafult value's index in the generated default array + +| Param | +| --- | +| clusterName | +| attributeName | +| attributeSide | +| attributeValueType | +| attributeValue | +| prefixReturn | +| postFixReturn | + + + +### Templating API: user-data specific helpers~generated\_attributes\_min\_max\_index(name, side, options) ⇒ +Extracts the index of generated min max defaults array which come from +all_user_cluster_attributes_min_max_defaults + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: index of the generated min max default array + +| Param | +| --- | +| name | +| side | +| options | + + + +### Templating API: user-data specific helpers~generated\_attribute\_min\_max\_index(clusterName, attributeName, attributeSide, options) ⇒ +Extracts the index of generated min max defaults array which come from +all_user_cluster_attributes_min_max_defaults + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: index of the generated min max default in the array + +| Param | +| --- | +| clusterName | +| attributeName | +| attributeSide | +| options | + + + +### Templating API: user-data specific helpers~if\_enabled\_clusters(options) ⇒ +If helper that checks if there are clusters enabled +Available options: +- side: side="client/server" can be used to check if there are client or +server side clusters are available + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~if\_multi\_protocol\_attributes\_enabled(options) ⇒ +Check if multi-protocol is enabled for the application. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: boolean based on existence of attribute-attribute associations. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: user-data specific helpers~all\_multi\_protocol\_attributes(options) ⇒ +Retrieve all the attribute-attribute associations for the current session. + +**Kind**: inner method of [Templating API: user-data specific helpers](#module_Templating API_ user-data specific helpers) +**Returns**: attribute-attribute mapping entries + +| Param | Type | +| --- | --- | +| options | \* | + + + +## Templating API: Token helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: Token helpers](#module_Templating API_ Token helpers) + * [~token_cluster_create(config)](#module_Templating API_ Token helpers..token_cluster_create) ⇒ + * [~tokens_context()](#module_Templating API_ Token helpers..tokens_context) + * [~token_next()](#module_Templating API_ Token helpers..token_next) + * [~debug_object(obj)](#module_Templating API_ Token helpers..debug_object) ⇒ + * [~token_attribute_util(context, options)](#module_Templating API_ Token helpers..token_attribute_util) ⇒ + * [~token_attributes(endpointTypeRef, options)](#module_Templating API_ Token helpers..token_attributes) ⇒ + * [~token_attribute_clusters(endpointTypeRef, options)](#module_Templating API_ Token helpers..token_attribute_clusters) ⇒ + * [~token_attribute_endpoints(options)](#module_Templating API_ Token helpers..token_attribute_endpoints) ⇒ + + + +### Templating API: Token helpers~token\_cluster\_create(config) ⇒ +Get a transformed config object. + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: object + +| Param | Type | +| --- | --- | +| config | \* | + + + +### Templating API: Token helpers~tokens\_context() +This function builds creates a new context from the endpoint_config structure + for use in the zap-tokens.h template. The endpoint_config context provides a + list of endpoints, and endpointTypes, where each endpointType contains a list + of clusters, and each cluster contains a list of attributes. However, the + tokens template requires a list of attributes per endpoint, and per cluster, + discriminating from singletons and non-singletons, so this function performs + the required grouping. + + While each attribute contains an isSingleton attribute, the database schema + allows for the same attribute to be returned both as singleton and non-singleton + in different clusters, for different endpoints. In consequence, care must be + taken to remove the singletons from the cluster and endpoint attribute lists. + This is done in two steps, the first loop creates a global (context) list of + singletons and non-singletons, and the second loop removes the singletons from + the endpoint, and clusters. + + Clusters from different endpoints may have different attributes, therefore each + endpoint keeps a separate list of clusters. Additionally, a context-level + map of clusters is required in order to gather all attributes (singletons and + non-singletons) from all endpoint clusters. + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) + + +### Templating API: Token helpers~token\_next() +The token template assigns an unique ID to each unique attribute. These IDs + span all attributes from all clusters from all endpointTypes. This helper + function allows the template to increment the token ID within the tokens context. + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) + + +### Templating API: Token helpers~debug\_object(obj) ⇒ +Get JSON stringified value of the obj. + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: JSON string + +| Param | Type | +| --- | --- | +| obj | \* | + + + +### Templating API: Token helpers~token\_attribute\_util(context, options) ⇒ +Util function that extracts all the token attribute information. + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: Information on all token attributes in the configuration. + +| Param | Type | +| --- | --- | +| context | \* | +| options | \* | + + + +### Templating API: Token helpers~token\_attributes(endpointTypeRef, options) ⇒ +Get information about all the token attributes in the configuration or this +helper can be used within an endpoint block helper to fetch the +corresponding token attributes based on endpoint type given. +Available Options: +isSingleton: 0/1, option can be used to filter attributes based on singleton +or non-singleton(Available with endpointTypeRef only) + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: singleton and non-singleton token attributes along with their +endpoint information. Singleton attributes are only returned once whereas +non-singleton attributes are returned per endpoint. However if used within +an endpoint block helper it returns token_attributes for a given endpoint +type. + +| Param | Type | +| --- | --- | +| endpointTypeRef | \* | +| options | \* | + + + +### Templating API: Token helpers~token\_attribute\_clusters(endpointTypeRef, options) ⇒ +This helper can return all token associated clusters across endpoints or +this helper can be used within an endpoint block helper to fetch the +corresponding token associated clusters. +Available Options: +isSingleton: 0/1, option can be used to filter clusters based on singleton +or non-singleton attributes. + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: Token associated clusters for a particular endpoint type or all +token associated clusters across endpoints. + +| Param | Type | +| --- | --- | +| endpointTypeRef | \* | +| options | \* | + + + +### Templating API: Token helpers~token\_attribute\_endpoints(options) ⇒ +Get all endpoints which have token attributes in the configuration. +AvailableOptions: +- isSingleton: 0/1, option can be used to filter endpoints based on singleton +or non-singleton. + +**Kind**: inner method of [Templating API: Token helpers](#module_Templating API_ Token helpers) +**Returns**: all endpoints with token attributes + +| Param | Type | +| --- | --- | +| options | \* | + + + +## Templating API: toplevel utility helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + * [~zap_header()](#module_Templating API_ toplevel utility helpers..zap_header) ⇒ + * [~ident()](#module_Templating API_ toplevel utility helpers..ident) ⇒ + * [~new_line(cnt)](#module_Templating API_ toplevel utility helpers..new_line) ⇒ + * [~backslash()](#module_Templating API_ toplevel utility helpers..backslash) ⇒ + * [~template_options(category, options)](#module_Templating API_ toplevel utility helpers..template_options) + * [~first(options)](#module_Templating API_ toplevel utility helpers..first) ⇒ + * [~not_first(options)](#module_Templating API_ toplevel utility helpers..not_first) ⇒ + * [~last(options)](#module_Templating API_ toplevel utility helpers..last) ⇒ + * [~not_last(optionms)](#module_Templating API_ toplevel utility helpers..not_last) ⇒ + * [~middle(options)](#module_Templating API_ toplevel utility helpers..middle) ⇒ + * [~template_option_with_code(options, key)](#module_Templating API_ toplevel utility helpers..template_option_with_code) + * [~fail(options)](#module_Templating API_ toplevel utility helpers..fail) + * [~isEqual(string_a, string_b)](#module_Templating API_ toplevel utility helpers..isEqual) + * [~is_lowercase_equal(string_a, string_b)](#module_Templating API_ toplevel utility helpers..is_lowercase_equal) + * [~toggle(condition, trueResult, falseResult)](#module_Templating API_ toplevel utility helpers..toggle) ⇒ + * [~trim_string(str)](#module_Templating API_ toplevel utility helpers..trim_string) ⇒ + * [~asLastWord(str)](#module_Templating API_ toplevel utility helpers..asLastWord) + * [~iterate()](#module_Templating API_ toplevel utility helpers..iterate) + * [~addToAccumulator(accumulator, value)](#module_Templating API_ toplevel utility helpers..addToAccumulator) + * [~iterateAccumulator(options)](#module_Templating API_ toplevel utility helpers..iterateAccumulator) ⇒ + * [~waitForSynchronousPromise(pollInterval, promise, resolve, reject)](#module_Templating API_ toplevel utility helpers..waitForSynchronousPromise) + * [~promiseToResolveAllPreviousPromises(globalPromises)](#module_Templating API_ toplevel utility helpers..promiseToResolveAllPreviousPromises) + * [~after(options)](#module_Templating API_ toplevel utility helpers..after) ⇒ + * [~concatenate()](#module_Templating API_ toplevel utility helpers..concatenate) + * [~is_num_equal(numA, numB)](#module_Templating API_ toplevel utility helpers..is_num_equal) ⇒ + * [~is_defined(value)](#module_Templating API_ toplevel utility helpers..is_defined) ⇒ + * [~replace_string(mainString, replaceString, replaceWithString)](#module_Templating API_ toplevel utility helpers..replace_string) ⇒ + * [~add_prefix_to_all_strings(str, prefixStr)](#module_Templating API_ toplevel utility helpers..add_prefix_to_all_strings) ⇒ + * [~multiply()](#module_Templating API_ toplevel utility helpers..multiply) ⇒ + * [~is_string_underscored(val)](#module_Templating API_ toplevel utility helpers..is_string_underscored) ⇒ + * [~as_uppercase(val)](#module_Templating API_ toplevel utility helpers..as_uppercase) ⇒ + + + +### Templating API: toplevel utility helpers~zap\_header() ⇒ +Produces the top-of-the-file header for a C file. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: The header content + + +### Templating API: toplevel utility helpers~ident() ⇒ +Simple helper that produces an approved size of identation. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: whitespace that is the identation. + + +### Templating API: toplevel utility helpers~new\_line(cnt) ⇒ +Return new lines based on the given cnt parameter. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: new line + +| Param | Type | +| --- | --- | +| cnt | \* | + + + +### Templating API: toplevel utility helpers~backslash() ⇒ +return back slash + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: string + + +### Templating API: toplevel utility helpers~template\_options(category, options) +Block helper that iterates over the package options of a given category. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| category | \* | +| options | \* | + + + +### Templating API: toplevel utility helpers~first(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +during the first element. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the first element inside an operator, empty otherwise. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: toplevel utility helpers~not\_first(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +if the element is not the first element. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the first element inside an operator, empty otherwise. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: toplevel utility helpers~last(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +during the last element. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the last element inside an operator, empty otherwise. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: toplevel utility helpers~not\_last(optionms) ⇒ +Inside an iterator. the block is output only if this is NOT the last item. +Useful for wrapping commas in the list of arguments and such. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's not the last element inside a block, empty otherwise. + +| Param | Type | +| --- | --- | +| optionms | \* | + + + +### Templating API: toplevel utility helpers~middle(options) ⇒ +Inside an iterator, this helper allows you to specify the content that will be output only +during the non-first and no-last element. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: content, if it's the middle element inside an operator, empty otherwise. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: toplevel utility helpers~template\_option\_with\_code(options, key) +This fetches a promise which returns template options if provided + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| options | \* | +| key | \* | + + + +### Templating API: toplevel utility helpers~fail(options) +Forced fail halper. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: toplevel utility helpers~isEqual(string_a, string_b) +This returns a boolean if the 2 strings are same + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| string_a | \* | +| string_b | \* | + + + +### Templating API: toplevel utility helpers~is\_lowercase\_equal(string_a, string_b) +This returns a boolean based on the 2 strings being equal or not given that both + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| string_a | \* | +| string_b | \* | + + + +### Templating API: toplevel utility helpers~toggle(condition, trueResult, falseResult) ⇒ +Return true/false result based on condition. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| condition | \* | +| trueResult | \* | +| falseResult | \* | + + + +### Templating API: toplevel utility helpers~trim\_string(str) ⇒ +Remove leading and trailing spaces from a string + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A string with no leading and trailing spaces + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: toplevel utility helpers~asLastWord(str) +Split the string based on spaces and return the last word + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| str | \* | + + + +### Templating API: toplevel utility helpers~iterate() +Iteration block. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + + +### Templating API: toplevel utility helpers~addToAccumulator(accumulator, value) +Add to accumulator results. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| accumulator | \* | +| value | \* | + + + +### Templating API: toplevel utility helpers~iterateAccumulator(options) ⇒ +Get accumulated information from templates. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: accumulated details + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: toplevel utility helpers~waitForSynchronousPromise(pollInterval, promise, resolve, reject) +Waits for promise to be resolved synchronously. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| pollInterval | \* | +| promise | \* | +| resolve | \* | +| reject | \* | + + + +### Templating API: toplevel utility helpers~promiseToResolveAllPreviousPromises(globalPromises) +Resolves all the given globalPromises promises. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + +| Param | Type | +| --- | --- | +| globalPromises | \* | + + + +### Templating API: toplevel utility helpers~after(options) ⇒ +Resolve the after promise after all other promises in the global context +have been resolved. + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: Content after all other content has been resolved. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: toplevel utility helpers~concatenate() +Given: A list of strings +Returns a concatenated string with spaces between each string + +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) + + +### Templating API: toplevel utility helpers~is\_num\_equal(numA, numB) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: true if both numbers are equal else returns false + +| Param | +| --- | +| numA | +| numB | + + + +### Templating API: toplevel utility helpers~is\_defined(value) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: true or false based on whether the value is undefined or not + +| Param | +| --- | +| value | + + + +### Templating API: toplevel utility helpers~replace\_string(mainString, replaceString, replaceWithString) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A string replaced with another string in the mainString + +| Param | +| --- | +| mainString | +| replaceString | +| replaceWithString | + + + +### Templating API: toplevel utility helpers~add\_prefix\_to\_all\_strings(str, prefixStr) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A resultant string with all string values prefixed with prefixStr + +| Param | +| --- | +| str | +| prefixStr | + + + +### Templating API: toplevel utility helpers~multiply() ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: A number which is result of multiplying all the arguments given + + +### Templating API: toplevel utility helpers~is\_string\_underscored(val) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: true if a string has an underscore in it + +| Param | Type | +| --- | --- | +| val | \* | + + + +### Templating API: toplevel utility helpers~as\_uppercase(val) ⇒ +**Kind**: inner method of [Templating API: toplevel utility helpers](#module_Templating API_ toplevel utility helpers) +**Returns**: val in uppercase + +| Param | Type | +| --- | --- | +| val | \* | + + + +## Templating API: static zcl helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + * [~zcl_bitmaps(options)](#module_Templating API_ static zcl helpers..zcl_bitmaps) ⇒ + * [~zcl_bitmap_items(options)](#module_Templating API_ static zcl helpers..zcl_bitmap_items) + * [~zcl_enums(options)](#module_Templating API_ static zcl helpers..zcl_enums) ⇒ + * [~zcl_structs(options)](#module_Templating API_ static zcl helpers..zcl_structs) ⇒ + * [~zcl_enum_items(options)](#module_Templating API_ static zcl helpers..zcl_enum_items) + * [~first_unused_enum_value(options)](#module_Templating API_ static zcl helpers..first_unused_enum_value) ⇒ + * [~zcl_struct_items(options)](#module_Templating API_ static zcl helpers..zcl_struct_items) ⇒ + * [~zcl_struct_items_by_struct_name(name, options)](#module_Templating API_ static zcl helpers..zcl_struct_items_by_struct_name) ⇒ + * [~zcl_struct_items_by_struct_and_cluster_name(name, clusterName, options)](#module_Templating API_ static zcl helpers..zcl_struct_items_by_struct_and_cluster_name) ⇒ + * [~zcl_device_types(options)](#module_Templating API_ static zcl helpers..zcl_device_types) ⇒ + * [~zcl_device_type_clusters(options)](#module_Templating API_ static zcl helpers..zcl_device_type_clusters) ⇒ + * [~zcl_device_type_cluster_commands(options)](#module_Templating API_ static zcl helpers..zcl_device_type_cluster_commands) ⇒ + * [~zcl_device_type_cluster_attributes(options)](#module_Templating API_ static zcl helpers..zcl_device_type_cluster_attributes) ⇒ + * [~zcl_clusters(options)](#module_Templating API_ static zcl helpers..zcl_clusters) ⇒ + * [~zcl_commands(options)](#module_Templating API_ static zcl helpers..zcl_commands) ⇒ + * [~zcl_command_responses(options)](#module_Templating API_ static zcl helpers..zcl_command_responses) ⇒ + * [~zcl_commands_with_cluster_info(options)](#module_Templating API_ static zcl helpers..zcl_commands_with_cluster_info) ⇒ + * [~zcl_commands_with_arguments(options)](#module_Templating API_ static zcl helpers..zcl_commands_with_arguments) + * [~zcl_commands_source_client(options)](#module_Templating API_ static zcl helpers..zcl_commands_source_client) ⇒ + * [~zcl_commands_source_server(options)](#module_Templating API_ static zcl helpers..zcl_commands_source_server) ⇒ + * [~zcl_events(options)](#module_Templating API_ static zcl helpers..zcl_events) ⇒ + * [~zcl_command_tree(options)](#module_Templating API_ static zcl helpers..zcl_command_tree) ⇒ + * [~zcl_global_commands(options)](#module_Templating API_ static zcl helpers..zcl_global_commands) ⇒ + * [~zcl_attributes(options)](#module_Templating API_ static zcl helpers..zcl_attributes) ⇒ + * [~zcl_attributes_client(options)](#module_Templating API_ static zcl helpers..zcl_attributes_client) ⇒ + * [~zcl_attributes_server(options)](#module_Templating API_ static zcl helpers..zcl_attributes_server) ⇒ + * [~zcl_atomics(options)](#module_Templating API_ static zcl helpers..zcl_atomics) ⇒ + * [~zcl_cluster_largest_label_length()](#module_Templating API_ static zcl helpers..zcl_cluster_largest_label_length) ⇒ + * [~largestLabelLength(An)](#module_Templating API_ static zcl helpers..largestLabelLength) ⇒ + * [~zcl_command_arguments_count(commandId)](#module_Templating API_ static zcl helpers..zcl_command_arguments_count) ⇒ + * [~ifCommandArgumentsHaveFixedLengthWithCurrentContext(commandId, fixedLengthReturn, notFixedLengthReturn, currentContext)](#module_Templating API_ static zcl helpers..ifCommandArgumentsHaveFixedLengthWithCurrentContext) + * [~if_command_arguments_have_fixed_length(commandId, fixedLengthReturn, notFixedLengthReturn)](#module_Templating API_ static zcl helpers..if_command_arguments_have_fixed_length) + * [~as_underlying_zcl_type_command_is_not_fixed_length_but_command_argument_is_always_present(type, command, commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_is_not_fixed_length_but_command_argument_is_always_present) ⇒ + * [~as_underlying_zcl_type_if_command_is_not_fixed_length(type, commandId, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_if_command_is_not_fixed_length) + * [~command_arguments_total_length(commandId)](#module_Templating API_ static zcl helpers..command_arguments_total_length) + * [~zcl_command_arguments(options)](#module_Templating API_ static zcl helpers..zcl_command_arguments) ⇒ + * [~zcl_event_fields(options)](#module_Templating API_ static zcl helpers..zcl_event_fields) + * [~zcl_command_argument_data_type(typeName, options)](#module_Templating API_ static zcl helpers..zcl_command_argument_data_type) + * [~asUnderlyingZclType(typeName, options)](#module_Templating API_ static zcl helpers..asUnderlyingZclType) + * [~zcl_string_type_return(type, options)](#module_Templating API_ static zcl helpers..zcl_string_type_return) + * [~is_zcl_string(type)](#module_Templating API_ static zcl helpers..is_zcl_string) + * [~if_is_number(type)](#module_Templating API_ static zcl helpers..if_is_number) ⇒ + * [~if_is_string(type)](#module_Templating API_ static zcl helpers..if_is_string) ⇒ + * [~if_is_char_string(type)](#module_Templating API_ static zcl helpers..if_is_char_string) ⇒ + * [~if_is_octet_string(type)](#module_Templating API_ static zcl helpers..if_is_octet_string) ⇒ + * [~if_is_short_string(type)](#module_Templating API_ static zcl helpers..if_is_short_string) ⇒ + * [~if_is_long_string(type)](#module_Templating API_ static zcl helpers..if_is_long_string) ⇒ + * [~if_is_atomic(type:)](#module_Templating API_ static zcl helpers..if_is_atomic) ⇒ + * [~if_is_bitmap(type)](#module_Templating API_ static zcl helpers..if_is_bitmap) ⇒ + * [~if_is_enum(type)](#module_Templating API_ static zcl helpers..if_is_enum) ⇒ + * [~if_is_struct(type)](#module_Templating API_ static zcl helpers..if_is_struct) ⇒ + * [~isClient(side)](#module_Templating API_ static zcl helpers..isClient) ⇒ + * [~isServer(side)](#module_Templating API_ static zcl helpers..isServer) ⇒ + * [~isStrEqual(str1, str2)](#module_Templating API_ static zcl helpers..isStrEqual) ⇒ + * [~isLastElement(index, count)](#module_Templating API_ static zcl helpers..isLastElement) ⇒ + * [~isFirstElement(index, count)](#module_Templating API_ static zcl helpers..isFirstElement) ⇒ + * [~isEnabled(enable)](#module_Templating API_ static zcl helpers..isEnabled) ⇒ + * [~isCommandAvailable(clusterSide, incoming, outgoing, source, name)](#module_Templating API_ static zcl helpers..isCommandAvailable) ⇒ + * [~as_underlying_zcl_type_command_argument_always_present(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_always_present) ⇒ + * [~if_command_argument_always_present(commandId, introducedInRef, removedInRef, presentIf, argumentPresentReturn, argumentNotPresentReturn)](#module_Templating API_ static zcl helpers..if_command_argument_always_present) ⇒ + * [~as_underlying_zcl_type_command_argument_not_always_present_no_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_not_always_present_no_presentif) ⇒ + * [~as_underlying_zcl_type_ca_not_always_present_no_presentif(commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_ca_not_always_present_no_presentif) ⇒ + * [~if_command_argument_not_always_present_no_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsReturn, argumentInAllVersionsReturn)](#module_Templating API_ static zcl helpers..if_command_argument_not_always_present_no_presentif) ⇒ + * [~as_underlying_zcl_type_command_argument_not_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_not_always_present_with_presentif) ⇒ + * [~as_underlying_zcl_type_ca_not_always_present_with_presentif(commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_ca_not_always_present_with_presentif) ⇒ + * [~if_command_argument_not_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn)](#module_Templating API_ static zcl helpers..if_command_argument_not_always_present_with_presentif) ⇒ + * [~as_underlying_zcl_type_command_argument_always_present_with_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_command_argument_always_present_with_presentif) ⇒ + * [~as_underlying_zcl_type_ca_always_present_with_presentif(commandArg, appendString, options)](#module_Templating API_ static zcl helpers..as_underlying_zcl_type_ca_always_present_with_presentif) ⇒ + * [~if_command_argument_always_present_with_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn)](#module_Templating API_ static zcl helpers..if_command_argument_always_present_with_presentif) ⇒ + * [~if_manufacturing_specific_cluster(clusterId, manufacturer_specific_return, null_manufacturer_specific_return)](#module_Templating API_ static zcl helpers..if_manufacturing_specific_cluster) ⇒ + * [~if_mfg_specific_cluster(clusterId, options)](#module_Templating API_ static zcl helpers..if_mfg_specific_cluster) ⇒ + * [~as_generated_default_macro(value, attributeSize, options)](#module_Templating API_ static zcl helpers..as_generated_default_macro) ⇒ + * [~attribute_mask(writable, storageOption, minMax, mfgSpecific, clusterCode, client, isSingleton, prefixString, postfixString)](#module_Templating API_ static zcl helpers..attribute_mask) ⇒ + * [~command_mask(commmandSource, clusterSide, isIncomingEnabled, isOutgoingEnabled, manufacturingCode, prefixForMask)](#module_Templating API_ static zcl helpers..command_mask) ⇒ + * [~command_mask_sub_helper(commandMask, str)](#module_Templating API_ static zcl helpers..command_mask_sub_helper) ⇒ + * [~format_zcl_string_as_characters_for_generated_defaults(stringVal, sizeOfString)](#module_Templating API_ static zcl helpers..format_zcl_string_as_characters_for_generated_defaults) ⇒ + * [~as_type_min_value(type, options)](#module_Templating API_ static zcl helpers..as_type_min_value) ⇒ + * [~as_type_max_value(type, options)](#module_Templating API_ static zcl helpers..as_type_max_value) ⇒ + * [~structs_with_clusters(options)](#module_Templating API_ static zcl helpers..structs_with_clusters) + * [~as_zcl_type_size(type, options)](#module_Templating API_ static zcl helpers..as_zcl_type_size) ⇒ + * [~if_compare(leftValue, rightValue, options)](#module_Templating API_ static zcl helpers..if_compare) ⇒ Object + * [~if_is_data_type_signed(type, clusterId, options)](#module_Templating API_ static zcl helpers..if_is_data_type_signed) ⇒ + * [~as_zcl_data_type_size(type, clusterId, options)](#module_Templating API_ static zcl helpers..as_zcl_data_type_size) ⇒ + + + +### Templating API: static zcl helpers~zcl\_bitmaps(options) ⇒ +Block helper iterating over all bitmaps. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_bitmap\_items(options) +Iterates over enum items. Valid only inside zcl_enums. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_enums(options) ⇒ +Block helper iterating over all enums. +If existing independently, it iterates over ALL the enums. +Within a context of a cluster, it iterates only over the +enums belonging to a cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_structs(options) ⇒ +Block helper iterating over all structs. +If existing independently, it iterates over ALL the structs. +Within a context of a cluster, it iterates only over the +structs belonging to a cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_enum\_items(options) +Iterates over enum items. Valid only inside zcl_enums. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~first\_unused\_enum\_value(options) ⇒ +This helper prints out the first unused enum value. +It supports mode="next_larger" and +mode="first_unused" (which is the default). + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the unused enum value + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_struct\_items(options) ⇒ +Block helper iterating over all struct items. Valid only inside zcl_structs. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_struct\_items\_by\_struct\_name(name, options) ⇒ +Block helper iterating over all struct items given the struct name. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | +| --- | +| name | +| options | + + + +### Templating API: static zcl helpers~zcl\_struct\_items\_by\_struct\_and\_cluster\_name(name, clusterName, options) ⇒ +Block helper iterating over all struct items given the struct name and +cluster name. The items iterated will be those that correspond to that +struct name being used within the given cluster. That means the struct name +must be either a global struct (in which case the cluster name is just +ignored), or a struct associated with the given cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | +| --- | +| name | +| clusterName | +| options | + + + +### Templating API: static zcl helpers~zcl\_device\_types(options) ⇒ +Block helper iterating over all deviceTypes. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_device\_type\_clusters(options) ⇒ +Block helper for use inside zcl_device_types + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: blocks for clusters + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_device\_type\_cluster\_commands(options) ⇒ +Block helper for use inside zcl_device_type_clusters + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: blocks for commands + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_device\_type\_cluster\_attributes(options) ⇒ +Block helper for use inside zcl_device_type_clusters + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: blocks for attributes + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_clusters(options) ⇒ +Block helper iterating over all clusters. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_commands(options) ⇒ +Block helper iterating over all commands. +There are two modes of this helper: + when used in a global context, it iterates over ALL commands in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the commands for that cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_command\_responses(options) ⇒ +Returns all commands which are command responses. +For eg, If the xml has the following: + +then newCmdResponse will be included in the list of commands returned here. + +There are two modes of this helper: +- when used in a global context, it iterates over ALL command responses in +the database. +- when used inside a `zcl_cluster` block helper, it iterates only over the +commands responses for that cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: all command responses + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_commands\_with\_cluster\_info(options) ⇒ +Block helper iterating over all commands with cluster information. +Note: Similar to zcl_commands but has cluster information as well. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_commands\_with\_arguments(options) +Helper that retrieves all commands that contain arguments. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_commands\_source\_client(options) ⇒ +Block helper iterating over all client commands. +There are two modes of this helper: + when used in a global context, it iterates over ALL client commands in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the commands for that client cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_commands\_source\_server(options) ⇒ +Block helper iterating over all server commands. +There are two modes of this helper: + when used in a global context, it iterates over ALL server commands in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the commands for that server cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_events(options) ⇒ +Block helper iterating over all events. +There are two modes of this helper: + when used in a global context, it iterates over ALL events in the database. + when used inside a `zcl_cluster` block helper, it iterates only over the events for that cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_command\_tree(options) ⇒ +Block helper iterating over all commands, including their arguments and clusters. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_global\_commands(options) ⇒ +Helper to iterate over all global commands. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of global command iteration. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_attributes(options) ⇒ +Iterator over the attributes. If it is used at toplevel, if iterates over all the attributes +in the database. If used within zcl_cluster context, it iterates over all the attributes +that belong to that cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of attribute iteration. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_attributes\_client(options) ⇒ +Iterator over the client attributes. If it is used at toplevel, if iterates over all the client attributes +in the database. If used within zcl_cluster context, it iterates over all the client attributes +that belong to that cluster. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of attribute iteration. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_attributes\_server(options) ⇒ +Iterator over the server attributes. If it is used at toplevel, if iterates over all the server attributes +in the database. If used within zcl_cluster context, it iterates over all the server attributes +that belong to that cluster. +Available Options: +- removeKeys: Removes one or more keys from the map(for eg keys in db-mapping.js) +for eg: (#zcl_attributes_server removeKeys='isOptional, isNullable') will remove 'isOptional' +from the results + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of attribute iteration. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_atomics(options) ⇒ +Block helper iterating over all atomic types. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_cluster\_largest\_label\_length() ⇒ +Given: N/A + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the length of largest cluster name in a list of clusters + + +### Templating API: static zcl helpers~largestLabelLength(An) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the length of largest object name in an array. Helper for +zcl_cluster_largest_label_length + +| Param | Type | Description | +| --- | --- | --- | +| An | \* | Array | + + + +### Templating API: static zcl helpers~zcl\_command\_arguments\_count(commandId) ⇒ +Helper to extract the number of command arguments in a command + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Number of command arguments as an integer + +| Param | Type | +| --- | --- | +| commandId | \* | + + + +### Templating API: static zcl helpers~ifCommandArgumentsHaveFixedLengthWithCurrentContext(commandId, fixedLengthReturn, notFixedLengthReturn, currentContext) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Description | +| --- | --- | +| commandId | | +| fixedLengthReturn | | +| notFixedLengthReturn | | +| currentContext | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not | + + + +### Templating API: static zcl helpers~if\_command\_arguments\_have\_fixed\_length(commandId, fixedLengthReturn, notFixedLengthReturn) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Description | +| --- | --- | +| commandId | | +| fixedLengthReturn | | +| notFixedLengthReturn | Returns fixedLengthReturn or notFixedLengthReturn based on whether the command is fixed length or not. Does not check if command arguments are always present or not. | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_is\_not\_fixed\_length\_but\_command\_argument\_is\_always\_present(type, command, commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: the underlying zcl type of a command argument if the argument is +not fixed length but is always present. If the condition is not met then +returns an empty string. + +| Param | +| --- | +| type | +| command | +| commandArg | +| appendString | +| options | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_if\_command\_is\_not\_fixed\_length(type, commandId, appendString, options) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Description | +| --- | --- | +| type | | +| commandId | | +| appendString | | +| options | Returns: Given the commandId and the type of one of its arguments, based on whether the command is fixed length or not either return nothing or return the underlying zcl type appended with the appendString. | + + + +### Templating API: static zcl helpers~command\_arguments\_total\_length(commandId) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Description | +| --- | --- | +| commandId | Returns the size of the command by calculating the sum total of the command arguments Note: This helper should be called on fixed length commands only. It should not be called with commands which do not have a fixed length. | + + + +### Templating API: static zcl helpers~zcl\_command\_arguments(options) ⇒ +Block helper iterating over command arguments within a command +or a command tree. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of command argument iteration. + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_event\_fields(options) +Block helper iterating over the event fields inside an event. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Type | +| --- | --- | +| options | \* | + + + +### Templating API: static zcl helpers~zcl\_command\_argument\_data\_type(typeName, options) +Helper that deals with the type of the argument. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Type | +| --- | --- | +| typeName | \* | +| options | \* | + + + +### Templating API: static zcl helpers~asUnderlyingZclType(typeName, options) +Helper that deals with the type of the argument. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Type | Description | +| --- | --- | --- | +| typeName | \* | | +| options | \* | Note: If the options has zclCharFormatter set to true then the function will return the user defined data associated with the zcl data type and not the actual data type. example: {{asUnderlyingZclType [array type] array="b" one_byte="u" two_byte="v" three_byte="x" four_byte="w" short_string="s" long_string="l" default="b" zclCharFormatter="true"}} For the above if asUnderlyingZclType was given [array type] then the above will return 'b' | + + + +### Templating API: static zcl helpers~zcl\_string\_type\_return(type, options) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Description | +| --- | --- | +| type | | +| options | Returns the data mentioned in the helper options based on whether the type is short string, long string or not a string Example: {{zcl_string_type_return type short_string="short string output" long_string="short string output" default="Output when not a string") | + + + +### Templating API: static zcl helpers~is\_zcl\_string(type) +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Description | +| --- | --- | +| type | Return: true or false based on whether the type is a string or not. | + + + +### Templating API: static zcl helpers~if\_is\_number(type) ⇒ +If helper that checks if a type is a string + +example: +{{#if_is_number type}} +type is number +{{else}} +type is not number +{{/if_is_number}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_string(type) ⇒ +If helper that checks if a type is a string + +example: +{{#if_is_string type}} +type is string +{{else}} +type is not string +{{/if_is_string}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_char\_string(type) ⇒ +If helper that checks if a string type is present in the list of char strings +i.e. characterStringTypes + +example: +{{#if_is_char_string type}} +type is char string +{{else}} +type is not char string +{{/if_is_char_string}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_octet\_string(type) ⇒ +If helper that checks if a string type is present in the list of octet strings +i.e. octetStringTypes + +example: +{{#if_is_octet_string type}} +type is octet string +{{else}} +type is not octet string +{{/if_is_octet_string}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_short\_string(type) ⇒ +If helper that checks if a string type is present in the list of short strings +i.e. stringShortTypes + +example: +{{#if_is_short_string type}} +type is short string +{{else}} +type is not short string +{{/if_is_short_string}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_long\_string(type) ⇒ +If helper that checks if a string type is present in the list of long strings +i.e. stringLongTypes + +example: +{{#if_is_long_string type}} +type is long string +{{else}} +type is not long string +{{/if_is_long_string}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_atomic(type:) ⇒ +If helper that checks if a type is an atomic + +example: +{{#if_is_atomic type}} +type is atomic +{{else}} +type is not atomic +{{/if_is_atomic}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | Description | +| --- | --- | --- | +| type: | \* | string | + + + +### Templating API: static zcl helpers~if\_is\_bitmap(type) ⇒ +If helper that checks if a type is a bitmap + +example: +{{#if_is_bitmap type}} +type is bitmap +{{else}} +type is not bitmap +{{/if_is_bitmap}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_enum(type) ⇒ +If helper that checks if a type is an enum + +* example: +{{#if_is_enum type}} +type is enum +{{else}} +type is not enum +{{/if_is_enum}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | Type | +| --- | --- | +| type | \* | + + + +### Templating API: static zcl helpers~if\_is\_struct(type) ⇒ +If helper that checks if a type is an struct + +* example: +{{#if_is_struct type}} +type is struct +{{else}} +type is not struct +{{/if_is_struct}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content. + +| Param | +| --- | +| type | + + + +### Templating API: static zcl helpers~isClient(side) ⇒ +Checks if the side is client or not + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| side | \* | + + + +### Templating API: static zcl helpers~isServer(side) ⇒ +Checks if the side is server or not + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| side | \* | + + + +### Templating API: static zcl helpers~isStrEqual(str1, str2) ⇒ +Compares 2 strings. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| str1 | \* | +| str2 | \* | + + + +### Templating API: static zcl helpers~isLastElement(index, count) ⇒ +Returns boolean based on whether the element is the last element. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| index | \* | +| count | \* | + + + +### Templating API: static zcl helpers~isFirstElement(index, count) ⇒ +Returns boolean based on whether the element is the first element. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| index | \* | +| count | \* | + + + +### Templating API: static zcl helpers~isEnabled(enable) ⇒ +Check if enable is 1. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| enable | \* | + + + +### Templating API: static zcl helpers~isCommandAvailable(clusterSide, incoming, outgoing, source, name) ⇒ +Returns boolean based on command being available or not. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: boolean + +| Param | Type | +| --- | --- | +| clusterSide | \* | +| incoming | \* | +| outgoing | \* | +| source | \* | +| name | \* | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_always\_present(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length and the command +argument is always present in all zcl specifications. + +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | + + + +### Templating API: static zcl helpers~if\_command\_argument\_always\_present(commandId, introducedInRef, removedInRef, presentIf, argumentPresentReturn, argumentNotPresentReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentPresentReturn if the command is not fixed length and command +argument is always present without conditions(introducedInRef, removedInRef, +presentIf) else returns argumentNotPresentReturn + +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentPresentReturn | +| argumentNotPresentReturn | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_not\_always\_present\_no\_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length, the command +argument is not always present in all zcl specifications and there is no present if conditionality +on the command argument. + +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_ca\_not\_always\_present\_no\_presentif(commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed +length, the command argument is not always present in all zcl specifications +and there is no present if conditionality on the command argument. + +| Param | Description | +| --- | --- | +| commandArg | command argument | +| appendString | append the string to the argument | +| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | + + + +### Templating API: static zcl helpers~if\_command\_argument\_not\_always\_present\_no\_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsReturn, argumentInAllVersionsReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentNotInAllVersionsReturn if the command is not fixed length and command +argument is present with conditions introducedInRef or removedInRef but no presentIf +conditions else returns argumentNotPresentReturn + +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentNotInAllVersionsReturn | +| argumentInAllVersionsReturn | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_not\_always\_present\_with\_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length, the command +argument is not always present in all zcl specifications and there is a present if conditionality +on the command argument. + +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_ca\_not\_always\_present\_with\_presentif(commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed +length, the command argument is not always present in all zcl specifications +but there is a present if conditionality on the command argument. + +| Param | Description | +| --- | --- | +| commandArg | command argument | +| appendString | append the string to the argument | +| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | + + + +### Templating API: static zcl helpers~if\_command\_argument\_not\_always\_present\_with\_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentNotInAllVersionsReturn if the command is not fixed length, command +argument is present with conditions introducedInRef or removedInRef and presentIf +conditions exist as well else returns argumentNotPresentReturn + +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentNotInAllVersionsPresentIfReturn | +| argumentInAllVersionsReturn | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_command\_argument\_always\_present\_with\_presentif(type:, commandId:, appendString:, introducedInRef:, removedInRef:, presentIf:, options:) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed length, the command +argument is always present in all zcl specifications and there is a present if conditionality +on the command argument. + +| Param | Description | +| --- | --- | +| type: | type of argument | +| commandId: | command id | +| appendString: | append the string to the argument | +| introducedInRef: | If the command argument is not present in all zcl specifications and was introduced in a certain specification version then this will not be null | +| removedInRef: | If the command argument is not present in all zcl specifications and was removed in a certain specification version then this will not be null | +| presentIf: | If the command argument is present conditionally then this will be a condition and not null | +| options: | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | + + + +### Templating API: static zcl helpers~as\_underlying\_zcl\_type\_ca\_always\_present\_with\_presentif(commandArg, appendString, options) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: A string as an underlying zcl type if the command is not fixed +length, the command argument is always present in all zcl specifications +but there is a present if conditionality on the command argument. + +| Param | Description | +| --- | --- | +| commandArg | command argument | +| appendString | append the string to the argument | +| options | options which can be passed to zclUtil.asUnderlyingZclTypeWithPackageId for determining the underlying zcl type for the provided argument type | + + + +### Templating API: static zcl helpers~if\_command\_argument\_always\_present\_with\_presentif(commandId, introducedInRef, removedInRef, presentIf, argumentNotInAllVersionsPresentIfReturn, argumentInAllVersionsReturn) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: argumentInAllVersionsPresentIfReturn if the command is not fixed length, command +argument is always present and presentIf conditions exist else returns argumentNotPresentReturn + +| Param | +| --- | +| commandId | +| introducedInRef | +| removedInRef | +| presentIf | +| argumentNotInAllVersionsPresentIfReturn | +| argumentInAllVersionsReturn | + + + +### Templating API: static zcl helpers~if\_manufacturing\_specific\_cluster(clusterId, manufacturer_specific_return, null_manufacturer_specific_return) ⇒ +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: manufacturer_specific_return if the cluster is manufacturer +specific or returns null_manufacturer_specific_return if cluster is +not manufacturer specific. + +| Param | Type | +| --- | --- | +| clusterId | \* | +| manufacturer_specific_return | \* | +| null_manufacturer_specific_return | \* | + + + +### Templating API: static zcl helpers~if\_mfg\_specific\_cluster(clusterId, options) ⇒ +If helper which checks if cluster is manufacturing specific or not +example: +{{#if_mfg_specific_cluster clusterId}} + cluster is manufacturing specific +{{else}} + cluster is not manufacturing specific +{{/if_mfg_specific_cluster}} + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Returns content in the handlebar template based on whether the +command is manufacturing specific or not. + +| Param | +| --- | +| clusterId | +| options | + + + +### Templating API: static zcl helpers~as\_generated\_default\_macro(value, attributeSize, options) ⇒ +Given the value and size of an attribute along with endian as an option. +This helper returns the attribute value as big/little endian. +Example: {{as_generated_default_macro 0x00003840 4 endian="big"}} +will return: 0x00, 0x00, 0x38, 0x40, + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Formatted attribute value based on given arguments +Available options: +- endian: Specify 'big' or 'little' endian format +- isCommaTerminated: '0' or '1' for output to have a ',' at the end + +| Param | +| --- | +| value | +| attributeSize | +| options | + + + +### Templating API: static zcl helpers~attribute\_mask(writable, storageOption, minMax, mfgSpecific, clusterCode, client, isSingleton, prefixString, postfixString) ⇒ +Given the attributes of a zcl attribute. Creates an attribute mask based on +the given options +Available options: +isClusterCodeMfgSpecific: 0/1, This is to determine if cluster code needs to +be used to determine if a cluster is mfg specific or not. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: attribute mask based on given values + +| Param | +| --- | +| writable | +| storageOption | +| minMax | +| mfgSpecific | +| clusterCode | +| client | +| isSingleton | +| prefixString | +| postfixString | + + + +### Templating API: static zcl helpers~command\_mask(commmandSource, clusterSide, isIncomingEnabled, isOutgoingEnabled, manufacturingCode, prefixForMask) ⇒ +Given the attributes of a zcl command. Creates a command mask based on +the given options + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: command mask based on given values + +| Param | +| --- | +| commmandSource | +| clusterSide | +| isIncomingEnabled | +| isOutgoingEnabled | +| manufacturingCode | +| prefixForMask | + + + +### Templating API: static zcl helpers~command\_mask\_sub\_helper(commandMask, str) ⇒ +A Sub helper api for command_mask to reduce code redundancy + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: command mask addition based on the arguments + +| Param | +| --- | +| commandMask | +| str | + + + +### Templating API: static zcl helpers~format\_zcl\_string\_as\_characters\_for\_generated\_defaults(stringVal, sizeOfString) ⇒ +This may be used within all_user_cluster_attributes_for_generated_defaults +for example: +{{format_zcl_string_as_characters_for_generated_defaults 'abc' 5}} +will return as follows: +3, 'a', 'b', 'c' 0, 0 + +Available Options: +- isOctet: 0/1 can be used to return results correctly for octet strings +- isCommaTerminated: 0/1 can be used to return result with/without ',' at +the end + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Formatted string for generated defaults starting with the lenth of a +string then each character and then filler for the size allocated for the +string. Long strings prefixed by 2 byte length field. + +| Param | +| --- | +| stringVal | +| sizeOfString | + + + +### Templating API: static zcl helpers~as\_type\_min\_value(type, options) ⇒ +Given a zcl data type return the min allowed value for that zcl data type +based on the language specified in the options + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: max allowed value for the given zcl data type +Available Options: +- language: determines the output of the helper based on language +for eg: (as_type_min_value language='c++') will give the output specific to +the c++ language. +Note: If language is not specified then helper throws an error. + +| Param | Type | +| --- | --- | +| type | \* | +| options | \* | + + + +### Templating API: static zcl helpers~as\_type\_max\_value(type, options) ⇒ +Given a zcl data type return the max allowed value for that zcl data type +based on the language specified in the options + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: max allowed value for the given zcl data type +Available Options: +- language: determines the output of the helper based on language +for eg: (as_type_max_value language='c++') will give the output specific to +the c++ language. +Note: If language is not specified then the helper returns size of type in +bits. + +| Param | Type | +| --- | --- | +| type | \* | +| options | \* | + + + +### Templating API: static zcl helpers~structs\_with\_clusters(options) +Returns all structs which have clusters associated with them + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) + +| Param | Type | Description | +| --- | --- | --- | +| options | \* | Available Options: - groupByStructName: Can group the query results based on struct name for structs which are present in more than one cluster eg Usage: {{#structs_with_clusters groupByStructName=1}}{{/structs_with_clusters}} | + + + +### Templating API: static zcl helpers~as\_zcl\_type\_size(type, options) ⇒ +Returns the size of the zcl type if possible else returns -1 + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: size of zcl type + +| Param | Type | +| --- | --- | +| type | \* | +| options | \* | + + + +### Templating API: static zcl helpers~if\_compare(leftValue, rightValue, options) ⇒ Object +An if helper for comparisons + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Object - Promise of content +example: checking if (4 < 5) +(if_compare 4 5 operator='<') +Content when comparison returns true + +Content when comparison returns false +(/if_compare) + +| Param | Type | +| --- | --- | +| leftValue | \* | +| rightValue | \* | +| options | \* | + + + +### Templating API: static zcl helpers~if\_is\_data\_type\_signed(type, clusterId, options) ⇒ +Check if the given type is signed or not based on the type name and cluster +id. +Note: This helper needs to be used under a block helper which has a +reference to clusterId. + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: Promise of content + +| Param | Type | +| --- | --- | +| type | \* | +| clusterId | \* | +| options | \* | + + + +### Templating API: static zcl helpers~as\_zcl\_data\_type\_size(type, clusterId, options) ⇒ +Fetches the size of the data type based on type name and cluster id given +Note: +- Size is zero for structs +- This helper needs to be used under a block helper which has a +reference to clusterId. +Available Options: +- roundUpToPowerOfTwo: Rounds the size up to the nearest power of 2 +- sizeIn: By default size is returned in bytes but it can be returned in bits +by mentioning sizeIn="bits" + +**Kind**: inner method of [Templating API: static zcl helpers](#module_Templating API_ static zcl helpers) +**Returns**: size of the data type + +| Param | Type | +| --- | --- | +| type | \* | +| clusterId | \* | +| options | \* | + + + +## Templating API: Zigbee Specific helpers +This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + + +* [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) + * [~get_cli_size(size, type, allowZclTypes)](#module_Templating API_ Zigbee Specific helpers..get_cli_size) ⇒ + * [~zcl_command_argument_type_to_cli_data_type_util(type, cliPrefix, context, options)](#module_Templating API_ Zigbee Specific helpers..zcl_command_argument_type_to_cli_data_type_util) ⇒ + * [~zcl_command_argument_type_to_cli_data_type(typeName, options)](#module_Templating API_ Zigbee Specific helpers..zcl_command_argument_type_to_cli_data_type) + * [~zcl_command_argument_type_to_zcl_cli_data_type(typeName, options)](#module_Templating API_ Zigbee Specific helpers..zcl_command_argument_type_to_zcl_cli_data_type) + + + +### Templating API: Zigbee Specific helpers~get\_cli\_size(size, type, allowZclTypes) ⇒ +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) +**Returns**: The size in bits for a cli type based on allowZclTypes + +| Param | Type | +| --- | --- | +| size | \* | +| type | \* | +| allowZclTypes | \* | + + + +### Templating API: Zigbee Specific helpers~zcl\_command\_argument\_type\_to\_cli\_data\_type\_util(type, cliPrefix, context, options) ⇒ +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) +**Returns**: the zcl cli data type string with the cli prefix given +Additional Options: +- isOptional option can be passed along with the command argument +to return optional command argument extension accordingly +eg: +#zcl_command_arguments + zcl_command_argument_type_to_zcl_cli_data_type type isOptional=isOptional +/zcl_command_arguments + +| Param | Type | +| --- | --- | +| type | \* | +| cliPrefix | \* | +| context | \* | +| options | \* | + + + +### Templating API: Zigbee Specific helpers~zcl\_command\_argument\_type\_to\_cli\_data\_type(typeName, options) +Helper that deals with the type of the argument. + +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) + +| Param | Type | +| --- | --- | +| typeName | \* | +| options | \* | + + + +### Templating API: Zigbee Specific helpers~zcl\_command\_argument\_type\_to\_zcl\_cli\_data\_type(typeName, options) +Helper that deals with the type of the argument. + +**Kind**: inner method of [Templating API: Zigbee Specific helpers](#module_Templating API_ Zigbee Specific helpers) + +| Param | Type | +| --- | --- | +| typeName | \* | +| options | \* | + diff --git a/package.json b/package.json index b189cade18..a7a62d60ea 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ "build-spa": "node src-script/build-spa.js", "build-backend": "node src-script/build-backend.js", "doc": "jsdoc src-electron src-shared -r -u docs -d ./generated-html/ README.md", - "apidoc": "jsdoc2md src-shared/**/*.js src-electron/**/*.js > docs/api.md", + "api-doc": "node src-script/generate-all-api-docs.js", + "helper-doc": "node src-script/generate-template-helper-docs.js", "format-code": "pretty-quick", "pretty-quick": "pretty-quick", "version-stamp": "node src-script/zap-versionstamp.js", @@ -213,7 +214,7 @@ ], "husky": { "hooks": { - "pre-commit": "pretty-quick --staged && jsdoc src-electron src-shared -r -d ./generated-html/ && eslint --ext .js,.vue src src-electron src-shared src-script test" + "pre-commit": "pretty-quick --staged && jsdoc src-electron src-shared -r -d ./generated-html/ && eslint ." } }, "build": { diff --git a/src-electron/client/ipc-client.js b/src-electron/client/ipc-client.js index a5773596af..ccb30659ac 100644 --- a/src-electron/client/ipc-client.js +++ b/src-electron/client/ipc-client.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module provides IPC Client functionality. + * + * @module IPC Client API: Inter-process communication + */ + const env = require('../util/env') const ipcServer = require('../server/ipc-server') const util = require('../util/util.js') @@ -28,6 +34,10 @@ const client = { let lastPong = '' +/** + * Log ipc client message + * @param {*} msg + */ function log(msg) { env.logIpc(`Ipc client: ${msg}`) } diff --git a/src-electron/db/db-api.js b/src-electron/db/db-api.js index 93dfee7daf..a1bab73311 100644 --- a/src-electron/db/db-api.js +++ b/src-electron/db/db-api.js @@ -38,6 +38,12 @@ const dbMapping = require('./db-mapping.js') // let inTransaction = false +/** + * Begin Database transaction. + * @param {*} db + * @param {*} resolve + * @param {*} reject + */ function executeBeginTransaction(db, resolve, reject) { db.run('BEGIN TRANSACTION', [], function (err) { if (err) { @@ -50,6 +56,12 @@ function executeBeginTransaction(db, resolve, reject) { }) } +/** + * Delay database transaction. + * @param {*} db + * @param {*} resolve + * @param {*} reject + */ function delayBeginTransaction(db, resolve, reject) { let cnt = 0 let interval = setInterval(() => { @@ -485,6 +497,13 @@ async function determineIfSchemaShouldLoad(db, filePath, crc) { return result } +/** + * Update the CRC of the sql schema file. + * @param {*} db + * @param {*} filePath + * @param {*} crc + * @returns promise of insert transaction. + */ async function updateCurrentSchemaCrc(db, filePath, crc) { return dbInsert( db, @@ -493,6 +512,12 @@ async function updateCurrentSchemaCrc(db, filePath, crc) { ) } +/** + * Load SQL Schema + * @param {*} db + * @param {*} schemaContent + * @returns Promise of loaded schema + */ async function performSchemaLoad(db, schemaContent) { return new Promise((resolve, reject) => { env.logSql('Loading schema.') diff --git a/src-electron/db/query-access.js b/src-electron/db/query-access.js index 0fbc2f9e04..b2a8f6a61d 100644 --- a/src-electron/db/query-access.js +++ b/src-electron/db/query-access.js @@ -23,6 +23,12 @@ const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') +/** + * Get access operations for package IDs given. + * @param {*} db + * @param {*} packageIds + * @returns promise of access operation. + */ async function selectAccessOperations(db, packageIds) { return dbApi .dbAll( @@ -36,6 +42,12 @@ SELECT NAME, DESCRIPTION FROM OPERATION WHERE PACKAGE_REF IN (${dbApi.toInClause .then((rows) => rows.map(dbMapping.map.accessOperation)) } +/** + * Get access roles for package IDs given. + * @param {*} db + * @param {*} packageIds + * @returns promise of access roles. + */ async function selectAccessRoles(db, packageIds) { return dbApi .dbAll( @@ -49,6 +61,12 @@ SELECT NAME, DESCRIPTION, LEVEL FROM ROLE WHERE PACKAGE_REF IN (${dbApi.toInClau .then((rows) => rows.map(dbMapping.map.accessRole)) } +/** + * Get access modifiers for package IDs given. + * @param {*} db + * @param {*} packageIds + * @returns promise of access modifiers. + */ async function selectAccessModifiers(db, packageIds) { return dbApi .dbAll( @@ -99,6 +117,12 @@ ORDER BY OPERATION.NAME, ROLE.NAME, ACCESS_MODIFIER.NAME .then((rows) => rows.map(dbMapping.map.access)) } +/** + * Get attribute access information for the attribute id given. + * @param {*} db + * @param {*} attributeId + * @returns Promise of attribute access information + */ async function selectAttributeAccess(db, attributeId) { return dbApi .dbAll( @@ -128,6 +152,12 @@ ORDER BY OPERATION.NAME, ROLE.NAME, ACCESS_MODIFIER.NAME .then((rows) => rows.map(dbMapping.map.access)) } +/** + * Get command access information for the attribute id given. + * @param {*} db + * @param {*} commandId + * @returns Promise of command access information + */ async function selectCommandAccess(db, commandId) { return dbApi .dbAll( @@ -157,6 +187,12 @@ ORDER BY OPERATION.NAME, ROLE.NAME, ACCESS_MODIFIER.NAME .then((rows) => rows.map(dbMapping.map.access)) } +/** + * Get event access information for the attribute id given. + * @param {*} db + * @param {*} eventId + * @returns Promise of event access information + */ async function selectEventAccess(db, eventId) { return dbApi .dbAll( diff --git a/src-electron/db/query-atomic.js b/src-electron/db/query-atomic.js index 8228e198b4..456edd7783 100644 --- a/src-electron/db/query-atomic.js +++ b/src-electron/db/query-atomic.js @@ -20,6 +20,7 @@ * * @module DB API: zcl database access */ + const dbApi = require('./db-api.js') const dbCache = require('./db-cache.js') const dbMapping = require('./db-mapping.js') @@ -42,7 +43,12 @@ FROM ATOMIC const cacheKey = 'atomic' // Raw query versions without caching. - +/** + * Get all atomic data type information + * @param {*} db + * @param {*} packageId + * @returns atomic data types + */ async function selectAllAtomics(db, packageId) { let rows = await dbApi.dbAll( db, diff --git a/src-electron/db/query-attribute.js b/src-electron/db/query-attribute.js index 7dda83da3a..8e52e3568b 100644 --- a/src-electron/db/query-attribute.js +++ b/src-electron/db/query-attribute.js @@ -20,6 +20,7 @@ * * @module DB API: attribute queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') const dbCache = require('./db-cache') @@ -565,7 +566,6 @@ async function selectAttributeDetailsFromEnabledClusters( * Union is used to get separate entries of attributes w.r.t to default, minimum * and maximum values */ - async function selectAttributeBoundDetails( db, endpointsAndClusters, @@ -793,6 +793,15 @@ async function selectReportableAttributeDetailsFromEnabledClustersAndEndpoints( .then((rows) => rows.map(mapFunction)) } +/** + * Get attribute data by attribute code. + * @param {*} db + * @param {*} packageIds + * @param {*} clusterCode + * @param {*} attributeCode + * @param {*} manufacturerCode + * @returns promise of attribute data + */ async function selectAttributeByCode( db, packageIds, @@ -818,6 +827,15 @@ async function selectAttributeByCode( } } +/** + * Get attribute information by code for attributes which are not global. + * @param {*} db + * @param {*} packageIds + * @param {*} clusterCode + * @param {*} attributeCode + * @param {*} manufacturerCode + * @returns promise of attribute data + */ async function selectNonGlobalAttributeByCode( db, packageIds, @@ -878,6 +896,14 @@ WHERE A.PACKAGE_REF IN (${dbApi.toInClause(packageIds)}) .then(dbMapping.map.attribute) } +/** + * Get global attributes by their attribute code. + * @param {*} db + * @param {*} packageIds + * @param {*} attributeCode + * @param {*} manufacturerCode + * @returns promise of global attribute data + */ async function selectGlobalAttributeByCode( db, packageIds, diff --git a/src-electron/db/query-bitmap.js b/src-electron/db/query-bitmap.js index ffdf934a51..44b70b80a2 100644 --- a/src-electron/db/query-bitmap.js +++ b/src-electron/db/query-bitmap.js @@ -20,6 +20,7 @@ * * @module DB API: zcl database access */ + const dbApi = require('./db-api') const dbCache = require('./db-cache') const dbMapping = require('./db-mapping') @@ -51,6 +52,13 @@ WHERE PACKAGE_REF = ? ORDER BY NAME`, return rows.map(dbMapping.map.bitmap) } +/** + * Get bitmap by name from the given package IDs. + * @param {*} db + * @param {*} packageIds + * @param {*} name + * @returns promise of bitmap + */ async function selectBitmapByName(db, packageIds, name) { return dbApi .dbGet( @@ -104,6 +112,12 @@ async function selectBitmapByNameAndClusterId(db, name, clusterId, packageIds) { } } +/** + * Get Bitmap information by Bitmap ID. + * @param {*} db + * @param {*} id + * @returns Promise of bitmap + */ async function selectBitmapById(db, id) { return dbApi .dbGet( diff --git a/src-electron/db/query-cluster.js b/src-electron/db/query-cluster.js index 349c7ffba2..3404f6316a 100644 --- a/src-electron/db/query-cluster.js +++ b/src-electron/db/query-cluster.js @@ -20,6 +20,7 @@ * * @module DB API: cluster queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') diff --git a/src-electron/db/query-command.js b/src-electron/db/query-command.js index b4f4fdd23f..0057162a8e 100644 --- a/src-electron/db/query-command.js +++ b/src-electron/db/query-command.js @@ -20,6 +20,7 @@ * * @module DB API: command queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') @@ -827,6 +828,15 @@ ORDER BY CLUSTER.NAME, COMMAND.NAME` .then((rows) => rows.map(mapFunction)) } +/** + * Get command by command code and given package ID. + * @param {*} db + * @param {*} packageId + * @param {*} clusterCode + * @param {*} commandCode + * @param {*} mfgCode + * @returns Promise of command. + */ async function selectCommandByCode( db, packageId, @@ -847,6 +857,15 @@ async function selectCommandByCode( } } +/** + * Get command that is not a global command by command code and package ID. + * @param {*} db + * @param {*} packageId + * @param {*} clusterCode + * @param {*} commandCode + * @param {*} mfgCode + * @returns Promise of command. + */ async function selectNonGlobalCommandByCode( db, packageId, @@ -888,6 +907,14 @@ async function selectNonGlobalCommandByCode( return dbApi.dbGet(db, query, args).then(dbMapping.map.command) } +/** + * Get global command by command code and package ID. + * @param {*} db + * @param {*} packageId + * @param {*} commandCode + * @param {*} mfgCode + * @returns Promise of command + */ async function selectGlobalCommandByCode( db, packageId, @@ -926,6 +953,12 @@ async function selectGlobalCommandByCode( return dbApi.dbGet(db, query, args).then(dbMapping.map.command) } +/** + * Get command by command ID. + * @param {*} db + * @param {*} id + * @returns Promise of command + */ async function selectCommandById(db, id) { return dbApi .dbGet( @@ -996,6 +1029,12 @@ ORDER BY CODE`, .then((rows) => rows.map(dbMapping.map.command)) } +/** + * Get all commands which have command arguments from the given package ID. + * @param {*} db + * @param {*} packageId + * @returns Promise of commands + */ async function selectAllCommandsWithArguments(db, packageId) { let mapFunction = (x) => { return { @@ -1185,6 +1224,12 @@ ORDER BY CLUSTER.CODE, COMMAND.CODE` .then((rows) => rows.map(dbMapping.map.command)) } +/** + * Get all commands from the given package IDs + * @param {*} db + * @param {*} packageIds + * @returns Promise of commands + */ async function selectAllCommands(db, packageIds) { return dbApi .dbAll( @@ -1219,6 +1264,13 @@ ORDER BY COMMAND.CODE, COMMAND.NAME` .then((rows) => rows.map(dbMapping.map.command)) } +/** + * Get all commands by source(client/server) from the given package IDs. + * @param {*} db + * @param {*} source + * @param {*} packageIds + * @returns Promise of commands + */ async function selectAllCommandsBySource(db, source, packageIds) { return dbApi .dbAll( @@ -1291,6 +1343,12 @@ ORDER BY CODE`, .then((rows) => rows.map(dbMapping.map.command)) } +/** + * Get all global commands from given package IDs. + * @param {*} db + * @param {*} packageIds + * @returns Promise of global commands + */ async function selectAllGlobalCommands(db, packageIds) { return dbApi .dbAll( @@ -1328,6 +1386,12 @@ ORDER BY .then((rows) => rows.map(dbMapping.map.command)) } +/** + * Get all commands from the given package ID. + * @param {*} db + * @param {*} packageId + * @returns Promise of Commands + */ async function selectAllClusterCommands(db, packageId) { return dbApi .dbAll( @@ -1358,6 +1422,12 @@ ORDER BY .then((rows) => rows.map(dbMapping.map.command)) } +/** + * Get all command arguments from the given package IDs. + * @param {*} db + * @param {*} packageIds + * @returns Promise of command arguments + */ async function selectAllCommandArguments(db, packageIds) { return dbApi .dbAll( @@ -1538,6 +1608,11 @@ WHERE ) } +/** + * An exception for the command map in db-mapping.js + * @param {*} x + * @returns Command map + */ function commandMapFunction(x) { return { id: x.COMMAND_ID, diff --git a/src-electron/db/query-config.js b/src-electron/db/query-config.js index f160c34cdb..2437b57c34 100644 --- a/src-electron/db/query-config.js +++ b/src-electron/db/query-config.js @@ -20,6 +20,7 @@ * * @module DB API: user configuration queries against the database. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') const queryPackage = require('./query-package.js') @@ -165,7 +166,7 @@ async function insertClusterDefaults(db, endpointTypeId, packageId, cluster) { /** * Promise to update the attribute state. - * If the attribute entry [as defined uniquely by endpointTypeId and id], is not there, then create a default entry + * If an attribute entry [as defined uniquely by endpointTypeId and id], is not there, then create a default entry * Afterwards, update entry. * @param {*} db * @param {*} endpointTypeId @@ -322,6 +323,14 @@ WHERE } } +/** + * Updates the endpoint type attribute table. + * + * @param {*} db + * @param {*} id + * @param {*} keyValuePairs + * @returns Promise of an endpoint type atribute table update. + */ async function updateEndpointTypeAttribute(db, id, keyValuePairs) { if (keyValuePairs == null || keyValuePairs.length == 0) return @@ -341,6 +350,11 @@ WHERE ENDPOINT_TYPE_ATTRIBUTE_ID = ?` return dbApi.dbUpdate(db, query, args) } +/** + * Based on the given key returns a database table column name. + * @param {*} key + * @returns Database table Column as String + */ function convertRestKeyToDbColumn(key) { switch (key) { case restApi.updateKey.endpointId: @@ -385,6 +399,13 @@ function convertRestKeyToDbColumn(key) { throw new Error(`Invalid rest update key: ${key}`) } +/** + * Create a Database column name and value string which can be used in database + * queries. + * + * @param {*} paramValuePairArray + * @returns string + */ function getAllParamValuePairArrayClauses(paramValuePairArray) { return paramValuePairArray.reduce((currentString, paramValuePair, index) => { if (index > 0) currentString += ',' @@ -412,7 +433,7 @@ function getAllParamValuePairArrayClauses(paramValuePairArray) { /** * Promise to update the command state. - * If the attribute entry [as defined uniquely by endpointTypeId and id], is not there, then create a default entry + * If the command entry [as defined uniquely by endpointTypeId and id], is not there, then create a default entry * Afterwards, update entry. * * @param {*} db @@ -480,7 +501,7 @@ WHERE ENDPOINT_TYPE_CLUSTER_REF = ? /** * Promise to update the event state. - * If the attribute entry [as defined uniquely by endpointTypeId and id], is not there, then create a default entry + * If an event entry [as defined uniquely by endpointTypeId and id], is not there, then create a default entry * Afterwards, update entry. * * @param {*} db @@ -1066,6 +1087,14 @@ async function resolveDefaultDeviceTypeAttributes( return Promise.all(promises) } +/** + * Initialize the command values within an endpoint type Id based on device type. + * + * @param {*} db + * @param {*} endpointTypeId + * @param {*} deviceCommand + * @returns An array of promises which update command state. + */ async function resolveCommandState(db, endpointTypeId, deviceCommand) { let deviceTypeCluster = await queryDeviceType.selectDeviceTypeClusterByDeviceTypeClusterId( @@ -1132,6 +1161,14 @@ async function resolveDefaultDeviceTypeCommands( ) } +/** + * Resolve non optional commands for given parameters. + * @param {*} db + * @param {*} endpointTypeId + * @param {*} clusters + * @param {*} packageIds + * @returns Promise of clusters with commands resolved + */ async function resolveNonOptionalCommands( db, endpointTypeId, @@ -1169,6 +1206,14 @@ async function resolveNonOptionalCommands( return Promise.all(clustersPromises) } +/** + * Resolve attribute defaults for endpoint type clusters. + * @param {*} db + * @param {*} endpointTypeId + * @param {*} packageId + * @param {*} endpointClusters + * @returns Array of promises for endpointClusters with attributes + */ async function resolveDefaultAttributes( db, endpointTypeId, @@ -1199,6 +1244,14 @@ async function resolveDefaultAttributes( return Promise.all(endpointClustersPromises) } +/** + * Get Non optional and reportable attributes foor the given arguments. + * @param {*} db + * @param {*} endpointTypeId + * @param {*} attributes + * @param {*} cluster + * @returns Promise of Attributes + */ async function resolveNonOptionalAndReportableAttributes( db, endpointTypeId, @@ -1315,7 +1368,6 @@ WHERE SESSION_PARTITION.SESSION_REF = ? * @param {*} clusterRef * @param {*} side */ - async function insertOrSelectDefaultEndpointTypeCluster( db, endpointTypeId, diff --git a/src-electron/db/query-data-type-discriminator.js b/src-electron/db/query-data-type-discriminator.js index 9792f6e624..804e943c45 100644 --- a/src-electron/db/query-data-type-discriminator.js +++ b/src-electron/db/query-data-type-discriminator.js @@ -16,7 +16,9 @@ */ /** - * This module provides queries for discriminators + * This module provides queries for data type discriminator + * + * @module DB API: Data type discriminator queries against the database. */ const dbApi = require('./db-api') diff --git a/src-electron/db/query-data-type.js b/src-electron/db/query-data-type.js index 83c0a76091..d297737c58 100644 --- a/src-electron/db/query-data-type.js +++ b/src-electron/db/query-data-type.js @@ -17,6 +17,8 @@ /** * This module provides queries for data types + * + * @module DB API: Data type queries against the database. */ const dbApi = require('./db-api') diff --git a/src-electron/db/query-device-type.js b/src-electron/db/query-device-type.js index 3f2a8d8462..688848badd 100644 --- a/src-electron/db/query-device-type.js +++ b/src-electron/db/query-device-type.js @@ -20,6 +20,7 @@ * * @module DB API: device type database access */ + const dbApi = require('./db-api') const dbMapping = require('./db-mapping') @@ -95,6 +96,13 @@ async function selectDeviceTypeByCode(db, packageId, code) { .then(dbMapping.map.deviceType) } +/** + * Get all device type clusters from a given device type ID. + * + * @param {*} db + * @param {*} deviceTypeRef + * @returns Promise of device type clusters + */ async function selectDeviceTypeClustersByDeviceTypeRef(db, deviceTypeRef) { let rows = await dbApi.dbAll( db, @@ -118,6 +126,13 @@ async function selectDeviceTypeClustersByDeviceTypeRef(db, deviceTypeRef) { return rows.map(dbMapping.map.deviceTypeCluster) } +/** + * Get device type cluster details from the device type cluster ID. + * + * @param {*} db + * @param {*} deviceTypeClusterId + * @returns Promise of device type cluster + */ async function selectDeviceTypeClusterByDeviceTypeClusterId( db, deviceTypeClusterId @@ -143,6 +158,13 @@ async function selectDeviceTypeClusterByDeviceTypeClusterId( return dbMapping.map.deviceTypeCluster(row) } +/** + * Get all device type commands from a given device type ID. + * + * @param {*} db + * @param {*} deviceTypeRef + * @returns Promise of device type attributes + */ async function selectDeviceTypeAttributesByDeviceTypeRef(db, deviceTypeRef) { let rows = await dbApi.dbAll( db, @@ -171,6 +193,13 @@ async function selectDeviceTypeAttributesByDeviceTypeRef(db, deviceTypeRef) { return rows.map(dbMapping.map.deviceTypeAttribute) } +/** + * Get all device type commands from a given device type ID. + * + * @param {*} db + * @param {*} deviceTypeRef + * @returns Promise of device type commands + */ async function selectDeviceTypeCommandsByDeviceTypeRef(db, deviceTypeRef) { let rows = await dbApi.dbAll( db, diff --git a/src-electron/db/query-endpoint-type.js b/src-electron/db/query-endpoint-type.js index 0dd7e85efe..61b4144999 100644 --- a/src-electron/db/query-endpoint-type.js +++ b/src-electron/db/query-endpoint-type.js @@ -20,6 +20,7 @@ * * @module DB API: endpoint type queries against the database. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') @@ -29,7 +30,6 @@ const dbMapping = require('./db-mapping.js') * @param {*} sessionId * @param {*} id */ - async function deleteEndpointType(db, id) { return dbApi.dbRemove( db, diff --git a/src-electron/db/query-endpoint.js b/src-electron/db/query-endpoint.js index ecabd23c82..52075a401b 100644 --- a/src-electron/db/query-endpoint.js +++ b/src-electron/db/query-endpoint.js @@ -20,6 +20,7 @@ * * @module DB API: endpoint configuration queries against the database. */ + const dbApi = require('./db-api.js') const bin = require('../util/bin') const dbMapping = require('./db-mapping.js') diff --git a/src-electron/db/query-enum.js b/src-electron/db/query-enum.js index 94489f3bec..91949ef07e 100644 --- a/src-electron/db/query-enum.js +++ b/src-electron/db/query-enum.js @@ -18,8 +18,9 @@ /** * This module provides queries for enums. * - * @module DB API: zcl database access + * @module DB API: zcl database enum access */ + const dbApi = require('./db-api') const dbCache = require('./db-cache') const dbMapping = require('./db-mapping') diff --git a/src-electron/db/query-event.js b/src-electron/db/query-event.js index a97ceb1f4a..dd6301206d 100644 --- a/src-electron/db/query-event.js +++ b/src-electron/db/query-event.js @@ -20,6 +20,7 @@ * * @module DB API: event queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') @@ -96,6 +97,13 @@ ORDER BY .then((rows) => rows.map(dbMapping.map.event)) } +/** + * Get all event fields for the pacckage IDs given. + * + * @param {*} db + * @param {*} packageIds + * @returns Promise of event fields + */ async function selectAllEventFields(db, packageIds) { return dbApi .dbAll( @@ -123,6 +131,13 @@ ORDER BY .then((rows) => rows.map(dbMapping.map.eventField)) } +/** + * Get all event fields for the given event ID. + * + * @param {*} db + * @param {*} eventId + * @returns Pomise of events fields + */ async function selectEventFieldsByEventId(db, eventId) { return dbApi .dbAll( diff --git a/src-electron/db/query-impexp.js b/src-electron/db/query-impexp.js index 627fcf48a9..360df59efe 100644 --- a/src-electron/db/query-impexp.js +++ b/src-electron/db/query-impexp.js @@ -20,6 +20,7 @@ * * @module DB API: package-based queries. */ + const dbApi = require('./db-api') const dbEnums = require('../../src-shared/db-enum') const dbMapping = require('./db-mapping.js') diff --git a/src-electron/db/query-loader.js b/src-electron/db/query-loader.js index ba0a066789..a81c07c6ea 100644 --- a/src-electron/db/query-loader.js +++ b/src-electron/db/query-loader.js @@ -20,6 +20,7 @@ * * @module DB API: zcl loading queries */ + const env = require('../util/env') const dbApi = require('./db-api.js') const queryNotification = require('../db/query-package-notification') @@ -203,6 +204,14 @@ WHERE AND DATA_TYPE.DISCRIMINATOR_REF = ?` +/** + * Transforms the array of attributes in a certain format and returns it. + * + * @param {*} clusterId + * @param {*} packageId + * @param {*} attributes + * @returns Array of attribute details + */ function attributeMap(clusterId, packageId, attributes) { return attributes.map((attribute) => [ clusterId, @@ -238,6 +247,14 @@ function attributeMap(clusterId, packageId, attributes) { ]) } +/** + * Transforms the array of events in a certain format and returns it. + * + * @param {*} clusterId + * @param {*} packageId + * @param {*} events + * @returns Array of event details + */ function eventMap(clusterId, packageId, events) { return events.map((event) => [ clusterId, @@ -257,6 +274,14 @@ function eventMap(clusterId, packageId, events) { ]) } +/** + * Transforms the array of commands in a certain format and returns it. + * + * @param {*} clusterId + * @param {*} packageId + * @param {*} commands + * @returns Array of command details + */ function commandMap(clusterId, packageId, commands) { return commands.map((command) => [ clusterId, @@ -278,6 +303,14 @@ function commandMap(clusterId, packageId, commands) { ]) } +/** + * Transforms the array of event fields in a certain format and returns it. + * + * @param {*} eventId + * @param {*} packageId + * @param {*} fields + * @returns Array of event field details + */ function fieldMap(eventId, packageId, fields) { return fields.map((field) => [ eventId, @@ -294,6 +327,14 @@ function fieldMap(eventId, packageId, fields) { ]) } +/** + * Transforms the array of command args in a certain format and returns it. + * + * @param {*} cmdId + * @param {*} packageId + * @param {*} args + * @returns Array of command arg details + */ function argMap(cmdId, packageId, args) { return args.map((arg) => [ cmdId, @@ -316,7 +357,15 @@ function argMap(cmdId, packageId, args) { ]) } -// access data is array of objects, containing id/op/role/modifier +/** + * access data is array of objects, containing id/op/role/modifier. + * Insert attribute access data. + * + * @param {*} db + * @param {*} packageId + * @param {*} accessData + * @returns Promise of insert on attribute access + */ async function insertAttributeAccessData(db, packageId, accessData) { let rowIds = await createAccessRows(db, packageId, accessData) let insertData = [] @@ -331,7 +380,15 @@ async function insertAttributeAccessData(db, packageId, accessData) { ) } -// access data is array of objects, containing id/op/role/modifier +/** + * access data is array of objects, containing id/op/role/modifier. + * Insert command access data. + * + * @param {*} db + * @param {*} packageId + * @param {*} accessData + * @returns Promise of insert on command access + */ async function insertCommandAccessData(db, packageId, accessData) { let rowIds = await createAccessRows(db, packageId, accessData) let insertData = [] @@ -345,7 +402,16 @@ async function insertCommandAccessData(db, packageId, accessData) { insertData ) } -// access data is array of objects, containing id/op/role/modifier + +/** + * access data is array of objects, containing id/op/role/modifier. + * Insert event access data. + * + * @param {*} db + * @param {*} packageId + * @param {*} accessData + * @returns Promise of insert on event access + */ async function insertEventAccessData(db, packageId, accessData) { let rowIds = await createAccessRows(db, packageId, accessData) let insertData = [] @@ -360,6 +426,14 @@ async function insertEventAccessData(db, packageId, accessData) { ) } +/** + * Insert attribute details. + * + * @param {*} db + * @param {*} packageId + * @param {*} attributes + * @returns None + */ async function insertAttributes(db, packageId, attributes) { let data = attributes.data let access = attributes.access @@ -431,6 +505,14 @@ async function insertAttributeMappings(db, data) { ) } +/** + * Insert event details. + * + * @param {*} db + * @param {*} packageId + * @param {*} events + * @returns None + */ async function insertEvents(db, packageId, events) { let data = events.data let fieldData = events.fields @@ -469,6 +551,14 @@ async function insertEvents(db, packageId, events) { } } +/** + * Insert command details + * + * @param {*} db + * @param {*} packageId + * @param {*} commands + * @returns None + */ async function insertCommands(db, packageId, commands) { let data = commands.data let argData = commands.args @@ -995,7 +1085,6 @@ async function getEndpointCompositionIdByCode(db, deviceType) { * @param {number} endpointCompositionId - The ID of the endpoint composition. * @returns {Promise} A promise that resolves when the insertion is complete. */ - function insertDeviceComposition(db, deviceType, endpointCompositionId) { const insertQuery = ` INSERT INTO DEVICE_COMPOSITION (CODE, ENDPOINT_COMPOSITION_REF, CONFORMANCE, DEVICE_CONSTRAINT) @@ -1184,6 +1273,14 @@ async function insertDeviceTypeCommands(db, dtClusterRefDataPairs) { ) } +/** + * Insert into Access operation Table. + * + * @param {*} db + * @param {*} packageId + * @param {*} operations + * @returns Promise of Access Operation insert operation. + */ async function insertAccessOperations(db, packageId, operations) { let data = operations.map((o) => [packageId, o.name, o.description]) return dbApi.dbMultiInsert( @@ -1198,6 +1295,14 @@ VALUES ) } +/** + * Insert into Access Role Table. + * + * @param {*} db + * @param {*} packageId + * @param {*} roles + * @returns Promise of Access Role insert operation. + */ async function insertAccessRoles(db, packageId, roles) { let data = roles.map((r) => [packageId, r.name, r.description, r.level]) return dbApi.dbMultiInsert( @@ -1212,6 +1317,14 @@ VALUES ) } +/** + * Insert into Access Modifier Table. + * + * @param {*} db + * @param {*} packageId + * @param {*} modifiers + * @returns Promise of Access Modifier insert operation. + */ async function insertAccessModifiers(db, packageId, modifiers) { let data = modifiers.map((m) => [packageId, m.name, m.description]) return dbApi.dbMultiInsert( diff --git a/src-electron/db/query-number.js b/src-electron/db/query-number.js index 490f3f6313..fe8fe67a15 100644 --- a/src-electron/db/query-number.js +++ b/src-electron/db/query-number.js @@ -16,8 +16,11 @@ */ /** - * This module provides queries for numbers + * This module provides queries for numbers. + * + * @module DB API: zcl database number access */ + const dbApi = require('./db-api') const dbMapping = require('./db-mapping') const dbCache = require('./db-cache') diff --git a/src-electron/db/query-package-notification.js b/src-electron/db/query-package-notification.js index f982cbb182..477d5fac74 100644 --- a/src-electron/db/query-package-notification.js +++ b/src-electron/db/query-package-notification.js @@ -15,13 +15,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /** * This module provides package notification related queries. * * @module DB API: session related queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') + /** * Sets a notification in the PACKAGE_NOTICE table * diff --git a/src-electron/db/query-package.js b/src-electron/db/query-package.js index c3557b7aa4..63505ec354 100644 --- a/src-electron/db/query-package.js +++ b/src-electron/db/query-package.js @@ -20,6 +20,7 @@ * * @module DB API: package-based queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') const dbEnum = require('../../src-shared/db-enum.js') diff --git a/src-electron/db/query-session-notification.js b/src-electron/db/query-session-notification.js index beb0f6005f..1b0bec4d86 100644 --- a/src-electron/db/query-session-notification.js +++ b/src-electron/db/query-session-notification.js @@ -15,11 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /** * This module provides session notification related queries. * * @module DB API: session related queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') const wsServer = require('../server/ws-server.js') diff --git a/src-electron/db/query-session-zcl.js b/src-electron/db/query-session-zcl.js index 00dfbbcb02..26ba4f7fbd 100644 --- a/src-electron/db/query-session-zcl.js +++ b/src-electron/db/query-session-zcl.js @@ -22,6 +22,7 @@ * * @module DB API: zcl database access */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') const dbEnum = require('../../src-shared/db-enum.js') diff --git a/src-electron/db/query-session.js b/src-electron/db/query-session.js index a4026099d3..6f9721771b 100644 --- a/src-electron/db/query-session.js +++ b/src-electron/db/query-session.js @@ -20,6 +20,7 @@ * * @module DB API: session related queries. */ + const dbApi = require('./db-api.js') const dbMapping = require('./db-mapping.js') const util = require('../util/util.js') diff --git a/src-electron/db/query-string.js b/src-electron/db/query-string.js index 6a1dbed701..7860efee9c 100644 --- a/src-electron/db/query-string.js +++ b/src-electron/db/query-string.js @@ -16,7 +16,9 @@ */ /** - * This module provides queries for strings + * This module provides queries for strings. + * + * @module DB API: zcl database strings access */ const dbApi = require('./db-api') diff --git a/src-electron/db/query-struct.js b/src-electron/db/query-struct.js index af5776ecf7..49ca9300f8 100644 --- a/src-electron/db/query-struct.js +++ b/src-electron/db/query-struct.js @@ -20,11 +20,18 @@ * * @module DB API: zcl database access */ + const dbApi = require('./db-api') const dbCache = require('./db-cache') const dbMapping = require('./db-mapping') const queryUtil = require('./query-util') +/** + * Get all structs from a given package ID. + * @param {*} db + * @param {*} packageId + * @returns Promise of Structs + */ async function selectAllStructs(db, packageId) { let rows = await dbApi.dbAll( db, @@ -49,6 +56,12 @@ async function selectAllStructs(db, packageId) { return rows.map(dbMapping.map.struct) } +/** + * Get struct details from the given struct ID. + * @param {*} db + * @param {*} id + * @returns Promise of Struct + */ async function selectStructById(db, id) { return dbApi .dbGet( @@ -73,6 +86,14 @@ WHERE .then(dbMapping.map.struct) } +/** + * Get Struct details from the given struct name and package IDs. + * + * @param {*} db + * @param {*} name + * @param {*} packageIds + * @returns Promise of Struct + */ async function selectStructByName(db, name, packageIds) { return dbApi .dbGet( diff --git a/src-electron/db/query-util.js b/src-electron/db/query-util.js index 732ade4d02..5adedae9a0 100644 --- a/src-electron/db/query-util.js +++ b/src-electron/db/query-util.js @@ -21,8 +21,16 @@ * * @module DB API: zcl database access */ + const dbApi = require('./db-api') +/** + * Formulate a sqlite query string for a data type from the given cluster ID and package IDs. + * @param {*} typeDiscriminator + * @param {*} clusterId + * @param {*} packageIds + * @returns SQLite query string + */ function sqlQueryForDataTypeByNameAndClusterId( typeDiscriminator, clusterId = null, diff --git a/src-electron/db/query-zcl.js b/src-electron/db/query-zcl.js index 161080272a..9e704d26d1 100644 --- a/src-electron/db/query-zcl.js +++ b/src-electron/db/query-zcl.js @@ -20,6 +20,7 @@ * * @module DB API: zcl database access */ + const dbApi = require('./db-api') const dbMapping = require('./db-mapping') const queryAtomic = require('./query-atomic') @@ -67,6 +68,12 @@ ORDER BY DT.NAME`, .then((rows) => rows.map(dbMapping.map.bitmap)) } +/** + * Get bitmap fields from the given bitmap ID. + * @param {*} db + * @param {*} id + * @returns Promise of bitmap fields + */ async function selectAllBitmapFieldsById(db, id) { return dbApi .dbAll( @@ -77,6 +84,13 @@ async function selectAllBitmapFieldsById(db, id) { .then((rows) => rows.map(dbMapping.map.bitmapField)) } +/** + * Get all bitmap fields from the given package ID. + * + * @param {*} db + * @param {*} packageId + * @returns Promise of bitmap fields + */ async function selectAllBitmapFields(db, packageId) { return dbApi .dbAll( @@ -104,6 +118,12 @@ async function selectAllDomains(db, packageId) { .then((rows) => rows.map(dbMapping.map.domain)) } +/** + * Get Domain details from the given domain ID. + * @param {*} db + * @param {*} id + * @returns Promise of domain + */ async function selectDomainById(db, id) { return dbApi .dbGet(db, 'SELECT DOMAIN_ID, NAME FROM DOMAIN WHERE DOMAIN_ID = ?', [id]) @@ -293,6 +313,14 @@ async function selectAllStructsWithItems(db, packageIds) { return selectStructsWithItemsImpl(db, packageIds, null) } +/** + * Get Struct details along with its struct items. + * + * @param {*} db + * @param {*} packageIds + * @param {*} clusterId + * @returns struct details + */ async function selectStructsWithItemsImpl(db, packageIds, clusterId) { let query let args = [] @@ -407,6 +435,12 @@ async function selectStructsWithItemsImpl(db, packageIds, clusterId) { }, []) } +/** + * Get struct item details from the given struct item ID. + * @param {*} db + * @param {*} id + * @returns Promise of Stuct Items + */ async function selectAllStructItemsById(db, id) { return dbApi .dbAll( @@ -690,6 +724,15 @@ ORDER BY CODE`, .then((rows) => rows.map(dbMapping.map.attribute)) } +/** + * Get attribute details from the given information. + * + * @param {*} db + * @param {*} clusterId + * @param {*} packageIds + * @param {*} side + * @returns Promise of attribute details + */ async function selectAttributesByClusterIdAndSideIncludingGlobal( db, clusterId, @@ -808,6 +851,13 @@ WHERE C.CODE = ? .then((rows) => rows.map(dbMapping.map.attribute)) } +/** + * Get attribute details from the given attribute ID. + * + * @param {*} db + * @param {*} id + * @returns Promise of attribute + */ async function selectAttributeById(db, id) { return dbApi .dbGet( @@ -917,6 +967,13 @@ WHERE ATTRIBUTE_ID = ?`, .then(dbMapping.map.attribute) } +/** + * Get all attributes from the given package IDs. + * + * @param {*} db + * @param {*} packageIds + * @returns Promise of attributes + */ async function selectAllAttributes(db, packageIds) { return dbApi .dbAll( @@ -1017,6 +1074,13 @@ ORDER BY CODE`, return rows.map(dbMapping.map.attribute) } +/** + * Get the endpoint type cluster details from the given endpoint type ID. + * + * @param {*} db + * @param {*} endpointTypeId + * @returns Promise of endpoint type clusters. + */ async function selectEndpointTypeClustersByEndpointTypeId(db, endpointTypeId) { let rows = await dbApi.dbAll( db, @@ -1038,6 +1102,13 @@ ORDER BY return rows.map(dbMapping.map.endpointTypeCluster) } +/** + * Get the endpoint type attribute details from the given endpoint type ID. + * + * @param {*} db + * @param {*} endpointTypeId + * @returns Promise of endpoint type attributes. + */ async function selectEndpointTypeAttributesByEndpointId(db, endpointTypeId) { let rows = await dbApi.dbAll( db, @@ -1067,6 +1138,15 @@ ORDER BY ATTRIBUTE_REF`, return rows.map(dbMapping.map.endpointTypeAttribute) } +/** + * Get the endpoint type attribute details from the given details. + * + * @param {*} db + * @param {*} endpointTypeId + * @param {*} attributeRef + * @param {*} clusterRef + * @returns Promise of endpoint type attribute. + */ async function selectEndpointTypeAttribute( db, endpointTypeId, @@ -1102,6 +1182,13 @@ WHERE return dbMapping.map.endpointTypeAttribute(row) } +/** + * Get the endpoint type command details from the given endpoint type ID. + * + * @param {*} db + * @param {*} endpointTypeId + * @returns Promise of endpoint type commands + */ async function selectEndpointTypeCommandsByEndpointId(db, endpointTypeId) { let rows = await dbApi.dbAll( db, @@ -1142,6 +1229,13 @@ ORDER BY return rows.map(dbMapping.map.endpointTypeCommand) } +/** + * Get endpoint type events from the given endpoint type ID. + * + * @param {*} db + * @param {*} endpointTypeId + * @returns Promise of endpoint type events + */ async function selectEndpointTypeEventsByEndpointId(db, endpointTypeId) { let rows = await dbApi.dbAll( db, diff --git a/src-electron/generator/generation-engine.js b/src-electron/generator/generation-engine.js index f7df672664..657297bd89 100644 --- a/src-electron/generator/generation-engine.js +++ b/src-electron/generator/generation-engine.js @@ -18,6 +18,7 @@ /** * @module JS API: generator logic */ + const _ = require('lodash') const fs = require('fs') const fsPromise = fs.promises @@ -56,6 +57,18 @@ async function loadGenTemplateFromFile(path) { } } +/** + * Inserts the package details when they do not exist. + * + * @param {*} db + * @param {*} packagePath + * @param {*} parentId + * @param {*} packageType + * @param {*} version + * @param {*} category + * @param {*} description + * @returns Promise of package insertion + */ async function recordPackageIfNonexistent( db, packagePath, @@ -89,6 +102,15 @@ async function recordPackageIfNonexistent( } } +/** + * Insert the template options from the json meta data file. + * + * @param {*} db + * @param {*} packageId + * @param {*} category + * @param {*} externalPath + * @returns Promise of inserted template options + */ async function loadTemplateOptionsFromJsonFile( db, packageId, @@ -584,6 +606,13 @@ async function loadGenTemplatesJsonFile(db, genTemplatesJson) { } } +/** + * Get the package information from the given package ID. + * + * @param {*} db + * @param {*} genTemplatesPkgId + * @returns package information + */ async function retrievePackageMetaInfo(db, genTemplatesPkgId) { let metaInfo = { aliases: [], @@ -1023,6 +1052,12 @@ async function generateAndWriteFiles( } } +/** + * Create a generation log. + * + * @param {*} logFile + * @param {*} genData + */ async function createGenerationLog(logFile, genData) { try { let jsonData diff --git a/src-electron/generator/helper-access.js b/src-electron/generator/helper-access.js index dbe253e986..88df9a66d9 100644 --- a/src-electron/generator/helper-access.js +++ b/src-electron/generator/helper-access.js @@ -15,16 +15,23 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: Access helpers + */ + const queryAccess = require('../db/query-access') const templateUtil = require('./template-util') const dbEnum = require('../../src-shared/db-enum') /** - * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * Collects the default access list * - * @module Templating API: Access helpers + * @param {*} ctx + * @param {*} entityType + * @returns Promise of default access */ - async function collectDefaultAccessList(ctx, entityType) { let packageIds = await templateUtil.ensureZclPackageIds(ctx) let defaultAccess = await queryAccess.selectDefaultAccess( @@ -35,6 +42,13 @@ async function collectDefaultAccessList(ctx, entityType) { return defaultAccess } +/** + * Get Access List based on on given options. + * + * @param {*} ctx + * @param {*} options + * @returns Access List + */ async function collectAccesslist(ctx, options) { let entityType = null let includeDefault = true @@ -185,6 +199,12 @@ async function access(options) { return templateUtil.templatePromise(this.global, p) } +/** + * Get the access list information. + * + * @param {*} options + * @returns access list + */ async function default_access(options) { let entityType = null diff --git a/src-electron/generator/helper-attribute.js b/src-electron/generator/helper-attribute.js index 39eac9ca05..870f730975 100644 --- a/src-electron/generator/helper-attribute.js +++ b/src-electron/generator/helper-attribute.js @@ -15,9 +15,20 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: Attribute helpers + */ + const queryAttribute = require('../db/query-attribute') const templateUtil = require('./template-util') +/** + * Get feature bits from the given context. + * @param {*} options + * @returns feature bits + */ async function featureBits(options) { if ('featureBits' in this) { let p = templateUtil.collectBlocks(this.featureBits, options, this) diff --git a/src-electron/generator/helper-c.js b/src-electron/generator/helper-c.js index 69cb0c2f7d..2cb2c23153 100644 --- a/src-electron/generator/helper-c.js +++ b/src-electron/generator/helper-c.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: C formatting helpers + */ + const queryZcl = require('../db/query-zcl.js') const queryPackage = require('../db/query-package.js') const templateUtil = require('./template-util.js') @@ -25,12 +31,6 @@ const _ = require('lodash') const dbEnum = require('../../src-shared/db-enum.js') const envConfig = require('../util/env') -/** - * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} - * - * @module Templating API: C formatting helpers - */ - /** * Given a hex number, it prints the offset, which is the index of the first non-zero bit. * @param {*} hex @@ -195,8 +195,13 @@ function asSymbol(value) { return value } -// Formats the default value into an attribute of a given length -function formatValue(value, length, type) { +/** + * Formats the default value into an attribute of a given length + * @param {*} value + * @param {*} length + * @returns Formatted value + */ +function formatValue(value, length) { let out = '' if (length < 0) { out = out.concat(value.length) @@ -251,7 +256,7 @@ async function asBytes(value, type) { return bin.hexToCBytes(bin.stringToHex(value)) } } else { - return formatValue(value, x, type) + return formatValue(value, x) } }) } diff --git a/src-electron/generator/helper-command.js b/src-electron/generator/helper-command.js index 1681abdbee..e37c1a5b33 100644 --- a/src-electron/generator/helper-command.js +++ b/src-electron/generator/helper-command.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: Command helpers + */ + const queryCommand = require('../db/query-command.js') const templateUtil = require('./template-util.js') const types = require('../util/types.js') diff --git a/src-electron/generator/helper-endpointconfig.js b/src-electron/generator/helper-endpointconfig.js index 1584b84d0b..624fd9d99a 100644 --- a/src-electron/generator/helper-endpointconfig.js +++ b/src-electron/generator/helper-endpointconfig.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: Matter endpoint config helpers + */ + const cHelper = require('./helper-c.js') const templateUtil = require('./template-util') const queryEndpoint = require('../db/query-endpoint.js') @@ -144,6 +150,12 @@ function endpoint_fixed_endpoint_type_array(options) { return '{ ' + indexes.join(', ') + ' }' } +/** + * Get indexes and manufacturer code. + * + * @param {*} codeIndexPairs + * @returns String + */ function createMfgCodes(codeIndexPairs) { let ret = '{ \\\n' if (codeIndexPairs.length == 0) { @@ -167,42 +179,100 @@ function endpoint_attribute_manufacturer_codes(options) { return createMfgCodes(this.attributeMfgCodes) } +/** + * Get count of attributes with manufacturer code. + * + * @param {*} options + * @returns Count of attributes with manufacturer code + */ function endpoint_attribute_manufacturer_code_count(options) { return this.attributeMfgCodes.length } +/** + * Get all command manufacturer codes. + * @param {*} options + * @returns all command manufacturer codes + */ function endpoint_command_manufacturer_codes(options) { return createMfgCodes(this.commandMfgCodes) } +/** + * Get count of commands with manufacturer code. + * + * @param {*} options + * @returns Count of commands with manufacturer code + */ function endpoint_command_manufacturer_code_count(options) { return this.commandMfgCodes.length } +/** + * Get all cluster manufacturer codes. + * @param {*} options + * @returns all cluster manufacturer codes + */ function endpoint_cluster_manufacturer_codes(options) { return createMfgCodes(this.clusterMfgCodes) } +/** + * Get count of clusters with manufacturer code. + * + * @param {*} options + * @returns Count of clusters with manufacturer code + */ function endpoint_cluster_manufacturer_code_count(options) { return this.clusterMfgCodes.length } +/** + * Get size of largest attribute. + * + * @param {*} options + * @returns size of largest attribute + */ function endpoint_largest_attribute_size(options) { return this.largestAttribute + 1 } +/** + * Get cumulative size of all singleton endpoint type attributes. + * + * @param {*} options + * @returns cumulative size of all singleton endpoint type attributes + */ function endpoint_singletons_size(options) { return this.singletonsSize } +/** + * Get cumulative size of all endpoint type attributes. + * + * @param {*} options + * @returns cumulative size of all endpoint type attributes + */ function endpoint_total_storage_size(options) { return this.totalAttributeSize } +/** + * Get count of endpoint type commands. + * + * @param {*} options + * @returns Count of endpoint type commands + */ function endpoint_command_count(options) { return this.commandList.length } +/** + * Get endpoint type information. + * + * @param {*} options + * @returns endpoint type information + */ function endpoint_types_list(options) { let ret = '{ \\\n' this.endpointList.forEach((ep) => { @@ -213,10 +283,22 @@ function endpoint_types_list(options) { return ret.concat('}\n') } +/** + * Get count of endpoint type clusters. + * + * @param {*} options + * @returns Count of endpoint type clusters + */ function endpoint_cluster_count(options) { return this.clusterList.length } +/** + * Get endpoint type cluster information. + * + * @param {*} options + * @returns endpoint type cluster information + */ function endpoint_cluster_list(options) { let ret = '{ \\\n' this.clusterList.forEach((c) => { @@ -235,6 +317,12 @@ function endpoint_cluster_list(options) { return ret.concat('}\n') } +/** + * Get endpoint type command information. + * + * @param {*} options + * @returns endpoint type command information + */ function endpoint_command_list(options) { let comment = null @@ -260,10 +348,22 @@ function endpoint_command_list(options) { return ret } +/** + * Get count of endpoint type attributes. + * + * @param {*} options + * @returns Count of endpoint type attributes + */ function endpoint_attribute_count(options) { return this.attributeList.length } +/** + * Get endpoint type attribute information. + * + * @param {*} options + * @returns endpoint type attribute information + */ function endpoint_attribute_list(options) { let order = options.hash.order if (order == null || order.length == 0) { @@ -343,6 +443,13 @@ function endpoint_attribute_list(options) { return ret } +/** + * Extracting device versions and identifiers from endpoint types + * + * @param {*} context + * @param {*} options + * @returns list of device types + */ async function device_list(context, options) { // Extracting device versions and identifiers from endpoint types let endpointTypes = context.endpointTypes @@ -359,6 +466,12 @@ async function device_list(context, options) { return deviceList } +/** + * Get all device types in the configuration. + * + * @param {*} options + * @returns device types + */ async function endpoint_fixed_device_type_array(options) { let deviceList = await device_list(this, options) let isEndpointIncluded = @@ -393,6 +506,12 @@ async function endpoint_fixed_device_type_array(options) { return ret } +/** + * Get device type offset per endpoint. + * + * @param {*} options + * @returns Device type offset per endpoint + */ async function endpoint_fixed_device_type_array_offsets(options) { let deviceList = await device_list(this, options) let ret = '{ ' @@ -423,6 +542,12 @@ async function endpoint_fixed_device_type_array_offsets(options) { return ret } +/** + * Get count of device types per endpoint. + * + * @param {*} options + * @returns Count of device types per endpoint + */ async function endpoint_fixed_device_type_array_lengths(options) { let deviceList = await device_list(this, options) let endpointDeviceLengthMap = {} @@ -447,10 +572,22 @@ async function endpoint_fixed_device_type_array_lengths(options) { return ret } +/** + * Get count of total attributes with min max values listed. + * + * @param {*} options + * @returns count of total attributes with min max values listed + */ function endpoint_attribute_min_max_count(options) { return this.minMaxList.length } +/** + * Get all attributes with min max values defined. + * + * @param {*} options + * @returns All attributes with min max values listed + */ function endpoint_attribute_min_max_list(options) { let comment = null let order = options.hash.order @@ -597,14 +734,32 @@ function endpoint_reporting_config_defaults(options) { return ret } +/** + * Get count of total attributes with reporting enabled + * + * @param {*} options + * @returns Count of total attributes with reporting enabled + */ function endpoint_reporting_config_default_count(options) { return this.reportList.length } +/** + * Get long(size>2 bytes) attribute count. + * + * @param {*} options + * @returns count of long attributes + */ function endpoint_attribute_long_defaults_count(options) { return this.longDefaultsList.length } +/** + * Get long(size>2 bytes) attribute default values based on endianness. + * + * @param {*} options + * @returns Long attribute's default values + */ function endpoint_attribute_long_defaults(options) { let comment = null @@ -636,6 +791,12 @@ function endpoint_attribute_long_defaults(options) { return ret } +/** + * Get 32 bit code from the given code and manufacturer code. + * @param {*} manufacturerCode + * @param {*} code + * @returns 32 bit Hex Code. + */ function asMEI(manufacturerCode, code) { // Left-shift (and for that matter bitwise or) produces a _signed_ 32-bit // number, which will probably be negative. Force it to unsigned 32-bit using @@ -643,8 +804,18 @@ function asMEI(manufacturerCode, code) { return '0x' + bin.int32ToHex(((manufacturerCode << 16) | code) >>> 0) } -// The representation of null depends on the type, so we can't use a single -// macro that's defined elsewhere for "null value". +/** + * The representation of null depends on the type, so we can't use a single + * macro that's defined elsewhere for "null value". + * Get the default value of an attribute. + * @param {*} specifiedDefault + * @param {*} type + * @param {*} typeSize + * @param {*} isNullable + * @param {*} db + * @param {*} sessionId + * @returns Attribute's default value + */ async function determineAttributeDefaultValue( specifiedDefault, type, @@ -1130,6 +1301,12 @@ async function collectAttributeTypeInfo(db, zclPackageIds, endpointTypes) { return endpointTypes } +/** + * Checks if global attribute is excluded from the meta data. + * + * @param {*} attr + * @returns boolean + */ function isGlobalAttrExcludedFromMetadata(attr) { // See Matter specification section "7.13. Global Elements". return ( diff --git a/src-electron/generator/helper-future.js b/src-electron/generator/helper-future.js index 479a623e84..b613a3e49d 100644 --- a/src-electron/generator/helper-future.js +++ b/src-electron/generator/helper-future.js @@ -14,6 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: Future helpers + */ + const futureKey = 'futures' const valueKey = 'futureValues' const timeoutMessage = '!---timeout---!' diff --git a/src-electron/generator/helper-sdkextension.js b/src-electron/generator/helper-sdkextension.js index 395b772bfc..3f54e919c8 100644 --- a/src-electron/generator/helper-sdkextension.js +++ b/src-electron/generator/helper-sdkextension.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: SDK extension helpers + */ + const dbEnum = require('../../src-shared/db-enum.js') const templateUtil = require('./template-util.js') const util = require('../util/util.js') @@ -24,7 +30,6 @@ const util = require('../util/util.js') * * @module Templating API: C formatting helpers */ - async function clusterExtension(context, prop, clusterCode, role) { return templateUtil .ensureTemplatePackageId(context) @@ -122,6 +127,14 @@ async function attribute_type_extension(options) { } } +/** + * Get extension values for the given information. + * + * @param {*} context + * @param {*} prop + * @param {*} entityType + * @returns extension default value + */ async function subentityExtension(context, prop, entityType) { if (prop == null) return '' @@ -186,6 +199,12 @@ async function subentityExtension(context, prop, entityType) { return val } +/** + * If helper for command extensions(true condition). + * + * @param {*} options + * @returns content like an if handlebar helper + */ function if_command_extension_true(options) { let prop = options.hash.property if (prop == '') return '' @@ -203,6 +222,12 @@ function if_command_extension_true(options) { }) } +/** + * If helper for command extensions(false condition). + * + * @param {*} options + * @returns content like an if handlebar helper + */ function if_command_extension_false(options) { let prop = options.hash.property if (prop == '') return '' @@ -220,6 +245,12 @@ function if_command_extension_false(options) { }) } +/** + * If helper for cluster extensions(true condition). + * + * @param {*} options + * @returns content like an if handlebar helper + */ function if_cluster_extension_true(options) { let prop = options.hash.property let code = options.hash.code @@ -235,6 +266,12 @@ function if_cluster_extension_true(options) { }) } +/** + * If helper for cluster extensions(false condition). + * + * @param {*} options + * @returns content like an if handlebar helper + */ function if_cluster_extension_false(options) { let prop = options.hash.property let code = options.hash.code diff --git a/src-electron/generator/helper-session.js b/src-electron/generator/helper-session.js index e1a223ba32..fbb3d2200e 100644 --- a/src-electron/generator/helper-session.js +++ b/src-electron/generator/helper-session.js @@ -20,6 +20,7 @@ * * @module Templating API: user-data specific helpers */ + const templateUtil = require('./template-util.js') const queryImpexp = require('../db/query-impexp.js') const queryCluster = require('../db/query-cluster.js') @@ -210,6 +211,11 @@ function user_cluster_events(options) { return templateUtil.templatePromise(this.global, promise) } +/** + * Get count of total endpoint types. + * + * @returns count of total endpoint types + */ function user_endpoint_type_count() { let promise = queryConfig.selectEndpointTypeCount( this.global.db, @@ -334,6 +340,17 @@ async function all_user_cluster_command_util( return templateUtil.collectBlocks(availableCommands, options, currentContext) } +/** + * Get attribute details based on given arguments. + * + * @param {*} name + * @param {*} side + * @param {*} options + * @param {*} currentContext + * @param {*} isManufacturingSpecific + * @param {*} isIrrespectiveOfManufacturingSpecification + * @returns Attribute details + */ async function all_user_cluster_attribute_util( name, side, @@ -747,6 +764,12 @@ async function if_command_discovery_enabled(options) { } } +/** + * Get Session's manufacturer code. + * + * @param {*} options + * @returns session's manufacturer code + */ async function user_manufacturer_code(options) { let value = await querySession.getSessionKeyValue( this.global.db, @@ -758,6 +781,12 @@ async function user_manufacturer_code(options) { else return value } +/** + * Get user's default response policy selected. + * + * @param {*} options + * @returns user's default response policy selected + */ async function user_default_response_policy(options) { let value = await querySession.getSessionKeyValue( this.global.db, @@ -819,9 +848,10 @@ async function is_command_default_response_disabled(command, options) { } } -/* +/** + * Get endpoint identifier from the given endpoint type ID. * @param {*} endpointTypeId - * Returns the endpoint type identifier for an endpoint type + * @returns the endpoint type identifier for an endpoint type */ async function endpoint_type_identifier(endpointTypeId) { let endpointTypes = await templateUtil.ensureEndpointTypeIds(this) @@ -842,10 +872,11 @@ async function endpoint_type_identifier(endpointTypeId) { return '0' } -/* - * @param {*} endpointTypeId - * Returns the index of the endpoint whose endpointTypeId is endpointTypeId +/** + * Get the index of the endpoint whose endpointTypeId is endpointTypeId * Will return -1 if the given endpoint type is not present. + * @param {*} endpointTypeId + * @returns integer */ async function endpoint_type_index(endpointTypeId) { let endpointTypes = await templateUtil.ensureEndpointTypeIds(this) @@ -1158,6 +1189,12 @@ async function all_incoming_commands_for_cluster_combined( return templateUtil.collectBlocks(clustersWithIncomingCommands, options, this) } +/** + * Get all incoming commands in the user configuration. + * + * @param {*} options + * @returns all incoming commands enabled by the user. + */ async function all_user_incoming_commands_for_all_clusters(options) { let packageIds = await templateUtil.ensureZclPackageIds(this) let isMfgSpec = diff --git a/src-electron/generator/helper-tokens.js b/src-electron/generator/helper-tokens.js index 026310433e..96cfc5dc82 100644 --- a/src-electron/generator/helper-tokens.js +++ b/src-electron/generator/helper-tokens.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: Token helpers + */ + const templateUtil = require('./template-util') const types = require('../util/types.js') const string = require('../util/string') @@ -22,6 +28,12 @@ const helperC = require('./helper-c.js') const queryAttribute = require('../db/query-attribute.js') const queryCluster = require('../db/query-cluster.js') +/** + * Get a transformed config object. + * + * @param {*} config + * @returns object + */ function token_cluster_create(config) { return { name: config.name, @@ -225,6 +237,12 @@ function token_next(context) { context.token_id = context.token_id + 1 } +/** + * Get JSON stringified value of the obj. + * + * @param {*} obj + * @returns JSON string + */ function debug_object(obj) { return JSON.stringify(obj) } diff --git a/src-electron/generator/helper-zap.js b/src-electron/generator/helper-zap.js index 9ab35b1647..83ae6160bd 100644 --- a/src-electron/generator/helper-zap.js +++ b/src-electron/generator/helper-zap.js @@ -15,15 +15,15 @@ * limitations under the License. */ -const templateUtil = require('./template-util.js') -const queryPackage = require('../db/query-package.js') - /** * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} * * @module Templating API: toplevel utility helpers */ +const templateUtil = require('./template-util.js') +const queryPackage = require('../db/query-package.js') + /** * Produces the top-of-the-file header for a C file. * @@ -46,6 +46,12 @@ function ident(cnt) { } } +/** + * Return new lines based on the given cnt parameter. + * + * @param {*} cnt + * @returns new line + */ function new_line(cnt) { if (Number.isInteger(cnt)) { return '\n'.repeat(cnt) @@ -54,6 +60,11 @@ function new_line(cnt) { } } +/** + * return back slash + * + * @returns string + */ function backslash() { return '\\' } @@ -208,6 +219,14 @@ function is_lowercase_equal(string_a, string_b) { return 0 == str1.localeCompare(str2) } +/** + * Return true/false result based on condition. + * + * @param {*} condition + * @param {*} trueResult + * @param {*} falseResult + * @returns boolean + */ function toggle(condition, trueResult, falseResult) { return condition ? trueResult : falseResult } @@ -253,6 +272,12 @@ function iterate(options) { return ret } +/** + * Add to accumulator results. + * + * @param {*} accumulator + * @param {*} value + */ function addToAccumulator(accumulator, value) { if (!('accumulators' in this.global)) { this.global.accumulators = {} @@ -276,6 +301,12 @@ function addToAccumulator(accumulator, value) { this.global.accumulators[accumulator].currentSum = newSum } +/** + * Get accumulated information from templates. + * + * @param {*} options + * @returns accumulated details + */ function iterateAccumulator(options) { let hash = options.hash if (!('accumulators' in this.global)) { @@ -299,6 +330,14 @@ function iterateAccumulator(options) { return ret } +/** + * Waits for promise to be resolved synchronously. + * + * @param {*} pollInterval + * @param {*} promise + * @param {*} resolve + * @param {*} reject + */ function waitForSynchronousPromise(pollInterval, promise, resolve, reject) { if (promise.isResolved()) { resolve() @@ -312,6 +351,11 @@ function waitForSynchronousPromise(pollInterval, promise, resolve, reject) { } } +/** + * Resolves all the given globalPromises promises. + * + * @param {*} globalPromises + */ async function promiseToResolveAllPreviousPromises(globalPromises) { if (globalPromises.length > 0) { let promises = [] @@ -326,6 +370,13 @@ async function promiseToResolveAllPreviousPromises(globalPromises) { } } +/** + * Resolve the after promise after all other promises in the global context + * have been resolved. + * + * @param {*} options + * @returns Content after all other content has been resolved. + */ async function after(options) { await promiseToResolveAllPreviousPromises(this.global.promises) let newContext = { diff --git a/src-electron/generator/helper-zcl.js b/src-electron/generator/helper-zcl.js index a1c8a08204..35394ddadd 100644 --- a/src-electron/generator/helper-zcl.js +++ b/src-electron/generator/helper-zcl.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: static zcl helpers + */ + const queryZcl = require('../db/query-zcl') const queryDeviceType = require('../db/query-device-type') const queryCommand = require('../db/query-command') @@ -33,12 +39,6 @@ const octetStringTypes = ['OCTET_STRING', 'LONG_OCTET_STRING'] const stringShortTypes = ['CHAR_STRING', 'OCTET_STRING'] const stringLongTypes = ['LONG_CHAR_STRING', 'LONG_OCTET_STRING'] -/** - * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} - * - * @module Templating API: static zcl helpers - */ - /** * Block helper iterating over all bitmaps. * @@ -1701,22 +1701,57 @@ function isServer(side) { return 0 == side.localeCompare(dbEnum.side.server) } +/** + * Compares 2 strings. + * + * @param {*} str1 + * @param {*} str2 + * @returns boolean + */ function isStrEqual(str1, str2) { return 0 == str1.localeCompare(str2) } +/** + * Returns boolean based on whether the element is the last element. + * @param {*} index + * @param {*} count + * @returns boolean + */ function isLastElement(index, count) { return index == count - 1 } +/** + * Returns boolean based on whether the element is the first element. + * @param {*} index + * @param {*} count + * @returns boolean + */ function isFirstElement(index, count) { return index == 0 } +/** + * Check if enable is 1. + * + * @param {*} enable + * @returns boolean + */ function isEnabled(enable) { return 1 == enable } +/** + * Returns boolean based on command being available or not. + * + * @param {*} clusterSide + * @param {*} incoming + * @param {*} outgoing + * @param {*} source + * @param {*} name + * @returns boolean + */ function isCommandAvailable(clusterSide, incoming, outgoing, source, name) { if (0 == clusterSide.localeCompare(source)) { return false @@ -1848,7 +1883,6 @@ function if_command_argument_always_present( * argument is not always present in all zcl specifications and there is no present if conditionality * on the command argument. */ - function as_underlying_zcl_type_command_argument_not_always_present_no_presentif( type, commandId, diff --git a/src-electron/generator/helper-zigbee-zcl.js b/src-electron/generator/helper-zigbee-zcl.js index c92f53021c..4c7e84d66c 100644 --- a/src-electron/generator/helper-zigbee-zcl.js +++ b/src-electron/generator/helper-zigbee-zcl.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains the API for templating. For more detailed instructions, read {@tutorial template-tutorial} + * + * @module Templating API: Zigbee Specific helpers + */ + const queryZcl = require('../db/query-zcl') const dbEnum = require('../../src-shared/db-enum') const templateUtil = require('./template-util') diff --git a/src-electron/generator/matter/app/zap-templates/common/ChipTypesHelper.js b/src-electron/generator/matter/app/zap-templates/common/ChipTypesHelper.js index 49bcde8104..64e75ac03c 100644 --- a/src-electron/generator/matter/app/zap-templates/common/ChipTypesHelper.js +++ b/src-electron/generator/matter/app/zap-templates/common/ChipTypesHelper.js @@ -17,6 +17,12 @@ const dbEnum = require('../../../../../../src-shared/db-enum'); +/** + * Get hardcoded basic type based on the given type. + * + * @param {*} type + * @returns string + */ function asBasicType(type) { switch (type) { case 'chip::ActionId': diff --git a/src-electron/generator/matter/app/zap-templates/common/ClusterTestGeneration.js b/src-electron/generator/matter/app/zap-templates/common/ClusterTestGeneration.js index d018c464e9..e4aa9ac825 100644 --- a/src-electron/generator/matter/app/zap-templates/common/ClusterTestGeneration.js +++ b/src-electron/generator/matter/app/zap-templates/common/ClusterTestGeneration.js @@ -62,6 +62,12 @@ class NullObject { } } +/** + * Throw error using given data. + * + * @param {*} test + * @param {*} errorStr + */ function throwError(test, errorStr) { console.error( 'Error in: ' + @@ -74,6 +80,13 @@ function throwError(test, errorStr) { throw new Error(); } +/** + * Set default value for the given parameters. + * + * @param {*} test + * @param {*} name + * @param {*} defaultValue + */ function setDefault(test, name, defaultValue) { if (!(name in test)) { if (defaultValue == null) { @@ -85,6 +98,10 @@ function setDefault(test, name, defaultValue) { } } +/** + * Set default type. + * @param {*} test + */ function setDefaultType(test) { if (kWaitCommandName in test) { setDefaultTypeForWaitCommand(test); @@ -93,6 +110,11 @@ function setDefaultType(test) { } } +/** + * Set default type for wait command. + * + * @param {*} test + */ function setDefaultTypeForWaitCommand(test) { const type = test[kWaitCommandName]; switch (type) { @@ -133,6 +155,11 @@ function setDefaultTypeForWaitCommand(test) { test.isWait = true; } +/** + * Set default type for command. + * + * @param {*} test + */ function setDefaultTypeForCommand(test) { const type = test[kCommandName]; switch (type) { @@ -219,6 +246,13 @@ function setDefaultTypeForCommand(test) { test.isWait = false; } +/** + * Set default PICS. + * + * @param {*} test + * @param {*} picsFilePath + * @returns None + */ function setDefaultPICS(test, picsFilePath) { const defaultPICS = ''; setDefault(test, kPICSName, defaultPICS); @@ -239,6 +273,12 @@ function setDefaultPICS(test, picsFilePath) { }); } +/** + * Set default arguments. + * + * @param {*} test + * @returns None + */ function setDefaultArguments(test) { const defaultArguments = {}; setDefault(test, kArgumentsName, defaultArguments); @@ -262,12 +302,25 @@ function setDefaultArguments(test) { delete test[kArgumentsName].value; } +/** + * Ensure a valid error. + * + * @param {*} response + * @param {*} errorName + */ function ensureValidError(response, errorName) { if (isNaN(response[errorName])) { response[errorName] = 'EMBER_ZCL_STATUS_' + response[errorName]; } } +/** + * Set default response. + * + * @param {*} test + * @param {*} useSynthesizeWaitForReport + * @returns None + */ function setDefaultResponse(test, useSynthesizeWaitForReport) { // Some of the tests does not have any command defined. if (!test.command || test.isWait) { @@ -408,6 +461,14 @@ function setDefaultResponse(test, useSynthesizeWaitForReport) { }); } +/** + * Set defaults. + * + * @param {*} test + * @param {*} defaultConfig + * @param {*} useSynthesizeWaitForReport + * @param {*} picsFilePath + */ function setDefaults( test, defaultConfig, @@ -431,6 +492,16 @@ function setDefaults( setDefaultResponse(test, useSynthesizeWaitForReport); } +/** + * Get yaml data. + * + * @param {*} filename + * @param {*} useSynthesizeWaitForReport + * @param {*} picsFilePath + * @param {*} certificationDir + * @param {*} testDir + * @returns yaml data + */ function parseYamlTest( filename, useSynthesizeWaitForReport, @@ -501,12 +572,24 @@ function parseYamlTest( return yaml; } +/** + * Log Errors and exit. + * + * @param {*} context + * @param {*} msg + */ function printErrorAndExit(context, msg) { console.log('\nERROR:\n', context.testName, ': ', context.label); console.log(msg); process.exit(1); } +/** + * Get Attribute, commands or events for a cluster. + * + * @param {*} context + * @returns Attribute, commands or events for a cluster + */ function assertCommandOrAttributeOrEvent(context) { const clusterName = context.cluster; return getClusters(context).then((clusters) => { @@ -579,6 +662,12 @@ function assertCommandOrAttributeOrEvent(context) { let loadedPICS = null; +/** + * Retireve PICS. + * + * @param {*} filepath + * @returns PICS + */ function retrievePICS(filepath) { if (loadedPICS != null) return loadedPICS; @@ -601,9 +690,12 @@ function retrievePICS(filepath) { return loadedPICS; } -// -// Templates -// +/** + * Get PICS. + * Templates. + * @param {*} options + * @returns PICS + */ function chip_tests_pics(options) { return templateUtil.collectBlocks( retrievePICS(this.global.resource('pics-metafile')).getAll(), @@ -612,6 +704,11 @@ function chip_tests_pics(options) { ); } +/** + * Configure test item. + * + * @param {*} item + */ async function configureTestItem(item) { if (item.isCommand) { let command = await assertCommandOrAttributeOrEvent(item); @@ -635,6 +732,13 @@ async function configureTestItem(item) { } } +/** + * Get tests. + * + * @param {*} listOrJson + * @param {*} options + * @returns tests + */ async function chip_tests(listOrJson, options) { // Set a global on our items so assertCommandOrAttributeOrEvent can work. let global = this.global; @@ -697,10 +801,24 @@ async function chip_tests(listOrJson, options) { return templateUtil.collectBlocks(tests, options, this); } +/** + * Get items in this context. + * + * @param {*} options + * @returns items + */ function chip_tests_items(options) { return templateUtil.collectBlocks(this.tests, options, this); } +/** + * Get variable. + * + * @param {*} context + * @param {*} key + * @param {*} name + * @returns variable + */ function getVariable(context, key, name) { if ( !( @@ -724,6 +842,14 @@ function getVariable(context, key, name) { return context.variables[key].find((variable) => variable.name == name); } +/** + * Get variable details. + * + * @param {*} context + * @param {*} key + * @param {*} name + * @returns variable or Error + */ function getVariableOrThrow(context, key, name) { const variable = getVariable(context, key, name); if (variable == null) { @@ -732,50 +858,108 @@ function getVariableOrThrow(context, key, name) { return variable; } +/** + * Get variables. + * + * @param {*} options + * @returns variables + */ function chip_tests_variables(options) { return templateUtil.collectBlocks(this.variables.tests, options, this); } +/** + * Check if tests have the variable. + * + * @param {*} name + * @param {*} options + * @returns boolean + */ function chip_tests_variables_has(name, options) { const variable = getVariable(this, 'tests', name); return !!variable; } +/** + * Get type of variable. + * @param {*} name + * @param {*} options + * @returns type of variable + */ function chip_tests_variables_get_type(name, options) { const variable = getVariableOrThrow(this, 'tests', name); return variable.type; } +/** + * Return boolean based on variable's nullable property. + * @param {*} name + * @param {*} options + * @returns boolean + */ function chip_tests_variables_is_nullable(name, options) { const variable = getVariableOrThrow(this, 'tests', name); return variable.isNullable; } +/** + * Get config + * @param {*} options + * @returns config + */ function chip_tests_config(options) { return templateUtil.collectBlocks(this.variables.config, options, this); } +/** + * chec if config has the variable. + * + * @param {*} name + * @param {*} options + * @returns boolean + */ function chip_tests_config_has(name, options) { const variable = getVariable(this, 'config', name); return !!variable; } +/** + * Get default value of the variable given. + * + * @param {*} name + * @param {*} options + * @returns default value + */ function chip_tests_config_get_default_value(name, options) { const variable = getVariableOrThrow(this, 'config', name); return variable.defaultValue; } +/** + * Get type of the variable given. + * + * @param {*} name + * @param {*} options + * @returns type of variable + */ function chip_tests_config_get_type(name, options) { const variable = getVariableOrThrow(this, 'config', name); return variable.type; } -// test_cluster_command_value and test_cluster_value-equals are recursive partials using #each. At some point the |global| -// context is lost and it fails. Make sure to attach the global context as a property of the | value | -// that is evaluated. -// -// errorContext should have "thisVal" and "name" properties that will be used -// for error reporting via printErrorAndExit. +/** + * test_cluster_command_value and test_cluster_value-equals are recursive partials using #each. At some point the |global| + * context is lost and it fails. Make sure to attach the global context as a property of the | value | + * that is evaluated. + * + * errorContext should have "thisVal" and "name" properties that will be used + * for error reporting via printErrorAndExit. + * + * @param {*} global + * @param {*} value + * @param {*} errorContext + * @returns Transformed value + */ function attachGlobal(global, value, errorContext) { if (Array.isArray(value)) { value = value.map((v) => attachGlobal(global, v, errorContext)); @@ -826,6 +1010,12 @@ function checkNumberSanity(value, errorContext) { } } +/** + * Get item parameters. + * + * @param {*} options + * @returns item parameters + */ function chip_tests_item_parameters(options) { if (this.isWait) { return asBlocks.call(this, Promise.resolve([]), options); @@ -887,10 +1077,22 @@ function chip_tests_item_parameters(options) { return asBlocks.call(this, promise, options); } +/** + * Get item responses. + * + * @param {*} options + * @returns item responses + */ function chip_tests_item_responses(options) { return templateUtil.collectBlocks(this[kResponseName], options, this); } +/** + * Get item response parameters. + * + * @param {*} options + * @returns item response parameters. + */ function chip_tests_item_response_parameters(options) { const responseValues = this.values.slice(); @@ -953,16 +1155,35 @@ function chip_tests_item_response_parameters(options) { return asBlocks.call(this, promise, options); } +/** + * Returns true/false based on value being a null or not. + * + * @param {*} value + * @param {*} options + * @returns boolean + */ function isLiteralNull(value, options) { // Literal null might look different depending on whether it went through // attachGlobal or not. return value === null || value instanceof NullObject; } +/** + * Returns true/false based on value being a hex string or not. + * + * @param {*} value + * @returns boolean + */ function isHexString(value) { return value && value.startsWith(kHexPrefix); } +/** + * Get octet string length from hex string value. + * + * @param {*} value + * @returns string length + */ function octetStringFromHexString(value) { const hexString = value.substring(kHexPrefix.length); @@ -982,11 +1203,24 @@ function octetStringFromHexString(value) { return bytes.map((byte) => '\\x' + byte).join(''); } +/** + * Get octet string length from hex string value. + * + * @param {*} value + * @returns string length + */ function octetStringLengthFromHexString(value) { const hexString = value.substring(kHexPrefix.length); return hexString.length / 2; } +/** + * Escape control characters, things outside the ASCII range, and single + * quotes (because that's our string terminator). + * + * @param {*} value + * @returns String + */ function octetStringEscapedForCLiteral(value) { // Escape control characters, things outside the ASCII range, and single // quotes (because that's our string terminator). @@ -996,7 +1230,14 @@ function octetStringEscapedForCLiteral(value) { }); } -// Structs may not always provide values for optional members. +/** + * Structs may not always provide values for optional members. + * + * @param {*} structValue + * @param {*} name + * @param {*} options + * @returns content based on struct details + */ function if_include_struct_item_value(structValue, name, options) { let hasValue = name in structValue; if (hasValue) { @@ -1013,8 +1254,13 @@ function if_include_struct_item_value(structValue, name, options) { return options.inverse(this); } -// To be used to verify that things are actually arrays before trying to use -// #each with them, since that silently treats non-arrays as empty arrays. +/** + * To be used to verify that things are actually arrays before trying to use + * #each with them, since that silently treats non-arrays as empty arrays. + * + * @param {*} value + * @param {*} options + */ function ensureIsArray(value, options) { if (!(value instanceof Array)) { printErrorAndExit( @@ -1026,6 +1272,12 @@ function ensureIsArray(value, options) { } } +/** + * Checks if conditions are inside test only cluster block. + * + * @param {*} conditions + * @param {*} name + */ function checkIsInsideTestOnlyClusterBlock(conditions, name) { conditions.forEach((condition) => { if (condition == undefined) { @@ -1146,6 +1398,13 @@ async function chip_tests_only_cluster_response_parameters(options) { return asBlocks.call(this, Promise.resolve(this.arguments), options); } +/** + * Get a transformed values list. + * + * @param {*} values + * @param {*} options + * @returns Transformed values list + */ function chip_tests_iterate_expected_list(values, options) { let context = options.hash.context || this; values = values.map((value) => { @@ -1163,6 +1422,13 @@ function chip_tests_iterate_expected_list(values, options) { return asBlocks.call(this, Promise.resolve(values), options); } +/** + * Get constraint details. + * + * @param {*} constraints + * @param {*} options + * @returns constraint details + */ function chip_tests_iterate_constraints(constraints, options) { let values = []; for (let key of Object.keys(constraints)) { @@ -1180,6 +1446,13 @@ function chip_tests_iterate_constraints(constraints, options) { return asBlocks.call(this, Promise.resolve(values), options); } +/** + * Get Data Model data type + * + * @param {*} type + * @param {*} isList + * @returns data type as String + */ async function asTestType(type, isList) { if (isList) { return 'list'; diff --git a/src-electron/generator/meta/helper-meta-2.js b/src-electron/generator/meta/helper-meta-2.js index 695764e9d2..c5dd361d89 100644 --- a/src-electron/generator/meta/helper-meta-2.js +++ b/src-electron/generator/meta/helper-meta-2.js @@ -17,6 +17,11 @@ const dbEnum = require('../../../src-shared/db-enum') +/** + * Get 'Meta category.' string. + * + * @returns string + */ async function meta_category() { return 'Meta category.' } diff --git a/src-electron/generator/meta/helper-meta.js b/src-electron/generator/meta/helper-meta.js index a935fd4cc8..4dcf295f05 100644 --- a/src-electron/generator/meta/helper-meta.js +++ b/src-electron/generator/meta/helper-meta.js @@ -15,6 +15,11 @@ * limitations under the License. */ +/** + * Get meta stamp string. + * + * @returns string + */ async function meta_stamp() { return 'Meta stamp.' } diff --git a/src-electron/generator/overridable.js b/src-electron/generator/overridable.js index ccfc1fc2bd..b5d07a6928 100644 --- a/src-electron/generator/overridable.js +++ b/src-electron/generator/overridable.js @@ -22,6 +22,15 @@ */ // Local utility function + +/** + * Get interger type in string format based on given arguments. + * + * @param {*} uint + * @param {*} size + * @param {*} signed + * @returns string + */ function cleanseUints(uint, size, signed) { if (size > 32) { return signed ? 'int8_t *' : 'uint8_t *' diff --git a/src-electron/generator/template-engine.js b/src-electron/generator/template-engine.js index 7cd6c9b649..1b5d0113e4 100644 --- a/src-electron/generator/template-engine.js +++ b/src-electron/generator/template-engine.js @@ -259,6 +259,11 @@ async function loadPartial(hb, name, path) { } } +/** + * + * @param {*} wrappedHelper + * @returns function + */ function helperWrapper(wrappedHelper) { return function w(...args) { let helperName = wrappedHelper.name diff --git a/src-electron/generator/template-iterators.js b/src-electron/generator/template-iterators.js index c886617094..32c3f995b4 100644 --- a/src-electron/generator/template-iterators.js +++ b/src-electron/generator/template-iterators.js @@ -15,14 +15,14 @@ * limitations under the License. */ -const dbEnums = require('../../src-shared/db-enum') -const querySessionZcl = require('../db/query-session-zcl') -const queryEndpointType = require('../db/query-endpoint-type') - /** * @module JS API: template iterators. */ +const dbEnums = require('../../src-shared/db-enum') +const querySessionZcl = require('../db/query-session-zcl') +const queryEndpointType = require('../db/query-endpoint-type') + // this structure links the names of iterators with the function. const iterators = {} iterators[dbEnums.iteratorValues.availableCluster] = availableClusterIterator @@ -32,18 +32,35 @@ iterators[dbEnums.iteratorValues.selectedServerCluster] = iterators[dbEnums.iteratorValues.selectedClientCluster] = selectedClientClusterIterator -// Iterator over all available clusters +/** + * Get all clusters available for a given session + * @param {*} db + * @param {*} sessionId + * @returns promise of all clusters available for a given session + */ async function availableClusterIterator(db, sessionId) { return querySessionZcl.selectAllSessionClusters(db, sessionId) } -// Iterator over all selected clusters +/** + * Iterator over all selected clusters. + * + * @param {*} db + * @param {*} sessionId + * @returns Promise of all clusters in the endpoint types. + */ async function selectedClusterIterator(db, sessionId) { let epts = await queryEndpointType.selectEndpointTypeIds(db, sessionId) return queryEndpointType.selectAllClustersDetailsFromEndpointTypes(db, epts) } -// Iterator over all selected client clusters +/** + * Iterator over all selected client clusters. + * + * @param {*} db + * @param {*} sessionId + * @returns Promise of all client clusters in the endpoint types. + */ async function selectedClientClusterIterator(db, sessionId) { let epts = await queryEndpointType.selectEndpointTypeIds(db, sessionId) return queryEndpointType.selectAllClustersDetailsFromEndpointTypes( @@ -53,7 +70,13 @@ async function selectedClientClusterIterator(db, sessionId) { ) } -// Iterator over all selected server clusters +/** + * Iterator over all selected server clusters. + * + * @param {*} db + * @param {*} sessionId + * @returns Promise of all server clusters in the endpoint types. + */ async function selectedServerClusterIterator(db, sessionId) { let epts = await queryEndpointType.selectEndpointTypeIds(db, sessionId) return queryEndpointType.selectAllClustersDetailsFromEndpointTypes( @@ -63,7 +86,14 @@ async function selectedServerClusterIterator(db, sessionId) { ) } -// Function that returns a given iteration array for a given iterator name. +/** + * Function that returns a given iteration array for a given iterator name. + * + * @param {*} iteratorName + * @param {*} db + * @param {*} sessionId + * @returns Iterator array + */ async function getIterativeObject(iteratorName, db, sessionId) { let fn = iterators[iteratorName] if (fn != null) { diff --git a/src-electron/generator/template-util.js b/src-electron/generator/template-util.js index 14705864ec..8a2f83f7b1 100644 --- a/src-electron/generator/template-util.js +++ b/src-electron/generator/template-util.js @@ -15,6 +15,10 @@ * limitations under the License. */ +/** + * @module JS API: generator logic + */ + const queryPackage = require('../db/query-package.js') const queryEndpointType = require('../db/query-endpoint-type.js') const queryDeviceType = require('../db/query-device-type.js') @@ -22,10 +26,6 @@ const dbEnum = require('../../src-shared/db-enum.js') const env = require('../util/env') const _ = require('lodash') -/** - * @module JS API: generator logic - */ - /** * All promises used by the templates should be synchronizable. * diff --git a/src-electron/ide-integration/studio-rest-api.js b/src-electron/ide-integration/studio-rest-api.js index 3030156356..b50e33505c 100644 --- a/src-electron/ide-integration/studio-rest-api.js +++ b/src-electron/ide-integration/studio-rest-api.js @@ -18,6 +18,7 @@ /** * This module provides the APIs to Silabs Simplicity Studio's Jetty server. * + * @module IDE Integration API: Studio REST API. */ // dirty flag reporting interval @@ -52,6 +53,13 @@ const heartbeatDelay = 6000 let studioHttpPort let studioWsConnections = {} +/** + * Get session key value for the given session. + * + * @param {*} db + * @param {*} sessionId + * @returns Promise of a session key value. + */ async function projectPath(db, sessionId) { return querySession.getSessionKeyValue( db, @@ -267,6 +275,13 @@ async function updateComponentByComponentIds(db, sessionId, componentIds, add) { ) } +/** + * Send HTTP Post to update UC component state in Studio + * @param {*} project + * @param {*} componentId + * @param {*} add + * @returns Http post resonse. + */ function httpPostComponentUpdate(project, componentId, add) { let operation = add ? StudioRestAPI.AddComponent @@ -411,6 +426,13 @@ async function wsConnect(db, session, path, handler) { } } +/** + * Close web socket connection with Studio. + * + * @param {*} db + * @param {*} session + * @param {*} path + */ async function wsDisconnect(db, session, path) { let { sessionId } = session if (studioWsConnections[sessionId]) { @@ -464,6 +486,13 @@ function deinitIdeIntegration() { }) } +/** + * Send selected UC components across the web socket. + * + * @param {*} db + * @param {*} session + * @param {*} ucComponentStates + */ async function sendSelectedUcComponents(db, session, ucComponentStates) { let socket = wsServer.clientSocket(session.sessionKey) let studioIntegration = await integrationEnabled(db, session.sessionId) diff --git a/src-electron/importexport/export.js b/src-electron/importexport/export.js index 61f119b5e6..fce75ad63f 100644 --- a/src-electron/importexport/export.js +++ b/src-electron/importexport/export.js @@ -19,6 +19,14 @@ * This file provides the functionality that reads the ZAP data from a database * and exports it into a file. */ + +/** + * This module provides the functionality that reads the ZAP data from a database + * and exports it into a file. + * + * @module Export API: Exports Data into a file. + */ + const os = require('os') const fs = require('fs') const fsp = fs.promises @@ -29,6 +37,13 @@ const queryImpExp = require('../db/query-impexp.js') const dbEnum = require('../../src-shared/db-enum.js') const ff = require('./file-format') +/** + * Export endpoint type information. + * + * @param {*} db + * @param {*} endpointType + * @returns Promise of an export of endpoint type and its entities + */ async function exportEndpointType(db, endpointType) { let data = await queryImpExp.exportClustersFromEndpointType( db, @@ -193,6 +208,14 @@ async function exportDataIntoFile( return filePath } +/** + * Get session key values. + * + * @param {*} db + * @param {*} sessionId + * @param {*} excludedKeys + * @returns session key values + */ async function getSessionKeyValues(db, sessionId, excludedKeys) { let keyValues = await querySession.getAllSessionKeyValues(db, sessionId) diff --git a/src-electron/importexport/file-format.js b/src-electron/importexport/file-format.js index 7178795c48..64a7951183 100644 --- a/src-electron/importexport/file-format.js +++ b/src-electron/importexport/file-format.js @@ -15,10 +15,21 @@ * limitations under the License. */ +/** + * Formats ZAP file in a certain format. + * + * @module Format API: Formats .zap file + */ + const _ = require('lodash') const types = require('../util/types') -// Converts attribute storage string to internal representation +/** + * Converts attribute storage string to internal representation + * + * @param {*} a + * @returns attribute object + */ function unpackAttribute(a) { let data if (a.includes('=>')) { @@ -49,7 +60,12 @@ function unpackAttribute(a) { return attr } -// Converts attribute object for internal representation. +/** + * Converts attribute object for internal representation. + * + * @param {*} a + * @returns string + */ function packAttribute(a) { let data = [ a.included === 1 ? '+' : '-', @@ -68,7 +84,12 @@ function packAttribute(a) { return `${data} => ${a.name} [${a.type}]` } -// Converts command storage string to internal representation +/** + * Converts command storage string to internal representation + * + * @param {*} c + * @returns command object + */ function unpackCommand(c) { let data if (c.includes('=>')) { @@ -92,7 +113,12 @@ function unpackCommand(c) { return cmd } -// Converts command object for file representation. +/** + * Converts command object for file representation. + * + * @param {*} cmd + * @returns string + */ function packCommand(cmd) { let data = [ types.intToHexString(cmd.code, 2), @@ -104,7 +130,12 @@ function packCommand(cmd) { return `${data} => ${cmd.name}` } -// Convert string representation to internal object representation +/** + * Convert string representation to internal object representation + * + * @param {*} ev + * @returns event object + */ function unpackEvent(ev) { let data if (ev.includes('=>')) { @@ -128,7 +159,12 @@ function unpackEvent(ev) { return evnt } -// Converts event object for file representation +/** + * Converts event object for file representation + * + * @param {*} ev + * @returns String + */ function packEvent(ev) { let data = [ ev.included === 1 ? '+' : '-', @@ -139,7 +175,12 @@ function packEvent(ev) { return `${data} => ${ev.name}` } -// Converts the key value pairs in the file into internal representation +/** + * Converts the key value pairs in the file into internal representation + * + * @param {*} keyValuePairs + * @returns array of objects + */ function unpackKeyValuePairs(keyValuePairs) { let kvps = [] for (let kvp of keyValuePairs) { @@ -156,7 +197,12 @@ function unpackKeyValuePairs(keyValuePairs) { return kvps } -// Packs key value pairs for extenrnal representation +/** + * Packs key value pairs for extenrnal representation + * + * @param {*} keyValuePairs + * @returns none + */ function packKeyValuePairs(keyValuePairs) { let props = [] for (let kvp of keyValuePairs) { @@ -165,7 +211,11 @@ function packKeyValuePairs(keyValuePairs) { return props } -// Cleanses toplevel cluster data. +/** + * Cleanses toplevel cluster data. + * + * @param {*} c + */ function cleanseCluster(c) { c.code = '0x' + c.code.toString(16).padStart(4, '0') if (c.mfgCode != null) { @@ -175,7 +225,11 @@ function cleanseCluster(c) { } } -// Uncleanses the toplevel cluster data. +/** + * Uncleanses the toplevel cluster data. + * + * @param {*} c + */ function uncleanseCluster(c) { if (_.isString(c.code)) { let code = c.code diff --git a/src-electron/importexport/import-isc.js b/src-electron/importexport/import-isc.js index 1c9830702c..b973f3e8b2 100644 --- a/src-electron/importexport/import-isc.js +++ b/src-electron/importexport/import-isc.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module provides the functionality that reads a .isc file + * + * @module Import API: Imports data from a file. + */ + const path = require('path') const queryConfig = require('../db/query-config') const queryEndpoint = require('../db/query-endpoint') @@ -386,10 +392,26 @@ async function loadEndpointType(db, sessionId, packageId, endpointType) { ) } +/** + * check if device is a custom device type. + * + * @param {*} deviceName + * @param {*} deviceCode + * @returns boolean + */ function isCustomDevice(deviceName, deviceCode) { return deviceName == 'zcustom' } +/** + * Load and endpoint type attribute entry. + * + * @param {*} db + * @param {*} endpointTypeId + * @param {*} packageId + * @param {*} at + * @returns Promise of an endpoint type attribute update + */ async function loadSingleAttribute(db, endpointTypeId, packageId, at) { let id = await queryConfig.selectEndpointTypeAttributeId( db, diff --git a/src-electron/importexport/import-json.js b/src-electron/importexport/import-json.js index 46c912b1e9..8387c14296 100644 --- a/src-electron/importexport/import-json.js +++ b/src-electron/importexport/import-json.js @@ -14,6 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * This module provides the functionality that reads a .json(.zap) file + * + * @module Import API: Imports data from a file. + */ + const fs = require('fs') const util = require('../util/util.js') const dbEnum = require('../../src-shared/db-enum.js') @@ -57,6 +64,13 @@ async function importSessionKeyValues(db, sessionId, keyValuePairs) { return Promise.all(allQueries).then(() => sessionId) } +/** + * Get package path using the zap file path. + * + * @param {*} pkg + * @param {*} zapFilePath + * @returns Package path + */ function getPkgPath(pkg, zapFilePath) { if ('pathRelativity' in pkg) { return util.createAbsolutePath(pkg.path, pkg.pathRelativity, zapFilePath) @@ -2025,8 +2039,11 @@ async function jsonDataLoader( } } -// This function cleans up some backwards-compatible problems in zap -// files. +/** + * This function cleans up some backwards-compatible problems in zap. + * files. + * @param {*} state + */ function cleanJsonState(state) { if (!('featureLevel' in state)) { state.featureLevel = 0 diff --git a/src-electron/importexport/import.js b/src-electron/importexport/import.js index b018c610ea..52fe5f2509 100644 --- a/src-electron/importexport/import.js +++ b/src-electron/importexport/import.js @@ -15,10 +15,13 @@ * limitations under the License. */ -/* +/** * This file provides the functionality that reads the ZAP data from a JSON file * and imports it into a database. + * + * @module Import API: Imports data from a file. */ + const fsp = require('fs').promises const importIsc = require('./import-isc.js') const importJson = require('./import-json.js') @@ -68,6 +71,14 @@ async function readDataFromFile( } } +/** + * Execute the post import script oonce import is done. + * + * @param {*} db + * @param {*} sessionId + * @param {*} scriptFile + * @returns Promise of function execution. + */ async function executePostImportScript(db, sessionId, scriptFile) { let context = { db: db, diff --git a/src-electron/main-process/session-timers.js b/src-electron/main-process/session-timers.js index 962a8ebd27..812ecb0cd7 100644 --- a/src-electron/main-process/session-timers.js +++ b/src-electron/main-process/session-timers.js @@ -21,6 +21,13 @@ * */ +/** + * This module provides the APIs for initializing timers specifically + * for sessions. + * + * @module Timer API: initializes times. + */ + let ASYNC_DEFAULT_TIMER_INTERVAL_MS = 6000 let sessionTimerIdArrayMap = {} diff --git a/src-electron/main-process/startup.js b/src-electron/main-process/startup.js index 176a46a209..a6903817ec 100644 --- a/src-electron/main-process/startup.js +++ b/src-electron/main-process/startup.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This file contains various startup modes. + * + * @module Startup API: initializes times. + */ + const fs = require('fs') const fsp = fs.promises const path = require('path') @@ -38,8 +44,6 @@ const watchdog = require('./watchdog') const sdkUtil = require('../util/sdk-util') const { argv } = require('process') -// This file contains various startup modes. - let mainDatabase = null /** @@ -172,6 +176,13 @@ function gatherFiles(filesArg, options = { suffix: '.zap', doBlank: true }) { return list } +/** + * Write file conversion results if converted. + * + * @param {*} resultsFile + * @param {*} logger + * @returns Promise of file write + */ async function noopConvert(resultsFile, logger) { if (resultsFile != null) { logger(`😎 No-op conversion: ${resultsFile}`) @@ -286,6 +297,12 @@ async function startConvert(argv, options) { } } +/** + * Write conversion results into file given. + * + * @param {*} file + * @returns promise of a file write operation. + */ async function writeConversionResultsFile(file) { return fsp.writeFile( file, @@ -522,6 +539,16 @@ async function startSelfCheck( } } +/** + * Generate a single template file + * @param {*} db + * @param {*} zapFile + * @param {*} templatePackageId + * @param {*} outputPattern + * @param {*} index + * @param {*} options + * @returns promise of generation results + */ async function generateSingleFile( db, zapFile, @@ -713,6 +740,10 @@ function shutdown() { } } +/** + * Log Data on the console. + * @param {*} data + */ function logRemoteData(data) { if (data != null) { if (_.isString(data)) { @@ -765,6 +796,10 @@ function startUpSecondaryInstance(argv, callbacks) { } } +/** + * Empty function by default. Startup sequence is supposed + * to declare this depending on whether this is node or electron. + */ function quit() { // Empty function by default. Startup sequence is supposed // to declare this depending on whether this is node or electron. @@ -875,6 +910,12 @@ async function startUpMainInstance(argv, callbacks) { } } +/** + * Exit the node js process. + * + * @param {*} delay + * @param {*} code + */ function cleanExit(delay, code) { util.waitFor(delay).then(() => process.exit(code)) } diff --git a/src-electron/main-process/watchdog.js b/src-electron/main-process/watchdog.js index cef7425154..36241cb8b4 100644 --- a/src-electron/main-process/watchdog.js +++ b/src-electron/main-process/watchdog.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This file contains watchdogs. + * + * @module watchdog API: initializes times. + */ + let watchDogId = null /** diff --git a/src-electron/rest/admin.js b/src-electron/rest/admin.js index 1fb36bb828..292420c770 100644 --- a/src-electron/rest/admin.js +++ b/src-electron/rest/admin.js @@ -15,18 +15,18 @@ * limitations under the License. */ -const dbApi = require('../db/db-api.js') -const dbCache = require('../db/db-cache.js') -const restApi = require('../../src-shared/rest-api.js') -const env = require('../util/env') -const { StatusCodes } = require('http-status-codes') - /** * This module provides the REST API to the admin functions. * * @module REST API: admin functions */ +const dbApi = require('../db/db-api.js') +const dbCache = require('../db/db-cache.js') +const restApi = require('../../src-shared/rest-api.js') +const env = require('../util/env') +const { StatusCodes } = require('http-status-codes') + /** * API: /sql * Request JSON: diff --git a/src-electron/rest/endpoint.js b/src-electron/rest/endpoint.js index 0e92742ba1..71353ac3fb 100644 --- a/src-electron/rest/endpoint.js +++ b/src-electron/rest/endpoint.js @@ -20,6 +20,7 @@ * * @module REST API: endpoint */ + const queryEndpointType = require('../db/query-endpoint-type.js') const queryEndpoint = require('../db/query-endpoint.js') const queryConfig = require('../db/query-config.js') diff --git a/src-electron/rest/ide-api-handler.js b/src-electron/rest/ide-api-handler.js index aeaac00c88..ac869680ee 100644 --- a/src-electron/rest/ide-api-handler.js +++ b/src-electron/rest/ide-api-handler.js @@ -27,6 +27,12 @@ const restApi = require('../../src-shared/rest-api.js') const querySession = require('../db/query-session.js') const { StatusCodes } = require('http-status-codes') +/** + * Get component tree. + * + * @param {*} db + * @returns Response data + */ function httpGetComponentTree(db) { return async (req, res) => { try { @@ -42,6 +48,14 @@ function httpGetComponentTree(db) { } } +/** + * Update component. + * + * @param {*} db + * @param {*} request + * @param {*} response + * @param {*} add + */ async function httpPostComponentUpdateHandler(db, request, response, add) { let { clusterId, side, componentIds } = request.body try { @@ -73,6 +87,12 @@ function httpPostComponentAdd(db) { httpPostComponentUpdateHandler(db, request, response, true) } +/** + * Remove component. + * + * @param {*} db + * @returns Promise of component removed + */ function httpPostComponentRemove(db) { return (request, response) => httpPostComponentUpdateHandler(db, request, response, false) diff --git a/src-electron/rest/initialize.js b/src-electron/rest/initialize.js index d27a25abf2..6cdf8832c9 100644 --- a/src-electron/rest/initialize.js +++ b/src-electron/rest/initialize.js @@ -20,6 +20,7 @@ * * @module REST API: initialization functions */ + const queryPackage = require('../db/query-package.js') const querySession = require('../db/query-session.js') const dbEnum = require('../../src-shared/db-enum.js') diff --git a/src-electron/rest/static-zcl.js b/src-electron/rest/static-zcl.js index 32cd794b4c..8b662dfe6a 100644 --- a/src-electron/rest/static-zcl.js +++ b/src-electron/rest/static-zcl.js @@ -33,9 +33,15 @@ const env = require('../util/env') const { StatusCodes } = require('http-status-codes') const queryNotification = require('../db/query-session-notification.js') -// This function builds a function that has the following skeleton. -// This is used to simplify all the logic where we have selectAll and selectById for -// each of the different ZCL entities. +/** + * This function builds a function that has the following skeleton. + * This is used to simplify all the logic where we have selectAll and selectById for + * each of the different ZCL entities. + * + * @param {*} selectAllFunction + * @param {*} selectByIdFunction + * @returns a certain function based on given arguments to them. + */ function zclEntityQuery(selectAllFunction, selectByIdFunction) { return (db, id, packageId = null) => { if (id == 'all') { @@ -46,7 +52,14 @@ function zclEntityQuery(selectAllFunction, selectByIdFunction) { } } -// For the CLUSTER path, we have special handling to also sideload attributes and commands relevant to that cluster. +/** + * For the CLUSTER path, we have special handling to also sideload attributes and commands relevant to that cluster. + * + * @param {*} db + * @param {*} clusterId + * @param {*} packageId + * @returns zcl entities + */ async function returnZclEntitiesForClusterId(db, clusterId, packageId) { return zclEntityQuery(queryZcl.selectAllClusters, queryZcl.selectClusterById)( db, @@ -77,7 +90,13 @@ async function returnZclEntitiesForClusterId(db, clusterId, packageId) { ) } -// This is the special merge function used for the CLUSTER path +/** + * This is the special merge function used for the CLUSTER path + * + * @param {*} accumulated + * @param {*} currentValue + * @returns ZCL entity details object + */ function mergeZclClusterAttributeCommandEventData(accumulated, currentValue) { return { clusterData: [accumulated.clusterData, currentValue.clusterData].flat(1), @@ -88,7 +107,17 @@ function mergeZclClusterAttributeCommandEventData(accumulated, currentValue) { eventData: [accumulated.eventData, currentValue.eventData].flat(1) } } -//This maps over each packageId, and runs the query callback. + +/** + * This maps over each packageId, and runs the query callback. + * @param {*} db + * @param {*} id + * @param {*} packageIdArray + * @param {*} zclQueryCallback + * @param {*} mergeFunction + * @param {*} defaultValue + * @returns zcl entities + */ function reduceAndConcatenateZclEntity( db, id, @@ -107,6 +136,15 @@ function reduceAndConcatenateZclEntity( ) } +/** + * Get entity details absed on given information. + * + * @param {*} db + * @param {*} entity + * @param {*} id + * @param {*} packageIdArray + * @returns Promise of entity details + */ async function parseForZclData(db, entity, id, packageIdArray) { // Retrieve all the standalone custom xml packages let packageData = await queryPackage.getPackagesByPackageIds( @@ -236,7 +274,6 @@ async function parseForZclData(db, entity, id, packageIdArray) { * @export * @param {*} app Express instance. */ - function httpGetZclEntity(db) { return async (request, response) => { const { id, entity } = request.params diff --git a/src-electron/rest/user-data.js b/src-electron/rest/user-data.js index a1366ad67d..dc91bbe1b8 100644 --- a/src-electron/rest/user-data.js +++ b/src-electron/rest/user-data.js @@ -20,6 +20,7 @@ * * @module REST API: user data */ + const env = require('../util/env') const queryZcl = require('../db/query-zcl.js') const queryAttribute = require('../db/query-attribute.js') @@ -680,6 +681,15 @@ function httpPostShareClusterStatesAcrossEndpoints(db) { } } +/** + * Get shared command defaults across endpoints. + * + * @param {*} db + * @param {*} endpointTypeIdList + * @param {*} sharedClusterList + * @param {*} packageIds + * @returns sharedCmdDefaults + */ async function commandDefaults( db, endpointTypeIdList, @@ -734,6 +744,12 @@ async function commandDefaults( return sharedCmdDefaults } +/** + * Insert command defaults into the database. + * + * @param {*} db + * @param {*} defaults + */ async function writeCommandDefaults(db, defaults) { let promises = [] for (const [endpointTypeId, commandList] of Object.entries(defaults)) { @@ -766,6 +782,15 @@ async function writeCommandDefaults(db, defaults) { await Promise.all(promises) } +/** + * Shared attribute defaults across endpoints. + * + * @param {*} db + * @param {*} endpointTypeIdList + * @param {*} sharedClusterList + * @param {*} packageIds + * @returns sharedAttributeDefaults + */ async function attributeDefaults( db, endpointTypeIdList, @@ -826,6 +851,12 @@ async function attributeDefaults( return sharedAttributeDefaults } +/** + * Write attribute defaults. + * + * @param {*} db + * @param {*} defaults + */ async function writeAttributeDefaults(db, defaults) { let promises = [] for (const [endpointTypeId, attributeList] of Object.entries(defaults)) { @@ -871,6 +902,13 @@ async function writeAttributeDefaults(db, defaults) { await Promise.all(promises) } +/** + * Compares 2 commands for equality. + * + * @param {*} a + * @param {*} b + * @returns boolean + */ function commandEquals(a, b) { return ( a.id === b.id && @@ -881,6 +919,13 @@ function commandEquals(a, b) { ) } +/** + * Compares 2 attributes for equality. + * + * @param {*} a + * @param {*} b + * @returns boolean + */ function attributeEquals(a, b) { return ( a.id === b.id && @@ -893,6 +938,12 @@ function attributeEquals(a, b) { ) } +/** + * Delete the session package. + * + * @param {*} db + * @returns HTTP Response for delete operation + */ function httpDeleteSessionPackage(db) { return async (request, response) => { let { sessionRef, packageRef } = request.query diff --git a/src-electron/sdk/matter.js b/src-electron/sdk/matter.js index 875f259f8b..223c8781cf 100644 --- a/src-electron/sdk/matter.js +++ b/src-electron/sdk/matter.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module contains Matter specific APIs. + * + * @module JS API: Matter specific APIs. + */ + const dbApi = require('../db/db-api.js') const queryPackage = require('../db/query-package.js') const queryCluster = require('../db/query-cluster.js') @@ -29,7 +35,6 @@ const dbEnum = require('../../src-shared/db-enum.js') * @param {Number} packageIds - The ID of the packages to query. * @returns {Promise} A promise that resolves to an array of forced external storage settings. */ - async function getForcedExternalStorage(db, packageIds) { try { // Ensure packageIds is an array @@ -65,7 +70,6 @@ async function getForcedExternalStorage(db, packageIds) { * @param {*} packageId the ID of the package to which the attributes belong, used to determine storage policies specific to the package * @returns an array of objects representing attributes in the database */ - async function computeStoragePolicyForGlobalAttributes( db, clusterId, @@ -101,6 +105,7 @@ async function computeStoragePolicyForGlobalAttributes( throw error // Rethrow the error if you want to handle it further up the call stack } } + /** * This asynchronous function computes and returns the new configuration for a storage option. * @@ -112,7 +117,6 @@ async function computeStoragePolicyForGlobalAttributes( * If the storagePolicy is neither of these, it throws an error 'check storage policy'. * Finally, it returns the updated storage option. */ - async function computeStorageOptionNewConfig(storagePolicy) { try { let storageOption @@ -183,7 +187,6 @@ async function computeStoragePolicyNewConfig( * the updatedStoragePolicy to attributeAccessInterface and stops the iteration. * Finally, it returns the updated storage policy. */ - async function computeStorageImport( db, clusterName, diff --git a/src-electron/server/http-server.js b/src-electron/server/http-server.js index 6295655033..f13b7042bb 100644 --- a/src-electron/server/http-server.js +++ b/src-electron/server/http-server.js @@ -92,6 +92,12 @@ function registerRestApi(module, db, app) { }) } +/** + * Register all REST modeules. + * + * @param {*} db + * @param {*} app + */ function registerAllRestModules(db, app) { restApiModules.forEach((module) => registerRestApi(module, db, app)) } @@ -175,6 +181,13 @@ async function initHttpServer( }) } +/** + * Handle user session. + * + * @param {*} db + * @param {*} options + * @returns function + */ function userSessionHandler(db, options) { return (req, res, next) => { let sessionUuid = req.query[restApi.param.sessionId] diff --git a/src-electron/server/ipc-server.js b/src-electron/server/ipc-server.js index adabc98f18..3f42077c0a 100644 --- a/src-electron/server/ipc-server.js +++ b/src-electron/server/ipc-server.js @@ -14,6 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * This module provides IPC Server functionality. + * + * @module IPC Server API: Inter-process communication + */ + const ipc = require('node-ipc') const env = require('../util/env') const path = require('path') @@ -52,20 +59,42 @@ function socketPath() { return defaultSocketPath } +/** + * Log IPC message. + * + * @param {*} msg + */ function log(msg) { env.logIpc(`Ipc server: ${msg}`) } +/** + * Ping IPC server. + * + * @param {*} context + * @param {*} data + */ function handlerPing(context, data) { server.ipc.server.emit(context.socket, eventType.pong, data) } +/** + * Get IPC server status. + * + * @param {*} context + */ function handlerServerStatus(context) { let svr = httpServer.httpServerStartupMessage() svr.zapServerStatus = 'running' server.ipc.server.emit(context.socket, eventType.overAndOut, svr) } +/** + * Convert zap files. + * + * @param {*} context + * @param {*} data + */ function handlerConvert(context, data) { let zapFiles = data.files @@ -76,6 +105,12 @@ function handlerConvert(context, data) { server.ipc.server.emit(context.socket, eventType.overAndOut, 'Done.') } +/** + * Shut down IPC server. + * + * @param {*} context + * @param {*} data + */ function handlerStop(context, data) { console.log('Shutting down because of remote client request.') server.ipc.server.emit( @@ -87,7 +122,13 @@ function handlerStop(context, data) { util.waitFor(1000).then(() => startup.quit()) } -// Data contains: zapFileArray, outputPattern, zcl, template +/** + * Data contains: zapFileArray, outputPattern, zcl, template + * + * @param {*} context + * @param {*} data + * @returns Promise of generation + */ async function handlerGenerate(context, data) { let ps = [] let packages = await queryPackage.getPackagesByType( diff --git a/src-electron/server/ws-server.js b/src-electron/server/ws-server.js index e46215016f..871b769205 100644 --- a/src-electron/server/ws-server.js +++ b/src-electron/server/ws-server.js @@ -20,6 +20,7 @@ * * @module JS API: websocket server */ + const ws = require('ws') const events = require('events') @@ -109,6 +110,10 @@ function clientSocket(sessionUuid) { return socketToReturn } +/** + * Send websocket payload with the tick category. + * @param {*} socket + */ function sendTick(socket) { sendWebSocketData(socket, dbEnum.wsCategory.tick, socket.tickCounter++) } diff --git a/src-electron/ui/about.js b/src-electron/ui/about.js index db7cbcbb07..c4b2592013 100644 --- a/src-electron/ui/about.js +++ b/src-electron/ui/about.js @@ -15,12 +15,24 @@ * limitations under the License. */ +/** + * This module provides the About page functionality for ZAP. + * + * @module JS API: About page + */ + const { BrowserWindow } = require('electron') const path = require('path') const env = require('../util/env') let window = null +/** + * Create the about window in ZAP. + * + * @param {*} parentWindow + * @param {*} port + */ function createAboutWindow(parentWindow, port) { let webPreferences = { nodeIntegration: false diff --git a/src-electron/ui/browser-api.js b/src-electron/ui/browser-api.js index 3e356a5931..43351351bb 100644 --- a/src-electron/ui/browser-api.js +++ b/src-electron/ui/browser-api.js @@ -15,14 +15,14 @@ * limitations under the License. */ -const rendApi = require('../../src-shared/rend-api.js') -const uiUtil = require('./ui-util') -const env = require('../util/env') - /** * @module JS API: renderer API related utilities */ +const rendApi = require('../../src-shared/rend-api.js') +const uiUtil = require('./ui-util') +const env = require('../util/env') + /** * This method returns the global session UUID from the browser window that is set by the front-end. * @param {*} browserWindow @@ -65,7 +65,6 @@ Functions:` * @param {*} rendererApiCommand * @param {...any} theArgs */ - async function execRendererApi(browserWindow, rendererApiCommand, ...theArgs) { const info = await browserWindow?.webContents.executeJavaScript( `window.${rendApi.GLOBAL_SYMBOL_INFO}` diff --git a/src-electron/ui/main-ui.dev.js b/src-electron/ui/main-ui.dev.js index 5c683e6975..3fadd91be2 100644 --- a/src-electron/ui/main-ui.dev.js +++ b/src-electron/ui/main-ui.dev.js @@ -16,10 +16,12 @@ */ /** - * This file is used specifically and only for development. It installs + * This file is used specifically and only for development. It installs * `electron-debug` & `vue-devtools`. There shouldn't be any need to * modify this file, but it can be used to extend your development * environment. + * + * @module JS API: UI Development */ const env = require('../util/env') diff --git a/src-electron/ui/main-ui.js b/src-electron/ui/main-ui.js index d4cb4b3bd4..a9a2ba2b49 100644 --- a/src-electron/ui/main-ui.js +++ b/src-electron/ui/main-ui.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * Main UI + * + * @module JS API: UI + */ + // enable stack trace to be mapped back to the correct line number in TypeScript source files. require('source-map-support').install() @@ -29,6 +35,11 @@ const util = require('../util/util') env.versionsCheck() env.setProductionEnv() +/** + * Hook second instance. + * + * @param {*} argv + */ function hookSecondInstanceEvents(argv) { app .whenReady() diff --git a/src-electron/ui/menu.js b/src-electron/ui/menu.js index 8b452debdf..4f45cb70d6 100644 --- a/src-electron/ui/menu.js +++ b/src-electron/ui/menu.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * Menu for ZAP UI + * + * @module JS API: Menu for ZAP UI + */ + const { dialog, Menu, shell } = require('electron') const uiJs = require('./ui-util') const about = require('./about') @@ -202,6 +208,12 @@ const template = (httpPort) => [ } ] +/** + * Get the user session information details in a string. + * + * @param {*} browserWindow + * @returns string + */ async function getUserSessionInfoMessage(browserWindow) { let userKey = await browserApi.getUserKeyFromBrowserWindow(browserWindow) let sessionUuid = @@ -338,11 +350,21 @@ function fileOpen(filePaths, httpPort) { }) } +/** + * Show the menu. + * + * @param {*} httpPort + */ function showMenu(httpPort) { const menu = Menu.buildFromTemplate(template(httpPort)) Menu.setApplicationMenu(menu) } +/** + * Hide the menu. + * + * @param {*} httpPort + */ function hideMenu(httpPort) { Menu.setApplicationMenu(null) } diff --git a/src-electron/ui/preload.js b/src-electron/ui/preload.js index 1d5d3fee73..97c8bd27b9 100644 --- a/src-electron/ui/preload.js +++ b/src-electron/ui/preload.js @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + const { contextBridge, ipcRenderer } = require('electron') contextBridge.exposeInMainWorld('electronAPI', { diff --git a/src-electron/ui/tray.js b/src-electron/ui/tray.js index c538c351f6..a3824d4713 100644 --- a/src-electron/ui/tray.js +++ b/src-electron/ui/tray.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * Tray for ZAP UI + * + * @module JS API: Tray for ZAP UI + */ + const { Menu, Tray, nativeImage, app } = require('electron') const path = require('path') const fs = require('fs') @@ -23,6 +29,12 @@ const uiUtil = require('./ui-util') let tray +/** + * Initialize tray. + * + * @param {*} port + * @returns none + */ function initTray(port) { let trayIconPath = path.join(env.iconsDirectory(), 'zap_32x32.png') let dockIconPath = path.join(env.iconsDirectory(), 'zap_128x128.png') diff --git a/src-electron/ui/ui-util.js b/src-electron/ui/ui-util.js index 8a1c94f393..46b38ac51b 100644 --- a/src-electron/ui/ui-util.js +++ b/src-electron/ui/ui-util.js @@ -14,6 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * Utility module for ZAP UI + * + * @module JS API: Utility module for ZAP UI + */ + const { dialog } = require('electron') const window = require('./window') const browserApi = require('./browser-api') @@ -131,6 +138,15 @@ function openFileDialogAndReportResult(browserWindow, options) { }) } +/** + * Enable the UI open using the given arguments. + * + * @param {*} port + * @param {*} zapFiles + * @param {*} uiMode + * @param {*} standalone + * @returns promise of a file open configuration + */ function enableUi(port, zapFiles, uiMode, standalone) { window.initializeElectronUi(port) if (zapFiles.length == 0) { diff --git a/src-electron/ui/window.js b/src-electron/ui/window.js index 229e302cd2..1670b8967b 100644 --- a/src-electron/ui/window.js +++ b/src-electron/ui/window.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * Window module for ZAP UI + * + * @module JS API: Window module for ZAP UI + */ + const { BrowserWindow, dialog, ipcMain } = require('electron') const path = require('path') const env = require('../util/env') @@ -41,12 +47,26 @@ export function initializeElectronUi(port) { tray.initTray(port) } +/** + * Create a window if none present. + * + * @param {*} port + */ export function windowCreateIfNotThere(port) { if (BrowserWindow.getAllWindows().length == 0) { windowCreate(port) } } +/** + * Get url string. + * @param {*} uiMode + * @param {*} standalone + * @param {*} isNew + * @param {*} filePath + * @param {*} restPort + * @returns String + */ function createQueryString(uiMode, standalone, isNew, filePath, restPort) { const params = new Map() diff --git a/src-electron/util/args.js b/src-electron/util/args.js index d4e62a6ae7..d094365f8b 100644 --- a/src-electron/util/args.js +++ b/src-electron/util/args.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * Arguments for ZAP + * + * @module JS API: Arguments for ZAP + */ + const yargs = require('yargs') const path = require('path') const os = require('os') @@ -23,6 +29,11 @@ const restApi = require('../../src-shared/rest-api.js') const commonUrl = require('../../src-shared/common-url.js') const env = require('./env.js') +/** + * Get environment variable details. + * + * @returns environment varibale details + */ function environmentVariablesDescription() { let vars = env.environmentVariable let desc = '' diff --git a/src-electron/util/bin.js b/src-electron/util/bin.js index b276f85e1d..de83773a6e 100644 --- a/src-electron/util/bin.js +++ b/src-electron/util/bin.js @@ -15,7 +15,11 @@ * limitations under the License. */ -// Binary utilities to deal with hex numbers and such. +/** + * Binary utilities to deal with hex numbers and such. + * + * @module JS API: Binary utilities + */ const byteBuffer = require('bytebuffer') diff --git a/src-electron/util/env.js b/src-electron/util/env.js index cb51762ae1..d3443d4971 100644 --- a/src-electron/util/env.js +++ b/src-electron/util/env.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * Environment utilities for ZAP + * + * @module JS API: Environment utilities + */ + const path = require('path') const os = require('os') const fs = require('fs') @@ -23,10 +29,19 @@ const zapBaseUrl = 'http://localhost:' let saveFileFormat = 2 // This is the enabled only .zap file format +/** + * Set save file format. + * @param {*} n + */ export function setSaveFileFormat(n) { saveFileFormat = n } +/** + * Get save file format. + * + * @returns saveFileFormat + */ export function defaultFileFormat() { return saveFileFormat } @@ -66,24 +81,44 @@ export function builtinSilabsSpecialZclGeneralSpecialXmlFile() { return locateProjectResource('./zcl-builtin/silabs/general-special.xml') } +/** + * Get builtin matter ZCL json file + * @returns matter ZCL json file + */ export function builtinMatterZclMetafile() { return locateProjectResource('./zcl-builtin/matter/zcl.json') } +/** + * Get builtin matter ZCL json file + * @returns matter ZCL json file + */ export function builtinNewMatterZclMetafile() { return locateProjectResource('./zcl-builtin/matter/zcl-new-data-model.json') } +/** + * Get builtin dotdot ZCL json file + * @returns dotdot ZCL json file + */ export function builtinDotdotZclMetafile() { return locateProjectResource('./zcl-builtin/dotdot/library.xml') } +/** + * Get builtin Matter ZCL json file + * @returns matter ZCL json file + */ export function builtinMatterZclMetafile2() { return locateProjectResource( './zcl-builtin/matter/zcl-with-test-extensions.json' ) } +/** + * No builtin meta template file. + * @returns null + */ export function builtinTemplateMetafile() { return null // No default. } @@ -161,6 +196,9 @@ let httpStaticContentPath = path.join(__dirname, '../../../spa') let versionObject = null let applicationStateDirectory = null +/** + * Set up the devlopment environment. + */ export function setDevelopmentEnv() { // @ts-ignore process.env.DEV = true @@ -171,6 +209,9 @@ export function setDevelopmentEnv() { global.__backend = path.join(__dirname, '../').replace(/\\/g, '\\\\') } +/** + * Set up the production environment. + */ export function setProductionEnv() { // @ts-ignore global.__statics = path.join(__dirname, 'statics').replace(/\\/g, '\\\\') @@ -181,6 +222,9 @@ export function setProductionEnv() { .replace(/\\/g, '\\\\') } +/** + * set explicit_logger_set + */ export function logInitStdout() { if (!explicit_logger_set) { pino_logger = pino(pinoOptions, pino.destination(1)) @@ -188,6 +232,9 @@ export function logInitStdout() { } } +/** + * Create zap.log file for logging. + */ export function logInitLogFile() { if (!explicit_logger_set) { pino_logger = pino( @@ -236,20 +283,43 @@ export function appDirectory() { return applicationStateDirectory } +/** + * Get path to icons directory. + * + * @returns path to icons directory + */ export function iconsDirectory() { // @ts-ignore return path.join(global.__backend, '/icons') } +/** + * Get path to sqlite schema file. + * + * @returns path to sqlite schema file + */ export function schemaFile() { // @ts-ignore return path.join(global.__backend, '/db/zap-schema.sql') } +/** + * Get sqlite file path relative to app directory. + * + * @param {*} filename + * @returns sqlite file path + */ export function sqliteFile(filename = 'zap') { return path.join(appDirectory(), `${filename}.sqlite`) } +/** + * Get sqlite test file name. + * + * @param {*} id + * @param {*} deleteExistingFile + * @returns sqlite test file name + */ export function sqliteTestFile(id, deleteExistingFile = true) { let dir = path.join(__dirname, '../../test/.zap') if (!fs.existsSync(dir)) { @@ -259,6 +329,7 @@ export function sqliteTestFile(id, deleteExistingFile = true) { if (deleteExistingFile && fs.existsSync(fileName)) fs.unlinkSync(fileName) return fileName } + /** * Returns a version as a single on-line string. * @@ -338,6 +409,11 @@ export function zapVersion() { return versionObject } +/** + * Get zapBaseUrl. + * + * @returns zapBaseUrl + */ export function baseUrl() { return zapBaseUrl } @@ -448,7 +524,13 @@ export function logDebug(msg, err = null) { log('debug', msg, err) } -// Returns true if major or minor component of versions is different. +/** + * Returns true if major or minor component of versions is different. + * + * @param {*} versionsArray + * @param {*} providedVersion + * @returns boolean + */ export function isMatchingVersion(versionsArray, providedVersion) { let ret = false let v2 = providedVersion.split('.') diff --git a/src-electron/util/external-helper-api.js b/src-electron/util/external-helper-api.js index 4c5ec93a06..696d231000 100644 --- a/src-electron/util/external-helper-api.js +++ b/src-electron/util/external-helper-api.js @@ -15,6 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * External helper utilities for ZAP + * + * @module External API: External API utilities + */ + const queryZcl = require('../db/query-zcl.js') const queryPackage = require('../db/query-package.js') const queryCommand = require('../db/query-command.js') diff --git a/src-electron/util/external-helper-register.js b/src-electron/util/external-helper-register.js index 76e82b1464..b8b7158a0e 100644 --- a/src-electron/util/external-helper-register.js +++ b/src-electron/util/external-helper-register.js @@ -14,6 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * External Registry utilities for ZAP + * + * @module External API: External API utilities + */ + // Import the helper API const api = require('./external-helper-api.js') diff --git a/src-electron/util/external-helper.js b/src-electron/util/external-helper.js index 00ead85954..a3c9002d8b 100644 --- a/src-electron/util/external-helper.js +++ b/src-electron/util/external-helper.js @@ -14,6 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * External helper utilities for ZAP + * + * @module External API: External API utilities + */ + const path = require('path') const helperRegister = require('./external-helper-register.js') const nativeRequire = require('./native-require.js') diff --git a/src-electron/util/iterator-util.js b/src-electron/util/iterator-util.js index 81bf188ae4..c05b4d06f1 100644 --- a/src-electron/util/iterator-util.js +++ b/src-electron/util/iterator-util.js @@ -18,6 +18,8 @@ /** * This module provides API to access various iterator utilities that can then * be used to build iterator helpers. + * + * @module JS API: Iterator utilities */ const templateUtil = require('../generator/template-util.js') diff --git a/src-electron/util/native-require.js b/src-electron/util/native-require.js index dd1e228242..44c7b101c2 100644 --- a/src-electron/util/native-require.js +++ b/src-electron/util/native-require.js @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + // webpack replaces calls to `require()` from within a bundle. This module // is not parsed by webpack and exports the real `require` // NOTE: since the module is unparsed, do not use es6 exports diff --git a/src-electron/util/post-import-api.js b/src-electron/util/post-import-api.js index 6c457db44c..8e14fc98a1 100644 --- a/src-electron/util/post-import-api.js +++ b/src-electron/util/post-import-api.js @@ -21,6 +21,7 @@ * * @module JS API: post-import. */ + const queryEndpoint = require('../db/query-endpoint.js') const queryConfig = require('../db/query-config.js') const dbEnum = require('../../src-shared/db-enum.js') @@ -127,6 +128,10 @@ function sessionId(context) { return context.sessionId } +/** + * + * @returns dbEnum + */ function dbEnums() { return dbEnum } @@ -141,9 +146,15 @@ async function availableClusters(context) { return querySessionZcl.selectAllSessionClusters(context.db, context.sessionId) } -// Finds the cluster database primary key from code,manufacturing code, and context. -// Note that by default, a standard ZCL library cluster will have manufacturing code of null -// in the database. +/** + * Finds the cluster database primary key from code,manufacturing code, and context. + * Note that by default, a standard ZCL library cluster will have manufacturing code of null + * in the database. + * @param {*} context + * @param {*} code + * @param {*} mfgCode + * @returns promise of cluster details + */ async function findCluster(context, code, mfgCode = null) { return querySessionZcl.selectSessionClusterByCode( context.db, @@ -153,6 +164,16 @@ async function findCluster(context, code, mfgCode = null) { ) } +/** + * find attribute using the given arguments. + * + * @param {*} context + * @param {*} clusterCode + * @param {*} side + * @param {*} attributeCode + * @param {*} mfgCode + * @returns promise of attribute details + */ async function findAttribute( context, clusterCode, @@ -170,6 +191,15 @@ async function findAttribute( ) } +/** + * find command using the given arguments. + * + * @param {*} context + * @param {*} clusterCode + * @param {*} commandCode + * @param {*} source + * @returns promise of command details + */ async function findCommand(context, clusterCode, commandCode, source) { return querySessionZcl.selectSessionCommandByCode( context.db, @@ -180,7 +210,16 @@ async function findCommand(context, clusterCode, commandCode, source) { ) } -// Non-public, common function to modify cluster. +/** + * Non-public, common function to modify cluster. + * + * @param {*} context + * @param {*} endpoint + * @param {*} code + * @param {*} side + * @param {*} enabled + * @returns promise of an updated or inserted cluster + */ async function modifyCluster(context, endpoint, code, side, enabled) { let cluster = await findCluster(context, code) if (cluster == null) { @@ -196,7 +235,17 @@ async function modifyCluster(context, endpoint, code, side, enabled) { ) } -// Non-public, common function to modify attribute. +/** + * Non-public, common function to modify attribute. + * + * @param {*} context + * @param {*} endpoint + * @param {*} clusterCode + * @param {*} attributeCode + * @param {*} side + * @param {*} enable + * @returns promise of an updated or inserted attribute + */ async function modifyAttribute( context, endpoint, @@ -239,7 +288,18 @@ async function modifyAttribute( ) } -// Non-public, common function to modify command. +/** + * Non-public, common function to modify command. + * + * @param {*} context + * @param {*} endpoint + * @param {*} clusterCode + * @param {*} commandCode + * @param {*} source + * @param {*} isIncoming + * @param {*} enable + * @returns promise of an updated or inserted command + */ async function modifyCommand( context, endpoint, diff --git a/src-electron/util/post-import.js b/src-electron/util/post-import.js index 8fae6ec25c..0b1a42f160 100644 --- a/src-electron/util/post-import.js +++ b/src-electron/util/post-import.js @@ -15,6 +15,13 @@ * limitations under the License. */ +/** + * This module contains the API functions for the post-load + * scripting functionality. + * + * @module JS API: post-import. + */ + const path = require('path') const scriptApi = require('./post-import-api.js') const nativeRequire = require('./native-require.js') diff --git a/src-electron/util/sdk-util.js b/src-electron/util/sdk-util.js index 951e4f08db..f61185697c 100644 --- a/src-electron/util/sdk-util.js +++ b/src-electron/util/sdk-util.js @@ -14,16 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * @module JS API: SDK utilities + */ + const fs = require('fs') const fsp = fs.promises const path = require('path') const util = require('./util') const fastGlob = require('fast-glob') -/** - * @module JS API: SDK utilities - */ - /** * This function reads in the sdk.json that is passed as sdkPath, * and resolve the promise with the sdk object. diff --git a/src-electron/util/string.js b/src-electron/util/string.js index 2361a61c54..e573c81885 100644 --- a/src-electron/util/string.js +++ b/src-electron/util/string.js @@ -45,6 +45,12 @@ function toCamelCase(label, firstLower = true) { return res } +/** + * Get spaced out lower case string from the given string. + * + * @param {*} str + * @returns spaced out lower case string + */ function toSpacedLowercase(str) { let res = str .replace(/[+()&]/g, '') @@ -92,6 +98,12 @@ function toSnakeCaseAllCaps(label) { return toCleanMacro(ret) } +/** + * Get snake case string from the given string. + * + * @param {*} str + * @returns snake case string + */ function toSnakeCase(str) { return toSnakeCaseAllCaps(str).toLowerCase() } @@ -141,11 +153,11 @@ function toCleanMacro(label) { return l } +// @ts-ignore TypeScript doesn't have character type /** * Returns true if given character is a digit. * @param {*} ch */ -// @ts-ignore TypeScript doesn't have character type function isDigit(ch) { return ch >= '0' && ch <= '9' } diff --git a/src-electron/util/studio-util.js b/src-electron/util/studio-util.js index 2d3fef06ca..d2c1a50209 100644 --- a/src-electron/util/studio-util.js +++ b/src-electron/util/studio-util.js @@ -14,6 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * @module JS API: Studio utilities + */ + const path = require('path') /** diff --git a/src-electron/util/types.js b/src-electron/util/types.js index 909ef63f06..4f7cbf90e7 100644 --- a/src-electron/util/types.js +++ b/src-electron/util/types.js @@ -15,6 +15,10 @@ * limitations under the License. */ +/** + * @module JS API: type related utilities + */ + const queryZcl = require('../db/query-zcl.js') const queryAtomic = require('../db/query-atomic.js') const queryPackages = require('../db/query-package.js') @@ -22,10 +26,6 @@ const dbEnum = require('../../src-shared/db-enum.js') const bin = require('./bin') const env = require('./env') -/** - * @module JS API: type related utilities - */ - /** * This function resolves with the size of a given type. * -1 means that this size is variable. @@ -321,7 +321,6 @@ function isTwoBytePrefixedString(type) { * @returns {string} The default value for a null string of the specified type. * @throws {Error} Throws an error if the string type is unknown. */ - function nullStringDefaultValue(type) { // We don't want to make longTypeDefaultValue know about our null // string representation. @@ -417,14 +416,25 @@ async function getSignAndSizeOfZclType(db, type, packageIds, options) { return ret } -// Converts a JS number to a hex representation with padding. -// intToHexString(17, 2) => 0x0011 +/** + * Converts a JS number to a hex representation with padding. + * intToHexString(17, 2) => 0x0011 . + * + * @param {*} n + * @param {*} byteCount + * @returns hex string + */ function intToHexString(n, byteCount) { return '0x' + n.toString(16).padStart(2 * byteCount, '0') } -// Convers a hex representation created by the intToHexString -// back into a JS integer. +/** + * Converts a hex representation created by the intToHexString + * back into a JS integer. + * + * @param {*} s + * @returns integer + */ function hexStringToInt(s) { let c = s if (s.startsWith('0x') || s.startsWith('0X')) c = s.substring(2) diff --git a/src-electron/util/util.js b/src-electron/util/util.js index a9aeb921f1..e573d9db74 100644 --- a/src-electron/util/util.js +++ b/src-electron/util/util.js @@ -355,6 +355,14 @@ async function ensurePackagesAndPopulateSessionOptions( return packages } +/** + * Insert session package options. + * + * @param {*} db + * @param {*} sessionId + * @param {*} packages + * @returns Promise array on inserting session package options + */ async function populateSessionPackageOptions(db, sessionId, packages) { let p = packages.map((pkg) => queryPackage @@ -812,6 +820,11 @@ function mainOrSecondaryInstance( } } +/** + * Disable test. + * + * @param {*} testName + */ function disable(testName) { const index = this.indexOf(testName) if (index == -1) { diff --git a/src-electron/util/zcl-util.js b/src-electron/util/zcl-util.js index 279c0273bd..a540f5553e 100644 --- a/src-electron/util/zcl-util.js +++ b/src-electron/util/zcl-util.js @@ -20,6 +20,7 @@ * * @module REST API: various zcl utilities */ + const toposort = require('toposort') const queryZcl = require('../db/query-zcl') const queryEvent = require('../db/query-event') @@ -92,6 +93,13 @@ function eventComparator(a, b) { return 0 } +/** + * Find struct by name from the given list of structs. + * + * @param {*} structs + * @param {*} name + * @returns struct + */ function findStructByName(structs, name) { for (const s of structs) { if (s.name == name) { @@ -183,6 +191,15 @@ function optionsHashOrDefault(options, optionsKey, defaultValue) { } } +/** + * Get the size of the type given. + * + * @param {*} res + * @param {*} options + * @param {*} db + * @param {*} packageIds + * @returns size of type + */ function calculateBytesForTypes(res, options, db, packageIds) { return queryZcl .selectSizeFromType(db, packageIds, res.toLowerCase()) @@ -268,6 +285,15 @@ function calculateBytesForTypes(res, options, db, packageIds) { }) } +/** + * Get size of struct. Also allow user to specifiy a default if calculation is not needed. + * + * @param {*} res + * @param {*} options + * @param {*} db + * @param {*} packageIds + * @returns size of struct + */ async function calculateBytesForStructs(res, options, db, packageIds) { if ('struct' in options.hash) { return options.hash.struct @@ -305,6 +331,14 @@ async function calculateBytesForStructs(res, options, db, packageIds) { } } +/** + * Get user defined values from the template for a given size or else return defaults specified. + * + * @param {*} size + * @param {*} res + * @param {*} options + * @returns user defined or default value based on size + */ function returnOptionsForTypes(size, res, options) { return new Promise((resolve, reject) => { let result = 0 @@ -740,6 +774,14 @@ async function determineType(db, type, packageIds) { } } +/** + * Get command signature of a command. + * + * @param {*} db + * @param {*} packageId + * @param {*} cmd + * @returns object + */ async function createCommandSignature(db, packageId, cmd) { let sig = [] let isSimple = true diff --git a/src-electron/validation/async-validation.js b/src-electron/validation/async-validation.js index 58538164c6..335384871f 100644 --- a/src-electron/validation/async-validation.js +++ b/src-electron/validation/async-validation.js @@ -19,6 +19,7 @@ * This module provides the APIs for validating inputs to the database, and returning flags indicating if * things were successful or not. * + * @module Validation API: Validation APIs */ const queryPackage = require('../db/query-package.js') @@ -59,6 +60,12 @@ export async function initAsyncValidation(db, session) { sessionTimers.initSessionTimers(db, session, timers) } +/** + * Enforce zigbee specific common cluster initialization. + * + * @param {*} session + * @returns object + */ function zigbeeEnforceCommonClusterSpecInit(session) { let timerSetup = { func: function () { @@ -69,6 +76,11 @@ function zigbeeEnforceCommonClusterSpecInit(session) { return timerSetup } +/** + * Enforce zigbee specific common cluster initialization. + * + * @param {*} session + */ function zigbeeEnforceCommonClusterSpecCallback(session) { let socket = wsServer.clientSocket(session.sessionKey) if (socket) { diff --git a/src-electron/validation/validation.js b/src-electron/validation/validation.js index ce283e7ef8..1530970d53 100644 --- a/src-electron/validation/validation.js +++ b/src-electron/validation/validation.js @@ -19,6 +19,7 @@ * This module provides the APIs for validating inputs to the database, and returning flags indicating if * things were successful or not. * + * @module Validation API: Validation APIs */ const queryZcl = require('../db/query-zcl.js') @@ -60,6 +61,13 @@ async function validateAttribute( ) } +/** + * Get issues in an endpoint. + * + * @param {*} db + * @param {*} endpointId + * @returns object + */ async function validateEndpoint(db, endpointId) { let endpoint = await queryEndpoint.selectEndpoint(db, endpointId) let currentIssues = validateSpecificEndpoint(endpoint) @@ -74,6 +82,14 @@ async function validateEndpoint(db, endpointId) { return currentIssues } +/** + * Check if there are no duplicate endpoints. + * + * @param {*} db + * @param {*} endpointIdentifier + * @param {*} sessionRef + * @returns boolean + */ async function validateNoDuplicateEndpoints( db, endpointIdentifier, @@ -156,6 +172,12 @@ async function validateSpecificAttribute( return { defaultValue: defaultAttributeIssues } } +/** + * Get endpoint and newtork issue on an endpoint. + * + * @param {*} endpoint + * @returns object + */ function validateSpecificEndpoint(endpoint) { let zclEndpointIdIssues = [] let zclNetworkIdIssues = [] @@ -176,27 +198,64 @@ function validateSpecificEndpoint(endpoint) { } } -//This applies to both actual numbers as well as octet strings. +/** + * Check if value is a valid number in string form. + * This applies to both actual numbers as well as octet strings. + * + * @param {*} value + * @returns boolean + */ function isValidNumberString(value) { //We test to see if the number is valid in hex. Decimals numbers also pass this test return /^(0x)?[\dA-F]+$/i.test(value) || Number.isInteger(Number(value)) } + +/** + * Check if value is a valid signed number in string form. + * + * @param {*} value + * @returns boolean + */ function isValidSignedNumberString(value) { return /^(0x)?[\dA-F]+$/i.test(value) || Number.isInteger(Number(value)) } +/** + * Check if value is a valid hex string. + * + * @param {*} value + * @returns boolean + */ function isValidHexString(value) { return /^(0x)?[\dA-F]+$/i.test(value) } +/** + * Check if value is a valid decimal string. + * + * @param {*} value + * @returns boolean + */ function isValidDecimalString(value) { return /^\d+$/.test(value) } +/** + * Check if value is a valid float value. + * + * @param {*} value + * @returns boolean + */ function isValidFloat(value) { return !/^0x/i.test(value) && !isNaN(Number(value)) } +/** + * Get float value from the given value. + * + * @param {*} value + * @returns float value + */ function extractFloatValue(value) { return parseFloat(value) } @@ -218,6 +277,12 @@ function extractIntegerValue(value) { } } +/** + * Get value of bit integer. + * + * @param {*} value + * @returns BigInt + */ function extractBigIntegerValue(value) { if (/^-?\d+$/.test(value)) { return BigInt(value) @@ -228,10 +293,24 @@ function extractBigIntegerValue(value) { } } +/** + * Check if integer is greater than 4 bytes. + * + * @param {*} bits + * @returns boolean + */ function isBigInteger(bits) { return bits >= 32 } +/** + * Get the integer attribute's bounds. + * + * @param {*} attribute + * @param {*} typeSize + * @param {*} isSigned + * @returns object + */ async function getBoundsInteger(attribute, typeSize, isSigned) { return { min: attribute.min @@ -337,18 +416,39 @@ async function checkAttributeBoundsInteger( return checkBoundsInteger(defaultValue, min, max) } +/** + * Check if an integer value is within the bounds. + * + * @param {*} defaultValue + * @param {*} min + * @param {*} max + * @returns boolean + */ function checkBoundsInteger(defaultValue, min, max) { if (min == null || Number.isNaN(min)) min = Number.MIN_SAFE_INTEGER if (max == null || Number.isNaN(max)) max = Number.MAX_SAFE_INTEGER return defaultValue >= min && defaultValue <= max } +/** + * Check if float attribute's value is within the bounds. + * + * @param {*} attribute + * @param {*} endpointAttribute + * @returns boolean + */ function checkAttributeBoundsFloat(attribute, endpointAttribute) { let { min, max } = getBoundsFloat(attribute) let defaultValue = extractFloatValue(endpointAttribute.defaultValue) return checkBoundsFloat(defaultValue, min, max) } +/** + * Get the bounds on a float attribute's value. + * + * @param {*} attribute + * @returns object + */ function getBoundsFloat(attribute) { return { min: extractFloatValue(attribute.min), @@ -356,6 +456,14 @@ function getBoundsFloat(attribute) { } } +/** + * Check if float value is within the min/max bounds. + * + * @param {*} defaultValue + * @param {*} min + * @param {*} max + * @returns boolean + */ function checkBoundsFloat(defaultValue, min, max) { if (Number.isNaN(min)) min = Number.MIN_VALUE if (Number.isNaN(max)) max = Number.MAX_VALUE diff --git a/src-electron/zcl/zcl-loader-dotdot.js b/src-electron/zcl/zcl-loader-dotdot.js index ab421bcff9..535da3862e 100644 --- a/src-electron/zcl/zcl-loader-dotdot.js +++ b/src-electron/zcl/zcl-loader-dotdot.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module provides the APIs for dotdot Loading + * + * @module Loader API: Loader APIs + */ + const fs = require('fs') const fsp = fs.promises const env = require('../util/env') @@ -48,7 +54,12 @@ async function collectDataFromLibraryXml(ctx) { } // Random internal XML utility functions - +/** + * Check if tag contains enum. + * + * @param {*} tag + * @returns boolean + */ function tagContainsEnum(tag) { return ( tag.restriction != null && @@ -57,6 +68,12 @@ function tagContainsEnum(tag) { ) } +/** + * Check if tag contains struct. + * + * @param {*} tag + * @returns boolean + */ function tagContainsStruct(tag) { return ( tag.restriction != null && @@ -65,10 +82,24 @@ function tagContainsStruct(tag) { ) } +/** + * Check if tag contains Bitmap. + * + * @param {*} tag + * @returns boolean + */ function tagContainsBitmap(tag) { return 'bitmap' in tag } +/** + * Parses ZCL xml file. + * + * @param {*} db + * @param {*} ctx + * @param {*} file + * @returns empty array + */ async function parseSingleZclFile(db, ctx, file) { let fileContent = await fsp.readFile(file) let data = { diff --git a/src-electron/zcl/zcl-loader-new-data-model.js b/src-electron/zcl/zcl-loader-new-data-model.js index 8dbbc3f6c8..0d96b642e6 100644 --- a/src-electron/zcl/zcl-loader-new-data-model.js +++ b/src-electron/zcl/zcl-loader-new-data-model.js @@ -14,6 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * This module provides the APIs for new data model loading + * + * @module Loader API: Loader APIs + */ + const _ = require('lodash') const util = require('../util/util') const fs = require('fs') @@ -67,6 +74,11 @@ async function parseNewXmlFiles(db, packageId, files, context) { return ret } +/** + * Prepare features from xml. + * @param {*} f + * @returns feature information + */ function prepXmlFeature(f) { let feature = {} feature.bit = parseInt(f.$.bit) @@ -75,6 +87,12 @@ function prepXmlFeature(f) { feature.summary = f.$.summary return feature } + +/** + * Prepare attributes from xml. + * @param {*} a + * @returns attribute information + */ function prepXmlAttribute(a) { let attribute = {} attribute.id = types.hexStringToInt(a.$.id) @@ -83,12 +101,24 @@ function prepXmlAttribute(a) { attribute.default = a.$.default return attribute } + +/** + * Prepare commands from xml. + * @param {*} c + * @returns command information + */ function prepXmlCommand(c) { let command = {} command.id = types.hexStringToInt(c.$.id) command.name = c.$.name return command } + +/** + * Prepare events from xml + * @param {*} e + * @returns event information + */ function prepXmlEvent(e) { let event = {} event.id = types.hexStringToInt(e.$.id) @@ -96,6 +126,11 @@ function prepXmlEvent(e) { return event } +/** + * Parse xml file. + * @param {*} f + * @returns xml information from file + */ async function parseSingleNewXmlFile(f) { let content = await fsp.readFile(f) let xmlObject = await util.parseXml(content) diff --git a/src-electron/zcl/zcl-loader-silabs.js b/src-electron/zcl/zcl-loader-silabs.js index 113be3c13e..dea764dbb0 100644 --- a/src-electron/zcl/zcl-loader-silabs.js +++ b/src-electron/zcl/zcl-loader-silabs.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module provides the APIs for ZCL/Data-Model loading. + * + * @module Loader API: Loader APIs + */ + const fs = require('fs') const fsp = fs.promises const path = require('path') @@ -374,6 +380,11 @@ function prepareClusterGlobalAttribute(cluster) { } } +/** + * Extract access information + * @param {*} ac + * @returns access tag information + */ function extractAccessTag(ac) { let e = { op: ac.$.op, @@ -386,6 +397,11 @@ function extractAccessTag(ac) { return e } +/** + * Extract list of access information + * @param {*} xmlElement + * @returns array of access information + */ function extractAccessIntoArray(xmlElement) { let accessArray = [] if ('access' in xmlElement) { @@ -799,6 +815,11 @@ async function processGlobals(db, filePath, packageId, data, context) { ) } +/** + * Prepare tag object from tag + * @param {*} tag + * @returns tag information + */ function prepareTag(tag) { return { name: tag.$.name, @@ -2425,7 +2446,6 @@ async function parseBoolOptions(db, pkgRef, booleanCategories) { * structured by cluster. * @returns {Promise} A promise that resolves when all attributes have been processed and inserted. */ - async function parseattributeAccessInterfaceAttributes( db, pkgRef, @@ -2468,6 +2488,13 @@ async function parseDefaults(db, packageId, defaults) { return Promise.all(promises) } +/** + * Parse text defaults from default options. + * @param {*} db + * @param {*} pkgRef + * @param {*} textDefaults + * @returns Array of promises + */ async function parseTextDefaults(db, pkgRef, textDefaults) { if (!textDefaults) return Promise.resolve() @@ -2512,6 +2539,13 @@ async function parseTextDefaults(db, pkgRef, textDefaults) { return Promise.all(promises) } +/** + * Parse the boolean defaults inside options. + * @param {*} db + * @param {*} pkgRef + * @param {*} booleanCategories + * @returns List of promises + */ async function parseBoolDefaults(db, pkgRef, booleanCategories) { if (!booleanCategories) return Promise.resolve() @@ -2671,10 +2705,22 @@ async function processCustomZclDeviceType(db, packageId) { await queryLoader.insertDeviceTypes(db, packageId, customDeviceTypes) } +/** + * Load ZCL metadata + * @param {*} db + * @param {*} metafile + * @returns Promise of loaded zcl json file + */ async function loadZclJson(db, metafile) { return loadZclJsonOrProperties(db, metafile, true) } +/** + * Load ZCL metadata + * @param {*} db + * @param {*} metafile + * @returns Promise of loaded zcl properties file + */ async function loadZclProperties(db, metafile) { return loadZclJsonOrProperties(db, metafile, false) } diff --git a/src-electron/zcl/zcl-loader.js b/src-electron/zcl/zcl-loader.js index 6b421537f6..bec9b6638d 100644 --- a/src-electron/zcl/zcl-loader.js +++ b/src-electron/zcl/zcl-loader.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module provides the APIs for for common functionality related to loading. + * + * @module Loader API: Loader APIs + */ + const fs = require('fs') const fsPromise = fs.promises const path = require('path') diff --git a/src-script/gen-test-runner.js b/src-script/gen-test-runner.js index 47c6475d9f..10e452b06d 100755 --- a/src-script/gen-test-runner.js +++ b/src-script/gen-test-runner.js @@ -45,11 +45,19 @@ if (argv.run == undefined) { TEST_RUN_COUNT = 20 } +/** + * Sample app name from path. + * @param {*} sampleAppPath + * @returns path + */ function getSampleAppNamefromPath(sampleAppPath) { const layers = path.dirname(sampleAppPath).split('/') return layers[layers.length - 3] } +/** + * Logs Generation statistics + */ async function main() { // grab sample apps from CLI if (fs.existsSync(argv.apps) && fs.lstatSync(argv.apps).isDirectory()) { @@ -93,6 +101,12 @@ async function main() { ) } +/** + * Log elapsed generation time. + * @param {*} LOG_PREFIX + * @param {*} zapFilePath + * @returns elapsed generation time. + */ async function runTest(LOG_PREFIX, zapFilePath) { console.log(LOG_PREFIX + `Generation started.`) let start = Date.now() @@ -103,6 +117,11 @@ async function runTest(LOG_PREFIX, zapFilePath) { return { elapsedSec } } +/** + * Log generation details. + * @param {*} LOG_PREFIX + * @param {*} zapFilePath + */ async function generate(LOG_PREFIX, zapFilePath) { // share cookie / session across HTTP requests const jar = new CookieJar() diff --git a/src-script/generate-all-api-docs.js b/src-script/generate-all-api-docs.js new file mode 100755 index 0000000000..86a71cd4f3 --- /dev/null +++ b/src-script/generate-all-api-docs.js @@ -0,0 +1,13 @@ +const { execSync } = require('child_process') + +try { + // Run jsdoc2md directly + execSync( + 'npx jsdoc2md src-shared/**/*.js src-electron/**/*.js > docs/api.md', + { stdio: 'inherit' } + ) + console.log('API documentation generated successfully.') +} catch (error) { + console.error('Failed to generate API documentation:', error.message) + throw error +} diff --git a/src-script/generate-template-helper-docs.js b/src-script/generate-template-helper-docs.js new file mode 100755 index 0000000000..fba608838e --- /dev/null +++ b/src-script/generate-template-helper-docs.js @@ -0,0 +1,15 @@ +const { execSync } = require('child_process') + +try { + // Run jsdoc2md directly + execSync('npx jsdoc2md src-electron/generator/helper*.js > docs/helpers.md', { + stdio: 'inherit' + }) + console.log('Handlebar template API documentation generated successfully.') +} catch (error) { + console.error( + 'Failed to generate Handlebar template API documentation:', + error.message + ) + throw error +} diff --git a/src-script/gsdk-public-regen.js b/src-script/gsdk-public-regen.js index ae951ddcc0..0d70223ab5 100755 --- a/src-script/gsdk-public-regen.js +++ b/src-script/gsdk-public-regen.js @@ -23,6 +23,10 @@ const fs = require('fs') const scriptUtil = require('./script-util') const process = require('process') +/** + * GSDK generation process. + * @param {*} argv + */ async function run(argv) { let gsdkDir = argv[0] let outputDir = argv[1] diff --git a/src-script/license-add.js b/src-script/license-add.js index a6b68570ab..604f48e98e 100644 --- a/src-script/license-add.js +++ b/src-script/license-add.js @@ -81,6 +81,11 @@ const directories = ['src', 'src-electron', 'test'] const startYear = 2020 const whos = ['Silicon Labs', 'Project CHIP Authors'] +/** + * Check for licensing of file. + * @param {*} path + * @returns none + */ async function processSingleFile(path) { let isVue = path.endsWith('.vue') let isJs = path.endsWith('.js') @@ -139,6 +144,13 @@ async function processSingleFile(path) { }) } +/** + * Read Dirent + * @param {*} level + * @param {*} currentDir + * @param {*} dirent + * @returns Promise + */ async function readDirent(level, currentDir, dirent) { if (dirent == null) return let fullName = path.join(currentDir.path, dirent.name) @@ -152,6 +164,12 @@ async function readDirent(level, currentDir, dirent) { .then((dirent) => readDirent(level, currentDir, dirent)) } +/** + * Scan directories recursively. + * @param {*} level + * @param {*} currentDir + * @returns currentDir + */ async function recursiveScan(level, currentDir) { currentDir.read().then((dirent) => readDirent(level, currentDir, dirent)) return currentDir diff --git a/src-script/pack-cli.js b/src-script/pack-cli.js index 69cb2f2455..b7d0b63ac2 100644 --- a/src-script/pack-cli.js +++ b/src-script/pack-cli.js @@ -14,6 +14,11 @@ console.log(argv) const platform = argv.p ? argv.p : process.platform +/** + * Zip file + * @param {*} dst + * @param {*} filename + */ async function addToZip(dst, filename) { await scriptUtil.executeCmd({}, zip.path7za, [ 'a', @@ -22,10 +27,18 @@ async function addToZip(dst, filename) { ]) } +/** + * Rename file + * @param {*} oldPath + * @param {*} newPath + */ async function rename(oldPath, newPath) { await fsp.rename(`${dist}/${oldPath}`, `${dist}/${newPath}`) } +/** + * Package ZAP. + */ async function main() { if (platform.includes('darwin') || platform.includes('mac')) { let file = 'zap-macos' diff --git a/src-script/run-conditionally.js b/src-script/run-conditionally.js index 3e575f5bed..9ecfa930a8 100755 --- a/src-script/run-conditionally.js +++ b/src-script/run-conditionally.js @@ -24,6 +24,11 @@ let args = process.argv.slice(2) let condition = args[0] let command = args.slice(1) +/** + * Checks if condition is met. + * @param {*} condition + * @returns boolean + */ function isConditionMet(condition) { if (condition === 'true' || condition === '1') return true if (condition === 'false' || condition === '0') return false @@ -47,6 +52,12 @@ function isConditionMet(condition) { return false } +/** + * Run command when condition is met. + * @param {*} condition + * @param {*} command + * @returns boolean + */ async function runConditionally(condition, command) { if (isConditionMet(condition)) { return scriptUtil.executeCmd(null, command[0], command.slice(1)) diff --git a/src-script/script-util.js b/src-script/script-util.js index dd57826287..1897c2b89e 100644 --- a/src-script/script-util.js +++ b/src-script/script-util.js @@ -101,7 +101,7 @@ async function getStdout(onError, cmd, args) { * Resolves into a context object. * Check for context.needsRebuild * - * @returns + * @returns Promise of SPA rebuilt */ async function rebuildSpaIfNeeded() { let srcHash = await folderHash.hashElement( @@ -173,6 +173,10 @@ async function rebuildSpaIfNeeded() { ) } +/** + * Rebuilds backend if needed. + * @returns promise of backend rebuilt + */ async function rebuildBackendIfNeeded() { return scriptUtil .executeCmd({}, 'npx', ['tsc', '--build', './tsconfig.json']) @@ -280,7 +284,7 @@ async function setPackageJsonVersion(date, mode) { * decently human readable time out of it. * * @param {*} nsDifference - * @returns + * @returns duration in the form of string */ function duration(nsDifference) { let diff = Number(nsDifference) @@ -308,7 +312,7 @@ async function doneStamp(startTime) { * Main entry of the program. * * @param {*} isNode - * @returns + * @returns main js file path */ function mainPath(isElectron) { if (isElectron) { @@ -338,7 +342,14 @@ async function addToJsonFile(file, object) { await fsp.writeFile(file, JSON.stringify(json, null, 2)) } -// Recursive entry +/** + * Recursive entry + * @param {*} directory + * @param {*} depth + * @param {*} pattern + * @param {*} collector + * @returns none + */ async function doLocate(directory, depth, pattern, collector) { if (depth > 50) { console.log('WARNING: Recursive depth of 50 exceeded. Aborting.') diff --git a/src-script/unify-regen.js b/src-script/unify-regen.js index 58d8d56231..9151b786bd 100644 --- a/src-script/unify-regen.js +++ b/src-script/unify-regen.js @@ -26,6 +26,9 @@ if (!unifySdkPath) { throw Error('Missing Argument. Usage: unify-regen.js ') } +/** + * Regenerates all zap generated files for the Unify gsdk. + */ async function generateZapFiles() { try { // get the Zcl file diff --git a/src-script/zap-combine-reports.js b/src-script/zap-combine-reports.js index ad8424add1..c0102e3e2e 100755 --- a/src-script/zap-combine-reports.js +++ b/src-script/zap-combine-reports.js @@ -22,6 +22,9 @@ const fsExtra = require('fs-extra') //workaround: executeCmd()/spawn() fails silently without complaining about missing path to electron process.env.PATH = process.env.PATH + ':/usr/local/bin/' +/** + * Execute the coverage report script. + */ async function executeScript() { try { // Create directory if it does not exist diff --git a/src-script/zap-uitest.js b/src-script/zap-uitest.js index 074157ba90..fd90af4730 100755 --- a/src-script/zap-uitest.js +++ b/src-script/zap-uitest.js @@ -39,6 +39,9 @@ if (process.argv.length > 4) { browserToUse = process.argv[4] } +/** + * Print ZAP usage information. + */ function printUsage() { console.log(`Usage: zap-uitest.js [ MODE | -? ] [matter|zigbee] [browser] diff --git a/src-shared/common-url.js b/src-shared/common-url.js index aef97b7144..e457fe60cb 100644 --- a/src-shared/common-url.js +++ b/src-shared/common-url.js @@ -20,6 +20,7 @@ * * @module DB API: External URLs. */ + const projectUrl = 'https://github.com/project-chip/zap/' exports.projectUrl = projectUrl diff --git a/src-shared/db-enum.js b/src-shared/db-enum.js index 654cc1369f..660e4d6ab7 100644 --- a/src-shared/db-enum.js +++ b/src-shared/db-enum.js @@ -20,6 +20,7 @@ * * @module DB API: DB types and enums. */ + exports.packageType = { zclProperties: 'zcl-properties', zclXml: 'zcl-xml-child', diff --git a/src-shared/rend-api.js b/src-shared/rend-api.js index 55086e69d1..1c2498d941 100644 --- a/src-shared/rend-api.js +++ b/src-shared/rend-api.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module provides Renderer API Exports. + * + * @module Renderer API: Renderer API. + */ + exports.renderer_api = { featureLevel: 1, prefix: 'zap', diff --git a/src-shared/rest-api.js b/src-shared/rest-api.js index b20f581698..282e300f66 100644 --- a/src-shared/rest-api.js +++ b/src-shared/rest-api.js @@ -15,6 +15,12 @@ * limitations under the License. */ +/** + * This module provides REST API Exports. + * + * @module REST API: REST API. + */ + const uri = { zclEntity: '/zcl/:entity/:id', saveSessionKeyValue: '/save', diff --git a/src/api/renderer_api.js b/src/api/renderer_api.js index dd2b6b2d3d..54da65334a 100644 --- a/src/api/renderer_api.js +++ b/src/api/renderer_api.js @@ -47,6 +47,10 @@ export function renderer_api_info() { } } +/** + * Save file. + * @param {*} zap_file + */ function fnSave(zap_file) { let data = {} if (zap_file != null) data.path = zap_file @@ -55,6 +59,10 @@ function fnSave(zap_file) { .catch((err) => console.log(err)) } +/** + * Check if state of file is dirty based on unsaved changes. + * @returns + */ function fnIsDirty() { return window .serverGet(`${restApi.ide.isDirty}`) @@ -64,6 +72,12 @@ function fnIsDirty() { .catch((err) => console.log(err)) } +/** + * Execute the renderer api based on id. + * @param {*} id + * @param {...any} args + * @returns ret + */ export function renderer_api_execute(id, ...args) { let ret = null switch (id) { diff --git a/src/boot/axios.js b/src/boot/axios.js index fa9d200248..8c03802f5f 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -44,6 +44,11 @@ function fillUrl(url) { } } +/** + * Returns Success or Failure. + * @param {*} code + * @returns succes or failure + */ function isHttpCodeSuccess(code) { return code >= 200 && code < 300 } diff --git a/src/boot/ws.js b/src/boot/ws.js index b6f3036cea..e8e8c12bf8 100644 --- a/src/boot/ws.js +++ b/src/boot/ws.js @@ -30,10 +30,17 @@ let wsUrl = `ws://${window.location.hostname}:${ }?${restApi.param.sessionId}=${window.sessionStorage.getItem('session_uuid')}` const client = new WebSocket(wsUrl) +/** + * Send object over the web socket. + * @param {*} object + */ function doSend(object) { client.send(JSON.stringify(object)) } +/** + * Initialize the web socket + */ function sendWebSocketInit() { sendWebSocketData(dbEnum.wsCategory.init, 'WebSocket initialized handshake.') setInterval(() => sendWebSocketData(dbEnum.wsCategory.tick), tickInterval) @@ -84,6 +91,10 @@ function onWebSocket(category, listener) { eventEmitter.on(category, listener) } +/** + * Process the received object over the web socket. + * @param {*} obj + */ function processReceivedObject(obj) { if (typeof obj == 'object' && 'category' in obj && 'payload' in obj) { eventEmitter.emit(obj.category, obj.payload) diff --git a/src/store/zap/actions.js b/src/store/zap/actions.js index 244f13ae84..ab3be32d9a 100644 --- a/src/store/zap/actions.js +++ b/src/store/zap/actions.js @@ -22,15 +22,29 @@ import dbEnum from '../../../src-shared/db-enum.js' const http = require('http-status-codes') +/** + * Show or hide dev tools in ZAP. + * @param {*} context + */ export function updateShowDevTools(context) { context.commit('updateShowDevTools') } +/** + * Update exceptions in ZAP. + * @param {*} context + * @param {*} data + */ export function updateExceptions(context, data) { context.commit('updateExceptions', data) context.commit('toggleShowExceptionIcon', true) } +/** + * Update the information text for ZAP. + * @param {*} context + * @param {*} text + */ export function updateInformationText(context, text) { axiosRequests .$serverPost(restApi.uri.saveSessionKeyValue, { @@ -42,6 +56,10 @@ export function updateInformationText(context, text) { }) } +/** + * Update the clusters in ZAP UI. + * @param {*} context + */ export async function updateClusters(context) { let deviceTypes = await axiosRequests.$serverGet( restApi.uri.zclDeviceType + 'all' @@ -52,12 +70,21 @@ export async function updateClusters(context) { }) } +/** + * Update the atomic data typess. + * @param {*} context + */ export function updateAtomics(context) { axiosRequests.$serverGet(restApi.uri.zclAtomics + 'all').then((response) => { context.commit('updateAtomics', response.data) }) } +/** + * Update the selected cluster in ZAP UI. + * @param {*} context + * @param {*} cluster + */ export async function updateSelectedCluster(context, cluster) { let res = await axiosRequests.$serverGet( restApi.uri.zclCluster + `${cluster.id}` @@ -68,18 +95,37 @@ export async function updateSelectedCluster(context, cluster) { updateEvents(context, res.data.eventData || []) } +/** + * Update the attributes for ZAP UI. + * @param {*} context + * @param {*} attributes + */ export function updateAttributes(context, attributes) { context.commit('updateAttributes', attributes) } +/** + * Update the commands for ZAP UI. + * @param {*} context + * @param {*} commands + */ export function updateCommands(context, commands) { context.commit('updateCommands', commands) } +/** + * Update the events for ZAP UI. + * @param {*} context + * @param {*} events + */ export function updateEvents(context, events) { context.commit('updateEvents', events) } +/** + * Update the device types for ZAP UI. + * @param {*} context + */ export function updateZclDeviceTypes(context) { axiosRequests .$serverGet(restApi.uri.zclDeviceType + 'all') @@ -100,14 +146,30 @@ export function updateZclDeviceTypes(context) { }) } +/** + * Update endpoint configuration for ZAP UI. + * @param {*} context + * @param {*} endpointConfigs + */ export function updateEndpointConfigs(context, endpointConfigs) { context.commit('updateEndpointConfigs', endpointConfigs) } +/** + * * Update selected ZAP configuration. + * @param {*} context + * @param {*} configurationName + */ export function selectConfiguration(context, configurationName) { context.commit('selectConfiguration', configurationName) } +/** + * Initialize the selected ZAP attribute. + * @param {*} context + * @param {*} selectionContext + * @returns + */ export function initSelectedAttribute(context, selectionContext) { return axiosRequests .$serverPost(restApi.uri.attributeUpdate, selectionContext) @@ -117,6 +179,11 @@ export function initSelectedAttribute(context, selectionContext) { }) } +/** + * Update the selected attribute in ZAP UI. + * @param {*} context + * @param {*} selectionContext + */ export function updateSelectedAttribute(context, selectionContext) { axiosRequests .$serverPost(restApi.uri.attributeUpdate, selectionContext) @@ -147,6 +214,11 @@ export function updateSelectedAttribute(context, selectionContext) { }) } +/** + * Update the selected commands in the ZAP UI. + * @param {*} context + * @param {*} selectionContext + */ export async function updateSelectedCommands(context, selectionContext) { let res = await axiosRequests.$serverPost( restApi.uri.commandUpdate, @@ -163,6 +235,11 @@ export async function updateSelectedCommands(context, selectionContext) { } } +/** + * Update the selected events in the ZAP UI. + * @param {*} context + * @param {*} selectionContext + */ export function updateSelectedEvents(context, selectionContext) { axiosRequests .$serverPost(restApi.uri.eventUpdate, selectionContext) @@ -179,11 +256,23 @@ export function updateSelectedEvents(context, selectionContext) { }) } +/** + * Update the selected UC component in Simplicity Studio. + * @param {*} context + * @param {*} payload + * @returns + */ export function updateSelectedComponent(context, payload) { let op = payload.added ? restApi.uc.componentAdd : restApi.uc.componentRemove return axiosRequests.$serverPost(op, payload) } +/** + * Update the selected server side clusters. + * @param {*} context + * @param {*} selectionContext + * @returns + */ export function updateSelectedServers(context, selectionContext) { return axiosRequests .$serverPost(restApi.uri.cluster, { @@ -197,6 +286,12 @@ export function updateSelectedServers(context, selectionContext) { }) } +/** + * * Update the selected client side clusters. + * @param {*} context + * @param {*} selectionContext + * @returns + */ export function updateSelectedClients(context, selectionContext) { return axiosRequests .$serverPost(restApi.uri.cluster, { @@ -210,6 +305,11 @@ export function updateSelectedClients(context, selectionContext) { }) } +/** + * Get the project packages. + * @param {*} context + * @returns packages for the project + */ export function getProjectPackages(context) { return axiosRequests.$serverGet(restApi.uri.packages).then((res) => { let data = res.data @@ -217,9 +317,20 @@ export function getProjectPackages(context) { }) } +/** + * Initialize the default endpoints. + * @param {*} context + * @param {*} defaultEndpoints + */ export function initializeDefaultEndpoints(context, defaultEndpoints) { context.commit('initializeDefaultEndpoints', defaultEndpoints) } + +/** + * Initialize the default endpoint types. + * @param {*} context + * @param {*} defaultEndpointsTypes + */ export function initializeDefaultEndpointsTypes( context, defaultEndpointsTypes @@ -227,10 +338,20 @@ export function initializeDefaultEndpointsTypes( context.commit('initializeDefaultEndpointsTypes', defaultEndpointsTypes) } +/** + * Update the selected endpoint in ZAP UI. + * @param {*} context + * @param {*} endpoint + */ export function updateSelectedEndpoint(context, endpoint) { context.commit('updateSelectedEndpoint', endpoint) } +/** + * * Update the selected endpoint type in ZAP UI. + * @param {*} context + * @param {*} endpointType + */ export function updateEndpointType(context, endpointType) { axiosRequests .$serverPatch(restApi.uri.endpointType, endpointType) @@ -252,6 +373,11 @@ export function updateEndpointType(context, endpointType) { }) } +/** + * Link endpoint types and deviec types. + * @param {*} context + * @param {*} endpointTypeIdDeviceTypeRefPair + */ export function setDeviceTypeReference( context, endpointTypeIdDeviceTypeRefPair @@ -310,6 +436,11 @@ export function setDeviceTypeReference( context.commit('setDeviceTypeReference', endpointTypeIdDeviceTypeRefPair) } +/** + * Update Endpoint in ZAP UI. + * @param {*} context + * @param {*} endpoint + */ export function updateEndpoint(context, endpoint) { // TODO this uri should handle deviceIdentifier as array axiosRequests.$serverPatch(restApi.uri.endpoint, endpoint).then((res) => { @@ -324,6 +455,12 @@ export function updateEndpoint(context, endpoint) { }) } +/** + * Add endpoint in ZAP UI. + * @param {*} context + * @param {*} newEndpointContext + * @returns endpoint data + */ export function addEndpoint(context, newEndpointContext) { return axiosRequests .$serverPost(restApi.uri.endpoint, newEndpointContext) @@ -343,10 +480,20 @@ export function addEndpoint(context, newEndpointContext) { }) } +/** + * Get endpoint ids. + * @returns endpoints ids + */ export async function getEndpointIds() { return await axiosRequests.$serverGet(restApi.uri.endpointIds) } +/** + * Add endpoint type for ZAP UI. + * @param {*} context + * @param {*} endpointTypeData + * @returns endpointType data + */ export function addEndpointType(context, endpointTypeData) { return axiosRequests .$serverPost(restApi.uri.endpointType, endpointTypeData) @@ -363,6 +510,12 @@ export function addEndpointType(context, endpointTypeData) { .catch((e) => console.log('Error in addEndpointType: ' + e.message)) } +/** + * Duplicate endpoint type. + * @param {*} context + * @param {*} param1 + * @returns endpoint type data + */ export function duplicateEndpointType(context, { endpointTypeId }) { return axiosRequests .$serverPost(restApi.uri.duplicateEndpointType, { @@ -373,6 +526,11 @@ export function duplicateEndpointType(context, { endpointTypeId }) { }) } +/** + * Delete endpoint from ZAP UI. + * @param {*} context + * @param {*} endpointId + */ export function deleteEndpoint(context, endpointId) { axiosRequests .$serverDelete(restApi.uri.endpoint, { params: { id: endpointId } }) @@ -381,6 +539,12 @@ export function deleteEndpoint(context, endpointId) { }) } +/** + * Duplicate endpoint in ZAP UI. + * @param {*} context + * @param {*} param1 + * @returns endpoint details + */ export function duplicateEndpoint( context, { endpointId, endpointIdentifier, endpointTypeId } @@ -396,6 +560,11 @@ export function duplicateEndpoint( }) } +/** + * Delete endpoint type from ZAP UI. + * @param {*} context + * @param {*} endpointTypeId + */ export function deleteEndpointType(context, endpointTypeId) { axiosRequests .$serverDelete(restApi.uri.endpointType, { params: { id: endpointTypeId } }) @@ -408,6 +577,11 @@ export function deleteEndpointType(context, endpointTypeId) { }) } +/** + * Refresh the endpoint type cluster details based on endpoint type selected in ZAP UI. + * @param {*} context + * @param {*} endpointType + */ export function refreshEndpointTypeCluster(context, endpointType) { axiosRequests .$serverGet(`${restApi.uri.endpointTypeAttributes}${endpointType}`) @@ -426,12 +600,24 @@ export function refreshEndpointTypeCluster(context, endpointType) { }) } +/** + * Get endpoint type cluster information for endpoint type. + * @param {*} context + * @param {*} endpointTypeId + * @returns endpoint type cluster information for endpoint type + */ export async function endpointTypeClustersInfo(context, endpointTypeId) { return axiosRequests.$serverGet( `${restApi.uri.endpointTypeClusters}${endpointTypeId}` ) } +/** + * Update selected endpoint type details in ZAP UI. + * @param {*} context + * @param {*} endpointTypeDeviceTypeRefPair + * @returns Resolved promises + */ export async function updateSelectedEndpointType( context, endpointTypeDeviceTypeRefPair @@ -512,6 +698,11 @@ export async function updateSelectedEndpointType( return await Promise.all(p) } +/** + * set client and server cluster lists. + * @param {*} context + * @param {*} selectionContext + */ export function setClusterList(context, selectionContext) { let enabledClients = [] let enabledServers = [] @@ -529,6 +720,12 @@ export function setClusterList(context, selectionContext) { servers: enabledServers }) } + +/** + * Set attribute state details for the endpoint type attribute. + * @param {*} context + * @param {*} selectionContext + */ export function setAttributeState(context, selectionContext) { let resolvedReference = Util.cantorPair( selectionContext.attributeRef, @@ -548,6 +745,11 @@ export function setAttributeState(context, selectionContext) { }) } +/** + * set attribute list for the state. + * @param {*} context + * @param {*} selectionContext + */ export function setAttributeStateLists(context, selectionContext) { let includedAttributes = [] let singletonAttributes = [] @@ -589,6 +791,11 @@ export function setAttributeStateLists(context, selectionContext) { }) } +/** + * set events list for the state. + * @param {*} context + * @param {*} selectionContext + */ export function setEventStateLists(context, selectionContext) { let selected = [] selectionContext.forEach((record) => { @@ -600,6 +807,11 @@ export function setEventStateLists(context, selectionContext) { context.commit('setEventLists', selected) } +/** + * Set commands list for the state. + * @param {*} context + * @param {*} selectionContext + */ export function setCommandStateLists(context, selectionContext) { let incoming = [] let outgoing = [] @@ -617,8 +829,13 @@ export function setCommandStateLists(context, selectionContext) { }) } -// TODO (?) This does not handle/highlight prohibited clusters. For now we just keep it in here +/** + * Set recommended cluster list for the endpoint. + * @param {*} context + * @param {*} data + */ export function setRecommendedClusterList(context, data) { + // TODO (?) This does not handle/highlight prohibited clusters. For now we just keep it in here let recommendedClients = [] let recommendedServers = [] @@ -632,6 +849,11 @@ export function setRecommendedClusterList(context, data) { }) } +/** + * Set required attributes for the cluster. + * @param {*} context + * @param {*} data + */ export function setRequiredAttributes(context, data) { let requiredAttributes = [] data.forEach((record) => { @@ -642,6 +864,11 @@ export function setRequiredAttributes(context, data) { }) } +/** + * Set required commands for the cluster. + * @param {*} context + * @param {*} data + */ export function setRequiredCommands(context, data) { let requiredCommands = [] data.forEach((record) => { @@ -652,10 +879,20 @@ export function setRequiredCommands(context, data) { }) } +/** + * Set left drawer in State. + * @param {*} context + * @param {*} data + */ export function setLeftDrawerState(context, data) { context.commit('setLeftDrawerState', data) } +/** + * Set minimization state in State. + * @param {*} context + * @param {*} data + */ export function setMiniState(context, data) { context.commit('setMiniState', data) } @@ -710,6 +947,8 @@ export function loadInitialData(context, data) { /** * This action loads the option from the backend, including any defaults that may exist. + * @param {*} context + * @param {*} option */ export function loadOptions(context, option) { axiosRequests @@ -739,6 +978,10 @@ export async function setSelectedGenericKey(context, data) { context.commit('setSelectedGenericOption', response.data) } +/** + * Load session key value pairs for ZAP. + * @param {*} context + */ export async function loadSessionKeyValues(context) { let response = await axiosRequests.$serverGet( restApi.uri.getAllSessionKeyValues @@ -766,6 +1009,12 @@ export async function addNewPackage(context, filePath) { } } +/** + * Delete's a session's package. + * @param {*} context + * @param {*} sessionPackage + * @returns project packages + */ export function deleteSessionPackage(context, sessionPackage) { return axiosRequests .$serverDelete(restApi.uri.sessionPackage, { params: sessionPackage }) @@ -774,67 +1023,144 @@ export function deleteSessionPackage(context, sessionPackage) { }) } +/** + * Set the default UI mode for ZAP UI. + * @param {*} context + * @param {*} uiMode + */ export function setDefaultUiMode(context, uiMode) { context.commit(`setDefaultUiMode`, uiMode) } +/** + * Show or hide the debug navigation bar in ZAP UI. + * @param {*} context + * @param {*} debugNavBar + */ export function setDebugNavBar(context, debugNavBar) { context.commit('setDebugNavBar', debugNavBar) } +/** + * Show or hide the Save button in ZAP UI. + * @param {*} context + * @param {*} saveButtonVisible + */ export function setSaveButtonVisible(context, saveButtonVisible) { context.commit('setSaveButtonVisible', saveButtonVisible) } +/** + * Set the mode of ZAP UI. + * @param {*} context + * @param {*} standalone + */ export function setStandalone(context, standalone) { context.commit('setStandalone', standalone) } +/** + * Set attribute's editable mode in ZAP UI. + * @param {*} context + * @param {*} editContext + */ export function setAttributeEditting(context, editContext) { context.commit('setAttributeEditting', editContext) } +/** + * Set attribute reporting's editable mode of ZAP UI. + * @param {*} context + * @param {*} editContext + */ export function setAttributeReportingEditting(context, editContext) { context.commit('setAttributeReportingEditting', editContext) } +/** + * Set the domain drop down for clusters in ZAP UI. + * @param {*} context + * @param {*} state + */ export function setOpenDomain(context, state) { context.commit('setOpenDomain', state) } +/** + * Set the domain's fliter for clusters in ZAP UI. + * @param {*} context + * @param {*} filterEnabledClusterPair + */ export function setDomainFilter(context, filterEnabledClusterPair) { context.commit('setDomainFilter', filterEnabledClusterPair) } +/** + * Apply filter for clusters in ZAP UI. + * @param {*} context + * @param {*} filterEnabledClusterPair + */ export function doActionFilter(context, filterEnabledClusterPair) { context.commit('doActionFilter', filterEnabledClusterPair) } +/** + * Set the filter string for filtering. + * @param {*} context + * @param {*} filterString + */ export function setFilterString(context, filterString) { context.commit('setFilterString', filterString) } +/** + * Reset the filters in ZAP UI. + * @param {*} context + */ export function resetFilters(context) { context.commit('resetFilters') } +/** + * Set the filter string for each cluster. + * @param {*} context + * @param {*} filterString + */ export function setIndividualClusterFilterString(context, filterString) { context.commit('setIndividualClusterFilterString', filterString) } +/** + * Set the last selected domain. + * @param {*} context + * @param {*} domainNameString + */ export function setLastSelectedDomain(context, domainNameString) { context.commit('setLastSelectedDomain', domainNameString) } +/** + * Clear the last selected domain. + * @param {*} context + */ export function clearLastSelectedDomain(context) { context.commit('clearLastSelectedDomain') } +/** + * Load the UC component state for Simplicity Studio. + * @param {*} context + */ export async function loadUcComponentState(context) { let resp = await axiosRequests.$serverGet(restApi.uc.componentTree) updateUcComponentState(context, resp.data) } +/** + * Update the UC component state for Simplicity Studio. + * @param {*} context + * @param {*} projectInfo + */ export function updateUcComponentState(context, projectInfo) { let ucComponents = Util.getUcComponents(projectInfo) let selectedUcComponents = Util.getSelectedUcComponents(ucComponents) @@ -844,6 +1170,11 @@ export function updateUcComponentState(context, projectInfo) { }) } +/** + * Update the selected UC component state for Simplicity Studio. + * @param {*} context + * @param {*} projectInfo + */ export function updateSelectedUcComponentState(context, projectInfo) { let ucComponents = Util.getUcComponents(projectInfo) let selectedUcComponents = Util.getSelectedUcComponents(ucComponents) @@ -852,10 +1183,19 @@ export function updateSelectedUcComponentState(context, projectInfo) { }) } +/** + * Set the dirty state for ZAP config when there are unsaved changes. + * @param {*} context + * @param {*} isDirty + */ export function setDirtyState(context, isDirty) { context.commit('setDirtyState', isDirty) } +/** + * Load ZCL's cluster to UC component mapping(Simplicity Studio) + * @param {*} context + */ export function loadZclClusterToUcComponentDependencyMap(context) { axiosRequests .$serverGet(`/zclExtension/cluster/component`) @@ -867,6 +1207,11 @@ export function loadZclClusterToUcComponentDependencyMap(context) { }) } +/** + * Share cluster states acorss endpoints. + * @param {*} context + * @param {*} data + */ export function shareClusterStatesAcrossEndpoints(context, data) { let { endpointTypeIdList } = data axiosRequests @@ -878,6 +1223,11 @@ export function shareClusterStatesAcrossEndpoints(context, data) { }) } +/** + * Generate all the endpoints data. + * @param {*} context + * @param {*} endpointData + */ export function generateAllEndpointsData(context, endpointData) { let attr = [] let report = [] diff --git a/src/store/zap/getters.js b/src/store/zap/getters.js index c6a4faaa47..6b40002a77 100644 --- a/src/store/zap/getters.js +++ b/src/store/zap/getters.js @@ -15,6 +15,11 @@ * limitations under the License. */ +/** + * Returns the state. + * @param {*} state + * @returns state + */ export function getFullState(state) { return state } diff --git a/src/store/zap/mutations.js b/src/store/zap/mutations.js index 093ff8d0b6..2bb7ea75ae 100644 --- a/src/store/zap/mutations.js +++ b/src/store/zap/mutations.js @@ -14,10 +14,24 @@ * limitations under the License. */ +/** + * Sets a property on an object to a given value. + * + * @param {object} object - The object on which to set the property. + * @param {string} property - The name of the property to set. + * @param {*} value - The value to assign to the property. + */ function vue3Set(object, property, value) { object[property] = value } +/** + * Deletes a property from an object. + * + * @param {object} object - The object from which to delete the property. + * @param {string} property - The name of the property to delete. + * + */ function vue3Delete(object, property) { delete object[property] } @@ -35,14 +49,29 @@ export const updateShowDevTools = (state) => { state.showDevTools = !state.showDevTools } +/** + * Set the information text in the state + * @param {*} state + * @param {*} text + */ export function updateInformationText(state, text) { state.informationText = text } +/** + * Set the packages in the state + * @param {*} state + * @param {*} packages + */ export function setAllPackages(state, packages) { state.allPackages = packages } +/** + * Updates the state with the cluster data + * @param {*} state + * @param {*} responseData + */ export function updateClusters(state, responseData) { let selectedEndpointTypeTemp = state.endpointTypeView.selectedEndpointType let selectedDeviceTypeRefs = @@ -102,18 +131,38 @@ export function updateClusters(state, responseData) { } } +/** + * Update the state with atomics data. + * @param {*} state + * @param {*} atomics + */ export function updateAtomics(state, atomics) { state.atomics = atomics } +/** + * update selected cluster view in the state. + * @param {*} state + * @param {*} cluster + */ export function updateSelectedCluster(state, cluster) { state.clustersView.selected = cluster } +/** + * Update the selected endpoint of the endpoint view in the state. + * @param {*} state + * @param {*} endpoint + */ export function updateSelectedEndpoint(state, endpoint) { state.endpointView.selectedEndpoint = endpoint } +/** + * Update the attribute details of the attribute view in the state. + * @param {*} state + * @param {*} attributes + */ export function updateAttributes(state, attributes) { attributes.forEach((attribute) => { if (state.attributeView.defaultValue[attribute.id] === undefined) { @@ -140,6 +189,11 @@ export function updateAttributes(state, attributes) { state.attributes = attributes } +/** + * Set the endpointTypeAttribute details in the state. + * @param {*} state + * @param {*} endpointTypeAttribute + */ export function setEndpointTypeAttribute(state, endpointTypeAttribute) { let attribute = endpointTypeAttribute @@ -187,6 +241,11 @@ export function setEndpointTypeAttribute(state, endpointTypeAttribute) { ) } +/** + * Initialize the ednpoint details in the state. + * @param {*} state + * @param {*} defaultEndpoints + */ export function initializeDefaultEndpoints(state, defaultEndpoints) { defaultEndpoints.forEach((endpoint) => { if (state.endpointView.endpointId[endpoint.id] === undefined) { @@ -218,6 +277,11 @@ export function initializeDefaultEndpoints(state, defaultEndpoints) { }) } +/** + * Add endpoint details the state. + * @param {*} state + * @param {*} endpoint + */ export function addEndpoint(state, endpoint) { vue3Set(state.endpointView.endpointId, endpoint.id, endpoint.endpointId) vue3Set( @@ -244,6 +308,11 @@ export function addEndpoint(state, endpoint) { ) } +/** + * Update endpoint details in the state. + * @param {*} state + * @param {*} context + */ export function updateEndpoint(state, context) { vue3Set( state.endpointView.parentEndpointIdentifier, @@ -265,6 +334,11 @@ export function updateEndpoint(state, context) { ) } +/** + * Initialize state with default details of an endpoint type. + * @param {*} state + * @param {*} defaultEndpointsTypes + */ export function initializeDefaultEndpointsTypes(state, defaultEndpointsTypes) { defaultEndpointsTypes.forEach((endpointType) => { if (state.endpointTypeView.name[endpointType.id] === undefined) { @@ -287,6 +361,11 @@ export function initializeDefaultEndpointsTypes(state, defaultEndpointsTypes) { }) } +/** + * Add endpoint type to the state. + * @param {*} state + * @param {*} endpointType + */ export function addEndpointType(state, endpointType) { vue3Set(state.endpointTypeView.name, endpointType.id, endpointType.name) vue3Set( @@ -305,7 +384,11 @@ export function addEndpointType(state, endpointType) { endpointType.deviceVersion ) } - +/** + * Update attribute details of the attribute view in the state. + * @param {*} state + * @param {*} selectionContext + */ export function updateAttributeDefaults(state, selectionContext) { vue3Set( state.attributeView[selectionContext.listType], @@ -324,26 +407,56 @@ export function updateAttributeDefaults(state, selectionContext) { ) } +/** + * Update commands in the state. + * @param {*} state + * @param {*} commands + */ export function updateCommands(state, commands) { state.commands = commands } +/** + * Update events in the state. + * @param {*} state + * @param {*} events + */ export function updateEvents(state, events) { state.events = events } +/** + * update ZCL device types in the state. + * @param {*} state + * @param {*} zclDeviceTypes + */ export function updateZclDeviceTypes(state, zclDeviceTypes) { state.zclDeviceTypes = zclDeviceTypes } +/** + * update Endpoint details in the state. + * @param {*} state + * @param {*} endpoints + */ export function updateEndpointConfigs(state, endpoints) { state.endpoints = endpoints } +/** + * Set the selected of configuration view in the state. + * @param {*} state + * @param {*} configurationName + */ export function selectConfiguration(state, configurationName) { state.configurationView.selected = configurationName } +/** + * Update inclusion list in the state. + * @param {*} state + * @param {*} selectionContext + */ export function updateInclusionList(state, selectionContext) { let inclusionList = state[selectionContext.view][selectionContext.listType] if (selectionContext.added && !inclusionList.includes(selectionContext.id)) { @@ -358,6 +471,11 @@ export function updateInclusionList(state, selectionContext) { state[selectionContext.view][selectionContext.listType] = inclusionList } +/** + * Set device type details for the endpoint type view in the state. + * @param {*} state + * @param {*} endpointTypeIdDeviceTypeRefPair + */ export function setDeviceTypeReference(state, endpointTypeIdDeviceTypeRefPair) { vue3Set( state.endpointTypeView.deviceTypeRef, @@ -378,10 +496,20 @@ export function setDeviceTypeReference(state, endpointTypeIdDeviceTypeRefPair) { ) } +/** + * Update the selectedEndpointType of endpoint type view in the state. + * @param {*} state + * @param {*} endpointType + */ export function updateSelectedEndpointType(state, endpointType) { state.endpointTypeView.selectedEndpointType = endpointType } +/** + * Remove endpoint type details from the endpoint type view of the state. + * @param {*} state + * @param {*} endpointType + */ export function removeEndpointType(state, endpointType) { state.endpointTypeView.selectedEndpointType = [] vue3Delete(state.endpointTypeView.name, endpointType.id) @@ -389,6 +517,11 @@ export function removeEndpointType(state, endpointType) { vue3Delete(state.endpointTypeView.deviceVersion, endpointType.id) } +/** + * Delete endpoint from the endpoint view of the state. + * @param {*} state + * @param {*} endpoint + */ export function deleteEndpoint(state, endpoint) { state.endpointView.selectedEndpoint = null vue3Delete(state.endpointView.endpointId, endpoint.id) @@ -397,11 +530,20 @@ export function deleteEndpoint(state, endpoint) { vue3Delete(state.endpointView.parentEndpointIdentifier, endpoint.id) } +/** + * Set selected clusters of the cluster view in the state. + * @param {*} state + * @param {*} data + */ export function setClusterList(state, data) { state.clustersView.selectedClients = data.clients state.clustersView.selectedServers = data.servers } +/** + * Reset attribute details of the attribute view in the state. + * @param {*} state + */ export function resetAttributeDefaults(state) { state.attributeView.defaultValue = {} state.attributeView.reportingMin = {} @@ -422,6 +564,11 @@ export function resetAttributeDefaults(state) { }) } +/** + * Set attribute details of the attribute view in the state. + * @param {*} state + * @param {*} data + */ export function setAttributeLists(state, data) { state.attributeView.selectedAttributes = data.included state.attributeView.selectedSingleton = data.singleton @@ -452,53 +599,109 @@ export function setAttributeLists(state, data) { ) } +/** + * Set command details of the command view in the state. + * @param {*} state + * @param {*} data + */ export function setCommandLists(state, data) { vue3Set(state.commandView, 'selectedIn', data.incoming) vue3Set(state.commandView, 'selectedOut', data.outgoing) } + +/** + * Set event details of the event view in the state. + * @param {*} state + * @param {*} data + */ export function setEventLists(state, data) { vue3Set(state.eventView, 'selectedEvents', data) } +/** + * Set recommended cluster lists of the cluster view in the state. + * @param {*} state + * @param {*} data + */ export function setRecommendedClusterList(state, data) { vue3Set(state.clustersView, 'recommendedClients', data.recommendedClients) vue3Set(state.clustersView, 'recommendedServers', data.recommendedServers) } +/** + * Set required attributes of the attribute view in the state. + * @param {*} state + * @param {*} data + */ export function setRequiredAttributesList(state, data) { vue3Set(state.attributeView, 'requiredAttributes', data.requiredAttributes) } +/** + * Set required commands of the command view in the state. + * @param {*} state + * @param {*} data + */ export function setRequiredCommandsList(state, data) { vue3Set(state.commandView, 'requiredCommands', data.requiredCommands) } +/** + * Set left drawer's state + * @param {*} state + * @param {*} data + */ export function setLeftDrawerState(state, data) { state.leftDrawerOpenState = data } +/** + * Set minimization state. + * @param {*} state + * @param {*} data + */ export function setMiniState(state, data) { state.miniState = data } +/** + * Initialize endpoints for the state. + * @param {*} state + * @param {*} endpoints + */ export function initializeEndpoints(state, endpoints) { endpoints.forEach((e) => { addEndpoint(state, e) }) } +/** + * Initialize endpoint types for the state. + * @param {*} state + * @param {*} endpointTypes + */ export function initializeEndpointTypes(state, endpointTypes) { endpointTypes.forEach((et) => { addEndpointType(state, et) }) } +/** + * Initialize session key values for the state. + * @param {*} state + * @param {*} sessionKeyValues + */ export function initializeSessionKeyValues(state, sessionKeyValues) { sessionKeyValues.forEach((skv) => { setSelectedGenericOption(state, skv) }) } +/** + * Set configuration options in the state. + * @param {*} state + * @param {*} data + */ export function setOptions(state, data) { vue3Set(state.genericOptions, data.option, [ ...new Set( @@ -511,36 +714,76 @@ export function setOptions(state, data) { ]) } +/** + * Set specific options for the state. + * @param {*} state + * @param {*} keyValue + */ export function setSelectedGenericOption(state, keyValue) { vue3Set(state.selectedGenericOptions, keyValue.key, keyValue.value) } +/** + * Load session key values pairs in the state. + * @param {*} state + * @param {*} sessionKeyValues + */ export function loadSessionKeyValues(state, sessionKeyValues) { sessionKeyValues?.data.map((keyValue) => { vue3Set(state.selectedGenericOptions, keyValue.key, keyValue.value) }) } +/** + * Set default UI mode in the state. + * @param {*} state + * @param {*} uiMode + */ export function setDefaultUiMode(state, uiMode) { vue3Set(state.calledArgs, `defaultUiMode`, uiMode) } +/** + * Set debug navigation view for the state. + * @param {*} state + * @param {*} debugNavBar + */ export function setDebugNavBar(state, debugNavBar) { state.debugNavBar = debugNavBar } +/** + * Show save button in the UI using the state. + * @param {*} state + * @param {*} saveButtonVisible + */ export function setSaveButtonVisible(state, saveButtonVisible) { state.saveButtonVisible = saveButtonVisible } +/** + * Set standalone mode for ZAP using the state. + * @param {*} state + * @param {*} standalone + */ export function setStandalone(state, standalone) { state.standalone = standalone } +/** + * Set open domain of cluster manager in the state. + * @param {*} state + * @param {*} context + */ export function setOpenDomain(state, context) { vue3Set(state.clusterManager.openDomains, context.domainName, context.value) } +/** + * Set the filter for the domain of cluster manager in the state. + * @param {*} state + * @param {*} filterEnabledClusterPair + */ export function setDomainFilter(state, filterEnabledClusterPair) { let filter = filterEnabledClusterPair.filter state.clusterManager.filter = filter @@ -558,6 +801,11 @@ export function setDomainFilter(state, filterEnabledClusterPair) { }) } +/** + * Filter each domain of the cluster manager in the state. + * @param {*} state + * @param {*} filterEnabledClusterPair + */ export function doActionFilter(state, filterEnabledClusterPair) { let filter = filterEnabledClusterPair.filter // When we close all, we also clear all filters. @@ -575,22 +823,45 @@ export function doActionFilter(state, filterEnabledClusterPair) { }) } +/** + * Set filter string of the cluster manager in state. + * @param {*} state + * @param {*} filterString + */ export function setFilterString(state, filterString) { state.clusterManager.filterString = filterString } +/** + * Set individual cluster filter string of the cluster manager in state. + * @param {*} state + * @param {*} filterString + */ export function setIndividualClusterFilterString(state, filterString) { state.clusterManager.individualClusterFilterString = filterString } +/** + * set the last selected domain of the cluster manager in the state. + * @param {*} state + * @param {*} domainNameString + */ export function setLastSelectedDomain(state, domainNameString) { state.clusterManager.lastSelectedDomain = domainNameString } +/** + * Clear last selected domain of the cluster manager in the state. + * @param {*} state + */ export function clearLastSelectedDomain(state) { state.clusterManager.lastSelectedDomain = null } +/** + * Reset the filter of cluster manager in the state. + * @param {*} state + */ export function resetFilters(state) { state.clusterManager.filter = { label: 'No Filter', @@ -600,22 +871,46 @@ export function resetFilters(state) { state.clusterManager.openDomains = {} } +/** + * Set isExceptionsExpanded of the state. + * @param {*} state + */ export function expandedExceptionsToggle(state) { state.isExceptionsExpanded = !state.isExceptionsExpanded } +/** + * Update state's exceptions. + * @param {*} state + * @param {*} value + */ export function updateExceptions(state, value) { state.exceptions.push(value) } +/** + * Toggle state's showExceptionIcon + * @param {*} state + * @param {*} value + */ export function toggleShowExceptionIcon(state, value) { state.showExceptionIcon = value } +/** + * Update the project packages of the state. + * @param {*} state + * @param {*} packages + */ export function updateProjectPackages(state, packages) { vue3Set(state, 'packages', packages) } +/** + * Update Simplicity Studio's UC component details in the state. + * @param {*} state + * @param {*} data + */ export function updateUcComponentState(state, data) { if (data != null) { vue3Set(state.studio, 'ucComponents', data.ucComponents) @@ -623,22 +918,43 @@ export function updateUcComponentState(state, data) { } } +/** + * Update Simplicity Studio's selected UC components in the state. + * @param {*} state + * @param {*} data + */ export function updateSelectedUcComponentState(state, data) { if (data != null) { vue3Set(state.studio, 'selectedUcComponents', data.selectedUcComponents) } } +/** + * Load Simplicity Studio's cluster to UC component mapping. + * @param {*} state + * @param {*} map + */ export function loadZclClusterToUcComponentDependencyMap(state, map) { if (map != null) vue3Set(state.studio, 'zclSdkExtClusterToUcComponentMap', map) } +/** + * Sets the selected zap config in the state. + * @param {*} state + * @param {*} val + * @returns boolean + */ export function selectZapConfig(state, val) { state.selectedZapConfig = val return true } +/** + * Set all endpoint data in the state. + * @param {*} state + * @param {*} value + */ export function setAllEndpointsData(state, value) { vue3Set(state.allEndpointsData, value.endpointId, { selectedservers: value.servers, @@ -648,26 +964,49 @@ export function setAllEndpointsData(state, value) { }) } +/** + * Set the multiconfig in state when more than one protocol configuration or stack is selected in ZAP. + * @param {*} state + * @param {*} value + */ export function setMultiConfig(state, value) { state.isMultiConfig = value } -// This function change state of showCreateModifyEndpoint and will show or hide create endpoint modal +/** + * This function changes state of showCreateModifyEndpoint and will show or hide create endpoint modal + * @param {*} state + * @param {*} value + */ export function toggleEndpointModal(state, value) { state.showCreateModifyEndpoint = value } +/** + * Helps show or hide the multi-protocol tutorial. + * @param {*} state + * @param {*} value + */ export function toggleCmpTutorial(state, value) { state.isCmpTutorialSelected = value state.isEndpointTutorialSelected = !value } +/** + * Helps show or hide the endpoint tutorial. + * @param {*} state + * @param {*} value + */ export function toggleEndpointTutorial(state, value) { state.isEndpointTutorialSelected = value state.isCmpTutorialSelected = !value } -// This function will show you is tutorial step running or not +/** + * This function will show or hide the tutorial. + * @param {*} state + * @param {*} value + */ export function toggleTutorial(state, value) { state.isTutorialRunning = value if (!value) { @@ -676,29 +1015,50 @@ export function toggleTutorial(state, value) { } } -// This function will expand the cluster so you can see data in it ( this function used for vue tour ) +/** + * This function will expand the cluster so you can see data in it ( this function used for vue tour ) + * @param {*} state + * @param {*} value + */ export function triggerExpanded(state, value) { state.expanded = value } -// This function will change the tab of the cluster configuration page +/** + * This function will change the tab of the cluster configuration page + * @param {*} state + * @param {*} value + */ export function openReportTabInCluster(state, value) { state.showReportTabInCluster = value } -// This function will set data of the endpoint that you created for showing clusters +/** + * This function will set data of the endpoint that you created for showing clusters + * @param {*} state + * @param {*} value + */ export function setClusterDataForTutorial(state, value) { state.clusterDataForTutorial = value } -// This function will check whether should we show the profile id to the users or no +/** + * This function will check whether to show the profile id to the users or not. + * @param {*} state + * @param {*} value + */ export function updateIsProfileIdShown(state, value) { value == 0 ? (state.isProfileIdShown = false) : (state.isProfileIdShown = true) } -// This function will sets the deviceTypeRef and deviceIdentifier so users can see which device chosen in the tutorial +/** + * This function will set the deviceTypeRef and deviceIdentifier so users + * can see which device is chosen in the tutorial. + * @param {*} state + * @param {*} value + */ export function setDeviceTypeRefAndDeviceIdPair(state, value) { state.deviceTypeRefAndDeviceIdPair = { deviceTypeRef: value.deviceTypeRef, @@ -706,26 +1066,48 @@ export function setDeviceTypeRefAndDeviceIdPair(state, value) { } } -// This function will toggle showEndpointData state and save that state +/** + * This function will toggle showEndpointData state and save that state + * @param {*} state + * @param {*} item + */ export function toggleShowEndpoint(state, item) { vue3Set(state.showEndpointData, item.id, item.value) } -// This function will update the cluster stage if cluster changed it will update the endpoint data +/** + * This function will update the cluster stage if cluster changed it will + * update the endpoint data. + * @param {*} state + * @param {*} value + */ export function updateIsClusterOptionChanged(state, value) { state.isClusterOptionChanged = value } -// Thie function will update the notification count after backend updates from websocket +/** + * This function will update the notification count after backend updates from websocket + * @param {*} state + * @param {*} value + */ export function updateNotificationCount(state, value) { state.notificationCount = value } -// This function will update the device type features after a new endpoint is selected +/** + * This function will update the device type features after a new endpoint is selected + * @param {*} state + * @param {*} value + */ export function updateDeviceTypeFeatures(state, value) { state.deviceTypeFeatures = value } +/** + * Set the state to dirty if there are unsaved changes. + * @param {*} state + * @param {*} isDirty + */ export function setDirtyState(state, isDirty) { if (state.isDirty != isDirty) { state.isDirty = isDirty @@ -736,6 +1118,11 @@ export function setDirtyState(state, isDirty) { } } +/** + * Set the enabled clusters of the state. + * @param {*} state + * @param {*} clusters + */ export function setEnabledClusters(state, clusters) { state.enabledClusters = clusters } diff --git a/src/store/zap/state.js b/src/store/zap/state.js index d189e2231a..7357c86027 100644 --- a/src/store/zap/state.js +++ b/src/store/zap/state.js @@ -16,6 +16,10 @@ */ const restApi = require('../../../src-shared/rest-api.js') +/** + * Entails the current state of ZAP + * @returns state object + */ export default function () { return { selectedZapConfig: null, diff --git a/src/util/observable.js b/src/util/observable.js index a705158f28..0dcae04857 100644 --- a/src/util/observable.js +++ b/src/util/observable.js @@ -26,7 +26,6 @@ * if type "string", it's used as a function name and will be invoked upon the Window Object * if type "function", it's invoked as a callback. */ - export function observeAttribute(attributeName, callbackObj) { // HTML attribute names are not guaranteed to be case sensitive attributeName = attributeName.toLowerCase() diff --git a/src/util/util.js b/src/util/util.js index 0ad15f3fe6..7c49413b2d 100644 --- a/src/util/util.js +++ b/src/util/util.js @@ -18,14 +18,25 @@ const http = require('http-status-codes') import { Notify } from 'quasar' -// Implements the pairing function here as a perfect hash. -// https://en.wikipedia.org/wiki/Pairing_function#Cantor_pairing_function -// We don't implement the inverse at this time. -// This function takes in 2 non-negative natural numbers, and returns a natural number +/** + * Implements the pairing function here as a perfect hash. + * https://en.wikipedia.org/wiki/Pairing_function#Cantor_pairing_function + * We don't implement the inverse at this time. + * This function takes in 2 non-negative natural numbers, and returns a natural number + * @param {*} x + * @param {*} y + * @returns returns a natural number + */ export function cantorPair(x, y) { return ((x + y) * (x + y + 1)) / 2 + y } +/** + * Returns a hex value for a given input value and padding + * @param {*} input + * @param {*} padding + * @returns Hex value + */ export function asHex(input, padding) { if (input == null) return '' if (input < 0) return input.toString() @@ -110,10 +121,20 @@ export function notifyComponentUpdateStatus(componentIdStates, added) { } } +/** + * Get all selected UC components + * @param {*} ucComponentList + * @returns Returns list of selected UC components + */ export function getSelectedUcComponents(ucComponentList) { return ucComponentList.filter((x) => x.isSelected) } +/** + * Get all UC components + * @param {*} ucComponentTreeResponse + * @returns UC components + */ export function getUcComponents(ucComponentTreeResponse) { // computed selected Nodes let selectedComponents = [] diff --git a/test/test-query.js b/test/test-query.js index 359b461199..382cad4332 100644 --- a/test/test-query.js +++ b/test/test-query.js @@ -166,7 +166,7 @@ WHERE * @param {*} sessionUuid * @param {*} zclFile * @param {*} genTemplatesFile - * @returns + * @returns session ID */ async function createSession(db, user, sessionUuid, zclFile, genTemplatesFile) { let userSession = await querySession.ensureZapUserAndSession(