@digicatapult/dtdl-parser 0.0.15 → 0.0.17

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/README.md CHANGED
@@ -1,28 +1,25 @@
1
- # dtdl-parser
1
+ # dtdl-parser library
2
2
 
3
3
  A library for parsing and validating (DTDL)[https://learn.microsoft.com/en-us/azure/digital-twins/concepts-models] ontologies.
4
4
 
5
- ## Prerequisites
5
+ ## Installation / Adding to the Package.json
6
6
 
7
- `node` >= 20
8
- `dotnet` [CLI](https://learn.microsoft.com/en-us/dotnet/core/install/)
9
- Run `dotnet workload install wasm-tools` to install `wasm-tools`
7
+ `@digicatapult/dtdl-parser` are available as an [npm package](https://www.npmjs.com/package/@digicatapult/dtdl-parser). In order to use your local version in the project please use `npm link` more on it -> [here](https://docs.npmjs.com/cli/v10/commands/npm-link) and below in this document
10
8
 
11
- ## Getting started
9
+ ```sh
10
+ // with npm
11
+ npm install @digicatapult/ui-component-library
12
+ ```
12
13
 
13
- Install dependencies
14
-
15
- `npm install`
16
-
17
- Build javascript files
18
-
19
- `npm run build`
14
+ ## Basic Usage
20
15
 
21
- Basic usage
16
+ Install dependencies
22
17
 
23
18
  ```javascript
24
19
  import { parseDirectories, validateDirectories, getInterop } from "dtdl-parser"
25
20
 
21
+
26
22
  const parser = await getInterop()
27
- parseDirectories('../dtdl/simple', parser)
28
- ```
23
+ const parsedDtdl = parseDirectories('../dtdl/simple', parser)
24
+ ```
25
+
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=DtdlErr.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../types/DtdlErr.d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=DtdlOm.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../types/DtdlOm.d.ts"],"names":[],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "mainAssemblyName": "DTDLParserJSInterop.dll",
3
3
  "resources": {
4
- "hash": "sha256-gz7SFK75PKjPCvG+55ZwMLiIGkxrTqRy/2Wjzk68AFU=",
4
+ "hash": "sha256-/02EiXo42by34HRcDCuken0BdNBfXbJLufifpL/Rjyw=",
5
5
  "jsModuleNative": {
6
6
  "dotnet.native.js": "sha256-79LdZogK41buIci0KtOWmQvQc2swMI3jvDQCoN23NBM="
7
7
  },
@@ -181,10 +181,10 @@
181
181
  "mscorlib.wasm": "sha256-KvqZaNpjwhrOuzE4b4aMFsI+VUTyiWfoDI4zn4l9BM8=",
182
182
  "netstandard.wasm": "sha256-v+s7sWxtOM6bnOvC0jFrtnm6uMfbDymwl2nHNgbS2LM=",
183
183
  "System.Private.CoreLib.wasm": "sha256-pklll63uFQoY6vaD3vbluS9osYiJWLLLmob1yHFgepI=",
184
- "DTDLParserJSInterop.wasm": "sha256-In0ykSqWvOHUMaydHOB4gMR1guIwhvIPHqqA+wJDy2w="
184
+ "DTDLParserJSInterop.wasm": "sha256-S+lZykwU05ll761uE0X/ItfR177rvhfza74y99CbMsU="
185
185
  },
186
186
  "pdb": {
187
- "DTDLParserJSInterop.pdb": "sha256-GY59ni7t9PtmnPBjm+F+HwpjTCgF9LoFjDMjode/fak="
187
+ "DTDLParserJSInterop.pdb": "sha256-YBF3EgpJ0UhawB/oiYDX9fIfO+k85wsBRJ0LVjKLIFA="
188
188
  },
189
189
  "vfs": {
190
190
  "runtimeconfig.bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digicatapult/dtdl-parser",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "JS tool to parse DTDL defined Ontologies",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "types": "./build/index.d.ts",
11
11
  "files": [
12
- "build/"
12
+ "build/",
13
+ "types/"
13
14
  ],
14
15
  "scripts": {
15
16
  "test": "NODE_ENV=test ./node_modules/.bin/mocha --config ./test/mocharc.json ./src/**/*.test.ts",
@@ -17,7 +18,7 @@
17
18
  "build:declarations": "tsc --emitDeclarationOnly",
18
19
  "interop:debug": "dotnet build interop",
19
20
  "interop:build": "dotnet build src/interop --configuration Release",
20
- "build:ts": "swc ./src -d ./build --strip-leading-paths",
21
+ "build:ts": "swc ./src ./types -d ./build --strip-leading-paths",
21
22
  "check": "tsc --noEmit",
22
23
  "clean": "rimraf -rf ./build",
23
24
  "lint": "eslint .",
@@ -66,4 +67,4 @@
66
67
  "engines": {
67
68
  "node": ">= 20"
68
69
  }
69
- }
70
+ }
@@ -0,0 +1,26 @@
1
+ export type ModelingException = ParsingException | ResolutionException
2
+
3
+ export interface ParsingException {
4
+ ExceptionKind: 'Parsing'
5
+ Errors: ParsingError[]
6
+ }
7
+
8
+ export interface ParsingError {
9
+ PrimaryID?: string
10
+ SecondaryID?: string
11
+ Property?: string
12
+ AuxProperty?: string
13
+ Type?: string
14
+ Value?: string
15
+ Restriction?: string
16
+ Transformation?: string
17
+ Violations?: string[]
18
+ Cause: string
19
+ Action: string
20
+ ValidationID: string
21
+ }
22
+
23
+ export interface ResolutionException {
24
+ ExceptionKind: 'Resolution'
25
+ UndefinedIdentifiers: string[]
26
+ }
@@ -0,0 +1,372 @@
1
+ export type DtdlObjectModel = { [entityId: string]: EntityType }
2
+
3
+ export interface ArrayInfo extends ComplexSchemaInfo {
4
+ EntityKind: 'Array'
5
+ elementSchema: string
6
+ }
7
+
8
+ export type ArrayType = ArrayInfo
9
+
10
+ export interface BooleanInfo extends PrimitiveSchemaInfo {
11
+ EntityKind: 'Boolean'
12
+ }
13
+
14
+ export type BooleanType = BooleanInfo
15
+
16
+ export interface CommandInfo extends ContentInfo {
17
+ EntityKind: 'Command'
18
+ commandType?: string
19
+ request?: string
20
+ response?: string
21
+ }
22
+
23
+ export type CommandType = CommandInfo
24
+
25
+ export interface CommandPayloadInfo extends SchemaFieldInfo {
26
+ EntityKind: 'CommandPayload' | 'CommandRequest' | 'CommandResponse'
27
+ }
28
+
29
+ export type CommandPayloadType = CommandPayloadInfo | CommandRequestType | CommandResponseType
30
+
31
+ export interface CommandRequestInfo extends CommandPayloadInfo {
32
+ EntityKind: 'CommandRequest'
33
+ }
34
+
35
+ export type CommandRequestType = CommandRequestInfo
36
+
37
+ export interface CommandResponseInfo extends CommandPayloadInfo {
38
+ EntityKind: 'CommandResponse'
39
+ }
40
+
41
+ export type CommandResponseType = CommandResponseInfo
42
+
43
+ export interface CommandTypeInfo extends EntityInfo {
44
+ EntityKind: 'CommandType'
45
+ }
46
+
47
+ export type CommandTypeType = CommandTypeInfo
48
+
49
+ export interface ComplexSchemaInfo extends SchemaInfo {
50
+ EntityKind: 'Array' | 'Enum' | 'Map' | 'Object'
51
+ }
52
+
53
+ export type ComplexSchemaType = ComplexSchemaInfo | ArrayType | EnumType | MapType | ObjectType
54
+
55
+ export interface ComponentInfo extends ContentInfo {
56
+ EntityKind: 'Component'
57
+ schema: string
58
+ }
59
+
60
+ export type ComponentType = ComponentInfo
61
+
62
+ export interface ContentInfo extends NamedEntityInfo {
63
+ EntityKind: 'Command' | 'Component' | 'Property' | 'Relationship' | 'Telemetry'
64
+ }
65
+
66
+ export type ContentType = ContentInfo | CommandType | ComponentType | PropertyType | RelationshipType | TelemetryType
67
+
68
+ export interface DateInfo extends TemporalSchemaInfo {
69
+ EntityKind: 'Date'
70
+ }
71
+
72
+ export type DateType = DateInfo
73
+
74
+ export interface DateTimeInfo extends TemporalSchemaInfo {
75
+ EntityKind: 'DateTime'
76
+ }
77
+
78
+ export type DateTimeType = DateTimeInfo
79
+
80
+ export interface DoubleInfo extends NumericSchemaInfo {
81
+ EntityKind: 'Double'
82
+ }
83
+
84
+ export type DoubleType = DoubleInfo
85
+
86
+ export interface DurationInfo extends TemporalSchemaInfo {
87
+ EntityKind: 'Duration'
88
+ }
89
+
90
+ export type DurationType = DurationInfo
91
+
92
+ export interface EntityInfo {
93
+ EntityKind:
94
+ | 'Array'
95
+ | 'Boolean'
96
+ | 'Command'
97
+ | 'CommandPayload'
98
+ | 'CommandType'
99
+ | 'Component'
100
+ | 'Date'
101
+ | 'DateTime'
102
+ | 'Double'
103
+ | 'Duration'
104
+ | 'Enum'
105
+ | 'EnumValue'
106
+ | 'Field'
107
+ | 'Float'
108
+ | 'Integer'
109
+ | 'Interface'
110
+ | 'Long'
111
+ | 'Map'
112
+ | 'MapKey'
113
+ | 'MapValue'
114
+ | 'Object'
115
+ | 'Property'
116
+ | 'Relationship'
117
+ | 'String'
118
+ | 'Telemetry'
119
+ | 'Time'
120
+ | 'CommandRequest'
121
+ | 'CommandResponse'
122
+ | 'Unit'
123
+ | 'UnitAttribute'
124
+ | 'LatentType'
125
+ | 'NamedLatentType'
126
+ SupplementalTypes: string[]
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ SupplementalProperties: { [property: string]: any }
129
+ UndefinedTypes: string[]
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ UndefinedProperties: { [property: string]: any }
132
+ ClassId: string
133
+ comment?: string
134
+ description: { [languageCode: string]: string }
135
+ displayName: { [languageCode: string]: string }
136
+ languageMajorVersion: number
137
+ Id: string
138
+ ChildOf?: string
139
+ DefinedIn?: string
140
+ }
141
+
142
+ export type EntityType =
143
+ | EntityInfo
144
+ | CommandTypeType
145
+ | InterfaceType
146
+ | LatentTypeType
147
+ | NamedEntityType
148
+ | SchemaType
149
+ | UnitType
150
+
151
+ export interface EnumInfo extends ComplexSchemaInfo {
152
+ EntityKind: 'Enum'
153
+ enumValues: string[]
154
+ valueSchema: string
155
+ }
156
+
157
+ export type EnumType = EnumInfo
158
+
159
+ export interface EnumValueInfo extends NamedEntityInfo {
160
+ EntityKind: 'EnumValue'
161
+ enumValue: string | number | boolean
162
+ }
163
+
164
+ export type EnumValueType = EnumValueInfo
165
+
166
+ export interface FieldInfo extends SchemaFieldInfo {
167
+ EntityKind: 'Field'
168
+ }
169
+
170
+ export type FieldType = FieldInfo
171
+
172
+ export interface FloatInfo extends NumericSchemaInfo {
173
+ EntityKind: 'Float'
174
+ }
175
+
176
+ export type FloatType = FloatInfo
177
+
178
+ export interface IntegerInfo extends NumericSchemaInfo {
179
+ EntityKind: 'Integer'
180
+ }
181
+
182
+ export type IntegerType = IntegerInfo
183
+
184
+ export interface InterfaceInfo extends EntityInfo {
185
+ EntityKind: 'Interface'
186
+ contents: { [name: string]: string }
187
+ commands: { [name: string]: string }
188
+ components: { [name: string]: string }
189
+ properties: { [name: string]: string }
190
+ relationships: { [name: string]: string }
191
+ telemetries: { [name: string]: string }
192
+ extends: string[]
193
+ extendedBy: string[]
194
+ schemas: string[]
195
+ }
196
+
197
+ export type InterfaceType = InterfaceInfo
198
+
199
+ export interface LatentTypeInfo extends EntityInfo {
200
+ EntityKind: 'LatentType'
201
+ }
202
+
203
+ export type LatentTypeType = LatentTypeInfo
204
+
205
+ export interface LongInfo extends NumericSchemaInfo {
206
+ EntityKind: 'Long'
207
+ }
208
+
209
+ export type LongType = LongInfo
210
+
211
+ export interface MapInfo extends ComplexSchemaInfo {
212
+ EntityKind: 'Map'
213
+ mapKey: string
214
+ mapValue: string
215
+ }
216
+
217
+ export type MapType = MapInfo
218
+
219
+ export interface MapKeyInfo extends NamedEntityInfo {
220
+ EntityKind: 'MapKey'
221
+ schema: string
222
+ }
223
+
224
+ export type MapKeyType = MapKeyInfo
225
+
226
+ export interface MapValueInfo extends SchemaFieldInfo {
227
+ EntityKind: 'MapValue'
228
+ }
229
+
230
+ export type MapValueType = MapValueInfo
231
+
232
+ export interface NamedEntityInfo extends EntityInfo {
233
+ EntityKind:
234
+ | 'Command'
235
+ | 'CommandPayload'
236
+ | 'Component'
237
+ | 'EnumValue'
238
+ | 'Field'
239
+ | 'MapKey'
240
+ | 'MapValue'
241
+ | 'Property'
242
+ | 'Relationship'
243
+ | 'Telemetry'
244
+ | 'CommandRequest'
245
+ | 'CommandResponse'
246
+ | 'UnitAttribute'
247
+ | 'NamedLatentType'
248
+ name: string
249
+ }
250
+
251
+ export type NamedEntityType =
252
+ | NamedEntityInfo
253
+ | ContentType
254
+ | EnumValueType
255
+ | MapKeyType
256
+ | NamedLatentTypeType
257
+ | SchemaFieldType
258
+ | UnitAttributeType
259
+
260
+ export interface NamedLatentTypeInfo extends NamedEntityInfo {
261
+ EntityKind: 'NamedLatentType'
262
+ }
263
+
264
+ export type NamedLatentTypeType = NamedLatentTypeInfo
265
+
266
+ export interface NumericSchemaInfo extends PrimitiveSchemaInfo {
267
+ EntityKind: 'Double' | 'Float' | 'Integer' | 'Long'
268
+ }
269
+
270
+ export type NumericSchemaType = NumericSchemaInfo | DoubleType | FloatType | IntegerType | LongType
271
+
272
+ export interface ObjectInfo extends ComplexSchemaInfo {
273
+ EntityKind: 'Object'
274
+ fields: string[]
275
+ }
276
+
277
+ export type ObjectType = ObjectInfo
278
+
279
+ export interface PrimitiveSchemaInfo extends SchemaInfo {
280
+ EntityKind: 'Boolean' | 'Date' | 'DateTime' | 'Double' | 'Duration' | 'Float' | 'Integer' | 'Long' | 'String' | 'Time'
281
+ }
282
+
283
+ export type PrimitiveSchemaType =
284
+ | PrimitiveSchemaInfo
285
+ | BooleanType
286
+ | NumericSchemaType
287
+ | StringType
288
+ | TemporalSchemaType
289
+
290
+ export interface PropertyInfo extends ContentInfo {
291
+ EntityKind: 'Property'
292
+ schema: string
293
+ writable: boolean
294
+ }
295
+
296
+ export type PropertyType = PropertyInfo
297
+
298
+ export interface RelationshipInfo extends ContentInfo {
299
+ EntityKind: 'Relationship'
300
+ maxMultiplicity?: number
301
+ minMultiplicity?: number
302
+ properties: string[]
303
+ target?: string
304
+ writable: boolean
305
+ }
306
+
307
+ export type RelationshipType = RelationshipInfo
308
+
309
+ export interface SchemaInfo extends EntityInfo {
310
+ EntityKind:
311
+ | 'Array'
312
+ | 'Boolean'
313
+ | 'Date'
314
+ | 'DateTime'
315
+ | 'Double'
316
+ | 'Duration'
317
+ | 'Enum'
318
+ | 'Float'
319
+ | 'Integer'
320
+ | 'Long'
321
+ | 'Map'
322
+ | 'Object'
323
+ | 'String'
324
+ | 'Time'
325
+ }
326
+
327
+ export type SchemaType = SchemaInfo | ComplexSchemaType | PrimitiveSchemaType
328
+
329
+ export interface SchemaFieldInfo extends NamedEntityInfo {
330
+ EntityKind: 'CommandPayload' | 'Field' | 'MapValue' | 'CommandRequest' | 'CommandResponse'
331
+ schema: string
332
+ }
333
+
334
+ export type SchemaFieldType = SchemaFieldInfo | CommandPayloadType | FieldType | MapValueType
335
+
336
+ export interface StringInfo extends PrimitiveSchemaInfo {
337
+ EntityKind: 'String'
338
+ }
339
+
340
+ export type StringType = StringInfo
341
+
342
+ export interface TelemetryInfo extends ContentInfo {
343
+ EntityKind: 'Telemetry'
344
+ schema: string
345
+ }
346
+
347
+ export type TelemetryType = TelemetryInfo
348
+
349
+ export interface TemporalSchemaInfo extends PrimitiveSchemaInfo {
350
+ EntityKind: 'Date' | 'DateTime' | 'Duration' | 'Time'
351
+ }
352
+
353
+ export type TemporalSchemaType = TemporalSchemaInfo | DateType | DateTimeType | DurationType | TimeType
354
+
355
+ export interface TimeInfo extends TemporalSchemaInfo {
356
+ EntityKind: 'Time'
357
+ }
358
+
359
+ export type TimeType = TimeInfo
360
+
361
+ export interface UnitInfo extends EntityInfo {
362
+ EntityKind: 'Unit'
363
+ symbol?: string
364
+ }
365
+
366
+ export type UnitType = UnitInfo
367
+
368
+ export interface UnitAttributeInfo extends NamedEntityInfo {
369
+ EntityKind: 'UnitAttribute'
370
+ }
371
+
372
+ export type UnitAttributeType = UnitAttributeInfo