@lpdjs/firestore-repo-service 2.2.9-beta.2 → 2.2.9-beta.3
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/{create-servers-xx0m3wwM.d.ts → create-servers-Dbmq3aN0.d.ts} +3 -3
- package/dist/{create-servers-CfLtucbQ.d.cts → create-servers-XKBCK7vV.d.cts} +3 -3
- package/dist/firebase-auth-CBqtAeb5.d.cts +309 -0
- package/dist/firebase-auth-CBqtAeb5.d.ts +309 -0
- package/dist/{index-Njwf8jvu.d.ts → index-BTrgC2ZA.d.cts} +7 -119
- package/dist/{index-BvKyjs6k.d.cts → index-CP4WoShV.d.ts} +7 -119
- package/dist/index.cjs +96 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +96 -96
- package/dist/index.js.map +1 -1
- package/dist/{openapi-BHZ2XHgn.d.ts → openapi-BSdeinkq.d.ts} +1 -1
- package/dist/{openapi-DXUE_MEP.d.cts → openapi-BSp3x2yW.d.cts} +1 -1
- package/dist/servers/admin/index.cjs +46 -46
- package/dist/servers/admin/index.cjs.map +1 -1
- package/dist/servers/admin/index.d.cts +3 -2
- package/dist/servers/admin/index.d.ts +3 -2
- package/dist/servers/admin/index.js +46 -46
- package/dist/servers/admin/index.js.map +1 -1
- package/dist/servers/auth/index.cjs +194 -0
- package/dist/servers/auth/index.cjs.map +1 -0
- package/dist/servers/auth/index.d.cts +13 -0
- package/dist/servers/auth/index.d.ts +13 -0
- package/dist/servers/auth/index.js +194 -0
- package/dist/servers/auth/index.js.map +1 -0
- package/dist/servers/crud/index.cjs +2 -2
- package/dist/servers/crud/index.cjs.map +1 -1
- package/dist/servers/crud/index.d.cts +5 -4
- package/dist/servers/crud/index.d.ts +5 -4
- package/dist/servers/crud/index.js +2 -2
- package/dist/servers/crud/index.js.map +1 -1
- package/dist/servers/index.cjs +111 -111
- package/dist/servers/index.cjs.map +1 -1
- package/dist/servers/index.d.cts +6 -5
- package/dist/servers/index.d.ts +6 -5
- package/dist/servers/index.js +111 -111
- package/dist/servers/index.js.map +1 -1
- package/dist/{types-C822D0dX.d.ts → types-CqXbEeXp.d.ts} +93 -6
- package/dist/{types-Z1Zy-2hs.d.cts → types-DptSRAK6.d.cts} +93 -6
- package/package.json +14 -1
|
@@ -1,121 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { HttpsOptions } from 'firebase-functions/v2/https';
|
|
3
|
-
import { C as ConfiguredRepository, R as RepositoryConfig, F as FieldPath, n as FieldRole } from './types-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Minimal zero-dependency HTTP router for Firebase Functions.
|
|
7
|
-
* Compatible with any Express-like (req, res) handler.
|
|
8
|
-
*
|
|
9
|
-
* Supports:
|
|
10
|
-
* - Named path parameters (e.g. "/repos/:name/:id")
|
|
11
|
-
* - GET, POST, DELETE methods
|
|
12
|
-
* - Global middleware (before each route)
|
|
13
|
-
* - 404 / error fallbacks
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { MiniRouter } from "@lpdjs/firestore-repo-service/servers/admin";
|
|
18
|
-
*
|
|
19
|
-
* // Create router
|
|
20
|
-
* const router = new MiniRouter();
|
|
21
|
-
*
|
|
22
|
-
* // Add global middleware (executed before every route)
|
|
23
|
-
* router.use(async (req, res, next) => {
|
|
24
|
-
* console.log(`${req.method} ${req.url}`);
|
|
25
|
-
* await next();
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // Auth middleware
|
|
29
|
-
* router.use((req, res, next) => {
|
|
30
|
-
* if (!req.headers?.authorization) {
|
|
31
|
-
* res.status(401).send("Unauthorized");
|
|
32
|
-
* return;
|
|
33
|
-
* }
|
|
34
|
-
* next();
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // Define routes with path parameters
|
|
38
|
-
* router.get("/users", async (req, res) => {
|
|
39
|
-
* res.json({ users: await getAllUsers() });
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* router.get("/users/:id", async (req, res) => {
|
|
43
|
-
* const user = await getUser(req.params.id); // Access path params
|
|
44
|
-
* if (!user) {
|
|
45
|
-
* res.status(404).send("User not found");
|
|
46
|
-
* return;
|
|
47
|
-
* }
|
|
48
|
-
* res.json(user);
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* router.post("/users", async (req, res) => {
|
|
52
|
-
* const user = await createUser(req.body);
|
|
53
|
-
* res.status(201).json(user);
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* router.delete("/users/:id", async (req, res) => {
|
|
57
|
-
* await deleteUser(req.params.id);
|
|
58
|
-
* res.status(204).end();
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* // Custom 404 handler
|
|
62
|
-
* router.onNotFound((req, res) => {
|
|
63
|
-
* res.status(404).json({ error: "Route not found", path: req.url });
|
|
64
|
-
* });
|
|
65
|
-
*
|
|
66
|
-
* // Custom error handler
|
|
67
|
-
* router.onError((err, req, res) => {
|
|
68
|
-
* console.error("Error:", err);
|
|
69
|
-
* res.status(500).json({ error: "Internal server error" });
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* // Use with Firebase Functions
|
|
73
|
-
* export const api = onRequest(async (req, res) => {
|
|
74
|
-
* await router.handle(req, res);
|
|
75
|
-
* });
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
type AnyReq = {
|
|
79
|
-
method?: string;
|
|
80
|
-
url?: string;
|
|
81
|
-
/** Express originalUrl — preserved before any router stripping, contains the full path including the Firebase Functions prefix */
|
|
82
|
-
originalUrl?: string;
|
|
83
|
-
path?: string;
|
|
84
|
-
headers?: Record<string, string | string[] | undefined>;
|
|
85
|
-
body?: unknown;
|
|
86
|
-
query?: Record<string, string | string[] | undefined>;
|
|
87
|
-
};
|
|
88
|
-
type AnyRes = {
|
|
89
|
-
status: (code: number) => AnyRes;
|
|
90
|
-
set: (key: string, value: string) => AnyRes;
|
|
91
|
-
send: (body: string) => void;
|
|
92
|
-
json: (body: unknown) => void;
|
|
93
|
-
end: () => void;
|
|
94
|
-
};
|
|
95
|
-
type RouteParams = Record<string, string>;
|
|
96
|
-
type RouteHandler = (req: AnyReq & {
|
|
97
|
-
params: RouteParams;
|
|
98
|
-
}, res: AnyRes) => void | Promise<void>;
|
|
99
|
-
type Middleware = (req: AnyReq & {
|
|
100
|
-
params: RouteParams;
|
|
101
|
-
}, res: AnyRes, next: () => void | Promise<void>) => void | Promise<void>;
|
|
102
|
-
declare class MiniRouter {
|
|
103
|
-
private routes;
|
|
104
|
-
private middlewares;
|
|
105
|
-
private notFoundHandler;
|
|
106
|
-
private errorHandler;
|
|
107
|
-
use(middleware: Middleware): this;
|
|
108
|
-
get(path: string, handler: RouteHandler): this;
|
|
109
|
-
post(path: string, handler: RouteHandler): this;
|
|
110
|
-
put(path: string, handler: RouteHandler): this;
|
|
111
|
-
patch(path: string, handler: RouteHandler): this;
|
|
112
|
-
delete(path: string, handler: RouteHandler): this;
|
|
113
|
-
onNotFound(handler: RouteHandler): this;
|
|
114
|
-
onError(handler: (err: unknown, req: AnyReq, res: AnyRes) => void): this;
|
|
115
|
-
private addRoute;
|
|
116
|
-
handle(req: AnyReq, res: AnyRes): Promise<void>;
|
|
117
|
-
private runMiddlewareChain;
|
|
118
|
-
}
|
|
3
|
+
import { C as ConfiguredRepository, R as RepositoryConfig, F as FieldPath, n as FieldRole } from './types-DptSRAK6.cjs';
|
|
4
|
+
import { A as AuthExtension, a as Middleware } from './firebase-auth-CBqtAeb5.cjs';
|
|
119
5
|
|
|
120
6
|
interface PageOptions {
|
|
121
7
|
title: string;
|
|
@@ -434,10 +320,12 @@ interface AdminServerOptions<TRepos extends Record<string, ConfiguredRepository<
|
|
|
434
320
|
parseBody?: boolean;
|
|
435
321
|
/**
|
|
436
322
|
* Authentication guard executed before every request.
|
|
323
|
+
* - Pass an {@link AuthExtension} (e.g. result of `firebaseAuth({...})`) to
|
|
324
|
+
* wire Firebase Auth with a bundled `/__login` page and session cookie.
|
|
437
325
|
* - Pass a `BasicAuthConfig` to enable HTTP Basic Auth.
|
|
438
|
-
* - Pass a `Middleware` function for custom auth logic.
|
|
326
|
+
* - Pass a `Middleware` function for fully custom auth logic.
|
|
439
327
|
*/
|
|
440
|
-
auth?: BasicAuthConfig | Middleware;
|
|
328
|
+
auth?: AuthExtension | BasicAuthConfig | Middleware;
|
|
441
329
|
/**
|
|
442
330
|
* Additional middleware functions executed after auth, before route handlers.
|
|
443
331
|
*/
|
|
@@ -570,4 +458,4 @@ declare function createAdminServer<TRepos extends Record<string, ConfiguredRepos
|
|
|
570
458
|
httpsOptions?: HttpsOptions;
|
|
571
459
|
};
|
|
572
460
|
|
|
573
|
-
export { type AdminRepoConfig as A, type BasicAuthConfig as B, type ColumnMeta as C, type FilterState as F,
|
|
461
|
+
export { type AdminRepoConfig as A, type BasicAuthConfig as B, type ColumnMeta as C, type FilterState as F, type PageOptions as P, type QueryError as Q, type RelationalFieldMeta as R, type SortState as S, type AdminRepoEntry as a, type AdminServerOptions as b, type RepoRegistry as c, createAdminServer as d };
|
|
@@ -1,121 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { HttpsOptions } from 'firebase-functions/v2/https';
|
|
3
|
-
import { C as ConfiguredRepository, R as RepositoryConfig, F as FieldPath, n as FieldRole } from './types-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Minimal zero-dependency HTTP router for Firebase Functions.
|
|
7
|
-
* Compatible with any Express-like (req, res) handler.
|
|
8
|
-
*
|
|
9
|
-
* Supports:
|
|
10
|
-
* - Named path parameters (e.g. "/repos/:name/:id")
|
|
11
|
-
* - GET, POST, DELETE methods
|
|
12
|
-
* - Global middleware (before each route)
|
|
13
|
-
* - 404 / error fallbacks
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { MiniRouter } from "@lpdjs/firestore-repo-service/servers/admin";
|
|
18
|
-
*
|
|
19
|
-
* // Create router
|
|
20
|
-
* const router = new MiniRouter();
|
|
21
|
-
*
|
|
22
|
-
* // Add global middleware (executed before every route)
|
|
23
|
-
* router.use(async (req, res, next) => {
|
|
24
|
-
* console.log(`${req.method} ${req.url}`);
|
|
25
|
-
* await next();
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* // Auth middleware
|
|
29
|
-
* router.use((req, res, next) => {
|
|
30
|
-
* if (!req.headers?.authorization) {
|
|
31
|
-
* res.status(401).send("Unauthorized");
|
|
32
|
-
* return;
|
|
33
|
-
* }
|
|
34
|
-
* next();
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // Define routes with path parameters
|
|
38
|
-
* router.get("/users", async (req, res) => {
|
|
39
|
-
* res.json({ users: await getAllUsers() });
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* router.get("/users/:id", async (req, res) => {
|
|
43
|
-
* const user = await getUser(req.params.id); // Access path params
|
|
44
|
-
* if (!user) {
|
|
45
|
-
* res.status(404).send("User not found");
|
|
46
|
-
* return;
|
|
47
|
-
* }
|
|
48
|
-
* res.json(user);
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* router.post("/users", async (req, res) => {
|
|
52
|
-
* const user = await createUser(req.body);
|
|
53
|
-
* res.status(201).json(user);
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* router.delete("/users/:id", async (req, res) => {
|
|
57
|
-
* await deleteUser(req.params.id);
|
|
58
|
-
* res.status(204).end();
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* // Custom 404 handler
|
|
62
|
-
* router.onNotFound((req, res) => {
|
|
63
|
-
* res.status(404).json({ error: "Route not found", path: req.url });
|
|
64
|
-
* });
|
|
65
|
-
*
|
|
66
|
-
* // Custom error handler
|
|
67
|
-
* router.onError((err, req, res) => {
|
|
68
|
-
* console.error("Error:", err);
|
|
69
|
-
* res.status(500).json({ error: "Internal server error" });
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* // Use with Firebase Functions
|
|
73
|
-
* export const api = onRequest(async (req, res) => {
|
|
74
|
-
* await router.handle(req, res);
|
|
75
|
-
* });
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
type AnyReq = {
|
|
79
|
-
method?: string;
|
|
80
|
-
url?: string;
|
|
81
|
-
/** Express originalUrl — preserved before any router stripping, contains the full path including the Firebase Functions prefix */
|
|
82
|
-
originalUrl?: string;
|
|
83
|
-
path?: string;
|
|
84
|
-
headers?: Record<string, string | string[] | undefined>;
|
|
85
|
-
body?: unknown;
|
|
86
|
-
query?: Record<string, string | string[] | undefined>;
|
|
87
|
-
};
|
|
88
|
-
type AnyRes = {
|
|
89
|
-
status: (code: number) => AnyRes;
|
|
90
|
-
set: (key: string, value: string) => AnyRes;
|
|
91
|
-
send: (body: string) => void;
|
|
92
|
-
json: (body: unknown) => void;
|
|
93
|
-
end: () => void;
|
|
94
|
-
};
|
|
95
|
-
type RouteParams = Record<string, string>;
|
|
96
|
-
type RouteHandler = (req: AnyReq & {
|
|
97
|
-
params: RouteParams;
|
|
98
|
-
}, res: AnyRes) => void | Promise<void>;
|
|
99
|
-
type Middleware = (req: AnyReq & {
|
|
100
|
-
params: RouteParams;
|
|
101
|
-
}, res: AnyRes, next: () => void | Promise<void>) => void | Promise<void>;
|
|
102
|
-
declare class MiniRouter {
|
|
103
|
-
private routes;
|
|
104
|
-
private middlewares;
|
|
105
|
-
private notFoundHandler;
|
|
106
|
-
private errorHandler;
|
|
107
|
-
use(middleware: Middleware): this;
|
|
108
|
-
get(path: string, handler: RouteHandler): this;
|
|
109
|
-
post(path: string, handler: RouteHandler): this;
|
|
110
|
-
put(path: string, handler: RouteHandler): this;
|
|
111
|
-
patch(path: string, handler: RouteHandler): this;
|
|
112
|
-
delete(path: string, handler: RouteHandler): this;
|
|
113
|
-
onNotFound(handler: RouteHandler): this;
|
|
114
|
-
onError(handler: (err: unknown, req: AnyReq, res: AnyRes) => void): this;
|
|
115
|
-
private addRoute;
|
|
116
|
-
handle(req: AnyReq, res: AnyRes): Promise<void>;
|
|
117
|
-
private runMiddlewareChain;
|
|
118
|
-
}
|
|
3
|
+
import { C as ConfiguredRepository, R as RepositoryConfig, F as FieldPath, n as FieldRole } from './types-CqXbEeXp.js';
|
|
4
|
+
import { A as AuthExtension, a as Middleware } from './firebase-auth-CBqtAeb5.js';
|
|
119
5
|
|
|
120
6
|
interface PageOptions {
|
|
121
7
|
title: string;
|
|
@@ -434,10 +320,12 @@ interface AdminServerOptions<TRepos extends Record<string, ConfiguredRepository<
|
|
|
434
320
|
parseBody?: boolean;
|
|
435
321
|
/**
|
|
436
322
|
* Authentication guard executed before every request.
|
|
323
|
+
* - Pass an {@link AuthExtension} (e.g. result of `firebaseAuth({...})`) to
|
|
324
|
+
* wire Firebase Auth with a bundled `/__login` page and session cookie.
|
|
437
325
|
* - Pass a `BasicAuthConfig` to enable HTTP Basic Auth.
|
|
438
|
-
* - Pass a `Middleware` function for custom auth logic.
|
|
326
|
+
* - Pass a `Middleware` function for fully custom auth logic.
|
|
439
327
|
*/
|
|
440
|
-
auth?: BasicAuthConfig | Middleware;
|
|
328
|
+
auth?: AuthExtension | BasicAuthConfig | Middleware;
|
|
441
329
|
/**
|
|
442
330
|
* Additional middleware functions executed after auth, before route handlers.
|
|
443
331
|
*/
|
|
@@ -570,4 +458,4 @@ declare function createAdminServer<TRepos extends Record<string, ConfiguredRepos
|
|
|
570
458
|
httpsOptions?: HttpsOptions;
|
|
571
459
|
};
|
|
572
460
|
|
|
573
|
-
export { type AdminRepoConfig as A, type BasicAuthConfig as B, type ColumnMeta as C, type FilterState as F,
|
|
461
|
+
export { type AdminRepoConfig as A, type BasicAuthConfig as B, type ColumnMeta as C, type FilterState as F, type PageOptions as P, type QueryError as Q, type RelationalFieldMeta as R, type SortState as S, type AdminRepoEntry as a, type AdminServerOptions as b, type RepoRegistry as c, createAdminServer as d };
|