npm package diff
Package: @forge/sql
Versions: 2.1.0 - 2.2.0-next.0
Modified:package/out/sql-statement.js
Index: package/out/sql-statement.js
===================================================================
--- package/out/sql-statement.js
+++ package/out/sql-statement.js
@@ -2,17 +2,20 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.SqlStatement = void 0;
class SqlStatement {
query;
- params;
+ _params;
remoteSqlApi;
constructor(query, remoteSqlApi) {
this.query = query;
- this.params = [];
+ this._params = [];
this.remoteSqlApi = remoteSqlApi;
}
+ get params() {
+ return this._params;
+ }
bindParams(...args) {
- this.params = args;
+ this._params = args;
return this;
}
async execute() {
return this.remoteSqlApi(this.query, this.params);
Modified:package/out/__test__/sql.test.js
Index: package/out/__test__/sql.test.js
===================================================================
--- package/out/__test__/sql.test.js
+++ package/out/__test__/sql.test.js
@@ -1,33 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
+const node_fetch_1 = require("node-fetch");
const api_1 = require("@forge/api");
const sql_1 = require("../sql");
const sql_statement_1 = require("../sql-statement");
+const response_handler_1 = require("../utils/response-handler");
jest.mock('@forge/api');
-jest.mock('../sql-statement');
-jest.mock('../utils/response-handler', () => ({
- ApiError: jest.fn(),
- getResponseBody: jest.fn()
-}));
describe('SqlClient', () => {
let sqlClient;
let mockFetch;
- let mockSqlStatement;
- let mockGetResponseBody;
beforeEach(() => {
sqlClient = new sql_1.SqlClient();
mockFetch = jest.fn();
api_1.__fetchProduct.mockReturnValue(mockFetch);
- mockSqlStatement = {
- bindParams: jest.fn().mockReturnThis(),
- execute: jest.fn()
- };
- sql_statement_1.SqlStatement.mockImplementation(() => mockSqlStatement);
- mockGetResponseBody = jest.fn();
- jest.requireMock('../utils/response-handler').getResponseBody = mockGetResponseBody;
jest.clearAllMocks();
});
+ function mockFetchExecute(rows) {
+ const body = { rows };
+ const response = new node_fetch_1.Response(JSON.stringify(body), { status: 200 });
+ mockFetch.mockResolvedValue(response);
+ return body;
+ }
describe('sendRequest', () => {
it('should send a request with the correct options and return the response', async () => {
const mockResponse = { ok: true, status: 200 };
mockFetch.mockResolvedValue(mockResponse);
@@ -66,84 +60,60 @@
});
});
describe('storageApi', () => {
it('should send a request and return the response body', async () => {
- const mockResponse = { text: jest.fn().mockResolvedValue(JSON.stringify({ response: { rows: [] } })) };
- mockFetch.mockResolvedValue(mockResponse);
- mockGetResponseBody.mockResolvedValue({ rows: [] });
+ mockFetchExecute([]);
const result = await sqlClient.storageApi('SELECT * FROM test');
expect(mockFetch).toHaveBeenCalledWith('api/v1/execute', {
method: 'POST',
body: JSON.stringify({ query: 'SELECT * FROM test', params: [], method: 'all' }),
redirect: 'follow',
headers: { 'Content-Type': 'application/json' }
});
- expect(mockGetResponseBody).toHaveBeenCalledWith(mockResponse);
expect(result).toEqual({ rows: [] });
});
it('should send a request with parameters and method', async () => {
- const mockResponse = { text: jest.fn().mockResolvedValue(JSON.stringify({ response: { rows: [] } })) };
- mockFetch.mockResolvedValue(mockResponse);
- mockGetResponseBody.mockResolvedValue({ rows: [] });
+ mockFetchExecute([]);
const params = [1];
const result = await sqlClient.storageApi('SELECT * FROM test WHERE id = ?', params, 'one');
expect(mockFetch).toHaveBeenCalledWith('api/v1/execute', {
method: 'POST',
body: JSON.stringify({ query: 'SELECT * FROM test WHERE id = ?', params, method: 'one' }),
redirect: 'follow',
headers: { 'Content-Type': 'application/json' }
});
- expect(mockGetResponseBody).toHaveBeenCalledWith(mockResponse);
expect(result).toEqual({ rows: [] });
});
it('should handle errors from getResponseBody', async () => {
- const mockResponse = { text: jest.fn().mockResolvedValue('Invalid JSON') };
- mockFetch.mockResolvedValue(mockResponse);
- const mockError = new Error('Invalid JSON');
- mockGetResponseBody.mockRejectedValue(mockError);
- await expect(sqlClient.storageApi('INVALID SQL QUERY')).rejects.toThrow(mockError);
- expect(mockFetch).toHaveBeenCalledWith('api/v1/execute', expect.any(Object));
- expect(mockGetResponseBody).toHaveBeenCalledWith(mockResponse);
+ const responseText = 'Invalid JSON';
+ const response = new node_fetch_1.Response(responseText, { status: 200 });
+ mockFetch.mockResolvedValue(response);
+ await expect(sqlClient.storageApi('INVALID SQL QUERY')).rejects.toThrow(`Unexpected error. Response was not valid JSON: ${responseText}`);
});
});
describe('prepare', () => {
- it('should return a SqlStatement instance', () => {
- const statement = sqlClient.prepare('SELECT * FROM test');
- expect(statement).toBe(mockSqlStatement);
- expect(sql_statement_1.SqlStatement).toHaveBeenCalledWith('SELECT * FROM test', expect.any(Function));
+ it('should return a SqlStatement instance with query', () => {
+ const statement = sqlClient.prepare('INSERT INTO test VALUES (?, ?)');
+ expect(statement).toBeInstanceOf(sql_statement_1.SqlStatement);
+ expect(statement.query).toBe('INSERT INTO test VALUES (?, ?)');
});
- it('should pass the correct query to SqlStatement', () => {
- sqlClient.prepare('INSERT INTO test VALUES (?, ?)');
- expect(sql_statement_1.SqlStatement).toHaveBeenCalledWith('INSERT INTO test VALUES (?, ?)', expect.any(Function));
- });
- it('should pass the storageApi method to SqlStatement', () => {
- sqlClient.prepare('SELECT * FROM test');
- const passedFunction = sql_statement_1.SqlStatement.mock.calls[0][1];
- expect(typeof passedFunction).toBe('function');
- });
});
describe('execute', () => {
it('should execute a query and return the result', async () => {
- const mockResult = { rows: [{ id: 1, name: 'Test' }] };
- mockSqlStatement.execute.mockResolvedValue(mockResult);
+ const expectedResult = mockFetchExecute([{ id: 1, name: 'Test' }]);
const result = await sqlClient.executeRaw('SELECT * FROM test');
- expect(result).toEqual(mockResult);
- expect(sql_statement_1.SqlStatement).toHaveBeenCalledWith('SELECT * FROM test', expect.any(Function));
- expect(mockSqlStatement.execute).toHaveBeenCalled();
+ expect(result).toEqual(expectedResult);
});
it('should execute a query with parameters', async () => {
- const mockResult = { rows: [{ id: 1, name: 'Test' }] };
- mockSqlStatement.execute.mockResolvedValue(mockResult);
- const result = await sqlClient.prepare('SELECT * FROM test WHERE id = ?').bindParams(1).execute();
+ const mockResult = mockFetchExecute([{ id: 1, name: 'Test' }]);
+ const result = await sqlClient
+ .prepare('SELECT * FROM test WHERE id = ?')
+ .bindParams(1)
+ .execute();
expect(result).toEqual(mockResult);
- expect(mockSqlStatement.bindParams).toHaveBeenCalledWith(1);
- expect(mockSqlStatement.execute).toHaveBeenCalled();
});
it('should handle API errors', async () => {
- const mockApiError1 = new Error('INVALID SQL QUERY');
- mockSqlStatement.execute.mockRejectedValueOnce(mockApiError1);
- await expect(sqlClient.executeRaw('INVALID SQL QUERY')).rejects.toThrow(mockApiError1);
- expect(sql_statement_1.SqlStatement).toHaveBeenCalledWith('INVALID SQL QUERY', expect.any(Function));
- expect(mockSqlStatement.execute).toHaveBeenCalled();
+ mockFetch.mockResolvedValue(new node_fetch_1.Response(JSON.stringify({ code: 'INVALID_QUERY', message: 'Invalid SQL query' }), { status: 400 }));
+ await expect(sqlClient.executeRaw('INVALID SQL QUERY')).rejects.toThrow(new response_handler_1.ApiError(400, 'INVALID_QUERY', 'Invalid SQL query'));
});
});
});
Modified:package/package.json
Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@forge/sql",
- "version": "2.1.0",
+ "version": "2.2.0-next.0",
"description": "Forge SQL sdk",
"author": "Atlassian",
"license": "UNLICENSED",
"main": "out/index.js",
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;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
+{"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,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEjE,YAAY,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC;AAC5C,eAAe,GAAG,CAAC"}
\ No newline at end of file
Modified:package/out/migration.d.ts.map
Index: package/out/migration.d.ts.map
===================================================================
--- package/out/migration.d.ts.map
+++ package/out/migration.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,aAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAOF,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAEnC,SAAS,EAAE,SAAS;IAK1B,UAAU;IAIT,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe;IAQzD,WAAW,IAAI,eAAe,EAAE;IAIjC,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAYnC,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAiC/B;AAED,eAAO,MAAM,eAAe,iBAA2B,CAAC"}
\ No newline at end of file
+{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../src/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,aAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAcF,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAEnC,SAAS,EAAE,SAAS;IAK1B,UAAU;IAIT,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe;IAQzD,WAAW,IAAI,eAAe,EAAE;IAIjC,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAYnC,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAiC/B;AAED,eAAO,MAAM,eAAe,iBAA2B,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,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
+{"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,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CA2B7F"}
\ No newline at end of file
Modified:package/out/sql-statement.d.ts.map
Index: package/out/sql-statement.d.ts.map
===================================================================
--- package/out/sql-statement.d.ts.map
+++ package/out/sql-statement.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"sql-statement.d.ts","sourceRoot":"","sources":["../src/sql-statement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,oBAAY,aAAa,GAAG,GAAG,EAAE,CAAC;AAElC,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2E;gBAE5F,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC;IAMjH,UAAU,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,YAAY;IAK1C,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAGjC"}
\ No newline at end of file
+{"version":3,"file":"sql-statement.d.ts","sourceRoot":"","sources":["../src/sql-statement.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,GAAG,GAAG,EAAE,CAAC;AAElC,oBAAY,aAAa,CAAC,WAAW,IAAI,CACvC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,MAAM,KACZ,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1B,qBAAa,YAAY,CAAC,WAAW;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;gBAE9C,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC;IAMnE,IAAI,MAAM,IAAI,aAAa,CAE1B;IACD,UAAU,CAAC,GAAG,IAAI,EAAE,aAAa,GAAG,IAAI;IAKlC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;CAGtC"}
\ No newline at end of file
Modified:package/out/sql.d.ts.map
Index: package/out/sql.d.ts.map
===================================================================
--- package/out/sql.d.ts.map
+++ package/out/sql.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9D,qBAAa,SAAS;YACN,WAAW;IAYnB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,aAAkB,EAAE,MAAM,SAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ5F,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY;IAI9B,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAMlC;AAED,eAAO,MAAM,GAAG,WAAkB,CAAC"}
\ No newline at end of file
+{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../src/sql.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9D,qBAAa,SAAS;YACN,WAAW;IAYnB,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,aAAkB,EAAE,MAAM,SAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAQhH,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAI1D,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAI9D,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAMlC;AAED,eAAO,MAAM,GAAG,WAAkB,CAAC"}
\ No newline at end of file
Modified:package/out/utils/types.d.ts.map
Index: package/out/utils/types.d.ts.map
===================================================================
--- package/out/utils/types.d.ts.map
+++ package/out/utils/types.d.ts.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,oBAAY,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;AAEnE,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC"}
\ No newline at end of file
+{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,oBAAY,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAElC,YAAY,EAAE,MAAM,CAAC;IAErB,UAAU,EAAE,MAAM,CAAC;IAEnB,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,CAAC;IAEjB,YAAY,EAAE,MAAM,CAAC;IAErB,aAAa,EAAE,MAAM,CAAC;CACvB;AAWD,MAAM,WAAW,MAAM,CAAC,QAAQ,GAAG,GAAG;IAKpC,IAAI,EAAE,QAAQ,EAAE,CAAC;IAMjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC"}
\ No newline at end of file
Modified:package/out/index.d.ts
Index: package/out/index.d.ts
===================================================================
--- package/out/index.d.ts
+++ package/out/index.d.ts
@@ -1,6 +1,8 @@
import { sql } from './sql';
import { errorCodes } from './errorCodes';
import { migrationRunner } from './migration';
+import type { Result, UpdateQueryResponse } from './utils/types';
+export type { Result, UpdateQueryResponse };
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
@@ -15,6 +15,6 @@
readonly migrationName: string;
readonly migrationsYetToRun: string[];
constructor(migrationName: string, migrationsYetToRun: string[]);
}
-export declare function getResponseBody(response: Response): Promise<Result>;
+export declare function getResponseBody<DataType>(response: Response): Promise<Result<DataType>>;
//# sourceMappingURL=response-handler.d.ts.map
\ No newline at end of file
Modified:package/out/sql-statement.d.ts
Index: package/out/sql-statement.d.ts
===================================================================
--- package/out/sql-statement.d.ts
+++ package/out/sql-statement.d.ts
@@ -1,11 +1,12 @@
-import { Result } from './utils/types';
export declare type SqlParameters = any[];
-export declare class SqlStatement {
- private readonly query;
- private params;
+export declare type RemoteApiCall<ApiResponse> = (query: string, params?: SqlParameters, method?: string) => Promise<ApiResponse>;
+export declare class SqlStatement<APIResponse> {
+ readonly query: string;
+ private _params;
private readonly remoteSqlApi;
- constructor(query: string, remoteSqlApi: (query: string, params?: SqlParameters, method?: string) => Promise<any>);
- bindParams(...args: SqlParameters): SqlStatement;
- execute(): Promise<Result>;
+ constructor(query: string, remoteSqlApi: RemoteApiCall<APIResponse>);
+ get params(): SqlParameters;
+ bindParams(...args: SqlParameters): this;
+ execute(): Promise<APIResponse>;
}
//# sourceMappingURL=sql-statement.d.ts.map
\ No newline at end of file
Modified:package/out/sql.d.ts
Index: package/out/sql.d.ts
===================================================================
--- package/out/sql.d.ts
+++ package/out/sql.d.ts
@@ -1,11 +1,11 @@
import { Result } from './utils/types';
import { SqlParameters, SqlStatement } from './sql-statement';
export declare class SqlClient {
private sendRequest;
- storageApi(query: string, params?: SqlParameters, method?: string): Promise<Result>;
- prepare(query: string): SqlStatement;
- executeRaw(query: string): Promise<Result>;
+ storageApi<DataType>(query: string, params?: SqlParameters, method?: string): Promise<Result<DataType>>;
+ prepare<DataType>(query: string): SqlStatement<Result<DataType>>;
+ executeRaw<DataType>(query: string): Promise<Result<DataType>>;
_provision(): Promise<void>;
}
export declare const sql: SqlClient;
//# sourceMappingURL=sql.d.ts.map
\ No newline at end of file
Modified:package/out/utils/types.d.ts
Index: package/out/utils/types.d.ts
===================================================================
--- package/out/utils/types.d.ts
+++ package/out/utils/types.d.ts
@@ -1,7 +1,15 @@
import { APIResponse } from '@forge/api';
export declare type Response = Pick<APIResponse, 'text' | 'ok' | 'status'>;
-export interface Result {
- rows: any;
+export interface UpdateQueryResponse {
+ affectedRows: number;
+ fieldCount: number;
+ info: string;
+ insertId: number;
+ serverStatus: number;
+ warningStatus: number;
+}
+export interface Result<DataType = any> {
+ rows: DataType[];
metadata?: Record<string, any>;
}
//# sourceMappingURL=types.d.ts.map
\ No newline at end of file