diff --git a/apps/velo-external-db/src/app.ts b/apps/velo-external-db/src/app.ts index 3618d20c0..32f876cd2 100644 --- a/apps/velo-external-db/src/app.ts +++ b/apps/velo-external-db/src/app.ts @@ -34,9 +34,8 @@ const initConnector = async(wixDataBaseUrl?: string, hooks?: Hooks) => { export const createApp = async(wixDataBaseUrl?: string) => { const app = express() const initConnectorResponse = await initConnector(wixDataBaseUrl) - app.use(initConnectorResponse.externalDbRouter.router) - const port = process.env.PORT || 8080 - const server = app.listen(port, () => console.log(`Connector listening on port ${port}`)) + app.use('/v3/', initConnectorResponse.externalDbRouter.router) + const server = app.listen(8080, () => console.log('Connector listening on port 8080')) return { server, ...initConnectorResponse, reload: () => initConnector(wixDataBaseUrl) } } diff --git a/apps/velo-external-db/test/drivers/data_api_rest_test_support.ts b/apps/velo-external-db/test/drivers/data_api_rest_test_support.ts index dd8684be2..29c584192 100644 --- a/apps/velo-external-db/test/drivers/data_api_rest_test_support.ts +++ b/apps/velo-external-db/test/drivers/data_api_rest_test_support.ts @@ -4,7 +4,7 @@ import { dataSpi, convertersUtils } from '@wix-velo/velo-external-db-core' const axiosInstance = axios.create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) export const insertRequest = (collectionName: string, items: Item[]): dataSpi.InsertRequest => ({ @@ -40,7 +40,7 @@ export const queryRequest = (collectionName: string, sort: dataSpi.Sorting[], fi export const queryCollectionAsArray = async(collectionName: string, sort: dataSpi.Sorting[], fields: string[], auth: any, filter?: dataSpi.Filter) => - await axiosInstance.post('/data/query', + await axiosInstance.post('/items/query', queryRequest(collectionName, sort, fields, filter), { transformRequest: auth.transformRequest }).then(res => res.data) @@ -48,4 +48,4 @@ export const pagingMetadata = (count: number, total?: number) => ({ count, offse export const givenItems = async(items: Item[], collectionName: string, auth: any) => - await axiosInstance.post('/data/insert', insertRequest(collectionName, items), { transformRequest: auth.transformRequest }) + await axiosInstance.post('/items/insert', insertRequest(collectionName, items), { transformRequest: auth.transformRequest }) diff --git a/apps/velo-external-db/test/drivers/schema_api_rest_test_support.ts b/apps/velo-external-db/test/drivers/schema_api_rest_test_support.ts index 42cdca1ee..b648d2005 100644 --- a/apps/velo-external-db/test/drivers/schema_api_rest_test_support.ts +++ b/apps/velo-external-db/test/drivers/schema_api_rest_test_support.ts @@ -4,7 +4,7 @@ import { schemaUtils } from '@wix-velo/velo-external-db-core' const axiosClient = axios.create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) export const givenCollection = async(name: string, columns: InputField[], auth: any) => { diff --git a/apps/velo-external-db/test/e2e/app.e2e.spec.ts b/apps/velo-external-db/test/e2e/app.e2e.spec.ts index e5dcca42f..97d711de6 100644 --- a/apps/velo-external-db/test/e2e/app.e2e.spec.ts +++ b/apps/velo-external-db/test/e2e/app.e2e.spec.ts @@ -2,9 +2,8 @@ import { authOwner } from '@wix-velo/external-db-testkit' import { initApp, teardownApp, dbTeardown, setupDb, currentDbImplementationName, env } from '../resources/e2e_resources' import { givenHideAppInfoEnvIsTrue } from '../drivers/app_info_config_test_support' -import { CollectionCapability } from '@wix-velo/velo-external-db-core' const axios = require('axios').create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) describe(`Velo External DB: ${currentDbImplementationName()}`, () => { @@ -34,10 +33,14 @@ describe(`Velo External DB: ${currentDbImplementationName()}`, () => { }) test('answer capability', async() => { - expect((await axios.get('/capabilities', { }, authOwner)).data).toEqual(expect.objectContaining({ - capabilities: { - collection: [CollectionCapability.CREATE] - } + expect((await axios.post('/capabilities/get', { }, authOwner)).data).toEqual(expect.objectContaining({ + supportsCollectionModifications: true, + supportedFieldTypes: expect.toBeArray(), + supportsCollectionDisplayName: false, + supportsCollectionDisplayField: false, + supportsCollectionPermissions: false, + supportsCollectionFieldDisplayName: false, + supportsCollectionFieldDescription: false, })) }) diff --git a/apps/velo-external-db/test/e2e/app_auth.e2e.spec.ts b/apps/velo-external-db/test/e2e/app_auth.e2e.spec.ts index b44fb57dd..11b687160 100644 --- a/apps/velo-external-db/test/e2e/app_auth.e2e.spec.ts +++ b/apps/velo-external-db/test/e2e/app_auth.e2e.spec.ts @@ -5,7 +5,7 @@ import { authOwnerWithoutJwt, authOwnerWithWrongJwtPublicKey, authVisitor, authO import { initApp, teardownApp, dbTeardown, setupDb, currentDbImplementationName } from '../resources/e2e_resources' const axiosInstance = axios.create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) @@ -27,15 +27,15 @@ describe(`Velo External DB authorization: ${currentDbImplementationName()}`, () describe('JWT authorization', () => { test('should throw if the request is not singed with JWT token', async() => { - return expect(axiosInstance.post('data/insert', {}, authOwnerWithoutJwt)).rejects.toThrow('401') + return expect(axiosInstance.post('items/insert', {}, authOwnerWithoutJwt)).rejects.toThrow('401') }) test('should throw if the request is singed with the wrong public key', async() => { - return expect(axiosInstance.post('data/insert', {}, authOwnerWithWrongJwtPublicKey)).rejects.toThrow('401') + return expect(axiosInstance.post('items/insert', {}, authOwnerWithWrongJwtPublicKey)).rejects.toThrow('401') }) test('should throw if the request is signed with wrong app id', async() => { - return expect(axiosInstance.post('data/insert', {}, authOwnerWithWrongAppId)).rejects.toThrow('401') + return expect(axiosInstance.post('items/insert', {}, authOwnerWithWrongAppId)).rejects.toThrow('401') }) }) diff --git a/apps/velo-external-db/test/e2e/app_data.e2e.spec.ts b/apps/velo-external-db/test/e2e/app_data.e2e.spec.ts index a82576f06..19332fb2d 100644 --- a/apps/velo-external-db/test/e2e/app_data.e2e.spec.ts +++ b/apps/velo-external-db/test/e2e/app_data.e2e.spec.ts @@ -16,7 +16,7 @@ const { UpdateImmediately, DeleteImmediately, Truncate, Aggregate, FindWithSort, const chance = Chance() const axiosInstance = axios.create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) describe(`Velo External DB Data REST API: ${currentDbImplementationName()}`, () => { @@ -71,7 +71,7 @@ describe(`Velo External DB Data REST API: ${currentDbImplementationName()}`, () test('insert api', async() => { await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) - const response = await axiosInstance.post('/data/insert', data.insertRequest(ctx.collectionName, ctx.items), authAdmin) + const response = await axiosInstance.post('/items/insert', data.insertRequest(ctx.collectionName, ctx.items), authAdmin) expect(response.data).toEqual({ results: expect.toIncludeSameMembers(ctx.items) }) @@ -84,7 +84,7 @@ describe(`Velo External DB Data REST API: ${currentDbImplementationName()}`, () await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) - const response = await axiosInstance.post('/data/insert', data.insertRequest(ctx.collectionName, ctx.items), authAdmin) + const response = await axiosInstance.post('/items/insert', data.insertRequest(ctx.collectionName, ctx.items), authAdmin) expect(response.data.results).toEqual([ @@ -109,7 +109,7 @@ describe(`Velo External DB Data REST API: ${currentDbImplementationName()}`, () await schema.givenCollection(ctx.collectionName, ctx.numberColumns, authOwner) await data.givenItems([ctx.numberItem, ctx.anotherNumberItem], ctx.collectionName, authOwner) - const response = await axiosInstance.post('/data/aggregate', { + const response = await axiosInstance.post('/items/aggregate', { collectionId: ctx.collectionName, initialFilter: { _id: { $eq: ctx.numberItem._id } }, aggregation: { @@ -145,7 +145,7 @@ describe(`Velo External DB Data REST API: ${currentDbImplementationName()}`, () await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems(ctx.items, ctx.collectionName, authAdmin) await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) - const response = await axiosInstance.post('/data/remove', { + const response = await axiosInstance.post('/items/remove', { collectionId: ctx.collectionName, itemIds: ctx.items.map(i => i._id) }, authAdmin) @@ -160,7 +160,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems([ ctx.items[0] ], ctx.collectionName, authAdmin) - const response = await axiosInstance.post('/data/remove', { + const response = await axiosInstance.post('/items/remove', { collectionId: ctx.collectionName, itemIds: ctx.items.map(i => i._id) }, authAdmin) @@ -227,7 +227,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) testIfSupportedOperationsIncludes(supportedOperations, [ UpdateImmediately ])('update api', async() => { await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems(ctx.items, ctx.collectionName, authAdmin) - const response = await axiosInstance.post('/data/update', data.updateRequest(ctx.collectionName, ctx.modifiedItems), authAdmin) + const response = await axiosInstance.post('/items/update', data.updateRequest(ctx.collectionName, ctx.modifiedItems), authAdmin) expect(response.data.results).toEqual(ctx.modifiedItems) @@ -240,7 +240,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) testIfSupportedOperationsIncludes(supportedOperations, [ UpdateImmediately ])('update api should return updated items if they exist and if they don\'t, it should return an error object', async() => { await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems(ctx.items.slice(0, ctx.items.length - 1), ctx.collectionName, authAdmin) - const response = await axiosInstance.post('/data/update', data.updateRequest(ctx.collectionName, ctx.modifiedItems), authAdmin) + const response = await axiosInstance.post('/items/update', data.updateRequest(ctx.collectionName, ctx.modifiedItems), authAdmin) expect(response.data.results).toEqual([ ...ctx.modifiedItems.slice(0, ctx.items.length - 1), @@ -263,7 +263,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) test('count api', async() => { await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems([ctx.item, ctx.anotherItem], ctx.collectionName, authAdmin) - await expect( axiosInstance.post('/data/count', data.countRequest(ctx.collectionName), authAdmin) ).resolves.toEqual( + await expect( axiosInstance.post('/items/count', data.countRequest(ctx.collectionName), authAdmin) ).resolves.toEqual( matchers.responseWith( { totalCount: 2 } )) }) @@ -271,7 +271,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) testIfSupportedOperationsIncludes(supportedOperations, [ Truncate ])('truncate api', async() => { await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems([ctx.item, ctx.anotherItem], ctx.collectionName, authAdmin) - await axiosInstance.post('/data/truncate', { collectionId: ctx.collectionName }, authAdmin) + await axiosInstance.post('/items/truncate', { collectionId: ctx.collectionName }, authAdmin) await expect(data.queryCollectionAsArray(ctx.collectionName, [], undefined, authOwner)).resolves.toEqual({ items: [], pagingMetadata: data.pagingMetadata(0, 0) @@ -283,7 +283,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) delete ctx.numberItem[ctx.numberColumns[0].name] delete ctx.numberItem[ctx.numberColumns[1].name] - await axiosInstance.post('/data/insert', data.insertRequest(ctx.collectionName, [ctx.numberItem]), authAdmin) + await axiosInstance.post('/items/insert', data.insertRequest(ctx.collectionName, [ctx.numberItem]), authAdmin) await expect(data.queryCollectionAsArray(ctx.collectionName, [], undefined, authOwner)).resolves.toEqual({ items: expect.toIncludeSameMembers([{ @@ -302,7 +302,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) ctx.numberItem[ctx.numberColumns[0].name] = null ctx.numberItem[ctx.numberColumns[1].name] = null - await axiosInstance.post('/data/update', data.updateRequest(ctx.collectionName, [ctx.numberItem]), authAdmin) + await axiosInstance.post('/items/update', data.updateRequest(ctx.collectionName, [ctx.numberItem]), authAdmin) await expect(data.queryCollectionAsArray(ctx.collectionName, [], undefined, authOwner)).resolves.toEqual({ @@ -334,7 +334,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) await data.givenItems([ctx.item], ctx.collectionName, authAdmin) - const response = await axiosInstance.post('/data/insert', data.insertRequest(ctx.collectionName, [ctx.item]), authAdmin) + const response = await axiosInstance.post('/items/insert', data.insertRequest(ctx.collectionName, [ctx.item]), authAdmin) expect(response.data).toEqual(expect.objectContaining({ results: [{ @@ -347,10 +347,10 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) }) each([ - ['update', '/data/update', data.updateRequest.bind(null, 'nonExistingCollection', [])], - ['count', '/data/count', data.countRequest.bind(null, 'nonExistingCollection')], - ['insert', '/data/insert', data.insertRequest.bind(null, 'nonExistingCollection', [], false)], - ['query', '/data/query', data.queryRequest.bind(null, 'nonExistingCollection', [], undefined)], + ['update', '/items/update', data.updateRequest.bind(null, 'nonExistingCollection', [])], + ['count', '/items/count', data.countRequest.bind(null, 'nonExistingCollection')], + ['insert', '/items/insert', data.insertRequest.bind(null, 'nonExistingCollection', [], false)], + ['query', '/items/query', data.queryRequest.bind(null, 'nonExistingCollection', [], undefined)], ]) .test('%s api on non existing collection should fail with WDE0025, 404', async(_, api, request) => { let error @@ -371,7 +371,7 @@ await data.givenItems([ ctx.items[1] ], ctx.collectionName, authAdmin) await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) let error - await axiosInstance.post('/data/query', data.queryRequest(ctx.collectionName, [], undefined, { nonExistingColumn: { $eq: 'value' } }), authAdmin).catch(e => error = e) + await axiosInstance.post('/items/query', data.queryRequest(ctx.collectionName, [], undefined, { nonExistingColumn: { $eq: 'value' } }), authAdmin).catch(e => error = e) expect(error).toBeDefined() expect(error.response.status).toEqual(400) diff --git a/apps/velo-external-db/test/e2e/app_data_hooks.e2e.spec.ts b/apps/velo-external-db/test/e2e/app_data_hooks.e2e.spec.ts index a2786385e..fd9f8aa07 100644 --- a/apps/velo-external-db/test/e2e/app_data_hooks.e2e.spec.ts +++ b/apps/velo-external-db/test/e2e/app_data_hooks.e2e.spec.ts @@ -16,7 +16,7 @@ const { Aggregate, UpdateImmediately, DeleteImmediately } = SchemaOperations const axios = require('axios').create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => { @@ -93,7 +93,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - await expect(axios.post('/data/count', data.countRequest(ctx.collectionName, { _id: { $ne: ctx.item._id } }), authOwner)).resolves.toEqual( + await expect(axios.post('/items/count', data.countRequest(ctx.collectionName, { _id: { $ne: ctx.item._id } }), authOwner)).resolves.toEqual( matchers.responseWith({ totalCount: 1 })) }) @@ -129,7 +129,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - const response = await axios.post('/data/aggregate', + const response = await axios.post('/items/aggregate', { collectionId: ctx.collectionName, initialFilter: { _id: { $ne: ctx.numberItem._id } }, @@ -172,8 +172,8 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => describe('Write Operations', () => { each(testSupportedOperations(supportedOperations, [ - ['insert', 'beforeInsert', '/data/insert'], - ['update', 'beforeUpdate', '/data/update', { neededOperations: [UpdateImmediately] }], + ['insert', 'beforeInsert', '/items/insert'], + ['update', 'beforeUpdate', '/items/update', { neededOperations: [UpdateImmediately] }], ] )).test('before %s request - should be able to modify the item', async(operation, hookName, api) => { await schema.givenCollection(ctx.collectionName, [ctx.column, ctx.afterAllColumn, ctx.afterWriteColumn, ctx.afterHookColumn], authOwner) @@ -258,7 +258,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - await axios.post('/data/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.numberItem]), authOwner) + await axios.post('/items/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.numberItem]), authOwner) await expect(data.queryCollectionAsArray(ctx.collectionName, [], undefined, authOwner)).resolves.toEqual({ items: [], @@ -290,7 +290,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - await axios.post('/data/truncate', hooks.writeRequestBodyWith('wrongCollectionId', []), authOwner) + await axios.post('/items/truncate', hooks.writeRequestBodyWith('wrongCollectionId', []), authOwner) await expect(data.queryCollectionAsArray(ctx.collectionName, [], undefined, authOwner)).resolves.toEqual({ items: [], @@ -371,7 +371,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - await expect(axios.post('/data/count', data.countRequest(ctx.collectionName), authOwner)).resolves.toEqual( + await expect(axios.post('/items/count', data.countRequest(ctx.collectionName), authOwner)).resolves.toEqual( matchers.responseWith({ totalCount: 3 })) }) @@ -413,7 +413,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - const response = await axios.post('/data/aggregate', + const response = await axios.post('/items/aggregate', { collectionId: ctx.collectionName, initialFilter: { _id: { $eq: ctx.item._id } }, @@ -445,9 +445,9 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => describe('Write Operations', () => { each(testSupportedOperations(supportedOperations, [ - ['insert', 'afterInsert', '/data/insert'], - ['update', 'afterUpdate', '/data/update', { neededOperations: [UpdateImmediately] }], - ['remove', 'afterRemove', '/data/remove', { neededOperations: [DeleteImmediately] }], + ['insert', 'afterInsert', '/items/insert'], + ['update', 'afterUpdate', '/items/update', { neededOperations: [UpdateImmediately] }], + ['remove', 'afterRemove', '/items/remove', { neededOperations: [DeleteImmediately] }], ])).test('after %s request - should be able to modify response', async(operation, hookName, api) => { await schema.givenCollection(ctx.collectionName, [ctx.column, ctx.afterAllColumn, ctx.afterWriteColumn, ctx.afterHookColumn], authOwner) if (operation !== 'insert') { @@ -515,7 +515,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - await expect(axios.post('/data/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.item]), authOwner)).rejects.toMatchObject( + await expect(axios.post('/items/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.item]), authOwner)).rejects.toMatchObject( errorResponseWith(409, 'message') ) }) @@ -530,7 +530,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - await expect(axios.post('/data/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.item]), authOwner)).rejects.toMatchObject( + await expect(axios.post('/items/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.item]), authOwner)).rejects.toMatchObject( errorResponseWith(500, 'message') ) }) @@ -544,7 +544,7 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => } }) - await expect(axios.post('/data/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.item]), authOwner)).rejects.toMatchObject( + await expect(axios.post('/items/remove', hooks.writeRequestBodyWith(ctx.collectionName, [ctx.item]), authOwner)).rejects.toMatchObject( errorResponseWith(500, 'message') ) }) @@ -553,12 +553,12 @@ describe(`Velo External DB Data Hooks: ${currentDbImplementationName()}`, () => describe('Custom context, Service context', () => { //skip aggregate if needed! each(testSupportedOperations(supportedOperations, [ - ['query', 'Read', 'beforeQuery', 'afterQuery', '/data/query'], - ['count', 'Read', 'beforeCount', 'afterCount', '/data/count'], - ['insert', 'Write', 'beforeInsert', 'afterInsert', '/data/insert'], - ['update', 'Write', 'beforeUpdate', 'afterUpdate', '/data/update', { neededOperations: [UpdateImmediately] }], - ['remove', 'Write', 'beforeRemove', 'afterRemove', '/data/remove', { neededOperations: [DeleteImmediately] }], - ['truncate', 'Write', 'beforeTruncate', 'afterTruncate', '/data/truncate'], + ['query', 'Read', 'beforeQuery', 'afterQuery', '/items/query'], + ['count', 'Read', 'beforeCount', 'afterCount', '/items/count'], + ['insert', 'Write', 'beforeInsert', 'afterInsert', '/items/insert'], + ['update', 'Write', 'beforeUpdate', 'afterUpdate', '/items/update', { neededOperations: [UpdateImmediately] }], + ['remove', 'Write', 'beforeRemove', 'afterRemove', '/items/remove', { neededOperations: [DeleteImmediately] }], + ['truncate', 'Write', 'beforeTruncate', 'afterTruncate', '/items/truncate'], ])).test('%s - should be able to modify custom context from each hook, and use service context', async(operation, operationType, beforeHook, afterHook, api) => { await schema.givenCollection(ctx.collectionName, [ctx.column], authOwner) if (operation !== 'insert') { diff --git a/apps/velo-external-db/test/e2e/app_schema.e2e.spec.ts b/apps/velo-external-db/test/e2e/app_schema.e2e.spec.ts index 4713de97c..c8a99772f 100644 --- a/apps/velo-external-db/test/e2e/app_schema.e2e.spec.ts +++ b/apps/velo-external-db/test/e2e/app_schema.e2e.spec.ts @@ -13,7 +13,7 @@ import { initApp, teardownApp, dbTeardown, setupDb, currentDbImplementationName, const chance = Chance() const axiosClient = axios.create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) describe(`Schema REST API: ${currentDbImplementationName()}`, () => { diff --git a/apps/velo-external-db/test/e2e/app_schema_hooks.e2e.spec.ts b/apps/velo-external-db/test/e2e/app_schema_hooks.e2e.spec.ts index e8c65141a..6949a74cb 100644 --- a/apps/velo-external-db/test/e2e/app_schema_hooks.e2e.spec.ts +++ b/apps/velo-external-db/test/e2e/app_schema_hooks.e2e.spec.ts @@ -14,7 +14,7 @@ import hooks = require('../drivers/hooks_test_support') import * as data from '../drivers/data_api_rest_test_support' const axiosClient = axios.create({ - baseURL: 'http://localhost:8080' + baseURL: 'http://localhost:8080/v3' }) diff --git a/libs/velo-external-db-core/src/router.ts b/libs/velo-external-db-core/src/router.ts index ff22d1962..b6f0d4e11 100644 --- a/libs/velo-external-db-core/src/router.ts +++ b/libs/velo-external-db-core/src/router.ts @@ -23,7 +23,6 @@ import { DataHooks, Hooks, RequestContext, SchemaHooks, ServiceContext } from '. import { ConfigValidator } from '@wix-velo/external-db-config' import * as dataSource from './spi-model/data_source' import * as schemaSource from './spi-model/collection' -import * as capabilities from './spi-model/capabilities' import { JWTVerifier } from './web/jwt-verifier' import { JWTVerifierDecoderMiddleware } from './web/jwt-verifier-decoder-middleware' @@ -101,19 +100,23 @@ export const createRouter = () => { res.send(appInfoPage) }) - router.get('/capabilities', async(req, res) => { + router.post('/capabilities/get', async(req, res) => { const capabilitiesResponse = { - capabilities: { - collection: [capabilities.CollectionCapability.CREATE] - } as capabilities.Capabilities - } as capabilities.GetCapabilitiesResponse + supportsCollectionModifications: true, + supportedFieldTypes: ['TEXT', 'NUMBER', 'DATE', 'DATETIME', 'BOOLEAN'], + supportsCollectionDisplayName: false, + supportsCollectionDisplayField: false, + supportsCollectionPermissions: false, + supportsCollectionFieldDisplayName: false, + supportsCollectionFieldDescription: false, + } res.json(capabilitiesResponse) }) router.post('/provision', async(req, res) => { const { type, vendor } = cfg - res.json({ type, vendor, protocolVersion: 3, adapterVersion: 'v1' }) + res.json({ type, vendor, protocolVersion: 3, adapterVersion: 'v3' }) }) router.get('/connectionStatus', async(req, res) => { @@ -122,7 +125,7 @@ export const createRouter = () => { }) // *************** Data API ********************** - router.post('/data/query', async(req, res, next) => { + router.post('/items/query', async(req, res, next) => { try { const customContext = {} const { collectionId, query, returnTotalCount } = await executeDataHooksFor(DataActions.BeforeQuery, dataPayloadFor(Query, req.body), requestContextFor(Query, req.body, res.locals), customContext) as dataSource.QueryRequest @@ -148,7 +151,7 @@ export const createRouter = () => { } }) - router.post('/data/count', async(req, res, next) => { + router.post('/items/count', async(req, res, next) => { try { const customContext = {} const { collectionId, filter } = await executeDataHooksFor(DataActions.BeforeCount, dataPayloadFor(Count, req.body), requestContextFor(Count, req.body, res.locals), customContext) as dataSource.CountRequest @@ -166,7 +169,7 @@ export const createRouter = () => { } }) - router.post('/data/insert', async(req, res, next) => { + router.post('/items/insert', async(req, res, next) => { try { const customContext = {} const { collectionId, items } = await executeDataHooksFor(DataActions.BeforeInsert, dataPayloadFor(Insert, req.body), requestContextFor(Insert, req.body, res.locals), customContext) as dataSource.InsertRequest @@ -181,7 +184,7 @@ export const createRouter = () => { } }) - router.post('/data/update', async(req, res, next) => { + router.post('/items/update', async(req, res, next) => { try { const customContext = {} @@ -197,7 +200,7 @@ export const createRouter = () => { } }) - router.post('/data/remove', async(req, res, next) => { + router.post('/items/remove', async(req, res, next) => { try { const customContext = {} const { collectionId, itemIds } = await executeDataHooksFor(DataActions.BeforeRemove, dataPayloadFor(Remove, req.body), requestContextFor(Remove, req.body, res.locals), customContext) as dataSource.RemoveRequest @@ -213,7 +216,7 @@ export const createRouter = () => { } }) - router.post('/data/aggregate', async(req, res, next) => { + router.post('/items/aggregate', async(req, res, next) => { try { const customContext = {} const { collectionId, initialFilter, aggregation, finalFilter, sort, pagingMethod, returnTotalCount } = await executeDataHooksFor(DataActions.BeforeAggregate, @@ -234,7 +237,7 @@ export const createRouter = () => { } }) - router.post('/data/truncate', async(req, res, next) => { + router.post('/items/truncate', async(req, res, next) => { try { const customContext = {} const { collectionId } = await executeDataHooksFor(DataActions.BeforeTruncate, dataPayloadFor(Truncate, req.body), requestContextFor(Truncate, req.body, res.locals), customContext) as dataSource.TruncateRequest