forge-sql-orm 2.0.30 → 2.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.
Files changed (46) hide show
  1. package/README.md +1090 -81
  2. package/dist/ForgeSQLORM.js +1080 -60
  3. package/dist/ForgeSQLORM.js.map +1 -1
  4. package/dist/ForgeSQLORM.mjs +1063 -60
  5. package/dist/ForgeSQLORM.mjs.map +1 -1
  6. package/dist/core/ForgeSQLAnalyseOperations.d.ts +1 -1
  7. package/dist/core/ForgeSQLAnalyseOperations.d.ts.map +1 -1
  8. package/dist/core/ForgeSQLCacheOperations.d.ts +119 -0
  9. package/dist/core/ForgeSQLCacheOperations.d.ts.map +1 -0
  10. package/dist/core/ForgeSQLCrudOperations.d.ts +38 -22
  11. package/dist/core/ForgeSQLCrudOperations.d.ts.map +1 -1
  12. package/dist/core/ForgeSQLORM.d.ts +104 -13
  13. package/dist/core/ForgeSQLORM.d.ts.map +1 -1
  14. package/dist/core/ForgeSQLQueryBuilder.d.ts +243 -15
  15. package/dist/core/ForgeSQLQueryBuilder.d.ts.map +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/lib/drizzle/extensions/additionalActions.d.ts +42 -0
  19. package/dist/lib/drizzle/extensions/additionalActions.d.ts.map +1 -0
  20. package/dist/utils/cacheContextUtils.d.ts +123 -0
  21. package/dist/utils/cacheContextUtils.d.ts.map +1 -0
  22. package/dist/utils/cacheUtils.d.ts +56 -0
  23. package/dist/utils/cacheUtils.d.ts.map +1 -0
  24. package/dist/utils/sqlUtils.d.ts +8 -0
  25. package/dist/utils/sqlUtils.d.ts.map +1 -1
  26. package/dist/webtriggers/clearCacheSchedulerTrigger.d.ts +46 -0
  27. package/dist/webtriggers/clearCacheSchedulerTrigger.d.ts.map +1 -0
  28. package/dist/webtriggers/index.d.ts +1 -0
  29. package/dist/webtriggers/index.d.ts.map +1 -1
  30. package/package.json +15 -12
  31. package/src/core/ForgeSQLAnalyseOperations.ts +1 -1
  32. package/src/core/ForgeSQLCacheOperations.ts +195 -0
  33. package/src/core/ForgeSQLCrudOperations.ts +49 -40
  34. package/src/core/ForgeSQLORM.ts +443 -34
  35. package/src/core/ForgeSQLQueryBuilder.ts +291 -20
  36. package/src/index.ts +1 -1
  37. package/src/lib/drizzle/extensions/additionalActions.ts +548 -0
  38. package/src/lib/drizzle/extensions/types.d.ts +68 -10
  39. package/src/utils/cacheContextUtils.ts +210 -0
  40. package/src/utils/cacheUtils.ts +403 -0
  41. package/src/utils/sqlUtils.ts +16 -0
  42. package/src/webtriggers/clearCacheSchedulerTrigger.ts +79 -0
  43. package/src/webtriggers/index.ts +1 -0
  44. package/dist/lib/drizzle/extensions/selectAliased.d.ts +0 -9
  45. package/dist/lib/drizzle/extensions/selectAliased.d.ts.map +0 -1
  46. package/src/lib/drizzle/extensions/selectAliased.ts +0 -72
@@ -1,7 +1,7 @@
1
1
  import { ForgeSqlOperation, SchemaAnalyzeForgeSql } from "./ForgeSQLQueryBuilder";
2
2
  import { Query } from "drizzle-orm";
3
3
  import { ClusterStatementRowCamelCase, ExplainAnalyzeRow, SlowQueryNormalized } from "./SystemTables";
4
- import { AnyMySqlTable } from "drizzle-orm/mysql-core/index";
4
+ import { AnyMySqlTable } from "drizzle-orm/mysql-core";
5
5
  /**
6
6
  * Interface representing a raw slow query row from the database
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ForgeSQLAnalyseOperations.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLAnalyseOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;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;;;;OAMG;IACG,qBAAqB,CACzB,MAAM,EAAE,aAAa,EAAE,EACvB,QAAQ,CAAC,EAAE,IAAI,EACf,MAAM,CAAC,EAAE,IAAI,GACZ,OAAO,CAAC,4BAA4B,EAAE,CAAC;CAI3C"}
@@ -0,0 +1,119 @@
1
+ import { MySqlSelectDynamic } from "drizzle-orm/mysql-core/query-builders/select.types";
2
+ import { AnyMySqlSelectQueryBuilder, AnyMySqlTable } from "drizzle-orm/mysql-core";
3
+ import { CacheForgeSQL, ForgeSqlOperation, ForgeSqlOrmOptions } from "./ForgeSQLQueryBuilder";
4
+ import { InferInsertModel, SQL } from "drizzle-orm";
5
+ /**
6
+ * Implementation of cache operations for ForgeSQL ORM.
7
+ * Provides methods for cacheable database operations with automatic cache management.
8
+ *
9
+ * ⚠️ **IMPORTANT**: All modification methods in this class use optimistic locking/versioning
10
+ * through `modifyWithVersioning()` internally. This ensures data consistency and prevents
11
+ * concurrent modification conflicts.
12
+ */
13
+ export declare class ForgeSQLCacheOperations implements CacheForgeSQL {
14
+ private readonly options;
15
+ private readonly forgeOperations;
16
+ /**
17
+ * Creates a new instance of ForgeSQLCacheOperations.
18
+ *
19
+ * @param options - Configuration options for the ORM
20
+ * @param forgeOperations - The ForgeSQL operations instance
21
+ */
22
+ constructor(options: ForgeSqlOrmOptions, forgeOperations: ForgeSqlOperation);
23
+ /**
24
+ * Evicts cache for multiple tables using Drizzle table objects.
25
+ *
26
+ * @param tables - Array of Drizzle table objects to clear cache for
27
+ * @returns Promise that resolves when cache eviction is complete
28
+ * @throws Error if cacheEntityName is not configured
29
+ */
30
+ evictCacheEntities(tables: AnyMySqlTable[]): Promise<void>;
31
+ /**
32
+ * Evicts cache for multiple tables by their names.
33
+ *
34
+ * @param tables - Array of table names to clear cache for
35
+ * @returns Promise that resolves when cache eviction is complete
36
+ * @throws Error if cacheEntityName is not configured
37
+ */
38
+ evictCache(tables: string[]): Promise<void>;
39
+ /**
40
+ * Inserts records with optimistic locking/versioning and automatically evicts cache.
41
+ *
42
+ * This method uses `modifyWithVersioning().insert()` internally, providing:
43
+ * - Automatic version field initialization
44
+ * - Optimistic locking support
45
+ * - Cache eviction after successful operation
46
+ *
47
+ * @param schema - The table schema
48
+ * @param models - Array of entities to insert
49
+ * @param updateIfExists - Whether to update existing records
50
+ * @returns Promise that resolves to the number of inserted rows
51
+ * @throws Error if cacheEntityName is not configured
52
+ * @throws Error if optimistic locking check fails
53
+ */
54
+ insert<T extends AnyMySqlTable>(schema: T, models: InferInsertModel<T>[], updateIfExists?: boolean): Promise<number>;
55
+ /**
56
+ * Deletes a record by ID with optimistic locking/versioning and automatically evicts cache.
57
+ *
58
+ * This method uses `modifyWithVersioning().deleteById()` internally, providing:
59
+ * - Optimistic locking checks before deletion
60
+ * - Version field validation
61
+ * - Cache eviction after successful operation
62
+ *
63
+ * @param id - The ID of the record to delete
64
+ * @param schema - The table schema
65
+ * @returns Promise that resolves to the number of affected rows
66
+ * @throws Error if cacheEntityName is not configured
67
+ * @throws Error if optimistic locking check fails
68
+ */
69
+ deleteById<T extends AnyMySqlTable>(id: unknown, schema: T): Promise<number>;
70
+ /**
71
+ * Updates a record by ID with optimistic locking/versioning and automatically evicts cache.
72
+ *
73
+ * This method uses `modifyWithVersioning().updateById()` internally, providing:
74
+ * - Optimistic locking checks before update
75
+ * - Version field incrementation
76
+ * - Cache eviction after successful operation
77
+ *
78
+ * @param entity - The entity with updated values (must include primary key)
79
+ * @param schema - The table schema
80
+ * @returns Promise that resolves to the number of affected rows
81
+ * @throws Error if cacheEntityName is not configured
82
+ * @throws Error if optimistic locking check fails
83
+ */
84
+ updateById<T extends AnyMySqlTable>(entity: Partial<InferInsertModel<T>>, schema: T): Promise<number>;
85
+ /**
86
+ * Updates fields based on conditions with optimistic locking/versioning and automatically evicts cache.
87
+ *
88
+ * This method uses `modifyWithVersioning().updateFields()` internally, providing:
89
+ * - Optimistic locking support (if version field is configured)
90
+ * - Version field validation and incrementation
91
+ * - Cache eviction after successful operation
92
+ *
93
+ * @param updateData - The data to update
94
+ * @param schema - The table schema
95
+ * @param where - Optional WHERE conditions
96
+ * @returns Promise that resolves to the number of affected rows
97
+ * @throws Error if cacheEntityName is not configured
98
+ * @throws Error if optimistic locking check fails
99
+ */
100
+ updateFields<T extends AnyMySqlTable>(updateData: Partial<InferInsertModel<T>>, schema: T, where?: SQL<unknown>): Promise<number>;
101
+ /**
102
+ * Executes a query with caching support.
103
+ * First checks cache, if not found executes query and stores result in cache.
104
+ *
105
+ * @param query - The Drizzle query to execute
106
+ * @param cacheTtl - Optional cache TTL override
107
+ * @returns Promise that resolves to the query results
108
+ * @throws Error if cacheEntityName is not configured
109
+ */
110
+ executeQuery<T extends MySqlSelectDynamic<AnyMySqlSelectQueryBuilder>>(query: T, cacheTtl?: number): Promise<Awaited<T>>;
111
+ /**
112
+ * Validates that cache configuration is properly set up.
113
+ *
114
+ * @throws Error if cacheEntityName is not configured
115
+ * @private
116
+ */
117
+ private validateCacheConfiguration;
118
+ }
119
+ //# sourceMappingURL=ForgeSQLCacheOperations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgeSQLCacheOperations.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLCacheOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAS,GAAG,EAAE,MAAM,aAAa,CAAC;AAI3D;;;;;;;GAOG;AACH,qBAAa,uBAAwB,YAAW,aAAa;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoB;IAEpD;;;;;OAKG;gBACS,OAAO,EAAE,kBAAkB,EAAE,e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- import { CRUDForgeSQL, ForgeSqlOperation } from "./ForgeSQLQueryBuilder";
3
- import { AnyMySqlTable } from "drizzle-orm/mysql-core/index";
4
- import { InferInsertModel } from "drizzle-orm";
5
- import { SQL } from "drizzle-orm";
2
+ import { VerioningModificationForgeSQL, ForgeSqlOperation } from "./ForgeSQLQueryBuilder";
3
+ import { AnyMySqlTable } from "drizzle-orm/mysql-core";
4
+ import { InferInsertModel, SQL } from "drizzle-orm";
6
5
  /**
7
- * Class implementing CRUD operations for ForgeSQL ORM.
6
+ * Class implementing Modification operations for ForgeSQL ORM.
8
7
  * Provides methods for inserting, updating, and deleting records with support for optimistic locking.
9
8
  */
10
- export declare class ForgeSQLCrudOperations implements CRUDForgeSQL {
9
+ export declare class ForgeSQLCrudOperations implements VerioningModificationForgeSQL {
11
10
  private readonly forgeOperations;
12
11
  private readonly options;
13
12
  /**
@@ -20,24 +19,35 @@ export declare class ForgeSQLCrudOperations implements CRUDForgeSQL {
20
19
  * Inserts records into the database with optional versioning support.
21
20
  * If a version field exists in the schema, versioning is applied.
22
21
  *
22
+ * This method automatically handles:
23
+ * - Version field initialization for optimistic locking
24
+ * - Batch insertion for multiple records
25
+ * - Duplicate key handling with optional updates
26
+ *
23
27
  * @template T - The type of the table schema
24
- * @param {T} schema - The entity schema
25
- * @param {Partial<InferInsertModel<T>>[]} models - Array of entities to insert
26
- * @param {boolean} [updateIfExists=false] - Whether to update existing records
27
- * @returns {Promise<number>} The number of inserted rows
28
- * @throws {Error} If the insert operation fails
28
+ * @param schema - The entity schema
29
+ * @param models - Array of entities to insert
30
+ * @param updateIfExists - Whether to update existing records (default: false)
31
+ * @returns Promise that resolves to the number of inserted rows
32
+ * @throws Error if the insert operation fails
29
33
  */
30
34
  insert<T extends AnyMySqlTable>(schema: T, models: InferInsertModel<T>[], updateIfExists?: boolean): Promise<number>;
31
35
  /**
32
36
  * Deletes a record by its primary key with optional version check.
33
37
  * If versioning is enabled, ensures the record hasn't been modified since last read.
34
38
  *
39
+ * This method automatically handles:
40
+ * - Single primary key validation
41
+ * - Optimistic locking checks if versioning is enabled
42
+ * - Version field validation before deletion
43
+ *
35
44
  * @template T - The type of the table schema
36
- * @param {unknown} id - The ID of the record to delete
37
- * @param {T} schema - The entity schema
38
- * @returns {Promise<number>} Number of affected rows
39
- * @throws {Error} If the delete operation fails
40
- * @throws {Error} If multiple primary keys are found
45
+ * @param id - The ID of the record to delete
46
+ * @param schema - The entity schema
47
+ * @returns Promise that resolves to the number of affected rows
48
+ * @throws Error if the delete operation fails
49
+ * @throws Error if multiple primary keys are found
50
+ * @throws Error if optimistic locking check fails
41
51
  */
42
52
  deleteById<T extends AnyMySqlTable>(id: unknown, schema: T): Promise<number>;
43
53
  /**
@@ -47,13 +57,19 @@ export declare class ForgeSQLCrudOperations implements CRUDForgeSQL {
47
57
  * - Checks for concurrent modifications
48
58
  * - Increments the version on successful update
49
59
  *
60
+ * This method automatically handles:
61
+ * - Primary key validation
62
+ * - Version field retrieval and validation
63
+ * - Optimistic locking conflict detection
64
+ * - Version field incrementation
65
+ *
50
66
  * @template T - The type of the table schema
51
- * @param {Partial<InferInsertModel<T>>} entity - The entity with updated values
52
- * @param {T} schema - The entity schema
53
- * @returns {Promise<number>} Number of affected rows
54
- * @throws {Error} If the primary key is not provided
55
- * @throws {Error} If optimistic locking check fails
56
- * @throws {Error} If multiple primary keys are found
67
+ * @param entity - The entity with updated values (must include primary key)
68
+ * @param schema - The entity schema
69
+ * @returns Promise that resolves to the number of affected rows
70
+ * @throws Error if the primary key is not provided
71
+ * @throws Error if optimistic locking check fails
72
+ * @throws Error if multiple primary keys are found
57
73
  */
58
74
  updateById<T extends AnyMySqlTable>(entity: Partial<InferInsertModel<T>>, schema: T): Promise<number>;
59
75
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ForgeSQLCrudOperations.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLCrudOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM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EAAE,CAAC,GACR,OAAO,CAAC,MAAM,CAAC;IAwDlB;;;;;;;;;;;OAWG;IACG,YAAY,CAAC,CAAC,SAAS,aAAa,EACxC,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EACxC,MAAM,EAAE,CAAC,EACT,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,GACnB,OAAO,CAAC,MAAM,CAAC;IAclB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAStB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAoD5B;;;;;;;;;OASG;YACW,iBAAiB;IAyB/B;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IA0B/B;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;;;;;;;OAQG;YACW,WAAW;CA2B1B"}
@@ -1,7 +1,11 @@
1
- import { CRUDForgeSQL, ForgeSqlOperation, ForgeSqlOrmOptions, SchemaAnalyzeForgeSql, SchemaSqlForgeSql } from "./ForgeSQLQueryBuilder";
2
- import { MySqlRemoteDatabase, MySqlRemotePreparedQueryHKT } from "drizzle-orm/mysql-proxy";
1
+ import { VerioningModificationForgeSQL, ForgeSqlOperation, ForgeSqlOrmOptions, SchemaAnalyzeForgeSql, SchemaSqlForgeSql } from "./ForgeSQLQueryBuilder";
2
+ import { MySqlRemoteDatabase, MySqlRemotePreparedQueryHKT, MySqlRemoteQueryResultHKT } from "drizzle-orm/mysql-proxy";
3
3
  import type { SelectedFields } from "drizzle-orm/mysql-core/query-builders/select.types";
4
4
  import { MySqlSelectBuilder } from "drizzle-orm/mysql-core";
5
+ import { DeleteAndEvictCacheType, InsertAndEvictCacheType, SelectAliasedCacheableType, SelectAliasedDistinctCacheableType, SelectAliasedDistinctType, SelectAliasedType, UpdateAndEvictCacheType } from "../lib/drizzle/extensions/additionalActions";
6
+ import { ForgeSQLCacheOperations } from "./ForgeSQLCacheOperations";
7
+ import type { MySqlTable } from "drizzle-orm/mysql-core/table";
8
+ import { MySqlDeleteBase, MySqlInsertBuilder, MySqlUpdateBuilder } from "drizzle-orm/mysql-core/query-builders";
5
9
  /**
6
10
  * Public class that acts as a wrapper around the private ForgeSQLORMImpl.
7
11
  * Provides a clean interface for working with Forge SQL and Drizzle ORM.
@@ -9,6 +13,86 @@ import { MySqlSelectBuilder } from "drizzle-orm/mysql-core";
9
13
  declare class ForgeSQLORM implements ForgeSqlOperation {
10
14
  private readonly ormInstance;
11
15
  constructor(options?: ForgeSqlOrmOptions);
16
+ selectCacheable<TSelection extends SelectedFields>(fields: TSelection, cacheTTL?: number): MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>;
17
+ selectDistinctCacheable<TSelection extends SelectedFields>(fields: TSelection, cacheTTL?: number): MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>;
18
+ executeWithCacheContext(cacheContext: () => Promise<void>): Promise<void>;
19
+ executeWithCacheContextAndReturnValue<T>(cacheContext: () => Promise<T>): Promise<T>;
20
+ /**
21
+ * Executes operations within a local cache context.
22
+ * This provides in-memory caching for select queries within a single request scope.
23
+ *
24
+ * @param cacheContext - Function containing operations that will benefit from local caching
25
+ * @returns Promise that resolves when all operations are complete
26
+ */
27
+ executeWithLocalContext(cacheContext: () => Promise<void>): Promise<void>;
28
+ /**
29
+ * Executes operations within a local cache context and returns a value.
30
+ * This provides in-memory caching for select queries within a single request scope.
31
+ *
32
+ * @param cacheContext - Function containing operations that will benefit from local caching
33
+ * @returns Promise that resolves to the return value of the cacheContext function
34
+ */
35
+ executeWithLocalCacheContextAndReturnValue<T>(cacheContext: () => Promise<T>): Promise<T>;
36
+ /**
37
+ * Creates an insert query builder.
38
+ *
39
+ * ⚠️ **IMPORTANT**: This method does NOT support optimistic locking/versioning.
40
+ * For versioned inserts, use `modifyWithVersioning().insert()` or `modifyWithVersioningAndEvictCache().insert()` instead.
41
+ *
42
+ * @param table - The table to insert into
43
+ * @returns Insert query builder (no versioning, no cache management)
44
+ */
45
+ insert<TTable extends MySqlTable>(table: TTable): MySqlInsertBuilder<TTable, MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT>;
46
+ /**
47
+ * Creates an insert query builder that automatically evicts cache after execution.
48
+ *
49
+ * ⚠️ **IMPORTANT**: This method does NOT support optimistic locking/versioning.
50
+ * For versioned inserts, use `modifyWithVersioning().insert()` or `modifyWithVersioningAndEvictCache().insert()` instead.
51
+ *
52
+ * @param table - The table to insert into
53
+ * @returns Insert query builder with automatic cache eviction (no versioning)
54
+ */
55
+ insertAndEvictCache<TTable extends MySqlTable>(table: TTable): MySqlInsertBuilder<TTable, MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT>;
56
+ /**
57
+ * Creates an update query builder.
58
+ *
59
+ * ⚠️ **IMPORTANT**: This method does NOT support optimistic locking/versioning.
60
+ * For versioned updates, use `modifyWithVersioning().updateById()` or `modifyWithVersioningAndEvictCache().updateById()` instead.
61
+ *
62
+ * @param table - The table to update
63
+ * @returns Update query builder (no versioning, no cache management)
64
+ */
65
+ update<TTable extends MySqlTable>(table: TTable): MySqlUpdateBuilder<TTable, MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT>;
66
+ /**
67
+ * Creates an update query builder that automatically evicts cache after execution.
68
+ *
69
+ * ⚠️ **IMPORTANT**: This method does NOT support optimistic locking/versioning.
70
+ * For versioned updates, use `modifyWithVersioning().updateById()` or `modifyWithVersioningAndEvictCache().updateById()` instead.
71
+ *
72
+ * @param table - The table to update
73
+ * @returns Update query builder with automatic cache eviction (no versioning)
74
+ */
75
+ updateAndEvictCache<TTable extends MySqlTable>(table: TTable): MySqlUpdateBuilder<TTable, MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT>;
76
+ /**
77
+ * Creates a delete query builder.
78
+ *
79
+ * ⚠️ **IMPORTANT**: This method does NOT support optimistic locking/versioning.
80
+ * For versioned deletes, use `modifyWithVersioning().deleteById()` or `modifyWithVersioningAndEvictCache().deleteById()` instead.
81
+ *
82
+ * @param table - The table to delete from
83
+ * @returns Delete query builder (no versioning, no cache management)
84
+ */
85
+ delete<TTable extends MySqlTable>(table: TTable): MySqlDeleteBase<TTable, MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT>;
86
+ /**
87
+ * Creates a delete query builder that automatically evicts cache after execution.
88
+ *
89
+ * ⚠️ **IMPORTANT**: This method does NOT support optimistic locking/versioning.
90
+ * For versioned deletes, use `modifyWithVersioning().deleteById()` or `modifyWithVersioningAndEvictCache().deleteById()` instead.
91
+ *
92
+ * @param table - The table to delete from
93
+ * @returns Delete query builder with automatic cache eviction (no versioning)
94
+ */
95
+ deleteAndEvictCache<TTable extends MySqlTable>(table: TTable): MySqlDeleteBase<TTable, MySqlRemoteQueryResultHKT, MySqlRemotePreparedQueryHKT>;
12
96
  /**
13
97
  * Creates a select query with unique field aliases to prevent field name collisions in joins.
14
98
  * This is particularly useful when working with Atlassian Forge SQL, which collapses fields with the same name in joined tables.
@@ -43,16 +127,11 @@ declare class ForgeSQLORM implements ForgeSqlOperation {
43
127
  * ```
44
128
  */
45
129
  selectDistinct<TSelection extends SelectedFields>(fields: TSelection): MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>;
46
- /**
47
- * Proxies the `crud` method from `ForgeSQLORMImpl`.
48
- * @returns CRUD operations.
49
- */
50
- crud(): CRUDForgeSQL;
51
130
  /**
52
131
  * Proxies the `modify` method from `ForgeSQLORMImpl`.
53
132
  * @returns Modify operations.
54
133
  */
55
- modify(): CRUDForgeSQL;
134
+ modifyWithVersioning(): VerioningModificationForgeSQL;
56
135
  /**
57
136
  * Proxies the `fetch` method from `ForgeSQLORMImpl`.
58
137
  * @returns Fetch operations.
@@ -63,16 +142,28 @@ declare class ForgeSQLORM implements ForgeSqlOperation {
63
142
  * @returns {SchemaAnalyzeForgeSql} Interface for analyzing query performance
64
143
  */
65
144
  analyze(): SchemaAnalyzeForgeSql;
145
+ /**
146
+ * Provides schema-level SQL cacheable operations with type safety.
147
+ * @returns {ForgeSQLCacheOperations} Interface for executing schema-bound SQL queries
148
+ */
149
+ modifyWithVersioningAndEvictCache(): ForgeSQLCacheOperations;
66
150
  /**
67
151
  * Returns a Drizzle query builder instance.
68
152
  *
69
- * ⚠️ IMPORTANT: This method should be used ONLY for query building purposes.
70
- * The returned instance should NOT be used for direct database connections or query execution.
71
- * All database operations should be performed through Forge SQL's executeRawSQL or executeRawUpdateSQL methods.
72
- *
73
153
  * @returns A Drizzle query builder instance for query construction only.
74
154
  */
75
- getDrizzleQueryBuilder(): MySqlRemoteDatabase<Record<string, unknown>>;
155
+ getDrizzleQueryBuilder(): MySqlRemoteDatabase<Record<string, unknown>> & {
156
+ selectAliased: SelectAliasedType;
157
+ selectAliasedDistinct: SelectAliasedDistinctType;
158
+ selectAliasedCacheable: SelectAliasedCacheableType;
159
+ selectAliasedDistinctCacheable: SelectAliasedDistinctCacheableType;
160
+ insertWithCacheContext: InsertAndEvictCacheType;
161
+ insertAndEvictCache: InsertAndEvictCacheType;
162
+ updateAndEvictCache: UpdateAndEvictCacheType;
163
+ updateWithCacheContext: UpdateAndEvictCacheType;
164
+ deleteAndEvictCache: DeleteAndEvictCacheType;
165
+ deleteWithCacheContext: DeleteAndEvictCacheType;
166
+ };
76
167
  }
77
168
  export default ForgeSQLORM;
78
169
  //# sourceMappingURL=ForgeSQLORM.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ForgeSQLORM.d.ts","sourceRoot":"","sources":["../../src/core/ForgeSQLORM.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAW,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAEpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,C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