Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: move shared app into main app

Brad Barbindc7bb1752ed0
diff --git a/.env.example b/.env.example
index e6a12fddaa..b2aaf7ca18 100644
--- a/.env.example
+++ b/.env.example
@@ -1,8 +1,17 @@
-GLOABL_SUPABASE_API_URL="http://localhost:54321"
-GLOBAL_SUPABASE_API_KEY="************"
+EXCHANGE_RATES_API_KEY="****************"
+EXCHANGE_RATES_API_URL=http://api.exchangeratesapi.io/v1/latest
+
REDIS_URL="redis://localhost:6389"
-SESSION_SECRET="super-duper-s3cret"
-SUPABASE_ANON_PUBLIC="************"
-SUPABASE_SERVICE_ROLE="***********"
+
+SESSION_SECRET="************************"
+
+SUPABASE_ANON_PUBLIC="******************"
+SUPABASE_SERVICE_ROLE="*****************"
SUPABASE_API_URL="http://localhost:54321"
-VERCEL_URL="http://localhost:3600"
\ No newline at end of file
+
+TRIGGER_ID="****************************"
+TRIGGER_API_KEY="***********************"
+TRIGGER_API_URL="https://api.trigger.dev"
+TRIGGER_PUBLIC_API_KEY="pk_*************"
+
+VERCEL_URL="http://localhost:3000"
\ No newline at end of file
diff --git a/README.md b/README.md
index 098d2e84fe..de976ef7c3 100644
--- a/README.md
+++ b/README.md
@@ -58,13 +58,6 @@ The monorepo follows the Turborepo covention of grouping packages into one of tw
| `@carbon/tsconfig` | Shared, extendable tsconfig configuration used across apps and packages |
| `@carbon/utils` | Shared utility functions used across apps and packages |
-There are two other top-level folders worth mentioning:
-
-| Package Name | Description | Local Command |
-| ------------ | ---------------------------------------------------- | -------------------- |
-| `shared` | A shared API for things like currency exchange rates | `npm run dev:shared` |
-| `www` | The documentation site | `npm run dev:www` |
-
## Local Development
Make sure that you have [Docker installed](https://docs.docker.com/desktop/install/mac-install/) on your system since this monorepo uses the Docker for local development.
@@ -73,7 +66,8 @@ After running the steps below you should be able to access the following apps/co
| Application | URL |
| --------------- | ------------------------------------------------------------------------------------------------------------------ |
-| Carbon ERP | [http://localhost:3600](http://localhost:3600) |
+| Carbon ERP | [http://localhost:3000](http://localhost:3000) |
+| Shared Workers | [http://localhost:3000](http://localhost:3000) |
| Postgres | [postgresql://postgres:postgres@localhost:54322/postgres](postgresql://postgres:postgres@localhost:54322/postgres) |
| Supabase Studio | [http://localhost:54323/project/default](http://localhost:54323/project/default) |
| Inbucket | [http://localhost:54324/monitor](http://localhost:54324/monitor) |
diff --git a/apps/carbon/app/jobs/get-exchange-rates.server.ts b/apps/carbon/app/jobs/get-exchange-rates.server.ts
new file mode 100644
index 0000000000..ed8976599d
--- /dev/null
+++ b/apps/carbon/app/jobs/get-exchange-rates.server.ts
@@ -0,0 +1,41 @@
+import { intervalTrigger } from "@trigger.dev/sdk";
+import { exchangeRatesClient } from "~/lib/exchange-rates.server";
+import { getSupabaseServiceRole } from "~/lib/supabase";
+import { triggerClient } from "~/lib/trigger.server";
+
+const supabaseClient = getSupabaseServiceRole();
+
+export const job = triggerClient.defineJob({
+ id: "get-exchange-rates",
+ name: "Update Currency Exchange Rates",
+ version: "0.0.2",
+ trigger: intervalTrigger({
+ seconds: 60 * 60 * 8, // thrice a day
+ }),
+ run: async (payload, io, ctx) => {
+ await io.logger.info(`💵 Exchange Rates Job: ${payload.lastTimestamp}`);
+ await io.logger.info(JSON.stringify(exchangeRatesClient.getMetaData()));
+
+ try {
+ const rates = await exchangeRatesClient.getExchangeRates();
+ await io.logger.info(JSON.stringify(rates));
+ const { error } = await supabaseClient
+ .from("currencyExchangeRate")
+ .insert(
+ Object.entries(rates).map(([currency, exchangeRate]) => ({
+ currency,
+ exchangeRate,
+ }))
+ );
+ if (error) {
+ await io.logger.error(JSON.stringify(error));
+ return;
+ }
+
+ io.logger.log("Success");
+ } catch (err) {
+ // TODO: notify SRE
+ await io.logger.error(JSON.stringify(err));
+ }
+ },
+});
diff --git a/apps/carbon/app/lib/exchange-rates.server.ts b/apps/carbon/app/lib/exchange-rates.server.ts
new file mode 100644
index 0000000000..f90752ed3c
--- /dev/null
+++ b/apps/carbon/app/lib/exchange-rates.server.ts
@@ -0,0 +1,86 @@
+import axios from "axios";
+import type { CurrencyCode } from "~/modules/accounting";
+
+type ExchangeClientOptions = {
+ apiKey?: string;
+ apiUrl?: string;
+ baseCurrency: CurrencyCode;
+};
+
+type Rates = { [key in CurrencyCode]?: number };
+
+type ExchangeRatesSuccessResponse = {
+ success: boolean;
+ timestamp: number;
+ base: CurrencyCode;
+ date: string;
+ rates: Rates;
+};
+
+type ExchangeRatesErrorResponse = {
+ error: {
+ code: string;
+ message: string;
+ };
+};
+
+type ExchangeRatesResponse =
+ | ExchangeRatesErrorResponse
+ | ExchangeRatesSuccessResponse;
+
+export class ExchangeRatesClient {
+ #apiKey: string;
+ #apiUrl: string;
+ #baseCurrency: CurrencyCode;
+
+ constructor(options: ExchangeClientOptions) {
+ if (!options.apiKey) throw new Error("EXCHANGE_RATES_API_KEY not set");
+ if (!options.apiUrl) throw new Error("EXCHANGE_RATES_API_URL not set");
+ this.#apiKey = options.apiKey;
+ this.#apiUrl = options.apiUrl;
+ this.#baseCurrency = options.baseCurrency ?? "USD";
+ }
+
+ getMetaData() {
+ return {
+ apiUrl: this.#apiUrl,
+ baseCurrency: this.#baseCurrency,
+ };
+ }
+
+ async getExchangeRates(base?: CurrencyCode): Promise<Rates> {
+ const { data } = await axios.get<ExchangeRatesResponse>(
+ `${this.#apiUrl}?access_key=${this.#apiKey}`
+ );
+
+ if ("success" in data && data.success === true) {
+ const baseRate = data.rates[base ?? this.#baseCurrency];
+ if (!baseRate) throw new Error("Base rate not found in response");
+
+ const convertedRates = Object.entries(data.rates).reduce<Rates>(
+ (acc, [currency, value]) => {
+ return {
+ ...acc,
+ [currency]: value / baseRate,
+ };
+ },
+ {
+ [data.base]: 1,
+ }
+ );
+
+ return convertedRates;
+ }
+
+ throw new Error("Unrecognized response from exchange rates server");
+ }
+}
+
+const apiKey = process.env.EXCHANGE_RATES_API_KEY;
+const apiUrl = process.env.EXCHANGE_RATES_API_URL;
+
+export const exchangeRatesClient = new ExchangeRatesClient({
+ apiKey,
+ apiUrl,
+ baseCurrency: "USD",
+});
diff --git a/apps/carbon/app/lib/trigger.server.ts b/apps/carbon/app/lib/trigger.server.ts
new file mode 100644
index 0000000000..87518f1b59
--- /dev/null
+++ b/apps/carbon/app/lib/trigger.server.ts
@@ -0,0 +1,7 @@
+import { TriggerClient } from "@trigger.dev/sdk";
+
+export const triggerClient = new TriggerClient({
+ id: "carbon-erp-wzkF",
+ apiKey: process.env.TRIGGER_API_KEY,
+ apiUrl: process.env.TRIGGER_API_URL,
+});
diff --git a/apps/carbon/app/modules/accounting/types.ts b/apps/carbon/app/modules/accounting/types.ts
index e55cf0c577..41736d9859 100644
--- a/apps/carbon/app/modules/accounting/types.ts
+++ b/apps/carbon/app/modules/accounting/types.ts
@@ -47,6 +47,317 @@ export type Currency = NonNullable<
Awaited<ReturnType<typeof getCurrencies>>["data"]
>[number];
+export const currencyCodes = [
+ "AFN",
+ "AFA",
+ "ALL",
+ "ALK",
+ "DZD",
+ "ADP",
+ "AOA",
+ "AOK",
+ "AON",
+ "AOR",
+ "ARA",
+ "ARS",
+ "ARM",
+ "ARP",
+ "ARL",
+ "AMD",
+ "AWG",
+ "AUD",
+ "ATS",
+ "AZN",
+ "AZM",
+ "BSD",
+ "BHD",
+ "BDT",
+ "BBD",
+ "BYN",
+ "BYB",
+ "BYR",
+ "BEF",
+ "BEC",
+ "BEL",
+ "BZD",
+ "BMD",
+ "BTN",
+ "BOB",
+ "BOL",
+ "BOV",
+ "BOP",
+ "BAM",
+ "BAD",
+ "BAN",
+ "BWP",
+ "BRC",
+ "BRZ",
+ "BRE",
+ "BRR",
+ "BRN",
+ "BRB",
+ "BRL",
+ "GBP",
+ "BND",
+ "BGL",
+ "BGN",
+ "BGO",
+ "BGM",
+ "BUK",
+ "BIF",
+ "XPF",
+ "KHR",
+ "CAD",
+ "CVE",
+ "KYD",
+ "XAF",
+ "CLE",
+ "CLP",
+ "CLF",
+ "CNX",
+ "CNY",
+ "CNH",
+ "COP",
+ "COU",
+ "KMF",
+ "CDF",
+ "CRC",
+ "HRD",
+ "HRK",
+ "CUC",
+ "CUP",
+ "CYP",
+ "CZK",
+ "CSK",
+ "DKK",
+ "DJF",
+ "DOP",
+ "NLG",
+ "XCD",
+ "DDM",
+ "ECS",
+ "ECV",
+ "EGP",
+ "GQE",
+ "ERN",
+ "EEK",
+ "ETB",
+ "EUR",
+ "XBA",
+ "XEU",
+ "XBB",
+ "XBC",
+ "XBD",
+ "FKP",
+ "FJD",
+ "FIM",
+ "FRF",
+ "XFO",
+ "XFU",
+ "GMD",
+ "GEK",
+ "GEL",
+ "DEM",
+ "GHS",
+ "GHC",
+ "GIP",
+ "XAU",
+ "GRD",
+ "GTQ",
+ "GWP",
+ "GNF",
+ "GNS",
+ "GYD",
+ "HTG",
+ "HNL",
+ "HKD",
+ "HUF",
+ "IMP",
+ "ISK",
+ "ISJ",
+ "INR",
+ "IDR",
+ "IRR",
+ "IQD",
+ "IEP",
+ "ILS",
+ "ILP",
+ "ILR",
+ "ITL",
+ "JMD",
+ "JPY",
+ "JOD",
+ "KZT",
+ "KES",
+ "KWD",
+ "KGS",
+ "LAK",
+ "LVL",
+ "LVR",
+ "LBP",
+ "LSL",
+ "LRD",
+ "LYD",
+ "LTL",
+ "LTT",
+ "LUL",
+ "LUC",
+ "LUF",
+ "MOP",
+ "MKD",
+ "MKN",
+ "MGA",
+ "MGF",
+ "MWK",
+ "MYR",
+ "MVR",
+ "MVP",
+ "MLF",
+ "MTL",
+ "MTP",
+ "MRU",
+ "MRO",
+ "MUR",
+ "MXV",
+ "MXN",
+ "MXP",
+ "MDC",
+ "MDL",
+ "MCF",
+ "MNT",
+ "MAD",
+ "MAF",
+ "MZE",
+ "MZN",
+ "MZM",
+ "MMK",
+ "NAD",
+ "NPR",
+ "ANG",
+ "TWD",
+ "NZD",
+ "NIO",
+ "NIC",
+ "NGN",
+ "KPW",
+ "NOK",
+ "OMR",
+ "PKR",
+ "XPD",
+ "PAB",
+ "PGK",
+ "PYG",
+ "PEI",
+ "PEN",
+ "PES",
+ "PHP",
+ "XPT",
+ "PLN",
+ "PLZ",
+ "PTE",
+ "GWE",
+ "QAR",
+ "XRE",
+ "RHD",
+ "RON",
+ "ROL",
+ "RUB",
+ "RUR",
+ "RWF",
+ "SVC",
+ "WST",
+ "SAR",
+ "RSD",
+ "CSD",
+ "SCR",
+ "SLL",
+ "XAG",
+ "SGD",
+ "SKK",
+ "SIT",
+ "SBD",
+ "SOS",
+ "ZAR",
+ "ZAL",
+ "KRH",
+ "KRW",
+ "KRO",
+ "SSP",
+ "SUR",
+ "ESP",
+ "ESA",
+ "ESB",
+ "XDR",
+ "LKR",
+ "SHP",
+ "XSU",
+ "SDD",
+ "SDG",
+ "SDP",
+ "SRD",
+ "SRG",
+ "SZL",
+ "SEK",
+ "CHF",
+ "SYP",
+ "STN",
+ "STD",
+ "TVD",
+ "TJR",
+ "TJS",
+ "TZS",
+ "XTS",
+ "THB",
+ "XXX",
+ "TPE",
+ "TOP",
+ "TTD",
+ "TND",
+ "TRY",
+ "TRL",
+ "TMT",
+ "TMM",
+ "USD",
+ "USN",
+ "USS",
+ "UGX",
+ "UGS",
+ "UAH",
+ "UAK",
+ "AED",
+ "UYW",
+ "UYU",
+ "UYP",
+ "UYI",
+ "UZS",
+ "VUV",
+ "VES",
+ "VEB",
+ "VEF",
+ "VND",
+ "VNN",
+ "CHE",
+ "CHW",
+ "XOF",
+ "YDD",
+ "YER",
+ "YUN",
+ "YUD",
+ "YUM",
+ "YUR",
+ "ZWN",
+ "ZRN",
+ "ZRZ",
+ "ZMW",
+ "ZMK",
+ "ZWD",
+ "ZWR",
+ "ZWL",
+ "XUA",
+] as const;
+
+export type CurrencyCode = (typeof currencyCodes)[number];
+
export type InventoryPostingGroup = NonNullable<
Awaited<ReturnType<typeof getInventoryPostingGroups>>["data"]
>[number];
diff --git a/apps/carbon/app/routes/api+/trigger.ts b/apps/carbon/app/routes/api+/trigger.ts
new file mode 100644
index 0000000000..10ca10568f
--- /dev/null
+++ b/apps/carbon/app/routes/api+/trigger.ts
@@ -0,0 +1,8 @@
+import { createRemixRoute } from "@trigger.dev/remix";
+import { triggerClient } from "~/lib/trigger.server";
+
+// Remix will automatically strip files with side effects
+// So you need to *export* your Job definitions like this:
+export * from "~/jobs/get-exchange-rates.server";
+
+export const { action } = createRemixRoute(triggerClient);
diff --git a/apps/carbon/app/services/auth/auth.server.ts b/apps/carbon/app/services/auth/auth.server.ts
index 833adfb563..b87f879d76 100644
--- a/apps/carbon/app/services/auth/auth.server.ts
+++ b/apps/carbon/app/services/auth/auth.server.ts
@@ -68,7 +68,7 @@ function makeAuthSession(
userId: supabaseSession.user.id,
email: supabaseSession.user.email,
expiresIn:
- (supabaseSession.expires_in ?? 3600) - REFRESH_ACCESS_TOKEN_THRESHOLD,
+ (supabaseSession.expires_in ?? 3000) - REFRESH_ACCESS_TOKEN_THRESHOLD,
expiresAt: supabaseSession.expires_at ?? -1,
};
}
diff --git a/apps/carbon/package.json b/apps/carbon/package.json
index 0d8de15e02..d430d5fbbc 100644
--- a/apps/carbon/package.json
+++ b/apps/carbon/package.json
@@ -5,8 +5,9 @@
"sideEffects": false,
"scripts": {
"build": "remix build",
- "dev": "PORT=3600 run-p dev:*",
- "dev:remix": "remix dev",
+ "dev": "run-p dev:remix dev:trigger",
+ "dev:remix": "PORT=3000 remix dev",
+ "dev:trigger": "sleep 15 && npx @trigger.dev/cli@latest dev",
"start": "remix-serve ./build/index.js",
"clean": "rimraf .cache .turbo node_modules dist build",
"lint": "TIMING=1 eslint \"app/**/*.ts*\"",
@@ -36,6 +37,9 @@
"@tailwindcss/line-clamp": "^0.4.4",
"@tailwindcss/typography": "^0.5.10",
"@tanstack/react-table": "^8.9.3",
+ "@trigger.dev/react": "^2.3.15",
+ "@trigger.dev/remix": "^2.3.15",
+ "@trigger.dev/sdk": "^2.3.15",
"@visx/axis": "3.3.0",
"@visx/curve": "3.3.0",
"@visx/drag": "3.3.0",
@@ -46,6 +50,7 @@
"@visx/responsive": "3.3.0",
"@visx/scale": "3.3.0",
"@visx/shape": "3.3.0",
+ "axios": "^1.6.5",
"bullmq": "^4.6.2",
"clsx": "^2.0.0",
"d3-array": "^3.2.4",
@@ -84,6 +89,9 @@
"tailwindcss": "3.3.2",
"typescript": "^5.2.2"
},
+ "trigger.dev": {
+ "endpointId": "carbon-erp-wzkF"
+ },
"engines": {
"node": ">=18"
}
diff --git a/package-lock.json b/package-lock.json
index 8824c8c144..7e932a4011 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -52,6 +52,9 @@
"@tailwindcss/line-clamp": "^0.4.4",
"@tailwindcss/typography": "^0.5.10",
"@tanstack/react-table": "^8.9.3",
+ "@trigger.dev/react": "^2.3.15",
+ "@trigger.dev/remix": "^2.3.15",
+ "@trigger.dev/sdk": "^2.3.15",
"@vercel/analytics": "^1.0.2",
"@vercel/remix": "2.2.0",
"@visx/axis": "3.3.0",
@@ -64,6 +67,7 @@
"@visx/responsive": "3.3.0",
"@visx/scale": "3.3.0",
"@visx/shape": "3.3.0",
+ "axios": "^1.6.5",
"bullmq": "^4.6.2",
"clsx": "^2.0.0",
"d3-array": "^3.2.4",
@@ -1224,7 +1228,6 @@
"os": [
"android"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1240,7 +1243,6 @@
"os": [
"android"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1256,7 +1258,6 @@
"os": [
"android"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1272,7 +1273,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1288,7 +1288,6 @@
"os": [
"darwin"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1304,7 +1303,6 @@
"os": [
"freebsd"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1320,7 +1318,6 @@
"os": [
"freebsd"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1336,7 +1333,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1352,7 +1348,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1368,7 +1363,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1384,7 +1378,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1400,7 +1393,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1416,7 +1408,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1432,7 +1423,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1448,7 +1438,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1464,7 +1453,6 @@
"os": [
"linux"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1480,7 +1468,6 @@
"os": [
"netbsd"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1496,7 +1483,6 @@
"os": [
"openbsd"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1512,7 +1498,6 @@
"os": [
"sunos"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1528,7 +1513,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1544,7 +1528,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -1560,7 +1543,6 @@
"os": [
"win32"
],
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -7547,11 +7529,11 @@
}
},
"node_modules/@trigger.dev/core": {
- "version": "2.2.4",
- "resolved": "https://registry.npmjs.org/@trigger.dev/core/-/core-2.2.4.tgz",
- "integrity": "sha512-WO4w0HeJYwrloyTL6Y8apOqyRlsYFa5ihBEkNjyI+QDlvOQxO/DbppYuW3iMpU2xmyO0T6zdV7yf7UEJP6boDA==",
+ "version": "2.3.15",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/core/-/core-2.3.15.tgz",
+ "integrity": "sha512-BoiGwJb6QYzReWOwZtLP7Cxg1ShdHhnUxclzhTBqN1fwiHLrAl/SqbLsLw7mRP663xlBI+4ses6DJFHdoxc98Q==",
"dependencies": {
- "ulid": "^2.3.0",
+ "ulidx": "^2.2.1",
"zod": "3.22.3",
"zod-error": "1.5.0"
},
@@ -7560,9 +7542,9 @@
}
},
"node_modules/@trigger.dev/core-backend": {
- "version": "2.2.4",
- "resolved": "https://registry.npmjs.org/@trigger.dev/core-backend/-/core-backend-2.2.4.tgz",
- "integrity": "sha512-C+CtJjKuuE+KRZHt8FzmI3rno8iUU4Tkd0m67/bhOBAVDWbSXkv+/yHdd6ANMrWgdX8NjGlIlQgsgOFB0IeGyA==",
+ "version": "2.3.15",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/core-backend/-/core-backend-2.3.15.tgz",
+ "integrity": "sha512-MyX9SfG5WGLw4x0mdzr/zhW9Bzm5gsGWXPMBxVrVZfsyExzeBCW8qVsRhauPqxSr6bsfWCnnvBY3iOKaPRXyPw==",
"engines": {
"node": ">=18.0.0"
}
@@ -7576,12 +7558,12 @@
}
},
"node_modules/@trigger.dev/react": {
- "version": "2.2.4",
- "resolved": "https://registry.npmjs.org/@trigger.dev/react/-/react-2.2.4.tgz",
- "integrity": "sha512-BXl7c/DqGKgUQ6MxdUrZzm04xnpq2zStmhqMspyFPZ66ZbjERha1fd7sz7aOskQdRioSMRdM1Birufaaak0C3w==",
+ "version": "2.3.15",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/react/-/react-2.3.15.tgz",
+ "integrity": "sha512-4WGDSGjr8DlJW0REvYCmyXifC1tlb5e/sjKjurjScm+2zNO4bNnHqzozANJfs6TzqO3mbrjBrpISAeN1MW8vzA==",
"dependencies": {
"@tanstack/react-query": "5.0.0-beta.2",
- "@trigger.dev/core": "^2.2.4",
+ "@trigger.dev/core": "^2.3.15",
"debug": "^4.3.4",
"zod": "3.22.3"
},
@@ -7598,9 +7580,9 @@
}
},
"node_modules/@trigger.dev/remix": {
- "version": "2.2.4",
- "resolved": "https://registry.npmjs.org/@trigger.dev/remix/-/remix-2.2.4.tgz",
- "integrity": "sha512-V6NcrZLU+SZ2ppORGw+8+IATNE0VKq7pnxRtclsAZdSd6kYhNCv0M02IQI+aVie+d/ACQbq0UTDA+ClwuUWOSA==",
+ "version": "2.3.15",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/remix/-/remix-2.3.15.tgz",
+ "integrity": "sha512-RNngiNCB80iF7d+OriUXdAPreuhIIiJNLq9vl0rfWgt75v2P4tlZKdbF6xp2e57/Eda91OjXf/FJ5qZJxSR2lQ==",
"dependencies": {
"debug": "^4.3.4"
},
@@ -7609,16 +7591,16 @@
},
"peerDependencies": {
"@remix-run/server-runtime": ">1.19.0",
- "@trigger.dev/sdk": "^2.2.4"
+ "@trigger.dev/sdk": "^2.3.15"
}
},
"node_modules/@trigger.dev/sdk": {
- "version": "2.2.4",
- "resolved": "https://registry.npmjs.org/@trigger.dev/sdk/-/sdk-2.2.4.tgz",
- "integrity": "sha512-Q0iUNLD//pCpMXnAScjQjFvLzQhNvWAjJ4y73v8dv1oLCoNyM9IreI/b4A92gr1LIlwC8hayKosgR/wP6G6lLQ==",
+ "version": "2.3.15",
+ "resolved": "https://registry.npmjs.org/@trigger.dev/sdk/-/sdk-2.3.15.tgz",
+ "integrity": "sha512-6ICeF5GYZ1CeqyaFurqUnYxmKgrq1eXeRaceOEhpgeNWhNArE0eGzGsv+c064lkCpqEQ2XphFLAEnp2NgQgZFw==",
"dependencies": {
- "@trigger.dev/core": "^2.2.4",
- "@trigger.dev/core-backend": "^2.2.4",
+ "@trigger.dev/core": "^2.3.15",
+ "@trigger.dev/core-backend": "^2.3.15",
"chalk": "^5.2.0",
"cronstrue": "^2.21.0",
"debug": "^4.3.4",
@@ -17496,6 +17478,11 @@
"node": ">=0.10"
}
},
+ "node_modules/layerr": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/layerr/-/layerr-2.0.1.tgz",
+ "integrity": "sha512-z0730CwG/JO24evdORnyDkwG1Q7b7mF2Tp1qRQ0YvrMMARbt1DFG694SOv439Gm7hYKolyZyaB49YIrYIfZBdg=="
+ },
"node_modules/layout-base": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/layout-base/-/layout-base-1.0.2.tgz",
@@ -23668,10 +23655,6 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
},
- "node_modules/shared": {
- "resolved": "shared",
- "link": true
- },
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
@@ -26104,6 +26087,17 @@
"ulid": "bin/cli.js"
}
},
+ "node_modules/ulidx": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/ulidx/-/ulidx-2.2.1.tgz",
+ "integrity": "sha512-DU9F5t1tihdafuNyW3fIrXUFHHiHxmwuQSGVGIbSpqkc93IH4P0dU8nPhk0gOW7ARxaFu4+P/9cxVwn6PdnIaQ==",
+ "dependencies": {
+ "layerr": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=16"
+ }
+ },
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@@ -28525,6 +28519,7 @@
}
},
"shared": {
+ "extraneous": true,
"license": "Apache-2.0",
"dependencies": {
"@carbon/logger": "*",
diff --git a/packages/database/SCHEMA.md b/packages/database/SCHEMA.md
index 2ddc82f2c7..f8af0668d4 100644
--- a/packages/database/SCHEMA.md
+++ b/packages/database/SCHEMA.md
@@ -1,4 +1,6 @@
-# Carbon Database Schema by `scripts/generate-schema-md.ts` using the migrations in `packages/database/supabase/migrations`.
+# Carbon Database Schema
+
+This file is generated by `scripts/generate-schema-md.ts` using the migrations in `packages/database/supabase/migrations`.
@@ -7396,3 +7398,24 @@ CREATE OR REPLACE VIEW "employeeSummary" WITH(SECURITY_INVOKER=true) AS
ON d.id = ej."departmentId";
```
+
+
+## `currency-exchange-rates`
+
+```sql
+CREATE TABLE "currencyExchangeRate" (
+ "id" SERIAL PRIMARY KEY,
+ "currency" TEXT NOT NULL,
+ "exchangeRate" NUMERIC NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
+);
+
+CREATE INDEX "currencyExchangeRate_currency_index" ON "currencyExchangeRate" ("currency");
+CREATE INDEX "currencyExchangeRate_createdAt_index" ON "currencyExchangeRate" ("createdAt");
+
+ALTER TABLE "currencyExchangeRate" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Authenticated users can read currencyExchangeRate" ON "currencyExchangeRate"
+ FOR SELECT USING (auth.role() = 'authenticated');
+```
+
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index d0597510f7..93d96ec475 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -1665,6 +1665,27 @@ export interface Database {
}
];
};
+ currencyExchangeRate: {
+ Row: {
+ createdAt: string;
+ currency: string;
+ exchangeRate: number;
+ id: number;
+ };
+ Insert: {
+ createdAt?: string;
+ currency: string;
+ exchangeRate: number;
+ id?: number;
+ };
+ Update: {
+ createdAt?: string;
+ currency?: string;
+ exchangeRate?: number;
+ id?: number;
+ };
+ Relationships: [];
+ };
customer: {
Row: {
accountManagerId: string | null;
diff --git a/packages/database/supabase/config.toml b/packages/database/supabase/config.toml
index 84d828210d..d1d84e77b1 100644
--- a/packages/database/supabase/config.toml
+++ b/packages/database/supabase/config.toml
@@ -67,11 +67,11 @@ file_size_limit = "50MiB"
enabled = true
# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
# in emails.
-site_url = "http://localhost:3600"
+site_url = "http://localhost:3000"
# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
-additional_redirect_urls = ["https://localhost:3600"]
-# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week).
-jwt_expiry = 3600
+additional_redirect_urls = ["https://localhost:3000"]
+# How long tokens are valid for, in seconds. Defaults to 3000 (1 hour), maximum 604,800 (1 week).
+jwt_expiry = 3000
# If disabled, the refresh token will never expire.
enable_refresh_token_rotation = true
# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds.
diff --git a/packages/database/supabase/migrations/20240118035549_currency-exchange-rates.sql b/packages/database/supabase/migrations/20240118035549_currency-exchange-rates.sql
new file mode 100644
index 0000000000..15492d9bfa
--- /dev/null
+++ b/packages/database/supabase/migrations/20240118035549_currency-exchange-rates.sql
@@ -0,0 +1,14 @@
+CREATE TABLE "currencyExchangeRate" (
+ "id" SERIAL PRIMARY KEY,
+ "currency" TEXT NOT NULL,
+ "exchangeRate" NUMERIC NOT NULL,
+ "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
+);
+
+CREATE INDEX "currencyExchangeRate_currency_index" ON "currencyExchangeRate" ("currency");
+CREATE INDEX "currencyExchangeRate_createdAt_index" ON "currencyExchangeRate" ("createdAt");
+
+ALTER TABLE "currencyExchangeRate" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Authenticated users can read currencyExchangeRate" ON "currencyExchangeRate"
+ FOR SELECT USING (auth.role() = 'authenticated');
\ No newline at end of file
diff --git a/www/pages/develop/getting-started.mdx b/www/pages/develop/getting-started.mdx
index 4089f15d2a..7dabf87826 100644
--- a/www/pages/develop/getting-started.mdx
+++ b/www/pages/develop/getting-started.mdx
@@ -13,7 +13,7 @@ After running the steps below you should be able to access the following apps/co
| Application | URL |
| --------------- | ------------------------------------------------------------------------------------------------------------------ |
-| Carbon ERP | [http://localhost:3600](http://localhost:3600) |
+| Carbon ERP | [http://localhost:3000](http://localhost:3000) |
| Postgres | [postgresql://postgres:postgres@localhost:54322/postgres](postgresql://postgres:postgres@localhost:54322/postgres) |
| Supabase Studio | [http://localhost:54323/project/default](http://localhost:54323/project/default) |
| Inbucket | [http://localhost:54324/monitor](http://localhost:54324/monitor) |