@lpdjs/firestore-repo-service 2.2.2 → 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.
@@ -515,38 +515,14 @@ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, an
515
515
  };
516
516
 
517
517
  /**
518
- * OpenAPI 3.1 specification generator for the CRUD server.
519
- *
520
- * Introspects each `CrudRepoEntry` and uses Zod 4's native `z.toJSONSchema()`
521
- * to produce a fully typed OpenAPI document ready for Scalar UI or codegen.
522
- *
523
- * @module servers/crud/openapi
518
+ * Type definitions for the CRUD API server.
524
519
  */
525
520
 
526
- /** Minimal subset of an OpenAPI 3.1 document we produce. */
527
- interface OpenAPIDocument {
528
- openapi: "3.1.0";
529
- info: OpenAPIInfo;
530
- servers?: {
531
- url: string;
532
- description?: string;
533
- }[];
534
- paths: Record<string, Record<string, OpenAPIOperation>>;
535
- components: {
536
- schemas: Record<string, Record<string, unknown>>;
537
- securitySchemes?: Record<string, Record<string, unknown>>;
538
- };
539
- security?: Record<string, string[]>[];
540
- tags?: {
541
- name: string;
542
- description?: string;
543
- }[];
544
- }
545
- interface OpenAPIInfo {
546
- title: string;
547
- version: string;
548
- description?: string;
549
- }
521
+ /**
522
+ * Options to control OpenAPI 3.1 spec generation for the CRUD server.
523
+ * Defined here (rather than in `./openapi`) to avoid a circular import:
524
+ * `openapi.ts` imports types from this module.
525
+ */
550
526
  interface OpenAPISpecOptions {
551
527
  /** Document title (default: "CRUD API") */
552
528
  title?: string;
@@ -562,54 +538,20 @@ interface OpenAPISpecOptions {
562
538
  /** Whether the API requires auth — adds securitySchemes */
563
539
  auth?: "basic" | "bearer" | false;
564
540
  }
565
- interface OpenAPIOperation {
566
- operationId: string;
567
- summary: string;
568
- tags: string[];
569
- parameters?: Record<string, unknown>[];
570
- requestBody?: Record<string, unknown>;
571
- responses: Record<string, Record<string, unknown>>;
572
- security?: Record<string, string[]>[];
573
- }
574
- /**
575
- * Generate a full OpenAPI 3.1 specification from a `CrudRepoRegistry`.
576
- *
577
- * Uses Zod 4's native `z.toJSONSchema()` to convert each repo's schema
578
- * into a JSON Schema component, then assembles paths for the standard
579
- * CRUD endpoints.
580
- *
581
- * @example
582
- * ```ts
583
- * import { generateOpenAPISpec } from "@lpdjs/firestore-repo-service/servers/crud";
584
- *
585
- * const spec = generateOpenAPISpec(registry, "/api", {
586
- * title: "My API",
587
- * version: "1.0.0",
588
- * servers: [{ url: "https://my-api.example.com" }],
589
- * auth: "bearer",
590
- * });
591
- *
592
- * // Write to file
593
- * fs.writeFileSync("openapi.json", JSON.stringify(spec, null, 2));
594
- * ```
595
- */
596
- declare function generateOpenAPISpec(registry: CrudRepoRegistry, basePath: string, options?: OpenAPISpecOptions): OpenAPIDocument;
597
-
598
- /**
599
- * Type definitions for the CRUD API server.
600
- */
601
-
602
541
  /**
603
542
  * Extracts the model type `T` from a `ConfiguredRepository`.
543
+ * Uses a two-step inference so it survives intersection types
544
+ * (e.g. `RepositoryConfig<...> & { schema: ZodObject }` produced by
545
+ * `createRepositoryConfig(schema)`).
604
546
  * @internal
605
547
  */
606
- type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any>> ? T : never;
548
+ type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any> ? T : never : never;
607
549
  /**
608
550
  * Extracts the auto-managed system keys (documentKey, pathKey, createdKey, updatedKey)
609
551
  * from a `ConfiguredRepository`. These keys must never appear in create/update payloads.
610
552
  * @internal
611
553
  */
612
- type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey>> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never;
554
+ type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never : never;
613
555
  /**
614
556
  * `true` when `T` is `any` (the `0 extends (1 & T)` trick).
615
557
  * @internal
@@ -923,4 +865,4 @@ interface QueryRequestBody {
923
865
  })[];
924
866
  }
925
867
 
926
- export { type ApiResponse as A, type BasicAuthConfig as B, type ConfiguredRepository as C, type ExtractDocumentRefSignature as E, type FieldPath as F, type GetOptions as G, type IncludeConfigTyped as I, type ListResponseData as L, type Middleware as M, type OpenAPIDocument as O, type PaginationOptions as P, type QueryOptions as Q, type RepositoryConfig as R, type UserFieldPath as U, type WhereClause as W, type RelationConfig as a, type ExtractUpdateSignature as b, type GetResult as c, type RelationalKeys as d, createPaginationIterator as e, executePaginatedQuery as f, type PaginationResult as g, type GenerateGetMethods as h, type GenerateQueryMethods as i, type PaginationWithIncludeOptionsTyped as j, type PopulateOptionsTyped as k, type CrudRepoConfig as l, type CrudServerOptions as m, type FieldRole as n, type QueryRequestBody as o, type RepoFieldPath as p, type RepoRelationKeys as q, type CrudRepoEntry as r, type CrudRepoRegistry as s, generateOpenAPISpec as t, type OpenAPISpecOptions as u };
868
+ export { type ApiResponse as A, type BasicAuthConfig as B, type ConfiguredRepository as C, type ExtractDocumentRefSignature as E, type FieldPath as F, type GetOptions as G, type IncludeConfigTyped as I, type ListResponseData as L, type Middleware as M, type OpenAPISpecOptions as O, type PaginationOptions as P, type QueryOptions as Q, type RepositoryConfig as R, type UserFieldPath as U, type WhereClause as W, type RelationConfig as a, type ExtractUpdateSignature as b, type GetResult as c, type RelationalKeys as d, createPaginationIterator as e, executePaginatedQuery as f, type PaginationResult as g, type GenerateGetMethods as h, type GenerateQueryMethods as i, type PaginationWithIncludeOptionsTyped as j, type PopulateOptionsTyped as k, type CrudRepoConfig as l, type CrudServerOptions as m, type FieldRole as n, type QueryRequestBody as o, type RepoFieldPath as p, type RepoRelationKeys as q, type CrudRepoEntry as r, type CrudRepoRegistry as s };
@@ -515,38 +515,14 @@ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, an
515
515
  };
516
516
 
517
517
  /**
518
- * OpenAPI 3.1 specification generator for the CRUD server.
519
- *
520
- * Introspects each `CrudRepoEntry` and uses Zod 4's native `z.toJSONSchema()`
521
- * to produce a fully typed OpenAPI document ready for Scalar UI or codegen.
522
- *
523
- * @module servers/crud/openapi
518
+ * Type definitions for the CRUD API server.
524
519
  */
525
520
 
526
- /** Minimal subset of an OpenAPI 3.1 document we produce. */
527
- interface OpenAPIDocument {
528
- openapi: "3.1.0";
529
- info: OpenAPIInfo;
530
- servers?: {
531
- url: string;
532
- description?: string;
533
- }[];
534
- paths: Record<string, Record<string, OpenAPIOperation>>;
535
- components: {
536
- schemas: Record<string, Record<string, unknown>>;
537
- securitySchemes?: Record<string, Record<string, unknown>>;
538
- };
539
- security?: Record<string, string[]>[];
540
- tags?: {
541
- name: string;
542
- description?: string;
543
- }[];
544
- }
545
- interface OpenAPIInfo {
546
- title: string;
547
- version: string;
548
- description?: string;
549
- }
521
+ /**
522
+ * Options to control OpenAPI 3.1 spec generation for the CRUD server.
523
+ * Defined here (rather than in `./openapi`) to avoid a circular import:
524
+ * `openapi.ts` imports types from this module.
525
+ */
550
526
  interface OpenAPISpecOptions {
551
527
  /** Document title (default: "CRUD API") */
552
528
  title?: string;
@@ -562,54 +538,20 @@ interface OpenAPISpecOptions {
562
538
  /** Whether the API requires auth — adds securitySchemes */
563
539
  auth?: "basic" | "bearer" | false;
564
540
  }
565
- interface OpenAPIOperation {
566
- operationId: string;
567
- summary: string;
568
- tags: string[];
569
- parameters?: Record<string, unknown>[];
570
- requestBody?: Record<string, unknown>;
571
- responses: Record<string, Record<string, unknown>>;
572
- security?: Record<string, string[]>[];
573
- }
574
- /**
575
- * Generate a full OpenAPI 3.1 specification from a `CrudRepoRegistry`.
576
- *
577
- * Uses Zod 4's native `z.toJSONSchema()` to convert each repo's schema
578
- * into a JSON Schema component, then assembles paths for the standard
579
- * CRUD endpoints.
580
- *
581
- * @example
582
- * ```ts
583
- * import { generateOpenAPISpec } from "@lpdjs/firestore-repo-service/servers/crud";
584
- *
585
- * const spec = generateOpenAPISpec(registry, "/api", {
586
- * title: "My API",
587
- * version: "1.0.0",
588
- * servers: [{ url: "https://my-api.example.com" }],
589
- * auth: "bearer",
590
- * });
591
- *
592
- * // Write to file
593
- * fs.writeFileSync("openapi.json", JSON.stringify(spec, null, 2));
594
- * ```
595
- */
596
- declare function generateOpenAPISpec(registry: CrudRepoRegistry, basePath: string, options?: OpenAPISpecOptions): OpenAPIDocument;
597
-
598
- /**
599
- * Type definitions for the CRUD API server.
600
- */
601
-
602
541
  /**
603
542
  * Extracts the model type `T` from a `ConfiguredRepository`.
543
+ * Uses a two-step inference so it survives intersection types
544
+ * (e.g. `RepositoryConfig<...> & { schema: ZodObject }` produced by
545
+ * `createRepositoryConfig(schema)`).
604
546
  * @internal
605
547
  */
606
- type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any>> ? T : never;
548
+ type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any> ? T : never : never;
607
549
  /**
608
550
  * Extracts the auto-managed system keys (documentKey, pathKey, createdKey, updatedKey)
609
551
  * from a `ConfiguredRepository`. These keys must never appear in create/update payloads.
610
552
  * @internal
611
553
  */
612
- type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey>> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never;
554
+ type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never : never;
613
555
  /**
614
556
  * `true` when `T` is `any` (the `0 extends (1 & T)` trick).
615
557
  * @internal
@@ -923,4 +865,4 @@ interface QueryRequestBody {
923
865
  })[];
924
866
  }
925
867
 
926
- export { type ApiResponse as A, type BasicAuthConfig as B, type ConfiguredRepository as C, type ExtractDocumentRefSignature as E, type FieldPath as F, type GetOptions as G, type IncludeConfigTyped as I, type ListResponseData as L, type Middleware as M, type OpenAPIDocument as O, type PaginationOptions as P, type QueryOptions as Q, type RepositoryConfig as R, type UserFieldPath as U, type WhereClause as W, type RelationConfig as a, type ExtractUpdateSignature as b, type GetResult as c, type RelationalKeys as d, createPaginationIterator as e, executePaginatedQuery as f, type PaginationResult as g, type GenerateGetMethods as h, type GenerateQueryMethods as i, type PaginationWithIncludeOptionsTyped as j, type PopulateOptionsTyped as k, type CrudRepoConfig as l, type CrudServerOptions as m, type FieldRole as n, type QueryRequestBody as o, type RepoFieldPath as p, type RepoRelationKeys as q, type CrudRepoEntry as r, type CrudRepoRegistry as s, generateOpenAPISpec as t, type OpenAPISpecOptions as u };
868
+ export { type ApiResponse as A, type BasicAuthConfig as B, type ConfiguredRepository as C, type ExtractDocumentRefSignature as E, type FieldPath as F, type GetOptions as G, type IncludeConfigTyped as I, type ListResponseData as L, type Middleware as M, type OpenAPISpecOptions as O, type PaginationOptions as P, type QueryOptions as Q, type RepositoryConfig as R, type UserFieldPath as U, type WhereClause as W, type RelationConfig as a, type ExtractUpdateSignature as b, type GetResult as c, type RelationalKeys as d, createPaginationIterator as e, executePaginatedQuery as f, type PaginationResult as g, type GenerateGetMethods as h, type GenerateQueryMethods as i, type PaginationWithIncludeOptionsTyped as j, type PopulateOptionsTyped as k, type CrudRepoConfig as l, type CrudServerOptions as m, type FieldRole as n, type QueryRequestBody as o, type RepoFieldPath as p, type RepoRelationKeys as q, type CrudRepoEntry as r, type CrudRepoRegistry as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpdjs/firestore-repo-service",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "⚡ Type-safe Firestore ORM with auto-generated repositories, advanced queries, relations with typed select, pagination with include, batch/bulk operations, aggregations and transactions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",