diskio-api 1.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.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ <p align="center">
2
+ <a href="https://github.com/xutyxd/diskio-server">
3
+ <picture>
4
+ <source srcset="../diskio-logo.png" width="150">
5
+ <img alt="diskio logo" src="./diskio-logo.png" width="150">
6
+ </picture>
7
+ </a>
8
+ </p>
9
+
10
+ <h1 align="center">
11
+ Client to interact with the Diskio Server API
12
+ </h1>
13
+
14
+ <p align="left">
15
+ <img src="https://img.shields.io/npm/dw/diskio-api"/>
16
+ <img alt="NPM Unpacked Size" src="https://img.shields.io/npm/unpacked-size/diskio-api">
17
+ <img alt="npm bundle size" src="https://img.shields.io/bundlephobia/min/diskio-api">
18
+ <img alt="NPM Version" src="https://img.shields.io/npm/v/diskio-api">
19
+ </p>
20
+
21
+ # Diskio Client
22
+ An API client for [diskio-server](https://github.com/xutyxd/diskio-server) exposed with OpenAPI.
23
+
24
+
25
+
26
+ ## 📦 Packages
27
+
28
+ ### 📦 CommonJS
29
+
30
+ ```js
31
+ const { DiskioAPIClient } = require('diskio-api');
32
+ ```
33
+
34
+ ### 📦 ESM
35
+
36
+ ```js
37
+ import { DiskioAPIClient } from 'diskio-api';
38
+ ```
39
+
40
+ ### 📦 TypeScript
41
+
42
+ ```ts
43
+ import { DiskioAPIClient } from 'diskio-api';
44
+ ```
45
+
46
+ ## 📝 License
47
+
48
+ This project is licensed under the `GNU AFFERO GENERAL PUBLIC LICENSE` - see the [LICENSE](LICENSE) file for details
package/cjs/index.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { components } from "../openapi/specification";
2
+ export declare class DiskioAPIClient {
3
+ private client;
4
+ private authentication?;
5
+ constructor(baseUrl: string);
6
+ private authenticate;
7
+ auth: {
8
+ set: (access_token: string) => void;
9
+ get: () => string | undefined;
10
+ };
11
+ healthCheck(): Promise<import("openapi-fetch").FetchResponse<{
12
+ parameters: {
13
+ query?: never;
14
+ header?: never;
15
+ path?: never;
16
+ cookie?: never;
17
+ };
18
+ requestBody?: never;
19
+ responses: {
20
+ 200: {
21
+ headers: {
22
+ [name: string]: unknown;
23
+ };
24
+ content: {
25
+ "application/json": components["schemas"]["response.model"] & {
26
+ data: number;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ }, import("openapi-fetch").FetchOptions<{
32
+ parameters: {
33
+ query?: never;
34
+ header?: never;
35
+ path?: never;
36
+ cookie?: never;
37
+ };
38
+ requestBody?: never;
39
+ responses: {
40
+ 200: {
41
+ headers: {
42
+ [name: string]: unknown;
43
+ };
44
+ content: {
45
+ "application/json": components["schemas"]["response.model"] & {
46
+ data: number;
47
+ };
48
+ };
49
+ };
50
+ };
51
+ }> | undefined, `${string}/${string}`>>;
52
+ }
package/cjs/index.js ADDED
@@ -0,0 +1,33 @@
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
+ exports.DiskioAPIClient = void 0;
7
+ const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
8
+ class DiskioAPIClient {
9
+ constructor(baseUrl) {
10
+ this.authenticate = {
11
+ onRequest: ({ request }) => {
12
+ if (this.authentication) {
13
+ request.headers.set('Authorization', `Bearer ${this.authentication}`);
14
+ }
15
+ return request;
16
+ }
17
+ };
18
+ this.auth = {
19
+ set: (access_token) => {
20
+ this.authentication = access_token;
21
+ },
22
+ get: () => {
23
+ return this.authentication;
24
+ }
25
+ };
26
+ this.client = (0, openapi_fetch_1.default)({ baseUrl, headers: { Bearer: 'access_token' } });
27
+ this.client.use(this.authenticate);
28
+ }
29
+ healthCheck() {
30
+ return this.client.GET('/health-check');
31
+ }
32
+ }
33
+ exports.DiskioAPIClient = DiskioAPIClient;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/mjs/index.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { components } from "../openapi/specification";
2
+ export declare class DiskioAPIClient {
3
+ private client;
4
+ private authentication?;
5
+ constructor(baseUrl: string);
6
+ private authenticate;
7
+ auth: {
8
+ set: (access_token: string) => void;
9
+ get: () => string | undefined;
10
+ };
11
+ healthCheck(): Promise<import("openapi-fetch").FetchResponse<{
12
+ parameters: {
13
+ query?: never;
14
+ header?: never;
15
+ path?: never;
16
+ cookie?: never;
17
+ };
18
+ requestBody?: never;
19
+ responses: {
20
+ 200: {
21
+ headers: {
22
+ [name: string]: unknown;
23
+ };
24
+ content: {
25
+ "application/json": components["schemas"]["response.model"] & {
26
+ data: number;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ }, import("openapi-fetch").FetchOptions<{
32
+ parameters: {
33
+ query?: never;
34
+ header?: never;
35
+ path?: never;
36
+ cookie?: never;
37
+ };
38
+ requestBody?: never;
39
+ responses: {
40
+ 200: {
41
+ headers: {
42
+ [name: string]: unknown;
43
+ };
44
+ content: {
45
+ "application/json": components["schemas"]["response.model"] & {
46
+ data: number;
47
+ };
48
+ };
49
+ };
50
+ };
51
+ }> | undefined, `${string}/${string}`>>;
52
+ }
package/mjs/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import createClient from "openapi-fetch";
2
+ export class DiskioAPIClient {
3
+ constructor(baseUrl) {
4
+ this.authenticate = {
5
+ onRequest: ({ request }) => {
6
+ if (this.authentication) {
7
+ request.headers.set('Authorization', `Bearer ${this.authentication}`);
8
+ }
9
+ return request;
10
+ }
11
+ };
12
+ this.auth = {
13
+ set: (access_token) => {
14
+ this.authentication = access_token;
15
+ },
16
+ get: () => {
17
+ return this.authentication;
18
+ }
19
+ };
20
+ this.client = createClient({ baseUrl, headers: { Bearer: 'access_token' } });
21
+ this.client.use(this.authenticate);
22
+ }
23
+ healthCheck() {
24
+ return this.client.GET('/health-check');
25
+ }
26
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+
6
+ export interface paths {
7
+ "/health-check": {
8
+ parameters: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ /** Health check endpoint */
15
+ get: {
16
+ parameters: {
17
+ query?: never;
18
+ header?: never;
19
+ path?: never;
20
+ cookie?: never;
21
+ };
22
+ requestBody?: never;
23
+ responses: {
24
+ /** @description Correct response indicating that the server is alive */
25
+ 200: {
26
+ headers: {
27
+ [name: string]: unknown;
28
+ };
29
+ content: {
30
+ "application/json": components["schemas"]["response.model"] & {
31
+ data: number;
32
+ };
33
+ };
34
+ };
35
+ };
36
+ };
37
+ put?: never;
38
+ post?: never;
39
+ delete?: never;
40
+ options?: never;
41
+ head?: never;
42
+ patch?: never;
43
+ trace?: never;
44
+ };
45
+ }
46
+ export type webhooks = Record<string, never>;
47
+ export interface components {
48
+ schemas: {
49
+ "id-request.model": {
50
+ /** @example f0a6f400-be55-42ae-9545-1bcba9b69b99 */
51
+ uuid: string;
52
+ };
53
+ "response.model": {
54
+ /** @example 200 */
55
+ code: number;
56
+ /** @example 1707947871721 */
57
+ timestamp: number;
58
+ };
59
+ };
60
+ responses: never;
61
+ parameters: never;
62
+ requestBodies: never;
63
+ headers: never;
64
+ pathItems: never;
65
+ }
66
+ export type $defs = Record<string, never>;
67
+ export type operations = Record<string, never>;
@@ -0,0 +1,95 @@
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "Crosscutting API",
5
+ "summary": "A boilerplate for building contract-first APIs in TypeScript with OpenAPI. Includes OpenAPI definition, compliant server setup, and npm package generation for seamless API development.",
6
+ "version": "0.0.0"
7
+ },
8
+ "servers": [
9
+ {
10
+ "url": "https://localhost:8080",
11
+ "description": "Production server"
12
+ }
13
+ ],
14
+ "tags": [
15
+ {
16
+ "name": "Crosscutting",
17
+ "description": "Operation related to a crosscutting actions"
18
+ }
19
+ ],
20
+ "paths": {
21
+ "/health-check": {
22
+ "get": {
23
+ "tags": [
24
+ "Crosscutting"
25
+ ],
26
+ "summary": "Health check endpoint",
27
+ "responses": {
28
+ "200": {
29
+ "description": "Correct response indicating that the server is alive",
30
+ "content": {
31
+ "application/json": {
32
+ "schema": {
33
+ "example": {
34
+ "code": 200,
35
+ "data": 1523,
36
+ "timestamp": 1707947871722
37
+ },
38
+ "allOf": [
39
+ {
40
+ "$ref": "#/components/schemas/response.model"
41
+ },
42
+ {
43
+ "type": "object",
44
+ "required": [
45
+ "data"
46
+ ],
47
+ "properties": {
48
+ "data": {
49
+ "type": "number"
50
+ }
51
+ }
52
+ }
53
+ ]
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ },
62
+ "components": {
63
+ "schemas": {
64
+ "id-request.model": {
65
+ "type": "object",
66
+ "required": [
67
+ "uuid"
68
+ ],
69
+ "properties": {
70
+ "uuid": {
71
+ "type": "string",
72
+ "example": "f0a6f400-be55-42ae-9545-1bcba9b69b99"
73
+ }
74
+ }
75
+ },
76
+ "response.model": {
77
+ "type": "object",
78
+ "required": [
79
+ "code",
80
+ "timestamp"
81
+ ],
82
+ "properties": {
83
+ "code": {
84
+ "type": "number",
85
+ "example": "200"
86
+ },
87
+ "timestamp": {
88
+ "type": "number",
89
+ "example": "1707947871721"
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "diskio-api",
3
+ "version": "1.0.0",
4
+ "description": "An API Client for diskio-server",
5
+ "type": "module",
6
+ "main": "cjs/index.js",
7
+ "module": "mjs/index.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./mjs/index.js",
11
+ "require": "./cjs/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "cjs",
16
+ "mjs",
17
+ "openapi"
18
+ ],
19
+ "scripts": {},
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/xutyxd/diskio-server.git"
23
+ },
24
+ "author": "XutyXD",
25
+ "license": "ISC",
26
+ "bugs": {
27
+ "url": "https://github.com/xutyxd/diskio-server/issues"
28
+ },
29
+ "homepage": "https://github.com/xutyxd/diskio-server#readme",
30
+ "keywords": [
31
+ "diskio",
32
+ "diskio-core",
33
+ "diskio-server",
34
+ "file-system",
35
+ "io",
36
+ "fs",
37
+ "api"
38
+ ],
39
+ "dependencies": {
40
+ "openapi-fetch": "^0.12.0"
41
+ }
42
+ }