arkormx 2.9.2 → 2.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- import { Kysely, Transaction } from "kysely";
2
- import { PrismaClient } from "@prisma/client";
3
1
  import { Collection } from "@h3ravel/collect.js";
2
+ import { Kysely, Transaction } from "kysely";
4
3
  import { Command } from "@h3ravel/musket";
4
+ import { PrismaClient } from "@prisma/client";
5
5
 
6
6
  //#region src/types/migrations.d.ts
7
- type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'boolean' | 'json' | 'date' | 'timestamp';
7
+ type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'decimal' | 'boolean' | 'json' | 'date' | 'dateTime' | 'timestamp';
8
8
  interface PrimaryKeyGeneration {
9
9
  strategy: 'uuid';
10
10
  prismaDefault?: string;
@@ -29,6 +29,10 @@ interface SchemaColumn {
29
29
  after?: string;
30
30
  default?: unknown;
31
31
  updatedAt?: boolean;
32
+ /** Total number of digits for `decimal` columns. */
33
+ precision?: number;
34
+ /** Number of digits to the right of the decimal point for `decimal` columns. */
35
+ scale?: number;
32
36
  primaryKeyGeneration?: PrimaryKeyGeneration;
33
37
  }
34
38
  interface SchemaIndex {
@@ -291,7 +295,7 @@ declare class LengthAwarePaginator<T> {
291
295
  readonly meta: PaginationMeta;
292
296
  private readonly urlDriver;
293
297
  /**
294
- * Creates a new LengthAwarePaginator instance.
298
+ * Creates a new LengthAwarePaginator instance.
295
299
  *
296
300
  * @param data The collection of data being paginated.
297
301
  * @param total The total number of items.
@@ -2373,8 +2377,8 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2373
2377
  constructor(attributes?: Record<string, unknown>);
2374
2378
  private static emitDeprecationWarning;
2375
2379
  /**
2376
- * Compatibility-only runtime API retained for the 2.x transition window.
2377
- * This is no longer part of the supported runtime bootstrap path.
2380
+ * Compatibility-only runtime API retained for the 2.x transition window.
2381
+ * This is no longer part of the supported runtime bootstrap path.
2378
2382
  *
2379
2383
  * @deprecated Use Model.setAdapter(createPrismaDatabaseAdapter(...)) or another
2380
2384
  * adapter-first bootstrap path instead.
@@ -2899,7 +2903,7 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2899
2903
  * Define a belongs to many relationship.
2900
2904
  *
2901
2905
  * @param related
2902
- * @param throughTable
2906
+ * @param throughTable
2903
2907
  * @param foreignPivotKey
2904
2908
  * @param relatedPivotKey
2905
2909
  * @param parentKey
@@ -2911,7 +2915,7 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2911
2915
  * Define a has one through relationship.
2912
2916
  *
2913
2917
  * @param related
2914
- * @param throughTable
2918
+ * @param throughTable
2915
2919
  * @param firstKey
2916
2920
  * @param secondKey
2917
2921
  * @param localKey
@@ -2923,7 +2927,7 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2923
2927
  * Define a has many through relationship.
2924
2928
  *
2925
2929
  * @param related
2926
- * @param throughTable
2930
+ * @param throughTable
2927
2931
  * @param firstKey
2928
2932
  * @param secondKey
2929
2933
  * @param localKey
@@ -4563,8 +4567,8 @@ declare class QueryBuilder<TModel, TDelegate extends ModelQuerySchemaLike = Mode
4563
4567
  */
4564
4568
  orWhereRaw(sql: string, bindings?: unknown[]): this;
4565
4569
  /**
4566
- * Paginates the query results and returns a LengthAwarePaginator instance
4567
- * containing data and total-aware pagination metadata.
4570
+ * Paginates the query results and returns a LengthAwarePaginator instance
4571
+ * containing data and total-aware pagination metadata.
4568
4572
  *
4569
4573
  * @param page
4570
4574
  * @param perPage
@@ -4723,7 +4727,7 @@ interface RelationshipModelStatic {
4723
4727
  }
4724
4728
  //#endregion
4725
4729
  //#region src/types/core.d.ts
4726
- type CastType = 'string' | 'number' | 'boolean' | 'date' | 'json' | 'array';
4730
+ type CastType = 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'json' | 'array';
4727
4731
  interface CastHandler<T = unknown> {
4728
4732
  get: (value: unknown) => T;
4729
4733
  set: (value: unknown) => unknown;
@@ -4803,12 +4807,12 @@ type NamingCase = 'camel' | 'snake' | 'kebab' | 'studly';
4803
4807
  type ModelTableCase = NamingCase;
4804
4808
  interface ArkormConfig {
4805
4809
  /**
4806
- * @property client Optional runtime client instance or resolver used for compatibility mode, CLI flows, and client-backed transactions.
4807
- */
4810
+ * @property client Optional runtime client instance or resolver used for compatibility mode, CLI flows, and client-backed transactions.
4811
+ */
4808
4812
  client?: ClientResolver;
4809
4813
  /**
4810
- * @deprecated Use client instead.
4811
- * @property prisma Optional Prisma client instance or resolver used for compatibility mode, CLI flows, and Prisma-backed transactions.
4814
+ * @deprecated Use client instead.
4815
+ * @property prisma Optional Prisma client instance or resolver used for compatibility mode, CLI flows, and Prisma-backed transactions.
4812
4816
  */
4813
4817
  prisma?: ClientResolver;
4814
4818
  /**
@@ -6307,7 +6311,7 @@ declare class CliApp {
6307
6311
  *
6308
6312
  * @param schema The Prisma schema source.
6309
6313
  * @returns A map of enum names to their declared member names.
6310
- */
6314
+ */
6311
6315
  private parsePrismaEnums;
6312
6316
  /**
6313
6317
  * Resolve the generated TypeScript declaration type for a Prisma field.
@@ -6796,6 +6800,16 @@ declare class TableBuilder {
6796
6800
  * @returns The current TableBuilder instance for chaining.
6797
6801
  */
6798
6802
  float(name: string, options?: Partial<SchemaColumn>): this;
6803
+ /**
6804
+ * Defines a fixed-precision decimal column in the table.
6805
+ *
6806
+ * @param name The name of the decimal column.
6807
+ * @param precision The total number of digits. Defaults to 8.
6808
+ * @param scale The number of digits to the right of the point. Defaults to 2.
6809
+ * @param options Additional options for the decimal column.
6810
+ * @returns The current TableBuilder instance for chaining.
6811
+ */
6812
+ decimal(name: string, precision?: number, scale?: number, options?: Partial<SchemaColumn>): this;
6799
6813
  /**
6800
6814
  * Marks a column as unique in the table.
6801
6815
  *
@@ -6829,6 +6843,14 @@ declare class TableBuilder {
6829
6843
  * @returns
6830
6844
  */
6831
6845
  date(name: string, options?: Partial<SchemaColumn>): this;
6846
+ /**
6847
+ * Defines a date-time column in the table (timestamp without time zone).
6848
+ *
6849
+ * @param name The name of the date-time column.
6850
+ * @param options Additional options for the date-time column.
6851
+ * @returns The current TableBuilder instance for chaining.
6852
+ */
6853
+ dateTime(name: string, options?: Partial<SchemaColumn>): this;
6832
6854
  /**
6833
6855
  * Defines colonns for a polymorphic relationship in the table.
6834
6856
  *
@@ -7029,6 +7051,47 @@ declare class TableBuilder {
7029
7051
  */
7030
7052
  declare class SchemaBuilder {
7031
7053
  private readonly operations;
7054
+ /**
7055
+ * Disable foreign-key constraint enforcement on the active PostgreSQL
7056
+ * connection by switching the session into replication mode, which
7057
+ * suppresses the internal triggers that enforce foreign keys.
7058
+ *
7059
+ * The setting is connection-scoped, so the disable, the work that depends
7060
+ * on it, and the matching {@link SchemaBuilder.enableForeignKeyConstraints}
7061
+ * must run on the same connection. Prefer
7062
+ * {@link SchemaBuilder.withoutForeignKeyConstraints}, which guarantees this
7063
+ * by wrapping the work in a transaction. Requires a SQL-backed adapter and
7064
+ * a database role permitted to set `session_replication_role`.
7065
+ *
7066
+ * @returns
7067
+ */
7068
+ static disableForeignKeyConstraints(): Promise<void>;
7069
+ /**
7070
+ * Re-enable foreign-key constraint enforcement on the active PostgreSQL
7071
+ * connection by restoring the default session replication role.
7072
+ *
7073
+ * @returns
7074
+ */
7075
+ static enableForeignKeyConstraints(): Promise<void>;
7076
+ /**
7077
+ * Run the given callback with foreign-key constraints disabled, then
7078
+ * restore them. The whole unit runs inside a transaction so the disable,
7079
+ * the callback, and the re-enable share a single connection (required for
7080
+ * the connection-scoped replication role to take effect) and roll back
7081
+ * together on failure.
7082
+ *
7083
+ * @example
7084
+ * await SchemaBuilder.withoutForeignKeyConstraints(async () => {
7085
+ * await User.factory()
7086
+ * .hasAttached(Tenant.factory().has(Project.factory(3)), { status: 'active' }, 'tenantMemberships')
7087
+ * .create()
7088
+ * })
7089
+ *
7090
+ * @param callback
7091
+ * @returns
7092
+ */
7093
+ static withoutForeignKeyConstraints<TResult>(callback: () => TResult | Promise<TResult>): Promise<TResult>;
7094
+ private static setSessionReplicationRole;
7032
7095
  /**
7033
7096
  * Defines a new table to be created in the migration.
7034
7097
  *
@@ -1,10 +1,10 @@
1
- import { Collection } from "@h3ravel/collect.js";
2
1
  import { Kysely, Transaction } from "kysely";
3
- import { Command } from "@h3ravel/musket";
4
2
  import { PrismaClient } from "@prisma/client";
3
+ import { Collection } from "@h3ravel/collect.js";
4
+ import { Command } from "@h3ravel/musket";
5
5
 
6
6
  //#region src/types/migrations.d.ts
7
- type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'boolean' | 'json' | 'date' | 'timestamp';
7
+ type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'decimal' | 'boolean' | 'json' | 'date' | 'dateTime' | 'timestamp';
8
8
  interface PrimaryKeyGeneration {
9
9
  strategy: 'uuid';
10
10
  prismaDefault?: string;
@@ -29,6 +29,10 @@ interface SchemaColumn {
29
29
  after?: string;
30
30
  default?: unknown;
31
31
  updatedAt?: boolean;
32
+ /** Total number of digits for `decimal` columns. */
33
+ precision?: number;
34
+ /** Number of digits to the right of the decimal point for `decimal` columns. */
35
+ scale?: number;
32
36
  primaryKeyGeneration?: PrimaryKeyGeneration;
33
37
  }
34
38
  interface SchemaIndex {
@@ -291,7 +295,7 @@ declare class LengthAwarePaginator<T> {
291
295
  readonly meta: PaginationMeta;
292
296
  private readonly urlDriver;
293
297
  /**
294
- * Creates a new LengthAwarePaginator instance.
298
+ * Creates a new LengthAwarePaginator instance.
295
299
  *
296
300
  * @param data The collection of data being paginated.
297
301
  * @param total The total number of items.
@@ -2373,8 +2377,8 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2373
2377
  constructor(attributes?: Record<string, unknown>);
2374
2378
  private static emitDeprecationWarning;
2375
2379
  /**
2376
- * Compatibility-only runtime API retained for the 2.x transition window.
2377
- * This is no longer part of the supported runtime bootstrap path.
2380
+ * Compatibility-only runtime API retained for the 2.x transition window.
2381
+ * This is no longer part of the supported runtime bootstrap path.
2378
2382
  *
2379
2383
  * @deprecated Use Model.setAdapter(createPrismaDatabaseAdapter(...)) or another
2380
2384
  * adapter-first bootstrap path instead.
@@ -2899,7 +2903,7 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2899
2903
  * Define a belongs to many relationship.
2900
2904
  *
2901
2905
  * @param related
2902
- * @param throughTable
2906
+ * @param throughTable
2903
2907
  * @param foreignPivotKey
2904
2908
  * @param relatedPivotKey
2905
2909
  * @param parentKey
@@ -2911,7 +2915,7 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2911
2915
  * Define a has one through relationship.
2912
2916
  *
2913
2917
  * @param related
2914
- * @param throughTable
2918
+ * @param throughTable
2915
2919
  * @param firstKey
2916
2920
  * @param secondKey
2917
2921
  * @param localKey
@@ -2923,7 +2927,7 @@ declare abstract class Model<TSchema extends ModelQuerySchemaLike | Record<strin
2923
2927
  * Define a has many through relationship.
2924
2928
  *
2925
2929
  * @param related
2926
- * @param throughTable
2930
+ * @param throughTable
2927
2931
  * @param firstKey
2928
2932
  * @param secondKey
2929
2933
  * @param localKey
@@ -4563,8 +4567,8 @@ declare class QueryBuilder<TModel, TDelegate extends ModelQuerySchemaLike = Mode
4563
4567
  */
4564
4568
  orWhereRaw(sql: string, bindings?: unknown[]): this;
4565
4569
  /**
4566
- * Paginates the query results and returns a LengthAwarePaginator instance
4567
- * containing data and total-aware pagination metadata.
4570
+ * Paginates the query results and returns a LengthAwarePaginator instance
4571
+ * containing data and total-aware pagination metadata.
4568
4572
  *
4569
4573
  * @param page
4570
4574
  * @param perPage
@@ -4723,7 +4727,7 @@ interface RelationshipModelStatic {
4723
4727
  }
4724
4728
  //#endregion
4725
4729
  //#region src/types/core.d.ts
4726
- type CastType = 'string' | 'number' | 'boolean' | 'date' | 'json' | 'array';
4730
+ type CastType = 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'json' | 'array';
4727
4731
  interface CastHandler<T = unknown> {
4728
4732
  get: (value: unknown) => T;
4729
4733
  set: (value: unknown) => unknown;
@@ -4803,12 +4807,12 @@ type NamingCase = 'camel' | 'snake' | 'kebab' | 'studly';
4803
4807
  type ModelTableCase = NamingCase;
4804
4808
  interface ArkormConfig {
4805
4809
  /**
4806
- * @property client Optional runtime client instance or resolver used for compatibility mode, CLI flows, and client-backed transactions.
4807
- */
4810
+ * @property client Optional runtime client instance or resolver used for compatibility mode, CLI flows, and client-backed transactions.
4811
+ */
4808
4812
  client?: ClientResolver;
4809
4813
  /**
4810
- * @deprecated Use client instead.
4811
- * @property prisma Optional Prisma client instance or resolver used for compatibility mode, CLI flows, and Prisma-backed transactions.
4814
+ * @deprecated Use client instead.
4815
+ * @property prisma Optional Prisma client instance or resolver used for compatibility mode, CLI flows, and Prisma-backed transactions.
4812
4816
  */
4813
4817
  prisma?: ClientResolver;
4814
4818
  /**
@@ -6307,7 +6311,7 @@ declare class CliApp {
6307
6311
  *
6308
6312
  * @param schema The Prisma schema source.
6309
6313
  * @returns A map of enum names to their declared member names.
6310
- */
6314
+ */
6311
6315
  private parsePrismaEnums;
6312
6316
  /**
6313
6317
  * Resolve the generated TypeScript declaration type for a Prisma field.
@@ -6796,6 +6800,16 @@ declare class TableBuilder {
6796
6800
  * @returns The current TableBuilder instance for chaining.
6797
6801
  */
6798
6802
  float(name: string, options?: Partial<SchemaColumn>): this;
6803
+ /**
6804
+ * Defines a fixed-precision decimal column in the table.
6805
+ *
6806
+ * @param name The name of the decimal column.
6807
+ * @param precision The total number of digits. Defaults to 8.
6808
+ * @param scale The number of digits to the right of the point. Defaults to 2.
6809
+ * @param options Additional options for the decimal column.
6810
+ * @returns The current TableBuilder instance for chaining.
6811
+ */
6812
+ decimal(name: string, precision?: number, scale?: number, options?: Partial<SchemaColumn>): this;
6799
6813
  /**
6800
6814
  * Marks a column as unique in the table.
6801
6815
  *
@@ -6829,6 +6843,14 @@ declare class TableBuilder {
6829
6843
  * @returns
6830
6844
  */
6831
6845
  date(name: string, options?: Partial<SchemaColumn>): this;
6846
+ /**
6847
+ * Defines a date-time column in the table (timestamp without time zone).
6848
+ *
6849
+ * @param name The name of the date-time column.
6850
+ * @param options Additional options for the date-time column.
6851
+ * @returns The current TableBuilder instance for chaining.
6852
+ */
6853
+ dateTime(name: string, options?: Partial<SchemaColumn>): this;
6832
6854
  /**
6833
6855
  * Defines colonns for a polymorphic relationship in the table.
6834
6856
  *
@@ -7029,6 +7051,47 @@ declare class TableBuilder {
7029
7051
  */
7030
7052
  declare class SchemaBuilder {
7031
7053
  private readonly operations;
7054
+ /**
7055
+ * Disable foreign-key constraint enforcement on the active PostgreSQL
7056
+ * connection by switching the session into replication mode, which
7057
+ * suppresses the internal triggers that enforce foreign keys.
7058
+ *
7059
+ * The setting is connection-scoped, so the disable, the work that depends
7060
+ * on it, and the matching {@link SchemaBuilder.enableForeignKeyConstraints}
7061
+ * must run on the same connection. Prefer
7062
+ * {@link SchemaBuilder.withoutForeignKeyConstraints}, which guarantees this
7063
+ * by wrapping the work in a transaction. Requires a SQL-backed adapter and
7064
+ * a database role permitted to set `session_replication_role`.
7065
+ *
7066
+ * @returns
7067
+ */
7068
+ static disableForeignKeyConstraints(): Promise<void>;
7069
+ /**
7070
+ * Re-enable foreign-key constraint enforcement on the active PostgreSQL
7071
+ * connection by restoring the default session replication role.
7072
+ *
7073
+ * @returns
7074
+ */
7075
+ static enableForeignKeyConstraints(): Promise<void>;
7076
+ /**
7077
+ * Run the given callback with foreign-key constraints disabled, then
7078
+ * restore them. The whole unit runs inside a transaction so the disable,
7079
+ * the callback, and the re-enable share a single connection (required for
7080
+ * the connection-scoped replication role to take effect) and roll back
7081
+ * together on failure.
7082
+ *
7083
+ * @example
7084
+ * await SchemaBuilder.withoutForeignKeyConstraints(async () => {
7085
+ * await User.factory()
7086
+ * .hasAttached(Tenant.factory().has(Project.factory(3)), { status: 'active' }, 'tenantMemberships')
7087
+ * .create()
7088
+ * })
7089
+ *
7090
+ * @param callback
7091
+ * @returns
7092
+ */
7093
+ static withoutForeignKeyConstraints<TResult>(callback: () => TResult | Promise<TResult>): Promise<TResult>;
7094
+ private static setSessionReplicationRole;
7032
7095
  /**
7033
7096
  * Defines a new table to be created in the migration.
7034
7097
  *