@opra/core 0.4.0 → 0.6.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.
Files changed (68) hide show
  1. package/cjs/adapter/adapter.js +103 -123
  2. package/cjs/adapter/classes/execution-context.host.js +17 -0
  3. package/cjs/adapter/classes/express-request-wrapper.host.js +37 -0
  4. package/cjs/adapter/classes/express-response-wrapper.host.js +56 -0
  5. package/cjs/adapter/classes/http-execution-context.host.js +31 -0
  6. package/cjs/adapter/{metadata-resource.js → classes/metadata.resource.js} +3 -3
  7. package/cjs/adapter/express-adapter.js +6 -104
  8. package/cjs/adapter/http-adapter.js +282 -81
  9. package/cjs/adapter/request-contexts/batch-request-context.js +12 -0
  10. package/cjs/adapter/{query-context.js → request-contexts/request-context.js} +9 -13
  11. package/cjs/adapter/request-contexts/single-request-context.js +15 -0
  12. package/cjs/index.js +2 -2
  13. package/cjs/interfaces/i18n-options.interface.js +2 -0
  14. package/cjs/services/json-collection-service.js +36 -39
  15. package/cjs/services/json-singleton-service.js +9 -10
  16. package/cjs/utils/create-i18n.js +2 -2
  17. package/esm/adapter/adapter.d.ts +13 -44
  18. package/esm/adapter/adapter.js +89 -109
  19. package/esm/adapter/classes/execution-context.host.d.ts +10 -0
  20. package/esm/adapter/classes/execution-context.host.js +13 -0
  21. package/esm/adapter/classes/express-request-wrapper.host.d.ts +19 -0
  22. package/esm/adapter/classes/express-request-wrapper.host.js +33 -0
  23. package/esm/adapter/classes/express-response-wrapper.host.d.ts +22 -0
  24. package/esm/adapter/classes/express-response-wrapper.host.js +52 -0
  25. package/esm/adapter/classes/http-execution-context.host.d.ts +13 -0
  26. package/esm/adapter/classes/http-execution-context.host.js +27 -0
  27. package/esm/adapter/classes/metadata.resource.d.ts +8 -0
  28. package/esm/adapter/{metadata-resource.js → classes/metadata.resource.js} +2 -2
  29. package/esm/adapter/express-adapter.d.ts +1 -1
  30. package/esm/adapter/express-adapter.js +5 -103
  31. package/esm/adapter/http-adapter.d.ts +23 -12
  32. package/esm/adapter/http-adapter.js +248 -47
  33. package/esm/adapter/request-contexts/batch-request-context.d.ts +7 -0
  34. package/esm/adapter/request-contexts/batch-request-context.js +8 -0
  35. package/esm/adapter/request-contexts/request-context.d.ts +22 -0
  36. package/esm/adapter/{query-context.js → request-contexts/request-context.js} +6 -10
  37. package/esm/adapter/request-contexts/single-request-context.d.ts +10 -0
  38. package/esm/adapter/request-contexts/single-request-context.js +11 -0
  39. package/esm/index.d.ts +2 -2
  40. package/esm/index.js +2 -2
  41. package/esm/interfaces/execution-context.interface.d.ts +19 -11
  42. package/esm/interfaces/i18n-options.interface.d.ts +28 -0
  43. package/esm/interfaces/i18n-options.interface.js +1 -0
  44. package/esm/interfaces/resource.interface.d.ts +1 -1
  45. package/esm/services/json-collection-service.d.ts +3 -4
  46. package/esm/services/json-collection-service.js +17 -20
  47. package/esm/services/json-singleton-service.d.ts +3 -3
  48. package/esm/services/json-singleton-service.js +8 -8
  49. package/esm/utils/create-i18n.d.ts +3 -3
  50. package/esm/utils/create-i18n.js +1 -1
  51. package/package.json +7 -8
  52. package/cjs/enums/http-headers.enum.js +0 -395
  53. package/cjs/enums/http-status.enum.js +0 -300
  54. package/cjs/enums/index.js +0 -5
  55. package/cjs/helpers/headers-map.js +0 -18
  56. package/cjs/utils/path-to-tree.js +0 -28
  57. package/esm/adapter/metadata-resource.d.ts +0 -8
  58. package/esm/adapter/query-context.d.ts +0 -25
  59. package/esm/enums/http-headers.enum.d.ts +0 -370
  60. package/esm/enums/http-headers.enum.js +0 -392
  61. package/esm/enums/http-status.enum.d.ts +0 -290
  62. package/esm/enums/http-status.enum.js +0 -297
  63. package/esm/enums/index.d.ts +0 -2
  64. package/esm/enums/index.js +0 -2
  65. package/esm/helpers/headers-map.d.ts +0 -5
  66. package/esm/helpers/headers-map.js +0 -14
  67. package/esm/utils/path-to-tree.d.ts +0 -4
  68. package/esm/utils/path-to-tree.js +0 -24
@@ -1,10 +1,7 @@
1
- import _ from 'lodash';
1
+ import { isNil, omitBy } from 'lodash';
2
2
  import merge from 'putil-merge';
3
3
  import { nSQL } from "@nano-sql/core";
4
- import { BadRequestError, MethodNotAllowedError, ResourceConflictError } from '@opra/exception';
5
- import { CollectionResourceInfo, ComplexType } from '@opra/schema';
6
- import { $parse, ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, Expression, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from '@opra/url';
7
- import { pathToTree } from '../utils/path-to-tree.js';
4
+ import { ArrayExpression, BadRequestError, BooleanLiteral, CollectionResourceInfo, ComparisonExpression, ComplexType, DateLiteral, Expression, LogicalExpression, MethodNotAllowedError, NullLiteral, NumberLiteral, ParenthesesExpression, parseFilter, pathToTree, QualifiedIdentifier, ResourceConflictError, StringLiteral, TimeLiteral } from '@opra/common';
8
5
  let dbId = 1;
9
6
  const indexingTypes = ['int', 'float', 'number', 'date', 'string'];
10
7
  export class JsonCollectionService {
@@ -248,9 +245,9 @@ export class JsonCollectionService {
248
245
  }
249
246
  switch (query.method) {
250
247
  case 'count': {
251
- const options = _.omitBy({
248
+ const options = omitBy({
252
249
  filter: this._convertFilter(query.filter)
253
- }, _.isNil);
250
+ }, isNil);
254
251
  return {
255
252
  method: query.method,
256
253
  options,
@@ -258,11 +255,11 @@ export class JsonCollectionService {
258
255
  };
259
256
  }
260
257
  case 'create': {
261
- const options = _.omitBy({
258
+ const options = omitBy({
262
259
  pick: query.pick,
263
260
  omit: query.omit,
264
261
  include: query.include
265
- }, _.isNil);
262
+ }, isNil);
266
263
  const { data } = query;
267
264
  return {
268
265
  method: query.method,
@@ -273,11 +270,11 @@ export class JsonCollectionService {
273
270
  }
274
271
  case 'get': {
275
272
  if (query.kind === 'CollectionGetQuery') {
276
- const options = _.omitBy({
273
+ const options = omitBy({
277
274
  pick: query.pick,
278
275
  omit: query.omit,
279
276
  include: query.include
280
- }, _.isNil);
277
+ }, isNil);
281
278
  const keyValue = query.keyValue;
282
279
  return {
283
280
  method: query.method,
@@ -296,7 +293,7 @@ export class JsonCollectionService {
296
293
  throw new MethodNotAllowedError({
297
294
  message: '$distinct parameter is not supported by JsonDataService'
298
295
  });
299
- const options = _.omitBy({
296
+ const options = omitBy({
300
297
  pick: query.pick,
301
298
  omit: query.omit,
302
299
  include: query.include,
@@ -306,7 +303,7 @@ export class JsonCollectionService {
306
303
  limit: query.limit,
307
304
  offset: query.skip,
308
305
  count: query.count,
309
- }, _.isNil);
306
+ }, isNil);
310
307
  return {
311
308
  method: query.method,
312
309
  options,
@@ -314,11 +311,11 @@ export class JsonCollectionService {
314
311
  };
315
312
  }
316
313
  case 'update': {
317
- const options = _.omitBy({
314
+ const options = omitBy({
318
315
  pick: query.pick,
319
316
  omit: query.omit,
320
317
  include: query.include
321
- }, _.isNil);
318
+ }, isNil);
322
319
  const { data } = query;
323
320
  const keyValue = query.keyValue;
324
321
  return {
@@ -330,9 +327,9 @@ export class JsonCollectionService {
330
327
  };
331
328
  }
332
329
  case 'updateMany': {
333
- const options = _.omitBy({
330
+ const options = omitBy({
334
331
  filter: this._convertFilter(query.filter)
335
- }, _.isNil);
332
+ }, isNil);
336
333
  const { data } = query;
337
334
  return {
338
335
  method: query.method,
@@ -351,9 +348,9 @@ export class JsonCollectionService {
351
348
  };
352
349
  }
353
350
  case 'deleteMany': {
354
- const options = _.omitBy({
351
+ const options = omitBy({
355
352
  filter: this._convertFilter(query.filter)
356
- }, _.isNil);
353
+ }, isNil);
357
354
  return {
358
355
  method: query.method,
359
356
  options,
@@ -388,7 +385,7 @@ export class JsonCollectionService {
388
385
  }
389
386
  _convertFilter(str) {
390
387
  const ast = typeof str === 'string'
391
- ? $parse(str)
388
+ ? parseFilter(str)
392
389
  : str;
393
390
  if (!ast || !(ast instanceof Expression))
394
391
  return ast;
@@ -1,5 +1,5 @@
1
- import { DataType, OpraQuery, OpraSchema } from '@opra/schema';
2
- import { QueryContext } from '../adapter/query-context.js';
1
+ import { DataType, OpraQuery, OpraSchema } from '@opra/common';
2
+ import { SingleRequestContext } from '../adapter/request-contexts/single-request-context.js';
3
3
  import { PartialOutput } from '../types.js';
4
4
  export interface JsonSingletonServiceOptions<T> {
5
5
  data: T;
@@ -9,7 +9,7 @@ export declare class JsonSingletonService<T, TOutput = PartialOutput<T>> {
9
9
  readonly dataType: DataType;
10
10
  protected _data?: T;
11
11
  constructor(dataType: DataType, options?: JsonSingletonServiceOptions<T>);
12
- processRequest(ctx: QueryContext): Promise<any>;
12
+ processRequest(ctx: SingleRequestContext): Promise<any>;
13
13
  get(options?: JsonSingletonService.GetOptions): TOutput | undefined;
14
14
  protected _prepare(query: OpraQuery): {
15
15
  method: OpraSchema.SingletonMethod;
@@ -1,5 +1,5 @@
1
- import _ from 'lodash';
2
- import { SingletonResourceInfo } from '@opra/schema';
1
+ import { isNil, omitBy } from 'lodash';
2
+ import { SingletonResourceInfo } from '@opra/common';
3
3
  export class JsonSingletonService {
4
4
  dataType;
5
5
  _data;
@@ -27,11 +27,11 @@ export class JsonSingletonService {
27
27
  }
28
28
  switch (query.method) {
29
29
  case 'create': {
30
- const options = _.omitBy({
30
+ const options = omitBy({
31
31
  pick: query.pick,
32
32
  omit: query.omit,
33
33
  include: query.include
34
- }, _.isNil);
34
+ }, isNil);
35
35
  const { data } = query;
36
36
  return {
37
37
  method: query.method,
@@ -42,11 +42,11 @@ export class JsonSingletonService {
42
42
  }
43
43
  case 'get': {
44
44
  if (query.kind === 'CollectionGetQuery') {
45
- const options = _.omitBy({
45
+ const options = omitBy({
46
46
  pick: query.pick,
47
47
  omit: query.omit,
48
48
  include: query.include
49
- }, _.isNil);
49
+ }, isNil);
50
50
  const keyValue = query.keyValue;
51
51
  return {
52
52
  method: query.method,
@@ -61,11 +61,11 @@ export class JsonSingletonService {
61
61
  break;
62
62
  }
63
63
  case 'update': {
64
- const options = _.omitBy({
64
+ const options = omitBy({
65
65
  pick: query.pick,
66
66
  omit: query.omit,
67
67
  include: query.include
68
- }, _.isNil);
68
+ }, isNil);
69
69
  const { data } = query;
70
70
  const keyValue = query.keyValue;
71
71
  return {
@@ -1,3 +1,3 @@
1
- import { I18n } from '@opra/i18n';
2
- import { OpraAdapter } from '../adapter/adapter.js';
3
- export declare function createI18n(options?: OpraAdapter.I18nOptions): Promise<I18n>;
1
+ import { I18n } from '@opra/common';
2
+ import { I18nOptions } from '../interfaces/i18n-options.interface.js';
3
+ export declare function createI18n(options?: I18nOptions): Promise<I18n>;
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { I18n } from '@opra/i18n';
2
+ import { I18n } from '@opra/common';
3
3
  import { getCallerFile } from './get-caller-file.util.js';
4
4
  export async function createI18n(options) {
5
5
  const opts = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/core",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Opra schema package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -28,16 +28,14 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@nano-sql/core": "^2.3.7",
31
- "@opra/common": "^0.4.0",
32
- "@opra/exception": "^0.4.0",
33
- "@opra/i18n": "^0.4.0",
34
- "@opra/optionals": "^0.4.0",
35
- "@opra/schema": "^0.4.0",
36
- "@opra/url": "^0.4.0",
37
- "axiosist": "^1.0.0",
31
+ "@opra/common": "^0.6.0",
32
+ "@opra/optionals": "^0.6.0",
38
33
  "body-parser": "^1.20.1",
34
+ "dicer": "^0.3.1",
39
35
  "express": "^4.18.2",
36
+ "http-parser-js": "^0.5.8",
40
37
  "lodash": "^4.17.21",
38
+ "power-tasks": "^1.6.1",
41
39
  "putil-isplainobject": "^1.1.4",
42
40
  "putil-merge": "^3.9.0",
43
41
  "putil-varhelpers": "^1.6.4",
@@ -46,6 +44,7 @@
46
44
  },
47
45
  "devDependencies": {
48
46
  "@faker-js/faker": "^7.6.0",
47
+ "@types/dicer": "^0.2.2",
49
48
  "@types/express": "^4.17.14"
50
49
  },
51
50
  "type": "module",
@@ -1,395 +0,0 @@
1
- "use strict";
2
- // noinspection JSUnusedGlobalSymbols
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.HttpHeaders = void 0;
5
- /**
6
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers#controls
7
- */
8
- var HttpHeaders;
9
- (function (HttpHeaders) {
10
- /* *** Custom Headers *** */
11
- HttpHeaders["X_Opra_Version"] = "X-Opra-Version";
12
- HttpHeaders["X_Opra_DataType"] = "X-Opra-DataType";
13
- HttpHeaders["X_Opra_Count"] = "X-Opra-Count";
14
- /* *** Authentication *** */
15
- /**
16
- * Defines the authentication method that should be used to access a resource.
17
- */
18
- HttpHeaders["WWW_Authenticate"] = "WWW-Authenticate";
19
- /**
20
- * Contains the credentials to authenticate a user-agent with a server.
21
- */
22
- HttpHeaders["Authorization"] = "Authorization";
23
- /**
24
- * Defines the authentication method that should be used to access a resource behind a proxy server.
25
- */
26
- HttpHeaders["Proxy_Authenticate"] = "Proxy-Authenticate";
27
- /**
28
- * Contains the credentials to authenticate a user agent with a proxy server.
29
- */
30
- HttpHeaders["Proxy_Authorization"] = "Proxy-Authorization";
31
- /* *** Caching *** */
32
- /**
33
- * The time, in seconds, that the object has been in a proxy cache.
34
- */
35
- HttpHeaders["Age"] = "Age";
36
- /**
37
- * Directives for caching mechanisms in both requests and responses.
38
- */
39
- HttpHeaders["Cache_Control"] = "Cache-Control";
40
- /**
41
- * Clears browsing data (e.g. cookies, storage, cache) associated with the requesting website.
42
- */
43
- HttpHeaders["Clear_Site_Data"] = "Clear-Site-Data";
44
- /**
45
- * The date/time after which the response is considered stale.
46
- */
47
- HttpHeaders["Expires"] = "Expires";
48
- /**
49
- * Implementation-specific header that may have various effects anywhere along the request-response chain.
50
- * Used for backwards compatibility with HTTP/1.0 caches where the Cache-Control header is not yet present.
51
- */
52
- HttpHeaders["Pragma"] = "Pragma";
53
- /* *** Conditionals *** */
54
- /**
55
- * The last modification date of the resource, used to compare several versions of the same resource.
56
- * It is less accurate than ETag, but easier to calculate in some environments.
57
- * Conditional requests using If-Modified-Since and If-Unmodified-Since
58
- * use this value to change the behavior of the request.
59
- */
60
- HttpHeaders["Last_Modified"] = "Last-Modified";
61
- /**
62
- * A unique string identifying the version of the resource.
63
- * Conditional requests using If-Match and If-None-Match use this value to change the behavior of the request.
64
- */
65
- HttpHeaders["ETag"] = "ETag";
66
- /**
67
- * Makes the request conditional, and applies the method only if the stored resource matches one of the given ETags.
68
- */
69
- HttpHeaders["If_Match"] = "If-Match";
70
- /**
71
- * Makes the request conditional, and applies the method only if the stored resource doesn't match
72
- * any of the given ETags. This is used to update caches (for safe requests), or to prevent uploading
73
- * a new resource when one already exists.
74
- */
75
- HttpHeaders["If_None_Match"] = "If-None-Match";
76
- /**
77
- * Makes the request conditional, and expects the resource to be transmitted only if it has been modified
78
- * after the given date. This is used to transmit data only when the cache is out of date.
79
- */
80
- HttpHeaders["If_Modified_Since"] = "If-Modified-Since";
81
- /**
82
- * Makes the request conditional, and expects the resource to be transmitted only if
83
- * it has not been modified after the given date. This ensures the coherence of a new
84
- * fragment of a specific range with previous ones, or to implement an optimistic
85
- * concurrency control system when modifying existing documents.
86
- */
87
- HttpHeaders["If_Unmodified_Since"] = "If-Unmodified-Since";
88
- /**
89
- * Determines how to match request headers to decide whether a cached response can be used
90
- * rather than requesting a fresh one from the origin server.
91
- */
92
- HttpHeaders["Vary"] = "Vary";
93
- /* *** Connection management *** */
94
- /**
95
- * Controls whether the network connection stays open after the current transaction finishes.
96
- */
97
- HttpHeaders["Connection"] = "Connection";
98
- /**
99
- * Controls how long a persistent connection should stay open.
100
- */
101
- HttpHeaders["Keep_Alive"] = "Keep-Alive";
102
- // Content negotiation
103
- /**
104
- * Informs the server about the types of data that can be sent back.
105
- */
106
- HttpHeaders["Accept"] = "Accept";
107
- /**
108
- * The encoding algorithm, usually a compression algorithm, that can be used on the resource sent back.
109
- */
110
- HttpHeaders["Accept_Encoding"] = "Accept-Encoding";
111
- /**
112
- * Informs the server about the human language the server is expected to send back.
113
- * This is a hint and is not necessarily under the full control of the user:
114
- * the server should always pay attention not to override an explicit user choice
115
- * (like selecting a language from a dropdown).
116
- */
117
- HttpHeaders["Accept_Language"] = "Accept-Language";
118
- /* *** Controls *** */
119
- /**
120
- * Indicates expectations that need to be fulfilled by the server to properly handle the request.
121
- */
122
- HttpHeaders["Expect"] = "Expect";
123
- /* *** Cookies *** */
124
- /**
125
- * Contains stored HTTP cookies previously sent by the server with the Set-Cookie header.
126
- */
127
- HttpHeaders["Cookie"] = "Cookie";
128
- /**
129
- * Send cookies from the server to the user-agent.
130
- */
131
- HttpHeaders["Set_Cookie"] = "Set-Cookie";
132
- /* *** CORS *** */
133
- /**
134
- * Indicates whether the response can be shared.
135
- */
136
- HttpHeaders["Access_Control_Allow_Origin"] = "Access-Control-Allow-Origin";
137
- /**
138
- * Indicates whether the response to the request can be exposed when the credentials flag is true.
139
- */
140
- HttpHeaders["Access_Control_Allow_Credentials"] = "Access-Control-Allow-Credentials";
141
- /**
142
- * Used in response to a preflight request to indicate which HTTP headers can be used when making the actual request.
143
- */
144
- HttpHeaders["Access_Control_Allow_Headers"] = "Access-Control-Allow-Headers";
145
- /**
146
- * Specifies the methods allowed when accessing the resource in response to a preflight request.
147
- */
148
- HttpHeaders["Access_Control_Allow_Methods"] = "Access-Control-Allow-Methods";
149
- /**
150
- * Indicates which headers can be exposed as part of the response by listing their names.
151
- */
152
- HttpHeaders["Access_Control_Expose_Headers"] = "Access-Control-Expose-Headers";
153
- /**
154
- * Indicates how long the results of a preflight request can be cached.
155
- */
156
- HttpHeaders["Access_Control_Max_Age"] = "Access-Control-Max-Age";
157
- /**
158
- * Used when issuing a preflight request to let the server know which HTTP headers will be
159
- * used when the actual request is made.
160
- */
161
- HttpHeaders["Access_Control_Request_Headers"] = "Access-Control-Request-Headers";
162
- /**
163
- * Used when issuing a preflight request to let the server know which HTTP method
164
- * will be used when the actual request is made.
165
- */
166
- HttpHeaders["Access_Control_Request_Method"] = "Access-Control-Request-Method";
167
- /**
168
- * Indicates where a fetch originates from.
169
- */
170
- HttpHeaders["Origin"] = "Origin";
171
- /**
172
- * Specifies origins that are allowed to see values of attributes retrieved via features of the Resource Timing API,
173
- * which would otherwise be reported as zero due to cross-origin restrictions.
174
- */
175
- HttpHeaders["Timing_Allow_Origin"] = "Timing-Allow-Origin";
176
- /* *** Downloads *** */
177
- /**
178
- * Indicates if the resource transmitted should be displayed inline (default behavior without the header),
179
- * or if it should be handled like a download and the browser should present a "Save As" dialog.
180
- */
181
- HttpHeaders["Content_Disposition"] = "Content-Disposition";
182
- /* *** Message body information *** */
183
- /**
184
- * The size of the resource, in decimal number of bytes.
185
- */
186
- HttpHeaders["Content_Length"] = "Content-Length";
187
- /**
188
- * Indicates the media type of the resource.
189
- */
190
- HttpHeaders["Content_Type"] = "Content-Type";
191
- /**
192
- * Used to specify the compression algorithm.
193
- */
194
- HttpHeaders["Content_Encoding"] = "Content-Encoding";
195
- /**
196
- * Describes the human language(s) intended for the audience, so that it allows a user to
197
- * differentiate according to the users' own preferred language.
198
- */
199
- HttpHeaders["Content_Language"] = "Content-Language";
200
- /**
201
- * Indicates an alternate location for the returned data.
202
- */
203
- HttpHeaders["Content_Location"] = "Content-Location";
204
- // Proxies
205
- /**
206
- * Contains information from the client-facing side of proxy servers that is altered or
207
- * lost when a proxy is involved in the path of the request.
208
- */
209
- HttpHeaders["Forwarded"] = "Forwarded";
210
- /**
211
- * Identifies the originating IP addresses of a client connecting to a web server
212
- * through an HTTP proxy or a load balancer.
213
- */
214
- HttpHeaders["X_Forwarded_For"] = "X-Forwarded-For";
215
- /**
216
- * Identifies the original host requested that a client used to connect to your proxy or load balancer.
217
- */
218
- HttpHeaders["X_Forwarded_Host"] = "X-Forwarded-Host";
219
- /**
220
- * Identifies the protocol (HTTP or HTTPS) that a client used to connect to your proxy or load balancer.
221
- */
222
- HttpHeaders["X_Forwarded_Proto"] = "X-Forwarded-Proto";
223
- /**
224
- * Added by proxies, both forward and reverse proxies, and can appear in the request headers and the response headers.
225
- */
226
- HttpHeaders["Via"] = "Via";
227
- /* *** Redirects *** */
228
- /**
229
- * Indicates the URL to redirect a page to.
230
- */
231
- HttpHeaders["Location"] = "Location";
232
- /* *** Request context *** */
233
- /**
234
- * Contains an Internet email address for a human user who controls the requesting user agent.
235
- */
236
- HttpHeaders["From"] = "From";
237
- /**
238
- * Specifies the domain name of the server (for virtual hosting), and (optionally)
239
- * the TCP port number on which the server is listening.
240
- */
241
- HttpHeaders["Host"] = "Host";
242
- /**
243
- * The address of the previous web page from which a link to the currently requested page was followed.
244
- */
245
- HttpHeaders["Referer"] = "Referer";
246
- /**
247
- * Governs which referrer information sent in the Referer header should be included with requests made.
248
- */
249
- HttpHeaders["Referrer_Policy"] = "Referrer-Policy";
250
- /**
251
- * Contains a characteristic string that allows the network protocol peers to identify the application type,
252
- * operating system, software vendor or software version of the requesting software user agent.
253
- */
254
- HttpHeaders["User_Agent"] = "User-Agent";
255
- /* *** Response context *** */
256
- /**
257
- * Lists the set of HTTP request methods supported by a resource.
258
- */
259
- HttpHeaders["Allow"] = "Allow";
260
- /**
261
- * Contains information about the software used by the origin server to handle the request.
262
- */
263
- HttpHeaders["Server"] = "Server";
264
- /* *** Range requests *** */
265
- /**
266
- * Indicates if the server supports range requests, and if so in which unit the range can be expressed.
267
- */
268
- HttpHeaders["Accept_Ranges"] = "Accept-Ranges";
269
- /**
270
- * Indicates the part of a document that the server should return.
271
- */
272
- HttpHeaders["Range"] = "Range";
273
- /**
274
- * Creates a conditional range request that is only fulfilled if the given etag or date matches
275
- * the remote resource. Used to prevent downloading two ranges from incompatible version of the resource.
276
- */
277
- HttpHeaders["If_Range"] = "If-Range";
278
- /**
279
- * Indicates where in a full body message a partial message belongs.
280
- */
281
- HttpHeaders["Content_Range"] = "Content-Range";
282
- /* *** Security *** */
283
- /**
284
- * Allows a server to declare an embedder policy for a given document.
285
- */
286
- HttpHeaders["Cross_Origin_Embedder_Policy"] = "Cross-Origin-Embedder-Policy";
287
- /**
288
- * Prevents other domains from opening/controlling a window.
289
- */
290
- HttpHeaders["Cross_Origin_Opener_Policy"] = "Cross-Origin-Opener-Policy";
291
- /**
292
- * Prevents other domains from reading the response of the resources to which this header is applied.
293
- */
294
- HttpHeaders["Cross_Origin_Resource_Policy"] = "Cross-Origin-Resource-Policy";
295
- /**
296
- * Controls resources the user agent is allowed to load for a given page.
297
- */
298
- HttpHeaders["Content_Security_Policy"] = "Content-Security-Policy";
299
- /**
300
- * Allows web developers to experiment with policies by monitoring, but not enforcing, their effects.
301
- * These violation reports consist of JSON documents sent via an HTTP POST request to the specified URI.
302
- */
303
- HttpHeaders["Content_Security_Policy_Report_Only"] = "Content-Security-Policy-Report-Only";
304
- /**
305
- * Allows sites to opt in to reporting and/or enforcement of Certificate Transparency requirements,
306
- * which prevents the use of misissued certificates for that site from going unnoticed.
307
- * When a site enables the Expect-CT header, they are requesting that Chrome check that
308
- * any certificate for that site appears in public CT logs.
309
- */
310
- HttpHeaders["Expect_CT"] = "Expect-CT";
311
- /**
312
- * Provides a mechanism to allow and deny the use of browser features in its own frame,
313
- * and in iframes that it embeds.
314
- */
315
- HttpHeaders["Feature_Policy"] = "Feature-Policy";
316
- /**
317
- * Force communication using HTTPS instead of HTTP.
318
- */
319
- HttpHeaders["Strict_Transport_Security"] = "Strict-Transport-Security";
320
- /**
321
- * Sends a signal to the server expressing the client's preference for an encrypted and authenticated response,
322
- * and that it can successfully handle the upgrade-insecure-requests directive.
323
- */
324
- HttpHeaders["Upgrade_Insecure_Requests"] = "Upgrade-Insecure-Requests";
325
- /**
326
- * Disables MIME sniffing and forces browser to use the type given in Content-Type.
327
- */
328
- HttpHeaders["X_Content_Type_Options"] = "X-Content-Type-Options";
329
- /**
330
- * The X-Download-Options HTTP header indicates that the browser (Internet Explorer)
331
- * should not display the option to "Open" a file that has been downloaded from an application,
332
- * to prevent phishing attacks as the file otherwise would gain access to execute in the context of the application.
333
- */
334
- HttpHeaders["X_Download_Options"] = "X-Download-Options";
335
- /**
336
- * Indicates whether a browser should be allowed to render a page in a <frame>, <iframe>, <embed> or <object>.
337
- */
338
- HttpHeaders["X_Frame_Options"] = "X-Frame-Options";
339
- /**
340
- * Specifies if a cross-domain policy file (crossdomain.xml) is allowed.
341
- * The file may define a policy to grant clients, such as Adobe's Flash Player (now obsolete),
342
- * Adobe Acrobat, Microsoft Silverlight (now obsolete), or Apache Flex,
343
- * permission to handle data across domains that would otherwise be restricted
344
- * due to the Same-Origin Policy. See the Cross-domain Policy File Specification for more information.
345
- */
346
- HttpHeaders["X_Permitted_Cross_Domain_Policies"] = "X-Permitted-Cross-Domain-Policies";
347
- /**
348
- * May be set by hosting environments or other frameworks and contains information about
349
- * them while not providing any usefulness to the application or its visitors.
350
- * Unset this header to avoid exposing potential vulnerabilities.
351
- */
352
- HttpHeaders["X_Powered_By"] = "X-Powered-By";
353
- /**
354
- * Enables cross-site scripting filtering.
355
- */
356
- HttpHeaders["X_XSS_Protection"] = "X-XSS-Protection";
357
- /* *** Transfer coding *** */
358
- /**
359
- * Specifies the form of encoding used to safely transfer the resource to the user.
360
- */
361
- HttpHeaders["Transfer_Encoding"] = "Transfer-Encoding";
362
- /**
363
- * Specifies the transfer encodings the user agent is willing to accept.
364
- */
365
- HttpHeaders["TE"] = "TE";
366
- /**
367
- * Allows the sender to include additional fields at the end of chunked message.
368
- */
369
- HttpHeaders["Trailer"] = "Trailer";
370
- /* *** WebSockets *** */
371
- HttpHeaders["Sec_WebSocket_Key"] = "Sec-WebSocket-Key";
372
- HttpHeaders["Sec_WebSocket_Extensions"] = "Sec-WebSocket-Extensions";
373
- HttpHeaders["Sec_WebSocket_Accept"] = "Sec-WebSocket-Accept";
374
- HttpHeaders["Sec_WebSocket_Protocol"] = "Sec-WebSocket-Protocol";
375
- HttpHeaders["Sec_WebSocket_Version"] = "Sec-WebSocket-Version";
376
- /* *** Other *** */
377
- /**
378
- * Contains the date and time at which the message was originated.
379
- */
380
- HttpHeaders["Date"] = "Date";
381
- /**
382
- * Indicates how long the user agent should wait before making a follow-up request.
383
- */
384
- HttpHeaders["Retry_After"] = "Retry-After";
385
- /**
386
- * Communicates one or more metrics and descriptions for the given request-response cycle.
387
- */
388
- HttpHeaders["Server_Timing"] = "Server-Timing";
389
- /**
390
- * Controls DNS prefetching, a feature by which browsers proactively perform domain name
391
- * resolution on both links that the user may choose to follow as well as URLs for items
392
- * referenced by the document, including images, CSS, JavaScript, and so forth.
393
- */
394
- HttpHeaders["X_DNS_Prefetch_Control"] = "X-DNS-Prefetch-Control";
395
- })(HttpHeaders = exports.HttpHeaders || (exports.HttpHeaders = {}));