@minecraft/server-net 0.0.1-beta → 1.0.0-beta.00001b01

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/.eslintrc.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "es2021": true
5
- },
6
- "extends": [
7
- "eslint:recommended",
8
- "plugin:@typescript-eslint/recommended"
9
- ],
10
- "overrides": [
11
- ],
12
- "parser": "@typescript-eslint/parser",
13
- "parserOptions": {
14
- "ecmaVersion": "latest",
15
- "sourceType": "module"
16
- },
17
- "plugins": [
18
- "@typescript-eslint"
19
- ],
20
- "rules": {
21
- "@typescript-eslint/no-explicit-any": "off"
22
- }
23
- }
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true
5
+ },
6
+ "extends": [
7
+ "eslint:recommended",
8
+ "plugin:@typescript-eslint/recommended"
9
+ ],
10
+ "overrides": [
11
+ ],
12
+ "parser": "@typescript-eslint/parser",
13
+ "parserOptions": {
14
+ "ecmaVersion": "latest",
15
+ "sourceType": "module"
16
+ },
17
+ "plugins": [
18
+ "@typescript-eslint"
19
+ ],
20
+ "rules": {
21
+ "@typescript-eslint/no-explicit-any": "off"
22
+ }
23
+ }
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # `@minecraft/server-net`
2
+
3
+ The `@minecraft/server-net` module contains types for executing HTTP-based requests. This module can only be used on Bedrock Dedicated Server.
4
+
5
+ ## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
6
+
7
+ See full documentation for this module here:
8
+
9
+ https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/@minecraft/server-net/@minecraft/server-net
package/index.d.ts CHANGED
@@ -1,62 +1,174 @@
1
- // Type definitions for Minecraft Bedrock Edition script APIs (experimental) 0.1
1
+ // Type definitions for Minecraft Bedrock Edition script APIs
2
2
  // Project: https://docs.microsoft.com/minecraft/creator/
3
3
  // Definitions by: Jake Shirley <https://github.com/JakeShirley>
4
4
  // Mike Ammerlaan <https://github.com/mammerla>
5
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
5
 
7
6
  /* *****************************************************************************
8
7
  Copyright (c) Microsoft Corporation.
9
8
  ***************************************************************************** */
10
9
  /**
10
+ * @packageDocumentation
11
+ * The `@minecraft/server-net` module contains types for
12
+ * executing HTTP-based requests. This module can only be used
13
+ * on Bedrock Dedicated Server.
11
14
  *
12
15
  * Manifest Details
13
16
  * ```json
14
17
  * {
15
18
  * "module_name": "@minecraft/server-net",
16
- * "version": "1.0.0-beta"
19
+ * "version": "1.0.0-beta.00001b01"
17
20
  * }
18
21
  * ```
19
22
  *
20
23
  */
21
24
  import * as minecraftserveradmin from '@minecraft/server-admin';
22
25
  export enum HttpRequestMethod {
26
+ /**
27
+ * Represents the method for an HTTP HEAD request. HEAD
28
+ * requests are similar to a GET request, but are commonly used
29
+ * to retrieve just the HTTP response headers from the
30
+ * specified URI, and not the body contents.
31
+ */
23
32
  DELETE = 'DELETE',
33
+ /**
34
+ * Represents the method for an HTTP PUT request. POST requests
35
+ * are commonly used to create a new resource that is a
36
+ * subordinate of the specified URI.
37
+ */
24
38
  GET = 'GET',
39
+ /**
40
+ * Represents the method for an HTTP PUT request. GET requests
41
+ * are commonly used to retrieve information about a resource
42
+ * at the specified URI.
43
+ */
25
44
  HEAD = 'HEAD',
45
+ /**
46
+ * Represents the method for an HTTP PUT request. GET requests
47
+ * are commonly used to retrieve information about a resource
48
+ * at the specified URI.
49
+ */
26
50
  POST = 'POST',
51
+ /**
52
+ * Represents the method for an HTTP PUT request. PUT requests
53
+ * are commonly used to update a single resource that already
54
+ * exists in a resource collection.
55
+ */
27
56
  PUT = 'PUT',
28
57
  }
29
58
  export class HttpClient {
59
+ /**
60
+ * @remarks
61
+ * Cancels all pending requests.
62
+ * @param reason
63
+ */
30
64
  cancelAll(reason: string): void;
65
+ /**
66
+ * @remarks
67
+ * Performs a simple HTTP get request.
68
+ * @param uri
69
+ * URL to make an HTTP Request to.
70
+ * @returns
71
+ * An awaitable promise that contains the HTTP response.
72
+ */
31
73
  get(uri: string): Promise<HttpResponse>;
74
+ /**
75
+ * @remarks
76
+ * Performs an HTTP request.
77
+ * @param config
78
+ * Contains an HTTP Request object with configuration data on
79
+ * the HTTP request.
80
+ * @returns
81
+ * An awaitable promise that contains the HTTP response.
82
+ */
32
83
  request(config: HttpRequest): Promise<HttpResponse>;
33
84
  testOnly_fulfillRequest(requestId: number, headers: HttpHeader[], body: string, status: number): void;
34
85
  testOnly_getRequests(): number[];
35
86
  testOnly_rejectRequest(requestId: number, reason: string): void;
36
87
  protected constructor();
37
88
  }
89
+ /**
90
+ * Represents an HTTP header - a key/value pair of
91
+ * meta-information about a request.
92
+ */
38
93
  export class HttpHeader {
94
+ /**
95
+ * Key of the HTTP header.
96
+ */
39
97
  key: string;
98
+ /**
99
+ * Value of the HTTP header.
100
+ */
40
101
  value: minecraftserveradmin.SecretString | string;
41
102
  constructor(key: string, value: minecraftserveradmin.SecretString | string);
42
103
  }
104
+ /**
105
+ * Main object for structuring a request.
106
+ */
43
107
  export class HttpRequest {
108
+ /**
109
+ * Content of the body of the HTTP request.
110
+ */
44
111
  body: string;
112
+ /**
113
+ * A collection of HTTP headers to add to the outbound request.
114
+ */
45
115
  headers: HttpHeader[];
116
+ /**
117
+ * HTTP method (e.g., GET or PUT or PATCH) to use for making
118
+ * the request.
119
+ */
46
120
  method: HttpRequestMethod;
121
+ /**
122
+ * Amount of time, in seconds, before the request times out and
123
+ * is abandoned.
124
+ */
47
125
  timeout: number;
126
+ /**
127
+ * The HTTP resource to access.
128
+ */
48
129
  uri: string;
130
+ /**
131
+ * @remarks
132
+ * Adds an additional header to the overall list of headers
133
+ * used in the corresponding HTTP request.
134
+ * @param key
135
+ * @param value
136
+ */
49
137
  addHeader(key: string, value: minecraftserveradmin.SecretString | string): HttpRequest;
50
138
  constructor(uri: string);
51
139
  setBody(body: string): HttpRequest;
140
+ /**
141
+ * @remarks
142
+ * Replaces and applies a set of HTTP Headers for the request.
143
+ * @param headers
144
+ */
52
145
  setHeaders(headers: HttpHeader[]): HttpRequest;
53
146
  setMethod(method: HttpRequestMethod): HttpRequest;
54
147
  setTimeout(timeout: number): HttpRequest;
55
148
  }
149
+ /**
150
+ * Main object that contains result information from a request.
151
+ */
56
152
  export class HttpResponse {
153
+ /**
154
+ * Body content of the HTTP response.
155
+ */
57
156
  readonly body: string;
157
+ /**
158
+ * A collection of HTTP response headers returned from the
159
+ * request.
160
+ */
58
161
  readonly headers: HttpHeader[];
162
+ /**
163
+ * Information that was used to formulate the HTTP response
164
+ * that this object represents.
165
+ */
59
166
  readonly request: HttpRequest;
167
+ /**
168
+ * HTTP response code for the request. For example, 404
169
+ * represents resource not found, and 500 represents an
170
+ * internal server error.
171
+ */
60
172
  readonly status: number;
61
173
  protected constructor();
62
174
  }
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
- {
2
- "name": "@minecraft/server-net",
3
- "version": "0.0.1-beta",
4
- "description": "",
5
- "contributors": [
6
- {
7
- "name": "Jake Shirley",
8
- "email": "jake@xbox.com"
9
- },
10
- {
11
- "name": "Mike Ammerlaan",
12
- "email": "mikeam@microsoft.com"
13
- }
14
- ],
15
- "license": "MIT",
16
- "dependencies": {
17
- "@minecraft/server-admin": "0.0.1-beta"
18
- }
1
+ {
2
+ "name": "@minecraft/server-net",
3
+ "version": "1.0.0-beta.00001b01",
4
+ "description": "",
5
+ "contributors": [
6
+ {
7
+ "name": "Jake Shirley",
8
+ "email": "jake@xbox.com"
9
+ },
10
+ {
11
+ "name": "Mike Ammerlaan",
12
+ "email": "mikeam@microsoft.com"
13
+ }
14
+ ],
15
+ "dependencies": {
16
+ "@minecraft/server-admin": "1.0.0-beta.00001b01"
17
+ },
18
+ "license": "MIT"
19
19
  }
package/tsconfig.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "lib": ["es6"],
5
- "target": "es6",
6
- "forceConsistentCasingInFileNames": true,
7
- "noEmit": true,
8
- "noImplicitAny": true,
9
- "noImplicitThis": true,
10
- "strictFunctionTypes": true,
11
- "strictNullChecks": true,
12
- "baseUrl": "../",
13
- "typeRoots": ["../"],
14
- "types": []
15
- },
16
- "files": [
17
- "index.d.ts",
18
- "tests.ts"
19
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "lib": ["es6"],
5
+ "target": "es6",
6
+ "forceConsistentCasingInFileNames": true,
7
+ "noEmit": true,
8
+ "noImplicitAny": true,
9
+ "noImplicitThis": true,
10
+ "strictFunctionTypes": true,
11
+ "strictNullChecks": true,
12
+ "baseUrl": "../",
13
+ "typeRoots": ["../"],
14
+ "types": []
15
+ },
16
+ "files": [
17
+ "index.d.ts",
18
+ "tests.ts"
19
+ ]
20
20
  }