naystack 1.4.26 → 1.4.28
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/dist/graphql/index.cjs.js +29 -4
- package/dist/graphql/index.esm.js +29 -4
- package/dist/graphql/utils.cjs.js +29 -4
- package/dist/graphql/utils.d.mts +13 -11
- package/dist/graphql/utils.d.ts +13 -11
- package/dist/graphql/utils.esm.js +29 -4
- package/package.json +1 -1
|
@@ -694,7 +694,7 @@ function query(fn, options) {
|
|
|
694
694
|
...options,
|
|
695
695
|
fn,
|
|
696
696
|
authCall: getAuthCaller(fn),
|
|
697
|
-
call: getCaller(fn)
|
|
697
|
+
call: options.authorized ? getAuthCaller(fn) : getCaller(fn)
|
|
698
698
|
};
|
|
699
699
|
}
|
|
700
700
|
var getUserId = async () => {
|
|
@@ -708,7 +708,7 @@ function getAuthCaller(fn) {
|
|
|
708
708
|
userId: await getUserId(),
|
|
709
709
|
isRefreshID: true
|
|
710
710
|
};
|
|
711
|
-
return fn(ctx, data);
|
|
711
|
+
return await fn(ctx, data);
|
|
712
712
|
};
|
|
713
713
|
}
|
|
714
714
|
function getCaller(fn) {
|
|
@@ -717,11 +717,36 @@ function getCaller(fn) {
|
|
|
717
717
|
userId: null,
|
|
718
718
|
isRefreshID: true
|
|
719
719
|
};
|
|
720
|
-
return fn(ctx, data);
|
|
720
|
+
return await fn(ctx, data);
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
function getFieldAuthCaller(fn) {
|
|
724
|
+
return async (root, data) => {
|
|
725
|
+
const ctx = {
|
|
726
|
+
userId: await getUserId(),
|
|
727
|
+
isRefreshID: true
|
|
728
|
+
};
|
|
729
|
+
return await fn(root, ctx, data);
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
function getFieldCaller(fn) {
|
|
733
|
+
return async (root, data) => {
|
|
734
|
+
const ctx = {
|
|
735
|
+
userId: null,
|
|
736
|
+
isRefreshID: true
|
|
737
|
+
};
|
|
738
|
+
return await fn(root, ctx, data);
|
|
721
739
|
};
|
|
722
740
|
}
|
|
723
741
|
function field(fn, options) {
|
|
724
|
-
return {
|
|
742
|
+
return {
|
|
743
|
+
...options,
|
|
744
|
+
fn,
|
|
745
|
+
authCall: getFieldAuthCaller(fn),
|
|
746
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
747
|
+
fn
|
|
748
|
+
)
|
|
749
|
+
};
|
|
725
750
|
}
|
|
726
751
|
function QueryLibrary(queries) {
|
|
727
752
|
let GeneratedResolver = class {
|
|
@@ -690,7 +690,7 @@ function query(fn, options) {
|
|
|
690
690
|
...options,
|
|
691
691
|
fn,
|
|
692
692
|
authCall: getAuthCaller(fn),
|
|
693
|
-
call: getCaller(fn)
|
|
693
|
+
call: options.authorized ? getAuthCaller(fn) : getCaller(fn)
|
|
694
694
|
};
|
|
695
695
|
}
|
|
696
696
|
var getUserId = async () => {
|
|
@@ -704,7 +704,7 @@ function getAuthCaller(fn) {
|
|
|
704
704
|
userId: await getUserId(),
|
|
705
705
|
isRefreshID: true
|
|
706
706
|
};
|
|
707
|
-
return fn(ctx, data);
|
|
707
|
+
return await fn(ctx, data);
|
|
708
708
|
};
|
|
709
709
|
}
|
|
710
710
|
function getCaller(fn) {
|
|
@@ -713,11 +713,36 @@ function getCaller(fn) {
|
|
|
713
713
|
userId: null,
|
|
714
714
|
isRefreshID: true
|
|
715
715
|
};
|
|
716
|
-
return fn(ctx, data);
|
|
716
|
+
return await fn(ctx, data);
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
function getFieldAuthCaller(fn) {
|
|
720
|
+
return async (root, data) => {
|
|
721
|
+
const ctx = {
|
|
722
|
+
userId: await getUserId(),
|
|
723
|
+
isRefreshID: true
|
|
724
|
+
};
|
|
725
|
+
return await fn(root, ctx, data);
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
function getFieldCaller(fn) {
|
|
729
|
+
return async (root, data) => {
|
|
730
|
+
const ctx = {
|
|
731
|
+
userId: null,
|
|
732
|
+
isRefreshID: true
|
|
733
|
+
};
|
|
734
|
+
return await fn(root, ctx, data);
|
|
717
735
|
};
|
|
718
736
|
}
|
|
719
737
|
function field(fn, options) {
|
|
720
|
-
return {
|
|
738
|
+
return {
|
|
739
|
+
...options,
|
|
740
|
+
fn,
|
|
741
|
+
authCall: getFieldAuthCaller(fn),
|
|
742
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
743
|
+
fn
|
|
744
|
+
)
|
|
745
|
+
};
|
|
721
746
|
}
|
|
722
747
|
function QueryLibrary(queries) {
|
|
723
748
|
let GeneratedResolver = class {
|
|
@@ -116,7 +116,7 @@ function query(fn, options) {
|
|
|
116
116
|
...options,
|
|
117
117
|
fn,
|
|
118
118
|
authCall: getAuthCaller(fn),
|
|
119
|
-
call: getCaller(fn)
|
|
119
|
+
call: options.authorized ? getAuthCaller(fn) : getCaller(fn)
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
var getUserId = async () => {
|
|
@@ -130,7 +130,7 @@ function getAuthCaller(fn) {
|
|
|
130
130
|
userId: await getUserId(),
|
|
131
131
|
isRefreshID: true
|
|
132
132
|
};
|
|
133
|
-
return fn(ctx, data);
|
|
133
|
+
return await fn(ctx, data);
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
function getCaller(fn) {
|
|
@@ -139,11 +139,36 @@ function getCaller(fn) {
|
|
|
139
139
|
userId: null,
|
|
140
140
|
isRefreshID: true
|
|
141
141
|
};
|
|
142
|
-
return fn(ctx, data);
|
|
142
|
+
return await fn(ctx, data);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function getFieldAuthCaller(fn) {
|
|
146
|
+
return async (root, data) => {
|
|
147
|
+
const ctx = {
|
|
148
|
+
userId: await getUserId(),
|
|
149
|
+
isRefreshID: true
|
|
150
|
+
};
|
|
151
|
+
return await fn(root, ctx, data);
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function getFieldCaller(fn) {
|
|
155
|
+
return async (root, data) => {
|
|
156
|
+
const ctx = {
|
|
157
|
+
userId: null,
|
|
158
|
+
isRefreshID: true
|
|
159
|
+
};
|
|
160
|
+
return await fn(root, ctx, data);
|
|
143
161
|
};
|
|
144
162
|
}
|
|
145
163
|
function field(fn, options) {
|
|
146
|
-
return {
|
|
164
|
+
return {
|
|
165
|
+
...options,
|
|
166
|
+
fn,
|
|
167
|
+
authCall: getFieldAuthCaller(fn),
|
|
168
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
169
|
+
fn
|
|
170
|
+
)
|
|
171
|
+
};
|
|
147
172
|
}
|
|
148
173
|
function QueryLibrary(queries) {
|
|
149
174
|
let GeneratedResolver = class {
|
package/dist/graphql/utils.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
import { Query, Arg
|
|
2
|
+
import { ClassType, Query, Arg } from 'type-graphql';
|
|
3
3
|
import { AuthorizedContext, Context } from './types.mjs';
|
|
4
4
|
|
|
5
5
|
type ReturnOptions = Parameters<typeof Query>[1];
|
|
@@ -23,21 +23,23 @@ interface BaseDefinition<T, U, IsAuth extends boolean = false, OutputNullable ex
|
|
|
23
23
|
inputOptions?: NullableOptions<ArgsOptions, InputNullable>;
|
|
24
24
|
authorized?: IsAuth;
|
|
25
25
|
}
|
|
26
|
-
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
27
|
-
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
28
|
-
call:
|
|
29
|
-
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
26
|
+
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
27
|
+
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
28
|
+
call: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
29
|
+
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
30
30
|
mutation?: boolean;
|
|
31
31
|
}
|
|
32
|
-
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
33
|
-
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
34
|
-
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
32
|
+
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>;
|
|
33
|
+
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
34
|
+
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
35
|
+
call: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
36
|
+
authCall: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
35
37
|
}
|
|
36
|
-
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
37
|
-
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any>>>(queries: T): {
|
|
38
|
+
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>;
|
|
39
|
+
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any, any>>>(queries: T): {
|
|
38
40
|
new (): {};
|
|
39
41
|
};
|
|
40
|
-
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any>>>(type: ClassType, queries: T): {
|
|
42
|
+
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>>>(type: ClassType, queries: T): {
|
|
41
43
|
new (): {};
|
|
42
44
|
};
|
|
43
45
|
|
package/dist/graphql/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
import { Query, Arg
|
|
2
|
+
import { ClassType, Query, Arg } from 'type-graphql';
|
|
3
3
|
import { AuthorizedContext, Context } from './types.js';
|
|
4
4
|
|
|
5
5
|
type ReturnOptions = Parameters<typeof Query>[1];
|
|
@@ -23,21 +23,23 @@ interface BaseDefinition<T, U, IsAuth extends boolean = false, OutputNullable ex
|
|
|
23
23
|
inputOptions?: NullableOptions<ArgsOptions, InputNullable>;
|
|
24
24
|
authorized?: IsAuth;
|
|
25
25
|
}
|
|
26
|
-
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
27
|
-
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
28
|
-
call:
|
|
29
|
-
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
26
|
+
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
27
|
+
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
28
|
+
call: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
29
|
+
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
30
30
|
mutation?: boolean;
|
|
31
31
|
}
|
|
32
|
-
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
33
|
-
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
34
|
-
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
32
|
+
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>;
|
|
33
|
+
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
34
|
+
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
35
|
+
call: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
36
|
+
authCall: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
35
37
|
}
|
|
36
|
-
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
37
|
-
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any>>>(queries: T): {
|
|
38
|
+
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>;
|
|
39
|
+
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any, any>>>(queries: T): {
|
|
38
40
|
new (): {};
|
|
39
41
|
};
|
|
40
|
-
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any>>>(type: ClassType, queries: T): {
|
|
42
|
+
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>>>(type: ClassType, queries: T): {
|
|
41
43
|
new (): {};
|
|
42
44
|
};
|
|
43
45
|
|
|
@@ -101,7 +101,7 @@ function query(fn, options) {
|
|
|
101
101
|
...options,
|
|
102
102
|
fn,
|
|
103
103
|
authCall: getAuthCaller(fn),
|
|
104
|
-
call: getCaller(fn)
|
|
104
|
+
call: options.authorized ? getAuthCaller(fn) : getCaller(fn)
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
var getUserId = async () => {
|
|
@@ -115,7 +115,7 @@ function getAuthCaller(fn) {
|
|
|
115
115
|
userId: await getUserId(),
|
|
116
116
|
isRefreshID: true
|
|
117
117
|
};
|
|
118
|
-
return fn(ctx, data);
|
|
118
|
+
return await fn(ctx, data);
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
function getCaller(fn) {
|
|
@@ -124,11 +124,36 @@ function getCaller(fn) {
|
|
|
124
124
|
userId: null,
|
|
125
125
|
isRefreshID: true
|
|
126
126
|
};
|
|
127
|
-
return fn(ctx, data);
|
|
127
|
+
return await fn(ctx, data);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function getFieldAuthCaller(fn) {
|
|
131
|
+
return async (root, data) => {
|
|
132
|
+
const ctx = {
|
|
133
|
+
userId: await getUserId(),
|
|
134
|
+
isRefreshID: true
|
|
135
|
+
};
|
|
136
|
+
return await fn(root, ctx, data);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function getFieldCaller(fn) {
|
|
140
|
+
return async (root, data) => {
|
|
141
|
+
const ctx = {
|
|
142
|
+
userId: null,
|
|
143
|
+
isRefreshID: true
|
|
144
|
+
};
|
|
145
|
+
return await fn(root, ctx, data);
|
|
128
146
|
};
|
|
129
147
|
}
|
|
130
148
|
function field(fn, options) {
|
|
131
|
-
return {
|
|
149
|
+
return {
|
|
150
|
+
...options,
|
|
151
|
+
fn,
|
|
152
|
+
authCall: getFieldAuthCaller(fn),
|
|
153
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
154
|
+
fn
|
|
155
|
+
)
|
|
156
|
+
};
|
|
132
157
|
}
|
|
133
158
|
function QueryLibrary(queries) {
|
|
134
159
|
let GeneratedResolver = class {
|