import { GetNumberOfPathSlash } from './validID'; export type ErrorUndefined = `Error: undefined is not a valid Firestore type`; export type ErrorNullBanned = `Error: Null type is banned in the setting`; export type ErrorTypesBanned = `Error: This type(s) is banned in the setting`; export type ErrorDirectNested = `Error: Direct Nested Array is not a valid Firestore type`; export type ErrorFieldValueInArray = `Error: Field Value is not a valid data type in array, directly or indirectly`; export type ErrorUnassignedAbleFieldValue = `Error: Please do not directly assign Increment, Array Remove and Array Union Field Value`; export type ErrorDeleteFieldMerge = `Error: To use deleteField, please set 'merge' to 'true' or set 'mergeFields with an array, empty array also fine' in the options parameter.`; export type ErrorDeleteFieldUnion = `Error: To use 'deleteField()' on '${T}', please union 'Delete' type with type of '${T}' in the type definition(MetaTypeCreator)`; export type ErrorPleaseDoConstAssertion = `Error: Please assert the value as const eg:''a' as const'`; export type ErrorCollectionIDString = `Error: Collection ID type must be string literal and cannot be string,, please check your Meta Type.`; export type ErrorEndOfID = `Error: ID or Path cannot end in a forward slash '/'`; export type ErrorInvalidDocumentOrCollectionID = `Error: ${T} ${Type} cannot contains ${Type extends 'ID' ? `forward slash '/', ` : ``}double dots '..' and double underscore '__' (except "__name__")`; export type ErrorInvalidDocumentOrCollectionIDStart = `Error: ${T} ID cannot start with a dot '.'`; export type ErrorEmptyDocumentOrCollectionID = `Error: ${T} ID is empty`; export type ErrorNumberOfForwardSlashIsNotEqual = `Error: ${GetNumberOfPathSlash extends 0 ? `The type in need is ${Type}.${string extends Value ? `Detected type is 'string', you seem to forget to assert your value as const, eg: ''a/b/c' as const'` : ''}` : `Invalid query, forward slash count mismatched`}, current count is ${GetNumberOfPathSlash}, need ${GetNumberOfPathSlash}.`; export type ErrorEmptyUpdate = `Error: Update data cannot be empty object literal unless the empty object belong to nested properties of UpdateNoFlatten operation, eg: 'updateDocNoFlatten(docRef, { a: { } } )'`; export type ErrorPossiblyUndefinedAsArrayElement = `Error: You cannot assign PossiblyUndefined as array element, eg: 'PossiblyUndefined[]', you can however indirectly assign PossiblyUndefined in array, eg: < { a : number | PossiblyUndefined }[] >`; export type ErrorMoreThanOnceDocSnapshotInCursor = `Error: If cursors has a DocumentSnapshot(or QueryDocumentSnapshot) argument, then DocumentSnapshot(or QueryDocumentSnapshot) should be the one and only argument`; export type ErrorLimitInvalidNumber = `Error: do not use negative, 0 or decimal value`; export type ErrorLimitToLastOrderBy = `Error: You must specify at least one orderBy clause for limitToLast queries`; export type ErrorWhereCompareValueMustBeArray = `Error: '${T}' is not an array, you can only use 'array-contains' and 'array-contains-any' on '${T}' if '${T}' is an array data type`; export type ErrorWhereOrderByAndInEquality = `Error: Invalid query. You have a where filter with an inequality '<, <=, !=, not-in, >, or >=' on field '${WhereField & string}' and so you must also use '${WhereField & string}' as your first argument to orderBy(), but your first orderBy() is on field '${OrderByField & string}' instead.`; export type ErrorWhereOrderByEquality = `Error: You can't order your query by a field included in an equality '==' or 'in' clause.`; export type ErrorWhereNotInArrayContainsAny = `Error: You can use at most one 'in, not-in, or array-contains-any' clause per query. You can't combine 'in, not-in, and array-contains-any' in the same query.`; export type ErrorWhereNotInNotEqual = `Error: You can't combine 'not-in' with not equals '!='.`; export type ErrorWhereArrayContainsArrayContainsAny = `You can use at most one array-contains clause per query. You can't combine 'array-contains' with 'array-contains-any.'`; export type ErrorWhereInequalityOpStrSameField = `Invalid query. All where filters with an inequality '<, <=, !=, not-in, >, or >=' must be on the same field path.`; export type ErrorWhereOnlyOneNotEqual = `Error: You cannot use more than one '!=' filter.`; export type ErrorWhereNoNeverEmptyArray = `Error: No Empty Array 'never[]' in 'in, not-in, array-contains-any' filter`; export type ErrorCursorTooManyArguments = `Error: Too many arguments provided to 'startAt/startAfter/endAt/endBefore'. The number of arguments must be less than or equal to the number of 'orderBy()' clauses than come before it`; export type ErrorUnknownMember = `Error: The value might be incorrect or '${T & string}' is an unknown property`; export type ErrorWhereDocumentFieldPath = `If field path is document ID, then value must be string`; export type ErrorWhere__name__ = `Error: Don't use '__name__' directly as where's field path, use 'documentId()' sentinel field path instead.`; export type ErrorArrayFieldValueEmpty = `Error: arrayUnion and arrayRemove need at least 1 argument`; export type ErrorEmptyCursor = `Error: cursor need at least 1 argument.`; export type ErrorCursorNoArray = `Error: cursor rest parameter must be tuple type, not array type. Use const assertion to transform array type to tuple type`; export type ErrorAutoIdTypeMustBeWideString = `Error: Only document with wide 'string' type can generate auto id, the current type is literal type '${T}'`; export type ErrorWhereInOrNotInValueIsNotArray = `Error: The value provided to 'in' or 'not-in' comparator must be array of type '${T}'`; export type ErrorNonTopLevelDeleteField = `Error: In non-flatten operations, deleteField() must appear at top level`; export type ErrorDocIdIncorrectType = 'Error: DocId must be single/multiple argument of string or CollectionReference'; export type ErrorKeyNotExist = `Error: The key '${T}' does not exist`; export type ErrorMsgs = ErrorUndefined | ErrorNullBanned | ErrorTypesBanned | ErrorDirectNested | ErrorFieldValueInArray | ErrorEmptyDocumentOrCollectionID<'Document' | 'Collection'> | ErrorUnassignedAbleFieldValue | ErrorDeleteFieldMerge | ErrorDeleteFieldUnion | ErrorNumberOfForwardSlashIsNotEqual | ErrorPleaseDoConstAssertion | ErrorEndOfID | ErrorCollectionIDString | ErrorInvalidDocumentOrCollectionID<'Document' | 'Collection', 'ID' | 'Path'> | ErrorInvalidDocumentOrCollectionIDStart<'Document' | 'Collection'> | ErrorEmptyUpdate | ErrorMoreThanOnceDocSnapshotInCursor | ErrorLimitInvalidNumber | ErrorLimitToLastOrderBy | ErrorWhereOrderByAndInEquality | ErrorWhereCompareValueMustBeArray | ErrorWhereOrderByEquality | ErrorWhereNotInArrayContainsAny | ErrorWhereArrayContainsArrayContainsAny | ErrorWhereInequalityOpStrSameField | ErrorWhereOnlyOneNotEqual | ErrorCursorTooManyArguments | ErrorUnknownMember | ErrorWhereDocumentFieldPath | ErrorWhere__name__ | ErrorWhereNoNeverEmptyArray | ErrorArrayFieldValueEmpty | ErrorEmptyCursor | ErrorCursorNoArray | ErrorAutoIdTypeMustBeWideString | ErrorWhereInOrNotInValueIsNotArray | ErrorNonTopLevelDeleteField | ErrorDocIdIncorrectType | ErrorKeyNotExist; export type ReplaceErrorMsgsWithNever = T extends ErrorMsgs ? never : T; export type NoUndefinedAndBannedTypes = Data extends undefined ? ErrorUndefined : Data extends BannedTypes ? BannedTypes extends null ? ErrorNullBanned : ErrorTypesBanned : Data extends ErrorUndefined ? never : Data; export type NoDirectNestedArray = Data extends unknown[][] ? ErrorDirectNested : Output;