@elementor/http-client 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+ # @elementor/http-client
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7daaa99: Rename `http` package to `http-client`
8
+
9
+ ## 0.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - f6a4d4f: add API client and hooks for enabling unfiltered files upload
14
+
15
+ ## 0.1.3
16
+
17
+ ### Patch Changes
18
+
19
+ - 317ca04: Load existing global classes on init
20
+
21
+ ## 0.1.2
22
+
23
+ ### Patch Changes
24
+
25
+ - 91453b3: Update and lock dependencies versions
26
+
27
+ ## 0.1.1
28
+
29
+ ### Patch Changes
30
+
31
+ - 1926fe1: Update dependencies
32
+
33
+ ## 0.1.0
34
+
35
+ ### Minor Changes
36
+
37
+ - af81d65: Create http package
@@ -0,0 +1,10 @@
1
+ import { AxiosInstance } from 'axios';
2
+ export { AxiosResponse } from 'axios';
3
+
4
+ type HttpResponse<TData, TMeta = Record<string, unknown>> = {
5
+ data: TData;
6
+ meta: TMeta;
7
+ };
8
+ declare const httpService: () => AxiosInstance;
9
+
10
+ export { type HttpResponse, httpService };
@@ -0,0 +1,10 @@
1
+ import { AxiosInstance } from 'axios';
2
+ export { AxiosResponse } from 'axios';
3
+
4
+ type HttpResponse<TData, TMeta = Record<string, unknown>> = {
5
+ data: TData;
6
+ meta: TMeta;
7
+ };
8
+ declare const httpService: () => AxiosInstance;
9
+
10
+ export { type HttpResponse, httpService };
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ httpService: () => httpService
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/http.ts
38
+ var import_axios = __toESM(require("axios"));
39
+
40
+ // src/env.ts
41
+ var import_env = require("@elementor/env");
42
+ var { env } = (0, import_env.parseEnv)("@elementor/http-client");
43
+
44
+ // src/http.ts
45
+ var instance;
46
+ var httpService = () => {
47
+ if (!instance) {
48
+ instance = import_axios.default.create({
49
+ baseURL: env.base_url,
50
+ timeout: 1e4,
51
+ headers: {
52
+ "Content-Type": "application/json",
53
+ ...env.headers
54
+ }
55
+ });
56
+ }
57
+ return instance;
58
+ };
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ httpService
62
+ });
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/http.ts","../src/env.ts"],"sourcesContent":["export { type AxiosResponse } from 'axios';\nexport { type HttpResponse, httpService } from './http';\n","import axios, { type AxiosInstance } from 'axios';\n\nimport { env } from './env';\n\nexport type HttpResponse< TData, TMeta = Record< string, unknown > > = {\n\tdata: TData;\n\tmeta: TMeta;\n};\n\nlet instance: AxiosInstance;\n\nexport const httpService = () => {\n\tif ( ! instance ) {\n\t\tinstance = axios.create( {\n\t\t\tbaseURL: env.base_url,\n\t\t\ttimeout: 10000,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t...env.headers,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn instance;\n};\n","import { parseEnv } from '@elementor/env';\n\nexport const { env } = parseEnv< {\n\tbase_url: string;\n\theaders: Record< string, string >;\n} >( '@elementor/http-client' );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;;;ACA1C,iBAAyB;AAElB,IAAM,EAAE,IAAI,QAAI,qBAGlB,wBAAyB;;;ADI9B,IAAI;AAEG,IAAM,cAAc,MAAM;AAChC,MAAK,CAAE,UAAW;AACjB,eAAW,aAAAA,QAAM,OAAQ;AAAA,MACxB,SAAS,IAAI;AAAA,MACb,SAAS;AAAA,MACT,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,GAAG,IAAI;AAAA,MACR;AAAA,IACD,CAAE;AAAA,EACH;AAEA,SAAO;AACR;","names":["axios"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,26 @@
1
+ // src/http.ts
2
+ import axios from "axios";
3
+
4
+ // src/env.ts
5
+ import { parseEnv } from "@elementor/env";
6
+ var { env } = parseEnv("@elementor/http-client");
7
+
8
+ // src/http.ts
9
+ var instance;
10
+ var httpService = () => {
11
+ if (!instance) {
12
+ instance = axios.create({
13
+ baseURL: env.base_url,
14
+ timeout: 1e4,
15
+ headers: {
16
+ "Content-Type": "application/json",
17
+ ...env.headers
18
+ }
19
+ });
20
+ }
21
+ return instance;
22
+ };
23
+ export {
24
+ httpService
25
+ };
26
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/http.ts","../src/env.ts"],"sourcesContent":["import axios, { type AxiosInstance } from 'axios';\n\nimport { env } from './env';\n\nexport type HttpResponse< TData, TMeta = Record< string, unknown > > = {\n\tdata: TData;\n\tmeta: TMeta;\n};\n\nlet instance: AxiosInstance;\n\nexport const httpService = () => {\n\tif ( ! instance ) {\n\t\tinstance = axios.create( {\n\t\t\tbaseURL: env.base_url,\n\t\t\ttimeout: 10000,\n\t\t\theaders: {\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t...env.headers,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn instance;\n};\n","import { parseEnv } from '@elementor/env';\n\nexport const { env } = parseEnv< {\n\tbase_url: string;\n\theaders: Record< string, string >;\n} >( '@elementor/http-client' );\n"],"mappings":";AAAA,OAAO,WAAmC;;;ACA1C,SAAS,gBAAgB;AAElB,IAAM,EAAE,IAAI,IAAI,SAGlB,wBAAyB;;;ADI9B,IAAI;AAEG,IAAM,cAAc,MAAM;AAChC,MAAK,CAAE,UAAW;AACjB,eAAW,MAAM,OAAQ;AAAA,MACxB,SAAS,IAAI;AAAA,MACb,SAAS;AAAA,MACT,SAAS;AAAA,QACR,gBAAgB;AAAA,QAChB,GAAG,IAAI;AAAA,MACR;AAAA,IACD,CAAE;AAAA,EACH;AAEA,SAAO;AACR;","names":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@elementor/http-client",
3
+ "description": "Provides a simple way to make HTTP requests",
4
+ "version": "0.2.0",
5
+ "private": false,
6
+ "author": "Elementor Team",
7
+ "homepage": "https://elementor.com/",
8
+ "license": "GPL-3.0-or-later",
9
+ "main": "dist/index.js",
10
+ "module": "dist/index.mjs",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.js"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/elementor/elementor-packages.git",
23
+ "directory": "packages/libs/http-client"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/elementor/elementor-packages/issues"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "README.md",
33
+ "CHANGELOG.md",
34
+ "/dist",
35
+ "/src",
36
+ "!**/__tests__"
37
+ ],
38
+ "scripts": {
39
+ "build": "tsup --config=../../tsup.build.ts",
40
+ "dev": "tsup --config=../../tsup.dev.ts"
41
+ },
42
+ "dependencies": {
43
+ "@elementor/env": "0.3.5",
44
+ "axios": "^1.7.9"
45
+ },
46
+ "devDependencies": {
47
+ "tsup": "^8.3.5"
48
+ }
49
+ }
package/src/env.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { parseEnv } from '@elementor/env';
2
+
3
+ export const { env } = parseEnv< {
4
+ base_url: string;
5
+ headers: Record< string, string >;
6
+ } >( '@elementor/http-client' );
package/src/http.ts ADDED
@@ -0,0 +1,25 @@
1
+ import axios, { type AxiosInstance } from 'axios';
2
+
3
+ import { env } from './env';
4
+
5
+ export type HttpResponse< TData, TMeta = Record< string, unknown > > = {
6
+ data: TData;
7
+ meta: TMeta;
8
+ };
9
+
10
+ let instance: AxiosInstance;
11
+
12
+ export const httpService = () => {
13
+ if ( ! instance ) {
14
+ instance = axios.create( {
15
+ baseURL: env.base_url,
16
+ timeout: 10000,
17
+ headers: {
18
+ 'Content-Type': 'application/json',
19
+ ...env.headers,
20
+ },
21
+ } );
22
+ }
23
+
24
+ return instance;
25
+ };
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { type AxiosResponse } from 'axios';
2
+ export { type HttpResponse, httpService } from './http';