naystack 1.1.12-beta.3 → 1.1.12-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/graphql/index.cjs.js +111 -2
- package/dist/graphql/index.esm.js +118 -1
- package/package.json +2 -2
|
@@ -16,11 +16,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
+
if (decorator = decorators[i])
|
|
23
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
+
if (kind && result) __defProp(target, key, result);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
19
27
|
|
|
20
28
|
// src/graphql/index.ts
|
|
21
29
|
var graphql_exports = {};
|
|
22
30
|
__export(graphql_exports, {
|
|
23
|
-
|
|
31
|
+
FieldLibrary: () => FieldLibrary,
|
|
32
|
+
QueryLibrary: () => QueryLibrary,
|
|
33
|
+
field: () => field,
|
|
34
|
+
initGraphQLServer: () => initGraphQLServer,
|
|
35
|
+
query: () => query
|
|
24
36
|
});
|
|
25
37
|
module.exports = __toCommonJS(graphql_exports);
|
|
26
38
|
|
|
@@ -71,7 +83,104 @@ async function initGraphQLServer({
|
|
|
71
83
|
context
|
|
72
84
|
};
|
|
73
85
|
}
|
|
86
|
+
|
|
87
|
+
// src/graphql/utils.ts
|
|
88
|
+
var import_type_graphql2 = require("type-graphql");
|
|
89
|
+
function query(fn, options) {
|
|
90
|
+
return { ...options, fn };
|
|
91
|
+
}
|
|
92
|
+
function field(fn, options) {
|
|
93
|
+
return { ...options, fn };
|
|
94
|
+
}
|
|
95
|
+
function QueryLibrary(queries) {
|
|
96
|
+
let GeneratedResolver = class {
|
|
97
|
+
};
|
|
98
|
+
GeneratedResolver = __decorateClass([
|
|
99
|
+
(0, import_type_graphql2.Resolver)()
|
|
100
|
+
], GeneratedResolver);
|
|
101
|
+
for (const key in queries) {
|
|
102
|
+
const def = queries[key];
|
|
103
|
+
if (!def) continue;
|
|
104
|
+
Object.defineProperty(GeneratedResolver.prototype, key, {
|
|
105
|
+
// eslint-disable-next-line
|
|
106
|
+
value: async function(ctx, data) {
|
|
107
|
+
return def.fn(ctx, data);
|
|
108
|
+
},
|
|
109
|
+
writable: false
|
|
110
|
+
});
|
|
111
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
112
|
+
GeneratedResolver.prototype,
|
|
113
|
+
key
|
|
114
|
+
);
|
|
115
|
+
if (def.mutation) {
|
|
116
|
+
(0, import_type_graphql2.Mutation)(() => def.output, def.outputOptions)(
|
|
117
|
+
GeneratedResolver.prototype,
|
|
118
|
+
key,
|
|
119
|
+
descriptor
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
(0, import_type_graphql2.Query)(() => def.output, def.outputOptions)(
|
|
123
|
+
GeneratedResolver.prototype,
|
|
124
|
+
key,
|
|
125
|
+
descriptor
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
(0, import_type_graphql2.Ctx)()(GeneratedResolver.prototype, key, 0);
|
|
129
|
+
if (def.input) {
|
|
130
|
+
(0, import_type_graphql2.Arg)("input", () => def.input || String, def.inputOptions)(
|
|
131
|
+
GeneratedResolver.prototype,
|
|
132
|
+
key,
|
|
133
|
+
1
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return GeneratedResolver;
|
|
138
|
+
}
|
|
139
|
+
function FieldLibrary(type, queries) {
|
|
140
|
+
let GeneratedResolver = class {
|
|
141
|
+
};
|
|
142
|
+
GeneratedResolver = __decorateClass([
|
|
143
|
+
(0, import_type_graphql2.Resolver)(() => type)
|
|
144
|
+
], GeneratedResolver);
|
|
145
|
+
for (const key in queries) {
|
|
146
|
+
const def = queries[key];
|
|
147
|
+
if (!def) continue;
|
|
148
|
+
Object.defineProperty(GeneratedResolver.prototype, key, {
|
|
149
|
+
// eslint-disable-next-line
|
|
150
|
+
value: async function(root, ctx, input) {
|
|
151
|
+
return def.fn(root, ctx, input);
|
|
152
|
+
},
|
|
153
|
+
writable: false
|
|
154
|
+
});
|
|
155
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
156
|
+
GeneratedResolver.prototype,
|
|
157
|
+
key
|
|
158
|
+
);
|
|
159
|
+
if (def.authorized) {
|
|
160
|
+
(0, import_type_graphql2.Authorized)()(GeneratedResolver, key);
|
|
161
|
+
}
|
|
162
|
+
(0, import_type_graphql2.Root)()(GeneratedResolver.prototype, key, 0);
|
|
163
|
+
(0, import_type_graphql2.FieldResolver)(() => def.output, def.outputOptions)(
|
|
164
|
+
GeneratedResolver.prototype,
|
|
165
|
+
key,
|
|
166
|
+
descriptor
|
|
167
|
+
);
|
|
168
|
+
(0, import_type_graphql2.Ctx)()(GeneratedResolver.prototype, key, 1);
|
|
169
|
+
if (def.input) {
|
|
170
|
+
(0, import_type_graphql2.Arg)("input", () => def.input || String, def.inputOptions)(
|
|
171
|
+
GeneratedResolver.prototype,
|
|
172
|
+
key,
|
|
173
|
+
2
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return GeneratedResolver;
|
|
178
|
+
}
|
|
74
179
|
// Annotate the CommonJS export names for ESM import in node:
|
|
75
180
|
0 && (module.exports = {
|
|
76
|
-
|
|
181
|
+
FieldLibrary,
|
|
182
|
+
QueryLibrary,
|
|
183
|
+
field,
|
|
184
|
+
initGraphQLServer,
|
|
185
|
+
query
|
|
77
186
|
});
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
1
12
|
// src/graphql/init.ts
|
|
2
13
|
import "reflect-metadata";
|
|
3
14
|
import { ApolloServer } from "@apollo/server";
|
|
@@ -50,6 +61,112 @@ async function initGraphQLServer({
|
|
|
50
61
|
context
|
|
51
62
|
};
|
|
52
63
|
}
|
|
64
|
+
|
|
65
|
+
// src/graphql/utils.ts
|
|
66
|
+
import {
|
|
67
|
+
Arg,
|
|
68
|
+
Authorized,
|
|
69
|
+
Ctx,
|
|
70
|
+
FieldResolver,
|
|
71
|
+
Mutation,
|
|
72
|
+
Query,
|
|
73
|
+
Resolver,
|
|
74
|
+
Root
|
|
75
|
+
} from "type-graphql";
|
|
76
|
+
function query(fn, options) {
|
|
77
|
+
return { ...options, fn };
|
|
78
|
+
}
|
|
79
|
+
function field(fn, options) {
|
|
80
|
+
return { ...options, fn };
|
|
81
|
+
}
|
|
82
|
+
function QueryLibrary(queries) {
|
|
83
|
+
let GeneratedResolver = class {
|
|
84
|
+
};
|
|
85
|
+
GeneratedResolver = __decorateClass([
|
|
86
|
+
Resolver()
|
|
87
|
+
], GeneratedResolver);
|
|
88
|
+
for (const key in queries) {
|
|
89
|
+
const def = queries[key];
|
|
90
|
+
if (!def) continue;
|
|
91
|
+
Object.defineProperty(GeneratedResolver.prototype, key, {
|
|
92
|
+
// eslint-disable-next-line
|
|
93
|
+
value: async function(ctx, data) {
|
|
94
|
+
return def.fn(ctx, data);
|
|
95
|
+
},
|
|
96
|
+
writable: false
|
|
97
|
+
});
|
|
98
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
99
|
+
GeneratedResolver.prototype,
|
|
100
|
+
key
|
|
101
|
+
);
|
|
102
|
+
if (def.mutation) {
|
|
103
|
+
Mutation(() => def.output, def.outputOptions)(
|
|
104
|
+
GeneratedResolver.prototype,
|
|
105
|
+
key,
|
|
106
|
+
descriptor
|
|
107
|
+
);
|
|
108
|
+
} else {
|
|
109
|
+
Query(() => def.output, def.outputOptions)(
|
|
110
|
+
GeneratedResolver.prototype,
|
|
111
|
+
key,
|
|
112
|
+
descriptor
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
Ctx()(GeneratedResolver.prototype, key, 0);
|
|
116
|
+
if (def.input) {
|
|
117
|
+
Arg("input", () => def.input || String, def.inputOptions)(
|
|
118
|
+
GeneratedResolver.prototype,
|
|
119
|
+
key,
|
|
120
|
+
1
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return GeneratedResolver;
|
|
125
|
+
}
|
|
126
|
+
function FieldLibrary(type, queries) {
|
|
127
|
+
let GeneratedResolver = class {
|
|
128
|
+
};
|
|
129
|
+
GeneratedResolver = __decorateClass([
|
|
130
|
+
Resolver(() => type)
|
|
131
|
+
], GeneratedResolver);
|
|
132
|
+
for (const key in queries) {
|
|
133
|
+
const def = queries[key];
|
|
134
|
+
if (!def) continue;
|
|
135
|
+
Object.defineProperty(GeneratedResolver.prototype, key, {
|
|
136
|
+
// eslint-disable-next-line
|
|
137
|
+
value: async function(root, ctx, input) {
|
|
138
|
+
return def.fn(root, ctx, input);
|
|
139
|
+
},
|
|
140
|
+
writable: false
|
|
141
|
+
});
|
|
142
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
143
|
+
GeneratedResolver.prototype,
|
|
144
|
+
key
|
|
145
|
+
);
|
|
146
|
+
if (def.authorized) {
|
|
147
|
+
Authorized()(GeneratedResolver, key);
|
|
148
|
+
}
|
|
149
|
+
Root()(GeneratedResolver.prototype, key, 0);
|
|
150
|
+
FieldResolver(() => def.output, def.outputOptions)(
|
|
151
|
+
GeneratedResolver.prototype,
|
|
152
|
+
key,
|
|
153
|
+
descriptor
|
|
154
|
+
);
|
|
155
|
+
Ctx()(GeneratedResolver.prototype, key, 1);
|
|
156
|
+
if (def.input) {
|
|
157
|
+
Arg("input", () => def.input || String, def.inputOptions)(
|
|
158
|
+
GeneratedResolver.prototype,
|
|
159
|
+
key,
|
|
160
|
+
2
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return GeneratedResolver;
|
|
165
|
+
}
|
|
53
166
|
export {
|
|
54
|
-
|
|
167
|
+
FieldLibrary,
|
|
168
|
+
QueryLibrary,
|
|
169
|
+
field,
|
|
170
|
+
initGraphQLServer,
|
|
171
|
+
query
|
|
55
172
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naystack",
|
|
3
|
-
"version": "1.1.12-beta.
|
|
3
|
+
"version": "1.1.12-beta.5",
|
|
4
4
|
"description": "A stack built with tight Next + Drizzle + GraphQL",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"bcryptjs": "^3.0.2",
|
|
56
56
|
"drizzle-orm": "^0.44.5",
|
|
57
57
|
"jsonwebtoken": "^9.0.2",
|
|
58
|
-
"next": "^15.
|
|
58
|
+
"next": "^15.6.0-canary.29",
|
|
59
59
|
"reflect-metadata": "^0.2.2",
|
|
60
60
|
"type-graphql": "2.0.0-rc.2"
|
|
61
61
|
},
|