@haibun/web-http 1.13.6 → 1.15.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.
@@ -1,27 +1,26 @@
1
- import { TNamed, AStepper } from '@haibun/core/build/lib/defs';
1
+ import { TNamed, AStepper } from '@haibun/core/build/lib/defs.js';
2
2
  declare const WebHttp: {
3
3
  new (): {
4
4
  steps: {
5
5
  listening: {
6
6
  gwta: string;
7
- action: ({ url }: TNamed) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult>;
7
+ action: ({ url }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
8
8
  };
9
9
  oidc_config: {
10
10
  gwta: string;
11
- action: ({ url }: TNamed) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult | import("@haibun/core/build/lib/defs").TNotOKActionResult>;
11
+ action: ({ url }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
12
12
  };
13
13
  hasContent: {
14
14
  gwta: string;
15
- action: ({ url, what }: TNamed) => Promise<import("@haibun/core/build/lib/defs").TOKActionResult | import("@haibun/core/build/lib/defs").TNotOKActionResult>;
15
+ action: ({ url, what }: TNamed) => Promise<import("@haibun/core/build/lib/defs.js").TOKActionResult | import("@haibun/core/build/lib/defs.js").TNotOKActionResult>;
16
16
  };
17
17
  };
18
- world?: import("@haibun/core/build/lib/defs").TWorld | undefined;
18
+ world?: import("@haibun/core/build/lib/defs.js").TWorld;
19
19
  close?(): void;
20
20
  endFeature?(): void;
21
- onFailure?(result: import("@haibun/core/build/lib/defs").TStepResult): void;
22
- setWorld(world: import("@haibun/core/build/lib/defs").TWorld, steppers: AStepper[]): void;
23
- getWorld(): import("@haibun/core/build/lib/defs").TWorld;
21
+ onFailure?(result: import("@haibun/core/build/lib/defs.js").TStepResult): void;
22
+ setWorld(world: import("@haibun/core/build/lib/defs.js").TWorld, steppers: AStepper[]): void;
23
+ getWorld(): import("@haibun/core/build/lib/defs.js").TWorld;
24
24
  };
25
25
  };
26
26
  export default WebHttp;
27
- //# sourceMappingURL=web-http.d.ts.map
package/build/web-http.js CHANGED
@@ -1,38 +1,36 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const got_1 = __importDefault(require("got"));
7
- const defs_1 = require("@haibun/core/build/lib/defs");
8
- const util_1 = require("@haibun/core/build/lib/util");
9
- const WebHttp = class WebHttp extends defs_1.AStepper {
10
- constructor() {
11
- super(...arguments);
12
- this.steps = {
13
- listening: {
14
- gwta: 'http {url} is listening',
15
- action: async ({ url }) => {
16
- await got_1.default.get({ url, throwHttpErrors: false });
17
- return defs_1.OK;
18
- },
1
+ import { OK, AStepper } from '@haibun/core/build/lib/defs.js';
2
+ import { actionNotOK } from '@haibun/core/build/lib/util/index.js';
3
+ const WebHttp = class WebHttp extends AStepper {
4
+ steps = {
5
+ listening: {
6
+ gwta: 'http {url} is listening',
7
+ action: async ({ url }) => {
8
+ try {
9
+ await fetch(url);
10
+ return OK;
11
+ }
12
+ catch (e) {
13
+ return actionNotOK(`${url} is not listening`, { topics: { result: { summary: 'error', details: e } } });
14
+ }
19
15
  },
20
- oidc_config: {
21
- gwta: 'http {url} has an oidc well-known configuration',
22
- action: async ({ url }) => {
23
- const json = await got_1.default.get({ url: `${url}/.well-known/openid-configuration` }).json();
24
- return json.authorization_endpoint ? defs_1.OK : (0, util_1.actionNotOK)(`${json} not recognized`, { topics: { result: { summary: 'json', details: json } } });
25
- },
16
+ },
17
+ oidc_config: {
18
+ gwta: 'http {url} has an oidc well-known configuration',
19
+ action: async ({ url }) => {
20
+ const response = await fetch(`${url}/.well-known/openid-configuration`);
21
+ const json = await response.json();
22
+ return json.authorization_endpoint ? OK : actionNotOK(`${json} not recognized`, { topics: { result: { summary: 'json', details: json } } });
26
23
  },
27
- hasContent: {
28
- gwta: 'fetch from {url} is {what}',
29
- action: async ({ url, what }) => {
30
- const text = await (0, got_1.default)(url).text();
31
- return text === what ? defs_1.OK : (0, util_1.actionNotOK)(`${url} does not contain ${what}, it contains ${text}`);
32
- },
24
+ },
25
+ hasContent: {
26
+ gwta: 'fetch from {url} is {what}',
27
+ action: async ({ url, what }) => {
28
+ const response = await fetch(url);
29
+ const text = await response.text();
30
+ return text === what ? OK : actionNotOK(`${url} does not contain ${what}, it contains ${text}`);
33
31
  },
34
- };
35
- }
32
+ },
33
+ };
36
34
  };
37
- exports.default = WebHttp;
35
+ export default WebHttp;
38
36
  //# sourceMappingURL=web-http.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-http.js","sourceRoot":"","sources":["../src/web-http.ts"],"names":[],"mappings":";;;;;AAAA,8CAAsB;AAEtB,sDAAmE;AACnE,sDAA0D;AAE1D,MAAM,OAAO,GAAG,MAAM,OAAQ,SAAQ,eAAQ;IAA9B;;QACd,UAAK,GAAG;YACN,SAAS,EAAE;gBACT,IAAI,EAAE,yBAAyB;gBAC/B,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAU,EAAE,EAAE;oBAChC,MAAM,aAAG,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAC;oBAC/C,OAAO,SAAE,CAAC;gBACZ,CAAC;aACF;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,iDAAiD;gBACvD,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAU,EAAE,EAAE;oBAChC,MAAM,IAAI,GAAG,MAAM,aAAG,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,mCAAmC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;oBACtF,OAAQ,IAAY,CAAC,sBAAsB,CAAC,CAAC,CAAC,SAAE,CAAC,CAAC,CAAC,IAAA,kBAAW,EAAC,G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;YACH,CAAC;SACF;QACD,WAAW,EAAE;YACX,IAAI,EAAE,iDAAiD;YACvD,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAU,EAAE,EAAE;gBAChC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,mCAAmC,CAAC,CAAC;gBACxE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnC,OAAO,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,IAAI,iBAAiB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAC9I,CAAC;SACF;QACD,UAAU,EAAE;YACV,IAAI,EAAE,4BAA4B;YAClC,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAU,EAAE,EAAE;gBACtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClC,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnC,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,GAAG,qBAAqB,IAAI,iBAAiB,IAAI,EAAE,CAAC,CAAA;YACjG,CAAC;SACF;KACF,CAAC;CACH,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=web-http.test.d.ts.map
@@ -1,12 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const web_http_1 = __importDefault(require("./web-http"));
1
+ import WebHttp from "./web-http.js";
7
2
  describe('web-http', () => {
8
3
  it('exists', () => {
9
- expect(web_http_1.default).toBeDefined();
4
+ expect(WebHttp).toBeDefined();
10
5
  });
11
6
  });
12
7
  //# sourceMappingURL=web-http.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-http.test.js","sourceRoot":"","sources":["../src/web-http.test.ts"],"names":[],"mappings":";;;;;AAAA,0DAAgC;AAEhC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACd,MAAM,CAAC,kBAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"web-http.test.js","sourceRoot":"","sources":["../src/web-http.test.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAA;AAEnC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACd,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@haibun/web-http",
3
- "version": "1.13.6",
3
+ "type": "module",
4
+ "version": "1.15.0",
4
5
  "description": "",
5
6
  "main": "build/web-http.js",
6
7
  "files": [
7
8
  "build/"
8
9
  ],
9
10
  "scripts": {
11
+ "build": "tsc -b .",
10
12
  "prepublishOnly": "tsc -b .",
11
13
  "test": "jest --config jest.config.ts",
12
14
  "test-watch": "jest --config jest.config.ts --watch"
@@ -15,22 +17,21 @@
15
17
  "author": "",
16
18
  "license": "ISC",
17
19
  "dependencies": {
18
- "got": "^11.8.2"
20
+ "@haibun/core": "1.15.0"
19
21
  },
20
22
  "devDependencies": {
21
23
  "@types/jest": "^29.2.4",
22
24
  "@types/node": "^18.11.14",
23
- "@typescript-eslint/eslint-plugin": "^4.13.0",
24
- "@typescript-eslint/parser": "^4.13.0",
25
- "eslint": "^7.2.0",
26
- "eslint-config-airbnb-typescript": "^12.0.0",
27
- "eslint-config-prettier": "^8.3.0",
25
+ "@typescript-eslint/eslint-plugin": "^5.48.0",
26
+ "@typescript-eslint/parser": "^5.48.0",
27
+ "eslint": "^8.31.0",
28
+ "eslint-config-airbnb-typescript": "^17.0.0",
29
+ "eslint-config-prettier": "^8.6.0",
28
30
  "eslint-plugin-import": "^2.22.1",
29
31
  "eslint-plugin-prefer-arrow": "^1.2.2",
30
- "eslint-plugin-prettier": "^3.3.1",
32
+ "eslint-plugin-prettier": "^4.2.1",
31
33
  "jest": "^29.3.1",
32
- "prettier": "^2.3.1",
33
- "ts-node": "^10.0.0",
34
+ "prettier": "^2.8.1",
34
35
  "tslint": "^6.1.3",
35
36
  "typescript": "^4.6.3"
36
37
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-http.d.ts","sourceRoot":"","sources":["../src/web-http.ts"],"names":[],"mappings":"AAEA,OAAO,EAAM,MAAM,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGnE,QAAA,MAAM,OAAO;;;;;kCAIiB,MAAM;;;;kCAON,MAAM;;;;wCAOA,MAAM;;;;;;;;;;CAMzC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-http.test.d.ts","sourceRoot":"","sources":["../src/web-http.test.ts"],"names":[],"mappings":""}