@effect-opcua/client 0.1.0-alpha.1

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 (171) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +367 -0
  3. package/dist/Opcua.d.mts +13 -0
  4. package/dist/Opcua.d.mts.map +1 -0
  5. package/dist/Opcua.mjs +23 -0
  6. package/dist/Opcua.mjs.map +1 -0
  7. package/dist/OpcuaClient.d.mts +27 -0
  8. package/dist/OpcuaClient.d.mts.map +1 -0
  9. package/dist/OpcuaClient.mjs +20 -0
  10. package/dist/OpcuaClient.mjs.map +1 -0
  11. package/dist/OpcuaError.d.mts +249 -0
  12. package/dist/OpcuaError.d.mts.map +1 -0
  13. package/dist/OpcuaError.mjs +97 -0
  14. package/dist/OpcuaError.mjs.map +1 -0
  15. package/dist/OpcuaMethod.d.mts +158 -0
  16. package/dist/OpcuaMethod.d.mts.map +1 -0
  17. package/dist/OpcuaMethod.mjs +31 -0
  18. package/dist/OpcuaMethod.mjs.map +1 -0
  19. package/dist/OpcuaSession.d.mts +247 -0
  20. package/dist/OpcuaSession.d.mts.map +1 -0
  21. package/dist/OpcuaSession.mjs +50 -0
  22. package/dist/OpcuaSession.mjs.map +1 -0
  23. package/dist/OpcuaSubscription.d.mts +148 -0
  24. package/dist/OpcuaSubscription.d.mts.map +1 -0
  25. package/dist/OpcuaSubscription.mjs +45 -0
  26. package/dist/OpcuaSubscription.mjs.map +1 -0
  27. package/dist/OpcuaVariable.d.mts +179 -0
  28. package/dist/OpcuaVariable.d.mts.map +1 -0
  29. package/dist/OpcuaVariable.mjs +15 -0
  30. package/dist/OpcuaVariable.mjs.map +1 -0
  31. package/dist/_virtual/rolldown_runtime.mjs +18 -0
  32. package/dist/index.d.mts +8 -0
  33. package/dist/index.mjs +7 -0
  34. package/dist/internal/batch/chunk.d.mts +11 -0
  35. package/dist/internal/batch/chunk.d.mts.map +1 -0
  36. package/dist/internal/batch/chunk.mjs +23 -0
  37. package/dist/internal/batch/chunk.mjs.map +1 -0
  38. package/dist/internal/batch/keyed.d.mts +50 -0
  39. package/dist/internal/batch/keyed.d.mts.map +1 -0
  40. package/dist/internal/batch/keyed.mjs +112 -0
  41. package/dist/internal/batch/keyed.mjs.map +1 -0
  42. package/dist/internal/batch/operations.d.mts +25 -0
  43. package/dist/internal/batch/operations.d.mts.map +1 -0
  44. package/dist/internal/batch/operations.mjs +213 -0
  45. package/dist/internal/batch/operations.mjs.map +1 -0
  46. package/dist/internal/browse/operations.d.mts +15 -0
  47. package/dist/internal/browse/operations.d.mts.map +1 -0
  48. package/dist/internal/browse/operations.mjs +72 -0
  49. package/dist/internal/browse/operations.mjs.map +1 -0
  50. package/dist/internal/client/make.d.mts +16 -0
  51. package/dist/internal/client/make.d.mts.map +1 -0
  52. package/dist/internal/client/make.mjs +76 -0
  53. package/dist/internal/client/make.mjs.map +1 -0
  54. package/dist/internal/common/collections.d.mts +5 -0
  55. package/dist/internal/common/collections.d.mts.map +1 -0
  56. package/dist/internal/common/collections.mjs +10 -0
  57. package/dist/internal/common/collections.mjs.map +1 -0
  58. package/dist/internal/common/constants.d.mts +18 -0
  59. package/dist/internal/common/constants.d.mts.map +1 -0
  60. package/dist/internal/common/constants.mjs +19 -0
  61. package/dist/internal/common/constants.mjs.map +1 -0
  62. package/dist/internal/common/node-id.d.mts +2 -0
  63. package/dist/internal/common/node-id.mjs +1 -0
  64. package/dist/internal/common/options.d.mts +15 -0
  65. package/dist/internal/common/options.d.mts.map +1 -0
  66. package/dist/internal/common/options.mjs +22 -0
  67. package/dist/internal/common/options.mjs.map +1 -0
  68. package/dist/internal/common/predicates.d.mts +8 -0
  69. package/dist/internal/common/predicates.d.mts.map +1 -0
  70. package/dist/internal/common/predicates.mjs +13 -0
  71. package/dist/internal/common/predicates.mjs.map +1 -0
  72. package/dist/internal/data-types/enum.d.mts +2 -0
  73. package/dist/internal/data-types/enum.mjs +3 -0
  74. package/dist/internal/data-types/manager.d.mts +2 -0
  75. package/dist/internal/data-types/manager.mjs +3 -0
  76. package/dist/internal/data-types/model.d.mts +2 -0
  77. package/dist/internal/data-types/model.mjs +1 -0
  78. package/dist/internal/data-types/read.d.mts +14 -0
  79. package/dist/internal/data-types/read.d.mts.map +1 -0
  80. package/dist/internal/data-types/read.mjs +291 -0
  81. package/dist/internal/data-types/read.mjs.map +1 -0
  82. package/dist/internal/data-types/structure.d.mts +2 -0
  83. package/dist/internal/data-types/structure.mjs +3 -0
  84. package/dist/internal/events/model.d.mts +72 -0
  85. package/dist/internal/events/model.d.mts.map +1 -0
  86. package/dist/internal/events/model.mjs +1 -0
  87. package/dist/internal/events/wire.d.mts +37 -0
  88. package/dist/internal/events/wire.d.mts.map +1 -0
  89. package/dist/internal/events/wire.mjs +127 -0
  90. package/dist/internal/events/wire.mjs.map +1 -0
  91. package/dist/internal/metadata/arguments.d.mts +2 -0
  92. package/dist/internal/metadata/arguments.mjs +3 -0
  93. package/dist/internal/metadata/methods.d.mts +2 -0
  94. package/dist/internal/metadata/methods.mjs +3 -0
  95. package/dist/internal/metadata/service.d.mts +23 -0
  96. package/dist/internal/metadata/service.d.mts.map +1 -0
  97. package/dist/internal/metadata/service.mjs +416 -0
  98. package/dist/internal/metadata/service.mjs.map +1 -0
  99. package/dist/internal/metadata/variables.d.mts +3 -0
  100. package/dist/internal/metadata/variables.mjs +3 -0
  101. package/dist/internal/method/arguments.d.mts +48 -0
  102. package/dist/internal/method/arguments.d.mts.map +1 -0
  103. package/dist/internal/method/arguments.mjs +216 -0
  104. package/dist/internal/method/arguments.mjs.map +1 -0
  105. package/dist/internal/method/operations.d.mts +19 -0
  106. package/dist/internal/method/operations.d.mts.map +1 -0
  107. package/dist/internal/method/operations.mjs +111 -0
  108. package/dist/internal/method/operations.mjs.map +1 -0
  109. package/dist/internal/monitoring/options.d.mts +30 -0
  110. package/dist/internal/monitoring/options.d.mts.map +1 -0
  111. package/dist/internal/monitoring/options.mjs +260 -0
  112. package/dist/internal/monitoring/options.mjs.map +1 -0
  113. package/dist/internal/monitoring/requests.d.mts +16 -0
  114. package/dist/internal/monitoring/requests.d.mts.map +1 -0
  115. package/dist/internal/monitoring/requests.mjs +53 -0
  116. package/dist/internal/monitoring/requests.mjs.map +1 -0
  117. package/dist/internal/monitoring/runtime.d.mts +14 -0
  118. package/dist/internal/monitoring/runtime.d.mts.map +1 -0
  119. package/dist/internal/monitoring/runtime.mjs +321 -0
  120. package/dist/internal/monitoring/runtime.mjs.map +1 -0
  121. package/dist/internal/monitoring/samples.d.mts +23 -0
  122. package/dist/internal/monitoring/samples.d.mts.map +1 -0
  123. package/dist/internal/monitoring/samples.mjs +45 -0
  124. package/dist/internal/monitoring/samples.mjs.map +1 -0
  125. package/dist/internal/session/make.d.mts +11 -0
  126. package/dist/internal/session/make.d.mts.map +1 -0
  127. package/dist/internal/session/make.mjs +36 -0
  128. package/dist/internal/session/make.mjs.map +1 -0
  129. package/dist/internal/session/service.d.mts +10 -0
  130. package/dist/internal/session/service.d.mts.map +1 -0
  131. package/dist/internal/session/service.mjs +232 -0
  132. package/dist/internal/session/service.mjs.map +1 -0
  133. package/dist/internal/structures/adapter.d.mts +11 -0
  134. package/dist/internal/structures/adapter.d.mts.map +1 -0
  135. package/dist/internal/structures/adapter.mjs +37 -0
  136. package/dist/internal/structures/adapter.mjs.map +1 -0
  137. package/dist/internal/structures/model.d.mts +21 -0
  138. package/dist/internal/structures/model.d.mts.map +1 -0
  139. package/dist/internal/structures/model.mjs +7 -0
  140. package/dist/internal/structures/model.mjs.map +1 -0
  141. package/dist/internal/structures/runtime.d.mts +28 -0
  142. package/dist/internal/structures/runtime.d.mts.map +1 -0
  143. package/dist/internal/structures/runtime.mjs +119 -0
  144. package/dist/internal/structures/runtime.mjs.map +1 -0
  145. package/dist/internal/subscription/options.d.mts +17 -0
  146. package/dist/internal/subscription/options.d.mts.map +1 -0
  147. package/dist/internal/subscription/options.mjs +51 -0
  148. package/dist/internal/subscription/options.mjs.map +1 -0
  149. package/dist/internal/subscription/runtime.d.mts +15 -0
  150. package/dist/internal/subscription/runtime.d.mts.map +1 -0
  151. package/dist/internal/subscription/runtime.mjs +43 -0
  152. package/dist/internal/subscription/runtime.mjs.map +1 -0
  153. package/dist/internal/values/codec.d.mts +53 -0
  154. package/dist/internal/values/codec.d.mts.map +1 -0
  155. package/dist/internal/values/codec.mjs +117 -0
  156. package/dist/internal/values/codec.mjs.map +1 -0
  157. package/dist/internal/values/normalize.d.mts +33 -0
  158. package/dist/internal/values/normalize.d.mts.map +1 -0
  159. package/dist/internal/values/normalize.mjs +177 -0
  160. package/dist/internal/values/normalize.mjs.map +1 -0
  161. package/dist/internal/values/result.d.mts +16 -0
  162. package/dist/internal/values/result.d.mts.map +1 -0
  163. package/dist/internal/values/result.mjs +15 -0
  164. package/dist/internal/values/result.mjs.map +1 -0
  165. package/dist/internal/variable/operations.d.mts +50 -0
  166. package/dist/internal/variable/operations.d.mts.map +1 -0
  167. package/dist/internal/variable/operations.mjs +192 -0
  168. package/dist/internal/variable/operations.mjs.map +1 -0
  169. package/dist/node-opcua.d.mts +2 -0
  170. package/dist/node-opcua.mjs +3 -0
  171. package/package.json +57 -0
@@ -0,0 +1,179 @@
1
+ import { AnySchema, CodecType, OpcuaCodec } from "./internal/values/codec.mjs";
2
+ import { DataType, DataValue, NodeId, Variant } from "node-opcua";
3
+
4
+ //#region src/OpcuaVariable.d.ts
5
+ declare namespace OpcuaVariable_d_exports {
6
+ export { AccessOfVariableDef, AnyReadResult, AnySchema, AnyVariableDef, AnyWriteManyRecord, CodecType, ExpandedNodeIdString, NodeIdOfVariableDef, NodeIdString, OpcuaCodec, OpcuaDynamicValue, OpcuaExpandedNodeIdInfo, OpcuaLocalizedTextInfo, OpcuaNodeIdInfo, OpcuaQualifiedNameInfo, OpcuaStatusInfo, OpcuaVariantInfo, ReadManyResult, ReadResult, ReadableVariableDef, ValueOfVariableDef, VariableAccess, VariableCapability, VariableDef, VariableMetadata, WritableVariableDef, WriteManyInput, WriteManyItem, WriteManyResult, WriteResult, make, makeVariableDef };
7
+ }
8
+ type NodeIdString = string;
9
+ type ExpandedNodeIdString = string;
10
+ type VariableCapability = "read" | "write";
11
+ type OpcuaStatusInfo = {
12
+ readonly text: string;
13
+ readonly code: number;
14
+ readonly isGood: boolean;
15
+ readonly isUncertain: boolean;
16
+ readonly isBad: boolean;
17
+ };
18
+ type OpcuaVariantInfo = {
19
+ readonly dataType: string;
20
+ readonly arrayType: "Scalar" | "Array" | "Matrix";
21
+ readonly valueRank?: number;
22
+ readonly arrayDimensions?: ReadonlyArray<number>;
23
+ };
24
+ type OpcuaDynamicValue = null | boolean | number | string | ReadonlyArray<OpcuaDynamicValue> | {
25
+ readonly _tag: "DateTime";
26
+ readonly iso: string;
27
+ } | {
28
+ readonly _tag: "ByteString";
29
+ readonly base64: string;
30
+ } | {
31
+ readonly _tag: "Int64";
32
+ readonly text: string;
33
+ } | {
34
+ readonly _tag: "UInt64";
35
+ readonly text: string;
36
+ } | {
37
+ readonly _tag: "LocalizedText";
38
+ readonly text: string;
39
+ readonly locale?: string;
40
+ } | {
41
+ readonly _tag: "QualifiedName";
42
+ readonly namespaceIndex: number;
43
+ readonly name: string;
44
+ readonly text: string;
45
+ } | {
46
+ readonly _tag: "NodeId";
47
+ readonly text: string;
48
+ readonly namespace: number;
49
+ readonly identifierType: string;
50
+ readonly value: unknown;
51
+ } | {
52
+ readonly _tag: "ExtensionObject";
53
+ readonly typeName?: string;
54
+ readonly value: Readonly<Record<string, OpcuaDynamicValue>>;
55
+ } | {
56
+ readonly _tag: "Object";
57
+ readonly typeName?: string;
58
+ readonly value: Readonly<Record<string, OpcuaDynamicValue>>;
59
+ };
60
+ type OpcuaNodeIdInfo = {
61
+ readonly text: string;
62
+ readonly namespace: number;
63
+ readonly namespaceUri?: string;
64
+ readonly identifierType: string;
65
+ readonly value: unknown;
66
+ };
67
+ type OpcuaExpandedNodeIdInfo = OpcuaNodeIdInfo & {
68
+ readonly serverIndex?: number;
69
+ readonly isLocal: boolean;
70
+ readonly isRemote: boolean;
71
+ };
72
+ type OpcuaQualifiedNameInfo = {
73
+ readonly namespaceIndex: number;
74
+ readonly name: string;
75
+ readonly text: string;
76
+ };
77
+ type OpcuaLocalizedTextInfo = {
78
+ readonly text: string;
79
+ readonly locale?: string;
80
+ };
81
+ type VariableAccess = "read" | "write" | "readWrite";
82
+ type VariableDef<Id$1 extends string = string, A$1 = OpcuaDynamicValue, Access extends VariableAccess = "read"> = {
83
+ readonly _tag: "VariableDef";
84
+ readonly nodeId: Id$1;
85
+ readonly codec: OpcuaCodec<A$1>;
86
+ readonly access: Access;
87
+ readonly includeRaw?: boolean;
88
+ };
89
+ type AnyVariableDef = VariableDef<string, unknown, VariableAccess>;
90
+ type ReadableVariableDef = VariableDef<string, unknown, "read"> | VariableDef<string, unknown, "readWrite">;
91
+ type WritableVariableDef = VariableDef<string, unknown, "write"> | VariableDef<string, unknown, "readWrite">;
92
+ type ValueOfVariableDef<Def$1> = Def$1 extends VariableDef<string, infer A, VariableAccess> ? A : never;
93
+ type AccessOfVariableDef<Def$1> = Def$1 extends VariableDef<string, unknown, infer Access> ? Access : never;
94
+ type NodeIdOfVariableDef<Def$1> = Def$1 extends VariableDef<infer Id, unknown, VariableAccess> ? Id : never;
95
+ type ReadResult<A$1, Id$1 extends string = string> = {
96
+ readonly _tag: "Value";
97
+ readonly nodeId: Id$1;
98
+ readonly value: A$1;
99
+ readonly status: OpcuaStatusInfo;
100
+ readonly sourceTimestamp?: string;
101
+ readonly serverTimestamp?: string;
102
+ readonly variant?: OpcuaVariantInfo;
103
+ readonly unsafeRaw?: {
104
+ readonly dataValue: DataValue;
105
+ readonly variant?: Variant;
106
+ };
107
+ } | {
108
+ readonly _tag: "NonGoodStatus";
109
+ readonly nodeId: Id$1;
110
+ readonly status: OpcuaStatusInfo;
111
+ readonly sourceTimestamp?: string;
112
+ readonly serverTimestamp?: string;
113
+ readonly variant?: OpcuaVariantInfo;
114
+ readonly unsafeRaw?: {
115
+ readonly dataValue: DataValue;
116
+ readonly variant?: Variant;
117
+ };
118
+ } | {
119
+ readonly _tag: "DecodeError";
120
+ readonly nodeId: Id$1;
121
+ readonly error: unknown;
122
+ readonly status: OpcuaStatusInfo;
123
+ readonly sourceTimestamp?: string;
124
+ readonly serverTimestamp?: string;
125
+ readonly variant?: OpcuaVariantInfo;
126
+ readonly unsafeRaw?: {
127
+ readonly dataValue: DataValue;
128
+ readonly variant?: Variant;
129
+ };
130
+ };
131
+ type AnyReadResult = ReadResult<unknown, string> | ReadResult<OpcuaDynamicValue, string>;
132
+ type ReadManyResult<Items> = { readonly [Key in keyof Items]: Items[Key] extends VariableDef<infer Id, infer A, "read" | "readWrite"> ? ReadResult<A, Id> : never };
133
+ type WriteResult<Id$1 extends string = string> = {
134
+ readonly _tag: "Written";
135
+ readonly nodeId: Id$1;
136
+ readonly status: OpcuaStatusInfo;
137
+ } | {
138
+ readonly _tag: "NonGoodStatus";
139
+ readonly nodeId: Id$1;
140
+ readonly status: OpcuaStatusInfo;
141
+ };
142
+ type WriteManyResult<Items> = { readonly [Key in keyof Items]: Items[Key] extends readonly [infer Def extends WritableVariableDef, unknown] ? Def extends VariableDef<infer Id, unknown, VariableAccess> ? WriteResult<Id> : never : never };
143
+ type WriteManyItem<Def$1 extends WritableVariableDef = WritableVariableDef> = readonly [def: Def$1, value: ValueOfVariableDef<Def$1>];
144
+ type AnyWriteManyRecord = Record<string, readonly [WritableVariableDef, unknown]>;
145
+ type WriteManyInput<Items extends AnyWriteManyRecord> = { readonly [Key in keyof Items]: Items[Key] extends readonly [infer Def extends WritableVariableDef, unknown] ? readonly [def: Def, value: ValueOfVariableDef<Def>] : never };
146
+ type VariableMetadata = {
147
+ readonly nodeId: NodeIdString;
148
+ readonly declaredDataType: OpcuaNodeIdInfo;
149
+ readonly builtInDataType: string;
150
+ readonly valueRank: number;
151
+ readonly arrayDimensions?: ReadonlyArray<number>;
152
+ readonly accessLevel: number;
153
+ readonly userAccessLevel?: number;
154
+ readonly access: {
155
+ readonly readable: boolean;
156
+ readonly writable: boolean;
157
+ readonly userReadable: boolean;
158
+ readonly userWritable: boolean;
159
+ };
160
+ readonly unsafeRaw: {
161
+ readonly declaredDataType: NodeId;
162
+ readonly builtInDataType: DataType;
163
+ };
164
+ };
165
+ declare const makeVariableDef: <const Id$1 extends string, C extends OpcuaCodec<unknown> = OpcuaCodec<OpcuaDynamicValue>, const Access extends VariableAccess = "read">(options: {
166
+ readonly nodeId: Id$1;
167
+ readonly codec?: C;
168
+ readonly access?: Access;
169
+ readonly includeRaw?: boolean;
170
+ }) => VariableDef<Id$1, CodecType<C>, Access>;
171
+ declare const make: <const Id$1 extends string, C extends OpcuaCodec<unknown> = OpcuaCodec<OpcuaDynamicValue>, const Access extends VariableAccess = "read">(options: {
172
+ readonly nodeId: Id$1;
173
+ readonly codec?: C;
174
+ readonly access?: Access;
175
+ readonly includeRaw?: boolean;
176
+ }) => VariableDef<Id$1, CodecType<C>, Access>;
177
+ //#endregion
178
+ export { AccessOfVariableDef, AnyReadResult, type AnySchema, AnyVariableDef, AnyWriteManyRecord, type CodecType, ExpandedNodeIdString, NodeIdOfVariableDef, NodeIdString, type OpcuaCodec, OpcuaDynamicValue, OpcuaExpandedNodeIdInfo, OpcuaLocalizedTextInfo, OpcuaNodeIdInfo, OpcuaQualifiedNameInfo, OpcuaStatusInfo, OpcuaVariable_d_exports, OpcuaVariantInfo, ReadManyResult, ReadResult, ReadableVariableDef, ValueOfVariableDef, VariableAccess, VariableCapability, VariableDef, VariableMetadata, WritableVariableDef, WriteManyInput, WriteManyItem, WriteManyResult, WriteResult, make, makeVariableDef };
179
+ //# sourceMappingURL=OpcuaVariable.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpcuaVariable.d.mts","names":[],"sources":["../src/OpcuaVariable.ts"],"sourcesContent":[],"mappings":";;;;;;;KAWY,YAAA;KACA,oBAAA;KACA,kBAAA;KAEA,eAAA;;;;;;;KAQA,gBAAA;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"}
@@ -0,0 +1,15 @@
1
+ import { dynamic } from "./internal/values/codec.mjs";
2
+
3
+ //#region src/OpcuaVariable.ts
4
+ const makeVariableDef = (options) => ({
5
+ _tag: "VariableDef",
6
+ nodeId: options.nodeId,
7
+ codec: options.codec ?? dynamic(),
8
+ access: options.access ?? "read",
9
+ includeRaw: options.includeRaw
10
+ });
11
+ const make = makeVariableDef;
12
+
13
+ //#endregion
14
+ export { make, makeVariableDef };
15
+ //# sourceMappingURL=OpcuaVariable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpcuaVariable.mjs","names":[],"sources":["../src/OpcuaVariable.ts"],"sourcesContent":["import { DataType, NodeId, type DataValue, type Variant } from \"node-opcua\";\n\nimport {\n dynamic,\n type AnySchema,\n type CodecType,\n type OpcuaCodec,\n} from \"./internal/values/codec.js\";\n\nexport type { AnySchema, CodecType, OpcuaCodec };\n\nexport type NodeIdString = string;\nexport type ExpandedNodeIdString = string;\nexport type VariableCapability = \"read\" | \"write\";\n\nexport type OpcuaStatusInfo = {\n readonly text: string;\n readonly code: number;\n readonly isGood: boolean;\n readonly isUncertain: boolean;\n readonly isBad: boolean;\n};\n\nexport type OpcuaVariantInfo = {\n readonly dataType: string;\n readonly arrayType: \"Scalar\" | \"Array\" | \"Matrix\";\n readonly valueRank?: number;\n readonly arrayDimensions?: ReadonlyArray<number>;\n};\n\nexport type OpcuaDynamicValue =\n | null\n | boolean\n | number\n | string\n | ReadonlyArray<OpcuaDynamicValue>\n | { readonly _tag: \"DateTime\"; readonly iso: string }\n | { readonly _tag: \"ByteString\"; readonly base64: string }\n | { readonly _tag: \"Int64\"; readonly text: string }\n | { readonly _tag: \"UInt64\"; readonly text: string }\n | {\n readonly _tag: \"LocalizedText\";\n readonly text: string;\n readonly locale?: string;\n }\n | {\n readonly _tag: \"QualifiedName\";\n readonly namespaceIndex: number;\n readonly name: string;\n readonly text: string;\n }\n | {\n readonly _tag: \"NodeId\";\n readonly text: string;\n readonly namespace: number;\n readonly identifierType: string;\n readonly value: unknown;\n }\n | {\n readonly _tag: \"ExtensionObject\";\n readonly typeName?: string;\n readonly value: Readonly<Record<string, OpcuaDynamicValue>>;\n }\n | {\n readonly _tag: \"Object\";\n readonly typeName?: string;\n readonly value: Readonly<Record<string, OpcuaDynamicValue>>;\n };\n\nexport type OpcuaNodeIdInfo = {\n readonly text: string;\n readonly namespace: number;\n readonly namespaceUri?: string;\n readonly identifierType: string;\n readonly value: unknown;\n};\n\nexport type OpcuaExpandedNodeIdInfo = OpcuaNodeIdInfo & {\n readonly serverIndex?: number;\n readonly isLocal: boolean;\n readonly isRemote: boolean;\n};\n\nexport type OpcuaQualifiedNameInfo = {\n readonly namespaceIndex: number;\n readonly name: string;\n readonly text: string;\n};\n\nexport type OpcuaLocalizedTextInfo = {\n readonly text: string;\n readonly locale?: string;\n};\n\nexport type VariableAccess = \"read\" | \"write\" | \"readWrite\";\n\nexport type VariableDef<\n Id extends string = string,\n A = OpcuaDynamicValue,\n Access extends VariableAccess = \"read\",\n> = {\n readonly _tag: \"VariableDef\";\n readonly nodeId: Id;\n readonly codec: OpcuaCodec<A>;\n readonly access: Access;\n readonly includeRaw?: boolean;\n};\n\nexport type AnyVariableDef = VariableDef<string, unknown, VariableAccess>;\nexport type ReadableVariableDef =\n | VariableDef<string, unknown, \"read\">\n | VariableDef<string, unknown, \"readWrite\">;\nexport type WritableVariableDef =\n | VariableDef<string, unknown, \"write\">\n | VariableDef<string, unknown, \"readWrite\">;\n\nexport type ValueOfVariableDef<Def> =\n Def extends VariableDef<string, infer A, VariableAccess> ? A : never;\n\nexport type AccessOfVariableDef<Def> =\n Def extends VariableDef<string, unknown, infer Access> ? Access : never;\n\nexport type NodeIdOfVariableDef<Def> =\n Def extends VariableDef<infer Id, unknown, VariableAccess> ? Id : never;\n\nexport type ReadResult<A, Id extends string = string> =\n | {\n readonly _tag: \"Value\";\n readonly nodeId: Id;\n readonly value: A;\n readonly status: OpcuaStatusInfo;\n readonly sourceTimestamp?: string;\n readonly serverTimestamp?: string;\n readonly variant?: OpcuaVariantInfo;\n readonly unsafeRaw?: {\n readonly dataValue: DataValue;\n readonly variant?: Variant;\n };\n }\n | {\n readonly _tag: \"NonGoodStatus\";\n readonly nodeId: Id;\n readonly status: OpcuaStatusInfo;\n readonly sourceTimestamp?: string;\n readonly serverTimestamp?: string;\n readonly variant?: OpcuaVariantInfo;\n readonly unsafeRaw?: {\n readonly dataValue: DataValue;\n readonly variant?: Variant;\n };\n }\n | {\n readonly _tag: \"DecodeError\";\n readonly nodeId: Id;\n readonly error: unknown;\n readonly status: OpcuaStatusInfo;\n readonly sourceTimestamp?: string;\n readonly serverTimestamp?: string;\n readonly variant?: OpcuaVariantInfo;\n readonly unsafeRaw?: {\n readonly dataValue: DataValue;\n readonly variant?: Variant;\n };\n };\n\nexport type AnyReadResult =\n | ReadResult<unknown, string>\n | ReadResult<OpcuaDynamicValue, string>;\n\nexport type ReadManyResult<Items> = {\n readonly [Key in keyof Items]: Items[Key] extends VariableDef<\n infer Id,\n infer A,\n \"read\" | \"readWrite\"\n >\n ? ReadResult<A, Id>\n : never;\n};\n\nexport type WriteResult<Id extends string = string> =\n | {\n readonly _tag: \"Written\";\n readonly nodeId: Id;\n readonly status: OpcuaStatusInfo;\n }\n | {\n readonly _tag: \"NonGoodStatus\";\n readonly nodeId: Id;\n readonly status: OpcuaStatusInfo;\n };\n\nexport type WriteManyResult<Items> = {\n readonly [Key in keyof Items]: Items[Key] extends readonly [\n infer Def extends WritableVariableDef,\n unknown,\n ]\n ? Def extends VariableDef<infer Id, unknown, VariableAccess>\n ? WriteResult<Id>\n : never\n : never;\n};\n\nexport type WriteManyItem<\n Def extends WritableVariableDef = WritableVariableDef,\n> = readonly [def: Def, value: ValueOfVariableDef<Def>];\n\nexport type AnyWriteManyRecord = Record<\n string,\n readonly [WritableVariableDef, unknown]\n>;\n\nexport type WriteManyInput<Items extends AnyWriteManyRecord> = {\n readonly [Key in keyof Items]: Items[Key] extends readonly [\n infer Def extends WritableVariableDef,\n unknown,\n ]\n ? readonly [def: Def, value: ValueOfVariableDef<Def>]\n : never;\n};\n\nexport type VariableMetadata = {\n readonly nodeId: NodeIdString;\n readonly declaredDataType: OpcuaNodeIdInfo;\n readonly builtInDataType: string;\n readonly valueRank: number;\n readonly arrayDimensions?: ReadonlyArray<number>;\n readonly accessLevel: number;\n readonly userAccessLevel?: number;\n readonly access: {\n readonly readable: boolean;\n readonly writable: boolean;\n readonly userReadable: boolean;\n readonly userWritable: boolean;\n };\n readonly unsafeRaw: {\n readonly declaredDataType: NodeId;\n readonly builtInDataType: DataType;\n };\n};\n\nexport const makeVariableDef = <\n const Id extends string,\n C extends OpcuaCodec<unknown> = OpcuaCodec<OpcuaDynamicValue>,\n const Access extends VariableAccess = \"read\",\n>(options: {\n readonly nodeId: Id;\n readonly codec?: C;\n readonly access?: Access;\n readonly includeRaw?: boolean;\n}): VariableDef<Id, CodecType<C>, Access> => ({\n _tag: \"VariableDef\",\n nodeId: options.nodeId,\n codec: (options.codec ?? dynamic()) as unknown as OpcuaCodec<CodecType<C>>,\n access: (options.access ?? \"read\") as Access,\n includeRaw: options.includeRaw,\n});\n\nexport const make = makeVariableDef;\n"],"mappings":";;;AAgPA,MAAa,mBAIX,aAK4C;CAC5C,MAAM;CACN,QAAQ,QAAQ;CAChB,OAAQ,QAAQ,SAAS,SAAS;CAClC,QAAS,QAAQ,UAAU;CAC3B,YAAY,QAAQ;CACrB;AAED,MAAa,OAAO"}
@@ -0,0 +1,18 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (all, symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __export };
@@ -0,0 +1,8 @@
1
+ import { OpcuaVariable_d_exports, ReadResult } from "./OpcuaVariable.mjs";
2
+ import { BufferPolicy, MonitorDeadband, MonitorFilter, OpcuaSubscription_d_exports } from "./OpcuaSubscription.mjs";
3
+ import { OpcuaError_d_exports } from "./OpcuaError.mjs";
4
+ import { OpcuaMethod_d_exports } from "./OpcuaMethod.mjs";
5
+ import { Opcua_d_exports } from "./Opcua.mjs";
6
+ import { OpcuaClient_d_exports } from "./OpcuaClient.mjs";
7
+ import { OpcuaSession_d_exports, SessionService } from "./OpcuaSession.mjs";
8
+ export { BufferPolicy, MonitorDeadband, MonitorFilter, Opcua_d_exports as Opcua, OpcuaClient_d_exports as OpcuaClient, OpcuaError_d_exports as OpcuaError, type OpcuaMethod_d_exports as OpcuaMethod, OpcuaSession_d_exports as OpcuaSession, type SessionService as OpcuaSessionService, type OpcuaSubscription_d_exports as OpcuaSubscription, type OpcuaVariable_d_exports as OpcuaVariable, type ReadResult };
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import { OpcuaError_exports } from "./OpcuaError.mjs";
2
+ import { BufferPolicy, MonitorDeadband, MonitorFilter } from "./OpcuaSubscription.mjs";
3
+ import { Opcua_exports } from "./Opcua.mjs";
4
+ import { OpcuaClient_exports } from "./OpcuaClient.mjs";
5
+ import { OpcuaSession_exports } from "./OpcuaSession.mjs";
6
+
7
+ export { BufferPolicy, MonitorDeadband, MonitorFilter, Opcua_exports as Opcua, OpcuaClient_exports as OpcuaClient, OpcuaError_exports as OpcuaError, OpcuaSession_exports as OpcuaSession };
@@ -0,0 +1,11 @@
1
+ import { Effect } from "effect";
2
+
3
+ //#region src/internal/batch/chunk.d.ts
4
+ type BatchOptions = {
5
+ readonly maxItemsPerRequest?: number;
6
+ readonly maxConcurrentRequests?: number;
7
+ };
8
+ declare const runChunked: <A, B, E, R>(items: ReadonlyArray<A>, options: BatchOptions | undefined, f: (chunk: ReadonlyArray<A>, chunkIndex: number) => Effect.Effect<ReadonlyArray<B>, E, R>) => Effect.Effect<ReadonlyArray<B>, E, R>;
9
+ //#endregion
10
+ export { BatchOptions, runChunked };
11
+ //# sourceMappingURL=chunk.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.d.mts","names":[],"sources":["../../../src/internal/batch/chunk.ts"],"sourcesContent":[],"mappings":";;;KAKY,YAAA;;EAAA,SAAA,qBAAY,CAAA,EAAA,MAAA;AAQxB,CAAA;AACuB,cADV,UACU,EAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,KAAA,EAAd,aAAc,CAAA,CAAA,CAAA,EAAA,OAAA,EACZ,YADY,GAAA,SAAA,EAAA,CAAA,EAAA,CAAA,KAAA,EAGZ,aAHY,CAGE,CAHF,CAAA,EAAA,UAAA,EAAA,MAAA,EAAA,GAKhB,MAAA,CAAO,MALS,CAKF,aALE,CAKY,CALZ,CAAA,EAKgB,CALhB,EAKmB,CALnB,CAAA,EAAA,GAMpB,MAAA,CAAO,MANa,CAMN,aANM,CAMQ,CANR,CAAA,EAMY,CANZ,EAMe,CANf,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { chunksOf } from "../common/collections.mjs";
2
+ import { positiveIntegerOrDefault } from "../common/options.mjs";
3
+ import { Effect } from "effect";
4
+
5
+ //#region src/internal/batch/chunk.ts
6
+ const DEFAULT_MAX_ITEMS_PER_REQUEST = 250;
7
+ const DEFAULT_MAX_CONCURRENT_REQUESTS = 1;
8
+ const runChunked = (items, options, f) => Effect.gen(function* () {
9
+ const normalized = normalizeBatchOptions(options);
10
+ const chunks = chunksOf(items, normalized.maxItemsPerRequest);
11
+ const chunkResults = yield* Effect.forEach(chunks, f, { concurrency: normalized.maxConcurrentRequests });
12
+ const results = [];
13
+ for (const chunkResult of chunkResults) results.push(...chunkResult);
14
+ return results;
15
+ });
16
+ const normalizeBatchOptions = (options) => ({
17
+ maxItemsPerRequest: positiveIntegerOrDefault(options?.maxItemsPerRequest, DEFAULT_MAX_ITEMS_PER_REQUEST),
18
+ maxConcurrentRequests: positiveIntegerOrDefault(options?.maxConcurrentRequests, DEFAULT_MAX_CONCURRENT_REQUESTS)
19
+ });
20
+
21
+ //#endregion
22
+ export { runChunked };
23
+ //# sourceMappingURL=chunk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.mjs","names":["results: Array<B>"],"sources":["../../../src/internal/batch/chunk.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport { chunksOf } from \"../common/collections.js\";\nimport { positiveIntegerOrDefault } from \"../common/options.js\";\n\nexport type BatchOptions = {\n readonly maxItemsPerRequest?: number;\n readonly maxConcurrentRequests?: number;\n};\n\nconst DEFAULT_MAX_ITEMS_PER_REQUEST = 250;\nconst DEFAULT_MAX_CONCURRENT_REQUESTS = 1;\n\nexport const runChunked = <A, B, E, R>(\n items: ReadonlyArray<A>,\n options: BatchOptions | undefined,\n f: (\n chunk: ReadonlyArray<A>,\n chunkIndex: number,\n ) => Effect.Effect<ReadonlyArray<B>, E, R>,\n): Effect.Effect<ReadonlyArray<B>, E, R> =>\n Effect.gen(function* () {\n const normalized = normalizeBatchOptions(options);\n const chunks = chunksOf(items, normalized.maxItemsPerRequest);\n const chunkResults = yield* Effect.forEach(chunks, f, {\n concurrency: normalized.maxConcurrentRequests,\n });\n const results: Array<B> = [];\n for (const chunkResult of chunkResults) {\n results.push(...chunkResult);\n }\n return results;\n });\n\nconst normalizeBatchOptions = (options: BatchOptions | undefined) => ({\n maxItemsPerRequest: positiveIntegerOrDefault(\n options?.maxItemsPerRequest,\n DEFAULT_MAX_ITEMS_PER_REQUEST,\n ),\n maxConcurrentRequests: positiveIntegerOrDefault(\n options?.maxConcurrentRequests,\n DEFAULT_MAX_CONCURRENT_REQUESTS,\n ),\n});\n"],"mappings":";;;;;AAUA,MAAM,gCAAgC;AACtC,MAAM,kCAAkC;AAExC,MAAa,cACX,OACA,SACA,MAKA,OAAO,IAAI,aAAa;CACtB,MAAM,aAAa,sBAAsB,QAAQ;CACjD,MAAM,SAAS,SAAS,OAAO,WAAW,mBAAmB;CAC7D,MAAM,eAAe,OAAO,OAAO,QAAQ,QAAQ,GAAG,EACpD,aAAa,WAAW,uBACzB,CAAC;CACF,MAAMA,UAAoB,EAAE;AAC5B,MAAK,MAAM,eAAe,aACxB,SAAQ,KAAK,GAAG,YAAY;AAE9B,QAAO;EACP;AAEJ,MAAM,yBAAyB,aAAuC;CACpE,oBAAoB,yBAClB,SAAS,oBACT,8BACD;CACD,uBAAuB,yBACrB,SAAS,uBACT,gCACD;CACF"}
@@ -0,0 +1,50 @@
1
+ import { OpcuaError } from "../../OpcuaError.mjs";
2
+ import { Effect } from "effect";
3
+
4
+ //#region src/internal/batch/keyed.d.ts
5
+ type KeyedEntry<Key extends string, Normalized> = {
6
+ readonly key: Key;
7
+ readonly index: number;
8
+ readonly normalized: Normalized;
9
+ };
10
+ type KeyedBatchSpec<Input, Options, Defaults, Normalized, Ready, EffectiveOptions, RawResult, PublicResult> = {
11
+ readonly operation: string;
12
+ readonly normalizeOptions: (options: Options, defaults: Defaults | undefined) => Effect.Effect<EffectiveOptions, OpcuaError>;
13
+ readonly normalizeItem: (key: string, input: Input, options: EffectiveOptions) => Effect.Effect<Normalized, OpcuaError>;
14
+ readonly validateItems?: (items: ReadonlyArray<KeyedEntry<string, Normalized>>, options: EffectiveOptions) => Effect.Effect<void, OpcuaError>;
15
+ readonly preflight?: (items: ReadonlyArray<KeyedEntry<string, Normalized>>, options: EffectiveOptions) => Effect.Effect<ReadonlyArray<KeyedEntry<string, Ready>>, OpcuaError>;
16
+ readonly execute: (items: ReadonlyArray<KeyedEntry<string, Ready>>, options: EffectiveOptions) => Effect.Effect<ReadonlyArray<RawResult>, OpcuaError>;
17
+ readonly toPublicResult: (entry: KeyedEntry<string, Ready>, raw: RawResult) => Effect.Effect<PublicResult, OpcuaError>;
18
+ };
19
+ declare const runKeyedBatchOperation: <Input, Options, Defaults, Normalized, Ready, EffectiveOptions, RawResult, PublicResult>(items: Readonly<Record<string, Input>>, options: Options, defaults: Defaults | undefined, spec: KeyedBatchSpec<Input, Options, Defaults, Normalized, Ready, EffectiveOptions, RawResult, PublicResult>) => Effect.Effect<Record<string, PublicResult>, OpcuaError>;
20
+ declare const normalizeKeyedRecord: <Input, Normalized>(operation: string, items: unknown, normalizeItem: (key: string, input: Input, index: number) => Effect.Effect<Normalized, OpcuaError>) => Effect.Effect<ReadonlyArray<KeyedEntry<string, Normalized>>, OpcuaError>;
21
+ declare const rekeyOrderedResults: <Ready, RawResult, PublicResult>(operation: string, entries: ReadonlyArray<KeyedEntry<string, Ready>>, rawResults: ReadonlyArray<RawResult>, toPublicResult: (entry: KeyedEntry<string, Ready>, raw: RawResult) => Effect.Effect<PublicResult, OpcuaError>) => Effect.Effect<Record<string, PublicResult>, OpcuaError>;
22
+ declare const validateUniqueTargets: <Normalized>(entries: ReadonlyArray<KeyedEntry<string, Normalized>>, options: {
23
+ readonly operation: string;
24
+ readonly target: (entry: KeyedEntry<string, Normalized>) => string;
25
+ readonly duplicateCause?: (target: string, previousKey: string) => string;
26
+ readonly errorContext?: (entry: KeyedEntry<string, Normalized>, target: string) => {
27
+ readonly nodeId?: string;
28
+ readonly objectId?: string;
29
+ readonly methodId?: string;
30
+ };
31
+ }) => Effect.Effect<void, OpcuaError>;
32
+ declare const validateOptionsShape: (operation: string, value: unknown, allowedKeys: ReadonlyArray<string>) => Effect.Effect<void, OpcuaError>;
33
+ declare const normalizeServiceOptions: <Key extends string>({
34
+ serviceLimits,
35
+ defaults,
36
+ serviceOperation,
37
+ defaultsOperation,
38
+ allowedKeys,
39
+ fallback
40
+ }: {
41
+ readonly serviceLimits: unknown;
42
+ readonly defaults: unknown;
43
+ readonly serviceOperation: string;
44
+ readonly defaultsOperation: string;
45
+ readonly allowedKeys: ReadonlyArray<Key>;
46
+ readonly fallback: Record<Key, number>;
47
+ }) => Effect.Effect<Record<Key, number>, OpcuaError>;
48
+ //#endregion
49
+ export { KeyedBatchSpec, KeyedEntry, normalizeKeyedRecord, normalizeServiceOptions, rekeyOrderedResults, runKeyedBatchOperation, validateOptionsShape, validateUniqueTargets };
50
+ //# sourceMappingURL=keyed.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed.d.mts","names":[],"sources":["../../../src/internal/batch/keyed.ts"],"sourcesContent":[],"mappings":";;;;KAMY;gBACI;EADJ,SAAA,KAAU,EAAA,MAAA;EAMV,SAAA,UAAc,EAHH,UAGG;CAYb;AACC,KAbF,cAaE,CAAA,KAAA,EAAA,OAAA,EAAA,QAAA,EAAA,UAAA,EAAA,KAAA,EAAA,gBAAA,EAAA,SAAA,EAAA,YAAA,CAAA,GAAA;EACO,SAAA,SAAA,EAAA,MAAA;EAAkB,SAAA,gBAAA,EAAA,CAAA,OAAA,EAF1B,OAE0B,EAAA,QAAA,EADzB,QACyB,GAAA,SAAA,EAAA,GAAhC,MAAA,CAAO,MAAyB,CAAlB,gBAAkB,EAAA,UAAA,CAAA;EAAhC,SAAO,aAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,KAAA,EAGH,KAHG,EAAA,OAAA,EAID,gBAJC,EAAA,GAKP,MAAA,CAAO,MALA,CAKO,UALP,EAKmB,UALnB,CAAA;EAGH,SAAA,aAAA,CAAA,EAAA,CAAA,KAAA,EAIA,aAJA,CAIc,UAJd,CAAA,MAAA,EAIiC,UAJjC,CAAA,CAAA,EAAA,OAAA,EAKE,gBALF,EAAA,GAMJ,MAAA,CAAO,MANH,CAAA,IAAA,EAMgB,UANhB,CAAA;EACE,SAAA,SAAA,CAAA,EAAA,CAAA,KAAA,EAOF,aAPE,CAOY,UAPZ,CAAA,MAAA,EAO+B,UAP/B,CAAA,CAAA,EAAA,OAAA,EAQA,gBARA,EAAA,GASN,MAAA,CAAO,MATD,CASQ,aATR,CASsB,UATtB,CAAA,MAAA,EASyC,KATzC,CAAA,CAAA,EASkD,UATlD,CAAA;EACQ,SAAA,OAAA,EAAA,CAAA,KAAA,EAUV,aAVU,CAUI,UAVJ,CAAA,M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EAgIE,UAhIF,CAAA;AAA0C,cAuJlD,oBAvJkD,EAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAAA,OAAA,EAAA,WAAA,EA0JhD,aA1JgD,CAAA,MAAA,CAAA,EAAA,GA2J5D,MAAA,CAAO,MA3JqD,CAAA,IAAA,EA2JxC,UA3JwC,CAAA;AAAxD,cAiKM,uBAjKC,EAAA,CAAA,YAAA,MAAA,CAAA,CAAA;EAAA,aAAA;EAAA,QAAA;EAAA,gBAAA;EAAA,iBAAA;EAAA,WAAA;EAAA;CAAA,EAAA;EAE8B,SAAA,aAAA,EAAA,OAAA;EAAnB,SAAA,QAAA,EAAA,OAAA;EAAd,SAAA,gBAAA,EAAA,MAAA;EACE,SAAA,iBAAA,EAAA,MAAA;EACsB,SAAA,WAAA,EAyKX,aAzKW,CAyKG,GAzKH,CAAA;EAAd,SAAA,QAAA,EA0KA,MA1KA,CA0KO,GA1KP,EAAA,MAAA,CAAA;CAA0B,EAAA,GA2K3C,MAAA,CAAO,MA3KoC,CA2K7B,MA3K6B,CA2KtB,GA3KsB,EAAA,MAAA,CAAA,EA2KR,UA3KQ,CAAA"}
@@ -0,0 +1,112 @@
1
+ import { isPlainRecord } from "../common/predicates.mjs";
2
+ import { configurationError } from "../../OpcuaError.mjs";
3
+ import { positiveIntegerOption, unknownKeys } from "../common/options.mjs";
4
+ import { Effect } from "effect";
5
+
6
+ //#region src/internal/batch/keyed.ts
7
+ const runKeyedBatchOperation = (items, options, defaults, spec) => Effect.gen(function* () {
8
+ const effectiveOptions = yield* spec.normalizeOptions(options, defaults);
9
+ const entries = yield* normalizeKeyedRecord(spec.operation, items, (key, input) => spec.normalizeItem(key, input, effectiveOptions));
10
+ if (spec.validateItems) yield* spec.validateItems(entries, effectiveOptions);
11
+ if (entries.length === 0) return {};
12
+ const readyEntries = spec.preflight ? yield* spec.preflight(entries, effectiveOptions) : entries;
13
+ const rawResults = yield* spec.execute(readyEntries, effectiveOptions);
14
+ return yield* rekeyOrderedResults(spec.operation, readyEntries, rawResults, spec.toPublicResult);
15
+ });
16
+ const normalizeKeyedRecord = (operation, items, normalizeItem) => Effect.suspend(() => {
17
+ const dictionaryError = keyedDictionaryError(operation, items);
18
+ if (dictionaryError) return Effect.fail(dictionaryError);
19
+ const keyedItems = Object.entries(items).map(([key, input], index) => ({
20
+ key,
21
+ input,
22
+ index
23
+ }));
24
+ return Effect.forEach(keyedItems, ({ key, input, index }) => Effect.map(normalizeItem(key, input, index), (normalized) => ({
25
+ key,
26
+ index,
27
+ normalized
28
+ })));
29
+ });
30
+ const rekeyOrderedResults = (operation, entries, rawResults, toPublicResult) => Effect.gen(function* () {
31
+ if (rawResults.length !== entries.length) return yield* Effect.fail(configurationError({
32
+ operation,
33
+ cause: `expected ${entries.length} ordered results, got ${rawResults.length}`
34
+ }));
35
+ const out = {};
36
+ for (let index = 0; index < entries.length; index++) {
37
+ const entry = entries[index];
38
+ out[entry.key] = yield* toPublicResult(entry, rawResults[index]);
39
+ }
40
+ return out;
41
+ });
42
+ const validateUniqueTargets = (entries, options) => Effect.suspend(() => {
43
+ const seen = /* @__PURE__ */ new Map();
44
+ for (const entry of entries) {
45
+ const target = options.target(entry);
46
+ const duplicate = seen.get(target);
47
+ if (duplicate !== void 0) return Effect.fail(configurationError({
48
+ operation: options.operation,
49
+ key: entry.key,
50
+ ...options.errorContext?.(entry, target),
51
+ cause: options.duplicateCause?.(target, duplicate) ?? `duplicate target also used by ${duplicate}`
52
+ }));
53
+ seen.set(target, entry.key);
54
+ }
55
+ return Effect.void;
56
+ });
57
+ const validateOptionsShape = (operation, value, allowedKeys) => Effect.suspend(() => {
58
+ const error = optionsShapeError(operation, value, allowedKeys);
59
+ return error ? Effect.fail(error) : Effect.void;
60
+ });
61
+ const normalizeServiceOptions = ({ serviceLimits, defaults, serviceOperation, defaultsOperation, allowedKeys, fallback }) => Effect.suspend(() => {
62
+ const defaultsError = serviceOptionsError(defaultsOperation, defaults, allowedKeys);
63
+ if (defaultsError) return Effect.fail(defaultsError);
64
+ const serviceError = serviceOptionsError(serviceOperation, serviceLimits, allowedKeys);
65
+ if (serviceError) return Effect.fail(serviceError);
66
+ const serviceLimitsRecord = serviceLimits;
67
+ const defaultsRecord = defaults;
68
+ const normalized = { ...fallback };
69
+ for (const key of allowedKeys) normalized[key] = serviceLimitsRecord?.[key] ?? defaultsRecord?.[key] ?? fallback[key];
70
+ return Effect.succeed(normalized);
71
+ });
72
+ const keyedDictionaryError = (operation, value) => {
73
+ if (isPlainRecord(value)) return void 0;
74
+ return configurationError({
75
+ operation,
76
+ cause: "items must be a plain keyed record"
77
+ });
78
+ };
79
+ const optionsShapeError = (operation, value, allowedKeys) => {
80
+ if (value === void 0) return void 0;
81
+ if (!isPlainRecord(value)) return configurationError({
82
+ operation,
83
+ cause: "options must be an object"
84
+ });
85
+ const unknown = unknownKeys(value, allowedKeys);
86
+ return unknown.length > 0 ? configurationError({
87
+ operation,
88
+ cause: `unsupported option: ${unknown.join(", ")}`
89
+ }) : void 0;
90
+ };
91
+ const serviceOptionsError = (operation, value, allowedKeys) => {
92
+ if (value === void 0) return void 0;
93
+ if (!isPlainRecord(value)) return configurationError({
94
+ operation,
95
+ cause: "service options must be an object"
96
+ });
97
+ for (const key of unknownKeys(value, allowedKeys)) return configurationError({
98
+ operation,
99
+ cause: `unsupported service option: ${key}`
100
+ });
101
+ for (const key of allowedKeys) {
102
+ const optionValue = value[key];
103
+ if (optionValue !== void 0 && !positiveIntegerOption(optionValue)) return configurationError({
104
+ operation,
105
+ cause: `${key} must be a positive integer`
106
+ });
107
+ }
108
+ };
109
+
110
+ //#endregion
111
+ export { normalizeKeyedRecord, normalizeServiceOptions, rekeyOrderedResults, runKeyedBatchOperation, validateOptionsShape, validateUniqueTargets };
112
+ //# sourceMappingURL=keyed.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed.mjs","names":["out: Record<string, PublicResult>"],"sources":["../../../src/internal/batch/keyed.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport { configurationError, type OpcuaError } from \"../../OpcuaError.js\";\nimport { positiveIntegerOption, unknownKeys } from \"../common/options.js\";\nimport { isPlainRecord } from \"../common/predicates.js\";\n\nexport type KeyedEntry<Key extends string, Normalized> = {\n readonly key: Key;\n readonly index: number;\n readonly normalized: Normalized;\n};\n\nexport type KeyedBatchSpec<\n Input,\n Options,\n Defaults,\n Normalized,\n Ready,\n EffectiveOptions,\n RawResult,\n PublicResult,\n> = {\n readonly operation: string;\n readonly normalizeOptions: (\n options: Options,\n defaults: Defaults | undefined,\n ) => Effect.Effect<EffectiveOptions, OpcuaError>;\n readonly normalizeItem: (\n key: string,\n input: Input,\n options: EffectiveOptions,\n ) => Effect.Effect<Normalized, OpcuaError>;\n readonly validateItems?: (\n items: ReadonlyArray<KeyedEntry<string, Normalized>>,\n options: EffectiveOptions,\n ) => Effect.Effect<void, OpcuaError>;\n readonly preflight?: (\n items: ReadonlyArray<KeyedEntry<string, Normalized>>,\n options: EffectiveOptions,\n ) => Effect.Effect<ReadonlyArray<KeyedEntry<string, Ready>>, OpcuaError>;\n readonly execute: (\n items: ReadonlyArray<KeyedEntry<string, Ready>>,\n options: EffectiveOptions,\n ) => Effect.Effect<ReadonlyArray<RawResult>, OpcuaError>;\n readonly toPublicResult: (\n entry: KeyedEntry<string, Ready>,\n raw: RawResult,\n ) => Effect.Effect<PublicResult, OpcuaError>;\n};\n\nexport const runKeyedBatchOperation = <\n Input,\n Options,\n Defaults,\n Normalized,\n Ready,\n EffectiveOptions,\n RawResult,\n PublicResult,\n>(\n items: Readonly<Record<string, Input>>,\n options: Options,\n defaults: Defaults | undefined,\n spec: KeyedBatchSpec<\n Input,\n Options,\n Defaults,\n Normalized,\n Ready,\n EffectiveOptions,\n RawResult,\n PublicResult\n >,\n): Effect.Effect<Record<string, PublicResult>, OpcuaError> =>\n Effect.gen(function* () {\n const effectiveOptions = yield* spec.normalizeOptions(options, defaults);\n const entries = yield* normalizeKeyedRecord<Input, Normalized>(\n spec.operation,\n items,\n (key, input) => spec.normalizeItem(key, input, effectiveOptions),\n );\n\n if (spec.validateItems) {\n yield* spec.validateItems(entries, effectiveOptions);\n }\n\n if (entries.length === 0) return {};\n\n const readyEntries = spec.preflight\n ? yield* spec.preflight(entries, effectiveOptions)\n : (entries as unknown as ReadonlyArray<KeyedEntry<string, Ready>>);\n const rawResults = yield* spec.execute(readyEntries, effectiveOptions);\n return yield* rekeyOrderedResults(\n spec.operation,\n readyEntries,\n rawResults,\n spec.toPublicResult,\n );\n });\n\nexport const normalizeKeyedRecord = <Input, Normalized>(\n operation: string,\n items: unknown,\n normalizeItem: (\n key: string,\n input: Input,\n index: number,\n ) => Effect.Effect<Normalized, OpcuaError>,\n): Effect.Effect<ReadonlyArray<KeyedEntry<string, Normalized>>, OpcuaError> =>\n Effect.suspend(() => {\n const dictionaryError = keyedDictionaryError(operation, items);\n if (dictionaryError) return Effect.fail(dictionaryError);\n\n const keyedItems = Object.entries(items as Record<string, Input>).map(\n ([key, input], index) => ({ key, input, index }),\n );\n return Effect.forEach(keyedItems, ({ key, input, index }) =>\n Effect.map(normalizeItem(key, input, index), (normalized) => ({\n key,\n index,\n normalized,\n })),\n );\n });\n\nexport const rekeyOrderedResults = <Ready, RawResult, PublicResult>(\n operation: string,\n entries: ReadonlyArray<KeyedEntry<string, Ready>>,\n rawResults: ReadonlyArray<RawResult>,\n toPublicResult: (\n entry: KeyedEntry<string, Ready>,\n raw: RawResult,\n ) => Effect.Effect<PublicResult, OpcuaError>,\n): Effect.Effect<Record<string, PublicResult>, OpcuaError> =>\n Effect.gen(function* () {\n if (rawResults.length !== entries.length) {\n return yield* Effect.fail(\n configurationError({\n operation,\n cause: `expected ${entries.length} ordered results, got ${rawResults.length}`,\n }),\n );\n }\n\n const out: Record<string, PublicResult> = {};\n for (let index = 0; index < entries.length; index++) {\n const entry = entries[index]!;\n out[entry.key] = yield* toPublicResult(entry, rawResults[index]!);\n }\n return out;\n });\n\nexport const validateUniqueTargets = <Normalized>(\n entries: ReadonlyArray<KeyedEntry<string, Normalized>>,\n options: {\n readonly operation: string;\n readonly target: (entry: KeyedEntry<string, Normalized>) => string;\n readonly duplicateCause?: (target: string, previousKey: string) => string;\n readonly errorContext?: (\n entry: KeyedEntry<string, Normalized>,\n target: string,\n ) => {\n readonly nodeId?: string;\n readonly objectId?: string;\n readonly methodId?: string;\n };\n },\n): Effect.Effect<void, OpcuaError> =>\n Effect.suspend(() => {\n const seen = new Map<string, string>();\n for (const entry of entries) {\n const target = options.target(entry);\n const duplicate = seen.get(target);\n if (duplicate !== undefined) {\n return Effect.fail(\n configurationError({\n operation: options.operation,\n key: entry.key,\n ...options.errorContext?.(entry, target),\n cause:\n options.duplicateCause?.(target, duplicate) ??\n `duplicate target also used by ${duplicate}`,\n }),\n );\n }\n seen.set(target, entry.key);\n }\n return Effect.void;\n });\n\nexport const validateOptionsShape = (\n operation: string,\n value: unknown,\n allowedKeys: ReadonlyArray<string>,\n): Effect.Effect<void, OpcuaError> =>\n Effect.suspend(() => {\n const error = optionsShapeError(operation, value, allowedKeys);\n return error ? Effect.fail(error) : Effect.void;\n });\n\nexport const normalizeServiceOptions = <Key extends string>({\n serviceLimits,\n defaults,\n serviceOperation,\n defaultsOperation,\n allowedKeys,\n fallback,\n}: {\n readonly serviceLimits: unknown;\n readonly defaults: unknown;\n readonly serviceOperation: string;\n readonly defaultsOperation: string;\n readonly allowedKeys: ReadonlyArray<Key>;\n readonly fallback: Record<Key, number>;\n}): Effect.Effect<Record<Key, number>, OpcuaError> =>\n Effect.suspend(() => {\n const defaultsError = serviceOptionsError(\n defaultsOperation,\n defaults,\n allowedKeys,\n );\n if (defaultsError) return Effect.fail(defaultsError);\n\n const serviceError = serviceOptionsError(\n serviceOperation,\n serviceLimits,\n allowedKeys,\n );\n if (serviceError) return Effect.fail(serviceError);\n\n const serviceLimitsRecord = serviceLimits as\n | Partial<Record<Key, number>>\n | undefined;\n const defaultsRecord = defaults as Partial<Record<Key, number>> | undefined;\n const normalized = { ...fallback };\n for (const key of allowedKeys) {\n normalized[key] =\n serviceLimitsRecord?.[key] ?? defaultsRecord?.[key] ?? fallback[key];\n }\n return Effect.succeed(normalized);\n });\n\nconst keyedDictionaryError = (operation: string, value: unknown) => {\n if (isPlainRecord(value)) return undefined;\n return configurationError({\n operation,\n cause: \"items must be a plain keyed record\",\n });\n};\n\nconst optionsShapeError = (\n operation: string,\n value: unknown,\n allowedKeys: ReadonlyArray<string>,\n) => {\n if (value === undefined) return undefined;\n if (!isPlainRecord(value)) {\n return configurationError({\n operation,\n cause: \"options must be an object\",\n });\n }\n const unknown = unknownKeys(value, allowedKeys);\n return unknown.length > 0\n ? configurationError({\n operation,\n cause: `unsupported option: ${unknown.join(\", \")}`,\n })\n : undefined;\n};\n\nconst serviceOptionsError = (\n operation: string,\n value: unknown,\n allowedKeys: ReadonlyArray<string>,\n) => {\n if (value === undefined) return undefined;\n if (!isPlainRecord(value)) {\n return configurationError({\n operation,\n cause: \"service options must be an object\",\n });\n }\n for (const key of unknownKeys(value, allowedKeys)) {\n return configurationError({\n operation,\n cause: `unsupported service option: ${key}`,\n });\n }\n for (const key of allowedKeys) {\n const optionValue = value[key];\n if (optionValue !== undefined && !positiveIntegerOption(optionValue)) {\n return configurationError({\n operation,\n cause: `${key} must be a positive integer`,\n });\n }\n }\n return undefined;\n};\n"],"mappings":";;;;;;AAkDA,MAAa,0BAUX,OACA,SACA,UACA,SAWA,OAAO,IAAI,aAAa;CACtB,MAAM,mBAAmB,OAAO,KAAK,iBAAiB,SAAS,SAAS;CACxE,MAAM,UAAU,OAAO,qBACrB,KAAK,WACL,QACC,KAAK,UAAU,KAAK,cAAc,KAAK,OAAO,iBAAiB,CACjE;AAED,KAAI,KAAK,cACP,QAAO,KAAK,cAAc,SAAS,iBAAiB;AAGtD,KAAI,QAAQ,WAAW,EAAG,QAAO,EAAE;CAEnC,MAAM,eAAe,KAAK,YACtB,OAAO,KAAK,UAAU,SAAS,iBAAiB,GAC/C;C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AK,MAAM,OAAO,YAAY,OAAO,YAAY,CAC/C,QAAO,mBAAmB;EACxB;EACA,OAAO,+BAA+B;EACvC,CAAC;AAEJ,MAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,cAAc,MAAM;AAC1B,MAAI,gBAAgB,UAAa,CAAC,sBAAsB,YAAY,CAClE,QAAO,mBAAmB;GACxB;GACA,OAAO,GAAG,IAAI;GACf,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { ReadManyResult, ReadableVariableDef, WritableVariableDef, WriteManyInput, WriteManyResult } from "../../OpcuaVariable.mjs";
2
+ import { makeStructureRuntime } from "../structures/runtime.mjs";
3
+ import { OpcuaError } from "../../OpcuaError.mjs";
4
+ import { AnyMethodDef, CallManyInput, CallManyResult, MethodCallOptions } from "../../OpcuaMethod.mjs";
5
+ import { CallManyOptions, ReadManyOptions, ServiceLimits, ServiceOptions, SessionBatchingOptions, WriteManyOptions } from "../../OpcuaSession.mjs";
6
+ import { makeMetadataService } from "../metadata/service.mjs";
7
+ import { ClientSession } from "node-opcua";
8
+ import { Effect } from "effect";
9
+
10
+ //#region src/internal/batch/operations.d.ts
11
+
12
+ type SessionOperationsState = {
13
+ readonly unsafeRaw: ClientSession;
14
+ readonly metadata: ReturnType<typeof makeMetadataService>;
15
+ readonly structureRuntime: ReturnType<typeof makeStructureRuntime>;
16
+ readonly batching?: SessionBatchingOptions;
17
+ };
18
+ type AnyWriteManyRecord = Record<string, readonly [WritableVariableDef, unknown]>;
19
+ type AnyCallManyRecord = Record<string, readonly [AnyMethodDef, unknown] | readonly [AnyMethodDef, unknown, MethodCallOptions]>;
20
+ declare const readManyWithState: <const Items extends Record<string, ReadableVariableDef>>(state: SessionOperationsState, items: Items, options?: ReadManyOptions) => Effect.Effect<ReadManyResult<Items>, OpcuaError>;
21
+ declare const writeManyWithState: <const Items extends AnyWriteManyRecord>(state: SessionOperationsState, items: Items & WriteManyInput<Items>, options?: WriteManyOptions) => Effect.Effect<WriteManyResult<Items>, OpcuaError>;
22
+ declare const callManyWithState: <const Items extends AnyCallManyRecord>(state: SessionOperationsState, items: Items & CallManyInput<Items>, options?: CallManyOptions) => Effect.Effect<CallManyResult<Items>, OpcuaError>;
23
+ //#endregion
24
+ export { type CallManyOptions, type MethodCallOptions, type ReadManyOptions, type ServiceLimits, type ServiceOptions, type SessionBatchingOptions, SessionOperationsState, type WriteManyOptions, callManyWithState, readManyWithState, writeManyWithState };
25
+ //# sourceMappingURL=operations.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.mts","names":[],"sources":["../../../src/internal/batch/operations.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAwCsB,KADV,sBAAA,GACU;EACiB,SAAA,SAAA,EADjB,aACiB;EAAlB,SAAA,QAAA,EAAA,UAAA,CAAA,OAAkB,mBAAlB,CAAA;EAC0B,SAAA,gBAAA,EAAlB,UAAkB,CAAA,OAAA,oBAAA,CAAA;EAAlB,SAAA,QAAA,CAAA,EACP,sBADO;CACP;KAGjB,kBAAA,GAAqB,MAHkB,CAAA,MAAA,EAAA,SAAA,CAKhC,mBALgC,EAAA,OAAA,CAAA,CAAA;AAC1C,KAOG,iBAAA,GAAoB,MALF,CAAA,MAEX,EAAA,SAAA,CAKE,YAPkB,EAAA,OAAA,CAAA,GAAA,SAAA,CAQlB,YARkB,EAAA,OAAA,EAQiB,iBARjB,CAAA,CAAA;AAK3B,cAyBQ,iBAzBS,EAAA,CAAA,oBA0BA,MA1BA,CAAA,MAAA,EA0Be,mBA1Bf,CAAA,CAAA,CAAA,KAAA,EA4Bb,sBA5Ba,EAAA,KAAA,EA6Bb,KA7Ba,EAAA,OAAA,CAAA,EA8BV,eA9BU,EAAA,GA+BnB,MAAA,CAAO,MA/BY,CA+BL,cA/BK,CA+BwB,KA/BxB,CAAA,EA+BgC,UA/BhC,CAAA;AAER,cAoED,kBApEC,EAAA,CAAA,oBAoEyC,kBApEzC,CAAA,CAAA,KAAA,EAqEL,sBArEK,EAAA,KAAA,E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