@hostlink/light 0.0.3 → 0.0.5

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.
@@ -0,0 +1,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import login from './login';
2
+ import logout from './logout';
3
+ import query from './query';
4
+ import mutation from './mutation';
5
+ import toQuery from './toQuery';
6
+ import getApiUrl from './getApiUrl';
7
+ import setApiUrl from './setApiUrl';
8
+ export { toQuery, login, logout, query, mutation, getApiUrl, setApiUrl };
package/dist/light.js CHANGED
@@ -1,53 +1,57 @@
1
- import { jsonToGraphQLQuery as i } from "json-to-graphql-query";
1
+ import { jsonToGraphQLQuery as c } from "json-to-graphql-query";
2
2
  import u from "axios";
3
- const f = async (r, a = null, o = []) => {
4
- const n = u.create({
3
+ const l = async (t, e = null, a = []) => {
4
+ const o = u.create({
5
5
  withCredentials: !0
6
- }), t = {
6
+ }), r = {
7
7
  mutation: {}
8
8
  };
9
- t.mutation[r] = !0, a && (t.mutation[r] = {}, t.mutation[r].__args = a), o.length > 0 && (t.mutation[r] = {}), o.forEach((m) => {
10
- t.mutation[r][m] = !0;
9
+ r.mutation[t] = !0, e && (r.mutation[t] = {}, r.mutation[t].__args = e), a.length > 0 && (r.mutation[t] = {}), a.forEach((g) => {
10
+ r.mutation[t][g] = !0;
11
11
  });
12
- const s = "/api/", e = await n.post(s, {
13
- query: i(t)
12
+ const s = {}.VITE_API_URL ?? "/api/", n = await o.post(s, {
13
+ query: c(r)
14
14
  });
15
- if (e.data.errors)
16
- throw new Error(e.data.errors[0].message);
17
- return e.data.data;
18
- }, g = async (r, a, o = "") => await f("login", {
19
- username: r,
20
- password: a,
21
- code: o
22
- }), d = async () => await f("logout"), c = function(r) {
23
- let a = {};
24
- return Object.entries(r).forEach(([o, n]) => {
25
- if (o == "__args") {
26
- a[o] = n;
15
+ if (n.data.errors)
16
+ throw new Error(n.data.errors[0].message);
17
+ return n.data.data;
18
+ }, p = async (t, e, a = "") => await l("login", {
19
+ username: t,
20
+ password: e,
21
+ code: a
22
+ }), w = async () => await l("logout"), i = function(t) {
23
+ let e = {};
24
+ return Object.entries(t).forEach(([a, o]) => {
25
+ if (a == "__args") {
26
+ e[a] = o;
27
27
  return;
28
28
  }
29
- n instanceof Array ? (a[o] = {}, n.forEach((t) => {
30
- t instanceof Object ? Object.entries(c(t)).forEach(([s, e]) => {
31
- a[o][s] = e;
32
- }) : a[o][t] = !0;
33
- })) : a[o] = c(n);
34
- }), a;
35
- }, h = (r) => c(r), p = async (r) => {
36
- const a = u.create({
29
+ o instanceof Array ? (e[a] = {}, o.forEach((r) => {
30
+ r instanceof Object ? Object.entries(i(r)).forEach(([s, n]) => {
31
+ e[a][s] = n;
32
+ }) : e[a][r] = !0;
33
+ })) : e[a] = i(o);
34
+ }), e;
35
+ }, m = (t) => i(t), E = async (t) => {
36
+ const e = u.create({
37
37
  withCredentials: !0
38
38
  });
39
- let o = i(h(r));
40
- const n = "/api/", t = await a.post(n, {
41
- query: `{ ${o} }`
39
+ let a = c(m(t));
40
+ const o = {}.VITE_API_URL ?? "/api/", r = await e.post(o, {
41
+ query: `{ ${a} }`
42
42
  });
43
- if (t.data.errors)
44
- throw new Error(t.data.errors[0].message);
45
- return t.data.data;
43
+ if (r.data.errors)
44
+ throw new Error(r.data.errors[0].message);
45
+ return r.data.data;
46
+ }, _ = () => localStorage.getItem("light-api-url") === null ? "/api/" : localStorage.getItem("light-api-url"), d = (t) => {
47
+ localStorage.setItem("light-api-url", t);
46
48
  };
47
49
  export {
48
- g as login,
49
- d as logout,
50
- f as mutation,
51
- p as query,
52
- h as toQuery
50
+ _ as getApiUrl,
51
+ p as login,
52
+ w as logout,
53
+ l as mutation,
54
+ E as query,
55
+ d as setApiUrl,
56
+ m as toQuery
53
57
  };
@@ -1 +1 @@
1
- (function(o,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],i):(o=typeof globalThis<"u"?globalThis:o||self,i(o.light={},o.jsonToGraphqlQuery,o.axios))})(this,function(o,i,d){"use strict";const u=async(e,r=null,n=[])=>{const a=d.create({withCredentials:!0}),t={mutation:{}};t.mutation[e]=!0,r&&(t.mutation[e]={},t.mutation[e].__args=r),n.length>0&&(t.mutation[e]={}),n.forEach(g=>{t.mutation[e][g]=!0});const f="/api/",s=await a.post(f,{query:i.jsonToGraphQLQuery(t)});if(s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data},l=async(e,r,n="")=>await u("login",{username:e,password:r,code:n}),y=async()=>await u("logout"),c=function(e){let r={};return Object.entries(e).forEach(([n,a])=>{if(n=="__args"){r[n]=a;return}a instanceof Array?(r[n]={},a.forEach(t=>{t instanceof Object?Object.entries(c(t)).forEach(([f,s])=>{r[n][f]=s}):r[n][t]=!0})):r[n]=c(a)}),r},h=e=>c(e),m=async e=>{const r=d.create({withCredentials:!0});let n=i.jsonToGraphQLQuery(h(e));const a="/api/",t=await r.post(a,{query:`{ ${n} }`});if(t.data.errors)throw new Error(t.data.errors[0].message);return t.data.data};o.login=l,o.logout=y,o.mutation=u,o.query=m,o.toQuery=h,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("json-to-graphql-query"),require("axios")):typeof define=="function"&&define.amd?define(["exports","json-to-graphql-query","axios"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.light={},e.jsonToGraphqlQuery,e.axios))})(this,function(e,i,f){"use strict";const u=async(t,n=null,o=[])=>{const a=f.create({withCredentials:!0}),r={mutation:{}};r.mutation[t]=!0,n&&(r.mutation[t]={},r.mutation[t].__args=n),o.length>0&&(r.mutation[t]={}),o.forEach(q=>{r.mutation[t][q]=!0});const l={}.VITE_API_URL??"/api/",s=await a.post(l,{query:i.jsonToGraphQLQuery(r)});if(s.data.errors)throw new Error(s.data.errors[0].message);return s.data.data},h=async(t,n,o="")=>await u("login",{username:t,password:n,code:o}),d=async()=>await u("logout"),c=function(t){let n={};return Object.entries(t).forEach(([o,a])=>{if(o=="__args"){n[o]=a;return}a instanceof Array?(n[o]={},a.forEach(r=>{r instanceof Object?Object.entries(c(r)).forEach(([l,s])=>{n[o][l]=s}):n[o][r]=!0})):n[o]=c(a)}),n},g=t=>c(t),m=async t=>{const n=f.create({withCredentials:!0});let o=i.jsonToGraphQLQuery(g(t));const a={}.VITE_API_URL??"/api/",r=await n.post(a,{query:`{ ${o} }`});if(r.data.errors)throw new Error(r.data.errors[0].message);return r.data.data},p=()=>localStorage.getItem("light-api-url")===null?"/api/":localStorage.getItem("light-api-url"),y=t=>{localStorage.setItem("light-api-url",t)};e.getApiUrl=p,e.login=h,e.logout=d,e.mutation=u,e.query=m,e.setApiUrl=y,e.toQuery=g,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,2 @@
1
+ declare const _default: (url: string) => void;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/light",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -12,7 +12,7 @@
12
12
  "import": "./dist/light.js"
13
13
  }
14
14
  },
15
- "types": "./dist/light.d.ts",
15
+ "types": "./dist/index.d.ts",
16
16
  "scripts": {
17
17
  "dev": "vite --host",
18
18
  "build": "tsc && vite build",
File without changes
File without changes
File without changes
File without changes
File without changes