hazo_notify 3.0.0 → 3.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/dist/lib/template_manager/handlers/adapters/hazo_auth.d.ts +20 -0
- package/dist/lib/template_manager/handlers/adapters/hazo_auth.d.ts.map +1 -0
- package/dist/lib/template_manager/handlers/adapters/hazo_auth.js +46 -0
- package/dist/lib/template_manager/handlers/adapters/hazo_auth.js.map +1 -0
- package/dist/lib/template_manager/handlers/auth.d.ts +47 -0
- package/dist/lib/template_manager/handlers/auth.d.ts.map +1 -0
- package/dist/lib/template_manager/handlers/auth.js +67 -0
- package/dist/lib/template_manager/handlers/auth.js.map +1 -0
- package/dist/lib/template_manager/handlers/index.d.ts +67 -0
- package/dist/lib/template_manager/handlers/index.d.ts.map +1 -0
- package/dist/lib/template_manager/handlers/index.js +284 -0
- package/dist/lib/template_manager/handlers/index.js.map +1 -0
- package/package.json +9 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience adapter wiring hazo_auth's `hazo_get_tenant_auth` into the
|
|
3
|
+
* template-manager auth wrapper.
|
|
4
|
+
*
|
|
5
|
+
* hazo_auth is dynamic-imported so it stays an OPTIONAL peer dependency of
|
|
6
|
+
* hazo_notify — apps that authenticate differently can implement
|
|
7
|
+
* `TemplateManagerAuthAdapter` themselves without installing hazo_auth.
|
|
8
|
+
*/
|
|
9
|
+
import 'server-only';
|
|
10
|
+
import type { TemplateManagerAuthAdapter } from '../auth.js';
|
|
11
|
+
export interface CreateHazoAuthAdapterOptions {
|
|
12
|
+
scoped_permission?: string;
|
|
13
|
+
global_permission?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the hazo_auth adapter. Throws a clear error if hazo_auth is not
|
|
17
|
+
* installed in the consuming app.
|
|
18
|
+
*/
|
|
19
|
+
export declare function create_hazo_auth_adapter(options?: CreateHazoAuthAdapterOptions): Promise<TemplateManagerAuthAdapter>;
|
|
20
|
+
//# sourceMappingURL=hazo_auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hazo_auth.d.ts","sourceRoot":"","sources":["../../../../../src/lib/template_manager/handlers/adapters/hazo_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAWD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,CAAC,EAAE,4BAA4B,GACrC,OAAO,CAAC,0BAA0B,CAAC,CAiCrC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience adapter wiring hazo_auth's `hazo_get_tenant_auth` into the
|
|
3
|
+
* template-manager auth wrapper.
|
|
4
|
+
*
|
|
5
|
+
* hazo_auth is dynamic-imported so it stays an OPTIONAL peer dependency of
|
|
6
|
+
* hazo_notify — apps that authenticate differently can implement
|
|
7
|
+
* `TemplateManagerAuthAdapter` themselves without installing hazo_auth.
|
|
8
|
+
*/
|
|
9
|
+
import 'server-only';
|
|
10
|
+
// hazo_auth re-exports template_manager types from hazo_notify itself. Resolving
|
|
11
|
+
// the import path statically would make tsc follow that chain back through the
|
|
12
|
+
// workspace symlink to this package's own dist/.d.ts files, triggering TS5055
|
|
13
|
+
// "would overwrite input file" errors on every rebuild after the first. We
|
|
14
|
+
// defeat constant-folding by passing the spec through a variable that's only
|
|
15
|
+
// computed at runtime — tsc treats it as `Promise<any>` and never resolves the
|
|
16
|
+
// types, while Node still imports it normally at the consumer site.
|
|
17
|
+
const HAZO_AUTH_PKG = ['hazo_auth', 'server-lib'].join('/');
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the hazo_auth adapter. Throws a clear error if hazo_auth is not
|
|
20
|
+
* installed in the consuming app.
|
|
21
|
+
*/
|
|
22
|
+
export async function create_hazo_auth_adapter(options) {
|
|
23
|
+
let mod;
|
|
24
|
+
try {
|
|
25
|
+
mod = (await import(HAZO_AUTH_PKG));
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw new Error("hazo_notify/template_manager_handlers/hazo_auth requires the optional peer 'hazo_auth' to be installed. Install it or supply a custom TemplateManagerAuthAdapter.");
|
|
29
|
+
}
|
|
30
|
+
const hazo_get_tenant_auth = mod.hazo_get_tenant_auth;
|
|
31
|
+
return {
|
|
32
|
+
scoped_permission: options?.scoped_permission ?? 'notify_templates_admin',
|
|
33
|
+
global_permission: options?.global_permission ?? 'notify_templates_super_admin',
|
|
34
|
+
resolve: async (request, required_permission) => {
|
|
35
|
+
const r = (await hazo_get_tenant_auth(request, {
|
|
36
|
+
required_permissions: [required_permission],
|
|
37
|
+
}));
|
|
38
|
+
return {
|
|
39
|
+
authenticated: r.authenticated,
|
|
40
|
+
permission_ok: r.permission_ok,
|
|
41
|
+
organization_id: r.organization_id ?? null,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=hazo_auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hazo_auth.js","sourceRoot":"","sources":["../../../../../src/lib/template_manager/handlers/adapters/hazo_auth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,aAAa,CAAC;AASrB,iFAAiF;AACjF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,oEAAoE;AACpE,MAAM,aAAa,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,OAAsC;IAEtC,IAAI,GAAuE,CAAC;IAC5E,IAAI,CAAC;QACH,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,CAEjC,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mKAAmK,CACpK,CAAC;IACJ,CAAC;IAED,MAAM,oBAAoB,GAAG,GAAG,CAAC,oBAAoB,CAAC;IAEtD,OAAO;QACL,iBAAiB,EAAE,OAAO,EAAE,iBAAiB,IAAI,wBAAwB;QACzE,iBAAiB,EACf,OAAO,EAAE,iBAAiB,IAAI,8BAA8B;QAC9D,OAAO,EAAE,KAAK,EAAE,OAAoB,EAAE,mBAA2B,EAAE,EAAE;YACnE,MAAM,CAAC,GAAG,CAAC,MAAM,oBAAoB,CAAC,OAAO,EAAE;gBAC7C,oBAAoB,EAAE,CAAC,mBAAmB,CAAC;aAC5C,CAAC,CAID,CAAC;YACF,OAAO;gBACL,aAAa,EAAE,CAAC,CAAC,aAAa;gBAC9B,aAAa,EAAE,CAAC,CAAC,aAAa;gBAC9B,eAAe,EAAE,CAAC,CAAC,eAAe,IAAI,IAAI;aAC3C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable auth wrapper for the template-manager admin route handlers.
|
|
3
|
+
*
|
|
4
|
+
* The wrapper resolves whether the request is in "global" view (`?view=global`)
|
|
5
|
+
* or scoped (per-tenant), checks the matching permission via the supplied
|
|
6
|
+
* `TemplateManagerAuthAdapter`, and on success calls the wrapped handler with
|
|
7
|
+
* `{ scope_id, is_global }` and any URL params.
|
|
8
|
+
*
|
|
9
|
+
* hazo_notify intentionally has NO direct dependency on hazo_auth — consumers
|
|
10
|
+
* supply an adapter. A convenience adapter for hazo_auth ships at
|
|
11
|
+
* `hazo_notify/template_manager_handlers/hazo_auth` (dynamic-imported, so
|
|
12
|
+
* apps that don't use hazo_auth aren't forced to install it).
|
|
13
|
+
*/
|
|
14
|
+
import 'server-only';
|
|
15
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
16
|
+
export interface TemplateManagerAuth {
|
|
17
|
+
scope_id: string | null;
|
|
18
|
+
is_global: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface TemplateManagerAuthAdapterResult {
|
|
21
|
+
authenticated: boolean;
|
|
22
|
+
permission_ok: boolean;
|
|
23
|
+
organization_id?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface TemplateManagerAuthAdapter {
|
|
26
|
+
/**
|
|
27
|
+
* Resolve auth for the request against the named permission. Mirrors the
|
|
28
|
+
* shape of hazo_auth's `hazo_get_tenant_auth`.
|
|
29
|
+
*/
|
|
30
|
+
resolve: (request: NextRequest, required_permission: string) => Promise<TemplateManagerAuthAdapterResult>;
|
|
31
|
+
/** Permission required for scoped (per-tenant) admin. */
|
|
32
|
+
scoped_permission: string;
|
|
33
|
+
/** Permission required for global (super-admin) admin. */
|
|
34
|
+
global_permission: string;
|
|
35
|
+
}
|
|
36
|
+
export type TemplateManagerHandler<P = Record<string, never>> = (request: NextRequest, auth: TemplateManagerAuth, params: P) => Promise<NextResponse>;
|
|
37
|
+
interface RouteContext<P> {
|
|
38
|
+
params: P | Promise<P>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Build a `with_template_auth` higher-order handler bound to the supplied
|
|
42
|
+
* adapter and CORS headers. The returned function wraps a route handler
|
|
43
|
+
* with auth, scope resolution and consistent error responses.
|
|
44
|
+
*/
|
|
45
|
+
export declare function create_with_template_auth(adapter: TemplateManagerAuthAdapter, cors_headers?: HeadersInit): <P = Record<string, never>>(handler: TemplateManagerHandler<P>) => (request: NextRequest, context?: RouteContext<P>) => Promise<NextResponse>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","s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@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable auth wrapper for the template-manager admin route handlers.
|
|
3
|
+
*
|
|
4
|
+
* The wrapper resolves whether the request is in "global" view (`?view=global`)
|
|
5
|
+
* or scoped (per-tenant), checks the matching permission via the supplied
|
|
6
|
+
* `TemplateManagerAuthAdapter`, and on success calls the wrapped handler with
|
|
7
|
+
* `{ scope_id, is_global }` and any URL params.
|
|
8
|
+
*
|
|
9
|
+
* hazo_notify intentionally has NO direct dependency on hazo_auth — consumers
|
|
10
|
+
* supply an adapter. A convenience adapter for hazo_auth ships at
|
|
11
|
+
* `hazo_notify/template_manager_handlers/hazo_auth` (dynamic-imported, so
|
|
12
|
+
* apps that don't use hazo_auth aren't forced to install it).
|
|
13
|
+
*/
|
|
14
|
+
import 'server-only';
|
|
15
|
+
import { NextResponse } from 'next/server';
|
|
16
|
+
async function resolve_params(context) {
|
|
17
|
+
if (!context)
|
|
18
|
+
return {};
|
|
19
|
+
const p = context.params;
|
|
20
|
+
return (p && typeof p.then === 'function'
|
|
21
|
+
? await p
|
|
22
|
+
: p);
|
|
23
|
+
}
|
|
24
|
+
function is_global_view(request) {
|
|
25
|
+
return new URL(request.url).searchParams.get('view') === 'global';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build a `with_template_auth` higher-order handler bound to the supplied
|
|
29
|
+
* adapter and CORS headers. The returned function wraps a route handler
|
|
30
|
+
* with auth, scope resolution and consistent error responses.
|
|
31
|
+
*/
|
|
32
|
+
export function create_with_template_auth(adapter, cors_headers = {}) {
|
|
33
|
+
const unauth = (status, body) => NextResponse.json(body, { status, headers: cors_headers });
|
|
34
|
+
return function with_template_auth(handler) {
|
|
35
|
+
return async (request, context) => {
|
|
36
|
+
const params = await resolve_params(context);
|
|
37
|
+
const is_global = is_global_view(request);
|
|
38
|
+
const required = is_global
|
|
39
|
+
? adapter.global_permission
|
|
40
|
+
: adapter.scoped_permission;
|
|
41
|
+
const auth_result = await adapter.resolve(request, required);
|
|
42
|
+
if (!auth_result.authenticated) {
|
|
43
|
+
return unauth(401, {
|
|
44
|
+
error: 'Authentication required',
|
|
45
|
+
code: 'UNAUTHENTICATED',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (!auth_result.permission_ok) {
|
|
49
|
+
return unauth(403, {
|
|
50
|
+
error: 'Insufficient permissions',
|
|
51
|
+
code: 'FORBIDDEN',
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const scope_id = is_global
|
|
55
|
+
? null
|
|
56
|
+
: auth_result.organization_id ?? null;
|
|
57
|
+
if (!is_global && !scope_id) {
|
|
58
|
+
return unauth(403, {
|
|
59
|
+
error: 'Organization context required',
|
|
60
|
+
code: 'TENANT_REQUIRED',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return handler(request, { scope_id, is_global }, params);
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/lib/template_manager/handlers/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AAsCxD,KAAK,UAAU,cAAc,CAC3B,OAAoC;IAEpC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAO,CAAC;IAC7B,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IACzB,OAAO,CAAC,CAAC,IAAI,OAAQ,CAAgB,CAAC,IAAI,KAAK,UAAU;QACvD,CAAC,CAAC,MAAM,CAAC;QACT,CAAC,CAAC,CAAC,CAAM,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,OAAoB;IAC1C,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,MA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E;oBACjB,KAAK,EAAE,+BAA+B;oBACtC,IAAI,EAAE,iBAAiB;iBACxB,CAAC,CAAC;YACL,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mountable route-handler factory for the template-manager admin UI.
|
|
3
|
+
*
|
|
4
|
+
* v3.1.0 lifts the test-app's route handlers + auth wrapper into a single
|
|
5
|
+
* factory that consumers wire up with three lines:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // app/api/template_manager/[...path]/route.ts
|
|
9
|
+
* import { create_template_manager_handlers } from 'hazo_notify/template_manager_handlers';
|
|
10
|
+
* import { create_hazo_auth_adapter } from 'hazo_notify/template_manager_handlers/hazo_auth';
|
|
11
|
+
* import { get_db } from '@/lib/db';
|
|
12
|
+
*
|
|
13
|
+
* export const dynamic = 'force-dynamic';
|
|
14
|
+
*
|
|
15
|
+
* const handlers = create_template_manager_handlers({
|
|
16
|
+
* hazo_connect_factory: () => get_db(),
|
|
17
|
+
* auth: await create_hazo_auth_adapter(),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = handlers;
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Routes handled (relative to mount point):
|
|
24
|
+
* GET /categories list categories
|
|
25
|
+
* POST /categories create category
|
|
26
|
+
* GET /categories/:id get category
|
|
27
|
+
* PUT /categories/:id update category (PATCH alias)
|
|
28
|
+
* DELETE /categories/:id delete category
|
|
29
|
+
* GET /templates list templates (?category_id filters)
|
|
30
|
+
* POST /templates create template
|
|
31
|
+
* GET /templates/:id get template
|
|
32
|
+
* PUT /templates/:id update template (PATCH alias)
|
|
33
|
+
* DELETE /templates/:id delete template
|
|
34
|
+
* GET /types list registered template types
|
|
35
|
+
*/
|
|
36
|
+
import 'server-only';
|
|
37
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
38
|
+
import type { HazoConnectInstance } from '../types.js';
|
|
39
|
+
import { type TemplateManagerAuthAdapter } from './auth.js';
|
|
40
|
+
export type { TemplateManagerAuth, TemplateManagerAuthAdapter, TemplateManagerAuthAdapterResult, TemplateManagerHandler, } from './auth.js';
|
|
41
|
+
export { create_with_template_auth } from './auth.js';
|
|
42
|
+
export interface TemplateManagerHandlersOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Returns the hazo_connect instance to use for this request. Called per
|
|
45
|
+
* request so the consumer can short-circuit to a singleton or per-request
|
|
46
|
+
* connection as appropriate.
|
|
47
|
+
*/
|
|
48
|
+
hazo_connect_factory: () => Promise<HazoConnectInstance> | HazoConnectInstance;
|
|
49
|
+
/** Auth adapter (see `create_hazo_auth_adapter` for the hazo_auth default). */
|
|
50
|
+
auth: TemplateManagerAuthAdapter;
|
|
51
|
+
/**
|
|
52
|
+
* CORS headers to attach to every response. Defaults to building from
|
|
53
|
+
* `cors_allowed_origins` in `hazo_notify_config.ini` (wildcard if missing).
|
|
54
|
+
* Pass a function to recompute per request.
|
|
55
|
+
*/
|
|
56
|
+
cors_headers?: HeadersInit | (() => HeadersInit);
|
|
57
|
+
}
|
|
58
|
+
export interface TemplateManagerHandlers {
|
|
59
|
+
GET: (request: NextRequest, ctx?: unknown) => Promise<NextResponse>;
|
|
60
|
+
POST: (request: NextRequest, ctx?: unknown) => Promise<NextResponse>;
|
|
61
|
+
PUT: (request: NextRequest, ctx?: unknown) => Promise<NextResponse>;
|
|
62
|
+
PATCH: (request: NextRequest, ctx?: unknown) => Promise<NextResponse>;
|
|
63
|
+
DELETE: (request: NextRequest, ctx?: unknown) => Promise<NextResponse>;
|
|
64
|
+
OPTIONS: () => Promise<NextResponse>;
|
|
65
|
+
}
|
|
66
|
+
export declare function create_template_manager_handlers(options: TemplateManagerHandlersOptions): TemplateManagerHandlers;
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/template_manager/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkBxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAGL,KAAK,0BAA0B,EAChC,MAAM,WAAW,CAAC;AAEnB,YAAY,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAKtD,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,oBAAoB,EAAE,MAClB,OAAO,CAAC,mBAAmB,CAAC,GAC5B,mBAAmB,CAAC;IACxB,+EAA+E;IAC/E,IAAI,EAAE,0BAA0B,CAAC;IACjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACpE,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACrE,GAAG,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACpE,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACtE,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACvE,OAAO,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CACtC;AAmCD,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,8BAA8B,GACtC,uBAAuB,CAmRzB"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mountable route-handler factory for the template-manager admin UI.
|
|
3
|
+
*
|
|
4
|
+
* v3.1.0 lifts the test-app's route handlers + auth wrapper into a single
|
|
5
|
+
* factory that consumers wire up with three lines:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* // app/api/template_manager/[...path]/route.ts
|
|
9
|
+
* import { create_template_manager_handlers } from 'hazo_notify/template_manager_handlers';
|
|
10
|
+
* import { create_hazo_auth_adapter } from 'hazo_notify/template_manager_handlers/hazo_auth';
|
|
11
|
+
* import { get_db } from '@/lib/db';
|
|
12
|
+
*
|
|
13
|
+
* export const dynamic = 'force-dynamic';
|
|
14
|
+
*
|
|
15
|
+
* const handlers = create_template_manager_handlers({
|
|
16
|
+
* hazo_connect_factory: () => get_db(),
|
|
17
|
+
* auth: await create_hazo_auth_adapter(),
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = handlers;
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Routes handled (relative to mount point):
|
|
24
|
+
* GET /categories list categories
|
|
25
|
+
* POST /categories create category
|
|
26
|
+
* GET /categories/:id get category
|
|
27
|
+
* PUT /categories/:id update category (PATCH alias)
|
|
28
|
+
* DELETE /categories/:id delete category
|
|
29
|
+
* GET /templates list templates (?category_id filters)
|
|
30
|
+
* POST /templates create template
|
|
31
|
+
* GET /templates/:id get template
|
|
32
|
+
* PUT /templates/:id update template (PATCH alias)
|
|
33
|
+
* DELETE /templates/:id delete template
|
|
34
|
+
* GET /types list registered template types
|
|
35
|
+
*/
|
|
36
|
+
import 'server-only';
|
|
37
|
+
import { NextResponse } from 'next/server';
|
|
38
|
+
import { list_categories, get_category, create_category, update_category, delete_category, } from '../db/category_repository.js';
|
|
39
|
+
import { list_templates, list_templates_by_category, get_template, create_template, update_template, delete_template, } from '../db/template_repository.js';
|
|
40
|
+
import { get_registered_template_types } from '../registry.js';
|
|
41
|
+
import { load_template_config } from '../config/config_loader.js';
|
|
42
|
+
import { create_with_template_auth, } from './auth.js';
|
|
43
|
+
export { create_with_template_auth } from './auth.js';
|
|
44
|
+
/** Resources exposed by the dispatcher (first path segment after mount). */
|
|
45
|
+
const KNOWN_RESOURCES = new Set(['categories', 'templates', 'types']);
|
|
46
|
+
function default_cors_headers() {
|
|
47
|
+
let allowed_origins = [];
|
|
48
|
+
try {
|
|
49
|
+
const config = load_template_config();
|
|
50
|
+
allowed_origins = config.cors_allowed_origins ?? [];
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
allowed_origins = [];
|
|
54
|
+
}
|
|
55
|
+
const origin = allowed_origins.length > 0 ? allowed_origins.join(', ') : '*';
|
|
56
|
+
return {
|
|
57
|
+
'Access-Control-Allow-Origin': origin,
|
|
58
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, PATCH, DELETE, OPTIONS',
|
|
59
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function resolve_cors(cors_headers) {
|
|
63
|
+
if (!cors_headers)
|
|
64
|
+
return default_cors_headers();
|
|
65
|
+
if (typeof cors_headers === 'function')
|
|
66
|
+
return cors_headers();
|
|
67
|
+
return cors_headers;
|
|
68
|
+
}
|
|
69
|
+
/** Extract the relative subpath from the URL by locating a known resource. */
|
|
70
|
+
function extract_subpath(pathname) {
|
|
71
|
+
const segments = pathname.split('/').filter(Boolean);
|
|
72
|
+
const idx = segments.findIndex((s) => KNOWN_RESOURCES.has(s));
|
|
73
|
+
if (idx < 0)
|
|
74
|
+
return segments;
|
|
75
|
+
return segments.slice(idx);
|
|
76
|
+
}
|
|
77
|
+
export function create_template_manager_handlers(options) {
|
|
78
|
+
const get_db = async () => await options.hazo_connect_factory();
|
|
79
|
+
const cors = () => resolve_cors(options.cors_headers);
|
|
80
|
+
// Build the per-request auth wrapper. CORS headers are resolved up-front
|
|
81
|
+
// for the wrapper's error responses; success responses re-resolve below
|
|
82
|
+
// so a per-request `cors_headers` function still wins for happy paths.
|
|
83
|
+
const with_template_auth = create_with_template_auth(options.auth, cors());
|
|
84
|
+
const json = (body, status, headers = cors()) => NextResponse.json(body, { status, headers });
|
|
85
|
+
const not_found = () => json({ success: false, error: 'Not found', code: 'NOT_FOUND' }, 404);
|
|
86
|
+
const method_not_allowed = () => json({
|
|
87
|
+
success: false,
|
|
88
|
+
error: 'Method not allowed',
|
|
89
|
+
code: 'METHOD_NOT_ALLOWED',
|
|
90
|
+
}, 405);
|
|
91
|
+
// ---- Internal handlers (each wrapped with auth) ---------------------
|
|
92
|
+
// GET /categories
|
|
93
|
+
const categories_list = with_template_auth(async (_req, { scope_id }) => {
|
|
94
|
+
const db = await get_db();
|
|
95
|
+
const result = await list_categories(db, scope_id);
|
|
96
|
+
return json(result, result.success ? 200 : 500);
|
|
97
|
+
});
|
|
98
|
+
// POST /categories
|
|
99
|
+
const categories_create = with_template_auth(async (req, { scope_id }) => {
|
|
100
|
+
const body = await req.json();
|
|
101
|
+
const { template_category_name } = body;
|
|
102
|
+
if (!template_category_name) {
|
|
103
|
+
return json({
|
|
104
|
+
success: false,
|
|
105
|
+
error: 'template_category_name is required',
|
|
106
|
+
}, 400);
|
|
107
|
+
}
|
|
108
|
+
const db = await get_db();
|
|
109
|
+
const result = await create_category(db, {
|
|
110
|
+
scope_id,
|
|
111
|
+
template_category_name,
|
|
112
|
+
});
|
|
113
|
+
return json(result, result.success ? 201 : 400);
|
|
114
|
+
});
|
|
115
|
+
// GET /categories/:id
|
|
116
|
+
const categories_get = with_template_auth(async (_req, _auth, params) => {
|
|
117
|
+
const db = await get_db();
|
|
118
|
+
const result = await get_category(db, params.id);
|
|
119
|
+
return json(result, result.success ? 200 : 404);
|
|
120
|
+
});
|
|
121
|
+
// PUT/PATCH /categories/:id
|
|
122
|
+
const categories_update = with_template_auth(async (req, _auth, params) => {
|
|
123
|
+
const body = await req.json();
|
|
124
|
+
const db = await get_db();
|
|
125
|
+
const result = await update_category(db, params.id, body);
|
|
126
|
+
const status = result.success
|
|
127
|
+
? 200
|
|
128
|
+
: result.error?.includes('not found')
|
|
129
|
+
? 404
|
|
130
|
+
: 500;
|
|
131
|
+
return json(result, status);
|
|
132
|
+
});
|
|
133
|
+
// DELETE /categories/:id
|
|
134
|
+
const categories_delete = with_template_auth(async (_req, _auth, params) => {
|
|
135
|
+
const db = await get_db();
|
|
136
|
+
const result = await delete_category(db, params.id);
|
|
137
|
+
return json(result, result.success ? 200 : 404);
|
|
138
|
+
});
|
|
139
|
+
// GET /templates
|
|
140
|
+
const templates_list = with_template_auth(async (req, { scope_id }) => {
|
|
141
|
+
const { searchParams } = new URL(req.url);
|
|
142
|
+
const category_id = searchParams.get('category_id');
|
|
143
|
+
const db = await get_db();
|
|
144
|
+
const result = category_id
|
|
145
|
+
? await list_templates_by_category(db, category_id, scope_id)
|
|
146
|
+
: await list_templates(db, scope_id);
|
|
147
|
+
return json(result, result.success ? 200 : 500);
|
|
148
|
+
});
|
|
149
|
+
// POST /templates
|
|
150
|
+
const templates_create = with_template_auth(async (req, { scope_id }) => {
|
|
151
|
+
const body = await req.json();
|
|
152
|
+
const required = [
|
|
153
|
+
'template_category_id',
|
|
154
|
+
'template_name',
|
|
155
|
+
'template_html',
|
|
156
|
+
'template_text',
|
|
157
|
+
];
|
|
158
|
+
const missing = required.filter((f) => body[f] == null);
|
|
159
|
+
if (missing.length > 0) {
|
|
160
|
+
return json({ success: false, error: `Missing: ${missing.join(', ')}` }, 400);
|
|
161
|
+
}
|
|
162
|
+
const db = await get_db();
|
|
163
|
+
const result = await create_template(db, {
|
|
164
|
+
scope_id,
|
|
165
|
+
template_category_id: body.template_category_id,
|
|
166
|
+
template_name: body.template_name,
|
|
167
|
+
template_html: body.template_html,
|
|
168
|
+
template_text: body.template_text,
|
|
169
|
+
template_variables: body.template_variables ?? [],
|
|
170
|
+
});
|
|
171
|
+
return json(result, result.success ? 201 : 400);
|
|
172
|
+
});
|
|
173
|
+
// GET /templates/:id
|
|
174
|
+
const templates_get = with_template_auth(async (_req, _auth, params) => {
|
|
175
|
+
const db = await get_db();
|
|
176
|
+
const result = await get_template(db, params.id);
|
|
177
|
+
return json(result, result.success ? 200 : 404);
|
|
178
|
+
});
|
|
179
|
+
// PUT/PATCH /templates/:id
|
|
180
|
+
const templates_update = with_template_auth(async (req, _auth, params) => {
|
|
181
|
+
const body = await req.json();
|
|
182
|
+
const db = await get_db();
|
|
183
|
+
const result = await update_template(db, params.id, body);
|
|
184
|
+
const status = result.success
|
|
185
|
+
? 200
|
|
186
|
+
: result.error?.includes('not found')
|
|
187
|
+
? 404
|
|
188
|
+
: 500;
|
|
189
|
+
return json(result, status);
|
|
190
|
+
});
|
|
191
|
+
// DELETE /templates/:id
|
|
192
|
+
const templates_delete = with_template_auth(async (_req, _auth, params) => {
|
|
193
|
+
const db = await get_db();
|
|
194
|
+
const result = await delete_template(db, params.id);
|
|
195
|
+
return json(result, result.success ? 200 : 404);
|
|
196
|
+
});
|
|
197
|
+
// GET /types
|
|
198
|
+
const types_list = with_template_auth(async () => {
|
|
199
|
+
const types = get_registered_template_types();
|
|
200
|
+
return json({
|
|
201
|
+
success: true,
|
|
202
|
+
data: types,
|
|
203
|
+
message: `Found ${types.length} template types`,
|
|
204
|
+
}, 200);
|
|
205
|
+
});
|
|
206
|
+
async function dispatch(request, method, raw_ctx) {
|
|
207
|
+
const segments = extract_subpath(request.nextUrl.pathname);
|
|
208
|
+
const [resource, id] = segments;
|
|
209
|
+
if (!resource || !KNOWN_RESOURCES.has(resource))
|
|
210
|
+
return not_found();
|
|
211
|
+
// Synthesise a Next-style RouteContext so wrapped handlers receive `id`
|
|
212
|
+
// even when consumer mounts under a catch-all `[...path]/route.ts`. If
|
|
213
|
+
// the caller already passed a `params` context (e.g. from a
|
|
214
|
+
// resource-specific `[id]/route.ts` file), prefer that.
|
|
215
|
+
const ctx_params = raw_ctx?.params ??
|
|
216
|
+
(id ? { id } : {});
|
|
217
|
+
// The wrappers each have their own `RouteContext<P>` generic; cast at the
|
|
218
|
+
// call site so the dispatcher can route through them uniformly. Wrappers
|
|
219
|
+
// re-resolve params safely at runtime.
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
221
|
+
const ctx = { params: ctx_params };
|
|
222
|
+
if (resource === 'categories') {
|
|
223
|
+
if (id) {
|
|
224
|
+
switch (method) {
|
|
225
|
+
case 'GET':
|
|
226
|
+
return categories_get(request, ctx);
|
|
227
|
+
case 'PUT':
|
|
228
|
+
case 'PATCH':
|
|
229
|
+
return categories_update(request, ctx);
|
|
230
|
+
case 'DELETE':
|
|
231
|
+
return categories_delete(request, ctx);
|
|
232
|
+
default:
|
|
233
|
+
return method_not_allowed();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
switch (method) {
|
|
237
|
+
case 'GET':
|
|
238
|
+
return categories_list(request, ctx);
|
|
239
|
+
case 'POST':
|
|
240
|
+
return categories_create(request, ctx);
|
|
241
|
+
default:
|
|
242
|
+
return method_not_allowed();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (resource === 'templates') {
|
|
246
|
+
if (id) {
|
|
247
|
+
switch (method) {
|
|
248
|
+
case 'GET':
|
|
249
|
+
return templates_get(request, ctx);
|
|
250
|
+
case 'PUT':
|
|
251
|
+
case 'PATCH':
|
|
252
|
+
return templates_update(request, ctx);
|
|
253
|
+
case 'DELETE':
|
|
254
|
+
return templates_delete(request, ctx);
|
|
255
|
+
default:
|
|
256
|
+
return method_not_allowed();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
switch (method) {
|
|
260
|
+
case 'GET':
|
|
261
|
+
return templates_list(request, ctx);
|
|
262
|
+
case 'POST':
|
|
263
|
+
return templates_create(request, ctx);
|
|
264
|
+
default:
|
|
265
|
+
return method_not_allowed();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (resource === 'types') {
|
|
269
|
+
if (id || method !== 'GET')
|
|
270
|
+
return method_not_allowed();
|
|
271
|
+
return types_list(request, ctx);
|
|
272
|
+
}
|
|
273
|
+
return not_found();
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
GET: (req, ctx) => dispatch(req, 'GET', ctx),
|
|
277
|
+
POST: (req, ctx) => dispatch(req, 'POST', ctx),
|
|
278
|
+
PUT: (req, ctx) => dispatch(req, 'PUT', ctx),
|
|
279
|
+
PATCH: (req, ctx) => dispatch(req, 'PATCH', ctx),
|
|
280
|
+
DELETE: (req, ctx) => dispatch(req, 'DELETE', ctx),
|
|
281
|
+
OPTIONS: async () => new NextResponse(null, { status: 204, headers: cors() }),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/template_manager/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,8BAA8B,CAA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CAAC;gBACxC;oBACE,OAAO,kBAAkB,EAAE,CAAC;YAChC,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACzB,IAAI,EAAE,IAAI,MAAM,KAAK,KAAK;gBAAE,OAAO,kBAAkB,EAAE,CAAC;YACxD,OAAO,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QAED,OAAO,SAAS,EAAE,CAAC;IACrB,CAAC;IAED,OAAO;QACL,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC;QAC5C,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC;QAC9C,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC;QAC5C,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC;QAChD,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC;QAClD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;KAC9E,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hazo_notify",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Email notification system with scope-aware template management",
|
|
6
6
|
"main": "./dist/lib/index.js",
|
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
"./template_manager_admin": {
|
|
22
22
|
"types": "./dist/components/template_manager/index.d.ts",
|
|
23
23
|
"default": "./dist/components/template_manager/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./template_manager_handlers": {
|
|
26
|
+
"types": "./dist/lib/template_manager/handlers/index.d.ts",
|
|
27
|
+
"default": "./dist/lib/template_manager/handlers/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./template_manager_handlers/hazo_auth": {
|
|
30
|
+
"types": "./dist/lib/template_manager/handlers/adapters/hazo_auth.d.ts",
|
|
31
|
+
"default": "./dist/lib/template_manager/handlers/adapters/hazo_auth.js"
|
|
24
32
|
}
|
|
25
33
|
},
|
|
26
34
|
"scripts": {
|