@ebusd/ebus-typespec 0.22.0 → 0.23.0

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/src/lib.d.ts CHANGED
@@ -65,7 +65,7 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
65
65
  "missing-decorator": {
66
66
  readonly default: import("@typespec/compiler").CallableMessage<["which"]>;
67
67
  };
68
- }, EbusdEmitterOptions, "values" | "reverse" | "unit" | "id" | "condition" | "write" | "passive" | "poll" | "auth" | "qq" | "zz" | "chain" | "inherit" | "example" | "bcd" | "hex" | "maxBits" | "out" | "divisor" | "step" | "constValue">;
68
+ }, EbusdEmitterOptions, "values" | "id" | "condition" | "write" | "passive" | "poll" | "auth" | "qq" | "zz" | "chain" | "inherit" | "example" | "bcd" | "hex" | "maxBits" | "out" | "reverse" | "unit" | "divisor" | "step" | "constValue">;
69
69
  export declare const $flags: {
70
70
  decoratorArgMarshalling: string;
71
71
  };
@@ -289,4 +289,4 @@ export declare const reportDiagnostic: <C extends "banned-source-address" | "ban
289
289
  "missing-decorator": {
290
290
  readonly default: import("@typespec/compiler").CallableMessage<["which"]>;
291
291
  };
292
- }, C, M>) => import("@typespec/compiler").Diagnostic, StateKeys: Record<"values" | "reverse" | "unit" | "id" | "condition" | "write" | "passive" | "poll" | "auth" | "qq" | "zz" | "chain" | "inherit" | "example" | "bcd" | "hex" | "maxBits" | "out" | "divisor" | "step" | "constValue", symbol>;
292
+ }, C, M>) => import("@typespec/compiler").Diagnostic, StateKeys: Record<"values" | "id" | "condition" | "write" | "passive" | "poll" | "auth" | "qq" | "zz" | "chain" | "inherit" | "example" | "bcd" | "hex" | "maxBits" | "out" | "reverse" | "unit" | "divisor" | "step" | "constValue", symbol>;
package/docs.md CHANGED
@@ -8,9 +8,7 @@ TypeSpec library for defining eBUS messages and emitting to ebusd CSV.
8
8
  npm install @ebusd/ebus-typespec
9
9
  ```
10
10
 
11
- ## Emitter
12
-
13
- ### Usage
11
+ ## Emitter usage
14
12
 
15
13
  1. Via the command line
16
14
 
@@ -25,29 +23,44 @@ emit:
25
23
  - "@ebusd/ebus-typespec"
26
24
  ```
27
25
 
28
- ### Emitter options
26
+ The config can be extended with options as follows:
27
+
28
+ ```yaml
29
+ emit:
30
+ - "@ebusd/ebus-typespec"
31
+ options:
32
+ "@ebusd/ebus-typespec":
33
+ option: value
34
+ ```
29
35
 
30
- #### `includes`
36
+ ## Emitter options
37
+
38
+ ### `emitter-output-dir`
39
+
40
+ **Type:** `absolutePath`
41
+
42
+ Defines the emitter output directory. Defaults to `{output-dir}/@ebusd/ebus-typespec`
43
+ See [Configuring output directory for more info](https://typespec.io/docs/handbook/configuration/configuration/#configuring-output-directory)
44
+
45
+ ### `includes`
31
46
 
32
47
  **Type:** `boolean`
33
48
 
34
49
  Emit includes files as includes instead of inline (incomplete!)
35
50
 
36
- #### `translations`
51
+ ### `translations`
37
52
 
38
53
  **Type:** `string`
39
54
 
40
55
  File name with translations to use.
41
56
 
42
- #### `withMinMax`
57
+ ### `withMinMax`
43
58
 
44
59
  **Type:** `boolean`
45
60
 
46
61
  Emit min+max values
47
62
 
48
- ## Linter
49
-
50
- ### Usage
63
+ ## Linter usage
51
64
 
52
65
  Add the following in `tspconfig.yaml`:
53
66
 
@@ -61,8 +74,8 @@ linter:
61
74
 
62
75
  Available ruleSets:
63
76
 
64
- - [`ebus/recommended`](#ebus/recommended)
65
- - [`ebus/all`](#ebus/all)
77
+ - `ebus/recommended`
78
+ - `ebus/all`
66
79
 
67
80
  ### Rules
68
81
 
@@ -117,9 +130,9 @@ Define authentication level.
117
130
 
118
131
  ##### Parameters
119
132
 
120
- | Name | Type | Description |
121
- | ----- | ----------------------- | ------------------------------------------ |
122
- | value | `valueof scalar string` | the authentication level (e.g. 'install'). |
133
+ | Name | Type | Description |
134
+ | ----- | ---------------- | ------------------------------------------ |
135
+ | value | `valueof string` | the authentication level (e.g. 'install'). |
123
136
 
124
137
  #### `@base`
125
138
 
@@ -135,11 +148,11 @@ Define the base message ID to be combined with an extension ID.
135
148
 
136
149
  ##### Parameters
137
150
 
138
- | Name | Type | Description |
139
- | ---- | ----------------------------- | ------------------------- |
140
- | pb | `valueof scalar Ebus.pb` | the primary message ID. |
141
- | sb | `valueof scalar Ebus.sb` | the secondary message ID. |
142
- | dd | `valueof model Ebus.symbol[]` | further message ID parts. |
151
+ | Name | Type | Description |
152
+ | ---- | ------------------- | ------------------------- |
153
+ | pb | [valueof `pb`](#pb) | the primary message ID. |
154
+ | sb | [valueof `sb`](#sb) | the secondary message ID. |
155
+ | dd | `valueof symbol[]` | further message ID parts. |
143
156
 
144
157
  #### `@chain`
145
158
 
@@ -155,11 +168,11 @@ Define chained message IDs.
155
168
 
156
169
  ##### Parameters
157
170
 
158
- | Name | Type | Description |
159
- | ------ | ------------------------------- | ------------------------------------------------------------------------------------------ |
160
- | length | `valueof scalar uint8` | the (maximum) length of a single message part of this chain, or 0 for default (=24). |
161
- | dd | `valueof model Ebus.symbol[]` | second message ID part the chain is built from (first one taken from id or ext decorator). |
162
- | dds | `valueof model Ebus.symbol[][]` | list of further message ID parts the chain is built from. |
171
+ | Name | Type | Description |
172
+ | ------ | -------------------- | ------------------------------------------------------------------------------------------ |
173
+ | length | `valueof uint8` | the (maximum) length of a single message part of this chain, or 0 for default (=24). |
174
+ | dd | `valueof symbol[]` | second message ID part the chain is built from (first one taken from id or ext decorator). |
175
+ | dds | `valueof symbol[][]` | list of further message ID parts the chain is built from. |
163
176
 
164
177
  #### `@condition`
165
178
 
@@ -172,14 +185,14 @@ This decorator and `@conditionExt` can be used multiple times to check that all
172
185
 
173
186
  ##### Target
174
187
 
175
- `union Namespace | Model | UnionVariant`
188
+ `Namespace | Model | UnionVariant`
176
189
 
177
190
  ##### Parameters
178
191
 
179
- | Name | Type | Description |
180
- | -------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
181
- | property | `union ModelProperty \| Model` | the referenced model property, or a model in case of existance check or single property only. |
182
- | values | `valueof model string[]` | the optional alternative values the property needs to match (one of the values must match for the condition to be met).<br />For numeric values, a single value (e.g. "18"), a value range separated by dash (e.g. "19-22"), or a value range with comparison (e.g. "<=5", ">10") can be used.<br />For string values, the value needs to be put in single quotes (e.g. 'abc'). |
192
+ | Name | Type | Description |
193
+ | -------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
194
+ | property | `ModelProperty \| Model` | the referenced model property, or a model in case of existance check or single property only. |
195
+ | values | `valueof string[]` | the optional alternative values the property needs to match (one of the values must match for the condition to be met).<br />For numeric values, a single value (e.g. "18"), a value range separated by dash (e.g. "19-22"), or a value range with comparison (e.g. "<=5", ">10") can be used.<br />For string values, the value needs to be put in single quotes (e.g. 'abc'). |
183
196
 
184
197
  #### `@conditionExt`
185
198
 
@@ -192,15 +205,15 @@ This decorator and `@condition` can be used multiple times to check that all con
192
205
 
193
206
  ##### Target
194
207
 
195
- `union Namespace | Model | UnionVariant`
208
+ `Namespace | Model | UnionVariant`
196
209
 
197
210
  ##### Parameters
198
211
 
199
- | Name | Type | Description |
200
- | -------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
201
- | property | `union ModelProperty \| Model` | the referenced model property, or a model in case of existance check or single property only. |
202
- | zz | `valueof scalar Ebus.target` | the target address ZZ. |
203
- | values | `valueof model string[]` | the optional alternative values the property needs to match (one of the values must match for the condition to be met).<br />For numeric values, a single value (e.g. "18"), a value range separated by dash (e.g. "19-22"), or a value range with comparison (e.g. "<=5", ">10") can be used.<br />For string values, the value needs to be put in single quotes (e.g. 'abc'). |
212
+ | Name | Type | Description |
213
+ | -------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
214
+ | property | `ModelProperty \| Model` | the referenced model property, or a model in case of existance check or single property only. |
215
+ | zz | [valueof `target`](#target) | the target address ZZ. |
216
+ | values | `valueof string[]` | the optional alternative values the property needs to match (one of the values must match for the condition to be met).<br />For numeric values, a single value (e.g. "18"), a value range separated by dash (e.g. "19-22"), or a value range with comparison (e.g. "<=5", ">10") can be used.<br />For string values, the value needs to be put in single quotes (e.g. 'abc'). |
204
217
 
205
218
  #### `@constValue`
206
219
 
@@ -212,13 +225,13 @@ Define the const value.
212
225
 
213
226
  ##### Target
214
227
 
215
- `union numeric | boolean | ModelProperty`
228
+ `numeric | boolean | ModelProperty`
216
229
 
217
230
  ##### Parameters
218
231
 
219
- | Name | Type | Description |
220
- | ----- | --------------------------------- | ---------------- |
221
- | value | `valueof union numeric \| string` | the const value. |
232
+ | Name | Type | Description |
233
+ | ----- | --------------------------- | ---------------- |
234
+ | value | `valueof numeric \| string` | the const value. |
222
235
 
223
236
  #### `@divisor`
224
237
 
@@ -230,13 +243,13 @@ Define the divisor.
230
243
 
231
244
  ##### Target
232
245
 
233
- `union numeric | plainTime | ModelProperty`
246
+ `numeric | plainTime | ModelProperty`
234
247
 
235
248
  ##### Parameters
236
249
 
237
- | Name | Type | Description |
238
- | ----- | ------------------------ | ------------ |
239
- | value | `valueof scalar numeric` | the divisor. |
250
+ | Name | Type | Description |
251
+ | ----- | ----------------- | ------------ |
252
+ | value | `valueof numeric` | the divisor. |
240
253
 
241
254
  #### `@example`
242
255
 
@@ -252,11 +265,11 @@ Define a data example.
252
265
 
253
266
  ##### Parameters
254
267
 
255
- | Name | Type | Description |
256
- | ---- | --------------------------------------- | ---------------------------------------------------------------------------- |
257
- | desc | `valueof scalar string` | a text describing the example. |
258
- | q | `valueof union string \| Ebus.symbol[]` | the query part of the message, i.e. pb, sb, and dd bytes sent to the target. |
259
- | a | `valueof union string \| Ebus.symbol[]` | the answer part of the message, i.e. dd bytes received from the target. |
268
+ | Name | Type | Description |
269
+ | ---- | ---------------------------- | ---------------------------------------------------------------------------- |
270
+ | desc | `valueof string` | a text describing the example. |
271
+ | q | `valueof string \| symbol[]` | the query part of the message, i.e. pb, sb, and dd bytes sent to the target. |
272
+ | a | `valueof string \| symbol[]` | the answer part of the message, i.e. dd bytes received from the target. |
260
273
 
261
274
  #### `@ext`
262
275
 
@@ -272,9 +285,9 @@ Define the extension message ID to be combined with a base ID.
272
285
 
273
286
  ##### Parameters
274
287
 
275
- | Name | Type | Description |
276
- | ---- | ----------------------------- | ---------------------------- |
277
- | dd | `valueof model Ebus.symbol[]` | message ID extensions parts. |
288
+ | Name | Type | Description |
289
+ | ---- | ------------------ | ---------------------------- |
290
+ | dd | `valueof symbol[]` | message ID extensions parts. |
278
291
 
279
292
  #### `@factor`
280
293
 
@@ -286,13 +299,13 @@ Define the factor.
286
299
 
287
300
  ##### Target
288
301
 
289
- `union numeric | plainTime | ModelProperty`
302
+ `numeric | plainTime | ModelProperty`
290
303
 
291
304
  ##### Parameters
292
305
 
293
- | Name | Type | Description |
294
- | ----- | ------------------------ | ----------- |
295
- | value | `valueof scalar numeric` | the factor. |
306
+ | Name | Type | Description |
307
+ | ----- | ----------------- | ----------- |
308
+ | value | `valueof numeric` | the factor. |
296
309
 
297
310
  #### `@id`
298
311
 
@@ -308,11 +321,11 @@ Define the whole message ID.
308
321
 
309
322
  ##### Parameters
310
323
 
311
- | Name | Type | Description |
312
- | ---- | ----------------------------- | ------------------------- |
313
- | pb | `valueof scalar Ebus.pb` | the primary message ID. |
314
- | sb | `valueof scalar Ebus.sb` | the secondary message ID. |
315
- | dd | `valueof model Ebus.symbol[]` | further message ID parts. |
324
+ | Name | Type | Description |
325
+ | ---- | ------------------- | ------------------------- |
326
+ | pb | [valueof `pb`](#pb) | the primary message ID. |
327
+ | sb | [valueof `sb`](#sb) | the secondary message ID. |
328
+ | dd | `valueof symbol[]` | further message ID parts. |
316
329
 
317
330
  #### `@in`
318
331
 
@@ -328,9 +341,9 @@ Define message part inbound from target.
328
341
 
329
342
  ##### Parameters
330
343
 
331
- | Name | Type | Description |
332
- | --------- | ------------------------ | ------------------------------------------------------------------------------------------------------------ |
333
- | writeOnly | `valueof scalar boolean` | optional true to put in only if write direction, false to put in only if read direction (alyways if absent). |
344
+ | Name | Type | Description |
345
+ | --------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |
346
+ | writeOnly | `valueof boolean` | optional true to put in only if write direction, false to put in only if read direction (alyways if absent). |
334
347
 
335
348
  #### `@inherit`
336
349
 
@@ -346,9 +359,9 @@ Define the inherited model(s).
346
359
 
347
360
  ##### Parameters
348
361
 
349
- | Name | Type | Description |
350
- | ------ | --------------- | ----------------- |
351
- | models | `model Model[]` | inherited models. |
362
+ | Name | Type | Description |
363
+ | ------ | --------- | ----------------- |
364
+ | models | `Model[]` | inherited models. |
352
365
 
353
366
  #### `@out`
354
367
 
@@ -364,9 +377,9 @@ Define message part outbound to target.
364
377
 
365
378
  ##### Parameters
366
379
 
367
- | Name | Type | Description |
368
- | --------- | ------------------------ | ------------------------------------------------------------------------------------------------------------ |
369
- | writeOnly | `valueof scalar boolean` | optional true to put in only if write direction, false to put in only if read direction (alyways if absent). |
380
+ | Name | Type | Description |
381
+ | --------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |
382
+ | writeOnly | `valueof boolean` | optional true to put in only if write direction, false to put in only if read direction (alyways if absent). |
370
383
 
371
384
  #### `@passive`
372
385
 
@@ -398,9 +411,9 @@ Define the poll priority (only for active read).
398
411
 
399
412
  ##### Parameters
400
413
 
401
- | Name | Type | Description |
402
- | ----- | ---------------------- | ------------------------------------ |
403
- | value | `valueof scalar uint8` | the poll priority (between 1 and 9). |
414
+ | Name | Type | Description |
415
+ | ----- | --------------- | ------------------------------------ |
416
+ | value | `valueof uint8` | the poll priority (between 1 and 9). |
404
417
 
405
418
  #### `@qq`
406
419
 
@@ -416,9 +429,9 @@ Define the source address.
416
429
 
417
430
  ##### Parameters
418
431
 
419
- | Name | Type | Description |
420
- | ----- | ---------------------------- | ---------------------- |
421
- | value | `valueof scalar Ebus.source` | the source address QQ. |
432
+ | Name | Type | Description |
433
+ | ----- | --------------------------- | ---------------------- |
434
+ | value | [valueof `source`](#source) | the source address QQ. |
422
435
 
423
436
  #### `@step`
424
437
 
@@ -430,13 +443,13 @@ Define the increment/decrement step value (useful in combination with `@minValue
430
443
 
431
444
  ##### Target
432
445
 
433
- `union numeric | ModelProperty`
446
+ `numeric | ModelProperty`
434
447
 
435
448
  ##### Parameters
436
449
 
437
- | Name | Type | Description |
438
- | ----- | ------------------------ | ----------------------------------- |
439
- | value | `valueof scalar numeric` | the increment/decrement step value. |
450
+ | Name | Type | Description |
451
+ | ----- | ----------------- | ----------------------------------- |
452
+ | value | `valueof numeric` | the increment/decrement step value. |
440
453
 
441
454
  #### `@unit`
442
455
 
@@ -448,13 +461,13 @@ Define the unit.
448
461
 
449
462
  ##### Target
450
463
 
451
- `union numeric | ModelProperty`
464
+ `numeric | ModelProperty`
452
465
 
453
466
  ##### Parameters
454
467
 
455
- | Name | Type | Description |
456
- | ----- | ----------------------- | ----------- |
457
- | value | `valueof scalar string` | the unit. |
468
+ | Name | Type | Description |
469
+ | ----- | ---------------- | ----------- |
470
+ | value | `valueof string` | the unit. |
458
471
 
459
472
  #### `@values`
460
473
 
@@ -466,7 +479,7 @@ Define the known values.
466
479
 
467
480
  ##### Target
468
481
 
469
- `union numeric | boolean | ModelProperty`
482
+ `numeric | boolean | ModelProperty`
470
483
 
471
484
  ##### Parameters
472
485
 
@@ -488,9 +501,9 @@ Define write direction.
488
501
 
489
502
  ##### Parameters
490
503
 
491
- | Name | Type | Description |
492
- | -------- | ------------------------ | ------------------------------------------------------------------------------------------- |
493
- | toSource | `valueof scalar boolean` | true to use the source address pendant of the target address instead of the target address. |
504
+ | Name | Type | Description |
505
+ | -------- | ----------------- | ------------------------------------------------------------------------------------------- |
506
+ | toSource | `valueof boolean` | true to use the source address pendant of the target address instead of the target address. |
494
507
 
495
508
  #### `@zz`
496
509
 
@@ -502,13 +515,13 @@ Define the target address.
502
515
 
503
516
  ##### Target
504
517
 
505
- `union Model | Namespace`
518
+ `Model | Namespace`
506
519
 
507
520
  ##### Parameters
508
521
 
509
- | Name | Type | Description |
510
- | ----- | ---------------------------- | ---------------------- |
511
- | value | `valueof scalar Ebus.target` | the target address ZZ. |
522
+ | Name | Type | Description |
523
+ | ----- | --------------------------- | ---------------------- |
524
+ | value | [valueof `target`](#target) | the target address ZZ. |
512
525
 
513
526
  ### Ebus.Internal
514
527
 
@@ -559,13 +572,13 @@ Define the max bits.
559
572
 
560
573
  ##### Target
561
574
 
562
- `scalar numeric`
575
+ `numeric`
563
576
 
564
577
  ##### Parameters
565
578
 
566
- | Name | Type | Description |
567
- | ----- | ---------------------- | ------------- |
568
- | value | `valueof scalar uint8` | the max bits. |
579
+ | Name | Type | Description |
580
+ | ----- | --------------- | ------------- |
581
+ | value | `valueof uint8` | the max bits. |
569
582
 
570
583
  #### `@reverse`
571
584
 
package/lib/models.tsp CHANGED
@@ -6,6 +6,7 @@ using Ebus.Str;
6
6
 
7
7
  namespace Id {
8
8
 
9
+ /** known manufacturer IDs */
9
10
  enum Values_manufacturers {
10
11
  Dungs: 0x06,
11
12
  "FH Ostfalia": 0x0f,
@@ -36,6 +37,7 @@ namespace Id {
36
37
  // Pb, // <= this is how to declare the base type as it seems for unions, see https://github.com/microsoft/typespec/issues/2737
37
38
  }
38
39
 
40
+ /** manufacturer ID */
39
41
  @values(Values_manufacturers)
40
42
  scalar manufacturer extends UCH;
41
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebusd/ebus-typespec",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "author": "John Baier",
5
5
  "description": "TypeSpec library for defining eBUS messages and emitting to ebusd CSV.",
6
6
  "homepage": "https://github.com/john30/ebus-typespec",
@@ -23,7 +23,8 @@
23
23
  "exports": {
24
24
  ".": {
25
25
  "types": "./dist/src/index.d.ts",
26
- "default": "./dist/src/index.js"
26
+ "default": "./dist/src/index.js",
27
+ "typespec": "./lib/main.tsp"
27
28
  },
28
29
  "./testing": {
29
30
  "types": "./dist/src/testing/index.d.ts",
@@ -43,20 +44,20 @@
43
44
  "*.md"
44
45
  ],
45
46
  "peerDependencies": {
46
- "@typespec/compiler": "^1.0.0"
47
+ "@typespec/compiler": "^1.4.0"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/js-yaml": "^4.0.9",
50
51
  "@types/node": "latest",
51
- "@typespec/compiler": "^1.0.0",
52
- "@typespec/library-linter": "~0.70.0",
52
+ "@typespec/compiler": "^1.4.0",
53
+ "@typespec/library-linter": "~0.74.0",
53
54
  "@typespec/tspd": "latest",
54
- "typedoc": "^0.28.4",
55
- "typedoc-plugin-markdown": "^4.6.3",
56
- "typescript": "^5.8.3"
55
+ "typedoc": "^0.28.13",
56
+ "typedoc-plugin-markdown": "^4.9.0",
57
+ "typescript": "^5.9.2"
57
58
  },
58
59
  "dependencies": {
59
- "@typespec/asset-emitter": "^0.70.1",
60
+ "@typespec/asset-emitter": "^0.74.0",
60
61
  "js-yaml": "^4.1.0"
61
62
  },
62
63
  "scripts": {
@@ -64,6 +65,6 @@
64
65
  "watch": "tsc --watch",
65
66
  "build:tsp": "tsp compile . --warn-as-error --import @typespec/library-linter --no-emit && chmod a+x dist/src/tsp2ebusd.js",
66
67
  "test": "node --test --test-force-exit ./dist/test/*.test.js",
67
- "docs": "sed -i -e 's# *hideInPageTOC: true,##' node_modules/@typespec/tspd/dist/src/ref-doc/api-docs.js; npx tspd doc --enable-experimental . && mv README.md docs.md && rm -rf docs && git checkout README.md"
68
+ "docs": "npx tspd doc --enable-experimental --skip-js . && mv README.md docs.md && rm -rf docs && git checkout README.md && sed -i -e 's/^## Usage/## Linter usage/' -e 's/^## Rule/### Rule/' docs.md"
68
69
  }
69
70
  }