@aeriajs/types 0.0.133 → 0.0.134

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,4 +1,4 @@
1
- import type { FilterOperators, StrictFilter as Filter, WithId, ObjectId } from 'mongodb';
1
+ import type { FilterOperators, StrictFilter as Filter, ObjectId } from 'mongodb';
2
2
  import type { Result, ExtractError } from './result.js';
3
3
  import type { EndpointError } from './endpointError.js';
4
4
  import type { SchemaWithId, InferSchema, PackReferences } from './schema.js';
@@ -41,16 +41,19 @@ export type What<TDocument> = ({
41
41
  [P in keyof InferredDocument]: InferredDocument[P] | null;
42
42
  } : never;
43
43
  export type Projection<TDocument> = keyof TDocument | '_id' extends infer DocumentProp ? [DocumentProp] extends [string] ? DocumentProp[] : string[] : never;
44
- export type QuerySort<TDocument> = Partial<Record<keyof WithId<TDocument>, 1 | -1>>;
45
- export type CountPayload<TDocument extends WithId<unknown>> = {
44
+ export type WithStringId<TDocument> = TDocument & {
45
+ _id: ObjectId | string;
46
+ };
47
+ export type QuerySort<TDocument> = Partial<Record<keyof WithStringId<TDocument>, 1 | -1>>;
48
+ export type CountPayload<TDocument extends WithStringId<unknown>> = {
46
49
  filters?: Filters<TDocument>;
47
50
  };
48
- export type GetPayload<TDocument extends WithId<unknown>> = {
51
+ export type GetPayload<TDocument extends WithStringId<unknown>> = {
49
52
  filters: Filters<TDocument>;
50
53
  project?: Projection<TDocument>;
51
54
  populate?: (keyof TDocument)[];
52
55
  };
53
- export type GetAllPayload<TDocument extends WithId<unknown>> = {
56
+ export type GetAllPayload<TDocument extends WithStringId<unknown>> = {
54
57
  filters?: Filters<TDocument>;
55
58
  project?: Projection<TDocument>;
56
59
  offset?: number;
@@ -58,11 +61,11 @@ export type GetAllPayload<TDocument extends WithId<unknown>> = {
58
61
  sort?: QuerySort<TDocument>;
59
62
  populate?: (keyof TDocument)[];
60
63
  };
61
- export type InsertPayload<TDocument extends WithId<unknown>> = {
64
+ export type InsertPayload<TDocument extends WithStringId<unknown>> = {
62
65
  what: What<TDocument>;
63
66
  project?: Projection<TDocument>;
64
67
  };
65
- export type RemovePayload<TDocument extends WithId<unknown>> = {
68
+ export type RemovePayload<TDocument extends WithStringId<unknown>> = {
66
69
  filters: Filters<TDocument>;
67
70
  };
68
71
  export type RemoveAllPayload = {
@@ -82,7 +85,7 @@ export type GetAllReturnType<TDocument> = Result.Either<ExtractError<Unpaginated
82
85
  data: TDocument[];
83
86
  pagination: Pagination;
84
87
  }>;
85
- export type CollectionFunctions<TSchema extends JsonSchema = JsonSchema> = SchemaWithId<TSchema> extends infer InferredDocument ? InferredDocument extends WithId<unknown> ? {
88
+ export type CollectionFunctions<TSchema extends JsonSchema = JsonSchema> = SchemaWithId<TSchema> extends infer InferredDocument ? InferredDocument extends WithStringId<unknown> ? {
86
89
  count: (payload: CountPayload<InferredDocument>) => Promise<CountReturnType>;
87
90
  get: (payload: GetPayload<InferredDocument>) => Promise<GetReturnType<InferredDocument>>;
88
91
  getAll: (payload?: GetAllPayload<InferredDocument>) => Promise<GetAllReturnType<InferredDocument>>;
@@ -94,7 +97,9 @@ export type CollectionFunctions<TSchema extends JsonSchema = JsonSchema> = Schem
94
97
  removeFile: (payload: RemoveFilePayload) => Promise<unknown>;
95
98
  unpaginatedGetAll: (payload?: GetAllPayload<InferredDocument>) => Promise<UnpaginatedGetAllReturnType<InferredDocument>>;
96
99
  } : never : never;
97
- export type CollectionFunctionsSDK<TSchema extends JsonSchema = JsonSchema> = SchemaWithId<TSchema> extends infer InferredDocument ? InferredDocument extends WithId<unknown> ? {
100
+ export type CollectionFunctionsSDK<TSchema extends JsonSchema = JsonSchema> = SchemaWithId<TSchema, {
101
+ useObjectIds: false;
102
+ }> extends infer InferredDocument ? InferredDocument extends WithStringId<unknown> ? {
98
103
  count: (payload: CountPayload<InferredDocument>) => Promise<WithACErrors<CountReturnType>>;
99
104
  get: (payload: GetPayload<InferredDocument>) => Promise<WithACErrors<GetReturnType<InferredDocument>>>;
100
105
  getAll: (payload?: GetAllPayload<InferredDocument>) => Promise<WithACErrors<GetAllReturnType<InferredDocument>>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.133",
3
+ "version": "0.0.134",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",