@ctx-core/graphql-client 7.2.148 → 7.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @ctx-core/graphql-client
2
2
 
3
+ ## 7.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - dependencies: fix: @ctx-core/env
8
+
9
+ ## 7.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - extract _.js & _.d.ts into directories
14
+
15
+ ### Patch Changes
16
+
17
+ - import*meta_env*() instead of process.env
18
+ - Updated dependencies
19
+ - @ctx-core/env@17.2.18
20
+
3
21
  ## 7.2.148
4
22
 
5
23
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/graphql-client",
3
- "version": "7.2.148",
3
+ "version": "7.3.1",
4
4
  "description": "ctx-core graphql-client",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@ctx-core/dom": "^11.4.21",
27
+ "@ctx-core/env": "^17.2.18",
27
28
  "@ctx-core/fetch-undici": "^2.3.114",
28
29
  "@ctx-core/graphql": "^9.0.117",
29
30
  "@ctx-core/object": "^26.0.0"
@@ -1,3 +1,3 @@
1
1
  export interface FetchHttpHeaders extends Record<string, string> {
2
- 'Content-Type':string;
2
+ 'Content-Type':string
3
3
  }
@@ -1,5 +1,5 @@
1
1
  import type { FetchHttpHeaders } from './FetchHttpHeaders'
2
2
  export interface FetchHttpOpts {
3
- url?:string;
4
- headers?:FetchHttpHeaders;
3
+ url?:string
4
+ headers?:FetchHttpHeaders
5
5
  }
@@ -1,8 +1,11 @@
1
- import type { FetchHttpOpts } from './_types'
1
+ import type { FetchHttpOpts } from '../_types'
2
2
  export declare function graphql_fetch<data_T extends unknown = unknown>(
3
3
  body:string, fn_in_http_opts?:FetchHttpOpts
4
- ):Promise<graphql_fetch_response_T<data_T>>;
4
+ ):Promise<graphql_fetch_response_T<data_T>>
5
5
  export interface graphql_fetch_response_T<data_T extends unknown = unknown> {
6
- data:data_T;
6
+ data:data_T
7
+ }
8
+ export {
9
+ graphql_fetch as fetch_graphql,
10
+ graphql_fetch as fetch__graphql,
7
11
  }
8
- export { graphql_fetch as fetch_graphql, graphql_fetch as fetch__graphql, }
@@ -0,0 +1,23 @@
1
+ import { graphql_fetch_ } from '../graphql_fetch_/index.js'
2
+ import { graphql_url_ } from '../graphql_url_/index.js'
3
+ let in_graphql_fetch
4
+ /**
5
+ * @param {string}body
6
+ * @param {import('../_types').FetchHttpOpts}fn_in_http_opts
7
+ * @returns {Promise<import('./index.d.ts').graphql_fetch_response_T>}
8
+ */
9
+ export function graphql_fetch(
10
+ body,
11
+ fn_in_http_opts = {}
12
+ ) {
13
+ if (!in_graphql_fetch) {
14
+ in_graphql_fetch = graphql_fetch_({
15
+ url: graphql_url_()
16
+ })
17
+ }
18
+ return in_graphql_fetch(body, fn_in_http_opts)
19
+ }
20
+ export {
21
+ graphql_fetch as fetch_graphql,
22
+ graphql_fetch as fetch__graphql,
23
+ }
@@ -0,0 +1,11 @@
1
+ import type { FetchHttpOpts } from '../_types'
2
+ import type { graphql_fetch_response_T } from '../graphql_fetch'
3
+ export declare function graphql_fetch_<
4
+ O1 extends unknown = unknown
5
+ >(in_http_opts?:FetchHttpOpts):graphql_fetch_T<O1>
6
+ export declare type graphql_fetch_T<O extends unknown = unknown> =
7
+ (body:string, fn_in_http_opts?:FetchHttpOpts)=>Promise<graphql_fetch_response_T<O>>
8
+ export {
9
+ graphql_fetch_ as _graphql_fetch,
10
+ graphql_fetch_ as _fetch__graphql,
11
+ }
@@ -1,5 +1,11 @@
1
+ import { import_meta_env_ } from '@ctx-core/env'
1
2
  import { fetch_response_pair_ } from '@ctx-core/fetch-undici'
2
3
  import { assign } from '@ctx-core/object'
4
+ /**
5
+ * @param {import('../_types').FetchHttpOpts}in_http_opts
6
+ * @returns {import('../graphql_fetch').graphql_fetch_response_T}
7
+ * @private
8
+ */
3
9
  export function graphql_fetch_(in_http_opts = {}) {
4
10
  return async function graphql_fetch(body, fn_in_http_opts = {}) {
5
11
  const url = fn_in_http_opts.url || in_http_opts.url
@@ -17,7 +23,7 @@ export function graphql_fetch_(in_http_opts = {}) {
17
23
  if (payload.errors) throw payload
18
24
  return payload
19
25
  } else {
20
- if (process.env.NODE_ENV === 'production') {
26
+ if (import_meta_env_().NODE_ENV === 'production') {
21
27
  console.error(payload)
22
28
  throw `Error fetching graphql`
23
29
  } else {
@@ -26,4 +32,7 @@ export function graphql_fetch_(in_http_opts = {}) {
26
32
  }
27
33
  }
28
34
  }
29
- export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, }
35
+ export {
36
+ graphql_fetch_ as _graphql_fetch,
37
+ graphql_fetch_ as _fetch__graphql,
38
+ }
@@ -0,0 +1,5 @@
1
+ export declare function graphql_port_txt_(port?:number|string|undefined):string
2
+ export {
3
+ graphql_port_txt_ as _graphql_port_txt,
4
+ graphql_port_txt_ as _txt__port__graphql,
5
+ }
@@ -0,0 +1,13 @@
1
+ import { import_meta_env_ } from '@ctx-core/env'
2
+ /**
3
+ * @param {number|string}port
4
+ * @returns {string}
5
+ * @private
6
+ */
7
+ export function graphql_port_txt_(port = import_meta_env_().PORT) {
8
+ return (port || 80) === 80 ? '' : `:${port}`
9
+ }
10
+ export {
11
+ graphql_port_txt_ as _graphql_port_txt,
12
+ graphql_port_txt_ as _txt__port__graphql,
13
+ }
@@ -0,0 +1,5 @@
1
+ export declare function graphql_url_(host?:string, port?:number):string
2
+ export {
3
+ graphql_url_ as _graphql_url,
4
+ graphql_url_ as _url__graphql,
5
+ }
@@ -1,8 +1,11 @@
1
1
  import { has_dom } from '@ctx-core/dom'
2
- import { graphql_port_txt_ } from './graphql_port_txt_.js'
2
+ import { graphql_port_txt_ } from '../graphql_port_txt_/index.js'
3
3
  export function graphql_url_(host = '127.0.0.1', port = 80) {
4
4
  if (has_dom) return '/graphql'
5
5
  const host_port = `${host}${graphql_port_txt_(port)}`
6
6
  return `http://${host_port}/graphql`
7
7
  }
8
- export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, }
8
+ export {
9
+ graphql_url_ as _graphql_url,
10
+ graphql_url_ as _url__graphql,
11
+ }
@@ -1,12 +0,0 @@
1
- import { graphql_fetch_ } from './graphql_fetch_.js'
2
- import { graphql_url_ } from './graphql_url_.js'
3
- let in_graphql_fetch
4
- export function graphql_fetch(body, fn_in_http_opts = {}) {
5
- if (!in_graphql_fetch) {
6
- in_graphql_fetch = graphql_fetch_({
7
- url: graphql_url_()
8
- })
9
- }
10
- return in_graphql_fetch(body, fn_in_http_opts)
11
- }
12
- export { graphql_fetch as fetch_graphql, graphql_fetch as fetch__graphql, }
@@ -1,8 +0,0 @@
1
- import type { FetchHttpOpts } from './_types'
2
- import type { graphql_fetch_response_T } from './graphql_fetch'
3
- export declare function graphql_fetch_<O1 extends unknown = unknown>(
4
- in_http_opts?:FetchHttpOpts
5
- ):graphql_fetch_T<O1>;
6
- export declare type graphql_fetch_T<O extends unknown = unknown> =
7
- (body:string, fn_in_http_opts?:FetchHttpOpts)=>Promise<graphql_fetch_response_T<O>>;
8
- export { graphql_fetch_ as _graphql_fetch, graphql_fetch_ as _fetch__graphql, }
@@ -1,2 +0,0 @@
1
- export declare function graphql_port_txt_(port?:string|undefined):string;
2
- export { graphql_port_txt_ as _graphql_port_txt, graphql_port_txt_ as _txt__port__graphql, }
@@ -1,4 +0,0 @@
1
- export function graphql_port_txt_(port = process.env.PORT) {
2
- return (port || 80) === 80 ? '' : `:${port}`
3
- }
4
- export { graphql_port_txt_ as _graphql_port_txt, graphql_port_txt_ as _txt__port__graphql, }
@@ -1,2 +0,0 @@
1
- export declare function graphql_url_(host?:string, port?:number):string;
2
- export { graphql_url_ as _graphql_url, graphql_url_ as _url__graphql, }