@motionpicture/coa-service 10.0.0-alpha.0 → 10.0.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.
@@ -4,7 +4,6 @@ import { AbstractCredentialsRepo } from './repo/credentials';
4
4
  export interface IOptions {
5
5
  endpoint: string;
6
6
  refreshToken?: string;
7
- useFetch: boolean;
8
7
  /**
9
8
  * カスタム認証情報リポジトリ
10
9
  */
@@ -194,9 +194,7 @@ class RefreshTokenClient {
194
194
  * 認証情報が適切である前提でAPIリクエストを投げる
195
195
  */
196
196
  async makeRequest(options, expectedStatusCodes) {
197
- const transporter = (this.options.useFetch === true)
198
- ? new transporters_1.FetchTransporter(expectedStatusCodes)
199
- : new transporters_1.FetchTransporter(expectedStatusCodes);
197
+ const transporter = new transporters_1.FetchTransporter(expectedStatusCodes);
200
198
  return transporter.request(options);
201
199
  }
202
200
  /**
@@ -27,101 +27,6 @@ exports.RESPONSE_BODY_STAUS_SUCCESS = 0;
27
27
  class Transporter {
28
28
  }
29
29
  exports.Transporter = Transporter;
30
- // export class DefaultTransporter implements Transporter {
31
- // /**
32
- // * Default user agent.
33
- // */
34
- // public static readonly USER_AGENT: string = `coa-service/${pkg.version}`;
35
- // public expectedStatusCodes: number[];
36
- // constructor(expectedStatusCodes: number[]) {
37
- // this.expectedStatusCodes = expectedStatusCodes;
38
- // }
39
- // /**
40
- // * Configures request options before making a request.
41
- // */
42
- // public static CONFIGURE(
43
- // options: IRequestOptions
44
- // ): IRequestOptions & Pick<request.OptionsWithUri, 'json' | 'useQuerystring'> {
45
- // // set transporter user agent
46
- // options.headers = (options.headers !== undefined) ? options.headers : {};
47
- // /* istanbul ignore else */
48
- // if (!options.headers['User-Agent']) {
49
- // options.headers['User-Agent'] = DefaultTransporter.USER_AGENT;
50
- // } else if (options.headers['User-Agent'].indexOf(DefaultTransporter.USER_AGENT) === -1) {
51
- // options.headers['User-Agent'] = `${options.headers['User-Agent']} ${DefaultTransporter.USER_AGENT}`;
52
- // } else {
53
- // // no operation
54
- // }
55
- // return {
56
- // ...options,
57
- // json: true,
58
- // useQuerystring: true
59
- // };
60
- // }
61
- // /**
62
- // * Makes a request with given options and invokes callback.
63
- // */
64
- // public async request(options: IRequestOptions): Promise<IResponseBody> {
65
- // const requestOptions = DefaultTransporter.CONFIGURE(options);
66
- // debug('requesting...', requestOptions);
67
- // return new Promise<any>((resolve, reject) => {
68
- // request(requestOptions, (error, response, body) => {
69
- // try {
70
- // resolve(this.wrapCallback(error, response, body, requestOptions));
71
- // } catch (callbackErr) {
72
- // reject(callbackErr);
73
- // }
74
- // });
75
- // });
76
- // }
77
- // /**
78
- // * Wraps the response callback.
79
- // */
80
- // private wrapCallback(error: any, response: request.RequestResponse, body: any, options: IRequestOptions): IResponseBody {
81
- // const requestOptions = { uri: options.uri };
82
- // let err: COAServiceError =
83
- // new COAServiceError(INTERNAL_SERVER_ERROR, '', 'An unexpected error occurred.', requestOptions);
84
- // if (error instanceof Error) {
85
- // throw new COAServiceError(INTERNAL_SERVER_ERROR, '', error.message, requestOptions);
86
- // }
87
- // debug('request processed', error, body, response.statusCode);
88
- // const statusFromBody = body?.status;
89
- // /* istanbul ignore else */
90
- // if (response.statusCode !== undefined) {
91
- // if (this.expectedStatusCodes.indexOf(response.statusCode) < 0) {
92
- // if (typeof body === 'string') {
93
- // // Consider all 4xx and 5xx responses errors.
94
- // err = new COAServiceError(response.statusCode, '', body, requestOptions);
95
- // } else {
96
- // // エラーレスポンスにステータスがあった場合
97
- // /* istanbul ignore else */
98
- // if (statusFromBody !== undefined) {
99
- // err = new COAServiceError(response.statusCode, statusFromBody, body.message, requestOptions);
100
- // } else {
101
- // // no operation
102
- // }
103
- // }
104
- // } else {
105
- // // HTTPステータスコード2xxでも、レスポンス本文のステータスが0でなければBadRequest
106
- // if (statusFromBody !== undefined && statusFromBody !== RESPONSE_BODY_STAUS_SUCCESS) {
107
- // err = new COAServiceError(response.statusCode, statusFromBody, body.message, requestOptions);
108
- // } else {
109
- // // if (response.statusCode === NO_CONTENT) {
110
- // // // consider 204
111
- // // return;
112
- // // } else {
113
- // // // consider 200,201
114
- // // return body;
115
- // // }
116
- // return body;
117
- // }
118
- // }
119
- // } else {
120
- // // no operation
121
- // }
122
- // throw err;
123
- // }
124
- // }
125
30
  /**
126
31
  * FetchTransporter
127
32
  */
package/package.json CHANGED
@@ -13,32 +13,28 @@
13
13
  }
14
14
  ],
15
15
  "dependencies": {
16
- "@coasystems/factory": "1.0.0-alpha.0",
16
+ "@coasystems/factory": "1.0.0",
17
17
  "debug": "4.4.3"
18
18
  },
19
19
  "description": "COA SDK",
20
20
  "devDependencies": {
21
21
  "@eslint/js": "9.39.4",
22
22
  "@types/debug": "4.1.13",
23
- "@types/mocha": "^5.2.0",
24
23
  "@types/node": "22.19.17",
25
- "@types/sinon": "^4.3.3",
24
+ "@vitest/coverage-v8": "4.1.3",
25
+ "@vitest/ui": "4.1.3",
26
26
  "eslint": "9.39.4",
27
- "mocha": "^5.2.0",
28
27
  "moment": "^2.22.1",
29
- "nyc": "^15.1.0",
30
28
  "redis": "4.6.5",
31
29
  "rimraf": "^2.6.2",
32
- "sinon": "^5.0.10",
33
- "ts-node": "10.8.0",
34
30
  "typescript": "5.6.3",
35
- "typescript-eslint": "8.58.0"
31
+ "typescript-eslint": "8.58.0",
32
+ "vitest": "4.1.3"
36
33
  },
37
34
  "engines": {
38
35
  "node": ">=18.0.0",
39
36
  "npm": ">=10.0.0"
40
37
  },
41
- "keywords": [],
42
38
  "license": "UNLICENSED",
43
39
  "main": "./lib/index.js",
44
40
  "types": "./lib/index.d.ts",
@@ -52,16 +48,15 @@
52
48
  },
53
49
  "scripts": {
54
50
  "build": "tsc",
51
+ "check:all": "npm run clean && npm run build && npm test",
55
52
  "eslint": "eslint \"src/**/*.ts\"",
53
+ "coverage": "vitest run --coverage",
56
54
  "clean": "rimraf \"npm-debug.log*\" ./lib ./docs ./coverage ./.nyc_output",
57
- "mocha": "mocha",
58
- "nyc": "nyc mocha \"src/**/*.spec.ts\"",
59
- "coverage": "npm run nyc && nyc report --reporter=text-summary",
60
55
  "test": "npm run eslint && npm run coverage",
61
- "preversion": "npm run clean && npm run build && npm test",
56
+ "preversion": "npm run check:all",
62
57
  "version": "git add -A",
63
58
  "postversion": "git push origin --tags",
64
- "prepublishOnly": "npm run clean && npm run build && npm test"
59
+ "prepublishOnly": "npm run clean && npm run build"
65
60
  },
66
- "version": "10.0.0-alpha.0"
61
+ "version": "10.0.0"
67
62
  }