@lpdjs/firestore-repo-service 2.2.3 → 2.2.4

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.
@@ -1,9 +1,75 @@
1
1
  import { HttpsOptions } from 'firebase-functions/v2/https';
2
- import { C as ConfiguredRepository, m as CrudServerOptions, O as OpenAPIDocument } from '../../types-DKgWRTDf.cjs';
3
- export { A as ApiResponse, B as BasicAuthConfig, l as CrudRepoConfig, r as CrudRepoEntry, s as CrudRepoRegistry, n as FieldRole, L as ListResponseData, M as Middleware, u as OpenAPISpecOptions, o as QueryRequestBody, p as RepoFieldPath, q as RepoRelationKeys, U as UserFieldPath, t as generateOpenAPISpec } from '../../types-DKgWRTDf.cjs';
2
+ import { s as CrudRepoRegistry, O as OpenAPISpecOptions, C as ConfiguredRepository, m as CrudServerOptions } from '../../types-Z9Qy8Xmx.cjs';
3
+ export { A as ApiResponse, B as BasicAuthConfig, l as CrudRepoConfig, r as CrudRepoEntry, n as FieldRole, L as ListResponseData, M as Middleware, o as QueryRequestBody, p as RepoFieldPath, q as RepoRelationKeys, U as UserFieldPath } from '../../types-Z9Qy8Xmx.cjs';
4
4
  import 'zod';
5
5
  import 'firebase-admin/firestore';
6
6
 
7
+ /**
8
+ * OpenAPI 3.1 specification generator for the CRUD server.
9
+ *
10
+ * Introspects each `CrudRepoEntry` and uses Zod 4's native `z.toJSONSchema()`
11
+ * to produce a fully typed OpenAPI document ready for Scalar UI or codegen.
12
+ *
13
+ * @module servers/crud/openapi
14
+ */
15
+
16
+ /** Minimal subset of an OpenAPI 3.1 document we produce. */
17
+ interface OpenAPIDocument {
18
+ openapi: "3.1.0";
19
+ info: OpenAPIInfo;
20
+ servers?: {
21
+ url: string;
22
+ description?: string;
23
+ }[];
24
+ paths: Record<string, Record<string, OpenAPIOperation>>;
25
+ components: {
26
+ schemas: Record<string, Record<string, unknown>>;
27
+ securitySchemes?: Record<string, Record<string, unknown>>;
28
+ };
29
+ security?: Record<string, string[]>[];
30
+ tags?: {
31
+ name: string;
32
+ description?: string;
33
+ }[];
34
+ }
35
+ interface OpenAPIInfo {
36
+ title: string;
37
+ version: string;
38
+ description?: string;
39
+ }
40
+ interface OpenAPIOperation {
41
+ operationId: string;
42
+ summary: string;
43
+ tags: string[];
44
+ parameters?: Record<string, unknown>[];
45
+ requestBody?: Record<string, unknown>;
46
+ responses: Record<string, Record<string, unknown>>;
47
+ security?: Record<string, string[]>[];
48
+ }
49
+ /**
50
+ * Generate a full OpenAPI 3.1 specification from a `CrudRepoRegistry`.
51
+ *
52
+ * Uses Zod 4's native `z.toJSONSchema()` to convert each repo's schema
53
+ * into a JSON Schema component, then assembles paths for the standard
54
+ * CRUD endpoints.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { generateOpenAPISpec } from "@lpdjs/firestore-repo-service/servers/crud";
59
+ *
60
+ * const spec = generateOpenAPISpec(registry, "/api", {
61
+ * title: "My API",
62
+ * version: "1.0.0",
63
+ * servers: [{ url: "https://my-api.example.com" }],
64
+ * auth: "bearer",
65
+ * });
66
+ *
67
+ * // Write to file
68
+ * fs.writeFileSync("openapi.json", JSON.stringify(spec, null, 2));
69
+ * ```
70
+ */
71
+ declare function generateOpenAPISpec(registry: CrudRepoRegistry, basePath: string, options?: OpenAPISpecOptions): OpenAPIDocument;
72
+
7
73
  /**
8
74
  * @module servers/crud
9
75
  *
@@ -181,4 +247,4 @@ declare function createCrudServer<TRepos extends Record<string, ConfiguredReposi
181
247
  httpsOptions?: HttpsOptions;
182
248
  };
183
249
 
184
- export { CrudServerOptions, OpenAPIDocument, createCrudServer };
250
+ export { CrudRepoRegistry, CrudServerOptions, type OpenAPIDocument, OpenAPISpecOptions, createCrudServer, generateOpenAPISpec };
@@ -1,9 +1,75 @@
1
1
  import { HttpsOptions } from 'firebase-functions/v2/https';
2
- import { C as ConfiguredRepository, m as CrudServerOptions, O as OpenAPIDocument } from '../../types-DKgWRTDf.js';
3
- export { A as ApiResponse, B as BasicAuthConfig, l as CrudRepoConfig, r as CrudRepoEntry, s as CrudRepoRegistry, n as FieldRole, L as ListResponseData, M as Middleware, u as OpenAPISpecOptions, o as QueryRequestBody, p as RepoFieldPath, q as RepoRelationKeys, U as UserFieldPath, t as generateOpenAPISpec } from '../../types-DKgWRTDf.js';
2
+ import { s as CrudRepoRegistry, O as OpenAPISpecOptions, C as ConfiguredRepository, m as CrudServerOptions } from '../../types-Z9Qy8Xmx.js';
3
+ export { A as ApiResponse, B as BasicAuthConfig, l as CrudRepoConfig, r as CrudRepoEntry, n as FieldRole, L as ListResponseData, M as Middleware, o as QueryRequestBody, p as RepoFieldPath, q as RepoRelationKeys, U as UserFieldPath } from '../../types-Z9Qy8Xmx.js';
4
4
  import 'zod';
5
5
  import 'firebase-admin/firestore';
6
6
 
7
+ /**
8
+ * OpenAPI 3.1 specification generator for the CRUD server.
9
+ *
10
+ * Introspects each `CrudRepoEntry` and uses Zod 4's native `z.toJSONSchema()`
11
+ * to produce a fully typed OpenAPI document ready for Scalar UI or codegen.
12
+ *
13
+ * @module servers/crud/openapi
14
+ */
15
+
16
+ /** Minimal subset of an OpenAPI 3.1 document we produce. */
17
+ interface OpenAPIDocument {
18
+ openapi: "3.1.0";
19
+ info: OpenAPIInfo;
20
+ servers?: {
21
+ url: string;
22
+ description?: string;
23
+ }[];
24
+ paths: Record<string, Record<string, OpenAPIOperation>>;
25
+ components: {
26
+ schemas: Record<string, Record<string, unknown>>;
27
+ securitySchemes?: Record<string, Record<string, unknown>>;
28
+ };
29
+ security?: Record<string, string[]>[];
30
+ tags?: {
31
+ name: string;
32
+ description?: string;
33
+ }[];
34
+ }
35
+ interface OpenAPIInfo {
36
+ title: string;
37
+ version: string;
38
+ description?: string;
39
+ }
40
+ interface OpenAPIOperation {
41
+ operationId: string;
42
+ summary: string;
43
+ tags: string[];
44
+ parameters?: Record<string, unknown>[];
45
+ requestBody?: Record<string, unknown>;
46
+ responses: Record<string, Record<string, unknown>>;
47
+ security?: Record<string, string[]>[];
48
+ }
49
+ /**
50
+ * Generate a full OpenAPI 3.1 specification from a `CrudRepoRegistry`.
51
+ *
52
+ * Uses Zod 4's native `z.toJSONSchema()` to convert each repo's schema
53
+ * into a JSON Schema component, then assembles paths for the standard
54
+ * CRUD endpoints.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * import { generateOpenAPISpec } from "@lpdjs/firestore-repo-service/servers/crud";
59
+ *
60
+ * const spec = generateOpenAPISpec(registry, "/api", {
61
+ * title: "My API",
62
+ * version: "1.0.0",
63
+ * servers: [{ url: "https://my-api.example.com" }],
64
+ * auth: "bearer",
65
+ * });
66
+ *
67
+ * // Write to file
68
+ * fs.writeFileSync("openapi.json", JSON.stringify(spec, null, 2));
69
+ * ```
70
+ */
71
+ declare function generateOpenAPISpec(registry: CrudRepoRegistry, basePath: string, options?: OpenAPISpecOptions): OpenAPIDocument;
72
+
7
73
  /**
8
74
  * @module servers/crud
9
75
  *
@@ -181,4 +247,4 @@ declare function createCrudServer<TRepos extends Record<string, ConfiguredReposi
181
247
  httpsOptions?: HttpsOptions;
182
248
  };
183
249
 
184
- export { CrudServerOptions, OpenAPIDocument, createCrudServer };
250
+ export { CrudRepoRegistry, CrudServerOptions, type OpenAPIDocument, OpenAPISpecOptions, createCrudServer, generateOpenAPISpec };