npm package diff
Package: @forge/sql
Versions: 2.0.1-next.1 - 2.1.0-next.2
Added:package/out/migration.js
Added:package/out/__test__/migration.test.js
Added:package/out/migration.d.ts.map
Added:package/out/__test__/migration.test.d.ts.map
Added:package/out/migration.d.ts
Added:package/out/__test__/migration.test.d.ts
Modified:package/out/index.js
Index: package/out/index.js
===================================================================
--- package/out/index.js
+++ package/out/index.js
@@ -1,7 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.errorCodes = void 0;
+exports.sql = exports.migrationRunner = exports.errorCodes = void 0;
const sql_1 = require("./sql");
+Object.defineProperty(exports, "sql", { enumerable: true, get: function () { return sql_1.sql; } });
const errorCodes_1 = require("./errorCodes");
Object.defineProperty(exports, "errorCodes", { enumerable: true, get: function () { return errorCodes_1.errorCodes; } });
+const migration_1 = require("./migration");
+Object.defineProperty(exports, "migrationRunner", { enumerable: true, get: function () { return migration_1.migrationRunner; } });
exports.default = sql_1.sql;
Modified:package/out/utils/response-handler.js
Index: package/out/utils/response-handler.js
===================================================================
--- package/out/utils/response-handler.js
+++ package/out/utils/response-handler.js
@@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.getResponseBody = exports.ApiError = void 0;
+exports.getResponseBody = exports.MigrationCheckPointError = exports.MigrationExecutionError = exports.ApiError = void 0;
class ApiError extends Error {
status;
code;
suggestion;
@@ -14,8 +14,28 @@
this.debug = debug;
}
}
exports.ApiError = ApiError;
+class MigrationExecutionError extends Error {
+ migrationName;
+ migrationsYetToRun;
+ constructor(migrationName, migrationsYetToRun) {
+ super(`Failed to execute migration with name ${migrationName}`);
+ this.migrationName = migrationName;
+ this.migrationsYetToRun = migrationsYetToRun;
+ }
+}
+exports.MigrationExecutionError = MigrationExecutionError;
+class MigrationCheckPointError extends Error {
+ migrationName;
+ migrationsYetToRun;
+ constructor(migrationName, migrationsYetToRun) {
+ super(`Failed to checkpoint after running migration with name ${migrationName}`);
+ this.migrationName = migrationName;
+ this.migrationsYetToRun = migrationsYetToRun;
+ }
+}
+exports.MigrationCheckPointError = MigrationCheckPointError;
async function getResponseBody(response) {
const responseText = await response.text();
if (!response.ok) {
try {
Modified:package/package.json
Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@forge/sql",
- "version": "2.0.1-next.1",
+ "version": "2.1.0-next.2",
"description": "Forge SQL sdk",
"author": "Atlassian",
"license": "UNLICENSED",
"main": "out/index.js",
@@ -17,9 +17,10 @@
"devDependencies": {
"@types/node": "14.18.63",
"@types/node-fetch": "^2.6.11",
"expect-type": "^0.17.3",
- "node-fetch": "2.7.0"
+ "node-fetch": "2.7.0",
+ "jest-when": "^3.6.0"
},
"dependencies": {
"@forge/api": "^4.0.0-next.1"
}
Modified:package/out/index.d.ts.map
Index: package/out/index.d.ts.map
===================================================================
--- package/out/index.d.ts.map
+++ package/out/index.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,eAAe,GAAG,CAAC"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC;AAC5C,eAAe,GAAG,CAAC"}
\ No newline at end of file
Modified:package/out/utils/response-handler.d.ts.map
Index: package/out/utils/response-handler.d.ts.map
===================================================================
--- package/out/utils/response-handler.d.ts.map
+++ package/out/utils/response-handler.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"response-handler.d.ts","sourceRoot":"","sources":["../../src/utils/response-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,qBAAa,QAAS,SAAQ,KAAK;IAE/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAErB,QAAQ,CAAC,UAAU,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC;gBAJN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACN,UAAU,CAAC,oBAAQ,EACnB,KAAK,CAAC,KAAK;CAIvB;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BzE"}
\ No newline at end of file
+{"version":3,"file":"response-handler.d.ts","sourceRoot":"","sources":["../../src/utils/response-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,qBAAa,QAAS,SAAQ,KAAK;IAE/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAErB,QAAQ,CAAC,UAAU,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC;gBAJN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACN,UAAU,CAAC,oBAAQ,EACnB,KAAK,CAAC,KAAK;CAIvB;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAE9C,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,EAAE;gBAD5B,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,MAAM,EAAE;CAIxC;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAE/C,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,EAAE;gBAD5B,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,MAAM,EAAE;CAIxC;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BzE"}
\ No newline at end of file
Modified:package/README.md
Index: package/README.md
===================================================================
--- package/README.md
+++ package/README.md
@@ -1,12 +1,21 @@
Library for Forge environment.
Usage example:
```typescript
-import sql from "@forge/sql";
+import sql, { migrationRunner } from "@forge/sql";
-const result = await sql.executeRaw('SELECT * FROM example');
+const migrationResults = await migrationRunner
+ .enqueue(
+ 'v001_create_example_table',
+ `CREATE TABLE IF NOT EXISTS example (id INT PRIMARY KEY AUTOINCREMENT,name TEXT NOT NULL);`
+ )
+ .enqueue('v002_alter_example_table_add_age', `ALTER TABLE example ADD COLUMN age INT NOT NULL;`)
+ .enqueue('v003_alter_example_table_add_index_age', `CREATE INDEX idx_example_age ON example (age);`)
+ .run();
-const statement = sql.prepare('INSERT INTO test VALUES (?, ?)');
+const listExamples = await sql.executeRaw('SELECT * FROM example');
-const result = await statement.bindParams('John Doe', 42).execute();
+const statement = sql.prepare('INSERT INTO test example(name, age) VALUES (?, ?)');
+
+const insertUserResult = await statement.bindParams('John Doe', 42).execute();
```
Modified:package/out/index.d.ts
Index: package/out/index.d.ts
===================================================================
--- package/out/index.d.ts
+++ package/out/index.d.ts
@@ -1,5 +1,6 @@
import { sql } from './sql';
import { errorCodes } from './errorCodes';
-export { errorCodes };
+import { migrationRunner } from './migration';
+export { errorCodes, migrationRunner, sql };
export default sql;
//# sourceMappingURL=index.d.ts.map
\ No newline at end of file
Modified:package/out/utils/response-handler.d.ts
Index: package/out/utils/response-handler.d.ts
===================================================================
--- package/out/utils/response-handler.d.ts
+++ package/out/utils/response-handler.d.ts
@@ -5,6 +5,16 @@
readonly suggestion?: string | undefined;
readonly debug?: any;
constructor(status: number, code: string, message: string, suggestion?: string | undefined, debug?: any);
}
+export declare class MigrationExecutionError extends Error {
+ readonly migrationName: string;
+ readonly migrationsYetToRun: string[];
+ constructor(migrationName: string, migrationsYetToRun: string[]);
+}
+export declare class MigrationCheckPointError extends Error {
+ readonly migrationName: string;
+ readonly migrationsYetToRun: string[];
+ constructor(migrationName: string, migrationsYetToRun: string[]);
+}
export declare function getResponseBody(response: Response): Promise<Result>;
//# sourceMappingURL=response-handler.d.ts.map
\ No newline at end of file