@dusted/anqst 0.1.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.
@@ -0,0 +1,217 @@
1
+ /**
2
+ * AnQst-Spec Language - Canonical source of truth for the language.
3
+ *
4
+ * @remarks
5
+ * - DSL for Widget generation, transported as TypeScript definition.
6
+ * - For AnQSt Widget Specifications only.
7
+ * - Exactly one toplevel namespace must be declared: It names the Widget.
8
+ * - Service interfaces are optional. Namespace-local type declarations are valid generation roots.
9
+ * - Imported/external types are generation-relevant when transitively reachable from namespace declarations.
10
+ * - This is not an input file to the generator, it is the description of the language that describes the widget.
11
+ * Not for use by TypeScript application implementation.
12
+ * @example
13
+ * package.json:
14
+ * - "AnQst": { "WidgetSpec": "MyUserMgmtWidget.AnQstSpec.d.ts" }
15
+ */
16
+
17
+ export namespace AnQst {
18
+
19
+ /**
20
+ * Declare service `InterfaceName`
21
+ *
22
+ * @remarks
23
+ * Multiple allowed.
24
+ * Affords developers of advanced widgets the ability to create domain-informed categories.
25
+ * - Duplicate method declarations with identical parameter lists are invalid in normative AnQst-Spec input.
26
+ *
27
+ * @example
28
+ * export interface UserService extends Widget.Service { }
29
+ * // Generates UserService.
30
+ */
31
+ interface Service { }
32
+
33
+ /**
34
+ * Declare service `InterfaceName` as development-mode capable transport service.
35
+ *
36
+ * @remarks
37
+ * - Extends the same method/property semantics as `AnQst.Service`.
38
+ * - Signals to the generator/runtime that this widget should emit dual-transport bridge support
39
+ * (Qt WebChannel + HTTP/WebSocket development bridge).
40
+ * - Existing generated service APIs remain unchanged.
41
+ *
42
+ * @example
43
+ * export interface UserService extends AnQst.AngularHTTPBaseServerClass { }
44
+ */
45
+ interface AngularHTTPBaseServerClass extends Service { }
46
+
47
+
48
+ /**
49
+ * Declare non-blocking service method `MethodName`(`MethodArguments`): Promise<`MethodReturnType`>.
50
+ * @remarks
51
+ * - **Widget** -> Parent
52
+ * - Flow:
53
+ * - Widget: Call to service method `MethodName`(`MethodArguments`).
54
+ * - Widget: Returns Promise<`MethodReturnType`>.
55
+ * - Parent: Registered `MethodReturnType` `MethodName`_Handler(`MethodArguments`) is called.
56
+ * - Parent: Handler returns result.
57
+ * - Widget: Promise resolves with result.
58
+ * @example
59
+ * // AnQst spec:
60
+ * getUserById(userId: string): AnQst.Call<User>
61
+ * //Angular app:
62
+ * const user: User = await this.userService.getUserById("abc");
63
+ */
64
+ interface Call<T> { dummy: T }
65
+
66
+ /**
67
+ * Declare blocking service method onSlot.`MethodName`( handler(`MethodArguments`):`MethodReturnType` ): void
68
+ * @remarks
69
+ * - **Parent** -> Widget
70
+ * - Impl note: Autogenerated stub handler queues until handler is set (set method calls spools queue through handler)
71
+ * - Flow:
72
+ * - Parent: Call to generated widget method `MethodName`(`MethodArguments`).
73
+ * - Widget: Registered handler(`MethodArguments`): `MethodReturnType` is called.
74
+ * - Widget: Handler returns result.
75
+ * - Parent: `MethodName` call returns with result.
76
+ * Note: One active handler, calling will replace existing and is valid and allowed.
77
+ * @example
78
+ * // AnQst spec:
79
+ * getUsernameSubstring(from: number, to:number ): AnQst.Slot<string>
80
+ * //Angular app:
81
+ * this.userService.onSlot.getUsername( provider );
82
+ * //Parent:
83
+ * auto currentFormUsername = userMgmt.getUsername();
84
+ */
85
+ interface Slot<T> { dummy: T }
86
+
87
+
88
+
89
+ /**
90
+ * Declare message emission method `MethodName`(`MethodArguments`): void
91
+ * @remarks
92
+ * - **Widget** -> ?Parent
93
+ * True Qt signal semantics (Message is emitted, no return path, no registration requirement)
94
+ * - Flow:
95
+ * - Widget: Call to service method `MethodName`(`MethodArguments`).
96
+ * - Widget: Returns void.
97
+ * - Parent: Might have something connected to the signal, might not.
98
+ * @example
99
+ * // AnQst spec:
100
+ * complain(whine: string): AnQst.Emitter;
101
+ * //Angular app:
102
+ * this.userService.complain("Why won't you LISTEN!");
103
+ */
104
+ interface Emitter { }
105
+
106
+
107
+ /**
108
+ * Declare reactive `PropertyName`:`OutputType` and set.`PropertyName`(arg: `OutputType`)
109
+ * @remarks
110
+ * - **Parent** -> Widget
111
+ * True Angular signal semantics (Property updates, signal emits, no return path, no registration requirement)
112
+ * - Flow:
113
+ * - Parent: Sets generated widget property `PropertyName`.
114
+ * - Widget: Service updates readonly property `PropertyName` and emits signal.
115
+ * @example
116
+ * // AnQst spec:
117
+ * activeUsers: AnQst.Output<number>;
118
+ * //Angular app template:
119
+ * <p>{{ userService.activeUsers() }}</p>
120
+ * //Parent:
121
+ * int users = userMgmt.activeUsers;
122
+ * userMgmt.activeUsers = 99;
123
+ */
124
+ interface Output<OutputType> {}
125
+
126
+
127
+ /**
128
+ * Declare Input bindable set.`PropertyName`(input:`InputType`): void and `PropertyName`:`InputType`
129
+ * @remarks
130
+ * - **Widget** -> Parent
131
+ * - Convenience method, for symmetry with Output.
132
+ * - Flow:
133
+ * - Widget: Calls service set.`PropertyName`(`InputType`) to publish current value.
134
+ * - Parent: Mirrored generated widget property `PropertyName` is updated and emits change notification.
135
+ * @example
136
+ * // AnQst spec:
137
+ * currentUsername: AnQst.Input<string>;
138
+ * //Angular app template:
139
+ * <input type="text" placeholder="Your Name Here" (input)="userService.set.currentUsername(($event.target as HTMLInputElement).value)" />
140
+ * //Parent:
141
+ * QString userName = userMgmt.currentUsername;
142
+ */
143
+ interface Input<InputType> {}
144
+
145
+ /**
146
+ * AnQst-Spec type mapping overview and control.
147
+ *
148
+ * @remarks
149
+ * Any Type that be mapped between TypeScript and Qt, C++ standard types or
150
+ * Plain Old Data (POD) types (in that order of preference) will be mapped by default.
151
+ *
152
+ * Canonical mapping directive namespace is AnQst.Type.<type>.
153
+ * To express advisory mapping preference, use AnQst.Type.<type>.
154
+ * Advisory means generator SHOULD honor it, but MAY fall back to inferred/default mapping and emit diagnostic.
155
+ * Array forms are equivalent: T[] == Array<T>, and AnQst.Type.X[] == Array<AnQst.Type.X>.
156
+ *
157
+ * TypeScript definitions+classes and C++ structs are generated for each
158
+ * structured TypeScript type ( type = {...} or interface { ... } )
159
+ * referenced in an AnQst spec.
160
+ *
161
+ */
162
+ enum Type {
163
+ object = "JavaScript Object <-> QVariantMap (JSON.stringify/parse semantics)",
164
+ json = "JavaScript Object <-> QJsonObject (JSON.stringify/parse semantics)",
165
+ string = "JavaScript String <-> QString",
166
+ stringArray = "JavaScript String[] <-> QStringList",
167
+ number = "JavaScript Number <-> double",
168
+ qint64 = "JavaScript BigInt <-> qint64 (Default, for symmetry, same as direct use of <BigInt> which is allowed.)",
169
+ quint64 = "JavaScript BigInt <-> quint64",
170
+ qint32 = "JavaScript Number <-> qint32",
171
+ quint32 = "JavaScript Number <-> quint32",
172
+ qint16 = "JavaScript Number <-> qint16",
173
+ quint16 = "JavaScript Number <-> quint16",
174
+ qint8 = "JavaScript Number <-> qint8",
175
+ quint8 = "JavaScript Number <-> quint8",
176
+ int32 = "JavaScript Number <-> int32_t",
177
+ uint32 = "JavaScript Number <-> uint32_t",
178
+ int16 = "JavaScript Number <-> int16_t",
179
+ uint16 = "JavaScript Number <-> uint16_t",
180
+ int8 = "JavaScript Number <-> int8_t",
181
+ uint8 = "JavaScript Number <-> uint8_t",
182
+ buffer = "JavaScript ArrayBuffer <-> QByteArray (Default, for symmetry, same as direct use of <ArrayBuffer> which is allowed.)",
183
+ blob = "JavaScript ArrayBuffer <-> QByteArray",
184
+ typedArray = "JavaScript TypedArray <-> QByteArray",
185
+ uint8Array = "JavaScript Uint8Array <-> QByteArray",
186
+ int8Array = "JavaScript Int8Array <-> QByteArray",
187
+ uint16Array = "JavaScript Uint16Array <-> QByteArray",
188
+ int16Array = "JavaScript Int16Array <-> QByteArray",
189
+ uint32Array = "JavaScript Uint32Array <-> QByteArray",
190
+ int32Array = "JavaScript Int32Array <-> QByteArray",
191
+ float32Array = "JavaScript Float32Array <-> QByteArray",
192
+ float64Array = "JavaScript Float64Array <-> QByteArray",
193
+ }
194
+
195
+
196
+ /**
197
+ * These are explicitly forbidden argument/return types.
198
+ *
199
+ * @remarks
200
+ * - They may not be referenced in AnQst specs or imported types.
201
+ * - Service methods cannot accept them as arguments
202
+ * - Service methods cannot return them.
203
+ * - Service properties of their type cannot be declared.
204
+ *
205
+ * - For Objects/Maps/Sets use AnQst.Type.<Type> instead.
206
+ */
207
+ export enum ForbiddenType {
208
+ Function = "Passing callbacks across the boundary is not allowed.",
209
+ Class = "Passing classes across the boundary is not allowed.",
210
+ Type = "Passing types across the boundary is not allowed.",
211
+ Promise = "Passing Promises across the boundary is not allowed",
212
+ Callable = "Passing Callable objects across the boundary is not allowed",
213
+ any = "Passing 'any' type across the boundary is not allowed",
214
+ }
215
+
216
+ }
217
+