@girs/uhm-1.0 0.9.0-4.0.0-beta.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.
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+
2
+ # Uhm-1.0
3
+
4
+ ![version](https://img.shields.io/npm/v/@girs/uhm-1.0)
5
+ ![downloads/week](https://img.shields.io/npm/dw/@girs/uhm-1.0)
6
+
7
+
8
+ GJS TypeScript type definitions for Uhm-1.0, generated from library version 0.9.0 using [ts-for-gir](https://github.com/gjsify/ts-for-gir) v4.0.0-beta.1.
9
+
10
+
11
+ ## Install
12
+
13
+ To use this type definitions, install them with NPM:
14
+ ```bash
15
+ npm install @girs/uhm-1.0
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ You can import this package into your project like this:
21
+ ```ts
22
+ import Uhm from '@girs/uhm-1.0';
23
+ ```
24
+
25
+ Or if you prefer CommonJS, you can also use this:
26
+ ```ts
27
+ const Uhm = require('@girs/uhm-1.0');
28
+ ```
29
+
30
+ ### Ambient Modules
31
+
32
+ You can also use [ambient modules](https://github.com/gjsify/ts-for-gir/tree/main/packages/cli#ambient-modules) to import this module like you would do this in JavaScript.
33
+ For this you need to include `@girs/uhm-1.0` or `@girs/uhm-1.0/ambient` in your `tsconfig` or entry point Typescript file:
34
+
35
+ `index.ts`:
36
+ ```ts
37
+ import '@girs/uhm-1.0'
38
+ ```
39
+
40
+ `tsconfig.json`:
41
+ ```json
42
+ {
43
+ "compilerOptions": {
44
+ ...
45
+ },
46
+ "include": ["@girs/uhm-1.0"],
47
+ ...
48
+ }
49
+ ```
50
+
51
+ Now you can import the ambient module with TypeScript support:
52
+
53
+ ```ts
54
+ import Uhm from 'gi://Uhm?version=1.0';
55
+ ```
56
+
57
+ ### Global import
58
+
59
+ You can also import the module with Typescript support using the global `imports.gi` object of GJS.
60
+ For this you need to include `@girs/uhm-1.0` or `@girs/uhm-1.0/import` in your `tsconfig` or entry point Typescript file:
61
+
62
+ `index.ts`:
63
+ ```ts
64
+ import '@girs/uhm-1.0'
65
+ ```
66
+
67
+ `tsconfig.json`:
68
+ ```json
69
+ {
70
+ "compilerOptions": {
71
+ ...
72
+ },
73
+ "include": ["@girs/uhm-1.0"],
74
+ ...
75
+ }
76
+ ```
77
+
78
+ Now you have also type support for this, too:
79
+
80
+ ```ts
81
+ const Uhm = imports.gi.Uhm;
82
+ ```
83
+
84
+
85
+ ### ESM vs. CommonJS
86
+
87
+ GJS supports two different import syntaxes. The new modern ESM syntax and the old global imports syntax.
88
+
89
+ In TypeScript projects for GJS and GNOME Shell extensions, you have the flexibility to use `ESM` syntax and then decide the import syntax for your bundled file. If your bundler is configured to use `CommonJS`, it will convert to the GJS-specific global imports syntax, like `const moduleName = imports.gi[moduleName]`. This is different from the traditional `require` syntax seen in Node.js. The global imports syntax is chosen because it aligns with the CommonJS format supported by NPM, which is used for the generated type definitions and this package.
90
+
91
+ On the other hand, if you configure your bundler to use ESM, it will retain the ESM import syntax. It's crucial to ensure that your bundler is set up to correctly translate and bundle these imports into either CommonJS or ESM format, depending on your project's requirements.
92
+
93
+ This approach is particularly important due to the `@girs` types, which include both `*.cjs `files, using the GJS global imports syntax, and `*.js` files, which utilize the ESM syntax. By appropriately setting up your bundler, you can control which syntax—CommonJS or ESM—is used in your project. The choice of CommonJS in this context is also due to the similarity between the GJS-specific global imports and CommonJS syntax, allowing for easier management and bundling in these specific types of projects.
94
+
95
+ Since GNOME Shell 45, you should only use ESM, even for GNOME Shell extensions. Before that, extensions had to use the global import syntax, unlike normal GJS applications, where ESM has been available for some time.
96
+
97
+ ### Bundle
98
+
99
+ Depending on your project configuration, it is recommended to use a bundler like [esbuild](https://esbuild.github.io/). You can find examples using different bundlers [here](https://github.com/gjsify/ts-for-gir/tree/main/examples).
100
+
101
+ ## Other packages
102
+
103
+ All existing pre-generated packages can be found on [gjsify/types](https://github.com/gjsify/types).
104
+
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@girs/uhm-1.0",
3
+ "version": "0.9.0-4.0.0-beta.1",
4
+ "description": "GJS TypeScript type definitions for Uhm-1.0, generated from library version 0.9.0",
5
+ "type": "module",
6
+ "module": "uhm-1.0.js",
7
+ "main": "uhm-1.0.js",
8
+ "exports": {
9
+ "./ambient": {
10
+ "types": "./uhm-1.0-ambient.d.ts",
11
+ "import": "./uhm-1.0-ambient.js",
12
+ "default": "./uhm-1.0-ambient.js"
13
+ },
14
+ "./import": {
15
+ "types": "./uhm-1.0-import.d.ts",
16
+ "import": "./uhm-1.0-import.js",
17
+ "default": "./uhm-1.0-import.js"
18
+ },
19
+ ".": {
20
+ "types": "./uhm-1.0.d.ts",
21
+ "import": "./uhm-1.0.js",
22
+ "default": "./uhm-1.0.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "test": "NODE_OPTIONS=--max_old_space_size=9216 tsc --noEmit uhm-1.0.d.ts"
27
+ },
28
+ "dependencies": {
29
+ "@girs/gio-2.0": "^2.77.0-4.0.0-beta.1",
30
+ "@girs/gjs": "^4.0.0-beta.1",
31
+ "@girs/glib-2.0": "^2.77.0-4.0.0-beta.1",
32
+ "@girs/gobject-2.0": "^2.77.0-4.0.0-beta.1",
33
+ "@girs/soup-3.0": "^3.4.2-4.0.0-beta.1"
34
+ },
35
+ "devDependencies": {
36
+ "typescript": "*"
37
+ },
38
+ "keywords": [
39
+ "Gir",
40
+ "TypeScript",
41
+ "types",
42
+ "GObject-Introspection",
43
+ "GJS",
44
+ "Uhm-1.0"
45
+ ],
46
+ "author": "ts-for-gir",
47
+ "license": "MIT",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/gjsify/ts-for-gir.git"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/gjsify/ts-for-gir/issues"
54
+ },
55
+ "homepage": "https://github.com/gjsify/types/tree/main/uhm-1.0#readme"
56
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ // General settings for code interpretation
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "lib": ["ESNext"],
7
+ "types": [],
8
+ "experimentalDecorators": true,
9
+ "moduleResolution": "node",
10
+ "noEmit": true,
11
+ "noEmitOnError": false,
12
+ "baseUrl": "./",
13
+ "rootDir": ".",
14
+ // General settings for code generation
15
+ "removeComments": false,
16
+ "inlineSourceMap": false,
17
+ "inlineSources": false,
18
+ "newLine": "LF"
19
+ },
20
+ "include": ["./uhm-1.0.d.ts"]
21
+ }
22
+
23
+
package/typedoc.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "entryPoints": ["./uhm-1.0.d.ts"],
3
+ "readme": "./README.md",
4
+ "name": "Uhm-1.0",
5
+ "tsconfig": "./tsconfig.json"
6
+ }
7
+
@@ -0,0 +1,12 @@
1
+
2
+ declare module 'gi://Uhm?version=1.0' {
3
+ import Uhm from '@girs/uhm-1.0';
4
+ export default Uhm;
5
+ }
6
+
7
+ declare module 'gi://Uhm' {
8
+ import Uhm10 from 'gi://Uhm?version=1.0';
9
+ export default Uhm10;
10
+ }
11
+
12
+
@@ -0,0 +1,2 @@
1
+ export {}
2
+
@@ -0,0 +1,12 @@
1
+
2
+ import Uhm10 from '@girs/uhm-1.0';
3
+
4
+ declare global {
5
+ export interface GjsGiImports {
6
+ Uhm: typeof Uhm10;
7
+ }
8
+ }
9
+
10
+ export default GjsGiImports;
11
+
12
+
@@ -0,0 +1,3 @@
1
+ const gi = globalThis.imports?.gi || {};
2
+ export default gi;
3
+
package/uhm-1.0.d.ts ADDED
@@ -0,0 +1,604 @@
1
+ /*
2
+ * Type Definitions for Gjs (https://gjs.guide/)
3
+ *
4
+ * These type definitions are automatically generated, do not edit them by hand.
5
+ * If you found a bug fix it in `ts-for-gir` or create a bug report on https://github.com/gjsify/ts-for-gir
6
+ */
7
+
8
+ import './uhm-1.0-ambient.d.ts';
9
+
10
+ /**
11
+ * Uhm-1.0
12
+ */
13
+
14
+ import type Soup from '@girs/soup-3.0';
15
+ import type Gio from '@girs/gio-2.0';
16
+ import type GObject from '@girs/gobject-2.0';
17
+ import type GLib from '@girs/glib-2.0';
18
+
19
+ export namespace Uhm {
20
+ /**
21
+ * Error codes for #UhmServer operations.
22
+ */
23
+ enum ServerError {
24
+ /**
25
+ * In comparison mode, a message received from the client did not match the next message in the current trace file.
26
+ */
27
+ SERVER_ERROR_MESSAGE_MISMATCH,
28
+ }
29
+ /**
30
+ * Evaluates to the major version of the libuhttpmock headers at compile time.
31
+ * (e.g. in libuhttpmock version 1.2.3 this is 1).
32
+ */
33
+ const MAJOR_VERSION: number;
34
+ /**
35
+ * Evaluates to the micro version of the libuhttpmock headers at compile time.
36
+ * (e.g. in libuhttpmock version 1.2.3 this is 3).
37
+ */
38
+ const MICRO_VERSION: number;
39
+ /**
40
+ * Evaluates to the minor version of the libuhttpmock headers at compile time.
41
+ * (e.g. in libuhttpmock version 1.2.3 this is 2).
42
+ */
43
+ const MINOR_VERSION: number;
44
+ module Message {
45
+ // Constructor properties interface
46
+
47
+ interface ConstructorProps extends GObject.Object.ConstructorProps {
48
+ method: string;
49
+ uri: GLib.Uri;
50
+ }
51
+ }
52
+
53
+ class Message extends GObject.Object {
54
+ static $gtype: GObject.GType<Message>;
55
+
56
+ // Own properties of Uhm.Message
57
+
58
+ get method(): string;
59
+ set method(val: string);
60
+ get uri(): GLib.Uri;
61
+ set uri(val: GLib.Uri);
62
+
63
+ // Constructors of Uhm.Message
64
+
65
+ constructor(properties?: Partial<Message.ConstructorProps>, ...args: any[]);
66
+
67
+ _init(...args: any[]): void;
68
+
69
+ // Own methods of Uhm.Message
70
+
71
+ get_http_version(): Soup.HTTPVersion;
72
+ get_method(): string;
73
+ get_reason_phrase(): string;
74
+ get_request_body(): Soup.MessageBody;
75
+ get_request_headers(): Soup.MessageHeaders;
76
+ get_response_body(): Soup.MessageBody;
77
+ get_response_headers(): Soup.MessageHeaders;
78
+ get_status(): number;
79
+ get_uri(): GLib.Uri;
80
+ set_http_version(version: Soup.HTTPVersion): void;
81
+ set_status(status: number, reason_phrase: string): void;
82
+ }
83
+
84
+ module Resolver {
85
+ // Constructor properties interface
86
+
87
+ interface ConstructorProps extends Gio.Resolver.ConstructorProps {}
88
+ }
89
+
90
+ /**
91
+ * All the fields in the #UhmResolver structure are private and should never be accessed directly.
92
+ */
93
+ class Resolver extends Gio.Resolver {
94
+ static $gtype: GObject.GType<Resolver>;
95
+
96
+ // Constructors of Uhm.Resolver
97
+
98
+ constructor(properties?: Partial<Resolver.ConstructorProps>, ...args: any[]);
99
+
100
+ _init(...args: any[]): void;
101
+
102
+ static ['new'](): Resolver;
103
+
104
+ // Own methods of Uhm.Resolver
105
+
106
+ /**
107
+ * Adds a resolution mapping from the host name `hostname` to the IP address `addr`.
108
+ * @param hostname the hostname to match
109
+ * @param addr the IP address to resolve to
110
+ * @returns %TRUE on success; %FALSE otherwise
111
+ */
112
+ add_A(hostname: string, addr: string): boolean;
113
+ /**
114
+ * Adds a resolution mapping the given `service` (on `protocol` and `domain)` to the IP address `addr` and given `port`.
115
+ * @param service the service name to match
116
+ * @param protocol the protocol name to match
117
+ * @param domain the domain name to match
118
+ * @param addr the IP address to resolve to
119
+ * @param port the port to resolve to
120
+ * @returns %TRUE on success; %FALSE otherwise
121
+ */
122
+ add_SRV(service: string, protocol: string, domain: string, addr: string, port: number): boolean;
123
+ /**
124
+ * Resets the state of the #UhmResolver, deleting all records added with uhm_resolver_add_A() and uhm_resolver_add_SRV().
125
+ */
126
+ reset(): void;
127
+ }
128
+
129
+ module Server {
130
+ // Signal callback interfaces
131
+
132
+ interface CompareMessages {
133
+ (expected_message: Message, actual_message: Message): boolean;
134
+ }
135
+
136
+ interface HandleMessage {
137
+ (message: Message): boolean;
138
+ }
139
+
140
+ // Constructor properties interface
141
+
142
+ interface ConstructorProps extends GObject.Object.ConstructorProps {
143
+ address: string;
144
+ enable_logging: boolean;
145
+ enableLogging: boolean;
146
+ enable_online: boolean;
147
+ enableOnline: boolean;
148
+ port: number;
149
+ resolver: Resolver;
150
+ tls_certificate: Gio.TlsCertificate;
151
+ tlsCertificate: Gio.TlsCertificate;
152
+ trace_directory: Gio.File;
153
+ traceDirectory: Gio.File;
154
+ }
155
+ }
156
+
157
+ /**
158
+ * All the fields in the #UhmServer structure are private and should never be accessed directly.
159
+ */
160
+ class Server extends GObject.Object {
161
+ static $gtype: GObject.GType<Server>;
162
+
163
+ // Own properties of Uhm.Server
164
+
165
+ /**
166
+ * Address of the local mock server if it's running, or %NULL otherwise. This will be non-%NULL between calls to uhm_server_run() and
167
+ * uhm_server_stop(). The address is a physical IP address, e.g. <code class="literal">127.0.0.1</code>.
168
+ *
169
+ * This should not normally need to be passed into client code under test, unless the code references IP addresses specifically. The mock server
170
+ * runs a DNS resolver which automatically redirects client requests for known domain names to this address (#UhmServer:resolver).
171
+ */
172
+ get address(): string;
173
+ /**
174
+ * %TRUE if network traffic should be logged to a trace file (specified by calling uhm_server_start_trace()). This operates independently
175
+ * of whether traffic is online or being handled locally by the mock server.
176
+ * Use this in conjunction with #UhmServer:enable-online to either log online traffic, or replay logged traffic locally.
177
+ */
178
+ get enable_logging(): boolean;
179
+ set enable_logging(val: boolean);
180
+ /**
181
+ * %TRUE if network traffic should be logged to a trace file (specified by calling uhm_server_start_trace()). This operates independently
182
+ * of whether traffic is online or being handled locally by the mock server.
183
+ * Use this in conjunction with #UhmServer:enable-online to either log online traffic, or replay logged traffic locally.
184
+ */
185
+ get enableLogging(): boolean;
186
+ set enableLogging(val: boolean);
187
+ /**
188
+ * %TRUE if network traffic should reach the Internet as normal; %FALSE to redirect it to the local mock server.
189
+ * Use this in conjunction with #UhmServer:enable-logging to either log online traffic, or replay logged traffic locally.
190
+ */
191
+ get enable_online(): boolean;
192
+ set enable_online(val: boolean);
193
+ /**
194
+ * %TRUE if network traffic should reach the Internet as normal; %FALSE to redirect it to the local mock server.
195
+ * Use this in conjunction with #UhmServer:enable-logging to either log online traffic, or replay logged traffic locally.
196
+ */
197
+ get enableOnline(): boolean;
198
+ set enableOnline(val: boolean);
199
+ /**
200
+ * Port of the local mock server if it's running, or <code class="literal">0</code> otherwise. This will be non-<code class="literal">0</code> between
201
+ * calls to uhm_server_run() and uhm_server_stop().
202
+ *
203
+ * It is intended that this port be passed into the client code under test, to substitute for the default HTTPS port (443) which it would otherwise
204
+ * use.
205
+ */
206
+ get port(): number;
207
+ /**
208
+ * Mock resolver used to redirect HTTP requests from specified domain names to the local mock server instance. This will always be set while the
209
+ * server is running (between calls to uhm_server_run() and uhm_server_stop()), and is %NULL otherwise.
210
+ *
211
+ * Use the resolver specified in this property to add domain names which are expected to be requested by the current trace. Domain names not added
212
+ * to the resolver will be rejected by the mock server. The set of domain names in the resolver will be reset when uhm_server_stop() is
213
+ * called.
214
+ */
215
+ get resolver(): Resolver;
216
+ /**
217
+ * TLS certificate for the mock server to use when serving HTTPS pages. If this is non-%NULL, the server will always use HTTPS. If it is %NULL,
218
+ * the server will always use HTTP. The TLS certificate may be changed after constructing the #UhmServer, but changes to the property will not
219
+ * take effect until the next call to uhm_server_run().
220
+ *
221
+ * A certificate and private key may be generated by executing:
222
+ * <code>openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -nodes</code>. These files may then be used to construct a
223
+ * #GTlsCertificate by calling g_tls_certificate_new_from_files().
224
+ *
225
+ * Alternatively, a default #GTlsCertificate which wraps a dummy certificate (not signed by any certificate authority) may be set by
226
+ * calling uhm_server_set_default_tls_certificate(). This may be used as the #UhmServer:tls-certificate if the code under test has no specific
227
+ * requirements of the certificate used by the mock server it's tested against.
228
+ */
229
+ get tls_certificate(): Gio.TlsCertificate;
230
+ set tls_certificate(val: Gio.TlsCertificate);
231
+ /**
232
+ * TLS certificate for the mock server to use when serving HTTPS pages. If this is non-%NULL, the server will always use HTTPS. If it is %NULL,
233
+ * the server will always use HTTP. The TLS certificate may be changed after constructing the #UhmServer, but changes to the property will not
234
+ * take effect until the next call to uhm_server_run().
235
+ *
236
+ * A certificate and private key may be generated by executing:
237
+ * <code>openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -nodes</code>. These files may then be used to construct a
238
+ * #GTlsCertificate by calling g_tls_certificate_new_from_files().
239
+ *
240
+ * Alternatively, a default #GTlsCertificate which wraps a dummy certificate (not signed by any certificate authority) may be set by
241
+ * calling uhm_server_set_default_tls_certificate(). This may be used as the #UhmServer:tls-certificate if the code under test has no specific
242
+ * requirements of the certificate used by the mock server it's tested against.
243
+ */
244
+ get tlsCertificate(): Gio.TlsCertificate;
245
+ set tlsCertificate(val: Gio.TlsCertificate);
246
+ /**
247
+ * Directory relative to which all trace files specified in calls to uhm_server_start_trace() will be resolved.
248
+ * This is not used for any other methods, but must be non-%NULL if uhm_server_start_trace() is called.
249
+ */
250
+ get trace_directory(): Gio.File;
251
+ set trace_directory(val: Gio.File);
252
+ /**
253
+ * Directory relative to which all trace files specified in calls to uhm_server_start_trace() will be resolved.
254
+ * This is not used for any other methods, but must be non-%NULL if uhm_server_start_trace() is called.
255
+ */
256
+ get traceDirectory(): Gio.File;
257
+ set traceDirectory(val: Gio.File);
258
+
259
+ // Constructors of Uhm.Server
260
+
261
+ constructor(properties?: Partial<Server.ConstructorProps>, ...args: any[]);
262
+
263
+ _init(...args: any[]): void;
264
+
265
+ static ['new'](): Server;
266
+
267
+ // Own signals of Uhm.Server
268
+
269
+ connect(id: string, callback: (...args: any[]) => any): number;
270
+ connect_after(id: string, callback: (...args: any[]) => any): number;
271
+ emit(id: string, ...args: any[]): void;
272
+ connect(
273
+ signal: 'compare-messages',
274
+ callback: (_source: this, expected_message: Message, actual_message: Message) => boolean,
275
+ ): number;
276
+ connect_after(
277
+ signal: 'compare-messages',
278
+ callback: (_source: this, expected_message: Message, actual_message: Message) => boolean,
279
+ ): number;
280
+ emit(signal: 'compare-messages', expected_message: Message, actual_message: Message): void;
281
+ connect(signal: 'handle-message', callback: (_source: this, message: Message) => boolean): number;
282
+ connect_after(signal: 'handle-message', callback: (_source: this, message: Message) => boolean): number;
283
+ emit(signal: 'handle-message', message: Message): void;
284
+
285
+ // Own static methods of Uhm.Server
286
+
287
+ static error_quark(): GLib.Quark;
288
+ /**
289
+ * Convenience version of uhm_server_received_message_chunk() which can be passed directly to soup_logger_set_printer()
290
+ * to forward all libsoup traffic logging to a #UhmServer. The #UhmServer must be passed to soup_logger_set_printer() as
291
+ * its user data.
292
+ *
293
+ * <informalexample><programlisting>
294
+ * UhmServer *mock_server;
295
+ * SoupSession *session;
296
+ * SoupLogger *logger;
297
+ *
298
+ * mock_server = uhm_server_new ();
299
+ * session = soup_session_new ();
300
+ *
301
+ * logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
302
+ * soup_logger_set_printer (logger, uhm_server_received_message_chunk_from_soup, g_object_ref (mock_server), g_object_unref);
303
+ * soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
304
+ * g_object_unref (logger);
305
+ *
306
+ * /<!-- -->* Do something with mock_server here. *<!-- -->/
307
+ * </programlisting></informalexample>
308
+ * @param logger a #SoupLogger
309
+ * @param level the detail level of this log message
310
+ * @param direction the transmission direction of the message
311
+ * @param data message data
312
+ * @param user_data user data passed to the #SoupLogger, or %NULL
313
+ */
314
+ static received_message_chunk_from_soup(
315
+ logger: Soup.Logger,
316
+ level: Soup.LoggerLogLevel,
317
+ direction: number,
318
+ data: string,
319
+ user_data?: any | null,
320
+ ): void;
321
+
322
+ // Own virtual methods of Uhm.Server
323
+
324
+ vfunc_compare_messages(expected_message: Message, actual_message: Message): boolean;
325
+ vfunc_handle_message(message: Message): boolean;
326
+
327
+ // Own methods of Uhm.Server
328
+
329
+ /**
330
+ * Remove a #UhmServer:compare-messages filter function installed previously by
331
+ * calling something like uhm_server_filter_ignore_parameter_values().
332
+ *
333
+ * It is an error to call this function with an invalid `filter_id`.
334
+ * @param filter_id filter ID returned by the filter addition function
335
+ */
336
+ compare_messages_remove_filter(filter_id: number): void;
337
+ /**
338
+ * Convenience function to finish logging to or reading from a trace file previously passed to uhm_server_start_trace() or
339
+ * uhm_server_start_trace_full().
340
+ *
341
+ * If #UhmServer:enable-online is %FALSE, this will shut down the mock server (as if uhm_server_stop() had been called).
342
+ */
343
+ end_trace(): void;
344
+ /**
345
+ * Install a #UhmServer:compare-messages filter function which will override the
346
+ * default comparison function to one which ignores differences in the values of
347
+ * the given query `parameter_names`. The named parameters must still be present
348
+ * in the query, however.
349
+ *
350
+ * The filter will remain in place for the lifetime of the #UhmServer, until
351
+ * `uhm_server_compare_messages_remove_filter(`) is called with the returned
352
+ * filter ID.
353
+ *
354
+ * Note that currently only one of the installed comparison functions will be
355
+ * used. This may change in future.
356
+ * @param parameter_names %NULL-terminated array of parameter names to ignore
357
+ * @returns opaque filter ID used with uhm_server_compare_messages_remove_filter() to remove the filter later
358
+ */
359
+ filter_ignore_parameter_values(parameter_names: string[]): number;
360
+ /**
361
+ * Gets the value of the #UhmServer:address property.
362
+ * @returns the physical address of the listening socket the server is currently bound to; or %NULL if the server is not running
363
+ */
364
+ get_address(): string | null;
365
+ /**
366
+ * Gets the value of the #UhmServer:enable-logging property.
367
+ * @returns %TRUE if client network traffic is being logged to a trace file; %FALSE otherwise
368
+ */
369
+ get_enable_logging(): boolean;
370
+ /**
371
+ * Gets the value of the #UhmServer:enable-online property.
372
+ * @returns %TRUE if the server does not intercept and handle network connections from client code; %FALSE otherwise
373
+ */
374
+ get_enable_online(): boolean;
375
+ /**
376
+ * Gets the value of the #UhmServer:port property.
377
+ * @returns the port of the listening socket the server is currently bound to; or <code class="literal">0</code> if the server is not running
378
+ */
379
+ get_port(): number;
380
+ /**
381
+ * Gets the value of the #UhmServer:resolver property.
382
+ * @returns the mock resolver in use by the mock server, or %NULL if no resolver is active
383
+ */
384
+ get_resolver(): Resolver | null;
385
+ /**
386
+ * Gets the value of the #UhmServer:tls-certificate property.
387
+ * @returns the server's current TLS certificate; or %NULL if it's serving HTTP only
388
+ */
389
+ get_tls_certificate(): Gio.TlsCertificate | null;
390
+ /**
391
+ * Gets the value of the #UhmServer:trace-directory property.
392
+ * @returns the directory to load/store trace files from, or %NULL
393
+ */
394
+ get_trace_directory(): Gio.File | null;
395
+ /**
396
+ * Synchronously loads the given `trace_file` of network messages, ready to simulate a network conversation by matching
397
+ * requests against the file and returning the associated responses. Call uhm_server_run() to start the mock
398
+ * server afterwards.
399
+ *
400
+ * Loading the trace file may be cancelled from another thread using `cancellable`.
401
+ *
402
+ * On error, `error` will be set and the state of the #UhmServer will not change. A #GIOError will be set if there is
403
+ * a problem reading the trace file.
404
+ * @param trace_file trace file to load
405
+ * @param cancellable a #GCancellable, or %NULL
406
+ */
407
+ load_trace(trace_file: Gio.File, cancellable?: Gio.Cancellable | null): void;
408
+ /**
409
+ * Asynchronous version of uhm_server_load_trace(). In `callback,` call uhm_server_load_trace_finish() to complete the operation.
410
+ * @param trace_file trace file to load
411
+ * @param cancellable a #GCancellable, or %NULL
412
+ * @param callback function to call once the async operation is complete
413
+ */
414
+ load_trace_async(
415
+ trace_file: Gio.File,
416
+ cancellable?: Gio.Cancellable | null,
417
+ callback?: Gio.AsyncReadyCallback<this> | null,
418
+ ): void;
419
+ /**
420
+ * Finishes an asynchronous operation started by uhm_server_load_trace_async().
421
+ *
422
+ * On error, `error` will be set and the state of the #UhmServer will not change.
423
+ * See uhm_server_load_trace() for details on the error domains used.
424
+ * @param result asynchronous operation result passed to the callback
425
+ */
426
+ load_trace_finish(result: Gio.AsyncResult): void;
427
+ /**
428
+ * Indicates to the mock server that a single new line of a message was received from the real server. The message line may be
429
+ * appended to the current trace file if logging is enabled (#UhmServer:enable-logging is %TRUE), adding a newline character
430
+ * at the end. If logging is disabled but online mode is enabled (#UhmServer:enable-online is %TRUE), the message line will
431
+ * be compared to the next expected line in the existing trace file. Otherwise, this function is a no-op.
432
+ *
433
+ * On failure, `error` will be set and the #UhmServer state will remain unchanged apart from the parse state machine, which will remain
434
+ * in the state reached after parsing `message_chunk`. A %G_IO_ERROR will be returned if writing to the trace file failed. If in
435
+ * comparison mode and the received message chunk corresponds to an unexpected message in the trace file, a %UHM_SERVER_ERROR will
436
+ * be returned.
437
+ *
438
+ * <note><para>In common cases where message log data only needs to be passed to a #UhmServer and not (for example) logged to an
439
+ * application-specific file or the command line as well, it is simpler to use uhm_server_received_message_chunk_from_soup(), passing
440
+ * it directly to soup_logger_set_printer(). See the documentation for uhm_server_received_message_chunk_from_soup() for details.</para></note>
441
+ * @param message_chunk single line of a message which was received
442
+ * @param message_chunk_length length of @message_chunk in bytes
443
+ */
444
+ received_message_chunk(message_chunk: string, message_chunk_length: number): void;
445
+ /**
446
+ * Convenience version of uhm_server_received_message_chunk() which takes the
447
+ * message `direction` and `data` separately, as provided by libsoup in a
448
+ * #SoupLoggerPrinter callback.
449
+ *
450
+ * <informalexample><programlisting>
451
+ * UhmServer *mock_server;
452
+ * SoupSession *session;
453
+ * SoupLogger *logger;
454
+ *
455
+ * static void
456
+ * soup_log_printer (SoupLogger *logger, SoupLoggerLogLevel level, char direction, const char *data, gpointer user_data)
457
+ * {
458
+ * /<!-- -->* Pass the data to libuhttpmock. *<!-- -->/
459
+ * UhmServer *mock_server = UHM_SERVER (user_data);
460
+ * uhm_server_received_message_chunk_with_direction (mock_server, direction, data, strlen (data), NULL);
461
+ * }
462
+ *
463
+ * mock_server = uhm_server_new ();
464
+ * session = soup_session_new ();
465
+ *
466
+ * logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
467
+ * soup_logger_set_printer (logger, (SoupLoggerPrinter) soup_log_printer, g_object_ref (mock_server), g_object_unref);
468
+ * soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
469
+ * g_object_unref (logger);
470
+ *
471
+ * /<!-- -->* Do something with mock_server here. *<!-- -->/
472
+ * </programlisting></informalexample>
473
+ * @param direction single character indicating the direction of message transmission
474
+ * @param data single line of a message which was received
475
+ * @param data_length length of @data in bytes
476
+ */
477
+ received_message_chunk_with_direction(direction: number, data: string, data_length: number): void;
478
+ /**
479
+ * Runs the mock server, binding to a loopback TCP/IP interface and preparing a HTTPS server which is ready to accept requests.
480
+ * The TCP/IP address and port number are chosen randomly out of the loopback addresses, and are exposed as #UhmServer:address and #UhmServer:port
481
+ * once this function has returned. A #UhmResolver (exposed as #UhmServer:resolver) is set as the default #GResolver while the server is running.
482
+ *
483
+ * The server is started in a worker thread, so this function returns immediately and the server continues to run in the background. Use uhm_server_stop()
484
+ * to shut it down.
485
+ *
486
+ * This function always succeeds.
487
+ */
488
+ run(): void;
489
+ /**
490
+ * Sets the value of the #UhmServer:tls-certificate property to the default TLS certificate built in to libuhttpmock.
491
+ * This default certificate is not signed by any certificate authority, and contains minimal metadata details. It may
492
+ * be used by clients which have no special certificate requirements; clients which have special requirements should
493
+ * construct a custom #GTlsCertificate and pass it to uhm_server_set_tls_certificate().
494
+ * @returns the default certificate set as #UhmServer:tls-certificate
495
+ */
496
+ set_default_tls_certificate(): Gio.TlsCertificate;
497
+ /**
498
+ * Sets the value of the #UhmServer:enable-logging property.
499
+ * @param enable_logging %TRUE to log client network traffic to a trace file; %FALSE otherwise
500
+ */
501
+ set_enable_logging(enable_logging: boolean): void;
502
+ /**
503
+ * Sets the value of the #UhmServer:enable-online property.
504
+ * @param enable_online %TRUE to not intercept and handle network connections from client code; %FALSE otherwise
505
+ */
506
+ set_enable_online(enable_online: boolean): void;
507
+ /**
508
+ * Set the domain names which are expected to have requests made of them by the client code interacting with this #UhmServer.
509
+ * This is a convenience method which calls uhm_resolver_add_A() on the server’s #UhmResolver for each of the domain names
510
+ * listed in `domain_names`. It associates them with the server’s current IP address, and automatically updates the mappings
511
+ * if the IP address or resolver change.
512
+ *
513
+ * Note that this will reset all records on the server’s #UhmResolver, replacing all of them with the provided `domain_names`.
514
+ *
515
+ * It is safe to add further domain names to the #UhmResolver in a callback for the #GObject::notify signal for #UhmServer:resolver;
516
+ * that signal is emitted after the resolver is cleared and these `domain_names` are added.
517
+ * @param domain_names %NULL-terminated array of domain names to expect, or %NULL to not expect any
518
+ */
519
+ set_expected_domain_names(domain_names?: string[] | null): void;
520
+ /**
521
+ * Sets the value of the #UhmServer:tls-certificate property.
522
+ * @param tls_certificate TLS certificate for the server to use; or %NULL to serve HTTP only
523
+ */
524
+ set_tls_certificate(tls_certificate?: Gio.TlsCertificate | null): void;
525
+ /**
526
+ * Sets the value of the #UhmServer:trace-directory property.
527
+ * @param trace_directory a directory to load/store trace files from, or %NULL to unset it
528
+ */
529
+ set_trace_directory(trace_directory?: Gio.File | null): void;
530
+ /**
531
+ * Starts a mock server which follows the trace file of filename `trace_name` in the #UhmServer:trace-directory directory.
532
+ * See uhm_server_start_trace_full() for further documentation.
533
+ *
534
+ * This function has undefined behaviour if #UhmServer:trace-directory is %NULL.
535
+ *
536
+ * On failure, `error` will be set and the #UhmServer state will remain unchanged. See uhm_server_start_trace_full() for
537
+ * details of the error domains used.
538
+ * @param trace_name name of the trace
539
+ */
540
+ start_trace(trace_name: string): void;
541
+ /**
542
+ * Convenience function to start logging to or reading from the given `trace_file,` depending on the values of #UhmServer:enable-logging and
543
+ * #UhmServer:enable-online.
544
+ *
545
+ * If #UhmServer:enable-logging is %TRUE, a log handler will be set up to redirect all client network activity into the given `trace_file`.
546
+ * If `trace_file` already exists, it will be overwritten.
547
+ *
548
+ * If #UhmServer:enable-online is %FALSE, the given `trace_file` is loaded using uhm_server_load_trace() and then a mock server is
549
+ * started using uhm_server_run().
550
+ *
551
+ * On failure, `error` will be set and the #UhmServer state will remain unchanged. A #GIOError will be set if logging is enabled
552
+ * (#UhmServer:enable-logging) and there is a problem writing to the trace file; or if a trace needs to be loaded and there is a problem
553
+ * reading from the trace file.
554
+ * @param trace_file a trace file to load
555
+ */
556
+ start_trace_full(trace_file: Gio.File): void;
557
+ /**
558
+ * Stops a mock server started by calling uhm_server_run(). This shuts down the server's worker thread and unbinds it from its TCP/IP socket.
559
+ *
560
+ * This unloads any trace file loaded by calling uhm_server_load_trace() (or its asynchronous counterpart). It also resets the set of domain
561
+ * names loaded into the #UhmServer:resolver.
562
+ *
563
+ * This function always succeeds.
564
+ */
565
+ stop(): void;
566
+ /**
567
+ * Unloads the current trace file of network messages, as loaded by uhm_server_load_trace() or uhm_server_load_trace_async().
568
+ */
569
+ unload_trace(): void;
570
+ }
571
+
572
+ type MessageClass = typeof Message;
573
+ type ResolverClass = typeof Resolver;
574
+ abstract class ResolverPrivate {
575
+ static $gtype: GObject.GType<ResolverPrivate>;
576
+
577
+ // Constructors of Uhm.ResolverPrivate
578
+
579
+ _init(...args: any[]): void;
580
+ }
581
+
582
+ type ServerClass = typeof Server;
583
+ abstract class ServerPrivate {
584
+ static $gtype: GObject.GType<ServerPrivate>;
585
+
586
+ // Constructors of Uhm.ServerPrivate
587
+
588
+ _init(...args: any[]): void;
589
+ }
590
+
591
+ /**
592
+ * Name of the imported GIR library
593
+ * `see` https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L188
594
+ */
595
+ const __name__: string;
596
+ /**
597
+ * Version of the imported GIR library
598
+ * `see` https://gitlab.gnome.org/GNOME/gjs/-/blob/master/gi/ns.cpp#L189
599
+ */
600
+ const __version__: string;
601
+ }
602
+
603
+ export default Uhm;
604
+ // END
package/uhm-1.0.js ADDED
@@ -0,0 +1,6 @@
1
+
2
+ // @ts-expect-error
3
+ import Uhm from 'gi://Uhm?version=1.0';
4
+ export { Uhm };
5
+ export default Uhm;
6
+