@iobroker/db-objects-redis 7.2.3 → 7.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/build/cjs/lib/objects/lua-v3/custom.lua +23 -1
  2. package/build/cjs/lib/objects/lua-v3/filter.lua +23 -1
  3. package/build/cjs/lib/objects/lua-v3/programs.lua +23 -1
  4. package/build/cjs/lib/objects/lua-v3/script.lua +23 -1
  5. package/build/cjs/lib/objects/lua-v3/variables.lua +23 -1
  6. package/build/cjs/lib/objects/lua-v4/custom.lua +23 -1
  7. package/build/cjs/lib/objects/lua-v4/filter.lua +23 -1
  8. package/build/cjs/lib/objects/lua-v4/programs.lua +23 -1
  9. package/build/cjs/lib/objects/lua-v4/script.lua +23 -1
  10. package/build/cjs/lib/objects/lua-v4/variables.lua +23 -1
  11. package/build/cjs/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  12. package/build/cjs/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  13. package/build/cjs/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  14. package/build/cjs/lib/objects/lua-v4-no-sets/script.lua +23 -1
  15. package/build/cjs/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  16. package/build/esm/lib/objects/lua-v3/custom.lua +23 -1
  17. package/build/esm/lib/objects/lua-v3/filter.lua +23 -1
  18. package/build/esm/lib/objects/lua-v3/programs.lua +23 -1
  19. package/build/esm/lib/objects/lua-v3/script.lua +23 -1
  20. package/build/esm/lib/objects/lua-v3/variables.lua +23 -1
  21. package/build/esm/lib/objects/lua-v4/custom.lua +23 -1
  22. package/build/esm/lib/objects/lua-v4/filter.lua +23 -1
  23. package/build/esm/lib/objects/lua-v4/programs.lua +23 -1
  24. package/build/esm/lib/objects/lua-v4/script.lua +23 -1
  25. package/build/esm/lib/objects/lua-v4/variables.lua +23 -1
  26. package/build/esm/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  27. package/build/esm/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  28. package/build/esm/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  29. package/build/esm/lib/objects/lua-v4-no-sets/script.lua +23 -1
  30. package/build/esm/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  31. package/build/tsconfig.build.tsbuildinfo +1 -1
  32. package/package.json +3 -3
@@ -7,11 +7,33 @@ cursor = result[1]
7
7
  local keys = result[2]
8
8
  local argStart = KEYS[1] .. KEYS[2]
9
9
  local argEnd = KEYS[1] .. KEYS[3]
10
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
11
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
12
+ local sLen = #argStart
13
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
14
+ local function byteLess(a, b, from)
15
+ local la, lb = #a, #b
16
+ local i = from or 1
17
+ while i <= la and i <= lb do
18
+ local ca, cb = a:byte(i), b:byte(i)
19
+ if ca ~= cb then
20
+ return ca < cb
21
+ end
22
+ i = i + 1
23
+ end
24
+ return la < lb
25
+ end
26
+ local function inRange(key)
27
+ if endHasPrefix then
28
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
29
+ end
30
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
31
+ end
10
32
  local checkStr = string.format("%q:%q", "type", "script")
11
33
  -- function(doc) {
12
34
  -- if (doc.type === "script" && doc.common.engineType.match(/^[jJ]ava[sS]cript|^[cC]offee[sS]cript|^[tT]ype[sS]cript|^Blockly/)) emit(doc.common.name, doc); }
13
35
  for _, key in ipairs(keys) do
14
- if (key >= argStart and key < argEnd) then
36
+ if (inRange(key)) then
15
37
  local obj = redis.call("get", key)
16
38
  if (obj:find(checkStr) ~= nil) then
17
39
  local success, decoded = pcall(cjson.decode, obj)
@@ -8,6 +8,28 @@ cursor = result[1]
8
8
  local keys = result[2]
9
9
  local argStart = KEYS[1] .. KEYS[2]
10
10
  local argEnd = KEYS[1] .. KEYS[3]
11
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
12
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
13
+ local sLen = #argStart
14
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
15
+ local function byteLess(a, b, from)
16
+ local la, lb = #a, #b
17
+ local i = from or 1
18
+ while i <= la and i <= lb do
19
+ local ca, cb = a:byte(i), b:byte(i)
20
+ if ca ~= cb then
21
+ return ca < cb
22
+ end
23
+ i = i + 1
24
+ end
25
+ return la < lb
26
+ end
27
+ local function inRange(key)
28
+ if endHasPrefix then
29
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
30
+ end
31
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
32
+ end
11
33
  local checkStr = string.format("%q:", "TypeName");
12
34
  -- function(doc) {
13
35
  -- if (doc._id.match(/^hm-rega\\.[0-9]+\\.[0-9,A-Z,a-z]+/) && (doc.native.TypeName === "ALARMDP" || doc.native.TypeName === "VARDP")) {
@@ -15,7 +37,7 @@ local checkStr = string.format("%q:", "TypeName");
15
37
  -- }
16
38
  -- }
17
39
  for _, key in ipairs(keys) do
18
- if (key >= argStart and key < argEnd and key:sub(7, 13) == "hm-rega") then
40
+ if (inRange(key) and key:sub(7, 13) == "hm-rega") then
19
41
  local obj = redis.call("get", key)
20
42
  if (obj:find(checkStr) ~= nil) then
21
43
  local success, decoded = pcall(cjson.decode, obj)
@@ -8,12 +8,34 @@ cursor = result[1]
8
8
  local keys = result[2]
9
9
  local argStart = KEYS[1] .. KEYS[2]
10
10
  local argEnd = KEYS[1] .. KEYS[3]
11
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
12
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
13
+ local sLen = #argStart
14
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
15
+ local function byteLess(a, b, from)
16
+ local la, lb = #a, #b
17
+ local i = from or 1
18
+ while i <= la and i <= lb do
19
+ local ca, cb = a:byte(i), b:byte(i)
20
+ if ca ~= cb then
21
+ return ca < cb
22
+ end
23
+ i = i + 1
24
+ end
25
+ return la < lb
26
+ end
27
+ local function inRange(key)
28
+ if endHasPrefix then
29
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
30
+ end
31
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
32
+ end
11
33
  -- function(doc) {
12
34
  -- if (doc.type==="state" && (doc.common.custom || doc.common.history))
13
35
  -- emit(doc._id, doc.common.custom || doc.common.history)
14
36
  -- }
15
37
  for _, key in ipairs(keys) do
16
- if (key >= argStart and key < argEnd) then
38
+ if (inRange(key)) then
17
39
  rep[#rep + 1] = redis.call("get", key)
18
40
  end
19
41
  end
@@ -7,9 +7,31 @@ cursor = result[1]
7
7
  local keys = result[2]
8
8
  local argStart = KEYS[1] .. KEYS[2]
9
9
  local argEnd = KEYS[1] .. KEYS[3]
10
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
11
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
12
+ local sLen = #argStart
13
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
14
+ local function byteLess(a, b, from)
15
+ local la, lb = #a, #b
16
+ local i = from or 1
17
+ while i <= la and i <= lb do
18
+ local ca, cb = a:byte(i), b:byte(i)
19
+ if ca ~= cb then
20
+ return ca < cb
21
+ end
22
+ i = i + 1
23
+ end
24
+ return la < lb
25
+ end
26
+ local function inRange(key)
27
+ if endHasPrefix then
28
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
29
+ end
30
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
31
+ end
10
32
  -- function(doc) { if (doc.type === "chart") emit(doc._id, doc); }
11
33
  for _, key in ipairs(keys) do
12
- if (key >= argStart and key < argEnd) then
34
+ if (inRange(key)) then
13
35
  rep[#rep + 1] = redis.call("get", key)
14
36
  end
15
37
  end
@@ -7,6 +7,28 @@ cursor = result[1]
7
7
  local keys = result[2]
8
8
  local argStart = KEYS[1] .. KEYS[2]
9
9
  local argEnd = KEYS[1] .. KEYS[3]
10
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
11
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
12
+ local sLen = #argStart
13
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
14
+ local function byteLess(a, b, from)
15
+ local la, lb = #a, #b
16
+ local i = from or 1
17
+ while i <= la and i <= lb do
18
+ local ca, cb = a:byte(i), b:byte(i)
19
+ if ca ~= cb then
20
+ return ca < cb
21
+ end
22
+ i = i + 1
23
+ end
24
+ return la < lb
25
+ end
26
+ local function inRange(key)
27
+ if endHasPrefix then
28
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
29
+ end
30
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
31
+ end
10
32
  local checkStr = string.format("%q:%q", "TypeName", "PROGRAM")
11
33
  -- function(doc) {
12
34
  -- if (doc._id.match(/^hm-rega\\.[0-9]+\\.[0-9,A-Z,a-z]+/) && (doc.native.TypeName === "PROGRAM")) {
@@ -14,7 +36,7 @@ local checkStr = string.format("%q:%q", "TypeName", "PROGRAM")
14
36
  -- }
15
37
  -- }
16
38
  for _, key in ipairs(keys) do
17
- if (key >= argStart and key < argEnd) then
39
+ if (inRange(key)) then
18
40
  local obj = redis.call("get", key)
19
41
  if (obj:find(checkStr) ~= nil) then
20
42
  local success, decoded = pcall(cjson.decode, obj)
@@ -7,10 +7,32 @@ cursor = result[1]
7
7
  local keys = result[2]
8
8
  local argStart = KEYS[1] .. KEYS[2]
9
9
  local argEnd = KEYS[1] .. KEYS[3]
10
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
11
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
12
+ local sLen = #argStart
13
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
14
+ local function byteLess(a, b, from)
15
+ local la, lb = #a, #b
16
+ local i = from or 1
17
+ while i <= la and i <= lb do
18
+ local ca, cb = a:byte(i), b:byte(i)
19
+ if ca ~= cb then
20
+ return ca < cb
21
+ end
22
+ i = i + 1
23
+ end
24
+ return la < lb
25
+ end
26
+ local function inRange(key)
27
+ if endHasPrefix then
28
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
29
+ end
30
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
31
+ end
10
32
  -- function(doc) {
11
33
  -- if (doc.type === "script" && doc.common.engineType.match(/^[jJ]ava[sS]cript|^[cC]offee[sS]cript|^[tT]ype[sS]cript|^Blockly/)) emit(doc.common.name, doc); }
12
34
  for _, key in ipairs(keys) do
13
- if (key >= argStart and key < argEnd) then
35
+ if (inRange(key)) then
14
36
  rep[#rep + 1] = redis.call("get", key)
15
37
  end
16
38
  end
@@ -8,6 +8,28 @@ cursor = result[1]
8
8
  local keys = result[2]
9
9
  local argStart = KEYS[1] .. KEYS[2]
10
10
  local argEnd = KEYS[1] .. KEYS[3]
11
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
12
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
13
+ local sLen = #argStart
14
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
15
+ local function byteLess(a, b, from)
16
+ local la, lb = #a, #b
17
+ local i = from or 1
18
+ while i <= la and i <= lb do
19
+ local ca, cb = a:byte(i), b:byte(i)
20
+ if ca ~= cb then
21
+ return ca < cb
22
+ end
23
+ i = i + 1
24
+ end
25
+ return la < lb
26
+ end
27
+ local function inRange(key)
28
+ if endHasPrefix then
29
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
30
+ end
31
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
32
+ end
11
33
  local checkStr = string.format("%q:", "TypeName");
12
34
  -- function(doc) {
13
35
  -- if (doc._id.match(/^hm-rega\\.[0-9]+\\.[0-9,A-Z,a-z]+/) && (doc.native.TypeName === "ALARMDP" || doc.native.TypeName === "VARDP")) {
@@ -15,7 +37,7 @@ local checkStr = string.format("%q:", "TypeName");
15
37
  -- }
16
38
  -- }
17
39
  for _, key in ipairs(keys) do
18
- if (key >= argStart and key < argEnd) then
40
+ if (inRange(key)) then
19
41
  local obj = redis.call("get", key)
20
42
  if (obj:find(checkStr) ~= nil) then
21
43
  local success, decoded = pcall(cjson.decode, obj)
@@ -8,13 +8,35 @@ cursor = result[1]
8
8
  local keys = result[2]
9
9
  local argStart = KEYS[1] .. KEYS[2]
10
10
  local argEnd = KEYS[1] .. KEYS[3]
11
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
12
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
13
+ local sLen = #argStart
14
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
15
+ local function byteLess(a, b, from)
16
+ local la, lb = #a, #b
17
+ local i = from or 1
18
+ while i <= la and i <= lb do
19
+ local ca, cb = a:byte(i), b:byte(i)
20
+ if ca ~= cb then
21
+ return ca < cb
22
+ end
23
+ i = i + 1
24
+ end
25
+ return la < lb
26
+ end
27
+ local function inRange(key)
28
+ if endHasPrefix then
29
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
30
+ end
31
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
32
+ end
11
33
  local checkStr = string.format("%q:{", "custom")
12
34
  -- function(doc) {
13
35
  -- if (doc.type==="state" && (doc.common.custom || doc.common.history))
14
36
  -- emit(doc._id, doc.common.custom || doc.common.history)
15
37
  -- }
16
38
  for _, key in ipairs(keys) do
17
- if (key >= argStart and key < argEnd) then
39
+ if (inRange(key)) then
18
40
  local obj = redis.call("get", key)
19
41
  if (obj:find(checkStr) ~= nil) then
20
42
  local success, decoded = pcall(cjson.decode, obj)
@@ -7,12 +7,34 @@ cursor = result[1]
7
7
  local keys = result[2]
8
8
  local argStart = KEYS[1] .. KEYS[2]
9
9
  local argEnd = KEYS[1] .. KEYS[3]
10
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
11
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
12
+ local sLen = #argStart
13
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
14
+ local function byteLess(a, b, from)
15
+ local la, lb = #a, #b
16
+ local i = from or 1
17
+ while i <= la and i <= lb do
18
+ local ca, cb = a:byte(i), b:byte(i)
19
+ if ca ~= cb then
20
+ return ca < cb
21
+ end
22
+ i = i + 1
23
+ end
24
+ return la < lb
25
+ end
26
+ local function inRange(key)
27
+ if endHasPrefix then
28
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
29
+ end
30
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
31
+ end
10
32
  local type = KEYS[4]
11
33
  local checkStr = string.format("%q:%q", "type", type)
12
34
  local skipCheck = not (type == "channel" or type == "device" or type == "folder")
13
35
  -- function(doc) { if (doc.type === "chart") emit(doc._id, doc); }
14
36
  for _, key in ipairs(keys) do
15
- if (key >= argStart and key < argEnd) then
37
+ if (inRange(key)) then
16
38
  local obj = redis.call("get", key)
17
39
  if (skipCheck or obj:find(checkStr) ~= nil) then
18
40
  local success, decoded = pcall(cjson.decode, obj)
@@ -7,6 +7,28 @@ cursor = result[1]
7
7
  local keys = result[2]
8
8
  local argStart = KEYS[1] .. KEYS[2]
9
9
  local argEnd = KEYS[1] .. KEYS[3]
10
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
11
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
12
+ local sLen = #argStart
13
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
14
+ local function byteLess(a, b, from)
15
+ local la, lb = #a, #b
16
+ local i = from or 1
17
+ while i <= la and i <= lb do
18
+ local ca, cb = a:byte(i), b:byte(i)
19
+ if ca ~= cb then
20
+ return ca < cb
21
+ end
22
+ i = i + 1
23
+ end
24
+ return la < lb
25
+ end
26
+ local function inRange(key)
27
+ if endHasPrefix then
28
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
29
+ end
30
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
31
+ end
10
32
  local checkStr = string.format("%q:%q", "TypeName", "PROGRAM")
11
33
  -- function(doc) {
12
34
  -- if (doc._id.match(/^hm-rega\\.[0-9]+\\.[0-9,A-Z,a-z]+/) && (doc.native.TypeName === "PROGRAM")) {
@@ -14,7 +36,7 @@ local checkStr = string.format("%q:%q", "TypeName", "PROGRAM")
14
36
  -- }
15
37
  -- }
16
38
  for _, key in ipairs(keys) do
17
- if (key >= argStart and key < argEnd and key:sub(7, 13) == "hm-rega") then
39
+ if (inRange(key) and key:sub(7, 13) == "hm-rega") then
18
40
  local obj = redis.call("get", key)
19
41
  if (obj:find(checkStr) ~= nil) then
20
42
  local success, decoded = pcall(cjson.decode, obj)
@@ -7,11 +7,33 @@ cursor = result[1]
7
7
  local keys = result[2]
8
8
  local argStart = KEYS[1] .. KEYS[2]
9
9
  local argEnd = KEYS[1] .. KEYS[3]
10
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
11
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
12
+ local sLen = #argStart
13
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
14
+ local function byteLess(a, b, from)
15
+ local la, lb = #a, #b
16
+ local i = from or 1
17
+ while i <= la and i <= lb do
18
+ local ca, cb = a:byte(i), b:byte(i)
19
+ if ca ~= cb then
20
+ return ca < cb
21
+ end
22
+ i = i + 1
23
+ end
24
+ return la < lb
25
+ end
26
+ local function inRange(key)
27
+ if endHasPrefix then
28
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
29
+ end
30
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
31
+ end
10
32
  local checkStr = string.format("%q:%q", "type", "script")
11
33
  -- function(doc) {
12
34
  -- if (doc.type === "script" && doc.common.engineType.match(/^[jJ]ava[sS]cript|^[cC]offee[sS]cript|^[tT]ype[sS]cript|^Blockly/)) emit(doc.common.name, doc); }
13
35
  for _, key in ipairs(keys) do
14
- if (key >= argStart and key < argEnd) then
36
+ if (inRange(key)) then
15
37
  local obj = redis.call("get", key)
16
38
  if (obj:find(checkStr) ~= nil) then
17
39
  local success, decoded = pcall(cjson.decode, obj)
@@ -8,6 +8,28 @@ cursor = result[1]
8
8
  local keys = result[2]
9
9
  local argStart = KEYS[1] .. KEYS[2]
10
10
  local argEnd = KEYS[1] .. KEYS[3]
11
+ -- Compare bytes: Lua's < uses strcoll(), so it depends on the locale the Redis
12
+ -- server was started with, and argEnd ends in the U+9999 sentinel.
13
+ local sLen = #argStart
14
+ local endHasPrefix = argEnd:sub(1, sLen) == argStart
15
+ local function byteLess(a, b, from)
16
+ local la, lb = #a, #b
17
+ local i = from or 1
18
+ while i <= la and i <= lb do
19
+ local ca, cb = a:byte(i), b:byte(i)
20
+ if ca ~= cb then
21
+ return ca < cb
22
+ end
23
+ i = i + 1
24
+ end
25
+ return la < lb
26
+ end
27
+ local function inRange(key)
28
+ if endHasPrefix then
29
+ return key:sub(1, sLen) == argStart and byteLess(key, argEnd, sLen + 1)
30
+ end
31
+ return not byteLess(key, argStart) and byteLess(key, argEnd)
32
+ end
11
33
  local checkStr = string.format("%q:", "TypeName");
12
34
  -- function(doc) {
13
35
  -- if (doc._id.match(/^hm-rega\\.[0-9]+\\.[0-9,A-Z,a-z]+/) && (doc.native.TypeName === "ALARMDP" || doc.native.TypeName === "VARDP")) {
@@ -15,7 +37,7 @@ local checkStr = string.format("%q:", "TypeName");
15
37
  -- }
16
38
  -- }
17
39
  for _, key in ipairs(keys) do
18
- if (key >= argStart and key < argEnd and key:sub(7, 13) == "hm-rega") then
40
+ if (inRange(key) and key:sub(7, 13) == "hm-rega") then
19
41
  local obj = redis.call("get", key)
20
42
  if (obj:find(checkStr) ~= nil) then
21
43
  local success, decoded = pcall(cjson.decode, obj)