arkormx 0.2.11 → 1.1.0
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/README.md +17 -0
- package/dist/cli.mjs +37 -9
- package/dist/index.cjs +680 -38
- package/dist/index.d.cts +308 -7
- package/dist/index.d.mts +308 -7
- package/dist/index.mjs +672 -39
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -570,10 +570,6 @@ declare class InlineFactory<TModel, TAttributes extends FactoryAttributes> exten
|
|
|
570
570
|
declare const defineFactory: <TModel, TAttributes extends FactoryAttributes = Partial<ModelAttributes<TModel>>>(model: FactoryModelConstructor<TModel>, definition: FactoryDefinition<TAttributes>) => ModelFactory<TModel, TAttributes>;
|
|
571
571
|
//#endregion
|
|
572
572
|
//#region src/Model.d.ts
|
|
573
|
-
type RelatedModelClass<TInstance = unknown> = (abstract new (attributes?: Record<string, unknown>) => TInstance) & RelationshipModelStatic;
|
|
574
|
-
type GlobalScope = (query: QueryBuilder<any, any>) => QueryBuilder<any, any> | void;
|
|
575
|
-
type ModelEventName = 'saving' | 'saved' | 'creating' | 'created' | 'updating' | 'updated' | 'deleting' | 'deleted' | 'restoring' | 'restored' | 'forceDeleting' | 'forceDeleted';
|
|
576
|
-
type ModelEventListener<TModel extends Model = Model> = (model: TModel) => void | Promise<void>;
|
|
577
573
|
/**
|
|
578
574
|
* Base model class that all models should extend.
|
|
579
575
|
*
|
|
@@ -583,6 +579,8 @@ type ModelEventListener<TModel extends Model = Model> = (model: TModel) => void
|
|
|
583
579
|
* @since 0.1.0
|
|
584
580
|
*/
|
|
585
581
|
declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string, unknown> | string = Record<string, any>, TAttributes extends Record<string, unknown> = ModelAttributesOf<TSchema>> {
|
|
582
|
+
private static readonly lifecycleStates;
|
|
583
|
+
private static eventsSuppressed;
|
|
586
584
|
protected static factoryClass?: new () => ModelFactory<any, any>;
|
|
587
585
|
protected static client: Record<string, unknown>;
|
|
588
586
|
protected static delegate: string;
|
|
@@ -590,11 +588,15 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
590
588
|
protected static deletedAtColumn: string;
|
|
591
589
|
protected static globalScopes: Record<string, GlobalScope>;
|
|
592
590
|
protected static eventListeners: Partial<Record<ModelEventName, ModelEventListener<any>[]>>;
|
|
591
|
+
protected static dispatchesEvents: Partial<Record<ModelEventName, ModelEventDispatcher<any> | ModelEventDispatcher<any>[]>>;
|
|
593
592
|
protected casts: CastMap;
|
|
594
593
|
protected hidden: string[];
|
|
595
594
|
protected visible: string[];
|
|
596
595
|
protected appends: string[];
|
|
597
596
|
protected readonly attributes: Record<string, unknown>;
|
|
597
|
+
protected original: Record<string, unknown>;
|
|
598
|
+
protected changes: Record<string, unknown>;
|
|
599
|
+
protected readonly touchedAttributes: Set<string>;
|
|
598
600
|
constructor(attributes?: Record<string, unknown>);
|
|
599
601
|
/**
|
|
600
602
|
* Set the Prisma client delegates for all models.
|
|
@@ -611,6 +613,13 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
611
613
|
* @param scope
|
|
612
614
|
*/
|
|
613
615
|
static addGlobalScope(name: string, scope: GlobalScope): void;
|
|
616
|
+
/**
|
|
617
|
+
* Execute a callback without applying global scopes for the current model class.
|
|
618
|
+
*
|
|
619
|
+
* @param callback
|
|
620
|
+
* @returns
|
|
621
|
+
*/
|
|
622
|
+
static withoutGlobalScopes<T>(callback: () => T | Promise<T>): Promise<Awaited<T>>;
|
|
614
623
|
/**
|
|
615
624
|
* Remove a global scope by name.
|
|
616
625
|
*
|
|
@@ -628,6 +637,26 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
628
637
|
* @param listener
|
|
629
638
|
*/
|
|
630
639
|
static on<TModel extends Model = Model>(event: ModelEventName, listener: ModelEventListener<TModel>): void;
|
|
640
|
+
/**
|
|
641
|
+
* Register a model lifecycle callback listener.
|
|
642
|
+
*
|
|
643
|
+
* @param event
|
|
644
|
+
* @param listener
|
|
645
|
+
*/
|
|
646
|
+
static event<TModel extends Model = Model>(event: ModelEventName, listener: ModelEventListener<TModel>): void;
|
|
647
|
+
static retrieved<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
648
|
+
static saving<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
649
|
+
static saved<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
650
|
+
static creating<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
651
|
+
static created<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
652
|
+
static updating<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
653
|
+
static updated<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
654
|
+
static deleting<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
655
|
+
static deleted<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
656
|
+
static restoring<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
657
|
+
static restored<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
658
|
+
static forceDeleting<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
659
|
+
static forceDeleted<TModel extends Model = Model>(listener: ModelEventListener<TModel>): void;
|
|
631
660
|
/**
|
|
632
661
|
* Remove listeners for an event. If listener is omitted, all listeners for that event are removed.
|
|
633
662
|
*
|
|
@@ -639,6 +668,22 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
639
668
|
* Clears all event listeners for the model.
|
|
640
669
|
*/
|
|
641
670
|
static clearEventListeners(): void;
|
|
671
|
+
/**
|
|
672
|
+
* Execute a callback while suppressing lifecycle events for all models.
|
|
673
|
+
*
|
|
674
|
+
* @param callback
|
|
675
|
+
* @returns
|
|
676
|
+
*/
|
|
677
|
+
static withoutEvents<T>(callback: () => T | Promise<T>): Promise<Awaited<T>>;
|
|
678
|
+
/**
|
|
679
|
+
* Execute a callback within a transaction scope.
|
|
680
|
+
* Nested calls reuse the active transaction client.
|
|
681
|
+
*
|
|
682
|
+
* @param callback
|
|
683
|
+
* @param options
|
|
684
|
+
* @returns
|
|
685
|
+
*/
|
|
686
|
+
static transaction<T>(callback: (client: PrismaClientLike) => T | Promise<T>, options?: PrismaTransactionOptions): Promise<Awaited<T>>;
|
|
642
687
|
/**
|
|
643
688
|
* Get the Prisma delegate for the model.
|
|
644
689
|
* If a delegate name is provided, it will attempt to resolve that delegate.
|
|
@@ -656,6 +701,14 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
656
701
|
* @returns
|
|
657
702
|
*/
|
|
658
703
|
static query<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema> ? TSchema : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
|
|
704
|
+
/**
|
|
705
|
+
* Boot hook for subclasses to register scopes or perform one-time setup.
|
|
706
|
+
*/
|
|
707
|
+
protected static boot(): void;
|
|
708
|
+
/**
|
|
709
|
+
* Booted hook for subclasses to register callbacks after boot logic runs.
|
|
710
|
+
*/
|
|
711
|
+
protected static booted(): void;
|
|
659
712
|
/**
|
|
660
713
|
* Get a query builder instance that includes soft-deleted records.
|
|
661
714
|
*
|
|
@@ -704,6 +757,22 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
704
757
|
* @returns
|
|
705
758
|
*/
|
|
706
759
|
static hydrateMany<TModel>(this: new (attributes: Record<string, unknown>) => TModel, attributes: Record<string, unknown>[]): TModel[];
|
|
760
|
+
/**
|
|
761
|
+
* Hydrate a model instance and dispatch the retrieved lifecycle event.
|
|
762
|
+
*
|
|
763
|
+
* @param this
|
|
764
|
+
* @param attributes
|
|
765
|
+
* @returns
|
|
766
|
+
*/
|
|
767
|
+
static hydrateRetrieved<TModel>(this: ModelStatic<TModel, PrismaDelegateLike>, attributes: Record<string, unknown>): Promise<TModel>;
|
|
768
|
+
/**
|
|
769
|
+
* Hydrate multiple model instances and dispatch the retrieved lifecycle event for each.
|
|
770
|
+
*
|
|
771
|
+
* @param this
|
|
772
|
+
* @param attributes
|
|
773
|
+
* @returns
|
|
774
|
+
*/
|
|
775
|
+
static hydrateManyRetrieved<TModel>(this: ModelStatic<TModel, PrismaDelegateLike>, attributes: Record<string, unknown>[]): Promise<TModel[]>;
|
|
707
776
|
/**
|
|
708
777
|
* Fill the model's attributes from a plain object, using the
|
|
709
778
|
* setAttribute method to ensure that mutators and casts are applied.
|
|
@@ -738,6 +807,12 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
738
807
|
* @returns
|
|
739
808
|
*/
|
|
740
809
|
save(): Promise<this>;
|
|
810
|
+
/**
|
|
811
|
+
* Save the model without dispatching lifecycle events.
|
|
812
|
+
*
|
|
813
|
+
* @returns
|
|
814
|
+
*/
|
|
815
|
+
saveQuietly(): Promise<this>;
|
|
741
816
|
/**
|
|
742
817
|
* Delete the model from the database.
|
|
743
818
|
* If soft deletes are enabled, it will perform a soft delete by
|
|
@@ -747,6 +822,12 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
747
822
|
* @returns
|
|
748
823
|
*/
|
|
749
824
|
delete(): Promise<this>;
|
|
825
|
+
/**
|
|
826
|
+
* Delete the model without dispatching lifecycle events.
|
|
827
|
+
*
|
|
828
|
+
* @returns
|
|
829
|
+
*/
|
|
830
|
+
deleteQuietly(): Promise<this>;
|
|
750
831
|
/**
|
|
751
832
|
* Permanently delete the model from the database, regardless of whether soft
|
|
752
833
|
* deletes are enabled.
|
|
@@ -754,12 +835,24 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
754
835
|
* @returns
|
|
755
836
|
*/
|
|
756
837
|
forceDelete(): Promise<this>;
|
|
838
|
+
/**
|
|
839
|
+
* Force delete the model without dispatching lifecycle events.
|
|
840
|
+
*
|
|
841
|
+
* @returns
|
|
842
|
+
*/
|
|
843
|
+
forceDeleteQuietly(): Promise<this>;
|
|
757
844
|
/**
|
|
758
845
|
* Restore a soft-deleted model by setting the deleted at column to null.
|
|
759
846
|
*
|
|
760
847
|
* @returns
|
|
761
848
|
*/
|
|
762
849
|
restore(): Promise<this>;
|
|
850
|
+
/**
|
|
851
|
+
* Restore the model without dispatching lifecycle events.
|
|
852
|
+
*
|
|
853
|
+
* @returns
|
|
854
|
+
*/
|
|
855
|
+
restoreQuietly(): Promise<this>;
|
|
763
856
|
/**
|
|
764
857
|
* Load related models onto the current model instance.
|
|
765
858
|
*
|
|
@@ -773,6 +866,37 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
773
866
|
* @returns
|
|
774
867
|
*/
|
|
775
868
|
getRawAttributes(): Partial<TAttributes>;
|
|
869
|
+
/**
|
|
870
|
+
* Get the model's original persisted attributes.
|
|
871
|
+
*
|
|
872
|
+
* @returns
|
|
873
|
+
*/
|
|
874
|
+
getOriginal(): Partial<TAttributes>;
|
|
875
|
+
/**
|
|
876
|
+
* @param key The attribute key to retrieve the original value for.
|
|
877
|
+
*/
|
|
878
|
+
getOriginal<TKey extends keyof TAttributes & string>(key: TKey): TAttributes[TKey] | undefined;
|
|
879
|
+
/**
|
|
880
|
+
* Determine whether the model has unsaved attribute changes.
|
|
881
|
+
*
|
|
882
|
+
* @param keys
|
|
883
|
+
* @returns
|
|
884
|
+
*/
|
|
885
|
+
isDirty(keys?: string | string[]): boolean;
|
|
886
|
+
/**
|
|
887
|
+
* Determine whether the model has no unsaved attribute changes.
|
|
888
|
+
*
|
|
889
|
+
* @param keys
|
|
890
|
+
* @returns
|
|
891
|
+
*/
|
|
892
|
+
isClean(keys?: string | string[]): boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Determine whether the model changed during the last successful persistence operation.
|
|
895
|
+
*
|
|
896
|
+
* @param keys
|
|
897
|
+
* @returns
|
|
898
|
+
*/
|
|
899
|
+
wasChanged(keys?: string | string[]): boolean;
|
|
776
900
|
/**
|
|
777
901
|
* Convert the model instance to a plain object, applying visibility
|
|
778
902
|
* rules, appends, and mutators.
|
|
@@ -786,6 +910,34 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
786
910
|
* @returns
|
|
787
911
|
*/
|
|
788
912
|
toJSON(): Serializable;
|
|
913
|
+
/**
|
|
914
|
+
* Determine if another model represents the same persisted record.
|
|
915
|
+
*
|
|
916
|
+
* @param model
|
|
917
|
+
* @returns
|
|
918
|
+
*/
|
|
919
|
+
is(model: unknown): boolean;
|
|
920
|
+
/**
|
|
921
|
+
* Determine if another model does not represent the same persisted record.
|
|
922
|
+
*
|
|
923
|
+
* @param model
|
|
924
|
+
* @returns
|
|
925
|
+
*/
|
|
926
|
+
isNot(model: unknown): boolean;
|
|
927
|
+
/**
|
|
928
|
+
* Determine if another model is the same in-memory instance.
|
|
929
|
+
*
|
|
930
|
+
* @param model
|
|
931
|
+
* @returns
|
|
932
|
+
*/
|
|
933
|
+
isSame(model: unknown): boolean;
|
|
934
|
+
/**
|
|
935
|
+
* Determine if another model is not the same in-memory instance.
|
|
936
|
+
*
|
|
937
|
+
* @param model
|
|
938
|
+
* @returns
|
|
939
|
+
*/
|
|
940
|
+
isNotSame(model: unknown): boolean;
|
|
789
941
|
/**
|
|
790
942
|
* Define a has one relationship.
|
|
791
943
|
*
|
|
@@ -886,6 +1038,20 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
886
1038
|
* @returns
|
|
887
1039
|
*/
|
|
888
1040
|
private resolveGetMutator;
|
|
1041
|
+
/**
|
|
1042
|
+
* Build a map of dirty attributes, optionally limited to specific keys.
|
|
1043
|
+
*
|
|
1044
|
+
* @param keys
|
|
1045
|
+
* @returns
|
|
1046
|
+
*/
|
|
1047
|
+
private getDirtyAttributes;
|
|
1048
|
+
/**
|
|
1049
|
+
* Normalize a key or key list for dirty/change lookups.
|
|
1050
|
+
*
|
|
1051
|
+
* @param keys
|
|
1052
|
+
* @returns
|
|
1053
|
+
*/
|
|
1054
|
+
private normalizeAttributeKeys;
|
|
889
1055
|
/**
|
|
890
1056
|
* Resolve an Attribute object mutator method for a given key, if it exists.
|
|
891
1057
|
*
|
|
@@ -908,6 +1074,67 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
|
|
|
908
1074
|
* Ensures event listeners are own properties on subclass constructors.
|
|
909
1075
|
*/
|
|
910
1076
|
private static ensureOwnEventListeners;
|
|
1077
|
+
/**
|
|
1078
|
+
* Clone an attribute value to keep snapshot state isolated from live mutations.
|
|
1079
|
+
*
|
|
1080
|
+
* @param value
|
|
1081
|
+
* @returns
|
|
1082
|
+
*/
|
|
1083
|
+
private static cloneAttributeValue;
|
|
1084
|
+
/**
|
|
1085
|
+
* Compare attribute values for dirty/change detection.
|
|
1086
|
+
*
|
|
1087
|
+
* @param left
|
|
1088
|
+
* @param right
|
|
1089
|
+
* @returns
|
|
1090
|
+
*/
|
|
1091
|
+
private static areAttributeValuesEqual;
|
|
1092
|
+
/**
|
|
1093
|
+
* Sync the original snapshot to the model's current raw attributes.
|
|
1094
|
+
*/
|
|
1095
|
+
private syncOriginal;
|
|
1096
|
+
/**
|
|
1097
|
+
* Sync the last-changed snapshot from a previous original state.
|
|
1098
|
+
*
|
|
1099
|
+
* @param previousOriginal
|
|
1100
|
+
*/
|
|
1101
|
+
private syncChanges;
|
|
1102
|
+
/**
|
|
1103
|
+
* Resolve lifecycle state for the provided model class.
|
|
1104
|
+
*
|
|
1105
|
+
* @param modelClass
|
|
1106
|
+
* @returns
|
|
1107
|
+
*/
|
|
1108
|
+
private static getLifecycleState;
|
|
1109
|
+
/**
|
|
1110
|
+
* Ensure the target model class has executed its boot lifecycle.
|
|
1111
|
+
*
|
|
1112
|
+
* @param modelClass
|
|
1113
|
+
*/
|
|
1114
|
+
private static ensureModelBooted;
|
|
1115
|
+
/**
|
|
1116
|
+
* Determine if global scopes are currently suppressed for the model class.
|
|
1117
|
+
*
|
|
1118
|
+
* @param modelClass
|
|
1119
|
+
* @returns
|
|
1120
|
+
*/
|
|
1121
|
+
private static areGlobalScopesSuppressed;
|
|
1122
|
+
/**
|
|
1123
|
+
* Resolve configured class-based event handlers for a lifecycle event.
|
|
1124
|
+
*
|
|
1125
|
+
* @param modelClass
|
|
1126
|
+
* @param event
|
|
1127
|
+
* @returns
|
|
1128
|
+
*/
|
|
1129
|
+
private static resolveDispatchedEventListeners;
|
|
1130
|
+
/**
|
|
1131
|
+
* Determine whether a lifecycle event has any registered listeners.
|
|
1132
|
+
*
|
|
1133
|
+
* @param modelClass
|
|
1134
|
+
* @param event
|
|
1135
|
+
* @returns
|
|
1136
|
+
*/
|
|
1137
|
+
private static hasEventListeners;
|
|
911
1138
|
/**
|
|
912
1139
|
* Dispatches lifecycle events to registered listeners.
|
|
913
1140
|
*
|
|
@@ -934,6 +1161,15 @@ type DelegateFromPrismaClient<TKey extends string> = LowercaseString<TKey> exten
|
|
|
934
1161
|
type DelegateForModelSchema<TSchema extends PrismaDelegateLike | Record<string, unknown> | string> = TSchema extends PrismaDelegateLike ? TSchema : TSchema extends string ? DelegateFromPrismaClient<TSchema> extends PrismaDelegateLike ? DelegateFromPrismaClient<TSchema> : PrismaDelegateLike : PrismaDelegateLike;
|
|
935
1162
|
type ModelAttributesOf<TSchema extends PrismaDelegateLike | Record<string, unknown> | string> = TSchema extends PrismaDelegateLike ? DelegateRow<TSchema> extends Record<string, unknown> ? DelegateRow<TSchema> : Record<string, any> : TSchema extends string ? DelegateFromPrismaClient<TSchema> extends PrismaDelegateLike ? DelegateRow<DelegateFromPrismaClient<TSchema>> extends Record<string, unknown> ? DelegateRow<DelegateFromPrismaClient<TSchema>> : Record<string, any> : Record<string, any> : TSchema extends Record<string, unknown> ? TSchema : Record<string, any>;
|
|
936
1163
|
type ModelAttributes<TModel> = TModel extends Model<infer TSchema> ? ModelAttributesOf<TSchema> : Record<string, any>;
|
|
1164
|
+
type RelatedModelClass<TInstance = unknown> = (abstract new (attributes?: Record<string, unknown>) => TInstance) & RelationshipModelStatic;
|
|
1165
|
+
type GlobalScope = (query: QueryBuilder<any, any>) => QueryBuilder<any, any> | void;
|
|
1166
|
+
type ModelEventName = 'retrieved' | 'saving' | 'saved' | 'creating' | 'created' | 'updating' | 'updated' | 'deleting' | 'deleted' | 'restoring' | 'restored' | 'forceDeleting' | 'forceDeleted';
|
|
1167
|
+
type ModelEventListener<TModel extends Model = Model> = (model: TModel) => void | Promise<void>;
|
|
1168
|
+
type ModelEventHandler<TModel extends Model = Model> = {
|
|
1169
|
+
handle: (model: TModel) => void | Promise<void>;
|
|
1170
|
+
};
|
|
1171
|
+
type ModelEventHandlerConstructor<TModel extends Model = Model> = new () => ModelEventHandler<TModel>;
|
|
1172
|
+
type ModelEventDispatcher<TModel extends Model = Model> = ModelEventHandler<TModel> | ModelEventHandlerConstructor<TModel>;
|
|
937
1173
|
//#endregion
|
|
938
1174
|
//#region src/Paginator.d.ts
|
|
939
1175
|
/**
|
|
@@ -1772,6 +2008,8 @@ interface ModelStatic<TModel, TDelegate extends PrismaDelegateLike = PrismaDeleg
|
|
|
1772
2008
|
query: () => QueryBuilder<TModel, TDelegate>;
|
|
1773
2009
|
hydrate: (attributes: DelegateRow<TDelegate> extends Record<string, unknown> ? DelegateRow<TDelegate> : Record<string, unknown>) => TModel;
|
|
1774
2010
|
hydrateMany: (attributes: (DelegateRow<TDelegate> extends Record<string, unknown> ? DelegateRow<TDelegate> : Record<string, unknown>)[]) => TModel[];
|
|
2011
|
+
hydrateRetrieved: (attributes: DelegateRow<TDelegate> extends Record<string, unknown> ? DelegateRow<TDelegate> : Record<string, unknown>) => Promise<TModel>;
|
|
2012
|
+
hydrateManyRetrieved: (attributes: (DelegateRow<TDelegate> extends Record<string, unknown> ? DelegateRow<TDelegate> : Record<string, unknown>)[]) => Promise<TModel[]>;
|
|
1775
2013
|
getDelegate: (delegate?: string) => TDelegate;
|
|
1776
2014
|
getSoftDeleteConfig: () => SoftDeleteConfig;
|
|
1777
2015
|
}
|
|
@@ -1789,6 +2027,15 @@ interface CastHandler<T = unknown> {
|
|
|
1789
2027
|
type CastDefinition = CastType | CastHandler;
|
|
1790
2028
|
type CastMap = Record<string, CastDefinition>;
|
|
1791
2029
|
type PrismaClientLike = PrismaClient | Record<string, unknown>;
|
|
2030
|
+
interface PrismaTransactionOptions {
|
|
2031
|
+
maxWait?: number;
|
|
2032
|
+
timeout?: number;
|
|
2033
|
+
isolationLevel?: string;
|
|
2034
|
+
}
|
|
2035
|
+
type PrismaTransactionCallback<TResult = unknown> = (client: PrismaClientLike) => TResult | Promise<TResult>;
|
|
2036
|
+
interface PrismaTransactionCapableClient {
|
|
2037
|
+
$transaction: <TResult>(callback: PrismaTransactionCallback<TResult>, options?: PrismaTransactionOptions) => Promise<TResult>;
|
|
2038
|
+
}
|
|
1792
2039
|
type ClientResolver = PrismaClientLike | (() => PrismaClientLike);
|
|
1793
2040
|
interface ArkormConfig {
|
|
1794
2041
|
/**
|
|
@@ -2791,8 +3038,34 @@ declare abstract class Seeder {
|
|
|
2791
3038
|
* @author Legacy (3m1n3nc3)
|
|
2792
3039
|
* @since 0.1.0
|
|
2793
3040
|
*/
|
|
3041
|
+
interface ArkormErrorContext {
|
|
3042
|
+
code?: string;
|
|
3043
|
+
operation?: string;
|
|
3044
|
+
model?: string;
|
|
3045
|
+
delegate?: string;
|
|
3046
|
+
relation?: string;
|
|
3047
|
+
scope?: string;
|
|
3048
|
+
meta?: Record<string, unknown>;
|
|
3049
|
+
cause?: unknown;
|
|
3050
|
+
}
|
|
2794
3051
|
declare class ArkormException extends Error {
|
|
2795
|
-
|
|
3052
|
+
readonly code?: string;
|
|
3053
|
+
readonly operation?: string;
|
|
3054
|
+
readonly model?: string;
|
|
3055
|
+
readonly delegate?: string;
|
|
3056
|
+
readonly relation?: string;
|
|
3057
|
+
readonly scope?: string;
|
|
3058
|
+
readonly meta?: Record<string, unknown>;
|
|
3059
|
+
constructor(message: string, context?: ArkormErrorContext);
|
|
3060
|
+
getContext(): Omit<ArkormErrorContext, 'cause'> & {
|
|
3061
|
+
cause?: unknown;
|
|
3062
|
+
};
|
|
3063
|
+
toJSON(): Record<string, unknown>;
|
|
3064
|
+
}
|
|
3065
|
+
//#endregion
|
|
3066
|
+
//#region src/Exceptions/MissingDelegateException.d.ts
|
|
3067
|
+
declare class MissingDelegateException extends ArkormException {
|
|
3068
|
+
constructor(message: string, context?: ArkormErrorContext);
|
|
2796
3069
|
}
|
|
2797
3070
|
//#endregion
|
|
2798
3071
|
//#region src/Exceptions/ModelNotFoundException.d.ts
|
|
@@ -2805,10 +3078,35 @@ declare class ArkormException extends Error {
|
|
|
2805
3078
|
*/
|
|
2806
3079
|
declare class ModelNotFoundException extends ArkormException {
|
|
2807
3080
|
private modelName;
|
|
2808
|
-
constructor(modelName: string, message?: string);
|
|
3081
|
+
constructor(modelName: string, message?: string, context?: ArkormErrorContext);
|
|
2809
3082
|
getModelName(): string;
|
|
2810
3083
|
}
|
|
2811
3084
|
//#endregion
|
|
3085
|
+
//#region src/Exceptions/QueryConstraintException.d.ts
|
|
3086
|
+
declare class QueryConstraintException extends ArkormException {
|
|
3087
|
+
constructor(message: string, context?: ArkormErrorContext);
|
|
3088
|
+
}
|
|
3089
|
+
//#endregion
|
|
3090
|
+
//#region src/Exceptions/RelationResolutionException.d.ts
|
|
3091
|
+
declare class RelationResolutionException extends ArkormException {
|
|
3092
|
+
constructor(message: string, context?: ArkormErrorContext);
|
|
3093
|
+
}
|
|
3094
|
+
//#endregion
|
|
3095
|
+
//#region src/Exceptions/ScopeNotDefinedException.d.ts
|
|
3096
|
+
declare class ScopeNotDefinedException extends ArkormException {
|
|
3097
|
+
constructor(message: string, context?: ArkormErrorContext);
|
|
3098
|
+
}
|
|
3099
|
+
//#endregion
|
|
3100
|
+
//#region src/Exceptions/UniqueConstraintResolutionException.d.ts
|
|
3101
|
+
declare class UniqueConstraintResolutionException extends ArkormException {
|
|
3102
|
+
constructor(message: string, context?: ArkormErrorContext);
|
|
3103
|
+
}
|
|
3104
|
+
//#endregion
|
|
3105
|
+
//#region src/Exceptions/UnsupportedAdapterFeatureException.d.ts
|
|
3106
|
+
declare class UnsupportedAdapterFeatureException extends ArkormException {
|
|
3107
|
+
constructor(message: string, context?: ArkormErrorContext);
|
|
3108
|
+
}
|
|
3109
|
+
//#endregion
|
|
2812
3110
|
//#region src/helpers/migration-history.d.ts
|
|
2813
3111
|
declare const resolveMigrationStateFilePath: (cwd: string, configuredPath?: string) => string;
|
|
2814
3112
|
declare const buildMigrationIdentity: (filePath: string, className: string) => string;
|
|
@@ -3125,6 +3423,9 @@ declare const getDefaultStubsPath: () => string;
|
|
|
3125
3423
|
* @returns
|
|
3126
3424
|
*/
|
|
3127
3425
|
declare const getRuntimePrismaClient: () => PrismaClientLike | undefined;
|
|
3426
|
+
declare const getActiveTransactionClient: () => PrismaClientLike | undefined;
|
|
3427
|
+
declare const isTransactionCapableClient: (value: unknown) => value is PrismaTransactionCapableClient;
|
|
3428
|
+
declare const runArkormTransaction: <TResult>(callback: PrismaTransactionCallback<TResult>, options?: PrismaTransactionOptions) => Promise<TResult>;
|
|
3128
3429
|
/**
|
|
3129
3430
|
* Get the configured pagination URL driver factory from runtime config.
|
|
3130
3431
|
*
|
|
@@ -3191,4 +3492,4 @@ declare class URLDriver {
|
|
|
3191
3492
|
url(page: number): string;
|
|
3192
3493
|
}
|
|
3193
3494
|
//#endregion
|
|
3194
|
-
export { ArkormCollection, ArkormException, Attribute, AttributeOptions, CliApp, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, SEEDER_BRAND, SchemaBuilder, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findModelBlock, formatDefaultValue, formatRelationAction, generateMigrationFile, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
|
|
3495
|
+
export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findModelBlock, formatDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
|