forge-sql-orm 2.0.9 → 2.0.11

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 (41) hide show
  1. package/README.md +67 -42
  2. package/dist/ForgeSQLORM.js +162 -16
  3. package/dist/ForgeSQLORM.js.map +1 -1
  4. package/dist/ForgeSQLORM.mjs +165 -19
  5. package/dist/ForgeSQLORM.mjs.map +1 -1
  6. package/dist/core/ForgeSQLCrudOperations.d.ts.map +1 -1
  7. package/dist/core/ForgeSQLORM.d.ts.map +1 -1
  8. package/dist/core/ForgeSQLQueryBuilder.d.ts +32 -0
  9. package/dist/core/ForgeSQLQueryBuilder.d.ts.map +1 -1
  10. package/dist/core/SystemTables.d.ts +8 -6
  11. package/dist/core/SystemTables.d.ts.map +1 -1
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/lib/drizzle/extensions/selectAliased.d.ts +9 -0
  15. package/dist/lib/drizzle/extensions/selectAliased.d.ts.map +1 -0
  16. package/dist/utils/sqlUtils.d.ts +8 -4
  17. package/dist/utils/sqlUtils.d.ts.map +1 -1
  18. package/dist/webtriggers/applyMigrationsWebTrigger.d.ts +23 -0
  19. package/dist/webtriggers/applyMigrationsWebTrigger.d.ts.map +1 -1
  20. package/dist/webtriggers/dropMigrationWebTrigger.d.ts +20 -4
  21. package/dist/webtriggers/dropMigrationWebTrigger.d.ts.map +1 -1
  22. package/dist/webtriggers/fetchSchemaWebTrigger.d.ts +28 -0
  23. package/dist/webtriggers/fetchSchemaWebTrigger.d.ts.map +1 -0
  24. package/dist/webtriggers/index.d.ts +1 -0
  25. package/dist/webtriggers/index.d.ts.map +1 -1
  26. package/dist-cli/cli.js +5 -0
  27. package/dist-cli/cli.js.map +1 -1
  28. package/dist-cli/cli.mjs +8 -3
  29. package/dist-cli/cli.mjs.map +1 -1
  30. package/package.json +10 -10
  31. package/src/core/ForgeSQLCrudOperations.ts +0 -425
  32. package/src/core/ForgeSQLORM.ts +0 -228
  33. package/src/core/ForgeSQLQueryBuilder.ts +0 -319
  34. package/src/core/ForgeSQLSelectOperations.ts +0 -93
  35. package/src/core/SystemTables.ts +0 -7
  36. package/src/index.ts +0 -10
  37. package/src/utils/forgeDriver.ts +0 -39
  38. package/src/utils/sqlUtils.ts +0 -306
  39. package/src/webtriggers/applyMigrationsWebTrigger.ts +0 -26
  40. package/src/webtriggers/dropMigrationWebTrigger.ts +0 -35
  41. package/src/webtriggers/index.ts +0 -25
@@ -1 +1 @@
1
- {"version":3,"file":"applyMigrationsWebTrigger.d.ts","sourceRoot":"","sources":["../../src/webtriggers/applyMigrationsWebTrigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,eAAO,MAAM,qBAAqB,GAChC,WAAW,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC;;;;;;;EAqB1E,CAAC"}
1
+ {"version":3,"file":"applyMigrationsWebTrigger.d.ts","sourceRoot":"","sources":["../../src/webtriggers/applyMigrationsWebTrigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,qBAAqB,GAChC,WAAW,CAAC,eAAe,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC;;;;;;;EAqB1E,CAAC"}
@@ -1,12 +1,28 @@
1
1
  import { AnyMySqlTable } from "drizzle-orm/mysql-core";
2
2
  import { TriggerResponse } from "./index";
3
3
  /**
4
- * ⚠️ WARNING: This web trigger will permanently delete all data in the specified tables.
5
- * DO NOT use this in production environment as it will cause irreversible data loss.
4
+ * ⚠️ DEVELOPMENT ONLY WEB TRIGGER ⚠️
5
+ *
6
+ * This web trigger is designed for development environments only and will permanently delete all data in the specified tables.
7
+ * It generates and executes SQL statements to drop tables and their associated constraints.
8
+ *
9
+ * @warning This trigger should NEVER be used in production environments because:
10
+ * - It permanently deletes all data in the specified tables
11
+ * - The operation cannot be undone
12
+ * - It may affect application functionality
13
+ * - It could lead to data loss and system instability
6
14
  *
7
- * Generates SQL statements to drop tables and executes them
8
15
  * @param tables - Array of table schemas to drop
9
- * @returns Trigger response with execution status and list of dropped tables
16
+ * @returns {Promise<TriggerResponse<string>>} A response containing:
17
+ * - On success: 200 status with warning message about permanent deletion
18
+ * - On failure: 500 status with error message
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Example usage in development only
23
+ * await dropSchemaMigrations([users, orders]);
24
+ * // ⚠️ Warning: This will permanently delete all data in users and orders tables
25
+ * ```
10
26
  */
11
27
  export declare function dropSchemaMigrations(tables: AnyMySqlTable[]): Promise<TriggerResponse<string>>;
12
28
  //# sourceMappingURL=dropMigrationWebTrigger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dropMigrationWebTrigger.d.ts","sourceRoot":"","sources":["../../src/webtriggers/dropMigrationWebTrigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAmB,eAAe,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EAAE,GACtB,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAmBlC"}
1
+ {"version":3,"file":"dropMigrationWebTrigger.d.ts","sourceRoot":"","sources":["../../src/webtriggers/dropMigrationWebTrigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAmB,eAAe,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EAAE,GACtB,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAmBlC"}
@@ -0,0 +1,28 @@
1
+ import { TriggerResponse } from "./index";
2
+ /**
3
+ * ⚠️ DEVELOPMENT ONLY WEB TRIGGER ⚠️
4
+ *
5
+ * This web trigger retrieves the current database schema from Atlassian Forge SQL.
6
+ * It generates SQL statements that can be used to recreate the database structure.
7
+ *
8
+ * @warning This trigger should ONLY be used in development environments. It:
9
+ * - Exposes your database structure
10
+ * - Disables foreign key checks temporarily
11
+ * - Generates SQL that could potentially be used maliciously
12
+ * - May expose sensitive table names and structures
13
+ *
14
+ * @returns {Promise<TriggerResponse<string>>} A response containing SQL statements to recreate the database schema
15
+ * - On success: Returns 200 status with SQL statements
16
+ * - On failure: Returns 500 status with error message
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // The response will contain SQL statements like:
21
+ * // SET foreign_key_checks = 0;
22
+ * // CREATE TABLE IF NOT EXISTS users (...);
23
+ * // CREATE TABLE IF NOT EXISTS orders (...);
24
+ * // SET foreign_key_checks = 1;
25
+ * ```
26
+ */
27
+ export declare function fetchSchemaWebTrigger(): Promise<TriggerResponse<string>>;
28
+ //# sourceMappingURL=fetchSchemaWebTrigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchSchemaWebTrigger.d.ts","sourceRoot":"","sources":["../../src/webtriggers/fetchSchemaWebTrigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,eAAe,EAAE,MAAM,SAAS,CAAC;AAS3D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAY9E"}
@@ -1,5 +1,6 @@
1
1
  export * from "./dropMigrationWebTrigger";
2
2
  export * from "./applyMigrationsWebTrigger";
3
+ export * from "./fetchSchemaWebTrigger";
3
4
  export interface TriggerResponse<BODY> {
4
5
  body?: BODY;
5
6
  headers?: Record<string, string[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webtriggers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAE5C,MAAM,WAAW,eAAe,CAAC,IAAI;IACnC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,GAAI,IAAI,EAAE,YAAY,MAAM,EAAE,MAAM,IAAI,KAAG,eAAe,CAAC,IAAI,CAc1F,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webtriggers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAExC,MAAM,WAAW,eAAe,CAAC,IAAI;IACnC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,GAAI,IAAI,EAAE,YAAY,MAAM,EAAE,MAAM,IAAI,KAAG,eAAe,CAAC,IAAI,CAc1F,CAAC"}
package/dist-cli/cli.js CHANGED
@@ -705,6 +705,11 @@ mysqlCore.customType({
705
705
  return parseDateTime(value, "HH:mm:ss.SSS");
706
706
  }
707
707
  });
708
+ mysqlCore.mysqlTable("__migrations", {
709
+ id: mysqlCore.bigint("id", { mode: "number" }).primaryKey().autoincrement(),
710
+ name: mysqlCore.varchar("name", { length: 255 }).notNull(),
711
+ migratedAt: mysqlCore.timestamp("migratedAt").defaultNow().notNull()
712
+ });
708
713
  function generateMigrationUUID(version) {
709
714
  const now = /* @__PURE__ */ new Date();
710
715
  const timestamp = now.getTime();