Implement code review suggestions

This commit is contained in:
Ivan
2025-04-11 01:51:37 +02:00
parent 755f310c93
commit 3194dc7d58
7 changed files with 199 additions and 292 deletions

69
dist/index.js vendored
View File

@@ -124,14 +124,14 @@ import type { RecordService } from 'pocketbase'`;
var RECORD_TYPE_COMMENT = `// Record types for each collection`;
var RESPONSE_TYPE_COMMENT = `// Response types include system fields and match responses from the PocketBase API`;
var ALL_RECORD_RESPONSE_COMMENT = `// Types containing all Records and Responses, useful for creating typing helper functions`;
var TYPED_POCKETBASE_COMMENT = `// Type for usage with type asserted PocketBase instance
var TYPED_POCKETBASE_TYPE = `// Type for usage with type asserted PocketBase instance
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions
export type TypedPocketBase = {
collection<T extends keyof CollectionResponses>(
idOrName: T
): RecordService<CollectionResponses[T]>;
} & PocketBase;`;
): RecordService<CollectionResponses[T]>
} & PocketBase`;
var EXPAND_GENERIC_NAME = "expand";
var DATE_STRING_TYPE_NAME = `IsoDateString`;
var AUTODATE_STRING_TYPE_NAME = `IsoAutoDateString`;
@@ -149,66 +149,57 @@ export type BaseSystemFields<T = never> = {
collectionName: Collections
expand?: T
}`;
var BASE_SYSTEM_CREATE_FIELDS_DEFINITION = `export type BaseSystemCreateFields = {
id?: ${RECORD_ID_STRING_NAME}
}`;
var BASE_SYSTEM_UPDATE_FIELDS_DEFINITION = `export type BaseSystemUpdateFields = unknown`;
var AUTH_SYSTEM_FIELDS_DEFINITION = `export type AuthSystemFields<T = never> = {
email: string
emailVisibility: boolean
username: string
verified: boolean
} & BaseSystemFields<T>`;
var AUTH_SYSTEM_CREATE_FIELDS_DEFINITION = `export type AuthSystemCreateFields = {
var UTILITY_TYPES = `// Utility types for create/update operations
// Create type for Auth collections
export type CreateAuth<T> = {
id?: ${RECORD_ID_STRING_NAME}
email: string
emailVisibility?: boolean
password: string
passwordConfirm: string
verified?: boolean
}`;
var AUTH_SYSTEM_UPDATE_FIELDS_DEFINITION = `export type AuthSystemUpdateFields = {
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
}, 'id'>
// Create type for Base collections
export type CreateBase<T> = {
id?: RecordIdString
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString | (IsoAutoDateString | undefined) ? never : K]: T[K]
}, 'id'>
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & {
email?: string
emailVisibility?: boolean
oldPassword?: string
password?: string
passwordConfirm?: string
verified?: boolean
}`;
var UTILITY_TYPES = `/** Utility types for PocketBase record operations */
// Helper to determine if a collection is Auth
type IsAuthCollection<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields ? true : false;
// Utility type that omits fields of type IsoAutoDateString
type OmitAutodate<T> = {
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
};
// Create type for Auth collections
export type CreateAuth<T> = OmitAutodate<Omit<T, 'id'>> & AuthSystemCreateFields;
// Create type for Base collections
export type CreateBase<T> = OmitAutodate<Omit<T, 'id'>> & BaseSystemCreateFields;
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & AuthSystemUpdateFields;
}
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>> & BaseSystemUpdateFields;
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>>
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
CollectionResponses[T] extends AuthSystemFields
? CreateAuth<CollectionRecords[T]>
: CreateBase<CollectionRecords[T]>;
: CreateBase<CollectionRecords[T]>
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
CollectionResponses[T] extends AuthSystemFields
? UpdateAuth<CollectionRecords[T]>
: UpdateBase<CollectionRecords[T]>;`;
: UpdateBase<CollectionRecords[T]>`;
// src/generics.ts
function fieldNameToGeneric(name) {
@@ -305,19 +296,15 @@ function generate(results, options2) {
createCollectionEnum(sortedCollectionNames),
ALIAS_TYPE_DEFINITIONS,
BASE_SYSTEM_FIELDS_DEFINITION,
BASE_SYSTEM_CREATE_FIELDS_DEFINITION,
BASE_SYSTEM_UPDATE_FIELDS_DEFINITION,
AUTH_SYSTEM_FIELDS_DEFINITION,
AUTH_SYSTEM_CREATE_FIELDS_DEFINITION,
AUTH_SYSTEM_UPDATE_FIELDS_DEFINITION,
RECORD_TYPE_COMMENT,
...recordTypes,
responseTypes.join("\n"),
ALL_RECORD_RESPONSE_COMMENT,
createCollectionRecords(sortedCollectionNames),
createCollectionResponses(sortedCollectionNames),
options2.sdk && TYPED_POCKETBASE_COMMENT,
UTILITY_TYPES
UTILITY_TYPES,
options2.sdk && TYPED_POCKETBASE_TYPE
];
return fileParts.filter(Boolean).join("\n\n") + "\n";
}

View File

@@ -6,14 +6,14 @@ import type { RecordService } from 'pocketbase'`
export const RECORD_TYPE_COMMENT = `// Record types for each collection`
export const RESPONSE_TYPE_COMMENT = `// Response types include system fields and match responses from the PocketBase API`
export const ALL_RECORD_RESPONSE_COMMENT = `// Types containing all Records and Responses, useful for creating typing helper functions`
export const TYPED_POCKETBASE_COMMENT = `// Type for usage with type asserted PocketBase instance
export const TYPED_POCKETBASE_TYPE = `// Type for usage with type asserted PocketBase instance
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions
export type TypedPocketBase = {
\tcollection<T extends keyof CollectionResponses>(
\t\tidOrName: T
\t): RecordService<CollectionResponses[T]>;
} & PocketBase;`
\t): RecordService<CollectionResponses[T]>
} & PocketBase`
export const EXPAND_GENERIC_NAME = "expand"
export const DATE_STRING_TYPE_NAME = `IsoDateString`
export const AUTODATE_STRING_TYPE_NAME = `IsoAutoDateString`
@@ -33,12 +33,6 @@ export type BaseSystemFields<T = never> = {
\texpand?: T
}`
export const BASE_SYSTEM_CREATE_FIELDS_DEFINITION = `export type BaseSystemCreateFields = {
\tid?: ${RECORD_ID_STRING_NAME}
}`
export const BASE_SYSTEM_UPDATE_FIELDS_DEFINITION = `export type BaseSystemUpdateFields = unknown`
export const AUTH_SYSTEM_FIELDS_DEFINITION = `export type AuthSystemFields<T = never> = {
\temail: string
\temailVisibility: boolean
@@ -46,55 +40,48 @@ export const AUTH_SYSTEM_FIELDS_DEFINITION = `export type AuthSystemFields<T = n
\tverified: boolean
} & BaseSystemFields<T>`
export const AUTH_SYSTEM_CREATE_FIELDS_DEFINITION = `export type AuthSystemCreateFields = {
export const UTILITY_TYPES = `// Utility types for create/update operations
// Create type for Auth collections
export type CreateAuth<T> = {
\tid?: ${RECORD_ID_STRING_NAME}
\temail: string
\temailVisibility?: boolean
\tpassword: string
\tpasswordConfirm: string
\tverified?: boolean
}`
} & Omit<{
\t[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
}, 'id'>
export const AUTH_SYSTEM_UPDATE_FIELDS_DEFINITION = `export type AuthSystemUpdateFields = {
// Create type for Base collections
export type CreateBase<T> = {
\tid?: RecordIdString
} & Omit<{
\t[K in keyof T as T[K] extends IsoAutoDateString | (IsoAutoDateString | undefined) ? never : K]: T[K]
}, 'id'>
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & {
\temail?: string
\temailVisibility?: boolean
\toldPassword?: string
\tpassword?: string
\tpasswordConfirm?: string
\tverified?: boolean
}`
export const UTILITY_TYPES = `/** Utility types for PocketBase record operations */
// Helper to determine if a collection is Auth
type IsAuthCollection<T extends keyof CollectionResponses> =
\tCollectionResponses[T] extends AuthSystemFields ? true : false;
// Utility type that omits fields of type IsoAutoDateString
type OmitAutodate<T> = {
\t[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
};
// Create type for Auth collections
export type CreateAuth<T> = OmitAutodate<Omit<T, 'id'>> & AuthSystemCreateFields;
// Create type for Base collections
export type CreateBase<T> = OmitAutodate<Omit<T, 'id'>> & BaseSystemCreateFields;
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & AuthSystemUpdateFields;
}
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>> & BaseSystemUpdateFields;
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>>
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
\tIsAuthCollection<T> extends true
\tCollectionResponses[T] extends AuthSystemFields
\t\t? CreateAuth<CollectionRecords[T]>
\t\t: CreateBase<CollectionRecords[T]>;
\t\t: CreateBase<CollectionRecords[T]>
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
\tIsAuthCollection<T> extends true
\tCollectionResponses[T] extends AuthSystemFields
\t\t? UpdateAuth<CollectionRecords[T]>
\t\t: UpdateBase<CollectionRecords[T]>;`;
\t\t: UpdateBase<CollectionRecords[T]>`

View File

@@ -6,18 +6,14 @@ import {
import {
ALIAS_TYPE_DEFINITIONS,
ALL_RECORD_RESPONSE_COMMENT,
AUTH_SYSTEM_CREATE_FIELDS_DEFINITION,
AUTH_SYSTEM_FIELDS_DEFINITION,
AUTH_SYSTEM_UPDATE_FIELDS_DEFINITION,
BASE_SYSTEM_CREATE_FIELDS_DEFINITION,
BASE_SYSTEM_FIELDS_DEFINITION,
BASE_SYSTEM_UPDATE_FIELDS_DEFINITION,
EXPAND_GENERIC_NAME,
EXPORT_COMMENT,
IMPORTS,
RECORD_TYPE_COMMENT,
RESPONSE_TYPE_COMMENT,
TYPED_POCKETBASE_COMMENT,
TYPED_POCKETBASE_TYPE,
UTILITY_TYPES
} from "./constants"
import { createSelectOptions, createTypeField } from "./fields"
@@ -57,19 +53,15 @@ export function generate(
createCollectionEnum(sortedCollectionNames),
ALIAS_TYPE_DEFINITIONS,
BASE_SYSTEM_FIELDS_DEFINITION,
BASE_SYSTEM_CREATE_FIELDS_DEFINITION,
BASE_SYSTEM_UPDATE_FIELDS_DEFINITION,
AUTH_SYSTEM_FIELDS_DEFINITION,
AUTH_SYSTEM_CREATE_FIELDS_DEFINITION,
AUTH_SYSTEM_UPDATE_FIELDS_DEFINITION,
RECORD_TYPE_COMMENT,
...recordTypes,
responseTypes.join("\n"),
ALL_RECORD_RESPONSE_COMMENT,
createCollectionRecords(sortedCollectionNames),
createCollectionResponses(sortedCollectionNames),
options.sdk && TYPED_POCKETBASE_COMMENT,
UTILITY_TYPES,
options.sdk && TYPED_POCKETBASE_TYPE,
]
return fileParts.filter(Boolean).join("\n\n") + "\n"

View File

@@ -35,26 +35,6 @@ export function getSystemFields(type: CollectionRecord["type"]) {
}
}
export function getSystemCreateFields(type: CollectionRecord["type"]) {
switch (type) {
case "auth":
return "AuthSystemCreateFields"
default:
// `view` and `base` collection types share the same system fields (for now)
return "BaseSystemCreateFields"
}
}
export function getSystemUpdateFields(type: CollectionRecord["type"]) {
switch (type) {
case "auth":
return "AuthSystemUpdateFields"
default:
// `view` and `base` collection types share the same system fields (for now)
return "BaseSystemUpdateFields"
}
}
export function getOptionEnumName(recordName: string, fieldName: string) {
return `${toPascalCase(recordName)}${toPascalCase(fieldName)}Options`
}

View File

@@ -36,12 +36,6 @@ export type BaseSystemFields<T = never> = {
expand?: T
}
export type BaseSystemCreateFields = {
id?: RecordIdString
}
export type BaseSystemUpdateFields = unknown
export type AuthSystemFields<T = never> = {
email: string
emailVisibility: boolean
@@ -49,24 +43,6 @@ export type AuthSystemFields<T = never> = {
verified: boolean
} & BaseSystemFields<T>
export type AuthSystemCreateFields = {
id?: RecordIdString
email: string
emailVisibility?: boolean
password: string
passwordConfirm: string
verified?: boolean
}
export type AuthSystemUpdateFields = {
email?: string
emailVisibility?: boolean
oldPassword?: string
password?: string
passwordConfirm?: string
verified?: boolean
}
// Record types for each collection
export type AuthoriginsRecord = {
@@ -239,48 +215,59 @@ export type CollectionResponses = {
users: UsersResponse
}
// Utility types for create/update operations
// Create type for Auth collections
export type CreateAuth<T> = {
id?: RecordIdString
email: string
emailVisibility?: boolean
password: string
passwordConfirm: string
verified?: boolean
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
}, 'id'>
// Create type for Base collections
export type CreateBase<T> = {
id?: RecordIdString
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString | (IsoAutoDateString | undefined) ? never : K]: T[K]
}, 'id'>
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & {
email?: string
emailVisibility?: boolean
oldPassword?: string
password?: string
passwordConfirm?: string
verified?: boolean
}
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>>
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields
? CreateAuth<CollectionRecords[T]>
: CreateBase<CollectionRecords[T]>
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields
? UpdateAuth<CollectionRecords[T]>
: UpdateBase<CollectionRecords[T]>
// Type for usage with type asserted PocketBase instance
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions
export type TypedPocketBase = {
collection<T extends keyof CollectionResponses>(
idOrName: T
): RecordService<CollectionResponses[T]>;
} & PocketBase;
/** Utility types for PocketBase record operations */
// Helper to determine if a collection is Auth
type IsAuthCollection<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields ? true : false;
// Utility type that omits fields of type IsoAutoDateString
type OmitAutodate<T> = {
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
};
// Create type for Auth collections
export type CreateAuth<T> = OmitAutodate<Omit<T, 'id'>> & AuthSystemCreateFields;
// Create type for Base collections
export type CreateBase<T> = OmitAutodate<Omit<T, 'id'>> & BaseSystemCreateFields;
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & AuthSystemUpdateFields;
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>> & BaseSystemUpdateFields;
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
? CreateAuth<CollectionRecords[T]>
: CreateBase<CollectionRecords[T]>;
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
? UpdateAuth<CollectionRecords[T]>
: UpdateBase<CollectionRecords[T]>;
): RecordService<CollectionResponses[T]>
} & PocketBase
"
`;

View File

@@ -46,12 +46,6 @@ export type BaseSystemFields<T = never> = {
expand?: T
}
export type BaseSystemCreateFields = {
id?: RecordIdString
}
export type BaseSystemUpdateFields = unknown
export type AuthSystemFields<T = never> = {
email: string
emailVisibility: boolean
@@ -59,24 +53,6 @@ export type AuthSystemFields<T = never> = {
verified: boolean
} & BaseSystemFields<T>
export type AuthSystemCreateFields = {
id?: RecordIdString
email: string
emailVisibility?: boolean
password: string
passwordConfirm: string
verified?: boolean
}
export type AuthSystemUpdateFields = {
email?: string
emailVisibility?: boolean
oldPassword?: string
password?: string
passwordConfirm?: string
verified?: boolean
}
// Record types for each collection
export type BooksRecord = {
@@ -96,48 +72,59 @@ export type CollectionResponses = {
books: BooksResponse
}
// Utility types for create/update operations
// Create type for Auth collections
export type CreateAuth<T> = {
id?: RecordIdString
email: string
emailVisibility?: boolean
password: string
passwordConfirm: string
verified?: boolean
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
}, 'id'>
// Create type for Base collections
export type CreateBase<T> = {
id?: RecordIdString
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString | (IsoAutoDateString | undefined) ? never : K]: T[K]
}, 'id'>
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & {
email?: string
emailVisibility?: boolean
oldPassword?: string
password?: string
passwordConfirm?: string
verified?: boolean
}
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>>
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields
? CreateAuth<CollectionRecords[T]>
: CreateBase<CollectionRecords[T]>
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields
? UpdateAuth<CollectionRecords[T]>
: UpdateBase<CollectionRecords[T]>
// Type for usage with type asserted PocketBase instance
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions
export type TypedPocketBase = {
collection<T extends keyof CollectionResponses>(
idOrName: T
): RecordService<CollectionResponses[T]>;
} & PocketBase;
/** Utility types for PocketBase record operations */
// Helper to determine if a collection is Auth
type IsAuthCollection<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields ? true : false;
// Utility type that omits fields of type IsoAutoDateString
type OmitAutodate<T> = {
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
};
// Create type for Auth collections
export type CreateAuth<T> = OmitAutodate<Omit<T, 'id'>> & AuthSystemCreateFields;
// Create type for Base collections
export type CreateBase<T> = OmitAutodate<Omit<T, 'id'>> & BaseSystemCreateFields;
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & AuthSystemUpdateFields;
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>> & BaseSystemUpdateFields;
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
? CreateAuth<CollectionRecords[T]>
: CreateBase<CollectionRecords[T]>;
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
? UpdateAuth<CollectionRecords[T]>
: UpdateBase<CollectionRecords[T]>;
): RecordService<CollectionResponses[T]>
} & PocketBase
"
`;

View File

@@ -33,12 +33,6 @@ export type BaseSystemFields<T = never> = {
expand?: T
}
export type BaseSystemCreateFields = {
id?: RecordIdString
}
export type BaseSystemUpdateFields = unknown
export type AuthSystemFields<T = never> = {
email: string
emailVisibility: boolean
@@ -46,24 +40,6 @@ export type AuthSystemFields<T = never> = {
verified: boolean
} & BaseSystemFields<T>
export type AuthSystemCreateFields = {
id?: RecordIdString
email: string
emailVisibility?: boolean
password: string
passwordConfirm: string
verified?: boolean
}
export type AuthSystemUpdateFields = {
email?: string
emailVisibility?: boolean
oldPassword?: string
password?: string
passwordConfirm?: string
verified?: boolean
}
// Record types for each collection
export type AuthoriginsRecord = {
@@ -236,46 +212,57 @@ export type CollectionResponses = {
users: UsersResponse
}
// Utility types for create/update operations
// Create type for Auth collections
export type CreateAuth<T> = {
id?: RecordIdString
email: string
emailVisibility?: boolean
password: string
passwordConfirm: string
verified?: boolean
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
}, 'id'>
// Create type for Base collections
export type CreateBase<T> = {
id?: RecordIdString
} & Omit<{
[K in keyof T as T[K] extends IsoAutoDateString | (IsoAutoDateString | undefined) ? never : K]: T[K]
}, 'id'>
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & {
email?: string
emailVisibility?: boolean
oldPassword?: string
password?: string
passwordConfirm?: string
verified?: boolean
}
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>>
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields
? CreateAuth<CollectionRecords[T]>
: CreateBase<CollectionRecords[T]>
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields
? UpdateAuth<CollectionRecords[T]>
: UpdateBase<CollectionRecords[T]>
// Type for usage with type asserted PocketBase instance
// https://github.com/pocketbase/js-sdk#specify-typescript-definitions
export type TypedPocketBase = {
collection<T extends keyof CollectionResponses>(
idOrName: T
): RecordService<CollectionResponses[T]>;
} & PocketBase;
/** Utility types for PocketBase record operations */
// Helper to determine if a collection is Auth
type IsAuthCollection<T extends keyof CollectionResponses> =
CollectionResponses[T] extends AuthSystemFields ? true : false;
// Utility type that omits fields of type IsoAutoDateString
type OmitAutodate<T> = {
[K in keyof T as T[K] extends IsoAutoDateString ? never : K]: T[K]
};
// Create type for Auth collections
export type CreateAuth<T> = OmitAutodate<Omit<T, 'id'>> & AuthSystemCreateFields;
// Create type for Base collections
export type CreateBase<T> = OmitAutodate<Omit<T, 'id'>> & BaseSystemCreateFields;
// Update type for Auth collections
export type UpdateAuth<T> = Partial<Omit<T, keyof AuthSystemFields>> & AuthSystemUpdateFields;
// Update type for Base collections
export type UpdateBase<T> = Partial<Omit<T, keyof BaseSystemFields>> & BaseSystemUpdateFields;
// Get the correct create type for any collection
export type Create<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
? CreateAuth<CollectionRecords[T]>
: CreateBase<CollectionRecords[T]>;
// Get the correct update type for any collection
export type Update<T extends keyof CollectionResponses> =
IsAuthCollection<T> extends true
? UpdateAuth<CollectionRecords[T]>
: UpdateBase<CollectionRecords[T]>;
): RecordService<CollectionResponses[T]>
} & PocketBase