@datrix/core 0.1.0 → 0.1.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.
- package/dist/index.d.mts +15 -6
- package/dist/index.d.ts +15 -6
- package/dist/index.js +36 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -37,7 +37,7 @@ type FallbackWhereClause = {
|
|
|
37
37
|
$not?: FallbackWhereClause;
|
|
38
38
|
};
|
|
39
39
|
type TypedWhereClause<T extends DatrixEntry> = Writable<{
|
|
40
|
-
[K in keyof T]?: T[K] extends RelationInput<infer R extends DatrixEntry> ? WhereClause<R> : T[K] extends ScalarValue ? T[K] | ComparisonOperators<T[K]
|
|
40
|
+
[K in keyof T]?: T[K] extends RelationInput<infer R extends DatrixEntry> ? WhereClause<R> : NonNullable<T[K]> extends DatrixEntry ? WhereClause<NonNullable<T[K]>> : NonNullable<T[K]> extends DatrixEntry[] ? WhereClause<NonNullable<T[K]>[number]> : NonNullable<T[K]> extends ScalarValue ? NonNullable<T[K]> | ComparisonOperators<NonNullable<T[K]>> : never;
|
|
41
41
|
}> & LogicalOperators<T>;
|
|
42
42
|
type WhereClause<T extends DatrixEntry = DatrixRecord> = DatrixRecord extends T ? FallbackWhereClause : TypedWhereClause<T>;
|
|
43
43
|
type SelectClause<T extends DatrixEntry = DatrixRecord> = (DatrixRecord extends T ? readonly string[] : readonly (keyof T)[]) | "*" | (DatrixRecord extends T ? string : keyof T);
|
|
@@ -49,9 +49,11 @@ type PopulateOptions<T extends DatrixEntry> = {
|
|
|
49
49
|
readonly offset?: number | undefined;
|
|
50
50
|
readonly orderBy?: QueryOrderBy | undefined;
|
|
51
51
|
};
|
|
52
|
-
type
|
|
53
|
-
|
|
52
|
+
type TypedPopulateValue<T> = NonNullable<T> extends DatrixEntry ? PopulateOptions<NonNullable<T>> | "*" | boolean : NonNullable<T> extends DatrixEntry[] ? PopulateOptions<NonNullable<T>[number]> | "*" | boolean : PopulateOptions<DatrixRecord> | "*" | boolean;
|
|
53
|
+
type TypedPopulateClause<T extends DatrixEntry> = {
|
|
54
|
+
readonly [K in keyof T]?: TypedPopulateValue<T[K]>;
|
|
54
55
|
};
|
|
56
|
+
type PopulateClause<T extends DatrixEntry = DatrixRecord> = boolean | "*" | "true" | (DatrixRecord extends T ? readonly string[] : readonly (keyof T)[]) | (DatrixRecord extends T ? Record<string, PopulateOptions<DatrixRecord> | "*" | boolean> : TypedPopulateClause<T>);
|
|
55
57
|
type OrderDirection = "asc" | "desc";
|
|
56
58
|
type OrderByItem<T extends DatrixEntry> = {
|
|
57
59
|
readonly field: keyof T;
|
|
@@ -367,6 +369,8 @@ interface AuthenticatedUser<TRoles extends string = string, TUser extends Datrix
|
|
|
367
369
|
password: string;
|
|
368
370
|
passwordSalt: string;
|
|
369
371
|
role: TRoles;
|
|
372
|
+
resetToken?: string;
|
|
373
|
+
resetTokenExpiry?: Date;
|
|
370
374
|
}
|
|
371
375
|
interface AuthUser {
|
|
372
376
|
readonly id: number;
|
|
@@ -857,8 +861,8 @@ declare function isLogicalOperator(operator: string): operator is (typeof LOGICA
|
|
|
857
861
|
declare function requiresArrayValue(operator: string): boolean;
|
|
858
862
|
declare function requiresConditions(operator: string): boolean;
|
|
859
863
|
declare function getOperatorValueType(operator: string): OperatorValueType | undefined;
|
|
860
|
-
declare const
|
|
861
|
-
declare const
|
|
864
|
+
declare const DATRIX_META_MODEL = "_datrix";
|
|
865
|
+
declare const DATRIX_META_KEY_PREFIX = "_schema_";
|
|
862
866
|
declare const FIELD_NAME_PATTERN: RegExp;
|
|
863
867
|
declare const CONTROL_CHARS_PATTERN: RegExp;
|
|
864
868
|
declare const RESERVED_FIELD_NAMES: readonly ["__proto__", "constructor", "prototype"];
|
|
@@ -1098,8 +1102,13 @@ declare const DEFAULT_API_AUTH_CONFIG: {
|
|
|
1098
1102
|
readonly register: "/auth/register";
|
|
1099
1103
|
readonly logout: "/auth/logout";
|
|
1100
1104
|
readonly me: "/auth/me";
|
|
1105
|
+
readonly forgotPassword: "/auth/forgot-password";
|
|
1106
|
+
readonly resetPassword: "/auth/reset-password";
|
|
1101
1107
|
readonly disableRegister: false;
|
|
1102
1108
|
};
|
|
1109
|
+
readonly passwordReset: {
|
|
1110
|
+
readonly tokenExpirySeconds: 3600;
|
|
1111
|
+
};
|
|
1103
1112
|
};
|
|
1104
1113
|
|
|
1105
1114
|
type ResponseData<T = unknown> = {
|
|
@@ -1932,4 +1941,4 @@ declare function getDatrixMetaSchema(): {
|
|
|
1932
1941
|
};
|
|
1933
1942
|
};
|
|
1934
1943
|
|
|
1935
|
-
export { ALL_WHERE_OPERATORS, ARRAY_OPERATORS, type AdapterErrorCode, type AdapterErrorContext, type AdapterName, type AdapterOperation, type AlterOperation, type AlterTableOperation, type AmbiguousAction, type AmbiguousActionType, type AmbiguousChange, type AmbiguousChangeType, type AnyRelationInput, type AnyRelationInputObject, type ArrayField, type AuthContext, type AuthErrorCode, type AuthErrorContext, type AuthStrategy, type AuthUser, type AuthenticatedUser, type BaseCommandOptions, type BaseErrorContext, type BaseMigrationOperation, BasePlugin, type BaseSchemaDiff, type BooleanField, CLIError, COMPARISON_OPERATORS, CONTROL_CHARS_PATTERN, type ComparisonOperators, type ConfigErrorCode, type ConfigErrorContext, type ConfigFactory, type ConfigFileExport, type ConnectionState, type CreateIndexOperation, type CreateTableOperation, type CrudErrorCode, type CrudErrorContext, type CrudOperation, DEFAULT_API_AUTH_CONFIG, DEFAULT_API_CONFIG, DEFAULT_DEV_CONFIG, DEFAULT_MIGRATION_CONFIG, DEFAULT_MIGRATION_MODEL, type DataTransferOperation, type DatabaseAdapter, type DateField, Datrix, DatrixAdapterError, type DatrixAdapterErrorOptions, DatrixAuthError, type DatrixAuthErrorOptions, type DatrixConfig, DatrixConfigError, type DatrixConfigErrorOptions, DatrixConfigValidationError, DatrixCrudError, type DatrixCrudErrorOptions, type DatrixEntry, DatrixError, type DatrixErrorOptions, type DatrixInitOptions, type DatrixPlugin, DatrixQueryBuilderError, type DatrixQueryBuilderErrorOptions, type DatrixRecord, DatrixValidationError, type DatrixValidationErrorOptions, type DefaultPermission, type DevCommandOptions, type DevConfig, type DropIndexOperation, type DropTableOperation, type EnumField, type ErrorLocation, type ExportMeta, type ExportWriter, FIELD_NAME_PATTERN,
|
|
1944
|
+
export { ALL_WHERE_OPERATORS, ARRAY_OPERATORS, type AdapterErrorCode, type AdapterErrorContext, type AdapterName, type AdapterOperation, type AlterOperation, type AlterTableOperation, type AmbiguousAction, type AmbiguousActionType, type AmbiguousChange, type AmbiguousChangeType, type AnyRelationInput, type AnyRelationInputObject, type ArrayField, type AuthContext, type AuthErrorCode, type AuthErrorContext, type AuthStrategy, type AuthUser, type AuthenticatedUser, type BaseCommandOptions, type BaseErrorContext, type BaseMigrationOperation, BasePlugin, type BaseSchemaDiff, type BooleanField, CLIError, COMPARISON_OPERATORS, CONTROL_CHARS_PATTERN, type ComparisonOperators, type ConfigErrorCode, type ConfigErrorContext, type ConfigFactory, type ConfigFileExport, type ConnectionState, type CreateIndexOperation, type CreateTableOperation, type CrudErrorCode, type CrudErrorContext, type CrudOperation, DATRIX_META_KEY_PREFIX, DATRIX_META_MODEL, DEFAULT_API_AUTH_CONFIG, DEFAULT_API_CONFIG, DEFAULT_DEV_CONFIG, DEFAULT_MIGRATION_CONFIG, DEFAULT_MIGRATION_MODEL, type DataTransferOperation, type DatabaseAdapter, type DateField, Datrix, DatrixAdapterError, type DatrixAdapterErrorOptions, DatrixAuthError, type DatrixAuthErrorOptions, type DatrixConfig, DatrixConfigError, type DatrixConfigErrorOptions, DatrixConfigValidationError, DatrixCrudError, type DatrixCrudErrorOptions, type DatrixEntry, DatrixError, type DatrixErrorOptions, type DatrixInitOptions, type DatrixPlugin, DatrixQueryBuilderError, type DatrixQueryBuilderErrorOptions, type DatrixRecord, DatrixValidationError, type DatrixValidationErrorOptions, type DefaultPermission, type DevCommandOptions, type DevConfig, type DropIndexOperation, type DropTableOperation, type EnumField, type ErrorLocation, type ExportMeta, type ExportWriter, FIELD_NAME_PATTERN, type FallbackInput, type FallbackOrderByItem, type FallbackScalar, type FallbackValue, type FallbackWhereClause, type FieldAddedDiff, type FieldDefinition, type FieldInvalidReason, type FieldMetadata, type FieldModifiedDiff, type FieldPermission, type FieldPermissionAction, type FieldPermissionCheckResult, type FieldRemovedDiff, type FieldRenamedDiff, type FieldType, type FieldValidationResult, type FieldsErrorContext, type FileField, type FileFieldOptions, type ForeignKeyReference, type GenerateCommandOptions, type IApiPlugin, type IAuthManager, type IDatrix, type IRawCrud, type ISchemaRegistry, type IUpload, type ImportReader, type IndexAddedDiff, type IndexDefinition, type IndexRemovedDiff, type JsonField, LOGICAL_OPERATORS, type LifecycleHooks, type LoadConfigOptions, type LocalProviderOptions, type LogicalOperators, type LoginResult, MAX_ARRAY_INDEX, MAX_FIELD_NAME_LENGTH, MAX_LOGICAL_NESTING_DEPTH, MAX_WHERE_VALUE_LENGTH, type MediaEntry, type MediaVariant, type MediaVariants, type MigrateCommandOptions, type Migration, type MigrationConfig, type MigrationContext, type MigrationExecutionResult, type MigrationFilePlan, type MigrationGenerator, type MigrationHistory, type MigrationHistoryRecord, type MigrationMetadata, type MigrationOperation, type MigrationOperationType, type MigrationPlan, type MigrationRunner, MigrationSession, type MigrationStatus, MigrationSystemError, NULL_OPERATORS, type NormalizedNestedData, type NormalizedRelationId, type NormalizedRelationOperations, type NormalizedRelationUpdate, type NumberField, OPERATOR_VALUE_TYPES, type OperatorValueType, type OrderByClause, type OrderByItem, type OrderDirection, type PaginationErrorContext, type PaginationParams, type ParameterStyle, type ParsedArgs, type ParsedPagination, type ParsedQuery, type ParsedSort, ParserError, type ParserErrorCode, type ParserErrorContext, type ParserErrorOptions, type ParserOptions, type ParserType, type PermissionAction, type PermissionCheckResult, type PermissionContext, type PermissionFn, type PermissionValue, type PluginContext, PluginError, type PluginFactory, PluginRegistry, type PopulateClause, type PopulateErrorContext, type PopulateOptions, type QueryAction, type QueryBuilderComponent, type QueryBuilderErrorCode, type QueryBuilderErrorContext, type QueryContext, type QueryCountObject, type QueryDeleteObject, type QueryInsertObject, type QueryMetadata, type QueryObject, type QueryObjectForType, type QueryOrderBy, type QueryPopulate, type QueryPopulateOptions, type QueryPrimitive, type QueryRelations, type QueryResult, type QueryRunner, type QuerySelect, type QuerySelectObject, type QueryTranslator, type QueryType, type QueryUpdateObject, RESERVED_FIELDS, RESERVED_FIELD_NAMES, type RawCrudOptions, type RawFindManyOptions, type RawQueryParams, type RawSQLOperation, type RelationBelongsTo, type RelationField, type RelationHasMany, type RelationHasOne, type RelationIdRef, type RelationIdRefs, type RelationInput, type RelationKind, type RelationManyToMany, type RenameTableOperation, type ReservedFieldName, type ResponseData, type S3ProviderOptions, STRING_OPERATORS, type ScalarValue, type SchemaComparison, type SchemaDefinition, type SchemaDefinitionValidationResult, type SchemaDiff, type SchemaDiffType, type SchemaDiffer, type SchemaExtension, type SchemaExtensionContext, type SchemaModifier, type SchemaOperations, type SchemaPattern, type SchemaPermission, type SchemaValidationError, type SelectClause, type SerializedDatrixAdapterError, type SerializedDatrixAuthError, type SerializedDatrixConfigError, type SerializedDatrixCrudError, type SerializedDatrixError, type SerializedDatrixQueryBuilderError, type SerializedDatrixValidationError, type SerializedParserError, type SortErrorContext, type SortParam, type SqlDialect, type StorageProvider, type StringField, type TableAddedDiff, type TableRemovedDiff, type TableRenamedDiff, type Transaction, type UploadConfig, UploadError, type UploadFile, type UploadResult, WHERE_OPERATORS, type WhereClause, type WhereErrorContext, type WhereOperator, buildErrorLocation, createMigrationSession, defineConfig, defineSchema, generateUniqueFilename, getDatrixMetaSchema, getFileExtension, getMigrationSchema, getOperatorValueType, hasDefaultExport, isDatabaseAdapter, isDatrixConfig, isDatrixPlugin, isLogicalOperator, isPermissionFn, isRelationIdRef, isRelationIdRefs, isStorageProvider, isValidFieldName, isValidWhereOperator, isWhereOperator, normalizeRelationId, normalizeRelationIds, requiresArrayValue, requiresConditions, sanitizeFilename, sortSchemasByDependency, throwConnectionError, throwFileNotFound, throwFileReadError, throwFileWriteError, throwForeignKeyConstraint, throwIntrospectionError, throwInvalidPopulateOptions, throwInvalidRelationType, throwInvalidRelationWhereSyntax, throwInvalidWhereField, throwJoinBuildError, throwJsonAggregationError, throwJunctionTableNotFound, throwLateralJoinError, throwLockError, throwLockTimeout, throwMaxDepthExceeded, throwMetaFieldAlreadyExists, throwMetaFieldNotFound, throwMigrationError, throwModelNotFound, throwNotConnected, throwPopulateQueryError, throwQueryError, throwQueryMissingData, throwRawQueryNotSupported, throwRelationNotFound, throwResultProcessingError, throwSchemaNotFound, throwTargetModelNotFound, throwTransactionAlreadyCommitted, throwTransactionAlreadyRolledBack, throwTransactionError, throwTransactionSavepointNotSupported, throwUniqueConstraintField, throwUniqueConstraintIndex, truncateSqlForError, validateFieldName, validateQueryObject, validateSchemaDefinition };
|
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ type FallbackWhereClause = {
|
|
|
37
37
|
$not?: FallbackWhereClause;
|
|
38
38
|
};
|
|
39
39
|
type TypedWhereClause<T extends DatrixEntry> = Writable<{
|
|
40
|
-
[K in keyof T]?: T[K] extends RelationInput<infer R extends DatrixEntry> ? WhereClause<R> : T[K] extends ScalarValue ? T[K] | ComparisonOperators<T[K]
|
|
40
|
+
[K in keyof T]?: T[K] extends RelationInput<infer R extends DatrixEntry> ? WhereClause<R> : NonNullable<T[K]> extends DatrixEntry ? WhereClause<NonNullable<T[K]>> : NonNullable<T[K]> extends DatrixEntry[] ? WhereClause<NonNullable<T[K]>[number]> : NonNullable<T[K]> extends ScalarValue ? NonNullable<T[K]> | ComparisonOperators<NonNullable<T[K]>> : never;
|
|
41
41
|
}> & LogicalOperators<T>;
|
|
42
42
|
type WhereClause<T extends DatrixEntry = DatrixRecord> = DatrixRecord extends T ? FallbackWhereClause : TypedWhereClause<T>;
|
|
43
43
|
type SelectClause<T extends DatrixEntry = DatrixRecord> = (DatrixRecord extends T ? readonly string[] : readonly (keyof T)[]) | "*" | (DatrixRecord extends T ? string : keyof T);
|
|
@@ -49,9 +49,11 @@ type PopulateOptions<T extends DatrixEntry> = {
|
|
|
49
49
|
readonly offset?: number | undefined;
|
|
50
50
|
readonly orderBy?: QueryOrderBy | undefined;
|
|
51
51
|
};
|
|
52
|
-
type
|
|
53
|
-
|
|
52
|
+
type TypedPopulateValue<T> = NonNullable<T> extends DatrixEntry ? PopulateOptions<NonNullable<T>> | "*" | boolean : NonNullable<T> extends DatrixEntry[] ? PopulateOptions<NonNullable<T>[number]> | "*" | boolean : PopulateOptions<DatrixRecord> | "*" | boolean;
|
|
53
|
+
type TypedPopulateClause<T extends DatrixEntry> = {
|
|
54
|
+
readonly [K in keyof T]?: TypedPopulateValue<T[K]>;
|
|
54
55
|
};
|
|
56
|
+
type PopulateClause<T extends DatrixEntry = DatrixRecord> = boolean | "*" | "true" | (DatrixRecord extends T ? readonly string[] : readonly (keyof T)[]) | (DatrixRecord extends T ? Record<string, PopulateOptions<DatrixRecord> | "*" | boolean> : TypedPopulateClause<T>);
|
|
55
57
|
type OrderDirection = "asc" | "desc";
|
|
56
58
|
type OrderByItem<T extends DatrixEntry> = {
|
|
57
59
|
readonly field: keyof T;
|
|
@@ -367,6 +369,8 @@ interface AuthenticatedUser<TRoles extends string = string, TUser extends Datrix
|
|
|
367
369
|
password: string;
|
|
368
370
|
passwordSalt: string;
|
|
369
371
|
role: TRoles;
|
|
372
|
+
resetToken?: string;
|
|
373
|
+
resetTokenExpiry?: Date;
|
|
370
374
|
}
|
|
371
375
|
interface AuthUser {
|
|
372
376
|
readonly id: number;
|
|
@@ -857,8 +861,8 @@ declare function isLogicalOperator(operator: string): operator is (typeof LOGICA
|
|
|
857
861
|
declare function requiresArrayValue(operator: string): boolean;
|
|
858
862
|
declare function requiresConditions(operator: string): boolean;
|
|
859
863
|
declare function getOperatorValueType(operator: string): OperatorValueType | undefined;
|
|
860
|
-
declare const
|
|
861
|
-
declare const
|
|
864
|
+
declare const DATRIX_META_MODEL = "_datrix";
|
|
865
|
+
declare const DATRIX_META_KEY_PREFIX = "_schema_";
|
|
862
866
|
declare const FIELD_NAME_PATTERN: RegExp;
|
|
863
867
|
declare const CONTROL_CHARS_PATTERN: RegExp;
|
|
864
868
|
declare const RESERVED_FIELD_NAMES: readonly ["__proto__", "constructor", "prototype"];
|
|
@@ -1098,8 +1102,13 @@ declare const DEFAULT_API_AUTH_CONFIG: {
|
|
|
1098
1102
|
readonly register: "/auth/register";
|
|
1099
1103
|
readonly logout: "/auth/logout";
|
|
1100
1104
|
readonly me: "/auth/me";
|
|
1105
|
+
readonly forgotPassword: "/auth/forgot-password";
|
|
1106
|
+
readonly resetPassword: "/auth/reset-password";
|
|
1101
1107
|
readonly disableRegister: false;
|
|
1102
1108
|
};
|
|
1109
|
+
readonly passwordReset: {
|
|
1110
|
+
readonly tokenExpirySeconds: 3600;
|
|
1111
|
+
};
|
|
1103
1112
|
};
|
|
1104
1113
|
|
|
1105
1114
|
type ResponseData<T = unknown> = {
|
|
@@ -1932,4 +1941,4 @@ declare function getDatrixMetaSchema(): {
|
|
|
1932
1941
|
};
|
|
1933
1942
|
};
|
|
1934
1943
|
|
|
1935
|
-
export { ALL_WHERE_OPERATORS, ARRAY_OPERATORS, type AdapterErrorCode, type AdapterErrorContext, type AdapterName, type AdapterOperation, type AlterOperation, type AlterTableOperation, type AmbiguousAction, type AmbiguousActionType, type AmbiguousChange, type AmbiguousChangeType, type AnyRelationInput, type AnyRelationInputObject, type ArrayField, type AuthContext, type AuthErrorCode, type AuthErrorContext, type AuthStrategy, type AuthUser, type AuthenticatedUser, type BaseCommandOptions, type BaseErrorContext, type BaseMigrationOperation, BasePlugin, type BaseSchemaDiff, type BooleanField, CLIError, COMPARISON_OPERATORS, CONTROL_CHARS_PATTERN, type ComparisonOperators, type ConfigErrorCode, type ConfigErrorContext, type ConfigFactory, type ConfigFileExport, type ConnectionState, type CreateIndexOperation, type CreateTableOperation, type CrudErrorCode, type CrudErrorContext, type CrudOperation, DEFAULT_API_AUTH_CONFIG, DEFAULT_API_CONFIG, DEFAULT_DEV_CONFIG, DEFAULT_MIGRATION_CONFIG, DEFAULT_MIGRATION_MODEL, type DataTransferOperation, type DatabaseAdapter, type DateField, Datrix, DatrixAdapterError, type DatrixAdapterErrorOptions, DatrixAuthError, type DatrixAuthErrorOptions, type DatrixConfig, DatrixConfigError, type DatrixConfigErrorOptions, DatrixConfigValidationError, DatrixCrudError, type DatrixCrudErrorOptions, type DatrixEntry, DatrixError, type DatrixErrorOptions, type DatrixInitOptions, type DatrixPlugin, DatrixQueryBuilderError, type DatrixQueryBuilderErrorOptions, type DatrixRecord, DatrixValidationError, type DatrixValidationErrorOptions, type DefaultPermission, type DevCommandOptions, type DevConfig, type DropIndexOperation, type DropTableOperation, type EnumField, type ErrorLocation, type ExportMeta, type ExportWriter, FIELD_NAME_PATTERN,
|
|
1944
|
+
export { ALL_WHERE_OPERATORS, ARRAY_OPERATORS, type AdapterErrorCode, type AdapterErrorContext, type AdapterName, type AdapterOperation, type AlterOperation, type AlterTableOperation, type AmbiguousAction, type AmbiguousActionType, type AmbiguousChange, type AmbiguousChangeType, type AnyRelationInput, type AnyRelationInputObject, type ArrayField, type AuthContext, type AuthErrorCode, type AuthErrorContext, type AuthStrategy, type AuthUser, type AuthenticatedUser, type BaseCommandOptions, type BaseErrorContext, type BaseMigrationOperation, BasePlugin, type BaseSchemaDiff, type BooleanField, CLIError, COMPARISON_OPERATORS, CONTROL_CHARS_PATTERN, type ComparisonOperators, type ConfigErrorCode, type ConfigErrorContext, type ConfigFactory, type ConfigFileExport, type ConnectionState, type CreateIndexOperation, type CreateTableOperation, type CrudErrorCode, type CrudErrorContext, type CrudOperation, DATRIX_META_KEY_PREFIX, DATRIX_META_MODEL, DEFAULT_API_AUTH_CONFIG, DEFAULT_API_CONFIG, DEFAULT_DEV_CONFIG, DEFAULT_MIGRATION_CONFIG, DEFAULT_MIGRATION_MODEL, type DataTransferOperation, type DatabaseAdapter, type DateField, Datrix, DatrixAdapterError, type DatrixAdapterErrorOptions, DatrixAuthError, type DatrixAuthErrorOptions, type DatrixConfig, DatrixConfigError, type DatrixConfigErrorOptions, DatrixConfigValidationError, DatrixCrudError, type DatrixCrudErrorOptions, type DatrixEntry, DatrixError, type DatrixErrorOptions, type DatrixInitOptions, type DatrixPlugin, DatrixQueryBuilderError, type DatrixQueryBuilderErrorOptions, type DatrixRecord, DatrixValidationError, type DatrixValidationErrorOptions, type DefaultPermission, type DevCommandOptions, type DevConfig, type DropIndexOperation, type DropTableOperation, type EnumField, type ErrorLocation, type ExportMeta, type ExportWriter, FIELD_NAME_PATTERN, type FallbackInput, type FallbackOrderByItem, type FallbackScalar, type FallbackValue, type FallbackWhereClause, type FieldAddedDiff, type FieldDefinition, type FieldInvalidReason, type FieldMetadata, type FieldModifiedDiff, type FieldPermission, type FieldPermissionAction, type FieldPermissionCheckResult, type FieldRemovedDiff, type FieldRenamedDiff, type FieldType, type FieldValidationResult, type FieldsErrorContext, type FileField, type FileFieldOptions, type ForeignKeyReference, type GenerateCommandOptions, type IApiPlugin, type IAuthManager, type IDatrix, type IRawCrud, type ISchemaRegistry, type IUpload, type ImportReader, type IndexAddedDiff, type IndexDefinition, type IndexRemovedDiff, type JsonField, LOGICAL_OPERATORS, type LifecycleHooks, type LoadConfigOptions, type LocalProviderOptions, type LogicalOperators, type LoginResult, MAX_ARRAY_INDEX, MAX_FIELD_NAME_LENGTH, MAX_LOGICAL_NESTING_DEPTH, MAX_WHERE_VALUE_LENGTH, type MediaEntry, type MediaVariant, type MediaVariants, type MigrateCommandOptions, type Migration, type MigrationConfig, type MigrationContext, type MigrationExecutionResult, type MigrationFilePlan, type MigrationGenerator, type MigrationHistory, type MigrationHistoryRecord, type MigrationMetadata, type MigrationOperation, type MigrationOperationType, type MigrationPlan, type MigrationRunner, MigrationSession, type MigrationStatus, MigrationSystemError, NULL_OPERATORS, type NormalizedNestedData, type NormalizedRelationId, type NormalizedRelationOperations, type NormalizedRelationUpdate, type NumberField, OPERATOR_VALUE_TYPES, type OperatorValueType, type OrderByClause, type OrderByItem, type OrderDirection, type PaginationErrorContext, type PaginationParams, type ParameterStyle, type ParsedArgs, type ParsedPagination, type ParsedQuery, type ParsedSort, ParserError, type ParserErrorCode, type ParserErrorContext, type ParserErrorOptions, type ParserOptions, type ParserType, type PermissionAction, type PermissionCheckResult, type PermissionContext, type PermissionFn, type PermissionValue, type PluginContext, PluginError, type PluginFactory, PluginRegistry, type PopulateClause, type PopulateErrorContext, type PopulateOptions, type QueryAction, type QueryBuilderComponent, type QueryBuilderErrorCode, type QueryBuilderErrorContext, type QueryContext, type QueryCountObject, type QueryDeleteObject, type QueryInsertObject, type QueryMetadata, type QueryObject, type QueryObjectForType, type QueryOrderBy, type QueryPopulate, type QueryPopulateOptions, type QueryPrimitive, type QueryRelations, type QueryResult, type QueryRunner, type QuerySelect, type QuerySelectObject, type QueryTranslator, type QueryType, type QueryUpdateObject, RESERVED_FIELDS, RESERVED_FIELD_NAMES, type RawCrudOptions, type RawFindManyOptions, type RawQueryParams, type RawSQLOperation, type RelationBelongsTo, type RelationField, type RelationHasMany, type RelationHasOne, type RelationIdRef, type RelationIdRefs, type RelationInput, type RelationKind, type RelationManyToMany, type RenameTableOperation, type ReservedFieldName, type ResponseData, type S3ProviderOptions, STRING_OPERATORS, type ScalarValue, type SchemaComparison, type SchemaDefinition, type SchemaDefinitionValidationResult, type SchemaDiff, type SchemaDiffType, type SchemaDiffer, type SchemaExtension, type SchemaExtensionContext, type SchemaModifier, type SchemaOperations, type SchemaPattern, type SchemaPermission, type SchemaValidationError, type SelectClause, type SerializedDatrixAdapterError, type SerializedDatrixAuthError, type SerializedDatrixConfigError, type SerializedDatrixCrudError, type SerializedDatrixError, type SerializedDatrixQueryBuilderError, type SerializedDatrixValidationError, type SerializedParserError, type SortErrorContext, type SortParam, type SqlDialect, type StorageProvider, type StringField, type TableAddedDiff, type TableRemovedDiff, type TableRenamedDiff, type Transaction, type UploadConfig, UploadError, type UploadFile, type UploadResult, WHERE_OPERATORS, type WhereClause, type WhereErrorContext, type WhereOperator, buildErrorLocation, createMigrationSession, defineConfig, defineSchema, generateUniqueFilename, getDatrixMetaSchema, getFileExtension, getMigrationSchema, getOperatorValueType, hasDefaultExport, isDatabaseAdapter, isDatrixConfig, isDatrixPlugin, isLogicalOperator, isPermissionFn, isRelationIdRef, isRelationIdRefs, isStorageProvider, isValidFieldName, isValidWhereOperator, isWhereOperator, normalizeRelationId, normalizeRelationIds, requiresArrayValue, requiresConditions, sanitizeFilename, sortSchemasByDependency, throwConnectionError, throwFileNotFound, throwFileReadError, throwFileWriteError, throwForeignKeyConstraint, throwIntrospectionError, throwInvalidPopulateOptions, throwInvalidRelationType, throwInvalidRelationWhereSyntax, throwInvalidWhereField, throwJoinBuildError, throwJsonAggregationError, throwJunctionTableNotFound, throwLateralJoinError, throwLockError, throwLockTimeout, throwMaxDepthExceeded, throwMetaFieldAlreadyExists, throwMetaFieldNotFound, throwMigrationError, throwModelNotFound, throwNotConnected, throwPopulateQueryError, throwQueryError, throwQueryMissingData, throwRawQueryNotSupported, throwRelationNotFound, throwResultProcessingError, throwSchemaNotFound, throwTargetModelNotFound, throwTransactionAlreadyCommitted, throwTransactionAlreadyRolledBack, throwTransactionError, throwTransactionSavepointNotSupported, throwUniqueConstraintField, throwUniqueConstraintIndex, truncateSqlForError, validateFieldName, validateQueryObject, validateSchemaDefinition };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ __export(index_exports, {
|
|
|
26
26
|
CLIError: () => CLIError,
|
|
27
27
|
COMPARISON_OPERATORS: () => COMPARISON_OPERATORS2,
|
|
28
28
|
CONTROL_CHARS_PATTERN: () => CONTROL_CHARS_PATTERN,
|
|
29
|
+
DATRIX_META_KEY_PREFIX: () => DATRIX_META_KEY_PREFIX,
|
|
30
|
+
DATRIX_META_MODEL: () => DATRIX_META_MODEL,
|
|
29
31
|
DEFAULT_API_AUTH_CONFIG: () => DEFAULT_API_AUTH_CONFIG,
|
|
30
32
|
DEFAULT_API_CONFIG: () => DEFAULT_API_CONFIG,
|
|
31
33
|
DEFAULT_DEV_CONFIG: () => DEFAULT_DEV_CONFIG,
|
|
@@ -41,8 +43,6 @@ __export(index_exports, {
|
|
|
41
43
|
DatrixQueryBuilderError: () => DatrixQueryBuilderError,
|
|
42
44
|
DatrixValidationError: () => DatrixValidationError,
|
|
43
45
|
FIELD_NAME_PATTERN: () => FIELD_NAME_PATTERN,
|
|
44
|
-
FORJA_META_KEY_PREFIX: () => FORJA_META_KEY_PREFIX,
|
|
45
|
-
FORJA_META_MODEL: () => FORJA_META_MODEL,
|
|
46
46
|
LOGICAL_OPERATORS: () => LOGICAL_OPERATORS,
|
|
47
47
|
MAX_ARRAY_INDEX: () => MAX_ARRAY_INDEX,
|
|
48
48
|
MAX_FIELD_NAME_LENGTH: () => MAX_FIELD_NAME_LENGTH,
|
|
@@ -1168,13 +1168,16 @@ function throwInvalidQueryType(receivedType) {
|
|
|
1168
1168
|
});
|
|
1169
1169
|
}
|
|
1170
1170
|
function throwSchemaNotFound2(modelName) {
|
|
1171
|
-
throw new DatrixQueryBuilderError(
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1171
|
+
throw new DatrixQueryBuilderError(
|
|
1172
|
+
`Schema not found for model: ${modelName}`,
|
|
1173
|
+
{
|
|
1174
|
+
code: "SCHEMA_NOT_FOUND",
|
|
1175
|
+
component: "builder",
|
|
1176
|
+
context: { modelName },
|
|
1177
|
+
suggestion: `Check that '${modelName}' is registered in the schema registry`,
|
|
1178
|
+
received: modelName
|
|
1179
|
+
}
|
|
1180
|
+
);
|
|
1178
1181
|
}
|
|
1179
1182
|
function throwInvalidFields(component, invalidFields, availableFields) {
|
|
1180
1183
|
const fieldList = invalidFields.join(", ");
|
|
@@ -5131,8 +5134,8 @@ function requiresConditions(operator) {
|
|
|
5131
5134
|
function getOperatorValueType(operator) {
|
|
5132
5135
|
return OPERATOR_VALUE_TYPES[operator];
|
|
5133
5136
|
}
|
|
5134
|
-
var
|
|
5135
|
-
var
|
|
5137
|
+
var DATRIX_META_MODEL = "_datrix";
|
|
5138
|
+
var DATRIX_META_KEY_PREFIX = "_schema_";
|
|
5136
5139
|
var FIELD_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_.]*$/;
|
|
5137
5140
|
var CONTROL_CHARS_PATTERN = /[\x00-\x1F\x7F]/;
|
|
5138
5141
|
var RESERVED_FIELD_NAMES = [
|
|
@@ -5317,12 +5320,12 @@ var SchemaRegistry = class {
|
|
|
5317
5320
|
const allSchemas = Array.from(this.schemas.values());
|
|
5318
5321
|
const sorted = sortSchemasByDependency(allSchemas);
|
|
5319
5322
|
const entries = /* @__PURE__ */ new Map();
|
|
5320
|
-
const metaSchema = this.schemas.get(
|
|
5323
|
+
const metaSchema = this.schemas.get(DATRIX_META_MODEL);
|
|
5321
5324
|
if (metaSchema) {
|
|
5322
|
-
entries.set(
|
|
5325
|
+
entries.set(DATRIX_META_MODEL, metaSchema);
|
|
5323
5326
|
}
|
|
5324
5327
|
for (const schema of sorted) {
|
|
5325
|
-
if (schema.name ===
|
|
5328
|
+
if (schema.name === DATRIX_META_MODEL) continue;
|
|
5326
5329
|
entries.set(schema.name, schema);
|
|
5327
5330
|
}
|
|
5328
5331
|
this.schemas.clear();
|
|
@@ -5879,8 +5882,8 @@ function getMigrationSchema(modelName = DEFAULT_MIGRATION_MODEL) {
|
|
|
5879
5882
|
}
|
|
5880
5883
|
function getDatrixMetaSchema() {
|
|
5881
5884
|
return defineSchema({
|
|
5882
|
-
name:
|
|
5883
|
-
tableName:
|
|
5885
|
+
name: DATRIX_META_MODEL,
|
|
5886
|
+
tableName: DATRIX_META_MODEL,
|
|
5884
5887
|
fields: {
|
|
5885
5888
|
key: {
|
|
5886
5889
|
type: "string",
|
|
@@ -6818,12 +6821,12 @@ var ForgeMigrationHistory = class {
|
|
|
6818
6821
|
);
|
|
6819
6822
|
}
|
|
6820
6823
|
const adapter = this.datrix.getAdapter();
|
|
6821
|
-
const metaExists = await adapter.tableExists(
|
|
6824
|
+
const metaExists = await adapter.tableExists(DATRIX_META_MODEL);
|
|
6822
6825
|
if (!metaExists) {
|
|
6823
|
-
const metaSchema = this.datrix.getSchemas().get(
|
|
6826
|
+
const metaSchema = this.datrix.getSchemas().get(DATRIX_META_MODEL);
|
|
6824
6827
|
if (!metaSchema) {
|
|
6825
6828
|
throw new MigrationSystemError(
|
|
6826
|
-
`Schema '${
|
|
6829
|
+
`Schema '${DATRIX_META_MODEL}' not found in registry`,
|
|
6827
6830
|
"MIGRATION_ERROR"
|
|
6828
6831
|
);
|
|
6829
6832
|
}
|
|
@@ -6957,10 +6960,13 @@ var ForgeMigrationHistory = class {
|
|
|
6957
6960
|
*/
|
|
6958
6961
|
async isApplied(version) {
|
|
6959
6962
|
try {
|
|
6960
|
-
const count = await this.datrix.raw.count(
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6963
|
+
const count = await this.datrix.raw.count(
|
|
6964
|
+
this.modelName,
|
|
6965
|
+
{
|
|
6966
|
+
version,
|
|
6967
|
+
status: "completed"
|
|
6968
|
+
}
|
|
6969
|
+
);
|
|
6964
6970
|
return count > 0;
|
|
6965
6971
|
} catch (error) {
|
|
6966
6972
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -8707,7 +8713,12 @@ var DEFAULT_API_AUTH_CONFIG = {
|
|
|
8707
8713
|
register: "/auth/register",
|
|
8708
8714
|
logout: "/auth/logout",
|
|
8709
8715
|
me: "/auth/me",
|
|
8716
|
+
forgotPassword: "/auth/forgot-password",
|
|
8717
|
+
resetPassword: "/auth/reset-password",
|
|
8710
8718
|
disableRegister: false
|
|
8719
|
+
},
|
|
8720
|
+
passwordReset: {
|
|
8721
|
+
tokenExpirySeconds: 3600
|
|
8711
8722
|
}
|
|
8712
8723
|
};
|
|
8713
8724
|
|
|
@@ -8833,6 +8844,8 @@ var BasePlugin = class {
|
|
|
8833
8844
|
CLIError,
|
|
8834
8845
|
COMPARISON_OPERATORS,
|
|
8835
8846
|
CONTROL_CHARS_PATTERN,
|
|
8847
|
+
DATRIX_META_KEY_PREFIX,
|
|
8848
|
+
DATRIX_META_MODEL,
|
|
8836
8849
|
DEFAULT_API_AUTH_CONFIG,
|
|
8837
8850
|
DEFAULT_API_CONFIG,
|
|
8838
8851
|
DEFAULT_DEV_CONFIG,
|
|
@@ -8848,8 +8861,6 @@ var BasePlugin = class {
|
|
|
8848
8861
|
DatrixQueryBuilderError,
|
|
8849
8862
|
DatrixValidationError,
|
|
8850
8863
|
FIELD_NAME_PATTERN,
|
|
8851
|
-
FORJA_META_KEY_PREFIX,
|
|
8852
|
-
FORJA_META_MODEL,
|
|
8853
8864
|
LOGICAL_OPERATORS,
|
|
8854
8865
|
MAX_ARRAY_INDEX,
|
|
8855
8866
|
MAX_FIELD_NAME_LENGTH,
|