@haibun/web-http 1.31.3 → 1.32.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/build/web-http.d.ts +27 -3
- package/build/web-http.js +66 -11
- package/build/web-http.js.map +1 -1
- package/package.json +3 -2
package/build/web-http.d.ts
CHANGED
|
@@ -10,13 +10,37 @@ declare const WebHttp: {
|
|
|
10
10
|
gwta: string;
|
|
11
11
|
action: ({ url }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
12
12
|
};
|
|
13
|
+
statusIs: {
|
|
14
|
+
gwta: string;
|
|
15
|
+
action: ({ url, method, status }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
16
|
+
};
|
|
17
|
+
hasContentType: {
|
|
18
|
+
gwta: string;
|
|
19
|
+
action: ({ url, method, contentType }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
20
|
+
};
|
|
21
|
+
requestWithBody: {
|
|
22
|
+
gwta: string;
|
|
23
|
+
action: ({ method, url, contentType, body, status }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
24
|
+
};
|
|
25
|
+
requestWithNoBody: {
|
|
26
|
+
gwta: string;
|
|
27
|
+
action: ({ method, url, contentType, status }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
28
|
+
};
|
|
13
29
|
containsContent: {
|
|
14
30
|
gwta: string;
|
|
15
|
-
action: ({ url, what }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
31
|
+
action: ({ method, url, what }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
32
|
+
};
|
|
33
|
+
returnsNoContent: {
|
|
34
|
+
gwta: string;
|
|
35
|
+
action: ({ method, url }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
36
|
+
};
|
|
37
|
+
returnsContent: {
|
|
38
|
+
gwta: string;
|
|
39
|
+
action: ({ method, url, what }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
16
40
|
};
|
|
17
|
-
|
|
41
|
+
headerWith: {
|
|
18
42
|
gwta: string;
|
|
19
|
-
action: ({ url,
|
|
43
|
+
action: ({ method, url, header, contents }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
|
|
20
44
|
};
|
|
21
45
|
};
|
|
22
46
|
world?: import("@haibun/core/build/lib/defs.js").TWorld;
|
package/build/web-http.js
CHANGED
|
@@ -15,27 +15,82 @@ const WebHttp = class WebHttp extends AStepper {
|
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
oidc_config: {
|
|
18
|
-
gwta: 'http {url} has an oidc
|
|
18
|
+
gwta: 'http {url} webpage has an oidc endpoint',
|
|
19
19
|
action: async ({ url }) => {
|
|
20
20
|
const response = await fetch(`${url}/.well-known/openid-configuration`);
|
|
21
21
|
const json = await response.json();
|
|
22
|
-
return json.authorization_endpoint ? OK : actionNotOK(`${json}
|
|
22
|
+
return json.authorization_endpoint ? OK : actionNotOK(`${json} has no endpoint`, { topics: { result: { summary: 'json', details: json } } });
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
statusIs: {
|
|
26
|
+
gwta: 'http {method} from {url} webpage returns status {status}',
|
|
27
|
+
action: async ({ url, method, status }) => {
|
|
28
|
+
const response = await fetch(url, { method: method.toUpperCase() });
|
|
29
|
+
return response.status === parseInt(status) ? OK : actionNotOK(`$${method} {url} does not have status ${status}, it has ${response.status}`);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
hasContentType: {
|
|
33
|
+
gwta: 'http {method} from {url} webpage returns content-type {contentType}',
|
|
34
|
+
action: async ({ url, method, contentType }) => {
|
|
35
|
+
const response = await fetch(url, { method: method.toUpperCase() });
|
|
36
|
+
const requestContentType = response.headers.get('content-type');
|
|
37
|
+
return requestContentType === contentType ? OK : actionNotOK(`${method} ${url} does not have content type ${contentType}, it has ${requestContentType}`);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
requestWithBody: {
|
|
41
|
+
gwta: 'http {method} to {url} webpage with {contentType} body {body} returns status {status}',
|
|
42
|
+
action: async ({ method, url, contentType, body, status }) => {
|
|
43
|
+
const response = await fetch(url, { method: 'POST', body: JSON.stringify(JSON.parse(body)), headers: { contentType } });
|
|
44
|
+
if (response.status === parseInt(status, 10)) {
|
|
45
|
+
return OK;
|
|
46
|
+
}
|
|
47
|
+
const message = contentType === 'json' ? await response.json() : await response.text();
|
|
48
|
+
return actionNotOK(`${method} ${url} did not return ${status}, it returned ${response.status} with message ${message}`);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
requestWithNoBody: {
|
|
52
|
+
gwta: 'http {method} to {url} webpage returns status {status}',
|
|
53
|
+
action: async ({ method, url, contentType, status }) => {
|
|
54
|
+
const response = await fetch(url, { method: method.toUpperCase(), headers: { contentType } });
|
|
55
|
+
if (response.status === parseInt(status, 10)) {
|
|
56
|
+
return OK;
|
|
57
|
+
}
|
|
58
|
+
const message = contentType === 'json' ? await response.json() : await response.text();
|
|
59
|
+
return actionNotOK(`${method} ${url} did not return ${status}, it returned ${response.status} with message ${message}`);
|
|
23
60
|
},
|
|
24
61
|
},
|
|
25
62
|
containsContent: {
|
|
26
|
-
gwta: '
|
|
27
|
-
action: async ({ url, what }) => {
|
|
28
|
-
const response = await fetch(url);
|
|
63
|
+
gwta: 'http {method} from {url} webpage contains {what}',
|
|
64
|
+
action: async ({ method, url, what }) => {
|
|
65
|
+
const response = await fetch(url, { method: method.toUpperCase() });
|
|
66
|
+
const text = await response.text();
|
|
67
|
+
return text.includes(what) ? OK : actionNotOK(`${method} ${url} does not contain ${what}, it contains ${text}`);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
returnsNoContent: {
|
|
71
|
+
gwta: 'http {method} from {url} webpage returns no content',
|
|
72
|
+
action: async ({ method, url }) => {
|
|
73
|
+
const response = await fetch(url, { method: method.toUpperCase() });
|
|
29
74
|
const text = await response.text();
|
|
30
|
-
return text
|
|
75
|
+
return text === "" ? OK : actionNotOK(`${method} ${url} does not contain no content, it contains ${text}`);
|
|
31
76
|
},
|
|
32
77
|
},
|
|
33
|
-
|
|
34
|
-
gwta: '
|
|
35
|
-
action: async ({ url, what }) => {
|
|
36
|
-
const response = await fetch(url);
|
|
78
|
+
returnsContent: {
|
|
79
|
+
gwta: 'http {method} from {url} webpage returns content {what}',
|
|
80
|
+
action: async ({ method, url, what }) => {
|
|
81
|
+
const response = await fetch(url, { method: method.toUpperCase() });
|
|
37
82
|
const text = await response.text();
|
|
38
|
-
return text === what ? OK : actionNotOK(`${url} does not contain ${what}, it contains ${text}`);
|
|
83
|
+
return text === what ? OK : actionNotOK(`${method} ${url} does not contain ${what}, it contains ${text}`);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
// http options from resource webpage returns header "Allow" with "GET, HEAD, OPTIONS, PUT, DELETE"
|
|
87
|
+
headerWith: {
|
|
88
|
+
gwta: 'http {method} from {url} webpage returns header {header} with {contents}',
|
|
89
|
+
action: async ({ method, url, header, contents }) => {
|
|
90
|
+
const response = await fetch(url, { method: method.toUpperCase() });
|
|
91
|
+
const headers = response.headers;
|
|
92
|
+
console.log('headers', headers);
|
|
93
|
+
return headers[header.toLowerCase()] === contents ? OK : actionNotOK(`${method} ${url} does not contain ${header} with ${contents}, it contains ${JSON.stringify(headers)}`);
|
|
39
94
|
},
|
|
40
95
|
},
|
|
41
96
|
};
|
package/build/web-http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-http.js","sourceRoot":"","sources":["../src/web-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAU,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEnE,MAAM,OAAO,GAAG,MAAM,OAAQ,SAAQ,QAAQ;IAC5C,KAAK,GAAG;QACN,SAAS,EAAE;YACT,IAAI,EAAE,yBAAyB;YAC/B,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAU,EAAE,EAAE;gBAChC,IAAI;oBACF,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;oBACjB,OAAO,EAAE,CAAC;iBACX;gBAAC,OAAO,CAAC,EAAE;oBACV,OAAO,WAAW,CAAC,GAAG,GAAG,mBAAmB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;iBACzG;YACH,CAAC;SACF;QACD,WAAW,EAAE;YACX,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"web-http.js","sourceRoot":"","sources":["../src/web-http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAU,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEnE,MAAM,OAAO,GAAG,MAAM,OAAQ,SAAQ,QAAQ;IAC5C,KAAK,GAAG;QACN,SAAS,EAAE;YACT,IAAI,EAAE,yBAAyB;YAC/B,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAU,EAAE,EAAE;gBAChC,IAAI;oBACF,MAAM,KAAK,CAA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CAAC,OAAO,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBAChC,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI,GAAG,qBAAqB,MAAM,SAAS,QAAQ,iBAAiB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC9K,CAAC;SACF;KACF,CAAC;CACH,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haibun/web-http",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.32.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "build/web-http.js",
|
|
7
7
|
"files": [
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc -b .",
|
|
12
|
+
"build-watch": "tsc -b . -w",
|
|
12
13
|
"prepublishOnly": "tsc -b .",
|
|
13
14
|
"lint": "eslint -c .eslintrc.json --ext .ts,.js src",
|
|
14
15
|
"preversion": "npm run lint",
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
"author": "",
|
|
20
21
|
"license": "ISC",
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@haibun/core": "1.
|
|
23
|
+
"@haibun/core": "1.32.0"
|
|
23
24
|
},
|
|
24
25
|
"gitHead": "7cf9680bd922fb622fb59f1e6bf5b65284cb8fd5"
|
|
25
26
|
}
|