node-opcua-data-model 2.186.4 → 2.186.10
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server_capability_lists.d.ts +60 -0
- package/dist/server_capability_lists.d.ts.map +1 -0
- package/dist/server_capability_lists.js +141 -0
- package/dist/server_capability_lists.js.map +1 -0
- package/package.json +10 -10
- package/source/index.ts +1 -0
- package/source/server_capability_lists.ts +160 -0
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;GAEG;AACH,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-data-model
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The OPC 10000-12 Annex D identifier meaning "no capability information is available".
|
|
6
|
+
*
|
|
7
|
+
* It cannot be used in combination with any other capability identifier.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NO_CAPABILITY_IDENTIFIER = "NA";
|
|
10
|
+
/**
|
|
11
|
+
* True when `identifier` has the shape of an OPC 10000-12 Annex D ServerCapabilityIdentifier:
|
|
12
|
+
* a short token of letters, digits, `_` or `-`, with no whitespace and none of the
|
|
13
|
+
* separators an mDNS TXT record uses (`,` and `=`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isValidCapabilityIdentifier(identifier: unknown): identifier is string;
|
|
16
|
+
/**
|
|
17
|
+
* True when `profileUri` is a non-empty, syntactically absolute URI without whitespace,
|
|
18
|
+
* as the Profile and Facet URIs of OPC 10000-7 are.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isValidProfileUri(profileUri: unknown): profileUri is string;
|
|
21
|
+
/**
|
|
22
|
+
* Add a ServerCapabilityIdentifier (OPC 10000-12 Annex D) to a capability list, in place.
|
|
23
|
+
*
|
|
24
|
+
* Identifiers are compared case-insensitively and kept in the case they were given.
|
|
25
|
+
* The list is left deduplicated and sorted, and the `"NA"` placeholder is dropped as
|
|
26
|
+
* soon as a real identifier is present.
|
|
27
|
+
*
|
|
28
|
+
* @returns true when the list was changed.
|
|
29
|
+
* @throws when `identifier` is not shaped like a capability identifier.
|
|
30
|
+
*/
|
|
31
|
+
export declare function addCapabilityIdentifier(capabilities: string[], identifier: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Remove a ServerCapabilityIdentifier (OPC 10000-12 Annex D) from a capability list, in place.
|
|
34
|
+
*
|
|
35
|
+
* The comparison is case-insensitive. When the last real identifier goes, the list
|
|
36
|
+
* becomes `["NA"]` rather than empty. The list is left deduplicated and sorted.
|
|
37
|
+
*
|
|
38
|
+
* @returns true when the list was changed.
|
|
39
|
+
* @throws when `identifier` is not shaped like a capability identifier.
|
|
40
|
+
*/
|
|
41
|
+
export declare function removeCapabilityIdentifier(capabilities: string[], identifier: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Add a Profile or Facet URI to a `ServerProfileArray`-style list, in place.
|
|
44
|
+
*
|
|
45
|
+
* The list is left deduplicated and sorted. URIs are compared exactly.
|
|
46
|
+
*
|
|
47
|
+
* @returns true when the list was changed.
|
|
48
|
+
* @throws when `profileUri` is not an absolute URI.
|
|
49
|
+
*/
|
|
50
|
+
export declare function addProfileUri(profileUris: string[], profileUri: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Remove a Profile or Facet URI from a `ServerProfileArray`-style list, in place.
|
|
53
|
+
*
|
|
54
|
+
* The list is left deduplicated and sorted. URIs are compared exactly.
|
|
55
|
+
*
|
|
56
|
+
* @returns true when the list was changed.
|
|
57
|
+
* @throws when `profileUri` is not an absolute URI.
|
|
58
|
+
*/
|
|
59
|
+
export declare function removeProfileUri(profileUris: string[], profileUri: string): boolean;
|
|
60
|
+
//# sourceMappingURL=server_capability_lists.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server_capability_lists.d.ts","sourceRoot":"","sources":["../source/server_capability_lists.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAS7C;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,MAAM,CAMrF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,MAAM,CAG3E;AAuDD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAG3F;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAM9F;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGhF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGnF"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-data-model
|
|
3
|
+
*/
|
|
4
|
+
// Editing the two string lists a Server uses to describe what it supports:
|
|
5
|
+
//
|
|
6
|
+
// - the Profile and Facet URIs of `Server.ServerCapabilities.ServerProfileArray`
|
|
7
|
+
// (OPC 10000-5 and OPC 10000-7), e.g. "http://opcfoundation.org/UA-Profile/Server/Standard";
|
|
8
|
+
// - the ServerCapabilityIdentifiers of OPC 10000-12 Annex D, e.g. "DA", "HD", "GDS",
|
|
9
|
+
// "ALIAS", published through mDNS / LDS registration and
|
|
10
|
+
// `ServerConfiguration.ServerCapabilities`.
|
|
11
|
+
//
|
|
12
|
+
// Both registries are open-ended, so the checks below reject malformed input rather
|
|
13
|
+
// than comparing against a fixed list of known values.
|
|
14
|
+
/**
|
|
15
|
+
* The OPC 10000-12 Annex D identifier meaning "no capability information is available".
|
|
16
|
+
*
|
|
17
|
+
* It cannot be used in combination with any other capability identifier.
|
|
18
|
+
*/
|
|
19
|
+
export const NO_CAPABILITY_IDENTIFIER = "NA";
|
|
20
|
+
/**
|
|
21
|
+
* Annex D identifiers are kept short because of the mDNS field length limits. This bound
|
|
22
|
+
* is only a sanity check against a value that is clearly not an identifier.
|
|
23
|
+
*/
|
|
24
|
+
const MAX_CAPABILITY_IDENTIFIER_LENGTH = 32;
|
|
25
|
+
const capabilityIdentifierRegex = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
26
|
+
/**
|
|
27
|
+
* True when `identifier` has the shape of an OPC 10000-12 Annex D ServerCapabilityIdentifier:
|
|
28
|
+
* a short token of letters, digits, `_` or `-`, with no whitespace and none of the
|
|
29
|
+
* separators an mDNS TXT record uses (`,` and `=`).
|
|
30
|
+
*/
|
|
31
|
+
export function isValidCapabilityIdentifier(identifier) {
|
|
32
|
+
return (typeof identifier === "string" &&
|
|
33
|
+
identifier.length <= MAX_CAPABILITY_IDENTIFIER_LENGTH &&
|
|
34
|
+
capabilityIdentifierRegex.test(identifier));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* True when `profileUri` is a non-empty, syntactically absolute URI without whitespace,
|
|
38
|
+
* as the Profile and Facet URIs of OPC 10000-7 are.
|
|
39
|
+
*/
|
|
40
|
+
export function isValidProfileUri(profileUri) {
|
|
41
|
+
// URL.canParse rejects a relative reference or a string without a scheme
|
|
42
|
+
return typeof profileUri === "string" && profileUri.length > 0 && !/\s/.test(profileUri) && URL.canParse(profileUri);
|
|
43
|
+
}
|
|
44
|
+
function assertValidCapabilityIdentifier(identifier) {
|
|
45
|
+
if (!isValidCapabilityIdentifier(identifier)) {
|
|
46
|
+
throw new Error(`Invalid ServerCapabilityIdentifier ${JSON.stringify(identifier)}: expecting a short token ` +
|
|
47
|
+
"of letters, digits, '_' or '-' (OPC 10000-12 Annex D), e.g. \"DA\" or \"GDS\"");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function assertValidProfileUri(profileUri) {
|
|
51
|
+
if (!isValidProfileUri(profileUri)) {
|
|
52
|
+
throw new Error(`Invalid profile URI ${JSON.stringify(profileUri)}: expecting an absolute URI, ` +
|
|
53
|
+
'e.g. "http://opcfoundation.org/UA-Profile/Server/Standard"');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function compareOrdinal(a, b) {
|
|
57
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
58
|
+
}
|
|
59
|
+
/** Replace the content of `list` in place, and report whether it differs from before. */
|
|
60
|
+
function replaceContent(list, content) {
|
|
61
|
+
const changed = list.length !== content.length || list.some((value, index) => value !== content[index]);
|
|
62
|
+
if (changed) {
|
|
63
|
+
list.splice(0, list.length, ...content);
|
|
64
|
+
}
|
|
65
|
+
return changed;
|
|
66
|
+
}
|
|
67
|
+
function normalizeCapabilities(capabilities, restorePlaceholderWhenEmpty) {
|
|
68
|
+
const seen = new Set();
|
|
69
|
+
const unique = [];
|
|
70
|
+
for (const identifier of capabilities) {
|
|
71
|
+
const key = identifier.toUpperCase();
|
|
72
|
+
if (!seen.has(key)) {
|
|
73
|
+
seen.add(key);
|
|
74
|
+
unique.push(identifier);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// "NA" means "none": it cannot coexist with a real capability
|
|
78
|
+
const real = unique.filter((identifier) => identifier.toUpperCase() !== NO_CAPABILITY_IDENTIFIER);
|
|
79
|
+
if (real.length === 0) {
|
|
80
|
+
return restorePlaceholderWhenEmpty || unique.length > 0 ? [NO_CAPABILITY_IDENTIFIER] : [];
|
|
81
|
+
}
|
|
82
|
+
return real.sort((a, b) => compareOrdinal(a.toUpperCase(), b.toUpperCase()));
|
|
83
|
+
}
|
|
84
|
+
function normalizeProfileUris(profileUris) {
|
|
85
|
+
return [...new Set(profileUris)].sort(compareOrdinal);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Add a ServerCapabilityIdentifier (OPC 10000-12 Annex D) to a capability list, in place.
|
|
89
|
+
*
|
|
90
|
+
* Identifiers are compared case-insensitively and kept in the case they were given.
|
|
91
|
+
* The list is left deduplicated and sorted, and the `"NA"` placeholder is dropped as
|
|
92
|
+
* soon as a real identifier is present.
|
|
93
|
+
*
|
|
94
|
+
* @returns true when the list was changed.
|
|
95
|
+
* @throws when `identifier` is not shaped like a capability identifier.
|
|
96
|
+
*/
|
|
97
|
+
export function addCapabilityIdentifier(capabilities, identifier) {
|
|
98
|
+
assertValidCapabilityIdentifier(identifier);
|
|
99
|
+
return replaceContent(capabilities, normalizeCapabilities([...capabilities, identifier], false));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Remove a ServerCapabilityIdentifier (OPC 10000-12 Annex D) from a capability list, in place.
|
|
103
|
+
*
|
|
104
|
+
* The comparison is case-insensitive. When the last real identifier goes, the list
|
|
105
|
+
* becomes `["NA"]` rather than empty. The list is left deduplicated and sorted.
|
|
106
|
+
*
|
|
107
|
+
* @returns true when the list was changed.
|
|
108
|
+
* @throws when `identifier` is not shaped like a capability identifier.
|
|
109
|
+
*/
|
|
110
|
+
export function removeCapabilityIdentifier(capabilities, identifier) {
|
|
111
|
+
assertValidCapabilityIdentifier(identifier);
|
|
112
|
+
const key = identifier.toUpperCase();
|
|
113
|
+
const remaining = capabilities.filter((c) => c.toUpperCase() !== key);
|
|
114
|
+
const removed = remaining.length !== capabilities.length;
|
|
115
|
+
return replaceContent(capabilities, normalizeCapabilities(remaining, removed));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Add a Profile or Facet URI to a `ServerProfileArray`-style list, in place.
|
|
119
|
+
*
|
|
120
|
+
* The list is left deduplicated and sorted. URIs are compared exactly.
|
|
121
|
+
*
|
|
122
|
+
* @returns true when the list was changed.
|
|
123
|
+
* @throws when `profileUri` is not an absolute URI.
|
|
124
|
+
*/
|
|
125
|
+
export function addProfileUri(profileUris, profileUri) {
|
|
126
|
+
assertValidProfileUri(profileUri);
|
|
127
|
+
return replaceContent(profileUris, normalizeProfileUris([...profileUris, profileUri]));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Remove a Profile or Facet URI from a `ServerProfileArray`-style list, in place.
|
|
131
|
+
*
|
|
132
|
+
* The list is left deduplicated and sorted. URIs are compared exactly.
|
|
133
|
+
*
|
|
134
|
+
* @returns true when the list was changed.
|
|
135
|
+
* @throws when `profileUri` is not an absolute URI.
|
|
136
|
+
*/
|
|
137
|
+
export function removeProfileUri(profileUris, profileUri) {
|
|
138
|
+
assertValidProfileUri(profileUri);
|
|
139
|
+
return replaceContent(profileUris, normalizeProfileUris(profileUris.filter((uri) => uri !== profileUri)));
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=server_capability_lists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server_capability_lists.js","sourceRoot":"","sources":["../source/server_capability_lists.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,2EAA2E;AAC3E,EAAE;AACF,iFAAiF;AACjF,+FAA+F;AAC/F,qFAAqF;AACrF,2DAA2D;AAC3D,8CAA8C;AAC9C,EAAE;AACF,oFAAoF;AACpF,uDAAuD;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAE7C;;;GAGG;AACH,MAAM,gCAAgC,GAAG,EAAE,CAAC;AAC5C,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEhE;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,UAAmB;IAC3D,OAAO,CACH,OAAO,UAAU,KAAK,QAAQ;QAC9B,UAAU,CAAC,MAAM,IAAI,gCAAgC;QACrD,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAC7C,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAmB;IACjD,yEAAyE;IACzE,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACzH,CAAC;AAED,SAAS,+BAA+B,CAAC,UAAmB;IACxD,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACX,sCAAsC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,4BAA4B;YACxF,+EAA+E,CACtF,CAAC;IACN,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAmB;IAC9C,IAAI,C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;IACzD,OAAO,cAAc,CAAC,YAAY,EAAE,qBAAqB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AACnF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,WAAqB,EAAE,UAAkB;IACnE,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAClC,OAAO,cAAc,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAqB,EAAE,UAAkB;IACtE,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAClC,OAAO,cAAc,CAAC,WAAW,EAAE,oBAAoB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;AAC9G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-data-model",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.186.
|
|
4
|
+
"version": "2.186.10",
|
|
5
5
|
"description": "pure nodejs OPCUA SDK - module data-model",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc -b",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"node": ">=22.13.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"node-opcua-assert": "2.
|
|
22
|
-
"node-opcua-basic-types": "2.186.
|
|
23
|
-
"node-opcua-binary-stream": "2.186.
|
|
24
|
-
"node-opcua-enum": "2.186.
|
|
25
|
-
"node-opcua-factory": "2.186.
|
|
26
|
-
"node-opcua-nodeid": "2.186.
|
|
27
|
-
"node-opcua-status-code": "2.186.
|
|
21
|
+
"node-opcua-assert": "2.186.7",
|
|
22
|
+
"node-opcua-basic-types": "2.186.7",
|
|
23
|
+
"node-opcua-binary-stream": "2.186.7",
|
|
24
|
+
"node-opcua-enum": "2.186.7",
|
|
25
|
+
"node-opcua-factory": "2.186.7",
|
|
26
|
+
"node-opcua-nodeid": "2.186.7",
|
|
27
|
+
"node-opcua-status-code": "2.186.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"node-opcua-packet-analyzer": "2.186.
|
|
30
|
+
"node-opcua-packet-analyzer": "2.186.7"
|
|
31
31
|
},
|
|
32
32
|
"author": "Etienne Rossignon",
|
|
33
33
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"internet of things"
|
|
45
45
|
],
|
|
46
46
|
"homepage": "http://node-opcua.github.io/",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "f6e25f12e17feabaf6ac2b07621b8bfbf92375c9",
|
|
48
48
|
"files": [
|
|
49
49
|
"dist",
|
|
50
50
|
"source"
|
package/source/index.ts
CHANGED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-data-model
|
|
3
|
+
*/
|
|
4
|
+
// Editing the two string lists a Server uses to describe what it supports:
|
|
5
|
+
//
|
|
6
|
+
// - the Profile and Facet URIs of `Server.ServerCapabilities.ServerProfileArray`
|
|
7
|
+
// (OPC 10000-5 and OPC 10000-7), e.g. "http://opcfoundation.org/UA-Profile/Server/Standard";
|
|
8
|
+
// - the ServerCapabilityIdentifiers of OPC 10000-12 Annex D, e.g. "DA", "HD", "GDS",
|
|
9
|
+
// "ALIAS", published through mDNS / LDS registration and
|
|
10
|
+
// `ServerConfiguration.ServerCapabilities`.
|
|
11
|
+
//
|
|
12
|
+
// Both registries are open-ended, so the checks below reject malformed input rather
|
|
13
|
+
// than comparing against a fixed list of known values.
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The OPC 10000-12 Annex D identifier meaning "no capability information is available".
|
|
17
|
+
*
|
|
18
|
+
* It cannot be used in combination with any other capability identifier.
|
|
19
|
+
*/
|
|
20
|
+
export const NO_CAPABILITY_IDENTIFIER = "NA";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Annex D identifiers are kept short because of the mDNS field length limits. This bound
|
|
24
|
+
* is only a sanity check against a value that is clearly not an identifier.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_CAPABILITY_IDENTIFIER_LENGTH = 32;
|
|
27
|
+
const capabilityIdentifierRegex = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* True when `identifier` has the shape of an OPC 10000-12 Annex D ServerCapabilityIdentifier:
|
|
31
|
+
* a short token of letters, digits, `_` or `-`, with no whitespace and none of the
|
|
32
|
+
* separators an mDNS TXT record uses (`,` and `=`).
|
|
33
|
+
*/
|
|
34
|
+
export function isValidCapabilityIdentifier(identifier: unknown): identifier is string {
|
|
35
|
+
return (
|
|
36
|
+
typeof identifier === "string" &&
|
|
37
|
+
identifier.length <= MAX_CAPABILITY_IDENTIFIER_LENGTH &&
|
|
38
|
+
capabilityIdentifierRegex.test(identifier)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* True when `profileUri` is a non-empty, syntactically absolute URI without whitespace,
|
|
44
|
+
* as the Profile and Facet URIs of OPC 10000-7 are.
|
|
45
|
+
*/
|
|
46
|
+
export function isValidProfileUri(profileUri: unknown): profileUri is string {
|
|
47
|
+
// URL.canParse rejects a relative reference or a string without a scheme
|
|
48
|
+
return typeof profileUri === "string" && profileUri.length > 0 && !/\s/.test(profileUri) && URL.canParse(profileUri);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function assertValidCapabilityIdentifier(identifier: unknown): asserts identifier is string {
|
|
52
|
+
if (!isValidCapabilityIdentifier(identifier)) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Invalid ServerCapabilityIdentifier ${JSON.stringify(identifier)}: expecting a short token ` +
|
|
55
|
+
"of letters, digits, '_' or '-' (OPC 10000-12 Annex D), e.g. \"DA\" or \"GDS\""
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function assertValidProfileUri(profileUri: unknown): asserts profileUri is string {
|
|
61
|
+
if (!isValidProfileUri(profileUri)) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Invalid profile URI ${JSON.stringify(profileUri)}: expecting an absolute URI, ` +
|
|
64
|
+
'e.g. "http://opcfoundation.org/UA-Profile/Server/Standard"'
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function compareOrdinal(a: string, b: string): number {
|
|
70
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Replace the content of `list` in place, and report whether it differs from before. */
|
|
74
|
+
function replaceContent(list: string[], content: string[]): boolean {
|
|
75
|
+
const changed = list.length !== content.length || list.some((value, index) => value !== content[index]);
|
|
76
|
+
if (changed) {
|
|
77
|
+
list.splice(0, list.length, ...content);
|
|
78
|
+
}
|
|
79
|
+
return changed;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function normalizeCapabilities(capabilities: string[], restorePlaceholderWhenEmpty: boolean): string[] {
|
|
83
|
+
const seen = new Set<string>();
|
|
84
|
+
const unique: string[] = [];
|
|
85
|
+
for (const identifier of capabilities) {
|
|
86
|
+
const key = identifier.toUpperCase();
|
|
87
|
+
if (!seen.has(key)) {
|
|
88
|
+
seen.add(key);
|
|
89
|
+
unique.push(identifier);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// "NA" means "none": it cannot coexist with a real capability
|
|
93
|
+
const real = unique.filter((identifier) => identifier.toUpperCase() !== NO_CAPABILITY_IDENTIFIER);
|
|
94
|
+
if (real.length === 0) {
|
|
95
|
+
return restorePlaceholderWhenEmpty || unique.length > 0 ? [NO_CAPABILITY_IDENTIFIER] : [];
|
|
96
|
+
}
|
|
97
|
+
return real.sort((a, b) => compareOrdinal(a.toUpperCase(), b.toUpperCase()));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function normalizeProfileUris(profileUris: string[]): string[] {
|
|
101
|
+
return [...new Set(profileUris)].sort(compareOrdinal);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Add a ServerCapabilityIdentifier (OPC 10000-12 Annex D) to a capability list, in place.
|
|
106
|
+
*
|
|
107
|
+
* Identifiers are compared case-insensitively and kept in the case they were given.
|
|
108
|
+
* The list is left deduplicated and sorted, and the `"NA"` placeholder is dropped as
|
|
109
|
+
* soon as a real identifier is present.
|
|
110
|
+
*
|
|
111
|
+
* @returns true when the list was changed.
|
|
112
|
+
* @throws when `identifier` is not shaped like a capability identifier.
|
|
113
|
+
*/
|
|
114
|
+
export function addCapabilityIdentifier(capabilities: string[], identifier: string): boolean {
|
|
115
|
+
assertValidCapabilityIdentifier(identifier);
|
|
116
|
+
return replaceContent(capabilities, normalizeCapabilities([...capabilities, identifier], false));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Remove a ServerCapabilityIdentifier (OPC 10000-12 Annex D) from a capability list, in place.
|
|
121
|
+
*
|
|
122
|
+
* The comparison is case-insensitive. When the last real identifier goes, the list
|
|
123
|
+
* becomes `["NA"]` rather than empty. The list is left deduplicated and sorted.
|
|
124
|
+
*
|
|
125
|
+
* @returns true when the list was changed.
|
|
126
|
+
* @throws when `identifier` is not shaped like a capability identifier.
|
|
127
|
+
*/
|
|
128
|
+
export function removeCapabilityIdentifier(capabilities: string[], identifier: string): boolean {
|
|
129
|
+
assertValidCapabilityIdentifier(identifier);
|
|
130
|
+
const key = identifier.toUpperCase();
|
|
131
|
+
const remaining = capabilities.filter((c) => c.toUpperCase() !== key);
|
|
132
|
+
const removed = remaining.length !== capabilities.length;
|
|
133
|
+
return replaceContent(capabilities, normalizeCapabilities(remaining, removed));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Add a Profile or Facet URI to a `ServerProfileArray`-style list, in place.
|
|
138
|
+
*
|
|
139
|
+
* The list is left deduplicated and sorted. URIs are compared exactly.
|
|
140
|
+
*
|
|
141
|
+
* @returns true when the list was changed.
|
|
142
|
+
* @throws when `profileUri` is not an absolute URI.
|
|
143
|
+
*/
|
|
144
|
+
export function addProfileUri(profileUris: string[], profileUri: string): boolean {
|
|
145
|
+
assertValidProfileUri(profileUri);
|
|
146
|
+
return replaceContent(profileUris, normalizeProfileUris([...profileUris, profileUri]));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Remove a Profile or Facet URI from a `ServerProfileArray`-style list, in place.
|
|
151
|
+
*
|
|
152
|
+
* The list is left deduplicated and sorted. URIs are compared exactly.
|
|
153
|
+
*
|
|
154
|
+
* @returns true when the list was changed.
|
|
155
|
+
* @throws when `profileUri` is not an absolute URI.
|
|
156
|
+
*/
|
|
157
|
+
export function removeProfileUri(profileUris: string[], profileUri: string): boolean {
|
|
158
|
+
assertValidProfileUri(profileUri);
|
|
159
|
+
return replaceContent(profileUris, normalizeProfileUris(profileUris.filter((uri) => uri !== profileUri)));
|
|
160
|
+
}
|