Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
Z
zap
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
esp-mirror
project-chip
zap
提交
fad2a60e
未验证
提交
fad2a60e
编辑于
11 months ago
作者:
paulr34
提交者:
GitHub
11 months ago
浏览文件
操作
下载
补丁
差异文件
further cleanup and documentation (#1290)
* further cleanup and documentation
上级
fba76592
No related branches found
No related tags found
无相关合并请求
变更
1
隐藏空白变更内容
行内
左右并排
显示
1 个更改的文件
src-electron/sdk/matter.js
+47
-34
47 个添加, 34 个删除
src-electron/sdk/matter.js
有
47 个添加
和
34 个删除
src-electron/sdk/matter.js
+
47
−
34
浏览文件 @
fad2a60e
...
...
@@ -20,25 +20,20 @@ const queryPackage = require('../db/query-package.js')
const
queryCluster
=
require
(
'
../db/query-cluster.js
'
)
const
queryAttribute
=
require
(
'
../db/query-attribute.js
'
)
const
dbEnum
=
require
(
'
../../src-shared/db-enum.js
'
)
const
fs
=
require
(
'
fs
'
)
const
fsp
=
fs
.
promises
/**
* This file implements SDK rules which are used to upgrade .zap files and xml files
* to be in sync with the Matter SDK and spec
*/
/**
* Returns an array of objects containing global attributes that should be forced external.
* This asynchronous function retrieves and returns the forced external storage options.
*
* @export
* @param {*} db
* @param {*} attributeId
* @returns An array of objects
* @param {Object} db - The database instance.
*
* The function calls the 'getAttributeAccessInterface' method from 'queryPackage' with
* the database instance and 'attributeAccessInterface' from 'storagePolicy' as parameters.
* The result is assigned to 'forcedExternal'.
* Finally, it returns the 'forcedExternal' options.
*/
async
function
getForcedExternalStorage
(
db
)
{
let
forcedExternal
=
await
queryPackage
.
getAttributeAccessInterface
(
let
forcedExternal
=
queryPackage
.
getAttributeAccessInterface
(
db
,
dbEnum
.
storagePolicy
.
attributeAccessInterface
)
...
...
@@ -72,13 +67,14 @@ async function computeStoragePolicyForGlobalAttributes(
attributes
.
map
(
async
(
attribute
)
=>
{
if
(
attribute
.
clusterId
==
null
)
{
forcedExternal
=
await
getForcedExternalStorage
(
db
,
attribute
.
id
)
forcedExternal
.
map
((
option
)
=>
{
forcedExternal
.
some
((
option
)
=>
{
if
(
option
.
optionCategory
==
clusterName
&&
option
.
optionLabel
==
attribute
.
name
)
{
attribute
.
storagePolicy
=
dbEnum
.
storagePolicy
.
attributeAccessInterface
return
true
}
})
}
...
...
@@ -87,16 +83,15 @@ async function computeStoragePolicyForGlobalAttributes(
)
}
/**
*
Returns a flag stating which type of storage option the attribute is categorized to be
.
*
This asynchronous function computes and returns the new configuration for a storage option
.
*
* @export
* @param {*} db
* @param {*} clusterName
* @param {*} clusterRef
* @param {*} storagePolicy
* @param {*} forcedExternal
* @param {*} attributeId
* @returns Storage Option
* @param {String} storagePolicy - 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.
*/
async
function
computeStorageOptionNewConfig
(
storagePolicy
)
{
...
...
@@ -110,7 +105,20 @@ async function computeStorageOptionNewConfig(storagePolicy) {
}
return
storageOption
}
/**
* This asynchronous function computes and returns the new configuration for a storage policy.
*
* @param {Object} db - The database instance.
* @param {Number} clusterRef - The reference to the cluster.
* @param {String} storagePolicy - The current storage policy.
* @param {Array} forcedExternal - An array of external options.
* @param {String} attributeName - 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.
*/
async
function
computeStoragePolicyNewConfig
(
db
,
clusterRef
,
...
...
@@ -118,28 +126,33 @@ async function computeStoragePolicyNewConfig(
forcedExternal
,
attributeName
)
{
let
clusterName
clusterName
=
await
queryCluster
.
selectClusterName
(
db
,
clusterRef
)
forcedExternal
.
map
((
option
)
=>
{
let
clusterName
=
await
queryCluster
.
selectClusterName
(
db
,
clusterRef
)
forcedExternal
.
some
((
option
)
=>
{
if
(
option
.
optionCategory
==
clusterName
&&
option
.
optionLabel
==
attributeName
)
{
storagePolicy
=
dbEnum
.
storagePolicy
.
attributeAccessInterface
return
true
}
})
return
storagePolicy
}
/**
*
Returns a flag stating which type of storage option the attribute is categorized to be
.
*
This asynchronous function computes and returns the updated storage import policy
.
*
* @export
* @param {*} db
* @param {*} clusterName
* @param {*} forcedExternal
* @param {*} attributeId
* @returns Storage Policy
* @param {Object} db - The database instance.
* @param {String} clusterName - The name of the cluster.
* @param {String} storagePolicy - The current storage policy.
* @param {Array} forcedExternal - An array of external options.
* @param {String} attributeName - 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.
*/
async
function
computeStorageImport
(
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录