@nhost/nhost-js 3.3.1 → 4.0.1

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.
Files changed (147) hide show
  1. package/README.md +67 -32
  2. package/dist/fetch-2PHmQBIJ.mjs +61 -0
  3. package/dist/fetch-2PHmQBIJ.mjs.map +1 -0
  4. package/dist/fetch-DWXwEnoe.js +2 -0
  5. package/dist/fetch-DWXwEnoe.js.map +1 -0
  6. package/dist/nhost-js/auth.cjs.js +2 -0
  7. package/dist/nhost-js/auth.cjs.js.map +1 -0
  8. package/dist/nhost-js/auth.es.js +917 -0
  9. package/dist/nhost-js/auth.es.js.map +1 -0
  10. package/dist/nhost-js/fetch.cjs.js +2 -0
  11. package/dist/nhost-js/fetch.cjs.js.map +1 -0
  12. package/dist/nhost-js/fetch.es.js +90 -0
  13. package/dist/nhost-js/fetch.es.js.map +1 -0
  14. package/dist/nhost-js/functions.cjs.js +2 -0
  15. package/dist/nhost-js/functions.cjs.js.map +1 -0
  16. package/dist/nhost-js/functions.es.js +45 -0
  17. package/dist/nhost-js/functions.es.js.map +1 -0
  18. package/dist/nhost-js/graphql.cjs.js +2 -0
  19. package/dist/nhost-js/graphql.cjs.js.map +1 -0
  20. package/dist/nhost-js/graphql.es.js +48 -0
  21. package/dist/nhost-js/graphql.es.js.map +1 -0
  22. package/dist/nhost-js/session.cjs.js +2 -0
  23. package/dist/nhost-js/session.cjs.js.map +1 -0
  24. package/dist/nhost-js/session.es.js +234 -0
  25. package/dist/nhost-js/session.es.js.map +1 -0
  26. package/dist/nhost-js/storage.cjs.js +2 -0
  27. package/dist/nhost-js/storage.cjs.js.map +1 -0
  28. package/dist/nhost-js/storage.es.js +324 -0
  29. package/dist/nhost-js/storage.es.js.map +1 -0
  30. package/dist/nhost-js.cjs.js +2 -0
  31. package/dist/nhost-js.cjs.js.map +1 -0
  32. package/dist/nhost-js.es.js +228 -0
  33. package/dist/nhost-js.es.js.map +1 -0
  34. package/dist/nhost-js.umd.js +2 -0
  35. package/dist/nhost-js.umd.js.map +1 -0
  36. package/dist/refreshSession-Bw715ZmX.js +2 -0
  37. package/dist/refreshSession-Bw715ZmX.js.map +1 -0
  38. package/dist/refreshSession-WwGlzgtM.mjs +95 -0
  39. package/dist/refreshSession-WwGlzgtM.mjs.map +1 -0
  40. package/dist/src/auth/client.d.ts +1763 -0
  41. package/dist/src/auth/client.d.ts.map +1 -0
  42. package/dist/src/auth/client.js +1043 -0
  43. package/dist/src/auth/client.js.map +1 -0
  44. package/dist/src/auth/index.d.ts +35 -0
  45. package/dist/src/auth/index.d.ts.map +1 -0
  46. package/dist/src/auth/index.js +35 -0
  47. package/dist/src/auth/index.js.map +1 -0
  48. package/dist/src/fetch/fetch.d.ts +88 -0
  49. package/dist/src/fetch/fetch.d.ts.map +1 -0
  50. package/dist/src/fetch/fetch.js +98 -0
  51. package/dist/src/fetch/fetch.js.map +1 -0
  52. package/dist/src/fetch/index.d.ts +38 -0
  53. package/dist/src/fetch/index.d.ts.map +1 -0
  54. package/dist/src/fetch/index.js +38 -0
  55. package/dist/src/fetch/index.js.map +1 -0
  56. package/dist/src/fetch/middlewareAttachAccessToken.d.ts +24 -0
  57. package/dist/src/fetch/middlewareAttachAccessToken.d.ts.map +1 -0
  58. package/dist/src/fetch/middlewareAttachAccessToken.js +54 -0
  59. package/dist/src/fetch/middlewareAttachAccessToken.js.map +1 -0
  60. package/dist/src/fetch/middlewareSessionRefresh.d.ts +30 -0
  61. package/dist/src/fetch/middlewareSessionRefresh.d.ts.map +1 -0
  62. package/dist/src/fetch/middlewareSessionRefresh.js +61 -0
  63. package/dist/src/fetch/middlewareSessionRefresh.js.map +1 -0
  64. package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts +26 -0
  65. package/dist/src/fetch/middlewareUpdateSessionFromResponse.d.ts.map +1 -0
  66. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js +79 -0
  67. package/dist/src/fetch/middlewareUpdateSessionFromResponse.js.map +1 -0
  68. package/dist/src/functions/client.d.ts +52 -0
  69. package/dist/src/functions/client.d.ts.map +1 -0
  70. package/dist/src/functions/client.js +89 -0
  71. package/dist/src/functions/client.js.map +1 -0
  72. package/dist/src/functions/index.d.ts +43 -0
  73. package/dist/src/functions/index.d.ts.map +1 -0
  74. package/dist/src/functions/index.js +43 -0
  75. package/dist/src/functions/index.js.map +1 -0
  76. package/dist/src/graphql/client.d.ts +93 -0
  77. package/dist/src/graphql/client.d.ts.map +1 -0
  78. package/dist/src/graphql/client.js +66 -0
  79. package/dist/src/graphql/client.js.map +1 -0
  80. package/dist/src/graphql/index.d.ts +65 -0
  81. package/dist/src/graphql/index.d.ts.map +1 -0
  82. package/dist/src/graphql/index.js +65 -0
  83. package/dist/src/graphql/index.js.map +1 -0
  84. package/dist/src/index.d.ts +35 -0
  85. package/dist/src/index.d.ts.map +1 -0
  86. package/dist/src/index.js +45 -0
  87. package/dist/src/index.js.map +1 -0
  88. package/dist/src/nhost.d.ts +301 -0
  89. package/dist/src/nhost.d.ts.map +1 -0
  90. package/dist/src/nhost.js +323 -0
  91. package/dist/src/nhost.js.map +1 -0
  92. package/dist/src/session/index.d.ts +20 -0
  93. package/dist/src/session/index.d.ts.map +1 -0
  94. package/dist/src/session/index.js +19 -0
  95. package/dist/src/session/index.js.map +1 -0
  96. package/dist/src/session/refreshSession.d.ts +17 -0
  97. package/dist/src/session/refreshSession.d.ts.map +1 -0
  98. package/dist/src/session/refreshSession.js +120 -0
  99. package/dist/src/session/refreshSession.js.map +1 -0
  100. package/dist/src/session/session.d.ts +24 -0
  101. package/dist/src/session/session.d.ts.map +1 -0
  102. package/dist/src/session/session.js +48 -0
  103. package/dist/src/session/session.js.map +1 -0
  104. package/dist/src/session/storage.d.ts +62 -0
  105. package/dist/src/session/storage.d.ts.map +1 -0
  106. package/dist/src/session/storage.js +91 -0
  107. package/dist/src/session/storage.js.map +1 -0
  108. package/dist/src/session/storageBackend.d.ts +122 -0
  109. package/dist/src/session/storageBackend.d.ts.map +1 -0
  110. package/dist/src/session/storageBackend.js +145 -0
  111. package/dist/src/session/storageBackend.js.map +1 -0
  112. package/dist/src/storage/client.d.ts +546 -0
  113. package/dist/src/storage/client.d.ts.map +1 -0
  114. package/dist/src/storage/client.js +368 -0
  115. package/dist/src/storage/client.js.map +1 -0
  116. package/dist/src/storage/index.d.ts +37 -0
  117. package/dist/src/storage/index.d.ts.map +1 -0
  118. package/dist/src/storage/index.js +37 -0
  119. package/dist/src/storage/index.js.map +1 -0
  120. package/dist/tsconfig.tsbuildinfo +1 -0
  121. package/package.json +103 -59
  122. package/dist/clients/auth.d.ts +0 -8
  123. package/dist/clients/auth.d.ts.map +0 -1
  124. package/dist/clients/functions/index.d.ts +0 -107
  125. package/dist/clients/functions/index.d.ts.map +0 -1
  126. package/dist/clients/functions/types.d.ts +0 -28
  127. package/dist/clients/functions/types.d.ts.map +0 -1
  128. package/dist/clients/graphql.d.ts +0 -8
  129. package/dist/clients/graphql.d.ts.map +0 -1
  130. package/dist/clients/index.d.ts +0 -6
  131. package/dist/clients/index.d.ts.map +0 -1
  132. package/dist/clients/nhost.d.ts +0 -83
  133. package/dist/clients/nhost.d.ts.map +0 -1
  134. package/dist/clients/storage.d.ts +0 -8
  135. package/dist/clients/storage.d.ts.map +0 -1
  136. package/dist/index.cjs.js +0 -2
  137. package/dist/index.cjs.js.map +0 -1
  138. package/dist/index.d.ts +0 -6
  139. package/dist/index.d.ts.map +0 -1
  140. package/dist/index.esm.js +0 -356
  141. package/dist/index.esm.js.map +0 -1
  142. package/dist/utils/helpers.d.ts +0 -20
  143. package/dist/utils/helpers.d.ts.map +0 -1
  144. package/dist/utils/types.d.ts +0 -57
  145. package/dist/utils/types.d.ts.map +0 -1
  146. package/umd/nhost-js.umd.js +0 -22
  147. package/umd/nhost-js.umd.js.map +0 -1
@@ -1,83 +0,0 @@
1
- import { NhostGraphqlClient } from '@nhost/graphql-js';
2
- import { HasuraAuthClient } from '@nhost/hasura-auth-js';
3
- import { HasuraStorageClient } from '@nhost/hasura-storage-js';
4
- import { NhostClientConstructorParams } from '../utils/types';
5
- import { NhostFunctionsClient } from './functions';
6
-
7
- export declare const createNhostClient: (params: NhostClientConstructorParams) => NhostClient;
8
- export declare class NhostClient {
9
- auth: HasuraAuthClient;
10
- storage: HasuraStorageClient;
11
- functions: NhostFunctionsClient;
12
- graphql: NhostGraphqlClient;
13
- private _adminSecret?;
14
- readonly devTools?: boolean;
15
- /**
16
- *
17
- * @example
18
- * ```ts
19
- * // Create a new Nhost client from subdomain and region.
20
- * const nhost = new NhostClient({ subdomain, region });
21
- * ```
22
- *
23
- *
24
- * ```ts
25
- * // Create a new Nhost client from individual service URLs (custom domains, self-hosting, etc).
26
- * const nhost = new NhostClient({
27
- * authUrl: "my-auth-service-url",
28
- * storageUrl: "my-storage-service-url",
29
- * graphqlUrl: "my-graphql-service-url",
30
- * functionsUrl: "my-functions-service-url",
31
- * });
32
- * ```
33
- *
34
- *
35
- * ```ts
36
- * // Create a new Nhost client for local development.
37
- * const nhost = new NhostClient({ subdomain: "local" });
38
- * ```
39
- *
40
- * @docs https://docs.nhost.io/reference/javascript
41
- */
42
- constructor({ refreshIntervalTime, clientStorage, clientStorageType, autoRefreshToken, autoSignIn, adminSecret, devTools, start, ...urlParams }: NhostClientConstructorParams);
43
- get adminSecret(): string | undefined;
44
- set adminSecret(newValue: string | undefined);
45
- /**
46
- * Use `nhost.setRole` to set the user role for all subsequent GraphQL, storage, and functions calls.
47
- * Underneath, this method sets the `x-hasura-role` header on the graphql, storage,
48
- * and functions clients.
49
- *
50
- * ```ts
51
- * nhost.graphql.setHeaders({ 'x-hasura-role': role })
52
- * nhost.storage.setHeaders({ 'x-hasura-role': role })
53
- * nhost.functions.setHeaders({ 'x-hasura-role': role })
54
- * ```
55
- *
56
- * Note: Exercise caution when mixing the use of `setRole` along with `setHeaders` when setting the
57
- * `x-hasura-role` header, as the last call will override any previous ones.
58
- *
59
- * @example
60
- * ```ts
61
- * nhost.setRole('admin')
62
- * ```
63
- *
64
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/set-role
65
- */
66
- setRole(role: string): void;
67
- /**
68
- * Use `nhost.unsetRole` to unset the user role for all subsequent graphql, storage and functions calls.
69
- * Underneath, this method removes the `x-hasura-role` header from the graphql, storage and functions clients.
70
- *
71
- * Note: Exercise caution when mixing the use of `unsetRole` along with `setHeaders` when setting the
72
- * `x-hasura-role` header, as the last call will override any previous ones.
73
- *
74
- * @example
75
- * ```ts
76
- * nhost.unsetRole()
77
- * ```
78
- *
79
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/unset-role
80
- */
81
- unsetRole(): void;
82
- }
83
- //# sourceMappingURL=nhost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nhost.d.ts","sourceRoot":"","sources":["../../src/clients/nhost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAE7D,OAAO,EAAyB,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAIzE,eAAO,MAAM,iBAAiB,GAAI,QAAQ,4BAA4B,gBAA4B,CAAA;AAElG,qBAAa,WAAW;IACtB,IAAI,EAAE,gBAAgB,CAAA;IACtB,OAAO,EAAE,mBAAmB,CAAA;IAC5B,SAAS,EAAE,oBAAoB,CAAA;IAC/B,OAAO,EAAE,kBAAkB,CAAA;IAC3B,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;gBACS,EACV,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,KAAY,EACZ,GAAG,SAAS,EACb,EAAE,4BAA4B;IA0C/B,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,IAAI,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAM3C;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM;IAMpB;;;;;;;;;;;;;OAaG;IACH,SAAS;CAOV"}
@@ -1,8 +0,0 @@
1
- import { HasuraStorageClient } from '@nhost/hasura-storage-js';
2
- import { NhostClientConstructorParams } from '../utils/types';
3
-
4
- /**
5
- * Creates a client for Storage from either a subdomain or a URL
6
- */
7
- export declare function createStorageClient(params: NhostClientConstructorParams): HasuraStorageClient;
8
- //# sourceMappingURL=storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/clients/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAG9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAE7D;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,4BAA4B,uBAQvE"}
package/dist/index.cjs.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";var k=Object.defineProperty;var q=(t,e,r)=>e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var a=(t,e,r)=>q(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@nhost/hasura-auth-js"),T=require("@nhost/hasura-storage-js"),y=require("isomorphic-unfetch"),H=require("@nhost/graphql-js"),v=/^((?<protocol>http[s]?):\/\/)?(?<host>(localhost|local))(:(?<port>(\d+|__\w+__)))?$/;function f(t,e){const{subdomain:r,region:n}=t;if(!r)throw new Error("A `subdomain` must be set.");const u=r.match(v);if(u!=null&&u.groups){const{protocol:h,host:i,port:l}=u.groups,s=E(e);return s||(i==="localhost"?(console.warn('The `subdomain` is set to "localhost". Support for this will be removed in a future release. Please use "local" instead.'),`${h||"http"}://localhost:${l||1337}/v1/${e}`):l?`${h||"https"}://local.${e}.local.nhost.run:${l}/v1`:`${h||"https"}://local.${e}.local.nhost.run/v1`)}if(!n)throw new Error('`region` must be set when using a `subdomain` other than "local".');return`https://${r}.${e}.${n}.nhost.run/v1`}function U(){return typeof window!="undefined"}function $(){return typeof process!="undefined"&&process.env}function E(t){return U()||!$()?null:process.env[`NHOST_${t.toUpperCase()}_URL`]}function O(t,e){const n=e.startsWith("/")?e:`/${e}`;return t+n}function b(t){const e="subdomain"in t?f(t,"auth"):t.authUrl,{subdomain:r,region:n}=t;if(!e)throw new Error("Please provide `subdomain` or `authUrl`.");return new p.HasuraAuthClient({url:e,broadcastKey:`${r}${n!=null?n:"local"}`,...t})}function w(t){const e="subdomain"in t?f(t,"functions"):t.functionsUrl;if(!e)throw new Error("Please provide `subdomain` or `functionsUrl`.");return new m({url:e,...t})}class m{constructor(e){a(this,"url");a(this,"accessToken");a(this,"adminSecret");a(this,"headers",{});const{url:r,adminSecret:n}=e;this.url=r,this.accessToken=null,this.adminSecret=n}async call(e,r,n){var i,l;const u={"Content-Type":"application/json",...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers,...this.headers},h=O(this.url,e);try{const s=await y(h,{body:r?JSON.stringify(r):null,headers:u,method:"POST"});if(!s.ok){let c;return(i=s.headers.get("content-type"))!=null&&i.includes("application/json")?c=await s.json():c=await s.text(),{res:null,error:{message:c,error:s.statusText,status:s.status}}}let o;return(l=s.headers.get("content-type"))!=null&&l.includes("application/json")?o=await s.json():o=await s.text(),{res:{data:o,status:s.status,statusText:s.statusText},error:null}}catch(s){const o=s;return{res:null,error:{message:o.message,status:o.name==="AbortError"?0:500,error:o.name==="AbortError"?"abort-error":"unknown"}}}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}getHeaders(){return this.headers}setHeaders(e){e&&(this.headers={...this.headers,...e})}unsetHeaders(){const e=this.headers["x-hasura-role"];this.headers=e?{"x-hasura-role":e}:{}}generateAccessTokenHeaders(){return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}}}function S(t){const e="subdomain"in t?f(t,"graphql"):t.graphqlUrl;if(!e)throw new Error("Please provide `subdomain` or `graphqlUrl`.");return new H.NhostGraphqlClient({url:e,...t})}function A(t){const e="subdomain"in t?f(t,"storage"):t.storageUrl;if(!e)throw new Error("Please provide `subdomain` or `storageUrl`.");return new T.HasuraStorageClient({url:e,...t})}const _=t=>new C(t);class C{constructor({refreshIntervalTime:e,clientStorage:r,clientStorageType:n,autoRefreshToken:u,autoSignIn:h,adminSecret:i,devTools:l,start:s=!0,...o}){a(this,"auth");a(this,"storage");a(this,"functions");a(this,"graphql");a(this,"_adminSecret");a(this,"devTools");this.auth=b({refreshIntervalTime:e,clientStorage:r,clientStorageType:n,autoRefreshToken:u,autoSignIn:h,start:s,...o}),this.storage=A({adminSecret:i,...o}),this.functions=w({adminSecret:i,...o}),this.graphql=S({adminSecret:i,...o}),this.auth.onAuthStateChanged((c,d)=>{if(c==="SIGNED_OUT"){this.storage.setAccessToken(void 0),this.functions.setAccessToken(void 0),this.graphql.setAccessToken(void 0);return}const g=d==null?void 0:d.accessToken;this.storage.setAccessToken(g),this.functions.setAccessToken(g),this.graphql.setAccessToken(g)}),this.auth.onTokenChanged(c=>{const d=c==null?void 0:c.accessToken;this.storage.setAccessToken(d),this.functions.setAccessToken(d),this.graphql.setAccessToken(d)}),this._adminSecret=i,this.devTools=l}get adminSecret(){return this._adminSecret}set adminSecret(e){this._adminSecret=e,this.storage.setAdminSecret(e)}setRole(e){this.graphql.setHeaders({"x-hasura-role":e}),this.storage.setHeaders({"x-hasura-role":e}),this.functions.setHeaders({"x-hasura-role":e})}unsetRole(){this.graphql.setHeaders((({"x-hasura-role":e,...r})=>r)(this.graphql.getHeaders())),this.storage.setHeaders((({"x-hasura-role":e,...r})=>r)(this.storage.getHeaders())),this.functions.setHeaders((({"x-hasura-role":e,...r})=>r)(this.functions.getHeaders()))}}exports.NhostClient=C;exports.NhostFunctionsClient=m;exports.createAuthClient=b;exports.createFunctionsClient=w;exports.createGraphqlClient=S;exports.createNhostClient=_;exports.createStorageClient=A;exports.urlFromSubdomain=f;Object.keys(p).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>p[t]})});Object.keys(T).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>T[t]})});
2
- //# sourceMappingURL=index.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/utils/helpers.ts","../src/clients/auth.ts","../src/clients/functions/index.ts","../src/clients/graphql.ts","../src/clients/storage.ts","../src/clients/nhost.ts"],"sourcesContent":["import { NhostClientConstructorParams } from './types'\n\n// a port can be a number or a placeholder string with leading and trailing double underscores, f.e. \"8080\" or \"__PLACEHOLDER_NAME__\"\nexport const LOCALHOST_REGEX =\n /^((?<protocol>http[s]?):\\/\\/)?(?<host>(localhost|local))(:(?<port>(\\d+|__\\w+__)))?$/\n\n/**\n * \\`subdomain\\` and `region` should be used when running the Nhost platform\n *\n * @param subdomainAndRegion\n * @param service\n * @returns\n */\nexport function urlFromSubdomain(\n subdomainAndRegion: Pick<NhostClientConstructorParams, 'region' | 'subdomain'>,\n service: string\n): string {\n const { subdomain, region } = subdomainAndRegion\n\n if (!subdomain) {\n throw new Error('A `subdomain` must be set.')\n }\n\n // check if subdomain is [http[s]://]localhost[:port] or [http[s]://]local[:port]\n const subdomainLocalhostFound = subdomain.match(LOCALHOST_REGEX)\n if (subdomainLocalhostFound?.groups) {\n const { protocol, host, port } = subdomainLocalhostFound.groups\n\n const urlFromEnv = getValueFromEnv(service)\n if (urlFromEnv) {\n return urlFromEnv\n }\n\n if (host === 'localhost') {\n console.warn(\n 'The `subdomain` is set to \"localhost\". Support for this will be removed in a future release. Please use \"local\" instead.'\n )\n\n return `${protocol || 'http'}://localhost:${port || 1337}/v1/${service}`\n }\n\n return port\n ? `${protocol || 'https'}://local.${service}.local.nhost.run:${port}/v1`\n : `${protocol || 'https'}://local.${service}.local.nhost.run/v1`\n }\n\n if (!region) {\n throw new Error('`region` must be set when using a `subdomain` other than \"local\".')\n }\n\n return `https://${subdomain}.${service}.${region}.nhost.run/v1`\n}\n\n/**\n *\n * @returns whether the code is running in a browser\n */\nfunction isBrowser(): boolean {\n return typeof window !== 'undefined'\n}\n\n/**\n *\n * @returns whether the code is running in a Node.js environment\n */\nfunction environmentIsAvailable() {\n return typeof process !== 'undefined' && process.env\n}\n\n/**\n *\n * @param service auth | storage | graphql | functions\n * @returns the service's url if the corresponding env var is set\n * NHOST_${service}_URL\n */\nfunction getValueFromEnv(service: string) {\n if (isBrowser() || !environmentIsAvailable()) {\n return null\n }\n\n return process.env[`NHOST_${service.toUpperCase()}_URL`]\n}\n\n/**\n * Combines a base URL and a path into a single URL string.\n *\n * @param baseUrl - The base URL to use.\n * @param path - The path to append to the base URL.\n * @returns The combined URL string.\n */\nexport function buildUrl(baseUrl: string, path: string) {\n const hasLeadingSlash = path.startsWith('/')\n const urlPath = hasLeadingSlash ? path : `/${path}`\n return baseUrl + urlPath\n}\n","import { HasuraAuthClient } from '@nhost/hasura-auth-js'\n\nimport { urlFromSubdomain } from '../utils/helpers'\nimport { NhostClientConstructorParams } from '../utils/types'\n\n/**\n * Creates a client for Auth from either a subdomain or a URL\n */\nexport function createAuthClient(params: NhostClientConstructorParams) {\n const authUrl = 'subdomain' in params ? urlFromSubdomain(params, 'auth') : params.authUrl\n\n const { subdomain, region } = params\n\n if (!authUrl) {\n throw new Error('Please provide `subdomain` or `authUrl`.')\n }\n\n return new HasuraAuthClient({\n url: authUrl,\n broadcastKey: `${subdomain}${region ?? 'local'}`,\n ...params\n })\n}\n","import fetch from 'isomorphic-unfetch'\nimport { buildUrl, urlFromSubdomain } from '../../utils/helpers'\nimport { NhostClientConstructorParams } from '../../utils/types'\nimport {\n NhostFunctionCallConfig,\n NhostFunctionCallResponse,\n NhostFunctionsConstructorParams\n} from './types'\n/**\n * Creates a client for Functions from either a subdomain or a URL\n */\nexport function createFunctionsClient(params: NhostClientConstructorParams) {\n const functionsUrl =\n 'subdomain' in params ? urlFromSubdomain(params, 'functions') : params.functionsUrl\n\n if (!functionsUrl) {\n throw new Error('Please provide `subdomain` or `functionsUrl`.')\n }\n\n return new NhostFunctionsClient({ url: functionsUrl, ...params })\n}\n\n/**\n * @alias Functions\n */\nexport class NhostFunctionsClient {\n readonly url: string\n private accessToken: string | null\n private adminSecret?: string\n private headers: Record<string, string> = {}\n\n constructor(params: NhostFunctionsConstructorParams) {\n const { url, adminSecret } = params\n\n this.url = url\n this.accessToken = null\n this.adminSecret = adminSecret\n }\n\n /**\n * Use `nhost.functions.call` to call (sending a POST request to) a serverless function. Use generic\n * types to specify the expected response data, request body and error message.\n *\n * @example\n * ### Without generic types\n * ```ts\n * await nhost.functions.call('send-welcome-email', { email: 'joe@example.com', name: 'Joe Doe' })\n * ```\n *\n * @example\n * ### Using generic types\n * ```ts\n * type Data = {\n * message: string\n * }\n *\n * type Body = {\n * email: string\n * name: string\n * }\n *\n * type ErrorMessage = {\n * details: string\n * }\n *\n * // The function will only accept a body of type `Body`\n * const { res, error } = await nhost.functions.call<Data, Body, ErrorMessage>(\n * 'send-welcome-email',\n * { email: 'joe@example.com', name: 'Joe Doe' }\n * )\n *\n * // Now the response data is typed as `Data`\n * console.log(res?.data.message)\n *\n * // Now the error message is typed as `ErrorMessage`\n * console.log(error?.message.details)\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/call\n */\n async call<TData = unknown, TBody = any, TErrorMessage = any>(\n url: string,\n body?: TBody | null,\n config?: NhostFunctionCallConfig\n ): Promise<NhostFunctionCallResponse<TData, TErrorMessage>> {\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n ...this.generateAccessTokenHeaders(),\n ...config?.headers,\n ...this.headers // nhost functions client headers to be sent with all calls\n }\n\n const fullUrl = buildUrl(this.url, url)\n\n try {\n const result = await fetch(fullUrl, {\n body: body ? JSON.stringify(body) : null,\n headers,\n method: 'POST'\n })\n\n if (!result.ok) {\n let message: TErrorMessage\n\n if (result.headers.get('content-type')?.includes('application/json')) {\n message = await result.json()\n } else {\n message = (await result.text()) as unknown as TErrorMessage\n }\n\n return {\n res: null,\n error: {\n message,\n error: result.statusText,\n status: result.status\n }\n }\n }\n\n let data: TData\n\n if (result.headers.get('content-type')?.includes('application/json')) {\n data = await result.json()\n } else {\n data = (await result.text()) as unknown as TData\n }\n\n return {\n res: { data, status: result.status, statusText: result.statusText },\n error: null\n }\n } catch (e) {\n const error = e as Error\n return {\n res: null,\n error: {\n message: error.message as unknown as TErrorMessage,\n status: error.name === 'AbortError' ? 0 : 500,\n error: error.name === 'AbortError' ? 'abort-error' : 'unknown'\n }\n }\n }\n }\n\n /**\n * Use `nhost.functions.setAccessToken` to a set an access token to be used in subsequent functions requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically.\n *\n * @example\n * ```ts\n * nhost.functions.setAccessToken('some-access-token')\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/set-access-token\n */\n setAccessToken(accessToken: string | undefined) {\n if (!accessToken) {\n this.accessToken = null\n return\n }\n\n this.accessToken = accessToken\n }\n\n /**\n * Use `nhost.functions.getHeaders` to get the global headers sent with all functions requests.\n *\n * @example\n * ```ts\n * nhost.functions.getHeaders()\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/get-headers\n */\n getHeaders(): Record<string, string> {\n return this.headers\n }\n\n /**\n * Use `nhost.functions.setHeaders` to a set global headers to be sent in all subsequent functions requests.\n *\n * @example\n * ```ts\n * nhost.functions.setHeaders({\n * 'x-hasura-role': 'admin'\n * })\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/set-headers\n */\n setHeaders(headers?: Record<string, string>) {\n if (!headers) {\n return\n }\n\n this.headers = {\n ...this.headers,\n ...headers\n }\n }\n\n /**\n * Use `nhost.functions.unsetHeaders` to a unset global headers sent with all functions requests.\n *\n * @example\n * ```ts\n * nhost.functions.unsetHeaders()\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/unset-headers\n */\n unsetHeaders() {\n const userRole = this.headers['x-hasura-role']\n\n // preserve the user role header to avoid invalidating preceding 'setRole' call.\n this.headers = userRole ? { 'x-hasura-role': userRole } : {}\n }\n\n generateAccessTokenHeaders(): NhostFunctionCallConfig['headers'] {\n if (this.adminSecret) {\n return {\n 'x-hasura-admin-secret': this.adminSecret\n }\n }\n if (this.accessToken) {\n return {\n Authorization: `Bearer ${this.accessToken}`\n }\n }\n return {}\n }\n}\n","import { NhostGraphqlClient } from '@nhost/graphql-js'\nimport { urlFromSubdomain } from '../utils/helpers'\nimport { NhostClientConstructorParams } from '../utils/types'\n\n/**\n * Creates a client for GraphQL from either a subdomain or a URL\n */\nexport function createGraphqlClient(params: NhostClientConstructorParams) {\n const graphqlUrl = 'subdomain' in params ? urlFromSubdomain(params, 'graphql') : params.graphqlUrl\n\n if (!graphqlUrl) {\n throw new Error('Please provide `subdomain` or `graphqlUrl`.')\n }\n\n return new NhostGraphqlClient({ url: graphqlUrl, ...params })\n}\n","import { HasuraStorageClient } from '@nhost/hasura-storage-js'\n\nimport { urlFromSubdomain } from '../utils/helpers'\nimport { NhostClientConstructorParams } from '../utils/types'\n\n/**\n * Creates a client for Storage from either a subdomain or a URL\n */\nexport function createStorageClient(params: NhostClientConstructorParams) {\n const storageUrl = 'subdomain' in params ? urlFromSubdomain(params, 'storage') : params.storageUrl\n\n if (!storageUrl) {\n throw new Error('Please provide `subdomain` or `storageUrl`.')\n }\n\n return new HasuraStorageClient({ url: storageUrl, ...params })\n}\n","import { NhostGraphqlClient } from '@nhost/graphql-js'\nimport { HasuraAuthClient } from '@nhost/hasura-auth-js'\nimport { HasuraStorageClient } from '@nhost/hasura-storage-js'\nimport { NhostClientConstructorParams } from '../utils/types'\nimport { createAuthClient } from './auth'\nimport { createFunctionsClient, NhostFunctionsClient } from './functions'\nimport { createGraphqlClient } from './graphql'\nimport { createStorageClient } from './storage'\n\nexport const createNhostClient = (params: NhostClientConstructorParams) => new NhostClient(params)\n\nexport class NhostClient {\n auth: HasuraAuthClient\n storage: HasuraStorageClient\n functions: NhostFunctionsClient\n graphql: NhostGraphqlClient\n private _adminSecret?: string\n readonly devTools?: boolean\n\n /**\n *\n * @example\n * ```ts\n * // Create a new Nhost client from subdomain and region.\n * const nhost = new NhostClient({ subdomain, region });\n * ```\n *\n *\n * ```ts\n * // Create a new Nhost client from individual service URLs (custom domains, self-hosting, etc).\n * const nhost = new NhostClient({\n * authUrl: \"my-auth-service-url\",\n * storageUrl: \"my-storage-service-url\",\n * graphqlUrl: \"my-graphql-service-url\",\n * functionsUrl: \"my-functions-service-url\",\n * });\n * ```\n *\n *\n * ```ts\n * // Create a new Nhost client for local development.\n * const nhost = new NhostClient({ subdomain: \"local\" });\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript\n */\n constructor({\n refreshIntervalTime,\n clientStorage,\n clientStorageType,\n autoRefreshToken,\n autoSignIn,\n adminSecret,\n devTools,\n start = true,\n ...urlParams\n }: NhostClientConstructorParams) {\n // * Set clients for all services\n this.auth = createAuthClient({\n refreshIntervalTime,\n clientStorage,\n clientStorageType,\n autoRefreshToken,\n autoSignIn,\n start,\n ...urlParams\n })\n this.storage = createStorageClient({ adminSecret, ...urlParams })\n this.functions = createFunctionsClient({ adminSecret, ...urlParams })\n this.graphql = createGraphqlClient({ adminSecret, ...urlParams })\n\n this.auth.onAuthStateChanged((event, session) => {\n if (event === 'SIGNED_OUT') {\n this.storage.setAccessToken(undefined)\n this.functions.setAccessToken(undefined)\n this.graphql.setAccessToken(undefined)\n\n return\n }\n\n const accessToken = session?.accessToken\n this.storage.setAccessToken(accessToken)\n this.functions.setAccessToken(accessToken)\n this.graphql.setAccessToken(accessToken)\n })\n\n // * Update access token for clients, including when signin in\n this.auth.onTokenChanged((session) => {\n const accessToken = session?.accessToken\n this.storage.setAccessToken(accessToken)\n this.functions.setAccessToken(accessToken)\n this.graphql.setAccessToken(accessToken)\n })\n\n this._adminSecret = adminSecret\n this.devTools = devTools\n }\n\n get adminSecret(): string | undefined {\n return this._adminSecret\n }\n\n set adminSecret(newValue: string | undefined) {\n this._adminSecret = newValue\n this.storage.setAdminSecret(newValue)\n // TODO inconsistent API: storage can change admin secret, but functions/graphql cannot\n // this.functions.setAdminSecret(newValue)\n // this.graphql.setAdminSecret(newValue)\n }\n\n /**\n * Use `nhost.setRole` to set the user role for all subsequent GraphQL, storage, and functions calls.\n * Underneath, this method sets the `x-hasura-role` header on the graphql, storage,\n * and functions clients.\n *\n * ```ts\n * nhost.graphql.setHeaders({ 'x-hasura-role': role })\n * nhost.storage.setHeaders({ 'x-hasura-role': role })\n * nhost.functions.setHeaders({ 'x-hasura-role': role })\n * ```\n *\n * Note: Exercise caution when mixing the use of `setRole` along with `setHeaders` when setting the\n * `x-hasura-role` header, as the last call will override any previous ones.\n *\n * @example\n * ```ts\n * nhost.setRole('admin')\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/set-role\n */\n setRole(role: string) {\n this.graphql.setHeaders({ 'x-hasura-role': role })\n this.storage.setHeaders({ 'x-hasura-role': role })\n this.functions.setHeaders({ 'x-hasura-role': role })\n }\n\n /**\n * Use `nhost.unsetRole` to unset the user role for all subsequent graphql, storage and functions calls.\n * Underneath, this method removes the `x-hasura-role` header from the graphql, storage and functions clients.\n *\n * Note: Exercise caution when mixing the use of `unsetRole` along with `setHeaders` when setting the\n * `x-hasura-role` header, as the last call will override any previous ones.\n *\n * @example\n * ```ts\n * nhost.unsetRole()\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/unset-role\n */\n unsetRole() {\n this.graphql.setHeaders((({ 'x-hasura-role': _, ...rest }) => rest)(this.graphql.getHeaders()))\n this.storage.setHeaders((({ 'x-hasura-role': _, ...rest }) => rest)(this.storage.getHeaders()))\n this.functions.setHeaders(\n (({ 'x-hasura-role': _, ...rest }) => rest)(this.functions.getHeaders())\n )\n }\n}\n"],"names":["LOCALHOST_REGEX","urlFromSubdomain","subdomainAndRegion","service","subdomain","region","subdomainLocalhostFound","protocol","host","port","urlFromEnv","getValueFromEnv","isBrowser","environmentIsAvailable","buildUrl","baseUrl","path","urlPath","createAuthClient","params","authUrl","HasuraAuthClient","createFunctionsClient","functionsUrl","NhostFunctionsClient","__publicField","url","adminSecret","body","config","headers","fullUrl","result","fetch","message","_a","data","_b","e","error","accessToken","userRole","createGraphqlClient","graphqlUrl","NhostGraphqlClient","createStorageClient","storageUrl","HasuraStorageClient","createNhostClient","NhostClient","refreshIntervalTime","clientStorage","clientStorageType","autoRefreshToken","autoSignIn","devTools","start","urlParams","event","session","newValue","role","_","rest"],"mappings":"kYAGaA,EACX,sFASc,SAAAC,EACdC,EACAC,EACQ,CACF,KAAA,CAAE,UAAAC,EAAW,OAAAC,CAAA,EAAWH,EAE9B,GAAI,CAACE,EACG,MAAA,IAAI,MAAM,4BAA4B,EAIxC,MAAAE,EAA0BF,EAAU,MAAMJ,CAAe,EAC/D,GAAIM,GAAA,MAAAA,EAAyB,OAAQ,CACnC,KAAM,CAAE,SAAAC,EAAU,KAAAC,EAAM,KAAAC,GAASH,EAAwB,OAEnDI,EAAaC,EAAgBR,CAAO,EAC1C,OAAIO,IAIAF,IAAS,aACH,QAAA,KACN,0HACF,EAEO,GAAGD,GAAY,MAAM,gBAAgBE,GAAQ,IAAI,OAAON,CAAO,IAGjEM,EACH,GAAGF,GAAY,OAAO,YAAYJ,CAAO,oBAAoBM,CAAI,MACjE,GAAGF,GAAY,OAAO,YAAYJ,CAAO,sBAAA,CAG/C,GAAI,CAACE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K,UAAU,YACZ,CAAC,CAAE,gBAAiBD,EAAG,GAAGC,CAAK,IAAMA,GAAM,KAAK,UAAU,WAAY,CAAA,CACzE,CAAA,CAEJ"}
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from '@nhost/hasura-auth-js';
2
- export * from '@nhost/hasura-storage-js';
3
- export * from './clients';
4
- export { urlFromSubdomain } from './utils/helpers';
5
- export * from './utils/types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,cAAc,eAAe,CAAA"}
package/dist/index.esm.js DELETED
@@ -1,356 +0,0 @@
1
- var p = Object.defineProperty;
2
- var T = (e, t, s) => t in e ? p(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var a = (e, t, s) => T(e, typeof t != "symbol" ? t + "" : t, s);
4
- import { HasuraAuthClient as m } from "@nhost/hasura-auth-js";
5
- export * from "@nhost/hasura-auth-js";
6
- import { HasuraStorageClient as w } from "@nhost/hasura-storage-js";
7
- export * from "@nhost/hasura-storage-js";
8
- import k from "isomorphic-unfetch";
9
- import { NhostGraphqlClient as b } from "@nhost/graphql-js";
10
- const A = /^((?<protocol>http[s]?):\/\/)?(?<host>(localhost|local))(:(?<port>(\d+|__\w+__)))?$/;
11
- function f(e, t) {
12
- const { subdomain: s, region: o } = e;
13
- if (!s)
14
- throw new Error("A `subdomain` must be set.");
15
- const c = s.match(A);
16
- if (c != null && c.groups) {
17
- const { protocol: l, host: i, port: h } = c.groups, r = x(t);
18
- return r || (i === "localhost" ? (console.warn(
19
- 'The `subdomain` is set to "localhost". Support for this will be removed in a future release. Please use "local" instead.'
20
- ), `${l || "http"}://localhost:${h || 1337}/v1/${t}`) : h ? `${l || "https"}://local.${t}.local.nhost.run:${h}/v1` : `${l || "https"}://local.${t}.local.nhost.run/v1`);
21
- }
22
- if (!o)
23
- throw new Error('`region` must be set when using a `subdomain` other than "local".');
24
- return `https://${s}.${t}.${o}.nhost.run/v1`;
25
- }
26
- function S() {
27
- return typeof window != "undefined";
28
- }
29
- function H() {
30
- return typeof process != "undefined" && process.env;
31
- }
32
- function x(e) {
33
- return S() || !H() ? null : process.env[`NHOST_${e.toUpperCase()}_URL`];
34
- }
35
- function U(e, t) {
36
- const o = t.startsWith("/") ? t : `/${t}`;
37
- return e + o;
38
- }
39
- function $(e) {
40
- const t = "subdomain" in e ? f(e, "auth") : e.authUrl, { subdomain: s, region: o } = e;
41
- if (!t)
42
- throw new Error("Please provide `subdomain` or `authUrl`.");
43
- return new m({
44
- url: t,
45
- broadcastKey: `${s}${o != null ? o : "local"}`,
46
- ...e
47
- });
48
- }
49
- function v(e) {
50
- const t = "subdomain" in e ? f(e, "functions") : e.functionsUrl;
51
- if (!t)
52
- throw new Error("Please provide `subdomain` or `functionsUrl`.");
53
- return new C({ url: t, ...e });
54
- }
55
- class C {
56
- constructor(t) {
57
- a(this, "url");
58
- a(this, "accessToken");
59
- a(this, "adminSecret");
60
- a(this, "headers", {});
61
- const { url: s, adminSecret: o } = t;
62
- this.url = s, this.accessToken = null, this.adminSecret = o;
63
- }
64
- /**
65
- * Use `nhost.functions.call` to call (sending a POST request to) a serverless function. Use generic
66
- * types to specify the expected response data, request body and error message.
67
- *
68
- * @example
69
- * ### Without generic types
70
- * ```ts
71
- * await nhost.functions.call('send-welcome-email', { email: 'joe@example.com', name: 'Joe Doe' })
72
- * ```
73
- *
74
- * @example
75
- * ### Using generic types
76
- * ```ts
77
- * type Data = {
78
- * message: string
79
- * }
80
- *
81
- * type Body = {
82
- * email: string
83
- * name: string
84
- * }
85
- *
86
- * type ErrorMessage = {
87
- * details: string
88
- * }
89
- *
90
- * // The function will only accept a body of type `Body`
91
- * const { res, error } = await nhost.functions.call<Data, Body, ErrorMessage>(
92
- * 'send-welcome-email',
93
- * { email: 'joe@example.com', name: 'Joe Doe' }
94
- * )
95
- *
96
- * // Now the response data is typed as `Data`
97
- * console.log(res?.data.message)
98
- *
99
- * // Now the error message is typed as `ErrorMessage`
100
- * console.log(error?.message.details)
101
- * ```
102
- *
103
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/call
104
- */
105
- async call(t, s, o) {
106
- var i, h;
107
- const c = {
108
- "Content-Type": "application/json",
109
- ...this.generateAccessTokenHeaders(),
110
- ...o == null ? void 0 : o.headers,
111
- ...this.headers
112
- // nhost functions client headers to be sent with all calls
113
- }, l = U(this.url, t);
114
- try {
115
- const r = await k(l, {
116
- body: s ? JSON.stringify(s) : null,
117
- headers: c,
118
- method: "POST"
119
- });
120
- if (!r.ok) {
121
- let u;
122
- return (i = r.headers.get("content-type")) != null && i.includes("application/json") ? u = await r.json() : u = await r.text(), {
123
- res: null,
124
- error: {
125
- message: u,
126
- error: r.statusText,
127
- status: r.status
128
- }
129
- };
130
- }
131
- let n;
132
- return (h = r.headers.get("content-type")) != null && h.includes("application/json") ? n = await r.json() : n = await r.text(), {
133
- res: { data: n, status: r.status, statusText: r.statusText },
134
- error: null
135
- };
136
- } catch (r) {
137
- const n = r;
138
- return {
139
- res: null,
140
- error: {
141
- message: n.message,
142
- status: n.name === "AbortError" ? 0 : 500,
143
- error: n.name === "AbortError" ? "abort-error" : "unknown"
144
- }
145
- };
146
- }
147
- }
148
- /**
149
- * Use `nhost.functions.setAccessToken` to a set an access token to be used in subsequent functions requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically.
150
- *
151
- * @example
152
- * ```ts
153
- * nhost.functions.setAccessToken('some-access-token')
154
- * ```
155
- *
156
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/set-access-token
157
- */
158
- setAccessToken(t) {
159
- if (!t) {
160
- this.accessToken = null;
161
- return;
162
- }
163
- this.accessToken = t;
164
- }
165
- /**
166
- * Use `nhost.functions.getHeaders` to get the global headers sent with all functions requests.
167
- *
168
- * @example
169
- * ```ts
170
- * nhost.functions.getHeaders()
171
- * ```
172
- *
173
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/get-headers
174
- */
175
- getHeaders() {
176
- return this.headers;
177
- }
178
- /**
179
- * Use `nhost.functions.setHeaders` to a set global headers to be sent in all subsequent functions requests.
180
- *
181
- * @example
182
- * ```ts
183
- * nhost.functions.setHeaders({
184
- * 'x-hasura-role': 'admin'
185
- * })
186
- * ```
187
- *
188
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/set-headers
189
- */
190
- setHeaders(t) {
191
- t && (this.headers = {
192
- ...this.headers,
193
- ...t
194
- });
195
- }
196
- /**
197
- * Use `nhost.functions.unsetHeaders` to a unset global headers sent with all functions requests.
198
- *
199
- * @example
200
- * ```ts
201
- * nhost.functions.unsetHeaders()
202
- * ```
203
- *
204
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/unset-headers
205
- */
206
- unsetHeaders() {
207
- const t = this.headers["x-hasura-role"];
208
- this.headers = t ? { "x-hasura-role": t } : {};
209
- }
210
- generateAccessTokenHeaders() {
211
- return this.adminSecret ? {
212
- "x-hasura-admin-secret": this.adminSecret
213
- } : this.accessToken ? {
214
- Authorization: `Bearer ${this.accessToken}`
215
- } : {};
216
- }
217
- }
218
- function _(e) {
219
- const t = "subdomain" in e ? f(e, "graphql") : e.graphqlUrl;
220
- if (!t)
221
- throw new Error("Please provide `subdomain` or `graphqlUrl`.");
222
- return new b({ url: t, ...e });
223
- }
224
- function q(e) {
225
- const t = "subdomain" in e ? f(e, "storage") : e.storageUrl;
226
- if (!t)
227
- throw new Error("Please provide `subdomain` or `storageUrl`.");
228
- return new w({ url: t, ...e });
229
- }
230
- const F = (e) => new E(e);
231
- class E {
232
- /**
233
- *
234
- * @example
235
- * ```ts
236
- * // Create a new Nhost client from subdomain and region.
237
- * const nhost = new NhostClient({ subdomain, region });
238
- * ```
239
- *
240
- *
241
- * ```ts
242
- * // Create a new Nhost client from individual service URLs (custom domains, self-hosting, etc).
243
- * const nhost = new NhostClient({
244
- * authUrl: "my-auth-service-url",
245
- * storageUrl: "my-storage-service-url",
246
- * graphqlUrl: "my-graphql-service-url",
247
- * functionsUrl: "my-functions-service-url",
248
- * });
249
- * ```
250
- *
251
- *
252
- * ```ts
253
- * // Create a new Nhost client for local development.
254
- * const nhost = new NhostClient({ subdomain: "local" });
255
- * ```
256
- *
257
- * @docs https://docs.nhost.io/reference/javascript
258
- */
259
- constructor({
260
- refreshIntervalTime: t,
261
- clientStorage: s,
262
- clientStorageType: o,
263
- autoRefreshToken: c,
264
- autoSignIn: l,
265
- adminSecret: i,
266
- devTools: h,
267
- start: r = !0,
268
- ...n
269
- }) {
270
- a(this, "auth");
271
- a(this, "storage");
272
- a(this, "functions");
273
- a(this, "graphql");
274
- a(this, "_adminSecret");
275
- a(this, "devTools");
276
- this.auth = $({
277
- refreshIntervalTime: t,
278
- clientStorage: s,
279
- clientStorageType: o,
280
- autoRefreshToken: c,
281
- autoSignIn: l,
282
- start: r,
283
- ...n
284
- }), this.storage = q({ adminSecret: i, ...n }), this.functions = v({ adminSecret: i, ...n }), this.graphql = _({ adminSecret: i, ...n }), this.auth.onAuthStateChanged((u, d) => {
285
- if (u === "SIGNED_OUT") {
286
- this.storage.setAccessToken(void 0), this.functions.setAccessToken(void 0), this.graphql.setAccessToken(void 0);
287
- return;
288
- }
289
- const g = d == null ? void 0 : d.accessToken;
290
- this.storage.setAccessToken(g), this.functions.setAccessToken(g), this.graphql.setAccessToken(g);
291
- }), this.auth.onTokenChanged((u) => {
292
- const d = u == null ? void 0 : u.accessToken;
293
- this.storage.setAccessToken(d), this.functions.setAccessToken(d), this.graphql.setAccessToken(d);
294
- }), this._adminSecret = i, this.devTools = h;
295
- }
296
- get adminSecret() {
297
- return this._adminSecret;
298
- }
299
- set adminSecret(t) {
300
- this._adminSecret = t, this.storage.setAdminSecret(t);
301
- }
302
- /**
303
- * Use `nhost.setRole` to set the user role for all subsequent GraphQL, storage, and functions calls.
304
- * Underneath, this method sets the `x-hasura-role` header on the graphql, storage,
305
- * and functions clients.
306
- *
307
- * ```ts
308
- * nhost.graphql.setHeaders({ 'x-hasura-role': role })
309
- * nhost.storage.setHeaders({ 'x-hasura-role': role })
310
- * nhost.functions.setHeaders({ 'x-hasura-role': role })
311
- * ```
312
- *
313
- * Note: Exercise caution when mixing the use of `setRole` along with `setHeaders` when setting the
314
- * `x-hasura-role` header, as the last call will override any previous ones.
315
- *
316
- * @example
317
- * ```ts
318
- * nhost.setRole('admin')
319
- * ```
320
- *
321
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/set-role
322
- */
323
- setRole(t) {
324
- this.graphql.setHeaders({ "x-hasura-role": t }), this.storage.setHeaders({ "x-hasura-role": t }), this.functions.setHeaders({ "x-hasura-role": t });
325
- }
326
- /**
327
- * Use `nhost.unsetRole` to unset the user role for all subsequent graphql, storage and functions calls.
328
- * Underneath, this method removes the `x-hasura-role` header from the graphql, storage and functions clients.
329
- *
330
- * Note: Exercise caution when mixing the use of `unsetRole` along with `setHeaders` when setting the
331
- * `x-hasura-role` header, as the last call will override any previous ones.
332
- *
333
- * @example
334
- * ```ts
335
- * nhost.unsetRole()
336
- * ```
337
- *
338
- * @docs https://docs.nhost.io/reference/javascript/nhost-js/unset-role
339
- */
340
- unsetRole() {
341
- this.graphql.setHeaders((({ "x-hasura-role": t, ...s }) => s)(this.graphql.getHeaders())), this.storage.setHeaders((({ "x-hasura-role": t, ...s }) => s)(this.storage.getHeaders())), this.functions.setHeaders(
342
- (({ "x-hasura-role": t, ...s }) => s)(this.functions.getHeaders())
343
- );
344
- }
345
- }
346
- export {
347
- E as NhostClient,
348
- C as NhostFunctionsClient,
349
- $ as createAuthClient,
350
- v as createFunctionsClient,
351
- _ as createGraphqlClient,
352
- F as createNhostClient,
353
- q as createStorageClient,
354
- f as urlFromSubdomain
355
- };
356
- //# sourceMappingURL=index.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/utils/helpers.ts","../src/clients/auth.ts","../src/clients/functions/index.ts","../src/clients/graphql.ts","../src/clients/storage.ts","../src/clients/nhost.ts"],"sourcesContent":["import { NhostClientConstructorParams } from './types'\n\n// a port can be a number or a placeholder string with leading and trailing double underscores, f.e. \"8080\" or \"__PLACEHOLDER_NAME__\"\nexport const LOCALHOST_REGEX =\n /^((?<protocol>http[s]?):\\/\\/)?(?<host>(localhost|local))(:(?<port>(\\d+|__\\w+__)))?$/\n\n/**\n * \\`subdomain\\` and `region` should be used when running the Nhost platform\n *\n * @param subdomainAndRegion\n * @param service\n * @returns\n */\nexport function urlFromSubdomain(\n subdomainAndRegion: Pick<NhostClientConstructorParams, 'region' | 'subdomain'>,\n service: string\n): string {\n const { subdomain, region } = subdomainAndRegion\n\n if (!subdomain) {\n throw new Error('A `subdomain` must be set.')\n }\n\n // check if subdomain is [http[s]://]localhost[:port] or [http[s]://]local[:port]\n const subdomainLocalhostFound = subdomain.match(LOCALHOST_REGEX)\n if (subdomainLocalhostFound?.groups) {\n const { protocol, host, port } = subdomainLocalhostFound.groups\n\n const urlFromEnv = getValueFromEnv(service)\n if (urlFromEnv) {\n return urlFromEnv\n }\n\n if (host === 'localhost') {\n console.warn(\n 'The `subdomain` is set to \"localhost\". Support for this will be removed in a future release. Please use \"local\" instead.'\n )\n\n return `${protocol || 'http'}://localhost:${port || 1337}/v1/${service}`\n }\n\n return port\n ? `${protocol || 'https'}://local.${service}.local.nhost.run:${port}/v1`\n : `${protocol || 'https'}://local.${service}.local.nhost.run/v1`\n }\n\n if (!region) {\n throw new Error('`region` must be set when using a `subdomain` other than \"local\".')\n }\n\n return `https://${subdomain}.${service}.${region}.nhost.run/v1`\n}\n\n/**\n *\n * @returns whether the code is running in a browser\n */\nfunction isBrowser(): boolean {\n return typeof window !== 'undefined'\n}\n\n/**\n *\n * @returns whether the code is running in a Node.js environment\n */\nfunction environmentIsAvailable() {\n return typeof process !== 'undefined' && process.env\n}\n\n/**\n *\n * @param service auth | storage | graphql | functions\n * @returns the service's url if the corresponding env var is set\n * NHOST_${service}_URL\n */\nfunction getValueFromEnv(service: string) {\n if (isBrowser() || !environmentIsAvailable()) {\n return null\n }\n\n return process.env[`NHOST_${service.toUpperCase()}_URL`]\n}\n\n/**\n * Combines a base URL and a path into a single URL string.\n *\n * @param baseUrl - The base URL to use.\n * @param path - The path to append to the base URL.\n * @returns The combined URL string.\n */\nexport function buildUrl(baseUrl: string, path: string) {\n const hasLeadingSlash = path.startsWith('/')\n const urlPath = hasLeadingSlash ? path : `/${path}`\n return baseUrl + urlPath\n}\n","import { HasuraAuthClient } from '@nhost/hasura-auth-js'\n\nimport { urlFromSubdomain } from '../utils/helpers'\nimport { NhostClientConstructorParams } from '../utils/types'\n\n/**\n * Creates a client for Auth from either a subdomain or a URL\n */\nexport function createAuthClient(params: NhostClientConstructorParams) {\n const authUrl = 'subdomain' in params ? urlFromSubdomain(params, 'auth') : params.authUrl\n\n const { subdomain, region } = params\n\n if (!authUrl) {\n throw new Error('Please provide `subdomain` or `authUrl`.')\n }\n\n return new HasuraAuthClient({\n url: authUrl,\n broadcastKey: `${subdomain}${region ?? 'local'}`,\n ...params\n })\n}\n","import fetch from 'isomorphic-unfetch'\nimport { buildUrl, urlFromSubdomain } from '../../utils/helpers'\nimport { NhostClientConstructorParams } from '../../utils/types'\nimport {\n NhostFunctionCallConfig,\n NhostFunctionCallResponse,\n NhostFunctionsConstructorParams\n} from './types'\n/**\n * Creates a client for Functions from either a subdomain or a URL\n */\nexport function createFunctionsClient(params: NhostClientConstructorParams) {\n const functionsUrl =\n 'subdomain' in params ? urlFromSubdomain(params, 'functions') : params.functionsUrl\n\n if (!functionsUrl) {\n throw new Error('Please provide `subdomain` or `functionsUrl`.')\n }\n\n return new NhostFunctionsClient({ url: functionsUrl, ...params })\n}\n\n/**\n * @alias Functions\n */\nexport class NhostFunctionsClient {\n readonly url: string\n private accessToken: string | null\n private adminSecret?: string\n private headers: Record<string, string> = {}\n\n constructor(params: NhostFunctionsConstructorParams) {\n const { url, adminSecret } = params\n\n this.url = url\n this.accessToken = null\n this.adminSecret = adminSecret\n }\n\n /**\n * Use `nhost.functions.call` to call (sending a POST request to) a serverless function. Use generic\n * types to specify the expected response data, request body and error message.\n *\n * @example\n * ### Without generic types\n * ```ts\n * await nhost.functions.call('send-welcome-email', { email: 'joe@example.com', name: 'Joe Doe' })\n * ```\n *\n * @example\n * ### Using generic types\n * ```ts\n * type Data = {\n * message: string\n * }\n *\n * type Body = {\n * email: string\n * name: string\n * }\n *\n * type ErrorMessage = {\n * details: string\n * }\n *\n * // The function will only accept a body of type `Body`\n * const { res, error } = await nhost.functions.call<Data, Body, ErrorMessage>(\n * 'send-welcome-email',\n * { email: 'joe@example.com', name: 'Joe Doe' }\n * )\n *\n * // Now the response data is typed as `Data`\n * console.log(res?.data.message)\n *\n * // Now the error message is typed as `ErrorMessage`\n * console.log(error?.message.details)\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/call\n */\n async call<TData = unknown, TBody = any, TErrorMessage = any>(\n url: string,\n body?: TBody | null,\n config?: NhostFunctionCallConfig\n ): Promise<NhostFunctionCallResponse<TData, TErrorMessage>> {\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n ...this.generateAccessTokenHeaders(),\n ...config?.headers,\n ...this.headers // nhost functions client headers to be sent with all calls\n }\n\n const fullUrl = buildUrl(this.url, url)\n\n try {\n const result = await fetch(fullUrl, {\n body: body ? JSON.stringify(body) : null,\n headers,\n method: 'POST'\n })\n\n if (!result.ok) {\n let message: TErrorMessage\n\n if (result.headers.get('content-type')?.includes('application/json')) {\n message = await result.json()\n } else {\n message = (await result.text()) as unknown as TErrorMessage\n }\n\n return {\n res: null,\n error: {\n message,\n error: result.statusText,\n status: result.status\n }\n }\n }\n\n let data: TData\n\n if (result.headers.get('content-type')?.includes('application/json')) {\n data = await result.json()\n } else {\n data = (await result.text()) as unknown as TData\n }\n\n return {\n res: { data, status: result.status, statusText: result.statusText },\n error: null\n }\n } catch (e) {\n const error = e as Error\n return {\n res: null,\n error: {\n message: error.message as unknown as TErrorMessage,\n status: error.name === 'AbortError' ? 0 : 500,\n error: error.name === 'AbortError' ? 'abort-error' : 'unknown'\n }\n }\n }\n }\n\n /**\n * Use `nhost.functions.setAccessToken` to a set an access token to be used in subsequent functions requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically.\n *\n * @example\n * ```ts\n * nhost.functions.setAccessToken('some-access-token')\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/set-access-token\n */\n setAccessToken(accessToken: string | undefined) {\n if (!accessToken) {\n this.accessToken = null\n return\n }\n\n this.accessToken = accessToken\n }\n\n /**\n * Use `nhost.functions.getHeaders` to get the global headers sent with all functions requests.\n *\n * @example\n * ```ts\n * nhost.functions.getHeaders()\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/get-headers\n */\n getHeaders(): Record<string, string> {\n return this.headers\n }\n\n /**\n * Use `nhost.functions.setHeaders` to a set global headers to be sent in all subsequent functions requests.\n *\n * @example\n * ```ts\n * nhost.functions.setHeaders({\n * 'x-hasura-role': 'admin'\n * })\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/set-headers\n */\n setHeaders(headers?: Record<string, string>) {\n if (!headers) {\n return\n }\n\n this.headers = {\n ...this.headers,\n ...headers\n }\n }\n\n /**\n * Use `nhost.functions.unsetHeaders` to a unset global headers sent with all functions requests.\n *\n * @example\n * ```ts\n * nhost.functions.unsetHeaders()\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/functions/unset-headers\n */\n unsetHeaders() {\n const userRole = this.headers['x-hasura-role']\n\n // preserve the user role header to avoid invalidating preceding 'setRole' call.\n this.headers = userRole ? { 'x-hasura-role': userRole } : {}\n }\n\n generateAccessTokenHeaders(): NhostFunctionCallConfig['headers'] {\n if (this.adminSecret) {\n return {\n 'x-hasura-admin-secret': this.adminSecret\n }\n }\n if (this.accessToken) {\n return {\n Authorization: `Bearer ${this.accessToken}`\n }\n }\n return {}\n }\n}\n","import { NhostGraphqlClient } from '@nhost/graphql-js'\nimport { urlFromSubdomain } from '../utils/helpers'\nimport { NhostClientConstructorParams } from '../utils/types'\n\n/**\n * Creates a client for GraphQL from either a subdomain or a URL\n */\nexport function createGraphqlClient(params: NhostClientConstructorParams) {\n const graphqlUrl = 'subdomain' in params ? urlFromSubdomain(params, 'graphql') : params.graphqlUrl\n\n if (!graphqlUrl) {\n throw new Error('Please provide `subdomain` or `graphqlUrl`.')\n }\n\n return new NhostGraphqlClient({ url: graphqlUrl, ...params })\n}\n","import { HasuraStorageClient } from '@nhost/hasura-storage-js'\n\nimport { urlFromSubdomain } from '../utils/helpers'\nimport { NhostClientConstructorParams } from '../utils/types'\n\n/**\n * Creates a client for Storage from either a subdomain or a URL\n */\nexport function createStorageClient(params: NhostClientConstructorParams) {\n const storageUrl = 'subdomain' in params ? urlFromSubdomain(params, 'storage') : params.storageUrl\n\n if (!storageUrl) {\n throw new Error('Please provide `subdomain` or `storageUrl`.')\n }\n\n return new HasuraStorageClient({ url: storageUrl, ...params })\n}\n","import { NhostGraphqlClient } from '@nhost/graphql-js'\nimport { HasuraAuthClient } from '@nhost/hasura-auth-js'\nimport { HasuraStorageClient } from '@nhost/hasura-storage-js'\nimport { NhostClientConstructorParams } from '../utils/types'\nimport { createAuthClient } from './auth'\nimport { createFunctionsClient, NhostFunctionsClient } from './functions'\nimport { createGraphqlClient } from './graphql'\nimport { createStorageClient } from './storage'\n\nexport const createNhostClient = (params: NhostClientConstructorParams) => new NhostClient(params)\n\nexport class NhostClient {\n auth: HasuraAuthClient\n storage: HasuraStorageClient\n functions: NhostFunctionsClient\n graphql: NhostGraphqlClient\n private _adminSecret?: string\n readonly devTools?: boolean\n\n /**\n *\n * @example\n * ```ts\n * // Create a new Nhost client from subdomain and region.\n * const nhost = new NhostClient({ subdomain, region });\n * ```\n *\n *\n * ```ts\n * // Create a new Nhost client from individual service URLs (custom domains, self-hosting, etc).\n * const nhost = new NhostClient({\n * authUrl: \"my-auth-service-url\",\n * storageUrl: \"my-storage-service-url\",\n * graphqlUrl: \"my-graphql-service-url\",\n * functionsUrl: \"my-functions-service-url\",\n * });\n * ```\n *\n *\n * ```ts\n * // Create a new Nhost client for local development.\n * const nhost = new NhostClient({ subdomain: \"local\" });\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript\n */\n constructor({\n refreshIntervalTime,\n clientStorage,\n clientStorageType,\n autoRefreshToken,\n autoSignIn,\n adminSecret,\n devTools,\n start = true,\n ...urlParams\n }: NhostClientConstructorParams) {\n // * Set clients for all services\n this.auth = createAuthClient({\n refreshIntervalTime,\n clientStorage,\n clientStorageType,\n autoRefreshToken,\n autoSignIn,\n start,\n ...urlParams\n })\n this.storage = createStorageClient({ adminSecret, ...urlParams })\n this.functions = createFunctionsClient({ adminSecret, ...urlParams })\n this.graphql = createGraphqlClient({ adminSecret, ...urlParams })\n\n this.auth.onAuthStateChanged((event, session) => {\n if (event === 'SIGNED_OUT') {\n this.storage.setAccessToken(undefined)\n this.functions.setAccessToken(undefined)\n this.graphql.setAccessToken(undefined)\n\n return\n }\n\n const accessToken = session?.accessToken\n this.storage.setAccessToken(accessToken)\n this.functions.setAccessToken(accessToken)\n this.graphql.setAccessToken(accessToken)\n })\n\n // * Update access token for clients, including when signin in\n this.auth.onTokenChanged((session) => {\n const accessToken = session?.accessToken\n this.storage.setAccessToken(accessToken)\n this.functions.setAccessToken(accessToken)\n this.graphql.setAccessToken(accessToken)\n })\n\n this._adminSecret = adminSecret\n this.devTools = devTools\n }\n\n get adminSecret(): string | undefined {\n return this._adminSecret\n }\n\n set adminSecret(newValue: string | undefined) {\n this._adminSecret = newValue\n this.storage.setAdminSecret(newValue)\n // TODO inconsistent API: storage can change admin secret, but functions/graphql cannot\n // this.functions.setAdminSecret(newValue)\n // this.graphql.setAdminSecret(newValue)\n }\n\n /**\n * Use `nhost.setRole` to set the user role for all subsequent GraphQL, storage, and functions calls.\n * Underneath, this method sets the `x-hasura-role` header on the graphql, storage,\n * and functions clients.\n *\n * ```ts\n * nhost.graphql.setHeaders({ 'x-hasura-role': role })\n * nhost.storage.setHeaders({ 'x-hasura-role': role })\n * nhost.functions.setHeaders({ 'x-hasura-role': role })\n * ```\n *\n * Note: Exercise caution when mixing the use of `setRole` along with `setHeaders` when setting the\n * `x-hasura-role` header, as the last call will override any previous ones.\n *\n * @example\n * ```ts\n * nhost.setRole('admin')\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/set-role\n */\n setRole(role: string) {\n this.graphql.setHeaders({ 'x-hasura-role': role })\n this.storage.setHeaders({ 'x-hasura-role': role })\n this.functions.setHeaders({ 'x-hasura-role': role })\n }\n\n /**\n * Use `nhost.unsetRole` to unset the user role for all subsequent graphql, storage and functions calls.\n * Underneath, this method removes the `x-hasura-role` header from the graphql, storage and functions clients.\n *\n * Note: Exercise caution when mixing the use of `unsetRole` along with `setHeaders` when setting the\n * `x-hasura-role` header, as the last call will override any previous ones.\n *\n * @example\n * ```ts\n * nhost.unsetRole()\n * ```\n *\n * @docs https://docs.nhost.io/reference/javascript/nhost-js/unset-role\n */\n unsetRole() {\n this.graphql.setHeaders((({ 'x-hasura-role': _, ...rest }) => rest)(this.graphql.getHeaders()))\n this.storage.setHeaders((({ 'x-hasura-role': _, ...rest }) => rest)(this.storage.getHeaders()))\n this.functions.setHeaders(\n (({ 'x-hasura-role': _, ...rest }) => rest)(this.functions.getHeaders())\n )\n }\n}\n"],"names":["LOCALHOST_REGEX","urlFromSubdomain","subdomainAndRegion","service","subdomain","region","subdomainLocalhostFound","protocol","host","port","urlFromEnv","getValueFromEnv","isBrowser","environmentIsAvailable","buildUrl","baseUrl","path","urlPath","createAuthClient","params","authUrl","HasuraAuthClient","createFunctionsClient","functionsUrl","NhostFunctionsClient","__publicField","url","adminSecret","body","config","headers","fullUrl","result","fetch","message","_a","data","_b","e","error","accessToken","userRole","createGraphqlClient","graphqlUrl","NhostGraphqlClient","createStorageClient","storageUrl","HasuraStorageClient","createNhostClient","NhostClient","refreshIntervalTime","clientStorage","clientStorageType","autoRefreshToken","autoSignIn","devTools","start","urlParams","event","session","newValue","role","_","rest"],"mappings":";;;;;;;;;AAGO,MAAMA,IACX;AASc,SAAAC,EACdC,GACAC,GACQ;AACF,QAAA,EAAE,WAAAC,GAAW,QAAAC,EAAA,IAAWH;AAE9B,MAAI,CAACE;AACG,UAAA,IAAI,MAAM,4BAA4B;AAIxC,QAAAE,IAA0BF,EAAU,MAAMJ,CAAe;AAC/D,MAAIM,KAAA,QAAAA,EAAyB,QAAQ;AACnC,UAAM,EAAE,UAAAC,GAAU,MAAAC,GAAM,MAAAC,MAASH,EAAwB,QAEnDI,IAAaC,EAAgBR,CAAO;AAC1C,WAAIO,MAIAF,MAAS,eACH,QAAA;AAAA,MACN;AAAA,IACF,GAEO,GAAGD,KAAY,MAAM,gBAAgBE,KAAQ,IAAI,OAAON,CAAO,MAGjEM,IACH,GAAGF,KAAY,OAAO,YAAYJ,CAAO,oBAAoBM,CAAI,QACjE,GAAGF,KAAY,OAAO,YAAYJ,CAAO;AAAA,EAAA;AAG/C,MAAI,CAACE;AACG,UAAA,IAAI,MAAM,mEAAmE;AAGrF,SAAO,WAAWD,CAAS,IAAID,CAAO,IAAIE,CAAM;AAClD;AAMA,SAASO,IAAqB;AAC5B,SAAO,OAAO,UAAW;AAC3B;AAMA,SAASC,IAAyB;AACzB,SAAA,OAAO,WAAY,eAAe,QAAQ;AACnD;AAQA,SAASF,EAAgBR,GAAiB;AACxC,SAAIS,EAAU,KAAK,CAACC,MACX,OAGF,QAAQ,IAAI,SAASV,EAAQ,YAAA,CAAa,MAAM;AACzD;AASgB,SAAAW,EAASC,GAAiBC,GAAc;AAEtD,QAAMC,IADkBD,EAAK,WAAW,GAAG,IACTA,IAAO,IAAIA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REGEX: RegExp;
4
- /**
5
- * \`subdomain\` and `region` should be used when running the Nhost platform
6
- *
7
- * @param subdomainAndRegion
8
- * @param service
9
- * @returns
10
- */
11
- export declare function urlFromSubdomain(subdomainAndRegion: Pick<NhostClientConstructorParams, 'region' | 'subdomain'>, service: string): string;
12
- /**
13
- * Combines a base URL and a path into a single URL string.
14
- *
15
- * @param baseUrl - The base URL to use.
16
- * @param path - The path to append to the base URL.
17
- * @returns The combined URL string.
18
- */
19
- export declare function buildUrl(baseUrl: string, path: string): string;
20
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAGtD,eAAO,MAAM,eAAe,QAC2D,CAAA;AAEvF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,kBAAkB,EAAE,IAAI,CAAC,4BAA4B,EAAE,QAAQ,GAAG,WAAW,CAAC,EAC9E,OAAO,EAAE,MAAM,GACd,MAAM,CAmCR;AAgCD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAIrD"}