express-file-cluster 0.9.0 → 0.9.2

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.
Files changed (87) hide show
  1. package/dist/auth/index.cjs +8 -2
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.d.cts +13 -2
  4. package/dist/auth/index.d.ts +13 -2
  5. package/dist/auth/index.js +9 -3
  6. package/dist/{chunk-2J3HHQKP.cjs → chunk-ANUSWEAP.cjs} +55 -2
  7. package/dist/chunk-ANUSWEAP.cjs.map +1 -0
  8. package/dist/{chunk-RSZB7VAO.js → chunk-ATL4GYFU.js} +54 -1
  9. package/dist/chunk-ATL4GYFU.js.map +1 -0
  10. package/dist/{chunk-2PBMLMO4.js → chunk-QKQZF573.js} +26 -4
  11. package/dist/chunk-QKQZF573.js.map +1 -0
  12. package/dist/{chunk-6QNLN6AI.js → chunk-RRQ2RK5M.js} +353 -3
  13. package/dist/chunk-RRQ2RK5M.js.map +1 -0
  14. package/dist/{chunk-RGTENTDN.cjs → chunk-RTF7PHS2.cjs} +432 -82
  15. package/dist/chunk-RTF7PHS2.cjs.map +1 -0
  16. package/dist/{chunk-66R7S7J3.cjs → chunk-X2US4RAM.cjs} +26 -4
  17. package/dist/chunk-X2US4RAM.cjs.map +1 -0
  18. package/dist/cli/db-runner.cjs +17 -17
  19. package/dist/cli/db-runner.js +2 -2
  20. package/dist/cli/index.cjs +315 -26
  21. package/dist/cli/index.cjs.map +1 -1
  22. package/dist/cli/index.js +295 -6
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/docs/api-reference/auth.md +35 -0
  25. package/dist/docs/api-reference/collection.md +155 -0
  26. package/dist/docs/cli/add.md +36 -7
  27. package/dist/docs/guides/authentication.md +80 -4
  28. package/dist/docs/guides/coming-from-mongoose.md +60 -0
  29. package/dist/docs/guides/which-api.md +21 -12
  30. package/dist/docs/index.md +4 -2
  31. package/dist/docs/skills/SKILL.md +3 -3
  32. package/dist/docs/skills/api-surface.md +16 -0
  33. package/dist/docs/skills/what-not-to-invent.md +3 -2
  34. package/dist/index.cjs +18 -16
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +193 -3
  37. package/dist/index.d.ts +193 -3
  38. package/dist/index.js +5 -3
  39. package/dist/index.js.map +1 -1
  40. package/dist/registry/index.json +1 -1
  41. package/dist/registry/js-mongo/admin-users.json +1 -1
  42. package/dist/registry/js-mongo/auth.json +1 -1
  43. package/dist/registry/js-mongo/auth@apple.json +1 -1
  44. package/dist/registry/js-mongo/auth@google.json +1 -1
  45. package/dist/registry/js-mongo/email-client.json +1 -1
  46. package/dist/registry/js-mongo/forgot-password.json +1 -1
  47. package/dist/registry/js-pg-model/admin-users.json +1 -1
  48. package/dist/registry/js-pg-model/auth.json +1 -1
  49. package/dist/registry/js-pg-model/auth@apple.json +1 -1
  50. package/dist/registry/js-pg-model/auth@google.json +1 -1
  51. package/dist/registry/js-pg-model/email-client.json +1 -1
  52. package/dist/registry/js-pg-model/forgot-password.json +1 -1
  53. package/dist/registry/js-pg-table/admin-users.json +1 -1
  54. package/dist/registry/js-pg-table/auth.json +1 -1
  55. package/dist/registry/js-pg-table/auth@apple.json +1 -1
  56. package/dist/registry/js-pg-table/auth@google.json +1 -1
  57. package/dist/registry/js-pg-table/email-client.json +1 -1
  58. package/dist/registry/js-pg-table/forgot-password.json +1 -1
  59. package/dist/registry/ts-mongo/admin-users.json +1 -1
  60. package/dist/registry/ts-mongo/auth.json +1 -1
  61. package/dist/registry/ts-mongo/auth@apple.json +1 -1
  62. package/dist/registry/ts-mongo/auth@google.json +1 -1
  63. package/dist/registry/ts-mongo/email-client.json +1 -1
  64. package/dist/registry/ts-mongo/forgot-password.json +1 -1
  65. package/dist/registry/ts-pg-model/admin-users.json +1 -1
  66. package/dist/registry/ts-pg-model/auth.json +1 -1
  67. package/dist/registry/ts-pg-model/auth@apple.json +1 -1
  68. package/dist/registry/ts-pg-model/auth@google.json +1 -1
  69. package/dist/registry/ts-pg-model/email-client.json +1 -1
  70. package/dist/registry/ts-pg-model/forgot-password.json +1 -1
  71. package/dist/registry/ts-pg-table/admin-users.json +1 -1
  72. package/dist/registry/ts-pg-table/auth.json +1 -1
  73. package/dist/registry/ts-pg-table/auth@apple.json +1 -1
  74. package/dist/registry/ts-pg-table/auth@google.json +1 -1
  75. package/dist/registry/ts-pg-table/email-client.json +1 -1
  76. package/dist/registry/ts-pg-table/forgot-password.json +1 -1
  77. package/dist/tasks/index.d.cts +1 -1
  78. package/dist/tasks/index.d.ts +1 -1
  79. package/dist/{types-gyvA7BtO.d.ts → types-BY-ObnZH.d.cts} +36 -7
  80. package/dist/{types-gyvA7BtO.d.cts → types-BY-ObnZH.d.ts} +36 -7
  81. package/package.json +3 -3
  82. package/dist/chunk-2J3HHQKP.cjs.map +0 -1
  83. package/dist/chunk-2PBMLMO4.js.map +0 -1
  84. package/dist/chunk-66R7S7J3.cjs.map +0 -1
  85. package/dist/chunk-6QNLN6AI.js.map +0 -1
  86. package/dist/chunk-RGTENTDN.cjs.map +0 -1
  87. package/dist/chunk-RSZB7VAO.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import http from 'node:http';
2
- import { S as Simplify, I as InferSchema, b as InferCreateInput, M as ModelSchema, c as ModelOptions, d as InferredModel, e as TableSchema, f as TableOptions, R as RouteEntry, E as EFCConfig } from './types-gyvA7BtO.cjs';
3
- export { A as AuthStrategy, C as CacheConfig, g as CorsConfig, D as DatabaseEngine, h as DatabasePoolConfig, i as DefaultOperator, F as FieldDefinition, j as Filter, k as FilterOperators, l as FindOptions, m as IndexDefinition, n as InferCreate, o as InferRecord, L as LoggingConfig, p as MigrationContext, q as ModelCRUD, r as ModelQueryOptions, s as ModelRecord, Q as QueryLogConfig, t as RequestSchema, u as RouteMeta, v as RouteMethodMeta, w as RouteSchema, x as ScalarKeys, y as SchemaField, z as SortDirection, B as TableFieldDefinition, G as TableRelation, H as TableSchemaField, a as TaskDefinition, T as TaskOptions, U as Update, V as ValidationIssue, J as Validator } from './types-gyvA7BtO.cjs';
2
+ import { S as Simplify, I as InferSchema, b as InferCreateInput, M as ModelSchema, c as ModelOptions, d as InferredModel, e as TableSchema, f as TableOptions, g as SortDirection, C as CollectionSchema, R as RouteEntry, E as EFCConfig } from './types-BY-ObnZH.cjs';
3
+ export { A as AuthStrategy, h as CacheConfig, i as CollectionFieldDefinition, j as CorsConfig, D as DatabaseEngine, k as DatabasePoolConfig, l as DefaultOperator, F as FieldDefinition, m as Filter, n as FilterOperators, o as FindOptions, G as GeoPoint, p as IndexDefinition, q as InferCreate, r as InferRecord, L as LoggingConfig, s as MigrationContext, t as ModelCRUD, u as ModelQueryOptions, v as ModelRecord, Q as QueryLogConfig, w as RequestSchema, x as RouteMeta, y as RouteMethodMeta, z as RouteSchema, B as ScalarKeys, H as SchemaField, J as TableFieldDefinition, K as TableRelation, N as TableSchemaField, a as TaskDefinition, T as TaskOptions, U as Update, V as ValidationIssue, O as Validator } from './types-BY-ObnZH.cjs';
4
4
  import { Logger } from 'pino';
5
5
  import { Request, RequestHandler } from 'express';
6
6
  export { listTasks } from './tasks/index.cjs';
@@ -722,6 +722,196 @@ declare function defineModel<T extends object = never, const S extends ModelSche
722
722
  */
723
723
  declare function defineTable<const S extends TableSchema, const O extends TableOptions = object>(name: string, schema: S, options?: O): TableModel<S, O>;
724
724
 
725
+ type AnyRecord = Record<string, unknown>;
726
+ interface CollectionOptions extends ModelOptions {
727
+ /** Default collation for this collection's queries, e.g. `{ locale: 'en', strength: 2 }`. */
728
+ collation?: AnyRecord;
729
+ }
730
+ interface CollectionFindOptions {
731
+ /** Inclusion (`{ name: 1 }`) or exclusion (`{ secret: 0 }`) projection. */
732
+ projection?: Record<string, 0 | 1 | boolean | AnyRecord>;
733
+ sort?: Record<string, SortDirection | {
734
+ $meta: 'textScore';
735
+ }>;
736
+ skip?: number;
737
+ limit?: number;
738
+ /** Resolve `objectId` fields that have a `ref` into the referenced documents. */
739
+ populate?: string | string[];
740
+ collation?: AnyRecord;
741
+ }
742
+ interface CollectionWriteResult {
743
+ matchedCount: number;
744
+ modifiedCount: number;
745
+ upsertedCount: number;
746
+ upsertedId: string | null;
747
+ }
748
+ interface CollectionBulkResult {
749
+ insertedCount: number;
750
+ matchedCount: number;
751
+ modifiedCount: number;
752
+ deletedCount: number;
753
+ upsertedCount: number;
754
+ }
755
+ /** A change stream: iterate with `for await`, stop with `close()` (or `break`). */
756
+ interface CollectionChangeStream<R> extends AsyncIterable<CollectionChange<R>> {
757
+ close(): Promise<void>;
758
+ }
759
+ interface CollectionChange<R> {
760
+ operationType: string;
761
+ /** The document id. */
762
+ id: string | undefined;
763
+ /** The new document (inserts, replaces; updates with `fullDocument: 'updateLookup'`). */
764
+ fullDocument?: R;
765
+ updateDescription?: {
766
+ updatedFields: AnyRecord;
767
+ removedFields: string[];
768
+ };
769
+ raw: AnyRecord;
770
+ }
771
+ /**
772
+ * Defines a MongoDB-native model with mongoose's vocabulary — `find` with projections,
773
+ * `findOneAndUpdate` with upsert, `bulkWrite`, aggregation pipelines, change streams —
774
+ * and BSON types (`decimal128`, `long`, `geoPoint`, `binary`). Record and input types are
775
+ * inferred from the schema. Throws at first use on a PostgreSQL connection.
776
+ */
777
+ declare function defineCollection<const S extends CollectionSchema, const O extends CollectionOptions = object>(name: string, schema: S, options?: O): CollectionModel<S, O>;
778
+ type Rec<S, O> = Simplify<InferSchema<S, O> & {
779
+ id: string;
780
+ }>;
781
+ type Elem<V> = V extends readonly (infer E)[] ? E : never;
782
+ /** A query filter: fields (with an array's element for "contains"), operators, dotted paths. */
783
+ type CollectionFilter<R> = {
784
+ [K in keyof R]?: R[K] | Elem<R[K]> | null | {
785
+ [op: `$${string}`]: unknown;
786
+ };
787
+ } & {
788
+ [path: `${string}.${string}`]: unknown;
789
+ _id?: unknown;
790
+ $and?: CollectionFilter<R>[];
791
+ $or?: CollectionFilter<R>[];
792
+ $nor?: CollectionFilter<R>[];
793
+ $text?: {
794
+ $search: string;
795
+ $language?: string;
796
+ $caseSensitive?: boolean;
797
+ };
798
+ $expr?: unknown;
799
+ };
800
+ type Fields<R> = {
801
+ [K in keyof R]?: unknown;
802
+ } & {
803
+ [path: `${string}.${string}`]: unknown;
804
+ };
805
+ /** Plain fields (shorthand for `$set`) and/or update operators. */
806
+ type CollectionUpdate<R> = Partial<R> | {
807
+ $set?: Fields<R>;
808
+ $unset?: Fields<R>;
809
+ $inc?: Fields<R>;
810
+ $mul?: Fields<R>;
811
+ $min?: Fields<R>;
812
+ $max?: Fields<R>;
813
+ $push?: Fields<R>;
814
+ $pull?: Fields<R>;
815
+ $addToSet?: Fields<R>;
816
+ $pop?: Fields<R>;
817
+ $rename?: Record<string, string>;
818
+ $setOnInsert?: Fields<R>;
819
+ $currentDate?: Fields<R>;
820
+ };
821
+ type CollectionBulkOp<R, C> = {
822
+ insertOne: {
823
+ document: C;
824
+ };
825
+ } | {
826
+ updateOne: {
827
+ filter: CollectionFilter<R>;
828
+ update: CollectionUpdate<R>;
829
+ upsert?: boolean;
830
+ };
831
+ } | {
832
+ updateMany: {
833
+ filter: CollectionFilter<R>;
834
+ update: CollectionUpdate<R>;
835
+ upsert?: boolean;
836
+ };
837
+ } | {
838
+ replaceOne: {
839
+ filter: CollectionFilter<R>;
840
+ replacement: C;
841
+ upsert?: boolean;
842
+ };
843
+ } | {
844
+ deleteOne: {
845
+ filter: CollectionFilter<R>;
846
+ };
847
+ } | {
848
+ deleteMany: {
849
+ filter: CollectionFilter<R>;
850
+ };
851
+ };
852
+ interface CollectionModel<S, O = object, R = Rec<S, O>, C = InferCreateInput<S>> {
853
+ readonly name: string;
854
+ /** Inferred types: `InferRecord<typeof Place>`, `InferCreate<typeof Place>`. */
855
+ readonly $types?: {
856
+ record: R;
857
+ create: C;
858
+ };
859
+ find(filter?: CollectionFilter<R>, options?: CollectionFindOptions): Promise<R[]>;
860
+ findOne(filter?: CollectionFilter<R>, options?: CollectionFindOptions): Promise<R | null>;
861
+ findById(id: string, options?: CollectionFindOptions): Promise<R | null>;
862
+ exists(filter: CollectionFilter<R>): Promise<boolean>;
863
+ countDocuments(filter?: CollectionFilter<R>): Promise<number>;
864
+ /** Fast count from collection metadata (ignores filters and transactions). */
865
+ estimatedDocumentCount(): Promise<number>;
866
+ distinct<K extends keyof R & string>(field: K | `${string}.${string}`, filter?: CollectionFilter<R>): Promise<(K extends keyof R ? Elem<R[K]> | Exclude<R[K], readonly unknown[]> : unknown)[]>;
867
+ create(data: C): Promise<R>;
868
+ insertMany(data: C[]): Promise<R[]>;
869
+ updateOne(filter: CollectionFilter<R>, update: CollectionUpdate<R>, options?: {
870
+ upsert?: boolean;
871
+ }): Promise<CollectionWriteResult>;
872
+ updateMany(filter: CollectionFilter<R>, update: CollectionUpdate<R>, options?: {
873
+ upsert?: boolean;
874
+ }): Promise<CollectionWriteResult>;
875
+ replaceOne(filter: CollectionFilter<R>, replacement: C, options?: {
876
+ upsert?: boolean;
877
+ }): Promise<CollectionWriteResult>;
878
+ /** Returns the document before the update unless `returnDocument: 'after'` (as mongoose). */
879
+ findOneAndUpdate(filter: CollectionFilter<R>, update: CollectionUpdate<R>, options?: {
880
+ upsert?: boolean;
881
+ returnDocument?: 'before' | 'after';
882
+ projection?: CollectionFindOptions['projection'];
883
+ sort?: CollectionFindOptions['sort'];
884
+ }): Promise<R | null>;
885
+ findByIdAndUpdate(id: string, update: CollectionUpdate<R>, options?: {
886
+ returnDocument?: 'before' | 'after';
887
+ }): Promise<R | null>;
888
+ findOneAndDelete(filter: CollectionFilter<R>, options?: {
889
+ sort?: CollectionFindOptions['sort'];
890
+ }): Promise<R | null>;
891
+ findByIdAndDelete(id: string): Promise<R | null>;
892
+ deleteOne(filter: CollectionFilter<R>): Promise<{
893
+ deletedCount: number;
894
+ }>;
895
+ deleteMany(filter?: CollectionFilter<R>): Promise<{
896
+ deletedCount: number;
897
+ }>;
898
+ /** An aggregation pipeline; type the output with the generic: `aggregate<{ _id: string; n: number }>(…)`. */
899
+ aggregate<T = Record<string, unknown>>(pipeline: Record<string, unknown>[]): Promise<T[]>;
900
+ bulkWrite(ops: CollectionBulkOp<R, C>[], options?: {
901
+ ordered?: boolean;
902
+ }): Promise<CollectionBulkResult>;
903
+ /** A change stream (needs a replica set). */
904
+ watch(pipeline?: Record<string, unknown>[], options?: {
905
+ fullDocument?: 'default' | 'updateLookup' | 'whenAvailable' | 'required';
906
+ }): CollectionChangeStream<R>;
907
+ /** The mongoose `Model`. */
908
+ raw(): Promise<unknown>;
909
+ sync(options?: {
910
+ dryRun?: boolean;
911
+ }): Promise<string[]>;
912
+ drop(): Promise<void>;
913
+ }
914
+
725
915
  type AnyClient = Record<string, unknown>;
726
916
  declare function setDbClient(client: AnyClient): void;
727
917
  declare function getDbClient(): AnyClient;
@@ -775,4 +965,4 @@ declare function workerCount(): number;
775
965
  declare function ignite(config: EFCConfig): Promise<http.Server | undefined>;
776
966
  declare function gracefulShutdown(server: http.Server | undefined, timeoutMs?: number): void;
777
967
 
778
- export { EFCConfig, HttpError, InferCreateInput, InferSchema, type InferTableRecord, type JsonFilter, type ListFilter, ModelOptions, ModelSchema, ModelValidationError, RouteEntry, type ScalarFilter, type StringFilter, type TableAggregateArgs, type TableAggregateResult, type TableCreateData, type TableCreateInput, type TableFindManyArgs, type TableGroupByArgs, type TableInclude, type TableModel, TableOptions, type TableOrderBy, type TableRecord, type TableResult, TableSchema, type TableSelect, type TableUpdateData, type TableUpdateInput, type TableWhere, type TableWhereUnique, type Tables, cache, cacheResponse, compose, db, defineModel, defineTable, getDbClient, getLogger, gracefulShutdown, ignite, isHttpError, logger, scanDir, setDbClient, transaction, workerCount };
968
+ export { type CollectionBulkOp, type CollectionBulkResult, type CollectionChange, type CollectionChangeStream, type CollectionFilter, type CollectionFindOptions, type CollectionModel, type CollectionOptions, CollectionSchema, type CollectionUpdate, type CollectionWriteResult, EFCConfig, HttpError, InferCreateInput, InferSchema, type InferTableRecord, type JsonFilter, type ListFilter, ModelOptions, ModelSchema, ModelValidationError, RouteEntry, type ScalarFilter, SortDirection, type StringFilter, type TableAggregateArgs, type TableAggregateResult, type TableCreateData, type TableCreateInput, type TableFindManyArgs, type TableGroupByArgs, type TableInclude, type TableModel, TableOptions, type TableOrderBy, type TableRecord, type TableResult, TableSchema, type TableSelect, type TableUpdateData, type TableUpdateInput, type TableWhere, type TableWhereUnique, type Tables, cache, cacheResponse, compose, db, defineCollection, defineModel, defineTable, getDbClient, getLogger, gracefulShutdown, ignite, isHttpError, logger, scanDir, setDbClient, transaction, workerCount };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import http from 'node:http';
2
- import { S as Simplify, I as InferSchema, b as InferCreateInput, M as ModelSchema, c as ModelOptions, d as InferredModel, e as TableSchema, f as TableOptions, R as RouteEntry, E as EFCConfig } from './types-gyvA7BtO.js';
3
- export { A as AuthStrategy, C as CacheConfig, g as CorsConfig, D as DatabaseEngine, h as DatabasePoolConfig, i as DefaultOperator, F as FieldDefinition, j as Filter, k as FilterOperators, l as FindOptions, m as IndexDefinition, n as InferCreate, o as InferRecord, L as LoggingConfig, p as MigrationContext, q as ModelCRUD, r as ModelQueryOptions, s as ModelRecord, Q as QueryLogConfig, t as RequestSchema, u as RouteMeta, v as RouteMethodMeta, w as RouteSchema, x as ScalarKeys, y as SchemaField, z as SortDirection, B as TableFieldDefinition, G as TableRelation, H as TableSchemaField, a as TaskDefinition, T as TaskOptions, U as Update, V as ValidationIssue, J as Validator } from './types-gyvA7BtO.js';
2
+ import { S as Simplify, I as InferSchema, b as InferCreateInput, M as ModelSchema, c as ModelOptions, d as InferredModel, e as TableSchema, f as TableOptions, g as SortDirection, C as CollectionSchema, R as RouteEntry, E as EFCConfig } from './types-BY-ObnZH.js';
3
+ export { A as AuthStrategy, h as CacheConfig, i as CollectionFieldDefinition, j as CorsConfig, D as DatabaseEngine, k as DatabasePoolConfig, l as DefaultOperator, F as FieldDefinition, m as Filter, n as FilterOperators, o as FindOptions, G as GeoPoint, p as IndexDefinition, q as InferCreate, r as InferRecord, L as LoggingConfig, s as MigrationContext, t as ModelCRUD, u as ModelQueryOptions, v as ModelRecord, Q as QueryLogConfig, w as RequestSchema, x as RouteMeta, y as RouteMethodMeta, z as RouteSchema, B as ScalarKeys, H as SchemaField, J as TableFieldDefinition, K as TableRelation, N as TableSchemaField, a as TaskDefinition, T as TaskOptions, U as Update, V as ValidationIssue, O as Validator } from './types-BY-ObnZH.js';
4
4
  import { Logger } from 'pino';
5
5
  import { Request, RequestHandler } from 'express';
6
6
  export { listTasks } from './tasks/index.js';
@@ -722,6 +722,196 @@ declare function defineModel<T extends object = never, const S extends ModelSche
722
722
  */
723
723
  declare function defineTable<const S extends TableSchema, const O extends TableOptions = object>(name: string, schema: S, options?: O): TableModel<S, O>;
724
724
 
725
+ type AnyRecord = Record<string, unknown>;
726
+ interface CollectionOptions extends ModelOptions {
727
+ /** Default collation for this collection's queries, e.g. `{ locale: 'en', strength: 2 }`. */
728
+ collation?: AnyRecord;
729
+ }
730
+ interface CollectionFindOptions {
731
+ /** Inclusion (`{ name: 1 }`) or exclusion (`{ secret: 0 }`) projection. */
732
+ projection?: Record<string, 0 | 1 | boolean | AnyRecord>;
733
+ sort?: Record<string, SortDirection | {
734
+ $meta: 'textScore';
735
+ }>;
736
+ skip?: number;
737
+ limit?: number;
738
+ /** Resolve `objectId` fields that have a `ref` into the referenced documents. */
739
+ populate?: string | string[];
740
+ collation?: AnyRecord;
741
+ }
742
+ interface CollectionWriteResult {
743
+ matchedCount: number;
744
+ modifiedCount: number;
745
+ upsertedCount: number;
746
+ upsertedId: string | null;
747
+ }
748
+ interface CollectionBulkResult {
749
+ insertedCount: number;
750
+ matchedCount: number;
751
+ modifiedCount: number;
752
+ deletedCount: number;
753
+ upsertedCount: number;
754
+ }
755
+ /** A change stream: iterate with `for await`, stop with `close()` (or `break`). */
756
+ interface CollectionChangeStream<R> extends AsyncIterable<CollectionChange<R>> {
757
+ close(): Promise<void>;
758
+ }
759
+ interface CollectionChange<R> {
760
+ operationType: string;
761
+ /** The document id. */
762
+ id: string | undefined;
763
+ /** The new document (inserts, replaces; updates with `fullDocument: 'updateLookup'`). */
764
+ fullDocument?: R;
765
+ updateDescription?: {
766
+ updatedFields: AnyRecord;
767
+ removedFields: string[];
768
+ };
769
+ raw: AnyRecord;
770
+ }
771
+ /**
772
+ * Defines a MongoDB-native model with mongoose's vocabulary — `find` with projections,
773
+ * `findOneAndUpdate` with upsert, `bulkWrite`, aggregation pipelines, change streams —
774
+ * and BSON types (`decimal128`, `long`, `geoPoint`, `binary`). Record and input types are
775
+ * inferred from the schema. Throws at first use on a PostgreSQL connection.
776
+ */
777
+ declare function defineCollection<const S extends CollectionSchema, const O extends CollectionOptions = object>(name: string, schema: S, options?: O): CollectionModel<S, O>;
778
+ type Rec<S, O> = Simplify<InferSchema<S, O> & {
779
+ id: string;
780
+ }>;
781
+ type Elem<V> = V extends readonly (infer E)[] ? E : never;
782
+ /** A query filter: fields (with an array's element for "contains"), operators, dotted paths. */
783
+ type CollectionFilter<R> = {
784
+ [K in keyof R]?: R[K] | Elem<R[K]> | null | {
785
+ [op: `$${string}`]: unknown;
786
+ };
787
+ } & {
788
+ [path: `${string}.${string}`]: unknown;
789
+ _id?: unknown;
790
+ $and?: CollectionFilter<R>[];
791
+ $or?: CollectionFilter<R>[];
792
+ $nor?: CollectionFilter<R>[];
793
+ $text?: {
794
+ $search: string;
795
+ $language?: string;
796
+ $caseSensitive?: boolean;
797
+ };
798
+ $expr?: unknown;
799
+ };
800
+ type Fields<R> = {
801
+ [K in keyof R]?: unknown;
802
+ } & {
803
+ [path: `${string}.${string}`]: unknown;
804
+ };
805
+ /** Plain fields (shorthand for `$set`) and/or update operators. */
806
+ type CollectionUpdate<R> = Partial<R> | {
807
+ $set?: Fields<R>;
808
+ $unset?: Fields<R>;
809
+ $inc?: Fields<R>;
810
+ $mul?: Fields<R>;
811
+ $min?: Fields<R>;
812
+ $max?: Fields<R>;
813
+ $push?: Fields<R>;
814
+ $pull?: Fields<R>;
815
+ $addToSet?: Fields<R>;
816
+ $pop?: Fields<R>;
817
+ $rename?: Record<string, string>;
818
+ $setOnInsert?: Fields<R>;
819
+ $currentDate?: Fields<R>;
820
+ };
821
+ type CollectionBulkOp<R, C> = {
822
+ insertOne: {
823
+ document: C;
824
+ };
825
+ } | {
826
+ updateOne: {
827
+ filter: CollectionFilter<R>;
828
+ update: CollectionUpdate<R>;
829
+ upsert?: boolean;
830
+ };
831
+ } | {
832
+ updateMany: {
833
+ filter: CollectionFilter<R>;
834
+ update: CollectionUpdate<R>;
835
+ upsert?: boolean;
836
+ };
837
+ } | {
838
+ replaceOne: {
839
+ filter: CollectionFilter<R>;
840
+ replacement: C;
841
+ upsert?: boolean;
842
+ };
843
+ } | {
844
+ deleteOne: {
845
+ filter: CollectionFilter<R>;
846
+ };
847
+ } | {
848
+ deleteMany: {
849
+ filter: CollectionFilter<R>;
850
+ };
851
+ };
852
+ interface CollectionModel<S, O = object, R = Rec<S, O>, C = InferCreateInput<S>> {
853
+ readonly name: string;
854
+ /** Inferred types: `InferRecord<typeof Place>`, `InferCreate<typeof Place>`. */
855
+ readonly $types?: {
856
+ record: R;
857
+ create: C;
858
+ };
859
+ find(filter?: CollectionFilter<R>, options?: CollectionFindOptions): Promise<R[]>;
860
+ findOne(filter?: CollectionFilter<R>, options?: CollectionFindOptions): Promise<R | null>;
861
+ findById(id: string, options?: CollectionFindOptions): Promise<R | null>;
862
+ exists(filter: CollectionFilter<R>): Promise<boolean>;
863
+ countDocuments(filter?: CollectionFilter<R>): Promise<number>;
864
+ /** Fast count from collection metadata (ignores filters and transactions). */
865
+ estimatedDocumentCount(): Promise<number>;
866
+ distinct<K extends keyof R & string>(field: K | `${string}.${string}`, filter?: CollectionFilter<R>): Promise<(K extends keyof R ? Elem<R[K]> | Exclude<R[K], readonly unknown[]> : unknown)[]>;
867
+ create(data: C): Promise<R>;
868
+ insertMany(data: C[]): Promise<R[]>;
869
+ updateOne(filter: CollectionFilter<R>, update: CollectionUpdate<R>, options?: {
870
+ upsert?: boolean;
871
+ }): Promise<CollectionWriteResult>;
872
+ updateMany(filter: CollectionFilter<R>, update: CollectionUpdate<R>, options?: {
873
+ upsert?: boolean;
874
+ }): Promise<CollectionWriteResult>;
875
+ replaceOne(filter: CollectionFilter<R>, replacement: C, options?: {
876
+ upsert?: boolean;
877
+ }): Promise<CollectionWriteResult>;
878
+ /** Returns the document before the update unless `returnDocument: 'after'` (as mongoose). */
879
+ findOneAndUpdate(filter: CollectionFilter<R>, update: CollectionUpdate<R>, options?: {
880
+ upsert?: boolean;
881
+ returnDocument?: 'before' | 'after';
882
+ projection?: CollectionFindOptions['projection'];
883
+ sort?: CollectionFindOptions['sort'];
884
+ }): Promise<R | null>;
885
+ findByIdAndUpdate(id: string, update: CollectionUpdate<R>, options?: {
886
+ returnDocument?: 'before' | 'after';
887
+ }): Promise<R | null>;
888
+ findOneAndDelete(filter: CollectionFilter<R>, options?: {
889
+ sort?: CollectionFindOptions['sort'];
890
+ }): Promise<R | null>;
891
+ findByIdAndDelete(id: string): Promise<R | null>;
892
+ deleteOne(filter: CollectionFilter<R>): Promise<{
893
+ deletedCount: number;
894
+ }>;
895
+ deleteMany(filter?: CollectionFilter<R>): Promise<{
896
+ deletedCount: number;
897
+ }>;
898
+ /** An aggregation pipeline; type the output with the generic: `aggregate<{ _id: string; n: number }>(…)`. */
899
+ aggregate<T = Record<string, unknown>>(pipeline: Record<string, unknown>[]): Promise<T[]>;
900
+ bulkWrite(ops: CollectionBulkOp<R, C>[], options?: {
901
+ ordered?: boolean;
902
+ }): Promise<CollectionBulkResult>;
903
+ /** A change stream (needs a replica set). */
904
+ watch(pipeline?: Record<string, unknown>[], options?: {
905
+ fullDocument?: 'default' | 'updateLookup' | 'whenAvailable' | 'required';
906
+ }): CollectionChangeStream<R>;
907
+ /** The mongoose `Model`. */
908
+ raw(): Promise<unknown>;
909
+ sync(options?: {
910
+ dryRun?: boolean;
911
+ }): Promise<string[]>;
912
+ drop(): Promise<void>;
913
+ }
914
+
725
915
  type AnyClient = Record<string, unknown>;
726
916
  declare function setDbClient(client: AnyClient): void;
727
917
  declare function getDbClient(): AnyClient;
@@ -775,4 +965,4 @@ declare function workerCount(): number;
775
965
  declare function ignite(config: EFCConfig): Promise<http.Server | undefined>;
776
966
  declare function gracefulShutdown(server: http.Server | undefined, timeoutMs?: number): void;
777
967
 
778
- export { EFCConfig, HttpError, InferCreateInput, InferSchema, type InferTableRecord, type JsonFilter, type ListFilter, ModelOptions, ModelSchema, ModelValidationError, RouteEntry, type ScalarFilter, type StringFilter, type TableAggregateArgs, type TableAggregateResult, type TableCreateData, type TableCreateInput, type TableFindManyArgs, type TableGroupByArgs, type TableInclude, type TableModel, TableOptions, type TableOrderBy, type TableRecord, type TableResult, TableSchema, type TableSelect, type TableUpdateData, type TableUpdateInput, type TableWhere, type TableWhereUnique, type Tables, cache, cacheResponse, compose, db, defineModel, defineTable, getDbClient, getLogger, gracefulShutdown, ignite, isHttpError, logger, scanDir, setDbClient, transaction, workerCount };
968
+ export { type CollectionBulkOp, type CollectionBulkResult, type CollectionChange, type CollectionChangeStream, type CollectionFilter, type CollectionFindOptions, type CollectionModel, type CollectionOptions, CollectionSchema, type CollectionUpdate, type CollectionWriteResult, EFCConfig, HttpError, InferCreateInput, InferSchema, type InferTableRecord, type JsonFilter, type ListFilter, ModelOptions, ModelSchema, ModelValidationError, RouteEntry, type ScalarFilter, SortDirection, type StringFilter, type TableAggregateArgs, type TableAggregateResult, type TableCreateData, type TableCreateInput, type TableFindManyArgs, type TableGroupByArgs, type TableInclude, type TableModel, TableOptions, type TableOrderBy, type TableRecord, type TableResult, TableSchema, type TableSelect, type TableUpdateData, type TableUpdateInput, type TableWhere, type TableWhereUnique, type Tables, cache, cacheResponse, compose, db, defineCollection, defineModel, defineTable, getDbClient, getLogger, gracefulShutdown, ignite, isHttpError, logger, scanDir, setDbClient, transaction, workerCount };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  configureAuth,
5
5
  configureCache,
6
6
  servePrimaryCache
7
- } from "./chunk-RSZB7VAO.js";
7
+ } from "./chunk-ATL4GYFU.js";
8
8
  import {
9
9
  scanDir
10
10
  } from "./chunk-RS4MXCPW.js";
@@ -15,19 +15,20 @@ import {
15
15
  import {
16
16
  connectMongo,
17
17
  db,
18
+ defineCollection,
18
19
  defineModel,
19
20
  defineTable,
20
21
  getDbClient,
21
22
  setDbClient,
22
23
  transaction
23
- } from "./chunk-6QNLN6AI.js";
24
+ } from "./chunk-RRQ2RK5M.js";
24
25
  import {
25
26
  HttpError,
26
27
  ModelValidationError,
27
28
  isHttpError,
28
29
  setAutoSync,
29
30
  setDbEngine
30
- } from "./chunk-2PBMLMO4.js";
31
+ } from "./chunk-QKQZF573.js";
31
32
  import {
32
33
  configureQueryLog,
33
34
  connectPostgres
@@ -1126,6 +1127,7 @@ export {
1126
1127
  cacheResponse,
1127
1128
  compose,
1128
1129
  db,
1130
+ defineCollection,
1129
1131
  defineModel,
1130
1132
  defineTable,
1131
1133
  getDbClient,