@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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ https://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,367 @@
1
+ # @effect-opcua/client
2
+
3
+ Effect-native OPC UA client wrapper for `node-opcua`.
4
+
5
+ This is a first alpha package. The public API is intentionally small and is not
6
+ 1.0-stable yet. Breaking changes are expected when they improve correctness,
7
+ ergonomics, performance, or the package boundary.
8
+
9
+ ## Requirements
10
+
11
+ - Node.js 22 or newer.
12
+ - ESM projects.
13
+ - `effect` v4 beta as a peer dependency.
14
+
15
+ ```sh
16
+ pnpm add @effect-opcua/client effect
17
+ ```
18
+
19
+ ## Public import paths
20
+
21
+ Use only:
22
+
23
+ - `@effect-opcua/client`
24
+ - `@effect-opcua/client/node-opcua`
25
+
26
+ Do not import source-module subpaths such as:
27
+
28
+ - `@effect-opcua/client/Opcua`
29
+ - `@effect-opcua/client/OpcuaClient`
30
+ - `@effect-opcua/client/OpcuaError`
31
+ - `@effect-opcua/client/internal/*`
32
+
33
+ Those paths are intentionally not public.
34
+
35
+ ```ts
36
+ import {
37
+ Opcua,
38
+ OpcuaClient,
39
+ OpcuaError,
40
+ OpcuaSession,
41
+ } from "@effect-opcua/client";
42
+
43
+ import {
44
+ DataType,
45
+ StatusCodes,
46
+ Variant,
47
+ } from "@effect-opcua/client/node-opcua";
48
+ ```
49
+
50
+ The root package is the normal user API. The `node-opcua` subpath is the raw
51
+ escape hatch for OPC UA constants and values that are not wrapped yet.
52
+
53
+ ## Quickstart
54
+
55
+ ```ts
56
+ import { Effect, Layer, Schema } from "effect";
57
+ import { Opcua, OpcuaClient, OpcuaSession } from "@effect-opcua/client";
58
+
59
+ const Temperature = Opcua.variable({
60
+ nodeId: "ns=2;s=Machine.Temperature",
61
+ codec: Opcua.schema(Schema.Number),
62
+ });
63
+
64
+ const Setpoint = Opcua.variable({
65
+ nodeId: "ns=2;s=Machine.Setpoint",
66
+ codec: Opcua.schema(Schema.Number),
67
+ access: "readWrite",
68
+ });
69
+
70
+ const Reset = Opcua.method({
71
+ objectId: "ns=2;s=Machine",
72
+ methodId: "ns=2;s=Machine.Reset",
73
+ input: {
74
+ mode: Opcua.arg({
75
+ name: "Mode",
76
+ codec: Opcua.schema(Schema.Literals(["soft", "hard"])),
77
+ }),
78
+ },
79
+ output: {
80
+ ok: Opcua.arg({
81
+ name: "Ok",
82
+ codec: Opcua.schema(Schema.Boolean),
83
+ }),
84
+ },
85
+ });
86
+
87
+ const program = Effect.gen(function* () {
88
+ const current = yield* OpcuaSession.read(Temperature);
89
+ const written = yield* OpcuaSession.write(Setpoint, 42);
90
+ const reset = yield* OpcuaSession.call(Reset, { mode: "soft" });
91
+
92
+ return { current, written, reset };
93
+ });
94
+
95
+ const MainLayer = OpcuaSession.layer().pipe(
96
+ Layer.provide(
97
+ OpcuaClient.layer({
98
+ endpointUrl: "opc.tcp://localhost:4840",
99
+ clientOptions: { endpointMustExist: false },
100
+ }),
101
+ ),
102
+ );
103
+
104
+ await Effect.runPromise(Effect.scoped(program).pipe(Effect.provide(MainLayer)));
105
+ ```
106
+
107
+ `OpcuaClient.layer` owns the TCP connection. `OpcuaSession.layer` owns the OPC
108
+ UA session. Use `Effect.scoped` so client, session, subscription, and monitor
109
+ finalizers run on exit or interruption.
110
+
111
+ ## Connection Profiles
112
+
113
+ A connection profile is usually just a small layer factory:
114
+
115
+ ```ts
116
+ import { Layer } from "effect";
117
+ import { OpcuaClient, OpcuaSession } from "@effect-opcua/client";
118
+
119
+ export const makeOpcuaLayer = (endpointUrl: string) =>
120
+ OpcuaSession.layer({
121
+ batching: {
122
+ read: { maxNodesPerRead: 250, maxConcurrentRequests: 1 },
123
+ write: { maxNodesPerWrite: 100, maxConcurrentRequests: 1 },
124
+ call: { maxMethodsPerCall: 50, maxConcurrentRequests: 1 },
125
+ },
126
+ }).pipe(
127
+ Layer.provide(
128
+ OpcuaClient.layer({
129
+ endpointUrl,
130
+ clientOptions: { endpointMustExist: false },
131
+ }),
132
+ ),
133
+ );
134
+ ```
135
+
136
+ Pass `userIdentity` to `OpcuaSession.layer(...)` when the server requires
137
+ session authentication. Pass raw `OPCUAClientOptions` through
138
+ `OpcuaClient.layer({ clientOptions })` for node-opcua connection settings.
139
+
140
+ ## Read, Write, And Call
141
+
142
+ Reads, writes, and method calls return OPC UA statuses as data. A good read is a
143
+ `Value`; a non-good server status is a `NonGoodStatus`.
144
+
145
+ ```ts
146
+ const program = Effect.gen(function* () {
147
+ const sample = yield* OpcuaSession.read(Temperature);
148
+
149
+ if (sample._tag === "Value") {
150
+ console.log(sample.value);
151
+ }
152
+
153
+ const written = yield* OpcuaSession.write(Setpoint, 42);
154
+ const reset = yield* OpcuaSession.call(Reset, { mode: "soft" });
155
+
156
+ return { written, reset };
157
+ });
158
+ ```
159
+
160
+ ## Batches
161
+
162
+ Use keyed batches when several nodes or methods should keep typed result keys:
163
+
164
+ ```ts
165
+ const program = Effect.gen(function* () {
166
+ const snapshot = yield* OpcuaSession.readMany(
167
+ {
168
+ temperature: Temperature,
169
+ setpoint: Setpoint,
170
+ },
171
+ { validation: "strict" },
172
+ );
173
+
174
+ const writes = yield* OpcuaSession.writeMany({
175
+ setpoint: [Setpoint, 42],
176
+ });
177
+
178
+ const calls = yield* OpcuaSession.callMany({
179
+ reset: [Reset, { mode: "soft" }],
180
+ });
181
+
182
+ return { snapshot, writes, calls };
183
+ });
184
+ ```
185
+
186
+ Per-call service options can override the batching defaults supplied to
187
+ `OpcuaSession.layer(...)`.
188
+
189
+ ## Browse
190
+
191
+ ```ts
192
+ import { makeNodeClassMask } from "@effect-opcua/client/node-opcua";
193
+
194
+ const program = Effect.gen(function* () {
195
+ const children = yield* OpcuaSession.browseChildren("ns=2;s=Machine", {
196
+ nodeClassMask: makeNodeClassMask("Variable"),
197
+ });
198
+
199
+ if (children._tag === "Browsed") {
200
+ for (const reference of children.references) {
201
+ console.log(reference.nodeId, reference.browseName);
202
+ }
203
+ }
204
+
205
+ return children;
206
+ });
207
+ ```
208
+
209
+ Use `OpcuaSession.browse`, `OpcuaSession.browseNext`, and
210
+ `OpcuaSession.releaseBrowseContinuation` directly when you need explicit
211
+ pagination control. `includeRaw: true` opts into raw node-opcua browse values.
212
+
213
+ ## Inspect nodes
214
+
215
+ `OpcuaSession.inspectNode` reads node metadata and, only when requested, the
216
+ current value and the data type definition:
217
+
218
+ ```ts
219
+ const program = Effect.gen(function* () {
220
+ // Metadata only — safe for address-space navigation.
221
+ const node = yield* OpcuaSession.inspectNode("ns=2;s=Machine.State");
222
+
223
+ // Opt into the expensive parts on demand.
224
+ const details = yield* OpcuaSession.inspectNode("ns=2;s=Machine.State", {
225
+ value: true,
226
+ dataTypeDefinition: true,
227
+ });
228
+
229
+ return { node, details };
230
+ });
231
+ ```
232
+
233
+ Keep `value` off while browsing: reading the value of a custom-structure
234
+ (`ExtensionObject`) variable forces node-opcua to populate its session-wide
235
+ data type manager on first use, which can take many seconds on large or slow
236
+ servers. With `value: true`, an unreadable node yields
237
+ `{ _tag: "NotReadable" }` and a failed read yields `{ _tag: "ReadFailed" }`
238
+ instead of failing the whole inspection.
239
+
240
+ ## Monitoring
241
+
242
+ Subscriptions and monitors are scoped resources. Closing or interrupting the
243
+ scope terminates created monitored item groups, shuts down client queues, and
244
+ removes listeners.
245
+
246
+ ```ts
247
+ import { Duration, Effect, Stream } from "effect";
248
+ import { Opcua, OpcuaSession } from "@effect-opcua/client";
249
+
250
+ const program = Effect.gen(function* () {
251
+ const subscription = yield* OpcuaSession.makeSubscription({
252
+ publishingInterval: Duration.millis(100),
253
+ maxNotificationsPerPublish: 0,
254
+ priority: 0,
255
+ });
256
+
257
+ const monitor = yield* subscription.monitor(
258
+ { temperature: Temperature },
259
+ {
260
+ startup: "strict",
261
+ validation: "strict",
262
+ samplingInterval: Duration.millis(250),
263
+ queueSize: 1,
264
+ discardOldest: true,
265
+ filter: Opcua.MonitorFilter.statusValue(),
266
+ timestamps: "source",
267
+ clientBuffer: Opcua.BufferPolicy.latest(),
268
+ },
269
+ );
270
+
271
+ yield* monitor.samples.pipe(
272
+ Stream.runForEach((sample) =>
273
+ Effect.sync(() => {
274
+ console.log(sample.key, sample._tag);
275
+ }),
276
+ ),
277
+ );
278
+ });
279
+ ```
280
+
281
+ Use `startup: "strict"` when all requested items must be active. Use
282
+ `startup: "bestEffort"` when an HMI should start with accepted items and inspect
283
+ rejections through `monitor.startup.failed`. Client buffering uses
284
+ `Opcua.BufferPolicy.sliding(...)`, `dropping(...)`, or `latest()`.
285
+
286
+ ## ExtensionObject Structures
287
+
288
+ Use `Opcua.structure(...)` for scalar OPC UA `ExtensionObject` payloads and
289
+ `Opcua.structureArray(...)` for one-dimensional arrays.
290
+
291
+ ```ts
292
+ const ScanSettings = Opcua.structure({
293
+ name: "ScanSettings",
294
+ dataTypeId: "ns=1;i=3010",
295
+ schema: Schema.Struct({
296
+ duration: Schema.Number,
297
+ cycles: Schema.Number,
298
+ dataAvailable: Schema.Boolean,
299
+ }),
300
+ });
301
+
302
+ const Settings = Opcua.variable({
303
+ nodeId: "ns=1;s=MyMachine.ScanSettings",
304
+ codec: ScanSettings,
305
+ access: "readWrite",
306
+ });
307
+
308
+ const program = Effect.gen(function* () {
309
+ yield* OpcuaSession.write(Settings, {
310
+ duration: 1000,
311
+ cycles: 5,
312
+ dataAvailable: true,
313
+ });
314
+ });
315
+ ```
316
+
317
+ Structure codecs need server metadata for the declared data type. The runtime
318
+ uses `session.extractNamespaceDataType()` and `session.constructExtensionObject`
319
+ through node-opcua. Scalar structures and one-dimensional arrays are supported;
320
+ structure matrices, missing metadata, and opaque dynamic structures are not
321
+ encoded by explicit structure codecs. Use generated structures when possible,
322
+ or `Opcua.dynamic()` while exploring.
323
+
324
+ ## Errors
325
+
326
+ Failed Effects represent local configuration errors, transport/service failures,
327
+ access validation failures, encode/decode failures, lifecycle failures, and
328
+ monitor startup/runtime failures. OPC UA service statuses that complete normally
329
+ are returned as result data.
330
+
331
+ ```ts
332
+ try {
333
+ await Effect.runPromise(
334
+ Effect.scoped(program).pipe(Effect.provide(MainLayer)),
335
+ );
336
+ } catch (error) {
337
+ if (OpcuaError.isOpcuaError(error)) {
338
+ switch (error.reason._tag) {
339
+ case "Connect":
340
+ case "SessionCreate":
341
+ case "Configuration":
342
+ case "Service":
343
+ case "MonitorStartup":
344
+ console.error(error.reason);
345
+ break;
346
+ }
347
+ }
348
+ }
349
+ ```
350
+
351
+ ## Raw Access
352
+
353
+ Prefer the typed API first. Use raw access only for OPC UA capabilities that are
354
+ not wrapped yet:
355
+
356
+ - import constants and constructors from `@effect-opcua/client/node-opcua`;
357
+ - read service `unsafeRaw` fields when you intentionally need raw node-opcua
358
+ objects;
359
+ - pass `includeRaw: true` on operations that document raw result access.
360
+
361
+ ## More Documentation
362
+
363
+ - [Workspace docs](https://github.com/bastikohn/effect-opcua/tree/main/docs)
364
+ - [Getting started](https://github.com/bastikohn/effect-opcua/blob/main/docs/users/getting-started.md)
365
+ - [Core concepts](https://github.com/bastikohn/effect-opcua/blob/main/docs/users/core-concepts.md)
366
+ - [Recipes](https://github.com/bastikohn/effect-opcua/blob/main/docs/users/recipes.md)
367
+ - [Code generation](https://github.com/bastikohn/effect-opcua/blob/main/docs/users/codegen.md)
@@ -0,0 +1,13 @@
1
+ import { NodeIdOfVariableDef, ReadableVariableDef, ValueOfVariableDef, VariableAccess, VariableDef, WritableVariableDef, make as make$1 } from "./OpcuaVariable.mjs";
2
+ import { AnyStructureDef, StructureArrayDef, StructureDef } from "./internal/structures/model.mjs";
3
+ import { BufferPolicy, MonitorDeadband, MonitorFilter } from "./OpcuaSubscription.mjs";
4
+ import { AnySchema, CodecType, OpcuaCodec, SchemaType, dynamic, schema, structure, structureArray } from "./internal/values/codec.mjs";
5
+ import { InputOfMethodDef, MethodArg, MethodArgSelector, MethodDef, OutputOfMethodDef, arg, make } from "./OpcuaMethod.mjs";
6
+
7
+ //#region src/Opcua.d.ts
8
+ declare namespace Opcua_d_exports {
9
+ export { AnySchema, AnyStructureDef, BufferPolicy, CodecType, InputOfMethodDef, MethodArg, MethodArgSelector, MethodDef, MonitorDeadband, MonitorFilter, NodeIdOfVariableDef, OpcuaCodec, OutputOfMethodDef, ReadableVariableDef, SchemaType, StructureArrayDef, StructureDef, ValueOfVariableDef, VariableAccess, VariableDef, WritableVariableDef, arg, dynamic, make as method, schema, structure, structureArray, make$1 as variable };
10
+ }
11
+ //#endregion
12
+ export { type AnySchema, type AnyStructureDef, BufferPolicy, type CodecType, type InputOfMethodDef, type MethodArg, type MethodArgSelector, type MethodDef, MonitorDeadband, MonitorFilter, type NodeIdOfVariableDef, type OpcuaCodec, Opcua_d_exports, type OutputOfMethodDef, type ReadableVariableDef, type SchemaType, type StructureArrayDef, type StructureDef, type ValueOfVariableDef, type VariableAccess, type VariableDef, type WritableVariableDef, arg, dynamic, make as method, schema, structure, structureArray, make$1 as variable };
13
+ //# sourceMappingURL=Opcua.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Opcua.d.mts","names":[],"sources":["../src/Opcua.ts"],"sourcesContent":[],"mappings":""}
package/dist/Opcua.mjs ADDED
@@ -0,0 +1,23 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.mjs";
2
+ import { dynamic, schema, structure, structureArray } from "./internal/values/codec.mjs";
3
+ import { BufferPolicy, MonitorDeadband, MonitorFilter } from "./OpcuaSubscription.mjs";
4
+ import { make as make$1 } from "./OpcuaVariable.mjs";
5
+ import { arg, make } from "./OpcuaMethod.mjs";
6
+
7
+ //#region src/Opcua.ts
8
+ var Opcua_exports = /* @__PURE__ */ __export({
9
+ BufferPolicy: () => BufferPolicy,
10
+ MonitorDeadband: () => MonitorDeadband,
11
+ MonitorFilter: () => MonitorFilter,
12
+ arg: () => arg,
13
+ dynamic: () => dynamic,
14
+ method: () => make,
15
+ schema: () => schema,
16
+ structure: () => structure,
17
+ structureArray: () => structureArray,
18
+ variable: () => make$1
19
+ });
20
+
21
+ //#endregion
22
+ export { BufferPolicy, MonitorDeadband, MonitorFilter, Opcua_exports, arg, dynamic, make as method, schema, structure, structureArray, make$1 as variable };
23
+ //# sourceMappingURL=Opcua.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Opcua.mjs","names":[],"sources":["../src/Opcua.ts"],"sourcesContent":["export {\n dynamic,\n schema,\n structure,\n structureArray,\n type AnySchema,\n type CodecType,\n type OpcuaCodec,\n type SchemaType,\n} from \"./internal/values/codec.js\";\nexport type {\n AnyStructureDef,\n StructureArrayDef,\n StructureDef,\n} from \"./internal/structures/model.js\";\nexport {\n BufferPolicy,\n MonitorDeadband,\n MonitorFilter,\n} from \"./OpcuaSubscription.js\";\nexport {\n make as variable,\n type NodeIdOfVariableDef,\n type ReadableVariableDef,\n type ValueOfVariableDef,\n type VariableAccess,\n type VariableDef,\n type WritableVariableDef,\n} from \"./OpcuaVariable.js\";\nexport {\n arg,\n make as method,\n type InputOfMethodDef,\n type MethodArg,\n type MethodArgSelector,\n type MethodDef,\n type OutputOfMethodDef,\n} from \"./OpcuaMethod.js\";\n"],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { OpcuaClientEvent } from "./internal/events/model.mjs";
2
+ import { OpcuaConnectError } from "./OpcuaError.mjs";
3
+ import { OPCUAClient, OPCUAClientOptions } from "node-opcua";
4
+ import { Config, Context, Effect, Layer, Stream } from "effect";
5
+ import * as effect_Scope0 from "effect/Scope";
6
+
7
+ //#region src/OpcuaClient.d.ts
8
+ declare namespace OpcuaClient_d_exports {
9
+ export { Client, ClientLayerConfig, ClientLayerOptions, ClientService, layer, layerConfig, make };
10
+ }
11
+ interface ClientService {
12
+ readonly events: Stream.Stream<OpcuaClientEvent>;
13
+ readonly unsafeRawClient: OPCUAClient;
14
+ }
15
+ declare const Client_base: Context.ServiceClass<Client, "@effect-opcua/client/OpcuaClient", ClientService>;
16
+ declare class Client extends Client_base {}
17
+ declare const make: (options: ClientLayerOptions) => Effect.Effect<ClientService, OpcuaConnectError, effect_Scope0.Scope>;
18
+ type ClientLayerOptions = {
19
+ readonly endpointUrl: string;
20
+ readonly clientOptions?: OPCUAClientOptions;
21
+ };
22
+ declare const layer: (options: ClientLayerOptions) => Layer.Layer<Client, OpcuaConnectError, never>;
23
+ type ClientLayerConfig = Config.Config<ClientLayerOptions>;
24
+ declare const layerConfig: (config: ClientLayerConfig) => Layer.Layer<Client, OpcuaConnectError | Config.ConfigError, never>;
25
+ //#endregion
26
+ export { Client, ClientLayerConfig, ClientLayerOptions, ClientService, OpcuaClient_d_exports, layer, layerConfig, make };
27
+ //# sourceMappingURL=OpcuaClient.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpcuaClient.d.mts","names":[],"sources":["../src/OpcuaClient.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAQiB,aAAA;mBACE,MAAA,CAAO,OAAO;4BACL;;cAC3B;cACY,MAAA,SAAe,WAAA;cAEf,gBAAiB,uBAAkB,MAAA,CAAA,OAAA,eAAA,iBAAA,EAAA,aAAA,CAAA,KAAA;KAGpC,kBAAA;;2BAEe;;cAGd,iBAAkB,uBAAkB,KAAA,CAAA,MAAA,QAAA,iBAAA;KAGrC,iBAAA,GAAoB,MAAA,CAAO,OAAO;AAjB7B,cAmBJ,WAnBiB,EAAA,CAAA,MAAA,EAmBM,iBAnBN,EAAA,GAmBuB,KAAA,CAAA,KAnBvB,CAmBuB,MAnBvB,EAmBuB,iBAAA,GAAA,MAAA,CAAA,WAnBvB,EAAA,KAAA,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { __export } from "./_virtual/rolldown_runtime.mjs";
2
+ import { makeClientService } from "./internal/client/make.mjs";
3
+ import { Context, Effect, Layer } from "effect";
4
+
5
+ //#region src/OpcuaClient.ts
6
+ var OpcuaClient_exports = /* @__PURE__ */ __export({
7
+ Client: () => Client,
8
+ layer: () => layer,
9
+ layerConfig: () => layerConfig,
10
+ make: () => make
11
+ });
12
+ const TypeId = "@effect-opcua/client/OpcuaClient";
13
+ var Client = class extends Context.Service()(TypeId) {};
14
+ const make = (options) => Effect.map(makeClientService(options), Client.of);
15
+ const layer = (options) => Layer.effect(Client, make(options));
16
+ const layerConfig = (config) => Layer.effect(Client, Effect.flatMap(config, make));
17
+
18
+ //#endregion
19
+ export { Client, OpcuaClient_exports, layer, layerConfig, make };
20
+ //# sourceMappingURL=OpcuaClient.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpcuaClient.mjs","names":[],"sources":["../src/OpcuaClient.ts"],"sourcesContent":["import type { OPCUAClient, OPCUAClientOptions } from \"node-opcua\";\nimport { type Config, Context, Effect, Layer, type Stream } from \"effect\";\n\nimport { makeClientService } from \"./internal/client/make.js\";\nimport type { OpcuaClientEvent } from \"./internal/events/model.js\";\n\nconst TypeId = \"@effect-opcua/client/OpcuaClient\";\n\nexport interface ClientService {\n readonly events: Stream.Stream<OpcuaClientEvent>;\n readonly unsafeRawClient: OPCUAClient;\n}\nexport class Client extends Context.Service<Client, ClientService>()(TypeId) {}\n\nexport const make = (options: ClientLayerOptions) =>\n Effect.map(makeClientService(options), Client.of);\n\nexport type ClientLayerOptions = {\n readonly endpointUrl: string;\n readonly clientOptions?: OPCUAClientOptions;\n};\n\nexport const layer = (options: ClientLayerOptions) =>\n Layer.effect(Client, make(options));\n\nexport type ClientLayerConfig = Config.Config<ClientLayerOptions>;\n\nexport const layerConfig = (config: ClientLayerConfig) =>\n Layer.effect(Client, Effect.flatMap(config, make));\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,SAAS;AAMf,IAAa,SAAb,cAA4B,QAAQ,SAAgC,CAAC,OAAO,CAAC;AAE7E,MAAa,QAAQ,YACnB,OAAO,IAAI,kBAAkB,QAAQ,EAAE,OAAO,GAAG;AAOnD,MAAa,SAAS,YACpB,MAAM,OAAO,QAAQ,KAAK,QAAQ,CAAC;AAIrC,MAAa,eAAe,WAC1B,MAAM,OAAO,QAAQ,OAAO,QAAQ,QAAQ,KAAK,CAAC"}