diff --git a/.dependency-cruiser.cjs b/.dependency-cruiser.cjs index ad306ee3d84..5e8c1e11def 100644 --- a/.dependency-cruiser.cjs +++ b/.dependency-cruiser.cjs @@ -19,6 +19,35 @@ module.exports = { from: { path: '(^|/)src/(routes|ui)/' }, to: { path: '(^|/)src/common/database\\.ts$' }, }, + { + name: 'domain-no-outward-deps', + comment: + 'domain is the hexagon center: pure business logic with zero dependency on application, ' + + 'infrastructure, any app, or Electron/transport libs. Everything else depends on domain, never ' + + 'the reverse.', + severity: 'warn', + from: { path: '^domain/' }, + to: { path: '^(application|infrastructure|apps)/|^(node_modules/)?electron($|/)' }, + }, + { + name: 'application-domain-only', + comment: + 'application orchestrates domain entities/repositories and depends on domain only - never ' + + 'infrastructure (concrete adapters) or a specific app.', + severity: 'warn', + from: { path: '^application/' }, + to: { path: '^(infrastructure|apps)/' }, + }, + { + name: 'infrastructure-no-application-or-apps', + comment: + 'infrastructure implements domain-defined ports and depends on domain plus external libs/' + + 'Electron/Node - never application (that direction is backwards) or a specific app (infrastructure ' + + 'is reached from an app\'s bootstrap/wiring code, not the other way around).', + severity: 'warn', + from: { path: '^infrastructure/' }, + to: { path: '^(application|apps)/' }, + }, ], options: { doNotFollow: { diff --git a/application/package.json b/application/package.json new file mode 100644 index 00000000000..11253031b28 --- /dev/null +++ b/application/package.json @@ -0,0 +1,27 @@ +{ + "private": true, + "name": "application", + "license": "Apache-2.0", + "version": "13.1.0", + "author": "Kong ", + "description": "Use cases that orchestrate domain entities and repositories, plus cross-cutting application-level ports (NetworkClient, TemplatingEngine, Clock, IdGenerator, ...). Depends on domain only.", + "repository": { + "type": "git", + "url": "git+https://github.com/Kong/insomnia.git", + "directory": "application" + }, + "bugs": { + "url": "https://github.com/kong/insomnia/issues" + }, + "homepage": "https://github.com/Kong/insomnia#readme", + "exports": { + ".": { + "import": "./src/index.ts", + "types": "./src/index.ts" + } + }, + "scripts": { + "lint": "eslint . --ext .ts,.tsx --cache", + "type-check": "tsc --noEmit --project tsconfig.json" + } +} diff --git a/application/src/index.ts b/application/src/index.ts new file mode 100644 index 00000000000..4fec6058e37 --- /dev/null +++ b/application/src/index.ts @@ -0,0 +1,6 @@ +// application: use cases that orchestrate domain entities and repositories, plus +// cross-cutting application-level ports (NetworkClient, TemplatingEngine, Clock, +// IdGenerator, ...). Depends on domain only. +// Populated incrementally, one aggregate at a time. +// eslint-disable-next-line unicorn/require-module-specifiers -- placeholder until real exports land +export {}; diff --git a/application/tsconfig.json b/application/tsconfig.json new file mode 100644 index 00000000000..5518ce9aab1 --- /dev/null +++ b/application/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "moduleResolution": "bundler", + "isolatedModules": true, + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, + "target": "es2022", + "module": "ESNext", + "noEmit": true, + "lib": ["ES2023"] + }, + "include": ["src"] +} diff --git a/domain/package.json b/domain/package.json new file mode 100644 index 00000000000..3f77b4cfcd5 --- /dev/null +++ b/domain/package.json @@ -0,0 +1,27 @@ +{ + "private": true, + "name": "domain", + "license": "Apache-2.0", + "version": "13.1.0", + "author": "Kong ", + "description": "Pure business logic - entities, value objects, and the Repository/port interfaces implemented by infrastructure. No I/O, no framework or runtime dependencies.", + "repository": { + "type": "git", + "url": "git+https://github.com/Kong/insomnia.git", + "directory": "domain" + }, + "bugs": { + "url": "https://github.com/kong/insomnia/issues" + }, + "homepage": "https://github.com/Kong/insomnia#readme", + "exports": { + ".": { + "import": "./src/index.ts", + "types": "./src/index.ts" + } + }, + "scripts": { + "lint": "eslint . --ext .ts,.tsx --cache", + "type-check": "tsc --noEmit --project tsconfig.json" + } +} diff --git a/domain/src/index.ts b/domain/src/index.ts new file mode 100644 index 00000000000..0b76107b8bd --- /dev/null +++ b/domain/src/index.ts @@ -0,0 +1,5 @@ +// domain: pure business logic - entities, value objects, and the Repository/port +// interfaces implemented by infrastructure. No I/O, no framework or runtime dependencies. +// Populated incrementally, one aggregate at a time. +// eslint-disable-next-line unicorn/require-module-specifiers -- placeholder until real exports land +export {}; diff --git a/domain/tsconfig.json b/domain/tsconfig.json new file mode 100644 index 00000000000..5518ce9aab1 --- /dev/null +++ b/domain/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "moduleResolution": "bundler", + "isolatedModules": true, + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, + "target": "es2022", + "module": "ESNext", + "noEmit": true, + "lib": ["ES2023"] + }, + "include": ["src"] +} diff --git a/infrastructure/package.json b/infrastructure/package.json new file mode 100644 index 00000000000..d9f7bf9c848 --- /dev/null +++ b/infrastructure/package.json @@ -0,0 +1,27 @@ +{ + "private": true, + "name": "infrastructure", + "license": "Apache-2.0", + "version": "13.1.0", + "author": "Kong ", + "description": "Adapters implementing domain- and application-defined ports (persistence, network, sync, secret storage). Depends on domain plus external libs/Electron/Node. Only reachable from each app's own bootstrap/wiring code, never from route/command logic directly.", + "repository": { + "type": "git", + "url": "git+https://github.com/Kong/insomnia.git", + "directory": "infrastructure" + }, + "bugs": { + "url": "https://github.com/kong/insomnia/issues" + }, + "homepage": "https://github.com/Kong/insomnia#readme", + "exports": { + ".": { + "import": "./src/index.ts", + "types": "./src/index.ts" + } + }, + "scripts": { + "lint": "eslint . --ext .ts,.tsx --cache", + "type-check": "tsc --noEmit --project tsconfig.json" + } +} diff --git a/infrastructure/src/index.ts b/infrastructure/src/index.ts new file mode 100644 index 00000000000..5612ce37ed0 --- /dev/null +++ b/infrastructure/src/index.ts @@ -0,0 +1,6 @@ +// infrastructure: adapters implementing domain- and application-defined ports +// (persistence, network, sync, secret storage). Depends on domain plus external +// libs/Electron/Node. Only reachable from each app's own bootstrap/wiring code. +// Populated incrementally, one aggregate at a time. +// eslint-disable-next-line unicorn/require-module-specifiers -- placeholder until real exports land +export {}; diff --git a/infrastructure/tsconfig.json b/infrastructure/tsconfig.json new file mode 100644 index 00000000000..67b8ef4d94a --- /dev/null +++ b/infrastructure/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "moduleResolution": "bundler", + "isolatedModules": true, + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "useUnknownInCatchVariables": false, + "target": "es2022", + "module": "ESNext", + "noEmit": true, + "lib": ["ES2023"], + "types": ["node"] + }, + "include": ["src"] +} diff --git a/package-lock.json b/package-lock.json index 2038925254d..b65cadf68bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,9 @@ "workspaces": [ "apps/desktop", "apps/cli", + "domain", + "application", + "infrastructure", "packages/insomnia-testing", "packages/insomnia-data", "packages/insomnia-analytics", @@ -57,6 +60,10 @@ "npm": ">=11" } }, + "application": { + "version": "13.1.0", + "license": "Apache-2.0" + }, "apps/cli": { "name": "insomnia-inso", "version": "13.1.0", @@ -331,6 +338,14 @@ "url": "https://github.com/sponsors/colinhacks" } }, + "domain": { + "version": "13.1.0", + "license": "Apache-2.0" + }, + "infrastructure": { + "version": "13.1.0", + "license": "Apache-2.0" + }, "node_modules/@apideck/better-ajv-errors": { "version": "0.3.7", "resolved": "https://registry.npmjs.org/@apideck/better-ajv-errors/-/better-ajv-errors-0.3.7.tgz", @@ -12670,6 +12685,10 @@ "dev": true, "license": "BSD-2-Clause" }, + "node_modules/application": { + "resolved": "application", + "link": true + }, "node_modules/arg": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", @@ -15546,6 +15565,10 @@ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" } }, + "node_modules/domain": { + "resolved": "domain", + "link": true + }, "node_modules/domelementtype": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", @@ -19297,6 +19320,10 @@ "wrappy": "1" } }, + "node_modules/infrastructure": { + "resolved": "infrastructure", + "link": true + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", diff --git a/package.json b/package.json index 16fa3980376..362e5239d1f 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "workspaces": [ "apps/desktop", "apps/cli", + "domain", + "application", + "infrastructure", "packages/insomnia-testing", "packages/insomnia-data", "packages/insomnia-analytics", @@ -30,9 +33,10 @@ "lint": "npm run lint --workspaces --if-present", "type-check": "npm run type-check --workspaces --if-present", "test": "npm run test --workspaces --if-present", - "check-boundaries": "npm run check-boundaries:insomnia-data && npm run check-boundaries:insomnia", + "check-boundaries": "npm run check-boundaries:insomnia-data && npm run check-boundaries:insomnia && npm run check-boundaries:hexagon", "check-boundaries:insomnia-data": "depcruise packages/insomnia-data/src packages/insomnia-data/node-src packages/insomnia-data/common-src --config .dependency-cruiser.cjs", "check-boundaries:insomnia": "cd apps/desktop && depcruise src --config ../../.dependency-cruiser.cjs --ts-config tsconfig.json", + "check-boundaries:hexagon": "depcruise domain/src application/src infrastructure/src --config .dependency-cruiser.cjs", "clean": "git clean -dfX", "install-libcurl-electron": "node-pre-gyp install --directory node_modules/@getinsomnia/node-libcurl --update-binary --runtime=electron --target=43.2.0", "install-libcurl-node": "node-pre-gyp install --directory node_modules/@getinsomnia/node-libcurl --update-binary --runtime=node --target=24.18.0",