@iobroker/db-objects-redis 7.2.3 → 8.0.0-alpha.1-20260921-e5941ca8a

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 (57) hide show
  1. package/build/cjs/index.d.ts +1 -1
  2. package/build/cjs/index.js +5 -3
  3. package/build/cjs/index.js.map +2 -2
  4. package/build/cjs/lib/objects/constants.js.map +2 -2
  5. package/build/cjs/lib/objects/interview.js +2 -0
  6. package/build/cjs/lib/objects/interview.js.map +1 -1
  7. package/build/cjs/lib/objects/lua-v3/custom.lua +23 -1
  8. package/build/cjs/lib/objects/lua-v3/filter.lua +23 -1
  9. package/build/cjs/lib/objects/lua-v3/programs.lua +23 -1
  10. package/build/cjs/lib/objects/lua-v3/script.lua +23 -1
  11. package/build/cjs/lib/objects/lua-v3/variables.lua +23 -1
  12. package/build/cjs/lib/objects/lua-v4/custom.lua +23 -1
  13. package/build/cjs/lib/objects/lua-v4/filter.lua +23 -1
  14. package/build/cjs/lib/objects/lua-v4/programs.lua +23 -1
  15. package/build/cjs/lib/objects/lua-v4/script.lua +23 -1
  16. package/build/cjs/lib/objects/lua-v4/variables.lua +23 -1
  17. package/build/cjs/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  18. package/build/cjs/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  19. package/build/cjs/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  20. package/build/cjs/lib/objects/lua-v4-no-sets/script.lua +23 -1
  21. package/build/cjs/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  22. package/build/cjs/lib/objects/objectsInRedisClient.d.ts +961 -125
  23. package/build/cjs/lib/objects/objectsInRedisClient.js +1092 -776
  24. package/build/cjs/lib/objects/objectsInRedisClient.js.map +3 -3
  25. package/build/cjs/lib/objects/objectsUtils.d.ts +139 -17
  26. package/build/cjs/lib/objects/objectsUtils.js +212 -192
  27. package/build/cjs/lib/objects/objectsUtils.js.map +3 -3
  28. package/build/esm/index.d.ts +1 -1
  29. package/build/esm/index.d.ts.map +1 -1
  30. package/build/esm/index.js.map +1 -1
  31. package/build/esm/lib/objects/constants.d.ts.map +1 -1
  32. package/build/esm/lib/objects/constants.js.map +1 -1
  33. package/build/esm/lib/objects/lua-v3/custom.lua +23 -1
  34. package/build/esm/lib/objects/lua-v3/filter.lua +23 -1
  35. package/build/esm/lib/objects/lua-v3/programs.lua +23 -1
  36. package/build/esm/lib/objects/lua-v3/script.lua +23 -1
  37. package/build/esm/lib/objects/lua-v3/variables.lua +23 -1
  38. package/build/esm/lib/objects/lua-v4/custom.lua +23 -1
  39. package/build/esm/lib/objects/lua-v4/filter.lua +23 -1
  40. package/build/esm/lib/objects/lua-v4/programs.lua +23 -1
  41. package/build/esm/lib/objects/lua-v4/script.lua +23 -1
  42. package/build/esm/lib/objects/lua-v4/variables.lua +23 -1
  43. package/build/esm/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  44. package/build/esm/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  45. package/build/esm/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  46. package/build/esm/lib/objects/lua-v4-no-sets/script.lua +23 -1
  47. package/build/esm/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  48. package/build/esm/lib/objects/objectsInRedisClient.d.ts +961 -125
  49. package/build/esm/lib/objects/objectsInRedisClient.d.ts.map +1 -1
  50. package/build/esm/lib/objects/objectsInRedisClient.js +880 -571
  51. package/build/esm/lib/objects/objectsInRedisClient.js.map +1 -1
  52. package/build/esm/lib/objects/objectsUtils.d.ts +139 -17
  53. package/build/esm/lib/objects/objectsUtils.d.ts.map +1 -1
  54. package/build/esm/lib/objects/objectsUtils.js +273 -221
  55. package/build/esm/lib/objects/objectsUtils.js.map +1 -1
  56. package/build/tsconfig.build.tsbuildinfo +1 -1
  57. package/package.json +9 -9
@@ -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)