Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"packages/auth-bundler": "12.0.0",
"packages/auth-core": "12.0.0",
"packages/auth-openapi": "12.0.0",
"packages/test-utils": "12.0.0",
"apps/auth-cron": "12.0.0",
"apps/auth-manager": "12.0.0",
Expand Down
8 changes: 8 additions & 0 deletions .vscode/project.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
"name": "Auth Core",
"path": "../packages/auth-core",
},
{
"name": "Auth OpenAPI",
"path": "../packages/auth-openapi",
},
{
"name": "Test Utils",
"path": "../packages/test-utils",
},
{
"name": "Auth Cron",
"path": "../packages/auth-cron",
Expand Down
3 changes: 1 addition & 2 deletions apps/auth-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"migration:revert": "npm run typeorm migration:revert -- ",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"lint:openapi": "redocly lint --config ../../.redocly.yaml openapi3.yaml",
"prebuild": "npm run clean",
"build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json && npm run assets:copy",
"build:docker": "docker buildx build --build-arg APP_NAME=$npm_package_name -f ../../docker/backend.Dockerfile -t ${DOCKER_REGISTRY:-}${npm_package_name}:${DOCKER_TAG:-latest} ${DOCKER_FLAGS:-} ../..",
Expand All @@ -34,7 +33,6 @@
"start:dev": "npm run build && cd dist && cross-env CONFIG_OFFLINE_MODE=true node --enable-source-maps --import ./instrumentation.mjs ./index.js",
"assets:copy": "copyfiles -f ./config/* ./dist/config && copyfiles -f ./openapi3.yaml ./dist/ && copyfiles ./dataSource.mjs dist && copyfiles ./package.json dist",
"clean": "rimraf dist",
"generate:openapi-types": "openapi-helpers ./openapi3.yaml ./src/openapi.d.ts --format --add-typed-request-handler",
"knip": "knip --directory ../.. --workspace apps/auth-manager"
},
"bugs": {
Expand All @@ -52,6 +50,7 @@
"@map-colonies/schemas": "catalog:",
"@map-colonies/telemetry": "^10.0.1",
"@opentelemetry/api": "^1.9.0",
"auth-openapi": "workspace:^",
"body-parser": "^2.2.2",
"compression": "^1.7.4",
"cors": "^2.8.5",
Expand Down
2 changes: 1 addition & 1 deletion apps/auth-manager/src/asset/controllers/assetController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpError } from '@map-colonies/error-express-handler';
import httpStatus from 'http-status-codes';
import { injectable, inject } from 'tsyringe';
import { type Logger } from '@map-colonies/js-logger';
import type { TypedRequestHandlers, components } from '@openapi';
import type { TypedRequestHandlers, components } from 'auth-openapi';
import { SERVICES } from '@common/constants';
import { AssetManager, type ResponseAsset } from '../models/assetManager';
import { AssetNotFoundError, AssetVersionMismatchError } from '../models/errors';
Expand Down
2 changes: 1 addition & 1 deletion apps/auth-manager/src/asset/models/assetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IAsset } from '@map-colonies/auth-core';
import { inject, injectable } from 'tsyringe';
import { ArrayContains } from 'typeorm';
import type { SetRequired } from 'type-fest';
import { operations } from '@openapi';
import { operations } from 'auth-openapi';
import { SERVICES } from '@common/constants';
import { type AssetRepository } from '../DAL/assetRepository';
import { AssetVersionMismatchError, AssetNotFoundError } from './errors';
Expand Down
3 changes: 1 addition & 2 deletions apps/auth-manager/src/bundle/controllers/bundleController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { HttpError } from '@map-colonies/error-express-handler';
import { IBundle } from '@map-colonies/auth-core';
import httpStatus from 'http-status-codes';
import { injectable, inject } from 'tsyringe';
import type { TypedRequestHandlers, components, operations } from '@openapi';

import type { TypedRequestHandlers, components, operations } from 'auth-openapi';
import { BundleManager } from '../models/bundleManager';
import { BundleNotFoundError } from '../models/errors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import httpStatus from 'http-status-codes';
import { injectable, inject } from 'tsyringe';
import { IClient } from '@map-colonies/auth-core';
import { parseISO } from 'date-fns';
import type { TypedRequestHandlers, components, operations } from '@openapi';
import type { TypedRequestHandlers, components, operations } from 'auth-openapi';
import { SERVICES } from '@common/constants';
import { DEFAULT_PAGE_SIZE } from '@src/common/db/pagination';
import { sortOptionParser } from '@src/common/db/sort';
Expand Down
2 changes: 1 addition & 1 deletion apps/auth-manager/src/client/models/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { operations } from '@src/openapi';
import type { operations } from 'auth-openapi';

type DateKeys = 'createdBefore' | 'createdAfter' | 'updatedBefore' | 'updatedAfter';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import httpStatus from 'http-status-codes';
import { injectable, inject } from 'tsyringe';
import { type Logger } from '@map-colonies/js-logger';
import { IConnection } from '@map-colonies/auth-core';
import type { TypedRequestHandlers, components } from '@openapi';
import type { TypedRequestHandlers, components } from 'auth-openapi';
import { SERVICES } from '@common/constants';
import { ClientNotFoundError } from '@client/models/errors';
import { DEFAULT_PAGE_SIZE } from '@src/common/db/pagination';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Client, Connection, Environments, IConnection } from '@map-colonies/aut
import { inject, injectable } from 'tsyringe';
import { SelectQueryBuilder } from 'typeorm';
import { JWK } from 'jose';
import { paths } from 'auth-openapi';
import { ClientNotFoundError } from '@client/models/errors';
import { SERVICES } from '@common/constants';
import { type DomainRepository } from '@domain/DAL/domainRepository';
Expand All @@ -13,7 +14,6 @@ import { PaginationParams, paginationParamsToFindOptions } from '@src/common/db/
import { KeyNotFoundError } from '@key/models/errors';
import { SortOptions } from '@src/common/db/sort';
import { asteriskStringComparatorLast } from '@src/utils/utils';
import { paths } from '@src/openapi';
import { type ConnectionRepository } from '../DAL/connectionRepository';
import { ConnectionVersionMismatchError, ConnectionNotFoundError } from './errors';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpError } from '@map-colonies/error-express-handler';
import httpStatus from 'http-status-codes';
import { injectable, inject } from 'tsyringe';
import { Domain } from '@map-colonies/auth-core';
import type { TypedRequestHandlers } from '@openapi';
import type { TypedRequestHandlers } from 'auth-openapi';
import { sortOptionParser } from '@src/common/db/sort';
import { DEFAULT_PAGE_SIZE } from '@src/common/db/pagination';
import { DomainManager } from '../models/domainManager';
Expand Down
2 changes: 1 addition & 1 deletion apps/auth-manager/src/key/controllers/keyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpError } from '@map-colonies/error-express-handler';
import httpStatus from 'http-status-codes';
import { injectable, inject } from 'tsyringe';
import { type Logger } from '@map-colonies/js-logger';
import type { TypedRequestHandlers } from '@openapi';
import type { TypedRequestHandlers } from 'auth-openapi';
import { SERVICES } from '@common/constants';
import { KeyManager } from '../models/keyManager';
import { KeyNotFoundError, KeyVersionMismatchError } from '../models/errors';
Expand Down
8 changes: 5 additions & 3 deletions apps/auth-manager/src/serverBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'node:path';
import express, { Router } from 'express';
import bodyParser from 'body-parser';
import compression, { CompressionOptions } from 'compression';
Expand All @@ -20,6 +21,8 @@ import { CONNECTION_ROUTER_SYMBOL } from './connection/routes/connectionRouter';
import { BUNDLE_ROUTER_SYMBOL } from './bundle/routes/bundleRouter';
import type { ConfigType } from './common/config';

const OPENAPI_PATH = path.join(path.dirname(require.resolve('auth-openapi')), 'openapi3.yaml');

@injectable()
export class ServerBuilder {
private readonly serverInstance: express.Application;
Expand Down Expand Up @@ -49,7 +52,7 @@ export class ServerBuilder {
private buildDocsRoutes(): void {
const openapiRouter = new OpenapiViewerRouter({
...this.config.get('openapiConfig'),
filePathOrSpec: this.config.get('openapiConfig.filePath'),
filePathOrSpec: OPENAPI_PATH,
});
openapiRouter.setup();
this.serverInstance.use(this.config.get('openapiConfig.basePath'), openapiRouter.getRouter());
Expand Down Expand Up @@ -88,10 +91,9 @@ export class ServerBuilder {
this.serverInstance.use(getTraceContexHeaderMiddleware());

const ignorePathRegex = new RegExp(`^${this.config.get('openapiConfig.basePath')}/.*`, 'i');
const apiSpecPath = this.config.get('openapiConfig.filePath');
this.serverInstance.use(
OpenApiMiddleware({
apiSpec: apiSpecPath,
apiSpec: OPENAPI_PATH,
validateRequests: true,
ignorePaths: ignorePathRegex,
formats: { phone: true },
Expand Down
4 changes: 2 additions & 2 deletions apps/auth-manager/tests/configurations/vitest.setup.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';

import path from 'node:path';
import { setupOpenapi } from '@map-colonies/vitest-utils';
import { OPENAPI_PATH } from '@tests/utils/paths.mjs';

setupOpenapi(path.join(process.cwd(), 'openapi3.yaml'));
setupOpenapi(OPENAPI_PATH);
5 changes: 3 additions & 2 deletions apps/auth-manager/tests/integration/asset/asset.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { faker } from '@faker-js/faker';
import type { RequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { createRequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { getFakeAsset } from 'test-utils';
import type { paths, operations } from '@openapi';
import type { paths, operations } from 'auth-openapi';
import type { AssetRepository } from '@src/asset/DAL/assetRepository.js';
import { getApp } from '@src/app.js';
import { SERVICES } from '@common/constants.js';
import { initConfig } from '@common/config.js';
import { OPENAPI_PATH } from '@tests/utils/paths.mjs';

describe('client', function () {
let requestSender: RequestSender<paths, operations>;
Expand All @@ -31,7 +32,7 @@ describe('client', function () {
],
useChild: true,
});
requestSender = await createRequestSender<paths, operations>('openapi3.yaml', app);
requestSender = await createRequestSender<paths, operations>(OPENAPI_PATH, app);
depContainer = container;
});

Expand Down
5 changes: 3 additions & 2 deletions apps/auth-manager/tests/integration/bundle/bundle.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import 'jest-openapi';
import type { RequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { createRequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { getFakeBundle } from 'test-utils';
import type { paths, operations } from '@openapi';
import type { paths, operations } from 'auth-openapi';
import { getApp } from '@src/app.js';
import { SERVICES } from '@common/constants.js';
import { initConfig } from '@common/config.js';
import { OPENAPI_PATH } from '@tests/utils/paths.mjs';

describe('bundle', function () {
let requestSender: RequestSender<paths, operations>;
Expand All @@ -32,7 +33,7 @@ describe('bundle', function () {
],
useChild: true,
});
requestSender = await createRequestSender<paths, operations>('openapi3.yaml', app);
requestSender = await createRequestSender<paths, operations>(OPENAPI_PATH, app);
depContainer = container;

await container.resolve(DataSource).getRepository(Bundle).save(bundles);
Expand Down
5 changes: 3 additions & 2 deletions apps/auth-manager/tests/integration/client/client.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { Client } from '@map-colonies/auth-core';
import type { RequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { createRequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { getFakeClient } from 'test-utils';
import type { paths, operations } from '@openapi';
import type { paths, operations } from 'auth-openapi';
import { getApp } from '@src/app.js';
import { SERVICES } from '@common/constants.js';
import { initConfig } from '@common/config.js';
import type { ClientRepository } from '@src/client/DAL/clientRepository.js';
import { OPENAPI_PATH } from '@tests/utils/paths.mjs';

describe('client', function () {
let requestSender: RequestSender<paths, operations>;
Expand All @@ -31,7 +32,7 @@ describe('client', function () {
],
useChild: true,
});
requestSender = await createRequestSender<paths, operations>('openapi3.yaml', app);
requestSender = await createRequestSender<paths, operations>(OPENAPI_PATH, app);
depContainer = container;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ import { faker } from '@faker-js/faker';
import type { RequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { createRequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { getRealKeys, getFakeClient, getFakeConnection, getFakeIConnection } from 'test-utils';
import type { paths, operations } from '@openapi';
import type { paths, operations } from 'auth-openapi';
import { getApp } from '@src/app.js';
import { SERVICES } from '@common/constants.js';
import type { ConnectionRepository } from '@src/connection/DAL/connectionRepository.js';
import type { KeyRepository } from '@src/key/DAL/keyRepository.js';
import type { DomainRepository } from '@src/domain/DAL/domainRepository.js';
import { initConfig } from '@common/config.js';
import { OPENAPI_PATH } from '@tests/utils/paths.mjs';

describe('connection', function () {
const OPENAPI_SPEC_PATH = 'openapi3.yaml'; // Path to the OpenAPI spec file

let requestSender: RequestSender<paths, operations>;
let depContainer: DependencyContainer;
const clients = [getFakeClient(false), getFakeClient(false)];
Expand All @@ -42,7 +41,7 @@ describe('connection', function () {
],
useChild: true,
});
requestSender = await createRequestSender<paths, operations>(OPENAPI_SPEC_PATH, app);
requestSender = await createRequestSender<paths, operations>(OPENAPI_PATH, app);
depContainer = container;
});

Expand Down
9 changes: 4 additions & 5 deletions apps/auth-manager/tests/integration/domain/domain.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import type { IDomain } from '@map-colonies/auth-core';
import { Domain } from '@map-colonies/auth-core';
import type { RequestSender } from '@map-colonies/openapi-helpers/requestSender';
import { createRequestSender } from '@map-colonies/openapi-helpers/requestSender';
import type { paths, operations } from '@openapi';
import type { paths, operations } from 'auth-openapi';
import { getApp } from '@src/app.js';
import { SERVICES } from '@src/common/constants.js';
import { initConfig } from '@src/common/config.js';
import { OPENAPI_PATH } from '@tests/utils/paths.mjs';

describe('domain', function () {
const OPENAPI_SPEC_PATH = 'openapi3.yaml'; // Path to the OpenAPI spec file

let requestSender: RequestSender<paths, operations>;
let depContainer: DependencyContainer;

Expand All @@ -31,7 +30,7 @@ describe('domain', function () {
],
useChild: true,
});
requestSender = await createRequestSender<paths, operations>(OPENAPI_SPEC_PATH, app);
requestSender = await createRequestSender<paths, operations>(OPENAPI_PATH, app);
depContainer = container;
});

Expand Down Expand Up @@ -121,7 +120,7 @@ describe('domain', function () {
],
useChild: true,
});
mockedSender = await createRequestSender<paths, operations>(OPENAPI_SPEC_PATH, app);
mockedSender = await createRequestSender<paths, operations>(OPENAPI_PATH, app);
await container.resolve(DataSource).destroy();
vi.resetAllMocks();
});
Expand Down
7 changes: 3 additions & 4 deletions apps/auth-manager/tests/integration/key/key.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import { createRequestSender } from '@map-colonies/openapi-helpers/requestSender
import type { IKey, Environments } from '@map-colonies/auth-core';
import { Key, Environment } from '@map-colonies/auth-core';
import { getMockKeys } from 'test-utils';
import type { paths, operations, components } from '@openapi';
import type { paths, operations, components } from 'auth-openapi';
import { getApp } from '@src/app.js';
import { SERVICES } from '@src/common/constants.js';
import type { KeyRepository } from '@src/key/DAL/keyRepository.js';
import { initConfig } from '@src/common/config.js';
import { OPENAPI_PATH } from '@tests/utils/paths.mjs';

describe('key', function () {
const OPENAPI_SPEC_PATH = 'openapi3.yaml'; // Path to the OpenAPI spec file

let requestSender: RequestSender<paths, operations>;
let depContainer: DependencyContainer;

Expand All @@ -35,7 +34,7 @@ describe('key', function () {
],
useChild: true,
});
requestSender = await createRequestSender<paths, operations>(OPENAPI_SPEC_PATH, app);
requestSender = await createRequestSender<paths, operations>(OPENAPI_PATH, app);
depContainer = container;
});

Expand Down
6 changes: 6 additions & 0 deletions apps/auth-manager/tests/utils/paths.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const authOpenapiPath = fileURLToPath(new URL('.', import.meta.resolve('auth-openapi')));

export const OPENAPI_PATH = path.join(authOpenapiPath, 'openapi3.yaml');
8 changes: 2 additions & 6 deletions apps/auth-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
"build:docker-no-cache": "cross-env DOCKER_FLAGS=--no-cache pnpm run build:docker",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"format": "prettier --check .",
"format:fix": "prettier --write .",
"prepare": "husky",
"generate-openapi": "openapi-typescript http://localhost:8080/docs/api.yaml -o src/types/schema.d.ts",
"knip": "knip --directory ../.. --workspace apps/auth-ui"
},
"overrides": {
Expand Down Expand Up @@ -67,9 +63,9 @@
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^15.15.0",
"openapi-typescript": "^7.6.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.24.1",
"vite": "^6.2.6"
"vite": "^6.2.6",
"auth-openapi": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion apps/auth-ui/src/fetch/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import createClient from 'openapi-react-query';
import createFetchClient from 'openapi-fetch';
import type { paths } from '../types/schema';
import type { paths } from 'auth-openapi';
import { configLoader } from '../config/loader';
import { NetworkConfig } from '../types/config';

Expand Down
2 changes: 1 addition & 1 deletion apps/auth-ui/src/pages/clients/ClientsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button } from '../../components/ui/button';
import { Loader2, Plus, Search, Calendar, Filter, X, ChevronDown, ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
import { Input } from '../../components/ui/input';
import { Dialog } from '../../components/ui/dialog';
import { components } from '../../types/schema';
import type { components } from 'auth-openapi';
import { ClientsTable } from './ClientsTable';
import { CreateClientModal } from './CreateClientModal';
import { EditClientModal } from './EditClientModal';
Expand Down
2 changes: 1 addition & 1 deletion apps/auth-ui/src/pages/clients/ClientsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from 'react';
import { components } from '../../types/schema';
import type { components } from 'auth-openapi';
import { Button } from '../../components/ui/button';
import { Pencil, ArrowUpDown, ArrowUp, ArrowDown } from 'lucide-react';
import { Badge } from '../../components/ui/badge';
Expand Down
2 changes: 1 addition & 1 deletion apps/auth-ui/src/pages/clients/CreateClientModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { components } from '../../types/schema';
import type { components } from 'auth-openapi';
import { Button } from '../../components/ui/button';
import { Loader2, X, AlertCircle, ArrowRight, Check } from 'lucide-react';
import { Input } from '../../components/ui/input';
Expand Down
Loading
Loading