Skip to content

Commit

Permalink
Deprecating the matter stateful helpers
Browse files Browse the repository at this point in the history
Github: ZAP#682
  • Loading branch information
brdandu committed Apr 4, 2023
1 parent 3ef5077 commit 83ff5d4
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 18 deletions.
25 changes: 25 additions & 0 deletions src-electron/generator/helper-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,30 @@ async function generated_attribute_min_max_index(
return dataPtr
}

/**
* 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
* @param {*} options
* @returns Promise of the resolved blocks iterating over cluster commands.
*
*/
async function if_enabled_clusters(options) {
let endpointTypes = await templateUtil.ensureEndpointTypeIds(this)
let clusters =
await queryEndpointType.selectAllClustersDetailsFromEndpointTypes(
this.global.db,
endpointTypes,
options
)
if (clusters.length > 0) {
return options.fn(this)
} else {
return options.inverse(this)
}
}

const dep = templateUtil.deprecatedHelper

// WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
Expand Down Expand Up @@ -1592,3 +1616,4 @@ exports.is_command_default_response_enabled =
is_command_default_response_enabled
exports.is_command_default_response_disabled =
is_command_default_response_disabled
exports.if_enabled_clusters = if_enabled_clusters
Original file line number Diff line number Diff line change
Expand Up @@ -750,44 +750,81 @@ const dep = templateUtil.deprecatedHelper;
//
// Module exports
//
exports.chip_clusters = chip_clusters;
exports.chip_has_clusters = chip_has_clusters;
exports.chip_clusters = dep(
chip_clusters,
'chip_clusters has been deprecated. Use all_user_clusters.'
);
exports.chip_has_clusters = dep(
chip_has_clusters,
'Use first/last block helper within all_user_clusters.'
);
exports.chip_client_clusters = dep(
chip_client_clusters,
'chip_client_clusters has been deprecated. Use all_user_clusters with the \
side option as client'
side option as client.'
);
exports.chip_has_client_clusters = dep(
chip_has_client_clusters,
'chip_has_client_clusters has been deprecated. Use if_enabled_clusters with side option as client.'
);
exports.chip_server_clusters = dep(
chip_server_clusters,
'chip_server_clusters has been deprecated. Use all_user_clusters with the side option as server.'
);
exports.chip_has_server_clusters = dep(
chip_has_server_clusters,
'chip_has_server_clusters has been deprecated. Use if_enabled_clusters with side option as server.'
);
exports.chip_has_client_clusters = chip_has_client_clusters;
exports.chip_server_clusters = chip_server_clusters;
exports.chip_has_server_clusters = chip_has_server_clusters;
exports.chip_cluster_commands = dep(
chip_cluster_commands,
'chip_cluster_commands has been deprecated. Use zcl_commands with source attribute as client'
'chip_cluster_commands has been deprecated. Use zcl_commands with source attribute as client.'
);
exports.chip_cluster_command_arguments = dep(chip_cluster_command_arguments, {
to: 'zcl_command_arguments',
});
exports.chip_cluster_command_arguments_with_structs_expanded =
chip_cluster_command_arguments_with_structs_expanded;
exports.chip_cluster_command_arguments_with_structs_expanded = dep(
chip_cluster_command_arguments_with_structs_expanded,
'chip_cluster_command_arguments_with_structs_expanded has been deprecated. Use if_is_struct and zcl_struct_items_by_struct_name to expand the structs.'
);
exports.chip_server_global_responses = chip_server_global_responses;
exports.chip_cluster_responses = dep(chip_cluster_responses, {
to: 'zcl_command_responses',
});
exports.chip_cluster_response_arguments = chip_cluster_response_arguments;
exports.chip_cluster_response_arguments = dep(
chip_cluster_response_arguments,
'chip_cluster_response_arguments has been deprecated. Use zcl_command_arguments.'
);
exports.chip_attribute_list_entryTypes = chip_attribute_list_entryTypes;
exports.chip_server_cluster_attributes = dep(
chip_server_cluster_attributes,
'chip_server_cluster_attributes has been deprecated. Use \
enabled_attributes_for_cluster_and_side and \
zcl_attributes_server to get enabled and all server attributes respectively'
zcl_attributes_server to get enabled and all server attributes respectively.'
);
exports.chip_server_cluster_events = dep(
chip_server_cluster_events,
'chip_server_cluster_events has been deprecated. Use zcl_events.'
);
exports.chip_server_has_list_attributes = dep(
chip_server_has_list_attributes,
'chip_server_has_list_attributes has been deprecated. Use isArray option to fiter array type attributes and use first/last blocks for one time checks.'
);
exports.chip_server_has_reportable_attributes = dep(
chip_server_has_reportable_attributes,
'chip_server_has_reportable_attributes has been deprecated. Use isReportableAttribute option to fiter reportable attributes and use first/last blocks for one time checks.'
);
exports.chip_available_cluster_commands = dep(
chip_available_cluster_commands,
'chip_available_cluster_commands has been deprecated. Use zcl_commands or all_user_cluster_generated_commands.'
);
exports.chip_endpoints = dep(
chip_endpoints,
'chip_endpoints has been deprecated. Use user_endpoints.'
);
exports.chip_endpoint_clusters = dep(
chip_endpoint_clusters,
'chip_endpoint_clusters has been deprecated. Use user_clusters or all_user_clusters.'
);
exports.chip_server_cluster_events = chip_server_cluster_events;
exports.chip_server_has_list_attributes = chip_server_has_list_attributes;
exports.chip_server_has_reportable_attributes =
chip_server_has_reportable_attributes;
exports.chip_available_cluster_commands = chip_available_cluster_commands;
exports.chip_endpoints = chip_endpoints;
exports.chip_endpoint_clusters = chip_endpoint_clusters;
exports.if_chip_enum = if_chip_enum;
exports.if_chip_complex = if_chip_complex;
exports.if_basic_global_response = dep(if_basic_global_response, {
Expand Down

0 comments on commit 83ff5d4

Please sign in to comment.