feat(boc): Complete Business Operations Center v1.0

- Go backend API with full CRUD for all modules (CRM, Sales, Finance, HR, Legal, Marketing, Support, Purchase, Inventory, Projects, Automation, Analytics)
- Rust analytics service with parallel report generation
- C runtime with POSIX shared memory IPC
- PostgreSQL schema with 30+ tables, full migrations
- Redis cache, sessions, pub/sub
- Kafka event streaming with Zookeeper
- WebSocket hub for real-time updates
- Automation engine with cron jobs, workflows, event triggers
- JWT authentication, multi-tenant from start
- Docker Compose with all services
- Nginx reverse proxy with rate limiting
- Integration tests passing
- Feature gap analysis against Fortnox/Odoo/Visma

Refs: BOC-001
This commit is contained in:
Bernt
2026-07-12 12:41:35 +00:00
parent 4789a7fb48
commit 58ca4e68db
26666 changed files with 575891 additions and 2074516 deletions
@@ -0,0 +1,106 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FetchHttpClientResponse = exports.FetchHttpClient = void 0;
const HttpClient_js_1 = require("./HttpClient.js");
/**
* HTTP client which uses a `fetch` function to issue requests.
*
* By default relies on the global `fetch` function, but an optional function
* can be passed in. If passing in a function, it is expected to match the Web
* Fetch API. As an example, this could be the function provided by the
* node-fetch package (https://github.com/node-fetch/node-fetch).
*/
class FetchHttpClient extends HttpClient_js_1.HttpClient {
constructor(fetchFn) {
super();
this._fetchFn = fetchFn;
}
/** @override. */
getClientName() {
return 'fetch';
}
makeRequest(host, port, path, method, headers, requestData, protocol, timeout) {
const isInsecureConnection = protocol === 'http';
const url = new URL(path, `${isInsecureConnection ? 'http' : 'https'}://${host}`);
url.port = port;
// For methods which expect payloads, we should always pass a body value
// even when it is empty. Without this, some JS runtimes (eg. Deno) will
// inject a second Content-Length header. See https://github.com/stripe/stripe-node/issues/1519
// for more details.
const methodHasPayload = method == 'POST' || method == 'PUT' || method == 'PATCH';
const body = requestData || (methodHasPayload ? '' : undefined);
const fetchFn = this._fetchFn || fetch;
const fetchPromise = fetchFn(url.toString(), {
method,
// @ts-ignore
headers,
// @ts-ignore
body,
});
// The Fetch API does not support passing in a timeout natively, so a
// timeout promise is constructed to race against the fetch and preempt the
// request, simulating a timeout.
//
// This timeout behavior differs from Node:
// - Fetch uses a single timeout for the entire length of the request.
// - Node is more fine-grained and resets the timeout after each stage of
// the request.
//
// As an example, if the timeout is set to 30s and the connection takes 20s
// to be established followed by 20s for the body, Fetch would timeout but
// Node would not. The more fine-grained timeout cannot be implemented with
// fetch.
let pendingTimeoutId;
const timeoutPromise = new Promise((_, reject) => {
pendingTimeoutId = setTimeout(() => {
pendingTimeoutId = null;
reject(HttpClient_js_1.HttpClient.makeTimeoutError());
}, timeout);
});
return Promise.race([fetchPromise, timeoutPromise])
.then((res) => {
return new FetchHttpClientResponse(res);
})
.finally(() => {
if (pendingTimeoutId) {
clearTimeout(pendingTimeoutId);
}
});
}
}
exports.FetchHttpClient = FetchHttpClient;
class FetchHttpClientResponse extends HttpClient_js_1.HttpClientResponse {
constructor(res) {
super(res.status, FetchHttpClientResponse._transformHeadersToObject(res.headers));
this._res = res;
}
getRawResponse() {
return this._res;
}
toStream(streamCompleteCallback) {
// Unfortunately `fetch` does not have event handlers for when the stream is
// completely read. We therefore invoke the streamCompleteCallback right
// away. This callback emits a response event with metadata and completes
// metrics, so it's ok to do this without waiting for the stream to be
// completely read.
streamCompleteCallback();
// Fetch's `body` property is expected to be a readable stream of the body.
return this._res.body;
}
toJSON() {
return this._res.json();
}
static _transformHeadersToObject(headers) {
// Fetch uses a Headers instance so this must be converted to a barebones
// JS object to meet the HttpClient interface.
const headersObj = {};
for (const entry of headers) {
if (!Array.isArray(entry) || entry.length != 2) {
throw new Error('Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.');
}
headersObj[entry[0]] = entry[1];
}
return headersObj;
}
}
exports.FetchHttpClientResponse = FetchHttpClientResponse;
+53
View File
@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpClientResponse = exports.HttpClient = void 0;
/**
* Encapsulates the logic for issuing a request to the Stripe API.
*
* A custom HTTP client should should implement:
* 1. A response class which extends HttpClientResponse and wraps around their
* own internal representation of a response.
* 2. A client class which extends HttpClient and implements all methods,
* returning their own response class when making requests.
*/
class HttpClient {
/** The client name used for diagnostics. */
getClientName() {
throw new Error('getClientName not implemented.');
}
makeRequest(host, port, path, method, headers, requestData, protocol, timeout) {
throw new Error('makeRequest not implemented.');
}
/** Helper to make a consistent timeout error across implementations. */
static makeTimeoutError() {
const timeoutErr = new TypeError(HttpClient.TIMEOUT_ERROR_CODE);
timeoutErr.code = HttpClient.TIMEOUT_ERROR_CODE;
return timeoutErr;
}
}
exports.HttpClient = HttpClient;
// Public API accessible via Stripe.HttpClient
HttpClient.CONNECTION_CLOSED_ERROR_CODES = ['ECONNRESET', 'EPIPE'];
HttpClient.TIMEOUT_ERROR_CODE = 'ETIMEDOUT';
class HttpClientResponse {
constructor(statusCode, headers) {
this._statusCode = statusCode;
this._headers = headers;
}
getStatusCode() {
return this._statusCode;
}
getHeaders() {
return this._headers;
}
getRawResponse() {
throw new Error('getRawResponse not implemented.');
}
toStream(streamCompleteCallback) {
throw new Error('toStream not implemented.');
}
toJSON() {
throw new Error('toJSON not implemented.');
}
}
exports.HttpClientResponse = HttpClientResponse;
+108
View File
@@ -0,0 +1,108 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeHttpClientResponse = exports.NodeHttpClient = void 0;
const http_ = require("http");
const https_ = require("https");
const HttpClient_js_1 = require("./HttpClient.js");
// `import * as http_ from 'http'` creates a "Module Namespace Exotic Object"
// which is immune to monkey-patching, whereas http_.default (in an ES Module context)
// will resolve to the same thing as require('http'), which is
// monkey-patchable. We care about this because users in their test
// suites might be using a library like "nock" which relies on the ability
// to monkey-patch and intercept calls to http.request.
const http = http_.default || http_;
const https = https_.default || https_;
const defaultHttpAgent = new http.Agent({ keepAlive: true });
const defaultHttpsAgent = new https.Agent({ keepAlive: true });
/**
* HTTP client which uses the Node `http` and `https` packages to issue
* requests.`
*/
class NodeHttpClient extends HttpClient_js_1.HttpClient {
constructor(agent) {
super();
this._agent = agent;
}
/** @override. */
getClientName() {
return 'node';
}
makeRequest(host, port, path, method, headers, requestData, protocol, timeout) {
const isInsecureConnection = protocol === 'http';
let agent = this._agent;
if (!agent) {
agent = isInsecureConnection ? defaultHttpAgent : defaultHttpsAgent;
}
const requestPromise = new Promise((resolve, reject) => {
const req = (isInsecureConnection ? http : https).request({
host: host,
port: port,
path,
method,
agent,
headers,
ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5',
});
req.setTimeout(timeout, () => {
req.destroy(HttpClient_js_1.HttpClient.makeTimeoutError());
});
req.on('response', (res) => {
resolve(new NodeHttpClientResponse(res));
});
req.on('error', (error) => {
reject(error);
});
req.once('socket', (socket) => {
if (socket.connecting) {
socket.once(isInsecureConnection ? 'connect' : 'secureConnect', () => {
// Send payload; we're safe:
req.write(requestData);
req.end();
});
}
else {
// we're already connected
req.write(requestData);
req.end();
}
});
});
return requestPromise;
}
}
exports.NodeHttpClient = NodeHttpClient;
class NodeHttpClientResponse extends HttpClient_js_1.HttpClientResponse {
constructor(res) {
// @ts-ignore
super(res.statusCode, res.headers || {});
this._res = res;
}
getRawResponse() {
return this._res;
}
toStream(streamCompleteCallback) {
// The raw response is itself the stream, so we just return that. To be
// backwards compatible, we should invoke the streamCompleteCallback only
// once the stream has been fully consumed.
this._res.once('end', () => streamCompleteCallback());
return this._res;
}
toJSON() {
return new Promise((resolve, reject) => {
let response = '';
this._res.setEncoding('utf8');
this._res.on('data', (chunk) => {
response += chunk;
});
this._res.once('end', () => {
try {
resolve(JSON.parse(response));
}
catch (e) {
reject(e);
}
});
});
}
}
exports.NodeHttpClientResponse = NodeHttpClientResponse;