asma-helpers 0.2.35 → 0.2.36
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.
|
@@ -5,13 +5,13 @@ interface CliOptions extends Omit<ClientOptions, 'url'> {
|
|
|
5
5
|
}
|
|
6
6
|
export declare function generateGenqlClient<T extends ReturnType<typeof createClient>>({ setReqConfig, createClient, serviceUrl, path, }: {
|
|
7
7
|
setReqConfig: () => Promise<AxiosRequestConfig<any>>;
|
|
8
|
-
createClient: (options?: ClientOptions | undefined) => T
|
|
8
|
+
createClient: (options?: ClientOptions | undefined) => T;
|
|
9
9
|
serviceUrl: () => string;
|
|
10
10
|
path?: string;
|
|
11
11
|
}): {
|
|
12
|
-
getGenqlClient: () => Promise<T
|
|
13
|
-
genqlClient: (options?: CliOptions) => Promise<T
|
|
14
|
-
genqlClientWs: () => Promise<T
|
|
12
|
+
getGenqlClient: () => Promise<T>;
|
|
13
|
+
genqlClient: (options?: CliOptions) => Promise<T>;
|
|
14
|
+
genqlClientWs: () => Promise<T>;
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=generateGenqlClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateGenqlClient.d.ts","sourceRoot":"","sources":["../../src/helpers/generateGenqlClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAIjE,UAAU,UAAW,SAAQ,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC;IACnD,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,YAAY,CAAC,EAAE,EAC3E,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,IAAoB,GACvB,EAAE;IAEC,YAAY,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAA;IACpD,YAAY,EAAE,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"generateGenqlClient.d.ts","sourceRoot":"","sources":["../../src/helpers/generateGenqlClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAIjE,UAAU,UAAW,SAAQ,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC;IACnD,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,YAAY,CAAC,EAAE,EAC3E,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,IAAoB,GACvB,EAAE;IAEC,YAAY,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAA;IACpD,YAAY,EAAE,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,KAAK,CAAC,CAAA;IACxD,UAAU,EAAE,MAAM,MAAM,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;;4BAyCuC,UAAU,KAAQ,QAAQ,CAAC,CAAC;;EA8CnE"}
|
|
@@ -10,7 +10,7 @@ export function generateGenqlClient({ setReqConfig, createClient, serviceUrl, pa
|
|
|
10
10
|
// return jwt_exp - 10 <= nowTime
|
|
11
11
|
//}
|
|
12
12
|
async function getGenqlClient() {
|
|
13
|
-
if ( /* accessTokenHasExpired() ||
|
|
13
|
+
if ( /* accessTokenHasExpired() || */client === null) {
|
|
14
14
|
client = await genqlClient();
|
|
15
15
|
return client;
|
|
16
16
|
}
|
|
@@ -32,33 +32,31 @@ export function generateGenqlClient({ setReqConfig, createClient, serviceUrl, pa
|
|
|
32
32
|
*
|
|
33
33
|
*/
|
|
34
34
|
async function genqlClient(options = {}) {
|
|
35
|
-
|
|
36
|
-
let req_headers = {};
|
|
35
|
+
//let req_headers: Record<string, string> = {}
|
|
37
36
|
const { anonymous, headers, ...rest } = options;
|
|
38
37
|
if (!serviceUrl()) {
|
|
39
38
|
console.warn('requred param srv_url is undefined, please check EnvConfig object!');
|
|
40
39
|
}
|
|
41
|
-
if (!anonymous) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
40
|
+
//if (!anonymous) {
|
|
41
|
+
//req_headers = ((await setReqConfig()).headers ?? {}) as Record<string, string>
|
|
42
|
+
// setJwtExp(req_headers['Authorization'])
|
|
43
|
+
// }
|
|
46
44
|
return createClient({
|
|
47
45
|
url: `${serviceUrl()}${path}`,
|
|
48
|
-
headers: async () =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
headers: async () => {
|
|
47
|
+
var _a;
|
|
48
|
+
return ({
|
|
49
|
+
...(options.anonymous ? {} : ((_a = (await setReqConfig()).headers) !== null && _a !== void 0 ? _a : {})),
|
|
50
|
+
...headers,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
52
53
|
batch: { batchInterval: 50, maxBatchSize: 100 },
|
|
53
54
|
...rest,
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
async function genqlClientWs() {
|
|
57
|
-
var _a;
|
|
58
58
|
if ( /* accessTokenHasExpired() || */!wsClient) {
|
|
59
|
-
const req_headers = ((
|
|
60
|
-
if (!req_headers['Authorization'])
|
|
61
|
-
return null;
|
|
59
|
+
//const req_headers = ((await setReqConfig()).headers ?? {}) as Record<string, string>
|
|
62
60
|
//setJwtExp(req_headers['Authorization'])
|
|
63
61
|
wsClient = createClient({
|
|
64
62
|
url: `${httpToWs(serviceUrl())}${path}`,
|
|
@@ -67,7 +65,7 @@ export function generateGenqlClient({ setReqConfig, createClient, serviceUrl, pa
|
|
|
67
65
|
subscription: {
|
|
68
66
|
reconnect: true,
|
|
69
67
|
reconnectionAttempts: 5,
|
|
70
|
-
headers: async () =>
|
|
68
|
+
headers: async () => { var _a; return ((_a = (await setReqConfig()).headers) !== null && _a !== void 0 ? _a : {}); },
|
|
71
69
|
},
|
|
72
70
|
});
|
|
73
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateGenqlClient.js","sourceRoot":"","sources":["../../src/helpers/generateGenqlClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAOnC,MAAM,UAAU,mBAAmB,CAA4C,EAC3E,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,IAAI,GAAG,aAAa,GAOvB;IACG,kBAAkB;IAElB,IAAI,MAAM,GAAa,IAAI,CAAA;IAE3B,IAAI,QAAQ,GAAa,IAAI,CAAA;IAE7B,oCAAoC;IACpC,6DAA6D;IAC7D,EAAE;IACF,2DAA2D;IAC3D,oCAAoC;IACpC,GAAG;IAEH,KAAK,UAAU,cAAc;QACzB,KAAI,gCAAiC,
|
|
1
|
+
{"version":3,"file":"generateGenqlClient.js","sourceRoot":"","sources":["../../src/helpers/generateGenqlClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAOnC,MAAM,UAAU,mBAAmB,CAA4C,EAC3E,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,IAAI,GAAG,aAAa,GAOvB;IACG,kBAAkB;IAElB,IAAI,MAAM,GAAa,IAAI,CAAA;IAE3B,IAAI,QAAQ,GAAa,IAAI,CAAA;IAE7B,oCAAoC;IACpC,6DAA6D;IAC7D,EAAE;IACF,2DAA2D;IAC3D,oCAAoC;IACpC,GAAG;IAEH,KAAK,UAAU,cAAc;QACzB,KAAI,gCAAiC,MAAM,KAAK,IAAI,EAAE;YAClD,MAAM,GAAG,MAAM,WAAW,EAAE,CAAA;YAE5B,OAAO,MAAM,CAAA;SAChB;QAED,OAAO,MAAM,CAAA;IACjB,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EAAE,IAAI;oBACf,oBAAoB,EAAE,CAAC;oBACvB,OAAO,EAAE,KAAK,IAAI,EAAE,WAAC,OAAA,CAAC,MAAA,CAAC,MAAM,YAAY,EAAE,CAAC,CAAC,OAAO,mCAAI,EAAE,CAA2B,CAAA,EAAA;iBACxF;aACJ,CAAC,CAAA;SACL;QAED,OAAO,QAAQ,CAAA;IACnB,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,uBAAuB,CAAC,WAAW,EAAE,aAAa,EAAE,CAAA;AACjF,CAAC"}
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
15
15
|
}: {
|
|
16
16
|
// jwt_exp: number
|
|
17
17
|
setReqConfig: () => Promise<AxiosRequestConfig<any>>
|
|
18
|
-
createClient: (options?: ClientOptions | undefined) => T
|
|
18
|
+
createClient: (options?: ClientOptions | undefined) => T
|
|
19
19
|
serviceUrl: () => string
|
|
20
20
|
path?: string
|
|
21
21
|
}) {
|
|
@@ -33,7 +33,7 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
33
33
|
//}
|
|
34
34
|
|
|
35
35
|
async function getGenqlClient() {
|
|
36
|
-
if (/* accessTokenHasExpired() || */
|
|
36
|
+
if (/* accessTokenHasExpired() || */ client === null) {
|
|
37
37
|
client = await genqlClient()
|
|
38
38
|
|
|
39
39
|
return client
|
|
@@ -59,23 +59,23 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
59
59
|
* This is used for anonymous requests as well as authenticated requests
|
|
60
60
|
*
|
|
61
61
|
*/
|
|
62
|
-
async function genqlClient(options: CliOptions = {}): Promise<T
|
|
63
|
-
let req_headers: Record<string, string> = {}
|
|
62
|
+
async function genqlClient(options: CliOptions = {}): Promise<T> {
|
|
63
|
+
//let req_headers: Record<string, string> = {}
|
|
64
64
|
|
|
65
65
|
const { anonymous, headers, ...rest } = options
|
|
66
66
|
|
|
67
67
|
if (!serviceUrl()) {
|
|
68
68
|
console.warn('requred param srv_url is undefined, please check EnvConfig object!')
|
|
69
69
|
}
|
|
70
|
-
if (!anonymous) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
70
|
+
//if (!anonymous) {
|
|
71
|
+
//req_headers = ((await setReqConfig()).headers ?? {}) as Record<string, string>
|
|
72
|
+
// setJwtExp(req_headers['Authorization'])
|
|
73
|
+
// }
|
|
74
74
|
|
|
75
75
|
return createClient({
|
|
76
76
|
url: `${serviceUrl()}${path}`,
|
|
77
77
|
headers: async () => ({
|
|
78
|
-
...
|
|
78
|
+
...(options.anonymous ? {} : (((await setReqConfig()).headers ?? {}) as Record<string, string>)),
|
|
79
79
|
...headers,
|
|
80
80
|
}),
|
|
81
81
|
batch: { batchInterval: 50, maxBatchSize: 100 },
|
|
@@ -85,9 +85,7 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
85
85
|
|
|
86
86
|
async function genqlClientWs() {
|
|
87
87
|
if (/* accessTokenHasExpired() || */ !wsClient) {
|
|
88
|
-
const req_headers = ((await setReqConfig()).headers ?? {}) as Record<string, string>
|
|
89
|
-
|
|
90
|
-
if (!req_headers['Authorization']) return null
|
|
88
|
+
//const req_headers = ((await setReqConfig()).headers ?? {}) as Record<string, string>
|
|
91
89
|
|
|
92
90
|
//setJwtExp(req_headers['Authorization'])
|
|
93
91
|
|
|
@@ -98,7 +96,7 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
98
96
|
subscription: {
|
|
99
97
|
reconnect: true,
|
|
100
98
|
reconnectionAttempts: 5,
|
|
101
|
-
headers: async () =>
|
|
99
|
+
headers: async () => ((await setReqConfig()).headers ?? {}) as Record<string, string>,
|
|
102
100
|
},
|
|
103
101
|
})
|
|
104
102
|
}
|