@voyantjs/next 0.1.0
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/LICENSE +109 -0
- package/README.md +42 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/responses.d.ts +9 -0
- package/dist/responses.d.ts.map +1 -0
- package/dist/responses.js +28 -0
- package/dist/responses.js.map +1 -0
- package/dist/route.d.ts +8 -0
- package/dist/route.d.ts.map +1 -0
- package/dist/route.js +83 -0
- package/dist/route.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, Apache 2.0 Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 PixelMakers Studio SRL
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly
|
|
28
|
+
display and redistribute the Software for any Permitted Purpose identified
|
|
29
|
+
below.
|
|
30
|
+
|
|
31
|
+
### Permitted Purpose
|
|
32
|
+
|
|
33
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing
|
|
34
|
+
Use means making the Software available to others in a commercial product or
|
|
35
|
+
service that:
|
|
36
|
+
|
|
37
|
+
1. substitutes for the Software;
|
|
38
|
+
|
|
39
|
+
2. substitutes for any other product or service we offer using the Software
|
|
40
|
+
that exists as of the date we make the Software available; or
|
|
41
|
+
|
|
42
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
43
|
+
|
|
44
|
+
Permitted Purposes specifically include using the Software:
|
|
45
|
+
|
|
46
|
+
1. for your internal use and access;
|
|
47
|
+
|
|
48
|
+
2. for non-commercial education;
|
|
49
|
+
|
|
50
|
+
3. for non-commercial research; and
|
|
51
|
+
|
|
52
|
+
4. in connection with professional services that you provide to a licensee
|
|
53
|
+
using the Software in accordance with these Terms and Conditions.
|
|
54
|
+
|
|
55
|
+
### Patents
|
|
56
|
+
|
|
57
|
+
To the extent your use for a Permitted Purpose would necessarily infringe
|
|
58
|
+
our patents, the license grant above includes a license under our patents.
|
|
59
|
+
If you make a claim against any party that the Software infringes or
|
|
60
|
+
contributes to the infringement of any patent, then your patent license to
|
|
61
|
+
the Software ends immediately.
|
|
62
|
+
|
|
63
|
+
### Redistribution
|
|
64
|
+
|
|
65
|
+
The Terms and Conditions apply to all copies, modifications and derivatives
|
|
66
|
+
of the Software.
|
|
67
|
+
|
|
68
|
+
If you redistribute any copies, modifications or derivatives of the
|
|
69
|
+
Software, you must include a copy of or a link to these Terms and Conditions
|
|
70
|
+
and not remove any copyright notices provided in or with the Software.
|
|
71
|
+
|
|
72
|
+
### Disclaimer
|
|
73
|
+
|
|
74
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS
|
|
75
|
+
OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A
|
|
76
|
+
PARTICULAR PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
77
|
+
|
|
78
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO
|
|
79
|
+
THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
|
|
80
|
+
DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
81
|
+
|
|
82
|
+
### Trademarks
|
|
83
|
+
|
|
84
|
+
Except for displaying the License Details and identifying us as the origin
|
|
85
|
+
of the Software, you have no right under these Terms and Conditions to use
|
|
86
|
+
our trademarks, trade names, service marks or product names.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Grant of Future License
|
|
91
|
+
|
|
92
|
+
We hereby irrevocably grant you an additional license to use the Software
|
|
93
|
+
under the Apache License, Version 2.0 that is effective on the second
|
|
94
|
+
anniversary of the date we make the Software available. On or after that
|
|
95
|
+
date, you may use the Software under the Apache License, Version 2.0, in
|
|
96
|
+
which case the following will apply:
|
|
97
|
+
|
|
98
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
99
|
+
use this file except in compliance with the License.
|
|
100
|
+
|
|
101
|
+
You may obtain a copy of the License at
|
|
102
|
+
|
|
103
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
104
|
+
|
|
105
|
+
Unless required by applicable law or agreed to in writing, software
|
|
106
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
107
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
108
|
+
License for the specific language governing permissions and limitations
|
|
109
|
+
under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @voyantjs/next
|
|
2
|
+
|
|
3
|
+
Next.js route adapter helpers for Voyant. Mount Voyant modules in-process from Next.js route handlers — an alternative to running Voyant as a separate Hono server.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @voyantjs/next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// app/api/v1/[...voyant]/route.ts
|
|
15
|
+
import { createVoyantRoute } from "@voyantjs/next/route"
|
|
16
|
+
import { crmModule, productsModule } from "..."
|
|
17
|
+
|
|
18
|
+
const handler = createVoyantRoute({
|
|
19
|
+
modules: [crmModule, productsModule],
|
|
20
|
+
db: () => getDb(),
|
|
21
|
+
auth: { handler, resolve },
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export const GET = handler
|
|
25
|
+
export const POST = handler
|
|
26
|
+
export const PUT = handler
|
|
27
|
+
export const PATCH = handler
|
|
28
|
+
export const DELETE = handler
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Exports
|
|
32
|
+
|
|
33
|
+
| Entry | Description |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| `.` | Barrel re-exports |
|
|
36
|
+
| `./route` | `createVoyantRoute` route-handler factory |
|
|
37
|
+
| `./responses` | JSON response helpers |
|
|
38
|
+
| `./types` | Route handler types |
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
FSL-1.1-Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { badRequest, created, forbidden, json, noContent, notFound, serverError, unauthorized, } from "./responses.js";
|
|
2
|
+
export { createVoyantNextRoute } from "./route.js";
|
|
3
|
+
export type { VoyantDb, VoyantNextAuthIntegration, VoyantNextAuthPermissionArgs, VoyantNextAuthResolveArgs, VoyantNextConfig, VoyantNextHandler, VoyantNextParams, VoyantNextRequestAuthContext, VoyantNextRouteContext, VoyantNextRouteHandler, VoyantNextRouteInput, } from "./types.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,YAAY,EACV,QAAQ,EACR,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function json(data: unknown, init?: ResponseInit): Response;
|
|
2
|
+
export declare function created(data: unknown, init?: ResponseInit): Response;
|
|
3
|
+
export declare function noContent(init?: ResponseInit): Response;
|
|
4
|
+
export declare function badRequest(body?: unknown, init?: ResponseInit): Response;
|
|
5
|
+
export declare function unauthorized(body?: unknown, init?: ResponseInit): Response;
|
|
6
|
+
export declare function forbidden(body?: unknown, init?: ResponseInit): Response;
|
|
7
|
+
export declare function notFound(body?: unknown, init?: ResponseInit): Response;
|
|
8
|
+
export declare function serverError(body?: unknown, init?: ResponseInit): Response;
|
|
9
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../src/responses.ts"],"names":[],"mappings":"AAIA,wBAAgB,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAEjE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAEpE;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAEvD;AAED,wBAAgB,UAAU,CACxB,IAAI,GAAE,OAAkC,EACxC,IAAI,CAAC,EAAE,YAAY,GAClB,QAAQ,CAEV;AAED,wBAAgB,YAAY,CAC1B,IAAI,GAAE,OAAmC,EACzC,IAAI,CAAC,EAAE,YAAY,GAClB,QAAQ,CAEV;AAED,wBAAgB,SAAS,CAAC,IAAI,GAAE,OAAgC,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAE/F;AAED,wBAAgB,QAAQ,CAAC,IAAI,GAAE,OAAgC,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAE9F;AAED,wBAAgB,WAAW,CACzB,IAAI,GAAE,OAA4C,EAClD,IAAI,CAAC,EAAE,YAAY,GAClB,QAAQ,CAEV"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function withStatus(status, init) {
|
|
2
|
+
return { ...init, status };
|
|
3
|
+
}
|
|
4
|
+
export function json(data, init) {
|
|
5
|
+
return Response.json(data, init);
|
|
6
|
+
}
|
|
7
|
+
export function created(data, init) {
|
|
8
|
+
return Response.json(data, withStatus(201, init));
|
|
9
|
+
}
|
|
10
|
+
export function noContent(init) {
|
|
11
|
+
return new Response(null, withStatus(204, init));
|
|
12
|
+
}
|
|
13
|
+
export function badRequest(body = { error: "Bad Request" }, init) {
|
|
14
|
+
return Response.json(body, withStatus(400, init));
|
|
15
|
+
}
|
|
16
|
+
export function unauthorized(body = { error: "Unauthorized" }, init) {
|
|
17
|
+
return Response.json(body, withStatus(401, init));
|
|
18
|
+
}
|
|
19
|
+
export function forbidden(body = { error: "Forbidden" }, init) {
|
|
20
|
+
return Response.json(body, withStatus(403, init));
|
|
21
|
+
}
|
|
22
|
+
export function notFound(body = { error: "Not Found" }, init) {
|
|
23
|
+
return Response.json(body, withStatus(404, init));
|
|
24
|
+
}
|
|
25
|
+
export function serverError(body = { error: "Internal Server Error" }, init) {
|
|
26
|
+
return Response.json(body, withStatus(500, init));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=responses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../src/responses.ts"],"names":[],"mappings":"AAAA,SAAS,UAAU,CAAC,MAAc,EAAE,IAAmB;IACrD,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5B,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,IAAa,EAAE,IAAmB;IACrD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAa,EAAE,IAAmB;IACxD,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAmB;IAC3C,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,OAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,EACxC,IAAmB;IAEnB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,OAAgB,EAAE,KAAK,EAAE,cAAc,EAAE,EACzC,IAAmB;IAEnB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,IAAmB;IACnF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,IAAmB;IAClF,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,OAAgB,EAAE,KAAK,EAAE,uBAAuB,EAAE,EAClD,IAAmB;IAEnB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,CAAC"}
|
package/dist/route.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VoyantPermission } from "@voyantjs/core";
|
|
2
|
+
import type { VoyantNextConfig, VoyantNextHandler, VoyantNextParams, VoyantNextRouteHandler } from "./types.js";
|
|
3
|
+
export declare function createVoyantNextRoute<TParams extends VoyantNextParams>(config: VoyantNextConfig<TParams>): {
|
|
4
|
+
public(handler: VoyantNextHandler<TParams>): VoyantNextRouteHandler<TParams>;
|
|
5
|
+
protected(handler: VoyantNextHandler<TParams>): VoyantNextRouteHandler<TParams>;
|
|
6
|
+
withPermission(permission: VoyantPermission, handler: VoyantNextHandler<TParams>): VoyantNextRouteHandler<TParams>;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../src/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGtD,OAAO,KAAK,EAEV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAEhB,sBAAsB,EAEvB,MAAM,YAAY,CAAA;AA6GnB,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,gBAAgB,EACpE,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC;oBAGf,iBAAiB,CAAC,OAAO,CAAC,GAAG,sBAAsB,CAAC,OAAO,CAAC;uBAIzD,iBAAiB,CAAC,OAAO,CAAC,GAAG,sBAAsB,CAAC,OAAO,CAAC;+BAKjE,gBAAgB,WACnB,iBAAiB,CAAC,OAAO,CAAC,GAClC,sBAAsB,CAAC,OAAO,CAAC;EAOrC"}
|
package/dist/route.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { forbidden, serverError, unauthorized } from "./responses.js";
|
|
2
|
+
function hasScope(scopes, permission) {
|
|
3
|
+
if (!scopes || scopes.length === 0)
|
|
4
|
+
return false;
|
|
5
|
+
const { resource, action } = permission;
|
|
6
|
+
return (scopes.includes("*") ||
|
|
7
|
+
scopes.includes(`${resource}:${action}`) ||
|
|
8
|
+
scopes.includes(`${resource}:*`) ||
|
|
9
|
+
scopes.includes(`*:${action}`));
|
|
10
|
+
}
|
|
11
|
+
async function resolveParams(input) {
|
|
12
|
+
return ((await input?.params) ?? {});
|
|
13
|
+
}
|
|
14
|
+
async function resolveDb(config, request, params) {
|
|
15
|
+
return typeof config.db === "function" ? await config.db({ request, params }) : config.db;
|
|
16
|
+
}
|
|
17
|
+
async function resolveAuth(config, request, db, params) {
|
|
18
|
+
if (!config.auth?.resolve) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (await config.auth.resolve({ request, db, params })) ?? null;
|
|
22
|
+
}
|
|
23
|
+
async function verifyPermission(config, request, db, params, auth, permission) {
|
|
24
|
+
if (auth?.isInternalRequest) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (hasScope(auth?.scopes, permission)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (!auth?.userId) {
|
|
31
|
+
return unauthorized();
|
|
32
|
+
}
|
|
33
|
+
if (!config.auth?.hasPermission) {
|
|
34
|
+
return serverError({ error: "No auth permission checker configured" });
|
|
35
|
+
}
|
|
36
|
+
const allowed = await config.auth.hasPermission({
|
|
37
|
+
request,
|
|
38
|
+
db,
|
|
39
|
+
params,
|
|
40
|
+
auth,
|
|
41
|
+
permission,
|
|
42
|
+
});
|
|
43
|
+
return allowed ? null : forbidden();
|
|
44
|
+
}
|
|
45
|
+
function buildRoute(config, handler, options) {
|
|
46
|
+
return async (request, input) => {
|
|
47
|
+
const params = await resolveParams(input);
|
|
48
|
+
const db = await resolveDb(config, request, params);
|
|
49
|
+
const auth = await resolveAuth(config, request, db, params);
|
|
50
|
+
if (options?.requireAuth && !auth?.userId && !auth?.isInternalRequest) {
|
|
51
|
+
return unauthorized();
|
|
52
|
+
}
|
|
53
|
+
if (options?.permission) {
|
|
54
|
+
const denied = await verifyPermission(config, request, db, params, auth, options.permission);
|
|
55
|
+
if (denied) {
|
|
56
|
+
return denied;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return handler({
|
|
60
|
+
request,
|
|
61
|
+
params,
|
|
62
|
+
db,
|
|
63
|
+
auth,
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function createVoyantNextRoute(config) {
|
|
68
|
+
return {
|
|
69
|
+
public(handler) {
|
|
70
|
+
return buildRoute(config, handler);
|
|
71
|
+
},
|
|
72
|
+
protected(handler) {
|
|
73
|
+
return buildRoute(config, handler, { requireAuth: true });
|
|
74
|
+
},
|
|
75
|
+
withPermission(permission, handler) {
|
|
76
|
+
return buildRoute(config, handler, {
|
|
77
|
+
requireAuth: true,
|
|
78
|
+
permission,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=route.js.map
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MAAM,IAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE,CAAC;YACtE,OAAO,YAAY,EAAE,CAAA;QACvB,CAAC;QAED,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;YAC5F,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,MAAM,CAAA;YACf,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;YACb,OAAO;YACP,MAAM;YACN,EAAE;YACF,IAAI;SACL,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,MAAiC;IAEjC,OAAO;QACL,MAAM,CAAC,OAAmC;YACxC,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACpC,CAAC;QAED,SAAS,CAAC,OAAmC;YAC3C,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QAC3D,CAAC;QAED,cAAc,CACZ,UAA4B,EAC5B,OAAmC;YAEnC,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE;gBACjC,WAAW,EAAE,IAAI;gBACjB,UAAU;aACX,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { VoyantAuthContext, VoyantPermission } from "@voyantjs/core";
|
|
2
|
+
import type { NeonHttpDatabase } from "drizzle-orm/neon-http";
|
|
3
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
4
|
+
export type VoyantDb = PostgresJsDatabase | NeonHttpDatabase;
|
|
5
|
+
export type VoyantNextParams = Record<string, string | string[] | undefined>;
|
|
6
|
+
export interface VoyantNextRouteInput<TParams extends VoyantNextParams = VoyantNextParams> {
|
|
7
|
+
params?: TParams | Promise<TParams>;
|
|
8
|
+
}
|
|
9
|
+
export type VoyantNextRequestAuthContext = VoyantAuthContext & {
|
|
10
|
+
userId: string;
|
|
11
|
+
};
|
|
12
|
+
export type VoyantNextDbFactory<TParams extends VoyantNextParams = VoyantNextParams> = VoyantDb | ((args: {
|
|
13
|
+
request: Request;
|
|
14
|
+
params: TParams;
|
|
15
|
+
}) => VoyantDb | Promise<VoyantDb>);
|
|
16
|
+
export interface VoyantNextAuthResolveArgs<TParams extends VoyantNextParams = VoyantNextParams> {
|
|
17
|
+
request: Request;
|
|
18
|
+
db: VoyantDb;
|
|
19
|
+
params: TParams;
|
|
20
|
+
}
|
|
21
|
+
export interface VoyantNextAuthPermissionArgs<TParams extends VoyantNextParams = VoyantNextParams> extends VoyantNextAuthResolveArgs<TParams> {
|
|
22
|
+
permission: VoyantPermission;
|
|
23
|
+
auth: VoyantNextRequestAuthContext;
|
|
24
|
+
}
|
|
25
|
+
export interface VoyantNextAuthIntegration<TParams extends VoyantNextParams = VoyantNextParams> {
|
|
26
|
+
resolve?: (args: VoyantNextAuthResolveArgs<TParams>) => Promise<VoyantNextRequestAuthContext | null> | VoyantNextRequestAuthContext | null;
|
|
27
|
+
hasPermission?: (args: VoyantNextAuthPermissionArgs<TParams>) => Promise<boolean> | boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface VoyantNextConfig<TParams extends VoyantNextParams = VoyantNextParams> {
|
|
30
|
+
db: VoyantNextDbFactory<TParams>;
|
|
31
|
+
auth?: VoyantNextAuthIntegration<TParams>;
|
|
32
|
+
}
|
|
33
|
+
export interface VoyantNextRouteContext<TParams extends VoyantNextParams = VoyantNextParams> {
|
|
34
|
+
request: Request;
|
|
35
|
+
params: TParams;
|
|
36
|
+
db: VoyantDb;
|
|
37
|
+
auth: VoyantNextRequestAuthContext | null;
|
|
38
|
+
}
|
|
39
|
+
export type VoyantNextHandler<TParams extends VoyantNextParams = VoyantNextParams> = (ctx: VoyantNextRouteContext<TParams>) => Response | Promise<Response>;
|
|
40
|
+
export type VoyantNextRouteHandler<TParams extends VoyantNextParams = VoyantNextParams> = (request: Request, context: VoyantNextRouteInput<TParams>) => Response | Promise<Response>;
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,MAAM,MAAM,QAAQ,GAAG,kBAAkB,GAAG,gBAAgB,CAAA;AAE5D,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAA;AAE5E,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,gBAAgB,GAAG,gBAAgB;IACvF,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACpC;AAED,MAAM,MAAM,4BAA4B,GAAG,iBAAiB,GAAG;IAC7D,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,IAC/E,QAAQ,GACR,CAAC,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEnF,MAAM,WAAW,yBAAyB,CAAC,OAAO,SAAS,gBAAgB,GAAG,gBAAgB;IAC5F,OAAO,EAAE,OAAO,CAAA;IAChB,EAAE,EAAE,QAAQ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,oBAAoB,CAAC,OAAO,CAAC,KACnC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./route": {
|
|
12
|
+
"types": "./dist/route.d.ts",
|
|
13
|
+
"import": "./dist/route.js"
|
|
14
|
+
},
|
|
15
|
+
"./responses": {
|
|
16
|
+
"types": "./dist/responses.d.ts",
|
|
17
|
+
"import": "./dist/responses.js"
|
|
18
|
+
},
|
|
19
|
+
"./types": {
|
|
20
|
+
"types": "./dist/types.d.ts",
|
|
21
|
+
"import": "./dist/types.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"drizzle-orm": "^0.45.2",
|
|
26
|
+
"@voyantjs/core": "0.1.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^6.0.2",
|
|
30
|
+
"@voyantjs/voyant-typescript-config": "0.1.0"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.build.json",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"lint": "biome check src/",
|
|
42
|
+
"clean": "rm -rf dist"
|
|
43
|
+
},
|
|
44
|
+
"main": "./dist/index.js",
|
|
45
|
+
"types": "./dist/index.d.ts"
|
|
46
|
+
}
|