Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

ralph(M11-006): Dissolve into core per the map: definitions move to modules/<m>/<m>.constants.ts or shared/, core's own importers repointed, the four packages become pure re-export shims

ralph5aa04468eb69
diff --git a/packages/common/index.ts b/packages/common/index.ts
index dd40b81e2..da14fc507 100644
--- a/packages/common/index.ts
+++ b/packages/common/index.ts
@@ -1,13 +1,14 @@
+// P11 shim (ADR-008). Definitions live in @openpanel/core; ./src/* are
+// re-exports only. `names`, `timezones` and `try-catch` are gone — the
+// dissolution map records every symbol they held as DELETE (no importer
+// anywhere). Deleted by M11-009.
export * from './src/date';
export * from './src/get-client-ip';
export * from './src/get-previous-metric';
export * from './src/group-by-labels';
export * from './src/id';
export * from './src/math';
-export * from './src/names';
export * from './src/object';
export * from './src/slug';
export * from './src/string';
-export * from './src/timezones';
-export * from './src/try-catch';
export * from './src/url';
diff --git a/packages/common/src/date.ts b/packages/common/src/date.ts
index e82c590ae..cae059474 100644
--- a/packages/common/src/date.ts
+++ b/packages/common/src/date.ts
@@ -1,6 +1,5 @@
-// biome-ignore lint/performance/noBarrelFile: lazy
-export { DateTime } from 'luxon';
-
-export function getTime(date: string | number | Date) {
- return new Date(date).getTime();
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export { DateTime, getTime } from '../../core/src/shared/date';
diff --git a/packages/common/src/get-client-ip.ts b/packages/common/src/get-client-ip.ts
index 888debb8f..7a07646f4 100644
--- a/packages/common/src/get-client-ip.ts
+++ b/packages/common/src/get-client-ip.ts
@@ -1,157 +1,8 @@
-/**
- * Get client IP from headers
- *
- * Can be configured via IP_HEADER_ORDER env variable
- * Example: IP_HEADER_ORDER="cf-connecting-ip,x-real-ip,x-forwarded-for"
- *
- * Kept in @openpanel/common (not @openpanel/core) so SDKs that need it
- * (packages/sdks/express) don't pull in core's backend-only dependency tree
- * (argon2, bullmq, aws-sdk, …) — see AGENTS.md/CLAUDE.md: "core is not a
- * grab-bag for cross-app code". @openpanel/core carries the same function
- * (src/shared/get-client-ip.ts) for backend consumers; this is the SDK-facing
- * copy, isomorphic by construction (no imports beyond globals).
- */
-
-// Order matters: client-forwarded headers (set explicitly by SDKs/upstream
-// servers) must come before infrastructure headers like `cf-connecting-ip`.
-// Otherwise, when our API sits behind Cloudflare (orange cloud), Cloudflare
-// rewrites `cf-connecting-ip` to the SDK server's IP — losing the original
-// end-user IP that the SDK forwarded in `x-client-ip` / `openpanel-client-ip`.
-export const DEFAULT_IP_HEADER_ORDER = [
- 'openpanel-client-ip',
- 'true-client-ip',
- 'x-client-ip',
- 'cf-connecting-ip',
- 'x-forwarded-for',
- 'x-real-ip',
- 'fastly-client-ip',
- 'x-cluster-client-ip',
- 'x-appengine-user-ip',
- 'do-connecting-ip',
- 'x-nf-client-connection-ip',
- 'x-forwarded',
- 'forwarded',
-];
-
-function isPublicIp(ip: string): boolean {
- // Handle IPv4-mapped IPv6 addresses (e.g., ::ffff:127.0.0.1)
- if (ip.startsWith('::ffff:')) {
- const ipv4Part = ip.substring(7); // Extract IPv4 part after "::ffff:"
- return isPublicIp(ipv4Part); // Recursively check the IPv4 address
- }
-
- // IPv6 loopback
- if (ip === '::1') {
- return false;
- }
-
- // IPv6 private ranges (fc00::/7 and fe80::/10)
- if (
- ip.startsWith('fc00:') ||
- ip.startsWith('fd00:') ||
- ip.startsWith('fe80:')
- ) {
- return false;
- }
-
- // IPv4 loopback (127.0.0.0/8)
- if (ip.startsWith('127.')) {
- return false;
- }
-
- // IPv4 private ranges
- // 10.0.0.0/8
- if (ip.startsWith('10.')) {
- return false;
- }
- // 172.16.0.0/12 (172.16.0.0 - 172.31.255.255)
- if (ip.startsWith('172.')) {
- const parts = ip.split('.');
- if (parts.length >= 2) {
- const secondOctet = Number.parseInt(parts[1] || '0', 10);
- if (secondOctet >= 16 && secondOctet <= 31) {
- return false;
- }
- }
- }
- // 192.168.0.0/16
- if (ip.startsWith('192.168.')) {
- return false;
- }
- // 169.254.0.0/16 (link-local)
- if (ip.startsWith('169.254.')) {
- return false;
- }
-
- return true;
-}
-
-function getHeaderOrder(): string[] {
- if (typeof process !== 'undefined' && process.env?.IP_HEADER_ORDER) {
- return process.env.IP_HEADER_ORDER.split(',').map((h) => h.trim());
- }
- return DEFAULT_IP_HEADER_ORDER;
-}
-
-function isValidIp(ip: string): boolean {
- // Basic IP validation
- const ipv4 = /^(\d{1,3}\.){3}\d{1,3}$/;
- const ipv6 = /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/;
- return isPublicIp(ip) && (ipv4.test(ip) || ipv6.test(ip));
-}
-
-export function getClientIpFromHeaders(
- headers: Record<string, string | string[] | undefined> | Headers,
- overrideHeaderName?: string
-): {
- ip: string;
- header: string;
-} {
- let headerOrder = getHeaderOrder();
-
- if (overrideHeaderName) {
- headerOrder = [overrideHeaderName];
- }
-
- for (const headerName of headerOrder) {
- let value: string | null = null;
-
- // Get header value
- if (headers instanceof Headers) {
- value = headers.get(headerName);
- } else {
- const headerValue = headers[headerName];
- if (Array.isArray(headerValue)) {
- value = headerValue[0] || null;
- } else {
- value = headerValue || null;
- }
- }
-
- if (!value) {
- continue;
- }
-
- // Handle x-forwarded-for (comma separated)
- if (headerName === 'x-forwarded-for') {
- const firstIp = value.split(',')[0]?.trim();
- if (firstIp && isValidIp(firstIp)) {
- return { ip: firstIp, header: headerName };
- }
- }
- // Handle forwarded header (RFC 7239)
- else if (headerName === 'forwarded') {
- const match = value.match(/for=(?:"?\[?([^\]"]+)\]?"?)/i);
- const ip = match?.[1];
- if (ip && isValidIp(ip)) {
- return { ip, header: headerName };
- }
- }
- // Regular headers
- else if (isValidIp(value)) {
- return { ip: value, header: headerName };
- }
- }
-
- return { ip: '', header: '' };
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export {
+ DEFAULT_IP_HEADER_ORDER,
+ getClientIpFromHeaders,
+} from '../../core/src/shared/get-client-ip';
diff --git a/packages/common/src/get-previous-metric.ts b/packages/common/src/get-previous-metric.ts
index 00be60771..b0bfaf7b6 100644
--- a/packages/common/src/get-previous-metric.ts
+++ b/packages/common/src/get-previous-metric.ts
@@ -1,39 +1,5 @@
-import { isNil } from 'ramda';
-
-import type { PreviousValue } from '@openpanel/validation';
-
-import { round } from './math';
-
-export function getPreviousMetric(
- current: number,
- previous: number | null | undefined,
-): PreviousValue {
- if (isNil(previous)) {
- return undefined;
- }
-
- const diff = round(
- ((current > previous
- ? current / previous
- : current < previous
- ? previous / current
- : 0) -
- 1) *
- 100,
- 1,
- );
-
- return {
- diff:
- Number.isNaN(diff) || !Number.isFinite(diff) || current === previous
- ? null
- : diff,
- state:
- current > previous
- ? 'positive'
- : current < previous
- ? 'negative'
- : 'neutral',
- value: previous,
- };
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export { getPreviousMetric } from '../../core/src/shared/math';
diff --git a/packages/common/src/group-by-labels.ts b/packages/common/src/group-by-labels.ts
index d8dadbb16..4d668a66a 100644
--- a/packages/common/src/group-by-labels.ts
+++ b/packages/common/src/group-by-labels.ts
@@ -1,73 +1,6 @@
-export interface ISerieDataItem {
- label_0: string | null | undefined;
- label_1?: string | null | undefined;
- label_2?: string | null | undefined;
- label_3?: string | null | undefined;
- count: number;
- total_count?: number;
- date: string;
-}
-
-interface GroupedDataPoint {
- date: string;
- count: number;
- total_count?: number;
-}
-
-interface GroupedResult {
- name: string[]; // [label_0, label_1, label_2, label_3]
- data: GroupedDataPoint[];
-}
-
-export function groupByLabels(data: ISerieDataItem[]): GroupedResult[] {
- const groupedMap = new Map<string, GroupedResult>();
- const timestamps = new Set<string>();
- data.forEach((row) => {
- timestamps.add(row.date);
- const labels = Object.keys(row)
- .filter((key) => key.startsWith('label_'))
- .sort((a, b) => {
- const numA = Number.parseInt(a.replace('label_', ''));
- const numB = Number.parseInt(b.replace('label_', ''));
- return numA - numB;
- })
- .map((key) => (row as any)[key])
- .filter((label): label is string => !!label);
-
- const labelKey = labels.join(':::');
-
- if (!groupedMap.has(labelKey)) {
- groupedMap.set(labelKey, {
- name: labels,
- data: [],
- });
- }
-
- const group = groupedMap.get(labelKey)!;
- group.data.push({
- date: row.date,
- count: row.count,
- total_count: row.total_count,
- });
- });
-
- const result = Array.from(groupedMap.values()).map((group) => ({
- ...group,
- data: group.data.sort(
- (a, b) => new Date(a.date).getTime() - new Date(b.date).getTime(),
- ),
- }));
-
- return result
- .filter((group) => group.name.length > 0)
- .map((group) => {
- return {
- ...group,
- // This will ensure that all dates are present in the data array
- data: Array.from(timestamps).map((date) => {
- const dataPoint = group.data.find((dp) => dp.date === date);
- return dataPoint || { date, count: 0, total_count: 0 };
- }),
- };
- });
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export type { ISerieDataItem } from '../../core/src/shared/group-by-labels';
+export { groupByLabels } from '../../core/src/shared/group-by-labels';
diff --git a/packages/common/src/id.ts b/packages/common/src/id.ts
index 06d963d90..5fc585d96 100644
--- a/packages/common/src/id.ts
+++ b/packages/common/src/id.ts
@@ -1,9 +1,5 @@
-import { nanoid } from 'nanoid/non-secure';
-
-export function shortId() {
- return nanoid(4);
-}
-
-export function generateId(prefix?: string, length?: number) {
- return prefix ? `${prefix}_${nanoid(length ?? 8)}` : nanoid(length ?? 8);
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export { generateId, shortId } from '../../core/src/shared/id';
diff --git a/packages/common/src/math.ts b/packages/common/src/math.ts
index 31b92f1ba..2701cc051 100644
--- a/packages/common/src/math.ts
+++ b/packages/common/src/math.ts
@@ -1,40 +1,13 @@
-import { isNumber } from 'mathjs';
-
-export const round = (num: number, decimals = 2) => {
- const factor = 10 ** decimals;
- return Math.round((num + Number.EPSILON) * factor) / factor;
-};
-
-export const average = (arr: (number | null)[], includeZero = false) => {
- const filtered = arr.filter(
- (n): n is number =>
- isNumber(n) &&
- !Number.isNaN(n) &&
- Number.isFinite(n) &&
- (includeZero || n !== 0),
- );
- const avg = filtered.reduce((p, c) => p + c, 0) / filtered.length;
- return Number.isNaN(avg) ? 0 : avg;
-};
-
-export const sum = (arr: (number | null | undefined)[]): number =>
- round(arr.filter(isNumber).reduce((acc, item) => acc + item, 0));
-
-export const min = (arr: (number | null | undefined)[]): number => {
- const filtered = arr.filter(isNumber);
- if (filtered.length === 0) return 0;
- return filtered.reduce((a, b) => (b < a ? b : a), filtered[0]!);
-};
-
-export const max = (arr: (number | null | undefined)[]): number => {
- const filtered = arr.filter(isNumber);
- if (filtered.length === 0) return 0;
- return filtered.reduce((a, b) => (b > a ? b : a), filtered[0]!);
-};
-
-export const isFloat = (n: number) => n % 1 !== 0;
-
-export const ifNaN = <T extends number>(
- n: number | null | undefined,
- defaultValue: T,
-): T => (Number.isNaN(n) ? defaultValue : (n as T));
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+// `isFloat` is gone: the map records it as DELETE, no importer anywhere.
+export {
+ average,
+ ifNaN,
+ max,
+ min,
+ round,
+ sum,
+} from '../../core/src/shared/math';
diff --git a/packages/common/src/names.ts b/packages/common/src/names.ts
deleted file mode 100644
index 623ed1b1c..000000000
--- a/packages/common/src/names.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { animals, names, uniqueNamesGenerator } from 'unique-names-generator';
-
-export function randomName() {
- return uniqueNamesGenerator({
- dictionaries: [names, animals],
- length: 2,
- style: 'capital',
- separator: ' ',
- });
-}
-
-export function randomSplitName() {
- const [firstName, lastName] = randomName().split(' ');
- return {
- firstName,
- lastName,
- };
-}
diff --git a/packages/common/src/object.ts b/packages/common/src/object.ts
index ebcb0917c..05d6b78bb 100644
--- a/packages/common/src/object.ts
+++ b/packages/common/src/object.ts
@@ -1,122 +1,10 @@
-import { anyPass, assocPath, isEmpty, isNil, reject } from 'ramda';
-
-function isValidJsonString(value: string): boolean {
- return (
- (value.startsWith('{') && value.endsWith('}')) ||
- (value.startsWith('[') && value.endsWith(']'))
- );
-}
-function isMalformedJsonString(value: string): boolean {
- return (
- (value.startsWith('{') && !value.endsWith('}')) ||
- (value.startsWith('[') && !value.endsWith(']'))
- );
-}
-
-export function toDots(
- obj: Record<string, unknown>,
- path = '',
-): Record<string, string> {
- // Clickhouse breaks on insert if a property contains invalid surrogate pairs
- function removeInvalidSurrogates(value: string): string {
- const validSurrogatePairRegex =
- /[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g;
- return value.match(validSurrogatePairRegex)?.join('') || '';
- }
-
- return Object.entries(obj).reduce((acc, [key, value]) => {
- if (typeof value === 'object' && value !== null) {
- return {
- ...acc,
- ...toDots(value as Record<string, unknown>, `${path}${key}.`),
- };
- }
-
- if (value === undefined || value === null || value === '') {
- return acc;
- }
-
- if (typeof value === 'string' && isMalformedJsonString(value)) {
- // Skip it
- return acc;
- }
-
- // Fix nested json strings - but catch parse errors for malformed JSON
- if (typeof value === 'string' && isValidJsonString(value)) {
- try {
- return {
- ...acc,
- ...toDots(JSON.parse(value), `${path}${key}.`),
- };
- } catch {
- // Skip it
- return acc;
- }
- }
-
- const cleanedValue =
- typeof value === 'string'
- ? removeInvalidSurrogates(value).trim()
- : String(value);
-
- return {
- ...acc,
- [`${path}${key}`]: cleanedValue,
- };
- }, {});
-}
-
-export function toObject(
- obj: Record<string, string | undefined>,
-): Record<string, unknown> {
- let result: Record<string, unknown> = {};
- Object.entries(obj).forEach(([key, value]) => {
- result = assocPath(key.split('.'), value, result);
- });
- return result;
-}
-
-export const strip = reject(anyPass([isEmpty, isNil]));
-
-type AnyObject = Record<string, any>;
-
-export function deepMergeObjects<T>(target: AnyObject, source: AnyObject): T {
- const merged: AnyObject = {};
- // Include all keys from both objects
- const allKeys = new Set([...Object.keys(target), ...Object.keys(source)]);
-
- allKeys.forEach((key) => {
- const targetValue = target[key];
- const sourceValue = source[key];
-
- if (
- (isNil(sourceValue) && !isNil(targetValue)) ||
- (sourceValue === '' &&
- typeof targetValue === 'string' &&
- targetValue !== '')
- ) {
- // Keep target value if source value is null or undefined
- merged[key] = targetValue;
- } else if (
- sourceValue !== undefined &&
- isObject(targetValue) &&
- isObject(sourceValue)
- ) {
- // Recursively merge objects
- merged[key] = deepMergeObjects(targetValue, sourceValue);
- } else if (sourceValue !== undefined) {
- // Directly assign any non-undefined source values
- merged[key] = sourceValue;
- } else if (sourceValue === undefined && target[key] !== undefined) {
- // Keep target value if source value is undefined
- merged[key] = targetValue;
- }
- });
-
- return merged as T;
-}
-
-// Helper function to check if a value is an object (but not null or an array)
-function isObject(value: any): boolean {
- return value !== null && typeof value === 'object' && !Array.isArray(value);
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export {
+ deepMergeObjects,
+ strip,
+ toDots,
+ toObject,
+} from '../../core/src/shared/object';
diff --git a/packages/common/src/slug.ts b/packages/common/src/slug.ts
index dcb51481a..0798d5249 100644
--- a/packages/common/src/slug.ts
+++ b/packages/common/src/slug.ts
@@ -1,19 +1,5 @@
-import _slugify from 'slugify';
-
-const slugify = (str: string) => {
- return _slugify(
- str
- .replaceAll('å', 'a')
- .replaceAll('ä', 'a')
- .replaceAll('ö', 'o')
- .replaceAll('Å', 'A')
- .replaceAll('Ä', 'A')
- .replaceAll('Ö', 'O')
- .replace(/\|+/g, '-'),
- { lower: true, strict: true, trim: true },
- );
-};
-
-export function slug(str: string): string {
- return slugify(str);
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export { slug } from '../../core/src/shared/slug';
diff --git a/packages/common/src/string.ts b/packages/common/src/string.ts
index aee2527d7..121632637 100644
--- a/packages/common/src/string.ts
+++ b/packages/common/src/string.ts
@@ -1,7 +1,8 @@
-export function stripTrailingSlash(url: string) {
- return url.replace(/\/+$/, '');
-}
-
-export function stripLeadingAndTrailingSlashes(url: string) {
- return url.replace(/^[/]+|[/]+$/g, '');
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export {
+ stripLeadingAndTrailingSlashes,
+ stripTrailingSlash,
+} from '../../core/src/shared/string';
diff --git a/packages/common/src/timezones.ts b/packages/common/src/timezones.ts
deleted file mode 100644
index 2310670c8..000000000
--- a/packages/common/src/timezones.ts
+++ /dev/null
@@ -1,600 +0,0 @@
-// List of available timezones from Clickhouse `select time_zone from system.time_zones`
-export const TIMEZONES = [
- 'Africa/Abidjan',
- 'Africa/Accra',
- 'Africa/Addis_Ababa',
- 'Africa/Algiers',
- 'Africa/Asmara',
- 'Africa/Asmera',
- 'Africa/Bamako',
- 'Africa/Bangui',
- 'Africa/Banjul',
- 'Africa/Bissau',
- 'Africa/Blantyre',
- 'Africa/Brazzaville',
- 'Africa/Bujumbura',
- 'Africa/Cairo',
- 'Africa/Casablanca',
- 'Africa/Ceuta',
- 'Africa/Conakry',
- 'Africa/Dakar',
- 'Africa/Dar_es_Salaam',
- 'Africa/Djibouti',
- 'Africa/Douala',
- 'Africa/El_Aaiun',
- 'Africa/Freetown',
- 'Africa/Gaborone',
- 'Africa/Harare',
- 'Africa/Johannesburg',
- 'Africa/Juba',
- 'Africa/Kampala',
- 'Africa/Khartoum',
- 'Africa/Kigali',
- 'Africa/Kinshasa',
- 'Africa/Lagos',
- 'Africa/Libreville',
- 'Africa/Lome',
- 'Africa/Luanda',
- 'Africa/Lubumbashi',
- 'Africa/Lusaka',
- 'Africa/Malabo',
- 'Africa/Maputo',
- 'Africa/Maseru',
- 'Africa/Mbabane',
- 'Africa/Mogadishu',
- 'Africa/Monrovia',
- 'Africa/Nairobi',
- 'Africa/Ndjamena',
- 'Africa/Niamey',
- 'Africa/Nouakchott',
- 'Africa/Ouagadougou',
- 'Africa/Porto-Novo',
- 'Africa/Sao_Tome',
- 'Africa/Timbuktu',
- 'Africa/Tripoli',
- 'Africa/Tunis',
- 'Africa/Windhoek',
- 'America/Adak',
- 'America/Anchorage',
- 'America/Anguilla',
- 'America/Antigua',
- 'America/Araguaina',
- 'America/Argentina/Buenos_Aires',
- 'America/Argentina/Catamarca',
- 'America/Argentina/ComodRivadavia',
- 'America/Argentina/Cordoba',
- 'America/Argentina/Jujuy',
- 'America/Argentina/La_Rioja',
- 'America/Argentina/Mendoza',
- 'America/Argentina/Rio_Gallegos',
- 'America/Argentina/Salta',
- 'America/Argentina/San_Juan',
- 'America/Argentina/San_Luis',
- 'America/Argentina/Tucuman',
- 'America/Argentina/Ushuaia',
- 'America/Aruba',
- 'America/Asuncion',
- 'America/Atikokan',
- 'America/Atka',
- 'America/Bahia',
- 'America/Bahia_Banderas',
- 'America/Barbados',
- 'America/Belem',
- 'America/Belize',
- 'America/Blanc-Sablon',
- 'America/Boa_Vista',
- 'America/Bogota',
- 'America/Boise',
- 'America/Buenos_Aires',
- 'America/Cambridge_Bay',
- 'America/Campo_Grande',
- 'America/Cancun',
- 'America/Caracas',
- 'America/Catamarca',
- 'America/Cayenne',
- 'America/Cayman',
- 'America/Chicago',
- 'America/Chihuahua',
- 'America/Ciudad_Juarez',
- 'America/Coral_Harbour',
- 'America/Cordoba',
- 'America/Costa_Rica',
- 'America/Creston',
- 'America/Cuiaba',
- 'America/Curacao',
- 'America/Danmarkshavn',
- 'America/Dawson',
- 'America/Dawson_Creek',
- 'America/Denver',
- 'America/Detroit',
- 'America/Dominica',
- 'America/Edmonton',
- 'America/Eirunepe',
- 'America/El_Salvador',
- 'America/Ensenada',
- 'America/Fort_Nelson',
- 'America/Fort_Wayne',
- 'America/Fortaleza',
- 'America/Glace_Bay',
- 'America/Godthab',
- 'America/Goose_Bay',
- 'America/Grand_Turk',
- 'America/Grenada',
- 'America/Guadeloupe',
- 'America/Guatemala',
- 'America/Guayaquil',
- 'America/Guyana',
- 'America/Halifax',
- 'America/Havana',
- 'America/Hermosillo',
- 'America/Indiana/Indianapolis',
- 'America/Indiana/Knox',
- 'America/Indiana/Marengo',
- 'America/Indiana/Petersburg',
- 'America/Indiana/Tell_City',
- 'America/Indiana/Vevay',
- 'America/Indiana/Vincennes',
- 'America/Indiana/Winamac',
- 'America/Indianapolis',
- 'America/Inuvik',
- 'America/Iqaluit',
- 'America/Jamaica',
- 'America/Jujuy',
- 'America/Juneau',
- 'America/Kentucky/Louisville',
- 'America/Kentucky/Monticello',
- 'America/Knox_IN',
- 'America/Kralendijk',
- 'America/La_Paz',
- 'America/Lima',
- 'America/Los_Angeles',
- 'America/Louisville',
- 'America/Lower_Princes',
- 'America/Maceio',
- 'America/Managua',
- 'America/Manaus',
- 'America/Marigot',
- 'America/Martinique',
- 'America/Matamoros',
- 'America/Mazatlan',
- 'America/Mendoza',
- 'America/Menominee',
- 'America/Merida',
- 'America/Metlakatla',
- 'America/Mexico_City',
- 'America/Miquelon',
- 'America/Moncton',
- 'America/Monterrey',
- 'America/Montevideo',
- 'America/Montreal',
- 'America/Montserrat',
- 'America/Nassau',
- 'America/New_York',
- 'America/Nipigon',
- 'America/Nome',
- 'America/Noronha',
- 'America/North_Dakota/Beulah',
- 'America/North_Dakota/Center',
- 'America/North_Dakota/New_Salem',
- 'America/Nuuk',
- 'America/Ojinaga',
- 'America/Panama',
- 'America/Pangnirtung',
- 'America/Paramaribo',
- 'America/Phoenix',
- 'America/Port-au-Prince',
- 'America/Port_of_Spain',
- 'America/Porto_Acre',
- 'America/Porto_Velho',
- 'America/Puerto_Rico',
- 'America/Punta_Arenas',
- 'America/Rainy_River',
- 'America/Rankin_Inlet',
- 'America/Recife',
- 'America/Regina',
- 'America/Resolute',
- 'America/Rio_Branco',
- 'America/Rosario',
- 'America/Santa_Isabel',
- 'America/Santarem',
- 'America/Santiago',
- 'America/Santo_Domingo',
- 'America/Sao_Paulo',
- 'America/Scoresbysund',
- 'America/Shiprock',
- 'America/Sitka',
- 'America/St_Barthelemy',
- 'America/St_Johns',
- 'America/St_Kitts',
- 'America/St_Lucia',
- 'America/St_Thomas',
- 'America/St_Vincent',
- 'America/Swift_Current',
- 'America/Tegucigalpa',
- 'America/Thule',
- 'America/Thunder_Bay',
- 'America/Tijuana',
- 'America/Toronto',
- 'America/Tortola',
- 'America/Vancouver',
- 'America/Virgin',
- 'America/Whitehorse',
- 'America/Winnipeg',
- 'America/Yakutat',
- 'America/Yellowknife',
- 'Antarctica/Casey',
- 'Antarctica/Davis',
- 'Antarctica/DumontDUrville',
- 'Antarctica/Macquarie',
- 'Antarctica/Mawson',
- 'Antarctica/McMurdo',
- 'Antarctica/Palmer',
- 'Antarctica/Rothera',
- 'Antarctica/South_Pole',
- 'Antarctica/Syowa',
- 'Antarctica/Troll',
- 'Antarctica/Vostok',
- 'Arctic/Longyearbyen',
- 'Asia/Aden',
- 'Asia/Almaty',
- 'Asia/Amman',
- 'Asia/Anadyr',
- 'Asia/Aqtau',
- 'Asia/Aqtobe',
- 'Asia/Ashgabat',
- 'Asia/Ashkhabad',
- 'Asia/Atyrau',
- 'Asia/Baghdad',
- 'Asia/Bahrain',
- 'Asia/Baku',
- 'Asia/Bangkok',
- 'Asia/Barnaul',
- 'Asia/Beirut',
- 'Asia/Bishkek',
- 'Asia/Brunei',
- 'Asia/Calcutta',
- 'Asia/Chita',
- 'Asia/Choibalsan',
- 'Asia/Chongqing',
- 'Asia/Chungking',
- 'Asia/Colombo',
- 'Asia/Dacca',
- 'Asia/Damascus',
- 'Asia/Dhaka',
- 'Asia/Dili',
- 'Asia/Dubai',
- 'Asia/Dushanbe',
- 'Asia/Famagusta',
- 'Asia/Gaza',
- 'Asia/Harbin',
- 'Asia/Hebron',
- 'Asia/Ho_Chi_Minh',
- 'Asia/Hong_Kong',
- 'Asia/Hovd',
- 'Asia/Irkutsk',
- 'Asia/Istanbul',
- 'Asia/Jakarta',
- 'Asia/Jayapura',
- 'Asia/Jerusalem',
- 'Asia/Kabul',
- 'Asia/Kamchatka',
- 'Asia/Karachi',
- 'Asia/Kashgar',
- 'Asia/Kathmandu',
- 'Asia/Katmandu',
- 'Asia/Khandyga',
- 'Asia/Kolkata',
- 'Asia/Krasnoyarsk',
- 'Asia/Kuala_Lumpur',
- 'Asia/Kuching',
- 'Asia/Kuwait',
- 'Asia/Macao',
- 'Asia/Macau',
- 'Asia/Magadan',
- 'Asia/Makassar',
- 'Asia/Manila',
- 'Asia/Muscat',
- 'Asia/Nicosia',
- 'Asia/Novokuznetsk',
- 'Asia/Novosibirsk',
- 'Asia/Omsk',
- 'Asia/Oral',
- 'Asia/Phnom_Penh',
- 'Asia/Pontianak',
- 'Asia/Pyongyang',
- 'Asia/Qatar',
- 'Asia/Qostanay',
- 'Asia/Qyzylorda',
- 'Asia/Rangoon',
- 'Asia/Riyadh',
- 'Asia/Saigon',
- 'Asia/Sakhalin',
- 'Asia/Samarkand',
- 'Asia/Seoul',
- 'Asia/Shanghai',
- 'Asia/Singapore',
- 'Asia/Srednekolymsk',
- 'Asia/Taipei',
- 'Asia/Tashkent',
- 'Asia/Tbilisi',
- 'Asia/Tehran',
- 'Asia/Tel_Aviv',
- 'Asia/Thimbu',
- 'Asia/Thimphu',
- 'Asia/Tokyo',
- 'Asia/Tomsk',
- 'Asia/Ujung_Pandang',
- 'Asia/Ulaanbaatar',
- 'Asia/Ulan_Bator',
- 'Asia/Urumqi',
- 'Asia/Ust-Nera',
- 'Asia/Vientiane',
- 'Asia/Vladivostok',
- 'Asia/Yakutsk',
- 'Asia/Yangon',
- 'Asia/Yekaterinburg',
- 'Asia/Yerevan',
- 'Atlantic/Azores',
- 'Atlantic/Bermuda',
- 'Atlantic/Canary',
- 'Atlantic/Cape_Verde',
- 'Atlantic/Faeroe',
- 'Atlantic/Faroe',
- 'Atlantic/Jan_Mayen',
- 'Atlantic/Madeira',
- 'Atlantic/Reykjavik',
- 'Atlantic/South_Georgia',
- 'Atlantic/St_Helena',
- 'Atlantic/Stanley',
- 'Australia/ACT',
- 'Australia/Adelaide',
- 'Australia/Brisbane',
- 'Australia/Broken_Hill',
- 'Australia/Canberra',
- 'Australia/Currie',
- 'Australia/Darwin',
- 'Australia/Eucla',
- 'Australia/Hobart',
- 'Australia/LHI',
- 'Australia/Lindeman',
- 'Australia/Lord_Howe',
- 'Australia/Melbourne',
- 'Australia/NSW',
- 'Australia/North',
- 'Australia/Perth',
- 'Australia/Queensland',
- 'Australia/South',
- 'Australia/Sydney',
- 'Australia/Tasmania',
- 'Australia/Victoria',
- 'Australia/West',
- 'Australia/Yancowinna',
- 'Brazil/Acre',
- 'Brazil/DeNoronha',
- 'Brazil/East',
- 'Brazil/West',
- 'CET',
- 'CST6CDT',
- 'Canada/Atlantic',
- 'Canada/Central',
- 'Canada/Eastern',
- 'Canada/Mountain',
- 'Canada/Newfoundland',
- 'Canada/Pacific',
- 'Canada/Saskatchewan',
- 'Canada/Yukon',
- 'Chile/Continental',
- 'Chile/EasterIsland',
- 'Cuba',
- 'EET',
- 'EST',
- 'EST5EDT',
- 'Egypt',
- 'Eire',
- 'Etc/GMT',
- 'Etc/GMT+0',
- 'Etc/GMT+1',
- 'Etc/GMT+10',
- 'Etc/GMT+11',
- 'Etc/GMT+12',
- 'Etc/GMT+2',
- 'Etc/GMT+3',
- 'Etc/GMT+4',
- 'Etc/GMT+5',
- 'Etc/GMT+6',
- 'Etc/GMT+7',
- 'Etc/GMT+8',
- 'Etc/GMT+9',
- 'Etc/GMT-0',
- 'Etc/GMT-1',
- 'Etc/GMT-10',
- 'Etc/GMT-11',
- 'Etc/GMT-12',
- 'Etc/GMT-13',
- 'Etc/GMT-14',
- 'Etc/GMT-2',
- 'Etc/GMT-3',
- 'Etc/GMT-4',
- 'Etc/GMT-5',
- 'Etc/GMT-6',
- 'Etc/GMT-7',
- 'Etc/GMT-8',
- 'Etc/GMT-9',
- 'Etc/GMT0',
- 'Etc/Greenwich',
- 'Etc/UCT',
- 'Etc/UTC',
- 'Etc/Universal',
- 'Etc/Zulu',
- 'Europe/Amsterdam',
- 'Europe/Andorra',
- 'Europe/Astrakhan',
- 'Europe/Athens',
- 'Europe/Belfast',
- 'Europe/Belgrade',
- 'Europe/Berlin',
- 'Europe/Bratislava',
- 'Europe/Brussels',
- 'Europe/Bucharest',
- 'Europe/Budapest',
- 'Europe/Busingen',
- 'Europe/Chisinau',
- 'Europe/Copenhagen',
- 'Europe/Dublin',
- 'Europe/Gibraltar',
- 'Europe/Guernsey',
- 'Europe/Helsinki',
- 'Europe/Isle_of_Man',
- 'Europe/Istanbul',
- 'Europe/Jersey',
- 'Europe/Kaliningrad',
- 'Europe/Kiev',
- 'Europe/Kirov',
- 'Europe/Kyiv',
- 'Europe/Lisbon',
- 'Europe/Ljubljana',
- 'Europe/London',
- 'Europe/Luxembourg',
- 'Europe/Madrid',
- 'Europe/Malta',
- 'Europe/Mariehamn',
- 'Europe/Minsk',
- 'Europe/Monaco',
- 'Europe/Moscow',
- 'Europe/Nicosia',
- 'Europe/Oslo',
- 'Europe/Paris',
- 'Europe/Podgorica',
- 'Europe/Prague',
- 'Europe/Riga',
- 'Europe/Rome',
- 'Europe/Samara',
- 'Europe/San_Marino',
- 'Europe/Sarajevo',
- 'Europe/Saratov',
- 'Europe/Simferopol',
- 'Europe/Skopje',
- 'Europe/Sofia',
- 'Europe/Stockholm',
- 'Europe/Tallinn',
- 'Europe/Tirane',
- 'Europe/Tiraspol',
- 'Europe/Ulyanovsk',
- 'Europe/Uzhgorod',
- 'Europe/Vaduz',
- 'Europe/Vatican',
- 'Europe/Vienna',
- 'Europe/Vilnius',
- 'Europe/Volgograd',
- 'Europe/Warsaw',
- 'Europe/Zagreb',
- 'Europe/Zaporozhye',
- 'Europe/Zurich',
- 'Factory',
- 'GB',
- 'GB-Eire',
- 'GMT',
- 'GMT+0',
- 'GMT-0',
- 'GMT0',
- 'Greenwich',
- 'HST',
- 'Hongkong',
- 'Iceland',
- 'Indian/Antananarivo',
- 'Indian/Chagos',
- 'Indian/Christmas',
- 'Indian/Cocos',
- 'Indian/Comoro',
- 'Indian/Kerguelen',
- 'Indian/Mahe',
- 'Indian/Maldives',
- 'Indian/Mauritius',
- 'Indian/Mayotte',
- 'Indian/Reunion',
- 'Iran',
- 'Israel',
- 'Jamaica',
- 'Japan',
- 'Kwajalein',
- 'Libya',
- 'MET',
- 'MST',
- 'MST7MDT',
- 'Mexico/BajaNorte',
- 'Mexico/BajaSur',
- 'Mexico/General',
- 'NZ',
- 'NZ-CHAT',
- 'Navajo',
- 'PRC',
- 'PST8PDT',
- 'Pacific/Apia',
- 'Pacific/Auckland',
- 'Pacific/Bougainville',
- 'Pacific/Chatham',
- 'Pacific/Chuuk',
- 'Pacific/Easter',
- 'Pacific/Efate',
- 'Pacific/Enderbury',
- 'Pacific/Fakaofo',
- 'Pacific/Fiji',
- 'Pacific/Funafuti',
- 'Pacific/Galapagos',
- 'Pacific/Gambier',
- 'Pacific/Guadalcanal',
- 'Pacific/Guam',
- 'Pacific/Honolulu',
- 'Pacific/Johnston',
- 'Pacific/Kanton',
- 'Pacific/Kiritimati',
- 'Pacific/Kosrae',
- 'Pacific/Kwajalein',
- 'Pacific/Majuro',
- 'Pacific/Marquesas',
- 'Pacific/Midway',
- 'Pacific/Nauru',
- 'Pacific/Niue',
- 'Pacific/Norfolk',
- 'Pacific/Noumea',
- 'Pacific/Pago_Pago',
- 'Pacific/Palau',
- 'Pacific/Pitcairn',
- 'Pacific/Pohnpei',
- 'Pacific/Ponape',
- 'Pacific/Port_Moresby',
- 'Pacific/Rarotonga',
- 'Pacific/Saipan',
- 'Pacific/Samoa',
- 'Pacific/Tahiti',
- 'Pacific/Tarawa',
- 'Pacific/Tongatapu',
- 'Pacific/Truk',
- 'Pacific/Wake',
- 'Pacific/Wallis',
- 'Pacific/Yap',
- 'Poland',
- 'Portugal',
- 'ROC',
- 'ROK',
- 'Singapore',
- 'Turkey',
- 'UCT',
- 'US/Alaska',
- 'US/Aleutian',
- 'US/Arizona',
- 'US/Central',
- 'US/East-Indiana',
- 'US/Eastern',
- 'US/Hawaii',
- 'US/Indiana-Starke',
- 'US/Michigan',
- 'US/Mountain',
- 'US/Pacific',
- 'US/Samoa',
- 'UTC',
- 'Universal',
- 'W-SU',
- 'WET',
- 'Zulu',
-];
diff --git a/packages/common/src/try-catch.ts b/packages/common/src/try-catch.ts
deleted file mode 100644
index f437bbd63..000000000
--- a/packages/common/src/try-catch.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export type TryCatchResult<T, E = Error> =
- | { ok: true; data: T; error: null }
- | { ok: false; data: null; error: E };
-
-export async function tryCatch<T, E = Error>(
- input: (() => Promise<T>) | Promise<T>,
-): Promise<TryCatchResult<T, E>> {
- try {
- const promise = typeof input === 'function' ? input() : input;
- const data = await promise;
- return { ok: true, data, error: null };
- } catch (error) {
- return { ok: false, data: null, error: error as E };
- }
-}
\ No newline at end of file
diff --git a/packages/common/src/url.ts b/packages/common/src/url.ts
index 32af023f6..3a355f692 100644
--- a/packages/common/src/url.ts
+++ b/packages/common/src/url.ts
@@ -1,63 +1,9 @@
-export function parseSearchParams(
- params: URLSearchParams,
-): Record<string, string> | undefined {
- const result: Record<string, string> = {};
- for (const [key, value] of params.entries()) {
- result[key] = value;
- }
- return Object.keys(result).length ? result : undefined;
-}
-
-export function parsePath(path?: string): {
- query?: Record<string, string>;
- path: string;
- origin: string;
- hash?: string;
-} {
- if (!path) {
- return {
- path: '',
- origin: '',
- };
- }
-
- const hasOrigin = path.startsWith('http');
-
- // If path does not have a leading /,
- // its probably a named route
- if (!path.startsWith('/') && !hasOrigin) {
- return {
- path,
- origin: '',
- };
- }
-
- try {
- const url = new URL(path, hasOrigin ? undefined : 'http://localhost');
- return {
- query: parseSearchParams(url.searchParams),
- path: url.pathname,
- hash: url.hash || undefined,
- origin: hasOrigin ? url.origin : '',
- };
- } catch (error) {
- return {
- path,
- origin: '',
- };
- }
-}
-
-export function isSameDomain(
- url1: string | undefined,
- url2: string | undefined,
-) {
- if (!url1 || !url2) {
- return false;
- }
- try {
- return new URL(url1).hostname === new URL(url2).hostname;
- } catch (e) {
- return false;
- }
-}
+// P11 shim (ADR-008/ADR-007): definitions moved to packages/core/src/shared.
+// Reached by relative path, not through @openpanel/core, so that bundling
+// this package (packages/sdks/express sets noExternal) pulls the one leaf file
+// and not core barrel. Deleted by M11-009.
+export {
+ isSameDomain,
+ parsePath,
+ parseSearchParams,
+} from '../../core/src/shared/url';
diff --git a/packages/core/package.json b/packages/core/package.json
index 39387f0ca..0eea1dd4d 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -33,13 +33,10 @@
"@maxmind/geoip2-node": "^6.1.0",
"@modelcontextprotocol/sdk": "^1.12.0",
"@node-rs/argon2": "^2.0.2",
- "@openpanel/common": "workspace:*",
- "@openpanel/constants": "workspace:*",
"@openpanel/db": "workspace:*",
"@openpanel/email": "workspace:*",
"@openpanel/payments": "workspace:*",
"@openpanel/redis": "workspace:*",
- "@openpanel/validation": "workspace:*",
"@oslojs/crypto": "^1.0.1",
"@oslojs/encoding": "^1.1.0",
"@oslojs/otp": "^1.1.0",
@@ -59,6 +56,7 @@
"js-yaml": "^4.1.0",
"kafkajs": "^2.2.4",
"lru-cache": "^11.2.4",
+ "luxon": "^3.7.2",
"mathjs": "^12.3.2",
"nanoid": "^5.1.6",
"pino": "catalog:",
@@ -69,6 +67,7 @@
"ramda": "^0.29.1",
"sharp": "^0.33.5",
"short-unique-id": "^5.0.3",
+ "slugify": "^1.6.6",
"sqlstring": "^2.3.3",
"superjson": "^1.13.3",
"ua-parser-js": "^2.0.6",
@@ -82,6 +81,7 @@
"@clickhouse/client": "^1.18.5",
"@openpanel/tsconfig": "workspace:*",
"@types/js-yaml": "^4.0.9",
+ "@types/luxon": "^3.7.1",
"@types/qrcode": "^1.5.6",
"@types/ramda": "^0.31.1",
"@types/sqlstring": "^2.3.2",
diff --git a/packages/core/src/buffers/group-buffer.ts b/packages/core/src/buffers/group-buffer.ts
index 442fd7be9..0ad19b9ee 100644
--- a/packages/core/src/buffers/group-buffer.ts
+++ b/packages/core/src/buffers/group-buffer.ts
@@ -1,10 +1,10 @@
-import { toDots } from '@openpanel/common';
import { getRedisCache, type Redis } from '@openpanel/redis';
import shallowEqual from 'fast-deep-equal';
import sqlstring from 'sqlstring';
import { formatClickhouseDate } from '../shared/ch-dates';
import { TABLE_NAMES } from '../shared/ch-tables';
import { getSafeJson } from '../shared/json';
+import { toDots } from '../shared/object';
import { BaseBuffer, type BufferDeps } from './base-buffer';
type IGroupBufferEntry = {
diff --git a/packages/core/src/buffers/profile-buffer.ts b/packages/core/src/buffers/profile-buffer.ts
index 4071a6eec..6cf07250e 100644
--- a/packages/core/src/buffers/profile-buffer.ts
+++ b/packages/core/src/buffers/profile-buffer.ts
@@ -1,10 +1,10 @@
-import { deepMergeObjects } from '@openpanel/common';
import { getRedisCache, type Redis } from '@openpanel/redis';
import { omit, uniq } from 'ramda';
import sqlstring from 'sqlstring';
import type { IClickhouseProfile } from '../modules/profile/profile.service';
import { TABLE_NAMES } from '../shared/ch-tables';
import { getSafeJson } from '../shared/json';
+import { deepMergeObjects } from '../shared/object';
import { BaseBuffer, type BufferDeps } from './base-buffer';
// Inlined to avoid a circular value-import with `profile.service.ts`
diff --git a/packages/core/src/buffers/session-buffer.ts b/packages/core/src/buffers/session-buffer.ts
index 642d64135..06e5a9527 100644
--- a/packages/core/src/buffers/session-buffer.ts
+++ b/packages/core/src/buffers/session-buffer.ts
@@ -1,8 +1,8 @@
-import { DateTime } from '@openpanel/common';
import { getRedisCache, type Redis } from '@openpanel/redis';
import type { IServiceCreateEventPayload } from '../modules/event/event.service';
import type { IClickhouseSession } from '../modules/session/session.service';
import { TABLE_NAMES } from '../shared/ch-tables';
+import { DateTime } from '../shared/date';
import { getSafeJson } from '../shared/json';
import { BaseBuffer, type BufferDeps } from './base-buffer';
diff --git a/packages/core/src/clients/ai/providers.ts b/packages/core/src/clients/ai/providers.ts
index a92fec224..f185f3e41 100644
--- a/packages/core/src/clients/ai/providers.ts
+++ b/packages/core/src/clients/ai/providers.ts
@@ -3,7 +3,7 @@
// SERVER-ONLY. This module instantiates `@better-agent/providers` clients and
// reads provider API keys from `process.env`. Never value-import it from the
// browser (apps/start) — import the model catalog/types from
-// `@openpanel/validation` instead.
+// `@openpanel/core/modules/assistant/assistant.constants` instead.
import { createAnthropic } from '@better-agent/providers/anthropic';
import { createOpenAI } from '@better-agent/providers/openai';
import { z } from 'zod';
diff --git a/packages/core/src/code-migrations/20-invite-project-access-levels.ts b/packages/core/src/code-migrations/20-invite-project-access-levels.ts
index 38afb3ed9..4da28d023 100644
--- a/packages/core/src/code-migrations/20-invite-project-access-levels.ts
+++ b/packages/core/src/code-migrations/20-invite-project-access-levels.ts
@@ -1,5 +1,5 @@
import { db } from '@openpanel/db';
-import { zProjectAccessGrant } from '@openpanel/validation';
+import { zProjectAccessGrant } from '../modules/organization/organization.constants';
import { getIsDry, printBoxMessage } from './helpers';
/**
diff --git a/packages/core/src/code-migrations/7-migrate-events-to-series.ts b/packages/core/src/code-migrations/7-migrate-events-to-series.ts
index bd23d1af9..bb15c31b9 100644
--- a/packages/core/src/code-migrations/7-migrate-events-to-series.ts
+++ b/packages/core/src/code-migrations/7-migrate-events-to-series.ts
@@ -1,10 +1,10 @@
-import { shortId } from '@openpanel/common';
import { db } from '@openpanel/db';
import type {
IChartEvent,
IChartEventItem,
IChartFormula,
-} from '@openpanel/validation';
+} from '../modules/report/report.constants';
+import { shortId } from '../shared/id';
import { printBoxMessage } from './helpers';
export async function up() {
diff --git a/packages/core/src/code-migrations/9-migrate-options.ts b/packages/core/src/code-migrations/9-migrate-options.ts
index 7c008bfe9..ad3c0a087 100644
--- a/packages/core/src/code-migrations/9-migrate-options.ts
+++ b/packages/core/src/code-migrations/9-migrate-options.ts
@@ -1,5 +1,5 @@
import { db } from '@openpanel/db';
-import type { IReportOptions } from '@openpanel/validation';
+import type { IReportOptions } from '../modules/report/report.constants';
import { printBoxMessage } from './helpers';
export async function up() {
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index ad180db3e..69f3cbf11 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -440,8 +440,8 @@ export { createDashboardService } from './modules/dashboard/dashboard.service';
// R + C only (M6-004): the router's three bodies are three small
// `db.emailUnsubscribe` calls, small enough to live inline in
// `email.rpc.ts` rather than a dedicated `email.service.ts` — see that
-// file's header. `emailCategories` moved from @openpanel/constants (ADR-008's
-// module map: email owns "C"); @openpanel/constants keeps a re-export shim.
+// file's header. `emailCategories` moved from packages/constants (ADR-008's
+// module map: email owns "C"); packages/constants keeps a re-export shim.
export type { EmailCategory } from './modules/email/email.constants';
export { emailCategories } from './modules/email/email.constants';
// Dissolved from @openpanel/db's services/event.service.ts, profile.service.ts
@@ -1066,7 +1066,7 @@ export {
getOrganizationAccess,
getProjectAccess,
} from './shared/access-lookups';
-// Dissolved from @openpanel/common/server (M4-003) — a still-live V1 package
+// Dissolved from packages/common/server (M4-003) — a still-live V1 package
// (db, queue, apps/worker) reaches these the same way apps/api and core
// itself do, until its own module lands. mcp reaches it as an internal
// relative import now that it lives inside core (M5-007).
@@ -1107,6 +1107,10 @@ export {
TRUSTED_IP_HEADER_ORDER,
} from './shared/get-client-ip';
export { generateId, generateSecureId, shortId } from './shared/id';
+// packages/db reads ClickHouse row JSON through this (P11: packages/json's
+// only definition already lived here; the barrel is how a package outside
+// core reaches it, since the exports map has no ./shared/* entry).
+export { getSafeJson } from './shared/json';
export { resolveMaxLookbackDays } from './shared/lookback';
export { getReferrerWithQuery, parseReferrer } from './shared/parse-referrer';
export type {
diff --git a/packages/core/src/modules/assistant/assistant.constants.ts b/packages/core/src/modules/assistant/assistant.constants.ts
index 0bacbdf9e..f06500509 100644
--- a/packages/core/src/modules/assistant/assistant.constants.ts
+++ b/packages/core/src/modules/assistant/assistant.constants.ts
@@ -5,7 +5,7 @@ import { z } from 'zod';
* assistant owns "C"). packages/validation/src/chat.ts becomes a re-export
* shim of this file (same shape as packages/validation/src/import.validation.ts
* since M5-004), so apps/start's model picker and the SDK-facing types keep
- * resolving these symbols through @openpanel/validation's existing barrel
+ * resolving these symbols through packages/validation's existing barrel
* unchanged.
*
* Isomorphic by the AGENTS.md rule: zod and nothing else.
diff --git a/packages/core/src/modules/assistant/src/filter-command.ts b/packages/core/src/modules/assistant/src/filter-command.ts
index 3699675bc..dbc031996 100644
--- a/packages/core/src/modules/assistant/src/filter-command.ts
+++ b/packages/core/src/modules/assistant/src/filter-command.ts
@@ -9,12 +9,6 @@ import {
defineTool,
type ToolRunContext,
} from '@better-agent/core';
-import { intervals, operators, timeWindows } from '@openpanel/constants';
-import {
- type IChartEventFilter,
- type IChartRange,
- zRange,
-} from '@openpanel/validation';
import { z } from 'zod';
import { resolveModel } from '../../../clients/ai/providers';
import {
@@ -26,6 +20,14 @@ import {
getTrafficBreakdownCore,
listEventNamesCore,
} from '../../../v1-compat';
+import {
+ type IChartEventFilter,
+ type IChartRange,
+ intervals,
+ operators,
+ timeWindows,
+ zRange,
+} from '../../report/report.constants';
import {
CHAT_MODELS,
type ChatModelEntry,
diff --git a/packages/core/src/modules/assistant/src/tools/base.ts b/packages/core/src/modules/assistant/src/tools/base.ts
index c29c00883..cb47853e2 100644
--- a/packages/core/src/modules/assistant/src/tools/base.ts
+++ b/packages/core/src/modules/assistant/src/tools/base.ts
@@ -1,5 +1,3 @@
-import { chartTypes, lineTypes, operators } from '@openpanel/constants';
-import { zReportInput } from '@openpanel/validation';
import { z } from 'zod';
import {
findProfilesCore,
@@ -18,6 +16,12 @@ import {
queryEventsCore,
querySessionsCore,
} from '../../../../v1-compat';
+import {
+ chartTypes,
+ lineTypes,
+ operators,
+ zReportInput,
+} from '../../../report/report.constants';
import { runReport, runReportFromConfig } from '../report-runner';
import {
chatTool,
diff --git a/packages/core/src/modules/assistant/src/tools/dashboard.ts b/packages/core/src/modules/assistant/src/tools/dashboard.ts
index a243fd15b..865d6fde8 100644
--- a/packages/core/src/modules/assistant/src/tools/dashboard.ts
+++ b/packages/core/src/modules/assistant/src/tools/dashboard.ts
@@ -1,4 +1,3 @@
-import type { IChartRange, IInterval } from '@openpanel/validation';
import { z } from 'zod';
import { getChartStartEndDate } from '../../../../shared/date';
import {
@@ -9,6 +8,7 @@ import {
getReportsByDashboardId,
getSettingsForProject,
} from '../../../../v1-compat';
+import type { IChartRange, IInterval } from '../../../report/report.constants';
import { chatTool, dashboardUrl } from './helpers';
// Cap on parallel report execution. Real dashboards rarely exceed this,
diff --git a/packages/core/src/modules/assistant/src/tools/helpers.ts b/packages/core/src/modules/assistant/src/tools/helpers.ts
index 262196442..20ab35441 100644
--- a/packages/core/src/modules/assistant/src/tools/helpers.ts
+++ b/packages/core/src/modules/assistant/src/tools/helpers.ts
@@ -3,12 +3,15 @@ import {
defineTool,
type ToolRunContext,
} from '@better-agent/core';
-import type { IChartEventFilter, IChartRange } from '@openpanel/validation';
import type { z } from 'zod';
import {
getDatesFromRange,
resolveDateRange as resolveDateRangeCore,
} from '../../../../shared/date';
+import type {
+ IChartEventFilter,
+ IChartRange,
+} from '../../../report/report.constants';
import type { ChatAgentContext, PageContext } from '../context';
import { chatRunContext } from '../run-context';
diff --git a/packages/core/src/modules/assistant/src/tools/report.ts b/packages/core/src/modules/assistant/src/tools/report.ts
index 33461edc2..19b2af22c 100644
--- a/packages/core/src/modules/assistant/src/tools/report.ts
+++ b/packages/core/src/modules/assistant/src/tools/report.ts
@@ -1,6 +1,6 @@
-import type { IReportInput } from '@openpanel/validation';
import { z } from 'zod';
import { listEventPropertiesCore } from '../../../../v1-compat';
+import type { IReportInput } from '../../../report/report.constants';
import { runReportFromConfig } from '../report-runner';
import { chatTool, previousPeriod, resolveDateRange } from './helpers';
diff --git a/packages/core/src/modules/auth/auth.constants.ts b/packages/core/src/modules/auth/auth.constants.ts
index ac7a6db38..e2e7ecd65 100644
--- a/packages/core/src/modules/auth/auth.constants.ts
+++ b/packages/core/src/modules/auth/auth.constants.ts
@@ -2,7 +2,7 @@
// auth owns "C"). packages/validation/src/index.ts becomes a re-export shim
// for these symbols (same shape as packages/validation/src/cohort.validation.ts
// since M5-003), so apps/start and packages/trpc keep resolving them through
-// @openpanel/validation's existing barrel unchanged. `zProvider` is new here —
+// packages/validation's existing barrel unchanged. `zProvider` is new here —
// it validated `signInOAuth`'s input inline in packages/trpc/src/routers/auth.ts
// and was never exported, but it is vocabulary the same way the rest of this
// file is.
diff --git a/packages/core/src/modules/auth/auth.rpc.ts b/packages/core/src/modules/auth/auth.rpc.ts
index c1810034c..119fad1e9 100644
--- a/packages/core/src/modules/auth/auth.rpc.ts
+++ b/packages/core/src/modules/auth/auth.rpc.ts
@@ -14,6 +14,13 @@
// This module has no queue/cron of its own, so there is no
// `ctx.services.auth` entry here — same shape as `user`/`project`.
+import { z } from 'zod';
+import {
+ createTRPCRouter,
+ protectedProcedure,
+ publicProcedure,
+} from '../../rpc/base';
+import { TRPCAccessError } from '../../rpc/errors';
import {
zProvider,
zRequestResetPassword,
@@ -23,14 +30,7 @@ import {
zSignUpEmail,
zTotpCode,
zTotpOrRecoveryCode,
-} from '@openpanel/validation';
-import { z } from 'zod';
-import {
- createTRPCRouter,
- protectedProcedure,
- publicProcedure,
-} from '../../rpc/base';
-import { TRPCAccessError } from '../../rpc/errors';
+} from './auth.constants';
import {
disableTotp,
enableTotp,
diff --git a/packages/core/src/modules/chart/chart.rpc.ts b/packages/core/src/modules/chart/chart.rpc.ts
index 021f1faf5..a3563f033 100644
--- a/packages/core/src/modules/chart/chart.rpc.ts
+++ b/packages/core/src/modules/chart/chart.rpc.ts
@@ -11,14 +11,6 @@
// date window). The resolved report rides on `ctx.report`, as in V1, so a
// handler cannot forget to resolve it.
-import {
- zChartEventFilter,
- zChartSeries,
- zCriteria,
- zRange,
- zReportInput,
- zTimeInterval,
-} from '@openpanel/validation';
import { z } from 'zod';
import {
createTRPCRouter,
@@ -27,6 +19,14 @@ import {
type TrpcContext,
} from '../../rpc/base';
import { TRPCAccessError, TRPCForbiddenError } from '../../rpc/errors';
+import {
+ zChartEventFilter,
+ zChartSeries,
+ zCriteria,
+ zRange,
+ zReportInput,
+ zTimeInterval,
+} from '../report/report.constants';
import type { IServiceReport } from '../report/report.service';
const zShareable = z.object({
diff --git a/packages/core/src/modules/chart/chart.service.test.ts b/packages/core/src/modules/chart/chart.service.test.ts
index c404073d9..d0d7ef6da 100644
--- a/packages/core/src/modules/chart/chart.service.test.ts
+++ b/packages/core/src/modules/chart/chart.service.test.ts
@@ -12,7 +12,7 @@
*/
import { afterAll, beforeAll, describe, expect, it, mock } from 'bun:test';
-import type { IChartEventItem, IReportInput } from '@openpanel/validation';
+import type { IChartEventItem, IReportInput } from '../report/report.constants';
const TEST_PROJECT_ID = 'chart-integration-test';
const TEST_ORG_ID = 'chart-integration-org';
diff --git a/packages/core/src/modules/chart/chart.service.ts b/packages/core/src/modules/chart/chart.service.ts
index dbd98e32c..97365408f 100644
--- a/packages/core/src/modules/chart/chart.service.ts
+++ b/packages/core/src/modules/chart/chart.service.ts
@@ -18,15 +18,6 @@
// ADR-013's `sql` tag, which ADR-007 keeps in `packages/db` by name: a
// compile-time template tag, no client and no request scope.
-import type {
- FinalChart,
- IChartEventFilter,
- IChartRange,
- IChartSeries,
- ICriteria,
- IInterval,
- IReportInput,
-} from '@openpanel/validation';
import { flatten, map, pipe, prop, sort, uniq } from 'ramda';
import type { ServiceDeps } from '../../services';
import {
@@ -40,35 +31,44 @@ import {
getProfilesCached,
type IServiceProfile,
} from '../profile/profile.service';
+import type {
+ FinalChart,
+ IChartEventFilter,
+ IChartRange,
+ IChartSeries,
+ ICriteria,
+ IInterval,
+ IReportInput,
+} from '../report/report.constants';
import type { IServiceReport } from '../report/report.service';
import { mergeGlobalFilters, onlyReportEvents } from '../report/src/series';
import { createConversionService, getConversion } from './conversion.service';
import {
- buildFunnelBase,
- buildSessionsCte,
+ type buildFunnelBase,
+ type buildSessionsCte,
createFunnelService,
getFunnel,
- getFunnelCore,
- getFunnelGroup,
+ type getFunnelCore,
+ type getFunnelGroup,
getFunnelProfileIds,
- toSeries as toFunnelSeries,
+ type toSeries as toFunnelSeries,
} from './funnel.service';
import {
createRetentionService,
- getEngagementCore,
+ type getEngagementCore,
getRetentionCohort,
- getRetentionCohortCore,
- getRetentionLastSeenSeries,
- getRetentionSeries,
- getRollingActiveUsers,
- getRollingActiveUsersCore,
- getWeeklyRetentionSeriesCore,
- processCohortData,
+ type getRetentionCohortCore,
+ type getRetentionLastSeenSeries,
+ type getRetentionSeries,
+ type getRollingActiveUsers,
+ type getRollingActiveUsersCore,
+ type getWeeklyRetentionSeriesCore,
+ type processCohortData,
} from './retention.service';
import {
createSankeyService,
getSankey,
- getUserFlowCore,
+ type getUserFlowCore,
} from './sankey.service';
import {
chartBucketProfilesQuery,
diff --git a/packages/core/src/modules/chart/conversion.service.ts b/packages/core/src/modules/chart/conversion.service.ts
index d68b23d4a..bd37781aa 100644
--- a/packages/core/src/modules/chart/conversion.service.ts
+++ b/packages/core/src/modules/chart/conversion.service.ts
@@ -3,10 +3,10 @@
// byte-equivalent to V1 in src/conversion.sql.proof.md; V1's
// conversion.service is a re-export shim onto this module (DELEGATE PATTERN).
-import { NOT_SET_VALUE } from '@openpanel/constants';
-import type { IReportInput } from '@openpanel/validation';
import { omit } from 'ramda';
import type { ServiceDeps } from '../../services';
+import type { IReportInput } from '../report/report.constants';
+import { NOT_SET_VALUE } from '../report/report.constants';
import { mergeGlobalFilters, onlyReportEvents } from '../report/src/series';
import { fetchCohortsMetadata } from './src/chart-statement';
import { type ConversionGroup, conversionQuery } from './src/conversion.sql';
diff --git a/packages/core/src/modules/chart/funnel.service.ts b/packages/core/src/modules/chart/funnel.service.ts
index 8c5527163..82e80713e 100644
--- a/packages/core/src/modules/chart/funnel.service.ts
+++ b/packages/core/src/modules/chart/funnel.service.ts
@@ -3,15 +3,15 @@
// byte-equivalent to V1 in src/funnel.sql.proof.md; V1's funnel.service is a
// re-export shim onto this module (DELEGATE PATTERN).
-import { ifNaN } from '@openpanel/common';
+import { last, reverse } from 'ramda';
+import type { ServiceDeps } from '../../services';
+import { ifNaN } from '../../shared/math';
+import { getSettingsForProject } from '../organization/organization.service';
import type {
IChartBreakdown,
IChartEvent,
IReportInput,
-} from '@openpanel/validation';
-import { last, reverse } from 'ramda';
-import type { ServiceDeps } from '../../services';
-import { getSettingsForProject } from '../organization/organization.service';
+} from '../report/report.constants';
import { mergeGlobalFilters, onlyReportEvents } from '../report/src/series';
import { fetchCohortsMetadata } from './src/chart-statement';
import { collectBreakdownCohortIds } from './src/field-resolution';
diff --git a/packages/core/src/modules/chart/retention.service.test.ts b/packages/core/src/modules/chart/retention.service.test.ts
index 7669d54af..1dc6c0d07 100644
--- a/packages/core/src/modules/chart/retention.service.test.ts
+++ b/packages/core/src/modules/chart/retention.service.test.ts
@@ -1,5 +1,4 @@
import { afterAll, beforeAll, describe, expect, it } from 'bun:test';
-import { round } from '@openpanel/common';
import { chQuery, TABLE_NAMES } from '@openpanel/db/src/clickhouse/client';
import {
RETENTION_BLUEPRINT,
@@ -9,6 +8,7 @@ import {
} from '../../../../../test/retention-fixtures';
import { testServiceDeps } from '../../../test/service-deps';
import type { ServiceDeps } from '../../services';
+import { round } from '../../shared/math';
import {
getRetentionCohort,
getRetentionSeries,
diff --git a/packages/core/src/modules/chart/retention.service.ts b/packages/core/src/modules/chart/retention.service.ts
index c8e856e9c..f3f20b14c 100644
--- a/packages/core/src/modules/chart/retention.service.ts
+++ b/packages/core/src/modules/chart/retention.service.ts
@@ -7,10 +7,11 @@
// it powers the dashboard retention chart (via the tRPC `cohort` procedure) as
// well as the MCP / agent / REST retention endpoints.
-import { DateTime, round } from '@openpanel/common';
-import type { IChartEventFilter } from '@openpanel/validation';
import { range } from 'ramda';
import type { ServiceDeps } from '../../services';
+import { DateTime } from '../../shared/date';
+import { round } from '../../shared/math';
+import type { IChartEventFilter } from '../report/report.constants';
import {
type IRetentionCriteria,
type IRetentionInterval,
diff --git a/packages/core/src/modules/chart/sankey.service.ts b/packages/core/src/modules/chart/sankey.service.ts
index 236e17ec8..f814e6fe0 100644
--- a/packages/core/src/modules/chart/sankey.service.ts
+++ b/packages/core/src/modules/chart/sankey.service.ts
@@ -3,11 +3,14 @@
// byte-equivalent to V1 in src/sankey.sql.proof.md; V1's sankey.service is a
// re-export shim onto this module (DELEGATE PATTERN).
-import { chartColors } from '@openpanel/constants';
-import { type IChartEventFilter, zChartEvent } from '@openpanel/validation';
import { z } from 'zod';
import type { ServiceDeps } from '../../services';
import { getSettingsForProject } from '../organization/organization.service';
+import {
+ chartColors,
+ type IChartEventFilter,
+ zChartEvent,
+} from '../report/report.constants';
import { getEventFiltersWhereClause } from './src/filter-where';
import { runQuery } from './src/run-query';
import {
diff --git a/packages/core/src/modules/chart/src/chart-statement.ts b/packages/core/src/modules/chart/src/chart-statement.ts
index 8cc16d1a2..eb78d5c81 100644
--- a/packages/core/src/modules/chart/src/chart-statement.ts
+++ b/packages/core/src/modules/chart/src/chart-statement.ts
@@ -4,8 +4,8 @@
// the service — which imports the engine — into a cycle.
import type { SqlFragment } from '@openpanel/db/src/clickhouse/sql';
-import type { IGetChartDataInput } from '@openpanel/validation';
import type { ServiceDeps } from '../../../services';
+import type { IGetChartDataInput } from '../../report/report.constants';
import {
aggregateChartQuery,
chartSeriesQuery,
diff --git a/packages/core/src/modules/chart/src/chart.sql.test.ts b/packages/core/src/modules/chart/src/chart.sql.test.ts
index 7d275e8fe..bbd81f038 100644
--- a/packages/core/src/modules/chart/src/chart.sql.test.ts
+++ b/packages/core/src/modules/chart/src/chart.sql.test.ts
@@ -24,7 +24,10 @@
import { afterAll, beforeAll, describe, expect, it, mock } from 'bun:test';
import type { SqlFragment } from '@openpanel/db/src/clickhouse/sql';
-import type { IChartBreakdown, IChartEvent } from '@openpanel/validation';
+import type {
+ IChartBreakdown,
+ IChartEvent,
+} from '../../report/report.constants';
import type { AggregateChartSqlInput, ChartSqlInput } from './chart-statement';
const cohortFindMany = mock(async () => []);
diff --git a/packages/core/src/modules/chart/src/chart.sql.ts b/packages/core/src/modules/chart/src/chart.sql.ts
index f0ed4a4cd..1ebb30354 100644
--- a/packages/core/src/modules/chart/src/chart.sql.ts
+++ b/packages/core/src/modules/chart/src/chart.sql.ts
@@ -28,7 +28,7 @@ import type {
IChartBreakdown,
IChartEvent,
IInterval,
-} from '@openpanel/validation';
+} from '../../report/report.constants';
import { compiledText, compiledTextWithProfileRefs } from './compiled';
import { formatClickhouseDate } from './dates';
import {
diff --git a/packages/core/src/modules/chart/src/conversion.sql.ts b/packages/core/src/modules/chart/src/conversion.sql.ts
index 0ee5a8d42..e6f26b7b3 100644
--- a/packages/core/src/modules/chart/src/conversion.sql.ts
+++ b/packages/core/src/modules/chart/src/conversion.sql.ts
@@ -15,7 +15,7 @@
// introduced or removed.
import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';
-import type { IInterval } from '@openpanel/validation';
+import type { IInterval } from '../../report/report.constants';
import { compiledText } from './compiled';
import { CHART_TABLE } from './field-resolution';
diff --git a/packages/core/src/modules/chart/src/engine/compute.ts b/packages/core/src/modules/chart/src/engine/compute.ts
index 7c6d524fa..cf5095cbe 100644
--- a/packages/core/src/modules/chart/src/engine/compute.ts
+++ b/packages/core/src/modules/chart/src/engine/compute.ts
@@ -1,6 +1,6 @@
-import { round } from '@openpanel/common';
-import { alphabetIds } from '@openpanel/constants';
-import type { IChartFormula } from '@openpanel/validation';
+import { round } from '../../../../shared/math';
+import type { IChartFormula } from '../../../report/report.constants';
+import { alphabetIds } from '../../../report/report.constants';
import { evaluateFormula } from './formula';
import type { ConcreteSeries } from './types';
diff --git a/packages/core/src/modules/chart/src/engine/execute.ts b/packages/core/src/modules/chart/src/engine/execute.ts
index 069b0557b..7abd83832 100644
--- a/packages/core/src/modules/chart/src/engine/execute.ts
+++ b/packages/core/src/modules/chart/src/engine/execute.ts
@@ -1,10 +1,13 @@
-import type { FinalChart, IReportInput } from '@openpanel/validation';
import type { ServiceDeps } from '../../../../services';
import { getChartPrevStartEndDate } from '../../../../shared/date';
import {
getOrganizationSubscriptionChartEndDate,
getSettingsForProject,
} from '../../../organization/organization.service';
+import type {
+ FinalChart,
+ IReportInput,
+} from '../../../report/report.constants';
import { compute } from './compute';
import { fetch, fetchAggregate } from './fetch';
import { format } from './format';
diff --git a/packages/core/src/modules/chart/src/engine/fetch.ts b/packages/core/src/modules/chart/src/engine/fetch.ts
index 0054b0d2e..35fe0bb89 100644
--- a/packages/core/src/modules/chart/src/engine/fetch.ts
+++ b/packages/core/src/modules/chart/src/engine/fetch.ts
@@ -1,13 +1,13 @@
-import type { ISerieDataItem } from '@openpanel/common';
-import { groupByLabels } from '@openpanel/common';
-import { alphabetIds } from '@openpanel/constants';
+import type { ServiceDeps } from '../../../../services';
+import type { ISerieDataItem } from '../../../../shared/group-by-labels';
+import { groupByLabels } from '../../../../shared/group-by-labels';
import type {
IChartBreakdown,
IChartEventFilter,
IChartEventItem,
IGetChartDataInput,
-} from '@openpanel/validation';
-import type { ServiceDeps } from '../../../../services';
+} from '../../../report/report.constants';
+import { alphabetIds } from '../../../report/report.constants';
import { getAggregateChartSql, getChartSql } from '../chart-statement';
import { runQuery } from '../run-query';
import type { NormalizedInput } from './normalize';
diff --git a/packages/core/src/modules/chart/src/engine/format.ts b/packages/core/src/modules/chart/src/engine/format.ts
index 430919721..9c687e599 100644
--- a/packages/core/src/modules/chart/src/engine/format.ts
+++ b/packages/core/src/modules/chart/src/engine/format.ts
@@ -4,11 +4,11 @@ import {
max,
min,
round,
- slug,
sum,
-} from '@openpanel/common';
-import { alphabetIds } from '@openpanel/constants';
-import type { FinalChart } from '@openpanel/validation';
+} from '../../../../shared/math';
+import { slug } from '../../../../shared/slug';
+import type { FinalChart } from '../../../report/report.constants';
+import { alphabetIds } from '../../../report/report.constants';
import type { ConcreteSeries } from './types';
/**
diff --git a/packages/core/src/modules/chart/src/engine/formula.ts b/packages/core/src/modules/chart/src/engine/formula.ts
index 55eff6c1c..4e72e9227 100644
--- a/packages/core/src/modules/chart/src/engine/formula.ts
+++ b/packages/core/src/modules/chart/src/engine/formula.ts
@@ -1,5 +1,5 @@
-import { alphabetIds } from '@openpanel/constants';
import * as mathjs from 'mathjs';
+import { alphabetIds } from '../../../report/report.constants';
/**
* Chart formulas are a tiny arithmetic language, not a general mathjs program.
diff --git a/packages/core/src/modules/chart/src/engine/normalize.ts b/packages/core/src/modules/chart/src/engine/normalize.ts
index f9bb30849..98908f888 100644
--- a/packages/core/src/modules/chart/src/engine/normalize.ts
+++ b/packages/core/src/modules/chart/src/engine/normalize.ts
@@ -1,12 +1,12 @@
-import { alphabetIds } from '@openpanel/constants';
+import type { ServiceDeps } from '../../../../services';
+import { getChartStartEndDate } from '../../../../shared/date';
+import { getSettingsForProject } from '../../../organization/organization.service';
import type {
IChartEvent,
IReportInput,
IReportInputWithDates,
-} from '@openpanel/validation';
-import type { ServiceDeps } from '../../../../services';
-import { getChartStartEndDate } from '../../../../shared/date';
-import { getSettingsForProject } from '../../../organization/organization.service';
+} from '../../../report/report.constants';
+import { alphabetIds } from '../../../report/report.constants';
import { mergeGlobalFilters } from '../../../report/src/series';
import type { SeriesDefinition } from './types';
diff --git a/packages/core/src/modules/chart/src/engine/plan.ts b/packages/core/src/modules/chart/src/engine/plan.ts
index 8746cc9f4..490b2ede4 100644
--- a/packages/core/src/modules/chart/src/engine/plan.ts
+++ b/packages/core/src/modules/chart/src/engine/plan.ts
@@ -1,8 +1,8 @@
-import { slug } from '@openpanel/common';
-import { alphabetIds } from '@openpanel/constants';
-import type { IChartEventItem } from '@openpanel/validation';
import type { ServiceDeps } from '../../../../services';
+import { slug } from '../../../../shared/slug';
import { getSettingsForProject } from '../../../organization/organization.service';
+import type { IChartEventItem } from '../../../report/report.constants';
+import { alphabetIds } from '../../../report/report.constants';
import type { NormalizedInput } from './normalize';
import type { ConcreteSeries, Plan } from './types';
diff --git a/packages/core/src/modules/chart/src/engine/types.ts b/packages/core/src/modules/chart/src/engine/types.ts
index c5d4fe114..810d3a958 100644
--- a/packages/core/src/modules/chart/src/engine/types.ts
+++ b/packages/core/src/modules/chart/src/engine/types.ts
@@ -2,7 +2,7 @@ import type {
IChartEventFilter,
IChartEventItem,
IReportInputWithDates,
-} from '@openpanel/validation';
+} from '../../../report/report.constants';
/** What the user asked for: one event or formula series from the report. */
export type SeriesDefinition = IChartEventItem;
diff --git a/packages/core/src/modules/chart/src/field-resolution.ts b/packages/core/src/modules/chart/src/field-resolution.ts
index 63fd1e258..6463a39b9 100644
--- a/packages/core/src/modules/chart/src/field-resolution.ts
+++ b/packages/core/src/modules/chart/src/field-resolution.ts
@@ -13,8 +13,8 @@
// through compiled.ts — the one bridge — and binds every chart-level value
// (project id, event name, dates, timezone, cohort ids/names, limits) itself.
-import type { IChartBreakdown } from '@openpanel/validation';
import sqlstring from 'sqlstring';
+import type { IChartBreakdown } from '../../report/report.constants';
export const CHART_TABLE = {
events: 'events',
diff --git a/packages/core/src/modules/chart/src/filter-cast.ts b/packages/core/src/modules/chart/src/filter-cast.ts
index c479670c0..27707a7f8 100644
--- a/packages/core/src/modules/chart/src/filter-cast.ts
+++ b/packages/core/src/modules/chart/src/filter-cast.ts
@@ -2,12 +2,13 @@
// Moved from packages/db/src/services/filter-cast.ts (M8-005) — the typed-cast
// half of `buildFilterWhere` (./table-filter-where.ts), which is the only
// caller. `./filter-where.ts` (the event-property compiler) imports it too.
+
+import sqlstring from 'sqlstring';
import type {
IChartEventFilterOperator,
IChartEventFilterValue,
IChartFilterValueType,
-} from '@openpanel/validation';
-import sqlstring from 'sqlstring';
+} from '../../report/report.constants';
/**
* Wrap a SQL expression (a column accessor or an already-escaped value literal)
@@ -53,19 +54,16 @@ export function hasTypedCast(
// Equality + comparison operators where a declared cast type changes the SQL.
// String-only operators (contains/startsWith/regex/…) and null checks are
// unaffected and keep their existing handling.
-const TYPED_SQL_OPERATOR: Partial<Record<IChartEventFilterOperator, string>> =
- {
- is: '=',
- isNot: '!=',
- gt: '>',
- gte: '>=',
- lt: '<',
- lte: '<=',
- };
+const TYPED_SQL_OPERATOR: Partial<Record<IChartEventFilterOperator, string>> = {
+ is: '=',
+ isNot: '!=',
+ gt: '>',
+ gte: '>=',
+ lt: '<',
+ lte: '<=',
+};
-export function isTypedOperator(
- operator: IChartEventFilterOperator
-): boolean {
+export function isTypedOperator(operator: IChartEventFilterOperator): boolean {
return operator in TYPED_SQL_OPERATOR;
}
diff --git a/packages/core/src/modules/chart/src/filter-where.ts b/packages/core/src/modules/chart/src/filter-where.ts
index 582afa230..8a1ec8d57 100644
--- a/packages/core/src/modules/chart/src/filter-where.ts
+++ b/packages/core/src/modules/chart/src/filter-where.ts
@@ -6,15 +6,10 @@
// splicing their output into text builders. Core splices it through
// compiled.ts, the one text bridge.
-import { stripLeadingAndTrailingSlashes } from '@openpanel/common';
-import type { IChartEventFilter } from '@openpanel/validation';
-import { getCohortIds } from '@openpanel/validation';
import sqlstring from 'sqlstring';
-import {
- buildTypedClause,
- hasTypedCast,
- isTypedOperator,
-} from './filter-cast';
+import { stripLeadingAndTrailingSlashes } from '../../../shared/string';
+import type { IChartEventFilter } from '../../report/report.constants';
+import { getCohortIds } from '../../report/report.constants';
import {
CHART_TABLE,
EVENT_FIELD_ALIASES,
@@ -24,6 +19,7 @@ import {
isNumericColumn,
normalizeEventField,
} from './field-resolution';
+import { buildTypedClause, hasTypedCast, isTypedOperator } from './filter-cast';
export type FilterTableScope = 'events' | 'sessions';
diff --git a/packages/core/src/modules/chart/src/funnel.sql.test.ts b/packages/core/src/modules/chart/src/funnel.sql.test.ts
index 9afda9ed7..78754b722 100644
--- a/packages/core/src/modules/chart/src/funnel.sql.test.ts
+++ b/packages/core/src/modules/chart/src/funnel.sql.test.ts
@@ -22,7 +22,10 @@
import { afterAll, beforeAll, describe, expect, it, mock } from 'bun:test';
import type { SqlFragment } from '@openpanel/db/src/clickhouse/sql';
-import type { IChartBreakdown, IReportInput } from '@openpanel/validation';
+import type {
+ IChartBreakdown,
+ IReportInput,
+} from '../../report/report.constants';
const COHORT_ID = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';
const cohortFindMany = mock(async () => [
diff --git a/packages/core/src/modules/chart/src/funnel.sql.ts b/packages/core/src/modules/chart/src/funnel.sql.ts
index 2e6aa4415..cefc0685e 100644
--- a/packages/core/src/modules/chart/src/funnel.sql.ts
+++ b/packages/core/src/modules/chart/src/funnel.sql.ts
@@ -23,7 +23,10 @@
// no `IN (subquery)` is introduced or removed.
import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';
-import type { IChartBreakdown, IChartEvent } from '@openpanel/validation';
+import type {
+ IChartBreakdown,
+ IChartEvent,
+} from '../../report/report.constants';
import { compiledText, compiledTextWithProfileRefs } from './compiled';
import {
buildInlineCohortJoin,
diff --git a/packages/core/src/modules/chart/src/retention.sql.ts b/packages/core/src/modules/chart/src/retention.sql.ts
index 202a81592..6a60eeeb5 100644
--- a/packages/core/src/modules/chart/src/retention.sql.ts
+++ b/packages/core/src/modules/chart/src/retention.sql.ts
@@ -14,7 +14,7 @@
// so no `IN` / `GLOBAL IN` decision is made or unmade here.
import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';
-import type { IChartEventFilter } from '@openpanel/validation';
+import type { IChartEventFilter } from '../../report/report.constants';
import { compiledText } from './compiled';
import { CHART_TABLE } from './field-resolution';
import { getEventFiltersWhereClause } from './filter-where';
diff --git a/packages/core/src/modules/chart/src/table-filter-where.test.ts b/packages/core/src/modules/chart/src/table-filter-where.test.ts
index 82d14cb59..31f22e7cf 100644
--- a/packages/core/src/modules/chart/src/table-filter-where.test.ts
+++ b/packages/core/src/modules/chart/src/table-filter-where.test.ts
@@ -9,10 +9,14 @@
* dropped when it does not, which is what the `group.*` and `session.*`
* branches already did.
*/
-import { TABLE_NAMES } from '@openpanel/db/src/clickhouse/client';
-import type { IChartEventFilter } from '@openpanel/validation';
+
import { describe, expect, it } from 'bun:test';
-import { buildFilterWhere, type FilterTableContext } from './table-filter-where';
+import { TABLE_NAMES } from '@openpanel/db/src/clickhouse/client';
+import type { IChartEventFilter } from '../../report/report.constants';
+import {
+ buildFilterWhere,
+ type FilterTableContext,
+} from './table-filter-where';
const PROJECT_ID = 'p';
diff --git a/packages/core/src/modules/chart/src/table-filter-where.ts b/packages/core/src/modules/chart/src/table-filter-where.ts
index b96493b06..da48ccb9d 100644
--- a/packages/core/src/modules/chart/src/table-filter-where.ts
+++ b/packages/core/src/modules/chart/src/table-filter-where.ts
@@ -12,12 +12,12 @@
// packages/db's non-`skipTime` branch, and `./field-resolution.CHART_TABLE`,
// which already carried all four physical table names used below.
+import sqlstring from 'sqlstring';
import {
getCohortIds,
type IChartEventFilter,
type IChartFilterValueType,
-} from '@openpanel/validation';
-import sqlstring from 'sqlstring';
+} from '../../report/report.constants';
import { formatClickhouseDate } from './dates';
import { CHART_TABLE } from './field-resolution';
import { buildTypedClause, hasTypedCast, isTypedOperator } from './filter-cast';
diff --git a/packages/core/src/modules/cohort/cohort.constants.ts b/packages/core/src/modules/cohort/cohort.constants.ts
index 847705455..3eabb38d1 100644
--- a/packages/core/src/modules/cohort/cohort.constants.ts
+++ b/packages/core/src/modules/cohort/cohort.constants.ts
@@ -3,12 +3,12 @@
// becomes a re-export shim of this file's `./modules/cohort/cohort.constants`
// subpath (same shape as packages/db/src/gsc.ts since M5-002), so
// apps/start and packages/db/src/types.ts keep resolving these symbols
-// through @openpanel/validation's existing barrel unchanged.
+// through packages/validation's existing barrel unchanged.
//
// Isomorphic by the AGENTS.md rule: zod, another `*.constants.ts`, or
// nothing. `zChartEventFilter` used to be a diverged local copy here
// (TODO(P7) in M5-003) to dodge a TDZ from importing it through
-// @openpanel/validation's barrel before that barrel finished initializing;
+// packages/validation's barrel before that barrel finished initializing;
// now that it lives in report.constants.ts — an isomorphic, cycle-free
// sibling — importing it directly is safe, and the duplicate is gone
// (M7-006).
diff --git a/packages/core/src/modules/cohort/cohort.rpc.ts b/packages/core/src/modules/cohort/cohort.rpc.ts
index 9d2c3c45e..c65d97aee 100644
--- a/packages/core/src/modules/cohort/cohort.rpc.ts
+++ b/packages/core/src/modules/cohort/cohort.rpc.ts
@@ -14,13 +14,13 @@
// directly, matching V1's router — cohort.service.ts owns only the
// compute-heavy and ClickHouse-touching operations, same split as V1.
-// The canonical zChartEventFilter, not cohort.constants.ts's private
-// TDZ-workaround copy — matches V1's router, which imports it from
-// @openpanel/validation's barrel rather than from cohort.validation.ts.
-import { zChartEventFilter } from '@openpanel/validation';
import { z } from 'zod';
import { createTRPCRouter, protectedProcedure } from '../../rpc/base';
import { TRPCAccessError, TRPCNotFoundError } from '../../rpc/errors';
+// The canonical zChartEventFilter, not cohort.constants.ts's private
+// TDZ-workaround copy — matches V1's router, which imports it from
+// packages/validation's barrel rather than from cohort.validation.ts.
+import { zChartEventFilter } from '../report/report.constants';
import {
zCohortDefinition,
zCohortInput,
diff --git a/packages/core/src/modules/cohort/cohort.service.ts b/packages/core/src/modules/cohort/cohort.service.ts
index 1c1c05aea..bb86bdab7 100644
--- a/packages/core/src/modules/cohort/cohort.service.ts
+++ b/packages/core/src/modules/cohort/cohort.service.ts
@@ -35,12 +35,12 @@
// module's own rpc mutations and its cron fragment).
import type { ClickHouseSettings } from '@clickhouse/client';
-import type { IChartEventFilter } from '@openpanel/validation';
import sqlstring from 'sqlstring';
import type { ServiceDeps } from '../../services';
import { chQuery } from '../../shared/ch-query';
import { getReplicatedTableName } from '../../shared/ch-tables';
import type { IServiceProfile } from '../profile/profile.service';
+import type { IChartEventFilter } from '../report/report.constants';
import type {
CohortDefinition,
EventBasedCohortDefinition,
@@ -367,9 +367,7 @@ export async function computeEventBasedCohort(
const finalQuery = limit ? `${combinedQuery} LIMIT ${limit}` : combinedQuery;
- const results = await chQuery<{ profile_id: string }>(
- deps,
- finalQuery);
+ const results = await chQuery<{ profile_id: string }>(deps, finalQuery);
return results.map((r) => r.profile_id);
}
@@ -390,9 +388,7 @@ export async function countEventBasedCohort(
: queries.join(' UNION DISTINCT ');
const countQuery = `SELECT count() as count FROM (${combinedQuery})`;
- const results = await chQuery<{ count: number }>(
- deps,
- countQuery);
+ const results = await chQuery<{ count: number }>(deps, countQuery);
return results[0]?.count ?? 0;
}
@@ -539,7 +535,7 @@ export async function computePropertyBasedCohort(
const results = await chQuery<{ profile_id: string }>(
deps,
-
+
buildPropertyBasedCohortQuery(projectId, definition, limit),
PROFILE_COHORT_QUERY_SETTINGS
);
@@ -557,7 +553,7 @@ export async function countPropertyBasedCohort(
const results = await chQuery<{ count: number }>(
deps,
-
+
`SELECT count() as count FROM (${buildPropertyBasedCohortQuery(projectId, definition)})`,
PROFILE_COHORT_QUERY_SETTINGS
);
@@ -635,7 +631,8 @@ export async function getCohortMembers(
const results = await chQuery<{ profile_id: string; total: number }>(
deps,
- query);
+ query
+ );
return {
profileIds: results.map((r) => r.profile_id),
total: results[0]?.total || 0,
@@ -670,7 +667,8 @@ export async function getCohortCount(
FROM ${TABLE.cohortMembers} FINAL
WHERE project_id = ${sqlstring.escape(projectId)}
AND cohort_id = ${sqlstring.escape(cohortId)}
- `);
+ `
+ );
return result[0]?.count || 0;
}
@@ -795,20 +793,21 @@ export async function listRefreshableCohortIds(
export async function listCohortMemberProfiles(
deps: ServiceDeps,
{
- projectId,
- cohortId,
- cursor,
- take,
- search,
- filters,
-}: {
- projectId: string;
- cohortId: string;
- cursor?: number;
- take: number;
- search?: string;
- filters?: IChartEventFilter[];
-}): Promise<{ data: IServiceProfile[]; count: number }> {
+ projectId,
+ cohortId,
+ cursor,
+ take,
+ search,
+ filters,
+ }: {
+ projectId: string;
+ cohortId: string;
+ cursor?: number;
+ take: number;
+ search?: string;
+ filters?: IChartEventFilter[];
+ }
+): Promise<{ data: IServiceProfile[]; count: number }> {
const { buildFilterWhere } = await import('../chart/src/table-filter-where');
const { profileSearchSql } = await import('../profile/profile.service');
// M10-005: `getProfiles` takes `ServiceDeps` now and this function has none
@@ -848,7 +847,8 @@ export async function listCohortMemberProfiles(
${extraConditionSql}
ORDER BY created_at DESC
LIMIT ${take} OFFSET ${offset}
- `);
+ `
+ );
const count = rows[0]?.total_count ?? 0;
const ids = rows.map((r) => r.id);
@@ -885,7 +885,8 @@ export async function getCohortMemberEvents(
GROUP BY name
ORDER BY count DESC
LIMIT ${limit}
- `);
+ `
+ );
}
export async function getCohortEventsPerDay(
@@ -914,7 +915,8 @@ export async function getCohortEventsPerDay(
FROM toDate(now() - INTERVAL ${days} DAY)
TO toDate(now() + INTERVAL 1 DAY)
STEP INTERVAL 1 DAY
- `);
+ `
+ );
return rows.map((r) => ({ date: String(r.date), count: Number(r.count) }));
}
@@ -940,7 +942,8 @@ export async function getCohortMemberRoutes(
GROUP BY path
ORDER BY count DESC
LIMIT ${limit}
- `);
+ `
+ );
}
export interface CohortService {
diff --git a/packages/core/src/modules/email/email.constants.ts b/packages/core/src/modules/email/email.constants.ts
index 467ac8671..3752853e5 100644
--- a/packages/core/src/modules/email/email.constants.ts
+++ b/packages/core/src/modules/email/email.constants.ts
@@ -1,6 +1,6 @@
// Moved from packages/constants/index.ts (M6-004, ADR-008's module map:
// email owns "C"). packages/constants re-exports these for existing
-// @openpanel/constants importers — same shape as packages/constants/index.ts's
+// packages/constants importers — same shape as packages/constants/index.ts's
// `ProjectTypeNames` re-export since M6-002.
//
// Keys must match the template `category` in @openpanel/email. Each entry's
diff --git a/packages/core/src/modules/event/event.rpc.ts b/packages/core/src/modules/event/event.rpc.ts
index cc012881f..032fa3244 100644
--- a/packages/core/src/modules/event/event.rpc.ts
+++ b/packages/core/src/modules/event/event.rpc.ts
@@ -15,11 +15,6 @@
// so the three-way lazy `import('@openpanel/core')` hop this file used to make
// for it is gone.
-import {
- zChartEventFilter,
- zRange,
- zTimeInterval,
-} from '@openpanel/validation';
import { z } from 'zod';
import {
createTRPCRouter,
@@ -29,6 +24,11 @@ import {
import { TRPCAccessError, TRPCNotFoundError } from '../../rpc/errors';
import { getChartStartEndDate } from '../../shared/date';
import { getSettingsForProject } from '../organization/organization.service';
+import {
+ zChartEventFilter,
+ zRange,
+ zTimeInterval,
+} from '../report/report.constants';
import {
getBotEventsPage,
getConversionEventNames,
diff --git a/packages/core/src/modules/event/event.service.ts b/packages/core/src/modules/event/event.service.ts
index bb1a4d1c2..696b7e28a 100644
--- a/packages/core/src/modules/event/event.service.ts
+++ b/packages/core/src/modules/event/event.service.ts
@@ -26,16 +26,15 @@
// from `shared/` (docs/TECH_DEBT.md §2, §4). What stays lazy is named and
// argued at each remaining `load*` below; none of them reach @openpanel/db.
-import { DateTime, toDots } from '@openpanel/common';
import type { SqlFragment } from '@openpanel/db/src/clickhouse/sql';
import type { EventMeta, Prisma } from '@openpanel/db/src/prisma-client';
-import type { IChartEventFilter } from '@openpanel/validation';
import { clone, mergeDeepRight, uniq } from 'ramda';
import type { ServiceDeps } from '../../services';
import { cacheablePerDeps } from '../../shared/cacheable-per-deps';
import { chQuery } from '../../shared/ch-query';
-import { resolveDateRange } from '../../shared/date';
+import { DateTime, resolveDateRange } from '../../shared/date';
import { resolveMaxLookbackDays } from '../../shared/lookback';
+import { toDots } from '../../shared/object';
import { getEventFiltersWhereClause } from '../chart/src/filter-where';
import {
getProfileById,
@@ -44,6 +43,7 @@ import {
type IServiceUpsertProfile,
upsertProfile,
} from '../profile/profile.service';
+import type { IChartEventFilter } from '../report/report.constants';
import type { IClickhouseSession } from '../session/session.service';
import { convertClickhouseDateToJs, formatClickhouseDate } from './src/dates';
import {
diff --git a/packages/core/src/modules/export/export.routes.ts b/packages/core/src/modules/export/export.routes.ts
index cf4bb16e7..e2255a0c1 100644
--- a/packages/core/src/modules/export/export.routes.ts
+++ b/packages/core/src/modules/export/export.routes.ts
@@ -26,20 +26,12 @@
// what `defineRoutes`'s `const T` inference can carry, same reason every
// other module here writes its routes as one static `.get()`/`.post()` chain.
-import { DateTime } from '@openpanel/common';
-import { getDefaultIntervalByDates } from '@openpanel/constants';
-import {
- zChartEvent,
- zChartEventFilter,
- zRange,
- zReport,
-} from '@openpanel/validation';
import { z } from 'zod';
import type { Ctx } from '../../context';
import type { ClientType } from '../../http/client-auth';
import { defineRoutes } from '../../http/define';
import { parseQueryStringTransform } from '../../http/query';
-import { getChartStartEndDate } from '../../shared/date';
+import { DateTime, getChartStartEndDate } from '../../shared/date';
import { HttpError } from '../../shared/errors';
import type { GetEventListOptions } from '../event/event.service';
import {
@@ -84,6 +76,13 @@ import {
getProfileSessionsCore,
getProfileWithEvents,
} from '../profile/profile.service';
+import {
+ getDefaultIntervalByDates,
+ zChartEvent,
+ zChartEventFilter,
+ zRange,
+ zReport,
+} from '../report/report.constants';
import { querySessionsCore } from '../session/session.service';
import {
resolveExportProjectId,
diff --git a/packages/core/src/modules/export/export.service.ts b/packages/core/src/modules/export/export.service.ts
index 708362261..6a8f6531c 100644
--- a/packages/core/src/modules/export/export.service.ts
+++ b/packages/core/src/modules/export/export.service.ts
@@ -13,11 +13,11 @@
// this package's own barrel (`@openpanel/core`) mid-evaluation, which a
// relative import cannot do (docs/TECH_DEBT.md §4).
-import type { IChartRange } from '@openpanel/validation';
import type { AuthenticatedClient } from '../../http/client-auth';
import type { ServiceDeps } from '../../services';
import { getChartStartEndDate, resolveDateRange } from '../../shared/date';
import { getSettingsForProject } from '../organization/organization.service';
+import type { IChartRange } from '../report/report.constants';
// project.service.ts's `resolveClientProjectId` takes `ServiceDeps` now
// (M10-004); `resolveInsightsProjectId` below is called from ~35 route
diff --git a/packages/core/src/modules/group/group.constants.ts b/packages/core/src/modules/group/group.constants.ts
index dafa3d641..6383218c3 100644
--- a/packages/core/src/modules/group/group.constants.ts
+++ b/packages/core/src/modules/group/group.constants.ts
@@ -2,7 +2,7 @@
// group owns "C"). validation's index re-exports this file's
// `./modules/group/group.constants` subpath, so packages/trpc's group router
// and apps/start's add-group / edit-group modals keep resolving these symbols
-// through @openpanel/validation unchanged.
+// through packages/validation unchanged.
//
// Isomorphic by the AGENTS.md rule: zod and nothing else.
diff --git a/packages/core/src/modules/group/group.service.ts b/packages/core/src/modules/group/group.service.ts
index ce53d5d07..3b07907b4 100644
--- a/packages/core/src/modules/group/group.service.ts
+++ b/packages/core/src/modules/group/group.service.ts
@@ -12,9 +12,9 @@
// through `deps.ch.insert`. The `loadChClient` lazy loader is gone
// (docs/TECH_DEBT.md §2, §4).
-import { toDots } from '@openpanel/common';
import type { ServiceDeps } from '../../services';
import { chQuery } from '../../shared/ch-query';
+import { toDots } from '../../shared/object';
import { getProfiles, type IServiceProfile } from '../profile/profile.service';
import { formatClickhouseDate, toNullIfDefaultMinDate } from './src/dates';
import {
diff --git a/packages/core/src/modules/gsc/gsc.rpc.ts b/packages/core/src/modules/gsc/gsc.rpc.ts
index e2de6ffef..58757f128 100644
--- a/packages/core/src/modules/gsc/gsc.rpc.ts
+++ b/packages/core/src/modules/gsc/gsc.rpc.ts
@@ -10,7 +10,6 @@
// The per-project access ladder itself is bound once, in auth.service.ts
// (M10-002); every procedure here reaches it through `ctx.services.auth`.
-import { zRange, zTimeInterval } from '@openpanel/validation';
import { z } from 'zod';
import {
createTRPCRouter,
@@ -19,6 +18,7 @@ import {
} from '../../rpc/base';
import { TRPCAccessError } from '../../rpc/errors';
import { Arctic, googleGsc } from '../auth/auth.service';
+import { zRange, zTimeInterval } from '../report/report.constants';
const OAUTH_COOKIE_MAX_AGE_SECONDS = 60 * 10;
diff --git a/packages/core/src/modules/import/import.constants.ts b/packages/core/src/modules/import/import.constants.ts
index 5ee8b2755..3af36ad88 100644
--- a/packages/core/src/modules/import/import.constants.ts
+++ b/packages/core/src/modules/import/import.constants.ts
@@ -3,7 +3,7 @@
// packages/validation/src/import.validation.ts becomes a re-export shim of
// this file (same shape as packages/validation/src/cohort.validation.ts since
// M5-003), so apps/start and packages/db/src/types.ts keep resolving these
-// symbols through @openpanel/validation's existing barrel unchanged.
+// symbols through packages/validation's existing barrel unchanged.
//
// Isomorphic by the AGENTS.md rule: zod and nothing else.
diff --git a/packages/core/src/modules/import/import.service.ts b/packages/core/src/modules/import/import.service.ts
index 19d66afd8..6cd83545f 100644
--- a/packages/core/src/modules/import/import.service.ts
+++ b/packages/core/src/modules/import/import.service.ts
@@ -19,7 +19,6 @@
// and this module's queries haven't been converted yet.
import { createHash } from 'node:crypto';
-import { toDots } from '@openpanel/common';
import type { Prisma } from '@openpanel/db/src/prisma-client';
import { createLogger, type ILogger } from '../../clients/logger';
import type { Logger } from '../../logger';
@@ -29,6 +28,7 @@ import {
formatClickhouseDate,
} from '../../shared/ch-dates';
import { getReplicatedTableName, TABLE_NAMES } from '../../shared/ch-tables';
+import { toDots } from '../../shared/object';
import type { IClickhouseEvent } from '../event/event.service';
import type { IClickhouseProfile } from '../profile/profile.service';
import type { IImportConfig } from './import.constants';
diff --git a/packages/core/src/modules/import/src/providers/amplitude.ts b/packages/core/src/modules/import/src/providers/amplitude.ts
index f2f8ea060..fc6ff14d2 100644
--- a/packages/core/src/modules/import/src/providers/amplitude.ts
+++ b/packages/core/src/modules/import/src/providers/amplitude.ts
@@ -2,16 +2,17 @@ import { randomUUID } from 'node:crypto';
import { createInterface } from 'node:readline';
import { Readable } from 'node:stream';
import { createBrotliDecompress, createGunzip } from 'node:zlib';
-import { isSameDomain, parsePath, toDots } from '@openpanel/common';
import unzipper from 'unzipper';
import { z } from 'zod';
import type { Logger } from '../../../../logger';
// core's own date helper, not @openpanel/db's — see umami.ts's header.
import { formatClickhouseDate } from '../../../../shared/ch-dates';
+import { toDots } from '../../../../shared/object';
import {
getReferrerWithQuery,
parseReferrer,
} from '../../../../shared/parse-referrer';
+import { isSameDomain, parsePath } from '../../../../shared/url';
import type { IClickhouseEvent } from '../../../event/event.service';
import type { IClickhouseProfile } from '../../../profile/profile.service';
import type { IAmplitudeImportConfig } from '../../import.constants';
diff --git a/packages/core/src/modules/import/src/providers/mixpanel.ts b/packages/core/src/modules/import/src/providers/mixpanel.ts
index f7670e0ae..da76ea051 100644
--- a/packages/core/src/modules/import/src/providers/mixpanel.ts
+++ b/packages/core/src/modules/import/src/providers/mixpanel.ts
@@ -1,9 +1,9 @@
import { randomUUID } from 'node:crypto';
-import { isSameDomain, parsePath, toDots } from '@openpanel/common';
import { z } from 'zod';
import type { Logger } from '../../../../logger';
// core's own date helper, not @openpanel/db's — see umami.ts's header.
import { formatClickhouseDate } from '../../../../shared/ch-dates';
+import { toDots } from '../../../../shared/object';
import {
getReferrerWithQuery,
parseReferrer,
@@ -12,6 +12,7 @@ import {
parseUserAgent,
type UserAgentInfo,
} from '../../../../shared/parser-user-agent';
+import { isSameDomain, parsePath } from '../../../../shared/url';
import type { IClickhouseEvent } from '../../../event/event.service';
import type { IClickhouseProfile } from '../../../profile/profile.service';
import type { IMixpanelImportConfig } from '../../import.constants';
diff --git a/packages/core/src/modules/import/src/providers/umami.ts b/packages/core/src/modules/import/src/providers/umami.ts
index f6237dd6a..ac51364ad 100644
--- a/packages/core/src/modules/import/src/providers/umami.ts
+++ b/packages/core/src/modules/import/src/providers/umami.ts
@@ -2,7 +2,6 @@ import { randomUUID } from 'node:crypto';
import { Readable } from 'node:stream';
import { pipeline } from 'node:stream/promises';
import { createBrotliDecompress, createGunzip } from 'node:zlib';
-import { isSameDomain, parsePath, toDots } from '@openpanel/common';
import { parse } from 'csv-parse';
import { assocPath } from 'ramda';
import { z } from 'zod';
@@ -13,12 +12,14 @@ import type { Logger } from '../../../../logger';
// worker threads, AGENTS.md's eager-barrel-chain hazard) and is a value
// import of `@openpanel/db` from core. See shared/ch-dates.ts's header.
import { formatClickhouseDate } from '../../../../shared/ch-dates';
+import { toDots } from '../../../../shared/object';
import {
getReferrerWithQuery,
parseReferrer,
} from '../../../../shared/parse-referrer';
import { generateDeviceId } from '../../../../shared/profileId';
import { safeFetchStream } from '../../../../shared/safe-fetch';
+import { isSameDomain, parsePath } from '../../../../shared/url';
import type { IClickhouseEvent } from '../../../event/event.service';
import type { IUmamiImportConfig } from '../../import.constants';
import { BaseImportProvider } from '../base-provider';
diff --git a/packages/core/src/modules/ingest/ingest.constants.ts b/packages/core/src/modules/ingest/ingest.constants.ts
index 17b5293e4..2a50fd571 100644
--- a/packages/core/src/modules/ingest/ingest.constants.ts
+++ b/packages/core/src/modules/ingest/ingest.constants.ts
@@ -1,6 +1,6 @@
// The ingestion wire contract (M8-002, ADR-008's module map: ingest owns "C").
// Moved from packages/validation/src/track.validation.ts,
-// packages/validation/src/event-blocklist.ts and @openpanel/constants'
+// packages/validation/src/event-blocklist.ts and packages/constants'
// RESERVED_EVENT_NAMES — all three enforce the same thing (what a caller may
// name an event and what a track body may contain), so they are one file here.
// packages/validation and packages/constants re-export this; the SDK deep-import
@@ -143,8 +143,8 @@ export function isBlockedEventName(name: string): boolean {
// These interfaces are duplicated in code that ships in our SDK type
// declarations. We hand-write them (instead of using `z.infer<…>`) so:
// 1. Generated `.d.ts` files for the SDKs are readable plain TypeScript
-// with no `import type { ITrackPayload } from '@openpanel/validation'`
-// lines (the package isn't published).
+// with no `import type { ITrackPayload }` line pointing at a workspace
+// package (none of them are published).
// 2. The interfaces stay clean — no zod internals leaking through.
// Each schema below has `satisfies z.ZodType<…>` attached so a drift
// between the interface and the schema fails to compile.
diff --git a/packages/core/src/modules/ingest/ingest.service.ts b/packages/core/src/modules/ingest/ingest.service.ts
index abedc9af8..acae09837 100644
--- a/packages/core/src/modules/ingest/ingest.service.ts
+++ b/packages/core/src/modules/ingest/ingest.service.ts
@@ -13,7 +13,6 @@
// workaround and no longer travels through `AppDeps` — it stays an argument
// only so a test can assert on what was produced without a broker.
-import { generateId } from '@openpanel/common';
import { assocPath, pathOr, pick } from 'ramda';
import { v4 as uuid } from 'uuid';
import type { Buffers } from '../../buffers/create-buffers';
@@ -26,6 +25,7 @@ import {
} from '../../clients/geo';
import type { Logger } from '../../logger';
import type { ServiceDeps } from '../../services';
+import { generateId } from '../../shared/id';
import { parseUserAgent } from '../../shared/parser-user-agent';
import { generateDeviceId } from '../../shared/profileId';
import { createBotEvent } from '../event/event.service';
diff --git a/packages/core/src/modules/ingest/src/client-auth.ts b/packages/core/src/modules/ingest/src/client-auth.ts
index b2c133497..236d05821 100644
--- a/packages/core/src/modules/ingest/src/client-auth.ts
+++ b/packages/core/src/modules/ingest/src/client-auth.ts
@@ -13,13 +13,13 @@
// ADR-011 leaves to Carl, not to a port.
import { getCache } from '@openpanel/redis';
-import type {
- IProjectFilterIp,
- IProjectFilterProfileId,
-} from '@openpanel/validation';
import { path } from 'ramda';
import { verifyPassword } from '../../../shared/crypto';
import type { IServiceClientWithProject } from '../../client/client.service';
+import type {
+ IProjectFilterIp,
+ IProjectFilterProfileId,
+} from '../../project/project.constants';
import { headerValue, type IngestHeaders } from './headers';
export type { IngestHeaders } from './headers';
diff --git a/packages/core/src/modules/ingest/src/incoming-event-handler.ts b/packages/core/src/modules/ingest/src/incoming-event-handler.ts
index e701837b9..0d45addb0 100644
--- a/packages/core/src/modules/ingest/src/incoming-event-handler.ts
+++ b/packages/core/src/modules/ingest/src/incoming-event-handler.ts
@@ -11,16 +11,16 @@
// the row the consumer writes (ADR-018 R1). The two lookups a work scope
// cannot supply arrive as `IncomingEventBindings` from the composition root.
-import { getTime, isSameDomain, parsePath } from '@openpanel/common';
-import type { IProjectFilters } from '@openpanel/validation';
import { anyPass, isEmpty, isNil, mergeDeepRight, omit, reject } from 'ramda';
import type { SessionIngestResult } from '../../../buffers/session-buffer';
import type { Ctx } from '../../../context';
import type { Logger } from '../../../logger';
+import { getTime } from '../../../shared/date';
import {
getReferrerWithQuery,
parseReferrer,
} from '../../../shared/parse-referrer';
+import { isSameDomain, parsePath } from '../../../shared/url';
import {
createEvent,
type IServiceCreateEventPayload,
@@ -28,6 +28,7 @@ import {
type IServiceEvent,
} from '../../event/event.service';
import { matchEvent } from '../../notification/notification.service';
+import type { IProjectFilters } from '../../project/project.constants';
import type { IClickhouseSession } from '../../session/session.service';
import { sessionEndsEnqueued } from '../../session/src/session.metrics';
import type { EnqueueSessionEndInput } from '../../session/src/session-end';
diff --git a/packages/validation/src/types.insights.ts b/packages/core/src/modules/insight/insight.constants.ts
similarity index 80%
rename from packages/validation/src/types.insights.ts
rename to packages/core/src/modules/insight/insight.constants.ts
index 7d2e13cfa..785eadc77 100644
--- a/packages/validation/src/types.insights.ts
+++ b/packages/core/src/modules/insight/insight.constants.ts
@@ -1,3 +1,8 @@
+// Moved from packages/validation/src/types.insights.ts (M11-006, ADR-008's
+// module map: insight owns "C"). Plain TypeScript, no zod — isomorphic by the
+// AGENTS.md rule, which constrains a constants file's imports, and this file
+// has none.
+
export type InsightMetricKey = 'sessions' | 'pageviews' | 'share';
export type InsightMetricUnit = 'count' | 'ratio';
diff --git a/packages/core/src/modules/insight/insight.rpc.ts b/packages/core/src/modules/insight/insight.rpc.ts
index d458592a4..0c32d4c87 100644
--- a/packages/core/src/modules/insight/insight.rpc.ts
+++ b/packages/core/src/modules/insight/insight.rpc.ts
@@ -10,10 +10,10 @@
// The permission ladder itself is bound once, in auth.service.ts
// (M10-002); every procedure here reaches it through `ctx.services.auth`.
-import type { InsightPayload } from '@openpanel/validation';
import { z } from 'zod';
import { createTRPCRouter, protectedProcedure } from '../../rpc/base';
import { TRPCAccessError } from '../../rpc/errors';
+import type { InsightPayload } from './insight.constants';
const DAY_MS = 24 * 60 * 60 * 1000;
const EXPLAIN_COLUMNS = [
diff --git a/packages/core/src/modules/insight/src/modules/geo.module.ts b/packages/core/src/modules/insight/src/modules/geo.module.ts
index e79601d78..8ab61ea6a 100644
--- a/packages/core/src/modules/insight/src/modules/geo.module.ts
+++ b/packages/core/src/modules/insight/src/modules/geo.module.ts
@@ -1,6 +1,6 @@
-import { getCountry } from '@openpanel/constants';
import { formatClickhouseDate } from '../../../../shared/ch-dates';
import { TABLE_NAMES } from '../../../../shared/ch-tables';
+import { getCountry } from '../../../report/report.constants';
import type {
ComputeContext,
ComputeResult,
diff --git a/packages/core/src/modules/insight/src/referrer-spikes.ts b/packages/core/src/modules/insight/src/referrer-spikes.ts
index 6327fa420..c3e875be3 100644
--- a/packages/core/src/modules/insight/src/referrer-spikes.ts
+++ b/packages/core/src/modules/insight/src/referrer-spikes.ts
@@ -5,11 +5,14 @@
// `sql` tag (see shared/ch-query.ts). Table names and the date helper are
// core's own copies (shared/ch-tables.ts, shared/ch-dates.ts).
import { clix } from '@openpanel/db/src/clickhouse/query-builder';
-import type { IChartEventFilter, IInterval } from '@openpanel/validation';
import type { ServiceDeps } from '../../../services';
import { convertClickhouseDateToJs } from '../../../shared/ch-dates';
import { TABLE_NAMES } from '../../../shared/ch-tables';
import { overviewService } from '../../../v1-compat';
+import type {
+ IChartEventFilter,
+ IInterval,
+} from '../../report/report.constants';
// Spike detection thresholds. Conservative defaults — markers should be rare
// and obviously meaningful when they appear. Tune here if real usage shows
diff --git a/packages/core/src/modules/insight/src/types.ts b/packages/core/src/modules/insight/src/types.ts
index 5dd9983b2..8028bbeca 100644
--- a/packages/core/src/modules/insight/src/types.ts
+++ b/packages/core/src/modules/insight/src/types.ts
@@ -1,4 +1,4 @@
-import type { InsightPayload } from '@openpanel/validation';
+import type { InsightPayload } from '../insight.constants';
export type Cadence = 'daily';
@@ -37,7 +37,7 @@ export interface ComputeResult {
extra?: Record<string, unknown>; // share delta pp, rank, sparkline, etc.
}
-// Types imported from @openpanel/validation:
+// Types imported from ../insight.constants:
// - InsightMetricKey
// - InsightMetricEntry
// - InsightDimension
diff --git a/packages/core/src/modules/integration/integration.constants.ts b/packages/core/src/modules/integration/integration.constants.ts
index b46cb20d4..0194e0b34 100644
--- a/packages/core/src/modules/integration/integration.constants.ts
+++ b/packages/core/src/modules/integration/integration.constants.ts
@@ -3,7 +3,7 @@
// a re-export shim of this file (same shape as ./notification.constants.ts
// since M6-005), so packages/trpc's integration router and apps/start's
// integration forms keep resolving these symbols through
-// @openpanel/validation's existing barrel unchanged.
+// packages/validation's existing barrel unchanged.
//
// `zSlackAuthResponse` does NOT move here even though it is zod-only and
// would pass `constants-stay-isomorphic`: it is Slack's OAuth token-exchange
diff --git a/packages/core/src/modules/integration/src/flush-exports.ts b/packages/core/src/modules/integration/src/flush-exports.ts
index 363d862f3..1b893bc7a 100644
--- a/packages/core/src/modules/integration/src/flush-exports.ts
+++ b/packages/core/src/modules/integration/src/flush-exports.ts
@@ -9,7 +9,6 @@
// value through ClickHouse's own `{name:Type}` params, and converting it to the
// `sql` tag would change the emitted statement. Kept byte-identical.
-import { DateTime } from '@openpanel/common';
import {
clickhouseEventToExportEvent,
createBatch,
@@ -21,6 +20,7 @@ import {
} from '../../../clients/integrations/export';
import type { IObjectStoreAdapter } from '../../../clients/integrations/object-store';
import type { Logger } from '../../../logger';
+import { DateTime } from '../../../shared/date';
import type { IClickhouseEvent } from '../../event/event.service';
import {
type IGCSExportConfig,
diff --git a/packages/core/src/modules/mcp/src/tools/dashboard-management.ts b/packages/core/src/modules/mcp/src/tools/dashboard-management.ts
index 5d0a09be7..b6f82825d 100644
--- a/packages/core/src/modules/mcp/src/tools/dashboard-management.ts
+++ b/packages/core/src/modules/mcp/src/tools/dashboard-management.ts
@@ -1,8 +1,8 @@
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
-import { zReport } from '@openpanel/validation';
import { z } from 'zod';
import { getId } from '../../../../shared/slug-id';
import { getDashboardById, getProjectById } from '../../../../v1-compat';
+import { zReport } from '../../../report/report.constants';
import type { McpAuthContext } from '../auth';
import { dashboardBaseUrl } from './dashboard-links';
import {
diff --git a/packages/core/src/modules/notification/notification.constants.ts b/packages/core/src/modules/notification/notification.constants.ts
index dc45d813e..4ea972f5b 100644
--- a/packages/core/src/modules/notification/notification.constants.ts
+++ b/packages/core/src/modules/notification/notification.constants.ts
@@ -3,16 +3,16 @@
// re-export shim of this file (same shape as ./onboarding.constants.ts since
// M6-003), so packages/trpc's notification router and apps/start's
// notification rule form keep resolving these symbols through
-// @openpanel/validation's existing barrel unchanged.
+// packages/validation's existing barrel unchanged.
//
// `zChartEvent`/`zChartEventFilter` are chart/report vocabulary that has not
// moved to core yet (ADR-008's "report" module is a later wave), so per
// `constants-stay-isomorphic` (zod, another `*.constants.ts`, or type-only —
-// nothing else) they cannot be value-imported from @openpanel/validation
+// nothing else) they cannot be value-imported from packages/validation
// here. Diverged local copy instead, same treatment as
// ./modules/cohort/cohort.constants.ts's zChartEventFilter since M5-003 —
// including inlining `operators`/`chartSegments`/`filterValueTypes` as
-// literal key tuples rather than importing them from @openpanel/constants.
+// literal key tuples rather than importing them from packages/constants.
// TODO(report module): once report.constants.ts exists, delete this
// duplicate and import zChartEvent from there instead.
//
diff --git a/packages/core/src/modules/notification/notification.service.test.ts b/packages/core/src/modules/notification/notification.service.test.ts
index 5b9c03b86..b90082843 100644
--- a/packages/core/src/modules/notification/notification.service.test.ts
+++ b/packages/core/src/modules/notification/notification.service.test.ts
@@ -5,7 +5,7 @@
// (side-effect-free) import.
import { afterAll, beforeAll, beforeEach, expect, mock, test } from 'bun:test';
-import type { IChartEvent } from '@openpanel/validation';
+import type { IChartEvent } from '../report/report.constants';
interface FakeRule {
id: string;
diff --git a/packages/core/src/modules/notification/notification.service.ts b/packages/core/src/modules/notification/notification.service.ts
index b1a57ea79..958510d20 100644
--- a/packages/core/src/modules/notification/notification.service.ts
+++ b/packages/core/src/modules/notification/notification.service.ts
@@ -16,15 +16,14 @@
// test file reaches, and constructing @openpanel/db's clients at import time
// would spawn a pino-pretty transport worker thread per test file).
-import { stripLeadingAndTrailingSlashes } from '@openpanel/common';
import type { Integration, Prisma } from '@openpanel/db/src/prisma-client';
import { cacheable } from '@openpanel/redis';
-import type { IChartEvent, IChartEventFilter } from '@openpanel/validation';
import { pathOr } from 'ramda';
import { sendEmail } from '../../clients/email';
import { getServerIntegration } from '../../clients/integrations/registry';
import { TRPCBadRequestError, TRPCForbiddenError } from '../../rpc/errors';
import type { ServiceDeps } from '../../services';
+import { stripLeadingAndTrailingSlashes } from '../../shared/string';
import type {
IServiceCreateEventPayload,
IServiceEvent,
@@ -33,6 +32,10 @@ import {
type IIntegrationConfig,
isKind,
} from '../integration/integration.constants';
+import type {
+ IChartEvent,
+ IChartEventFilter,
+} from '../report/report.constants';
import type { ICreateNotificationRule } from './notification.constants';
export const APP_NOTIFICATION_INTEGRATION_ID = 'app';
diff --git a/packages/core/src/modules/onboarding/onboarding.rpc.ts b/packages/core/src/modules/onboarding/onboarding.rpc.ts
index 503229a08..d09d8e0de 100644
--- a/packages/core/src/modules/onboarding/onboarding.rpc.ts
+++ b/packages/core/src/modules/onboarding/onboarding.rpc.ts
@@ -12,13 +12,13 @@
// already belong to needs no more than that); this router repeats the check
// explicitly through the organization module's own lookup.
-import { zOnboardingProject } from '@openpanel/validation';
import {
createTRPCRouter,
protectedProcedure,
publicProcedure,
} from '../../rpc/base';
import { TRPCAccessError, TRPCForbiddenError } from '../../rpc/errors';
+import { zOnboardingProject } from './onboarding.constants';
import {
canSkipOnboarding,
createOnboardingProject,
diff --git a/packages/core/src/modules/onboarding/onboarding.service.ts b/packages/core/src/modules/onboarding/onboarding.service.ts
index a200949c9..c382a7b69 100644
--- a/packages/core/src/modules/onboarding/onboarding.service.ts
+++ b/packages/core/src/modules/onboarding/onboarding.service.ts
@@ -13,7 +13,6 @@
// re-exports.
import crypto from 'node:crypto';
-import { stripTrailingSlash } from '@openpanel/common';
import { getRecommendedPlan } from '@openpanel/payments';
import { format } from 'date-fns';
import type { Logger } from '../../logger';
@@ -24,6 +23,7 @@ import {
type SequenceSubject,
step,
} from '../../shared/email-sequence';
+import { stripTrailingSlash } from '../../shared/string';
import { hashPassword } from '../auth/auth.service';
import {
getOrganizationById,
diff --git a/packages/core/src/modules/organization/organization.constants.ts b/packages/core/src/modules/organization/organization.constants.ts
new file mode 100644
index 000000000..23dabed56
--- /dev/null
+++ b/packages/core/src/modules/organization/organization.constants.ts
@@ -0,0 +1,41 @@
+// Moved from packages/validation/src/index.ts (M11-006, ADR-008's module map:
+// organization owns "C" for the member/invite/organization vocabulary).
+// `zProjectAccessGrant` is a per-project grant but every consumer is
+// organization-shaped (organization.rpc.ts's invite/access mutations,
+// code-migrations/20-invite-project-access-levels.ts), so it lives here and
+// `zInviteUser` embeds it without a cross-file constants import.
+//
+// Isomorphic by the AGENTS.md rule: zod and nothing else.
+
+import { z } from 'zod';
+
+/**
+ * A per-project grant. `read` means exactly that: the member can look at the
+ * project but no mutation will be accepted for it. `admin` is not offered here
+ * - destructive operations hang off the organization role instead, so a third
+ * project level would be a second way to say `write`.
+ */
+export const zProjectAccessGrant = z.object({
+ projectId: z.string(),
+ level: z.enum(['read', 'write']),
+});
+export type IProjectAccessGrant = z.infer<typeof zProjectAccessGrant>;
+
+export const zInviteUser = z.object({
+ email: z.string().email(),
+ organizationId: z.string(),
+ role: z.enum(['org:admin', 'org:member']),
+ access: z.array(zProjectAccessGrant),
+});
+
+export const zUpdateMemberAccess = z.object({
+ userId: z.string(),
+ organizationId: z.string(),
+ access: z.array(zProjectAccessGrant),
+});
+
+export const zEditOrganization = z.object({
+ id: z.string().min(2),
+ name: z.string().min(2),
+ timezone: z.string().min(1),
+});
diff --git a/packages/core/src/modules/organization/organization.rpc.ts b/packages/core/src/modules/organization/organization.rpc.ts
index 87ffa15c2..27ae711d8 100644
--- a/packages/core/src/modules/organization/organization.rpc.ts
+++ b/packages/core/src/modules/organization/organization.rpc.ts
@@ -14,11 +14,6 @@
// move with M11-001. `createRateLimitMiddleware` in rpc/base.ts is the seam
// that will carry it.
-import {
- zEditOrganization,
- zInviteUser,
- zUpdateMemberAccess,
-} from '@openpanel/validation';
import { z } from 'zod';
import {
createTRPCRouter,
@@ -32,6 +27,11 @@ import {
TRPCBadRequestError,
TRPCForbiddenError,
} from '../../rpc/errors';
+import {
+ zEditOrganization,
+ zInviteUser,
+ zUpdateMemberAccess,
+} from './organization.constants';
function requireLogin(userId: string | null | undefined): string {
if (!userId) {
diff --git a/packages/core/src/modules/organization/organization.service.ts b/packages/core/src/modules/organization/organization.service.ts
index 24a73dddf..0237f2863 100644
--- a/packages/core/src/modules/organization/organization.service.ts
+++ b/packages/core/src/modules/organization/organization.service.ts
@@ -25,7 +25,6 @@
// value import of `@openpanel/db`: like ADR-013's `sql` tag and `clix`, it is
// a pure string BUILDER that holds no client (see shared/ch-query.ts).
-import { DateTime } from '@openpanel/common';
import type {
Invite,
Prisma,
@@ -40,10 +39,8 @@ import { TRPCBadRequestError } from '../../rpc/errors';
import type { ServiceDeps } from '../../services';
import { formatClickhouseDate } from '../../shared/ch-dates';
import { chQuery } from '../../shared/ch-query';
-import {
- getReplicatedTableName,
- TABLE_NAMES,
-} from '../../shared/ch-tables';
+import { getReplicatedTableName, TABLE_NAMES } from '../../shared/ch-tables';
+import { DateTime } from '../../shared/date';
import { generateSecureId } from '../../shared/id';
export type IServiceOrganization = Awaited<
@@ -222,12 +219,13 @@ export async function getMember(
export async function connectUserToOrganization(
deps: ServiceDeps,
{
- user,
- inviteId,
-}: {
- user: User;
- inviteId: string;
-}) {
+ user,
+ inviteId,
+ }: {
+ user: User;
+ inviteId: string;
+ }
+) {
const db = deps.db;
const { getOrganizationAccess, getProjectAccess } = await import(
'../../shared/access-lookups'
@@ -628,10 +626,11 @@ export async function runDeleteCron(
export async function updateOrganization(
deps: ServiceDeps,
input: {
- id: string;
- name: string;
- timezone: string;
-}) {
+ id: string;
+ name: string;
+ timezone: string;
+ }
+) {
const db = deps.db;
return db.organization.update({
where: {
@@ -725,12 +724,13 @@ export type InviteUserResult =
export async function inviteUserToOrganization(
deps: ServiceDeps,
input: {
- organizationId: string;
- email: string;
- role: 'org:admin' | 'org:member';
- access: { projectId: string; level: 'read' | 'write' }[];
- invitedById: string;
-}): Promise<InviteUserResult> {
+ organizationId: string;
+ email: string;
+ role: 'org:admin' | 'org:member';
+ access: { projectId: string; level: 'read' | 'write' }[];
+ invitedById: string;
+ }
+): Promise<InviteUserResult> {
const db = deps.db;
const email = input.email.toLowerCase();
const userExists = await db.user.findFirst({
@@ -840,11 +840,12 @@ export async function revokeInvite(
export async function removeOrganizationMember(
deps: ServiceDeps,
input: {
- organizationId: string;
- memberId: string;
- targetUserId: string;
- requestedByUserId: string;
-}): Promise<void> {
+ organizationId: string;
+ memberId: string;
+ targetUserId: string;
+ requestedByUserId: string;
+ }
+): Promise<void> {
const db = deps.db;
const exists = await db.member.count({
where: {
@@ -877,10 +878,11 @@ export async function removeOrganizationMember(
export async function updateOrganizationMemberAccess(
deps: ServiceDeps,
input: {
- organizationId: string;
- targetUserId: string;
- access: { projectId: string; level: 'read' | 'write' }[];
-}) {
+ organizationId: string;
+ targetUserId: string;
+ access: { projectId: string; level: 'read' | 'write' }[];
+ }
+) {
const db = deps.db;
return db.$transaction([
db.projectAccess.deleteMany({
diff --git a/packages/core/src/modules/overview/overview.rpc.ts b/packages/core/src/modules/overview/overview.rpc.ts
index abc5d6f6d..4a289e1da 100644
--- a/packages/core/src/modules/overview/overview.rpc.ts
+++ b/packages/core/src/modules/overview/overview.rpc.ts
@@ -12,11 +12,6 @@
// router; they moved to `services.overview.getLiveData` (src/overview.sql.ts)
// so every query this module runs goes through the same `sql` tag (M7-005).
-import {
- type IChartRange,
- pageContextSchema,
- zRange,
-} from '@openpanel/validation';
import { format } from 'date-fns';
import { z } from 'zod';
import {
@@ -31,12 +26,14 @@ import {
getChartPrevStartEndDate,
getChartStartEndDate,
} from '../../shared/date';
+import { pageContextSchema } from '../assistant/assistant.constants';
import { getConversionEventNames } from '../event/event.service';
import { getReferrerSpikes } from '../insight/insight.service';
import {
getOrganizationSubscriptionChartEndDate,
getSettingsForProject,
} from '../organization/organization.service';
+import { type IChartRange, zRange } from '../report/report.constants';
import {
zGetMapDataInput,
zGetMetricsInput,
diff --git a/packages/core/src/modules/overview/overview.service.ts b/packages/core/src/modules/overview/overview.service.ts
index 343b7f596..1f0fd784e 100644
--- a/packages/core/src/modules/overview/overview.service.ts
+++ b/packages/core/src/modules/overview/overview.service.ts
@@ -10,16 +10,15 @@
// `constructor(client)` slot is gone with it: the client is `deps.ch`, which
// is what puts the request's id on the query's log line (ADR-018 R1).
-import { average, sum } from '@openpanel/common';
-import { chartColors } from '@openpanel/constants';
import type { SqlFragment } from '@openpanel/db/src/clickhouse/sql';
-import type { IChartEventFilter, IInterval } from '@openpanel/validation';
-import { zTimeInterval } from '@openpanel/validation';
import { z } from 'zod';
import type { ServiceDeps } from '../../services';
+import { average, sum } from '../../shared/math';
import { convertClickhouseDateToJs } from '../chart/src/dates';
import { getEventFiltersWhereClause } from '../chart/src/filter-where';
import { getSettingsForProject } from '../organization/organization.service';
+import type { IChartEventFilter, IInterval } from '../report/report.constants';
+import { chartColors, zTimeInterval } from '../report/report.constants';
import {
distinctSessionsQuery,
liveMinuteCountsQuery,
diff --git a/packages/core/src/modules/overview/pages.service.ts b/packages/core/src/modules/overview/pages.service.ts
index f69be823c..a776962ab 100644
--- a/packages/core/src/modules/overview/pages.service.ts
+++ b/packages/core/src/modules/overview/pages.service.ts
@@ -12,9 +12,9 @@
// dodge a module-singleton mocking hazard, and there is no singleton left to
// dodge.
-import type { IChartEventFilter, IInterval } from '@openpanel/validation';
import type { ServiceDeps } from '../../services';
import { getSettingsForProject } from '../organization/organization.service';
+import type { IChartEventFilter, IInterval } from '../report/report.constants';
import {
getTopPages as getOverviewTopPages,
getTopEntryExit,
diff --git a/packages/core/src/modules/overview/src/overview.sql.ts b/packages/core/src/modules/overview/src/overview.sql.ts
index 470d3de19..cc3d5aa85 100644
--- a/packages/core/src/modules/overview/src/overview.sql.ts
+++ b/packages/core/src/modules/overview/src/overview.sql.ts
@@ -20,10 +20,10 @@
// `session_timezone` setting instead, which every statement here still sets
// (see src/run-query.ts).
+import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';
import { compiledText } from '../../chart/src/compiled';
import { getSelectPropertyKey } from '../../chart/src/field-resolution';
-import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';
-import type { IInterval } from '@openpanel/validation';
+import type { IInterval } from '../../report/report.constants';
const ROLLUP_DATE_PREFIX = '1970-01-01';
@@ -117,7 +117,11 @@ export function fillClause(
return sql`WITH FILL FROM ${fillFrom(interval, startDate)} TO ${fillBoundaryParam(interval, endDate)} STEP ${compiledText(toIntervalStep(interval))}`;
}
-function dateRangeWhere(column: string, startDate: string, endDate: string): SqlFragment {
+function dateRangeWhere(
+ column: string,
+ startDate: string,
+ endDate: string
+): SqlFragment {
return sql`${sql.id(column)} BETWEEN toDateTime(${sql.string(toDateTimeLiteral(startDate))}) AND toDateTime(${sql.string(toDateTimeLiteral(endDate))})`;
}
@@ -162,7 +166,9 @@ export interface SessionMetricsQueryInput {
rawFilterWhere: string;
}
-export function sessionMetricsQuery(input: SessionMetricsQueryInput): SqlFragment {
+export function sessionMetricsQuery(
+ input: SessionMetricsQueryInput
+): SqlFragment {
return sql`
SELECT
${toStartOf('created_at', input.interval)} AS date,
@@ -319,7 +325,9 @@ export interface DistinctSessionsQueryInput {
rawFilterWhere: string;
}
-export function distinctSessionsQuery(input: DistinctSessionsQueryInput): SqlFragment {
+export function distinctSessionsQuery(
+ input: DistinctSessionsQueryInput
+): SqlFragment {
return sql`
SELECT DISTINCT session_id
FROM events
@@ -343,7 +351,9 @@ function distinctSessionsCteHeader(cte: SqlFragment | null): SqlFragment {
}
function distinctSessionsConstraint(cte: SqlFragment | null): SqlFragment {
- return cte ? sql`AND id IN (SELECT session_id FROM distinct_sessions)` : sql.empty;
+ return cte
+ ? sql`AND id IN (SELECT session_id FROM distinct_sessions)`
+ : sql.empty;
}
export interface TopEntryExitQueryInput {
@@ -423,10 +433,15 @@ export interface TopGenericQueryInput {
distinctSessionsCte: SqlFragment | null;
}
-function topGenericSelect(column: string, prefixColumn: string | null): SqlFragment {
+function topGenericSelect(
+ column: string,
+ prefixColumn: string | null
+): SqlFragment {
const parts: SqlFragment[] = [];
if (prefixColumn) {
- parts.push(sql`${sql.id(prefixColumn, TOP_GENERIC_PREFIX_COLUMNS)} as prefix`);
+ parts.push(
+ sql`${sql.id(prefixColumn, TOP_GENERIC_PREFIX_COLUMNS)} as prefix`
+ );
}
parts.push(
sql`nullIf(${sql.id(column, TOP_GENERIC_COLUMNS)}, '') as name`,
@@ -437,7 +452,10 @@ function topGenericSelect(column: string, prefixColumn: string | null): SqlFragm
return sql.join(parts);
}
-function topGenericGroupBy(column: string, prefixColumn: string | null): SqlFragment {
+function topGenericGroupBy(
+ column: string,
+ prefixColumn: string | null
+): SqlFragment {
return prefixColumn
? sql`${sql.id(prefixColumn, TOP_GENERIC_PREFIX_COLUMNS)}, ${sql.id(column, TOP_GENERIC_COLUMNS)}`
: sql.id(column, TOP_GENERIC_COLUMNS);
@@ -527,7 +545,10 @@ function orderedEventsQuery(input: OrderedEventsQueryInput): SqlFragment {
`;
}
-function pathsDedupedCte(input: OrderedEventsQueryInput, steps: number): SqlFragment {
+function pathsDedupedCte(
+ input: OrderedEventsQueryInput,
+ steps: number
+): SqlFragment {
return sql`
WITH ordered_events AS (${orderedEventsQuery(input)})
SELECT
@@ -696,7 +717,9 @@ export interface LiveTotalSessionsQueryInput {
projectId: string;
}
-export function liveTotalSessionsQuery(input: LiveTotalSessionsQueryInput): SqlFragment {
+export function liveTotalSessionsQuery(
+ input: LiveTotalSessionsQueryInput
+): SqlFragment {
return sql`
SELECT uniq(session_id) as total_sessions
FROM events
@@ -705,7 +728,9 @@ export function liveTotalSessionsQuery(input: LiveTotalSessionsQueryInput): SqlF
`;
}
-export function liveMinuteCountsQuery(input: LiveTotalSessionsQueryInput): SqlFragment {
+export function liveMinuteCountsQuery(
+ input: LiveTotalSessionsQueryInput
+): SqlFragment {
return sql`
SELECT
toStartOfMinute(created_at) as minute,
@@ -720,7 +745,9 @@ export function liveMinuteCountsQuery(input: LiveTotalSessionsQueryInput): SqlFr
`;
}
-export function liveMinuteReferrersQuery(input: LiveTotalSessionsQueryInput): SqlFragment {
+export function liveMinuteReferrersQuery(
+ input: LiveTotalSessionsQueryInput
+): SqlFragment {
return sql`
SELECT
toStartOfMinute(created_at) as minute,
@@ -736,7 +763,9 @@ export function liveMinuteReferrersQuery(input: LiveTotalSessionsQueryInput): Sq
`;
}
-export function liveReferrersQuery(input: LiveTotalSessionsQueryInput): SqlFragment {
+export function liveReferrersQuery(
+ input: LiveTotalSessionsQueryInput
+): SqlFragment {
return sql`
SELECT referrer_name as referrer, uniq(session_id) as count
FROM events
diff --git a/packages/core/src/modules/overview/src/pages.sql.ts b/packages/core/src/modules/overview/src/pages.sql.ts
index dbfe43f68..3fb89df6b 100644
--- a/packages/core/src/modules/overview/src/pages.sql.ts
+++ b/packages/core/src/modules/overview/src/pages.sql.ts
@@ -6,14 +6,18 @@
// sets diffed against V1's on the local prod-copy — see pages.sql.proof.md.
import { type SqlFragment, sql } from '@openpanel/db/src/clickhouse/sql';
-import type { IInterval } from '@openpanel/validation';
+import type { IInterval } from '../../report/report.constants';
import { fillClause, toStartOf } from './overview.sql';
function toDateTimeLiteral(value: string): string {
return new Date(value).toISOString().slice(0, 19).replace('T', ' ');
}
-function dateRangeWhere(column: string, startDate: string, endDate: string): SqlFragment {
+function dateRangeWhere(
+ column: string,
+ startDate: string,
+ endDate: string
+): SqlFragment {
return sql`${sql.id(column)} BETWEEN toDateTime(${sql.string(toDateTimeLiteral(startDate))}) AND toDateTime(${sql.string(toDateTimeLiteral(endDate))})`;
}
@@ -66,7 +70,9 @@ export function topPagesQuery(input: TopPagesQueryInput): SqlFragment {
`;
const limitClause =
- input.limit === undefined ? sql.empty : sql`LIMIT ${sql.uint64(input.limit)}`;
+ input.limit === undefined
+ ? sql.empty
+ : sql`LIMIT ${sql.uint64(input.limit)}`;
return sql`
WITH
@@ -104,7 +110,9 @@ export interface PageTimeseriesQueryInput {
filterPath?: string;
}
-export function pageTimeseriesQuery(input: PageTimeseriesQueryInput): SqlFragment {
+export function pageTimeseriesQuery(
+ input: PageTimeseriesQueryInput
+): SqlFragment {
const originFilter = input.filterOrigin
? sql`AND e.origin = ${sql.string(input.filterOrigin)}`
: sql.empty;
@@ -141,7 +149,9 @@ export interface PageConversionsQueryInput {
limit: number;
}
-export function pageConversionsQuery(input: PageConversionsQueryInput): SqlFragment {
+export function pageConversionsQuery(
+ input: PageConversionsQueryInput
+): SqlFragment {
const conversionEvents = sql`
SELECT profile_id, created_at AS conv_time
FROM events
diff --git a/packages/core/src/modules/profile/profile.rpc.ts b/packages/core/src/modules/profile/profile.rpc.ts
index d31fa1e5f..63b579ced 100644
--- a/packages/core/src/modules/profile/profile.rpc.ts
+++ b/packages/core/src/modules/profile/profile.rpc.ts
@@ -7,7 +7,6 @@
// `organizationId`, so anything resolved from another id needs its own
// (ADR-011).
-import { zChartEventFilter } from '@openpanel/validation';
import { z } from 'zod';
import {
createTRPCRouter,
@@ -15,6 +14,7 @@ import {
type TrpcContext,
} from '../../rpc/base';
import { TRPCAccessError } from '../../rpc/errors';
+import { zChartEventFilter } from '../report/report.constants';
import {
getPowerUsers,
getProfileActivity,
diff --git a/packages/core/src/modules/profile/profile.service.ts b/packages/core/src/modules/profile/profile.service.ts
index af641b9f5..71685266b 100644
--- a/packages/core/src/modules/profile/profile.service.ts
+++ b/packages/core/src/modules/profile/profile.service.ts
@@ -16,13 +16,13 @@
// loaders are gone (docs/TECH_DEBT.md §2, §4); `loadFilterCompiler` stays and
// reaches a core sibling, not @openpanel/db.
-import { strip, toObject } from '@openpanel/common';
-import type { IChartEventFilter } from '@openpanel/validation';
import { assocPath, flatten, map, pathOr, pipe, prop, sort, uniq } from 'ramda';
import type { ServiceDeps } from '../../services';
import { cacheablePerDeps } from '../../shared/cacheable-per-deps';
import { chQuery } from '../../shared/ch-query';
+import { strip, toObject } from '../../shared/object';
import type { IClickhouseEvent } from '../event/event.service';
+import type { IChartEventFilter } from '../report/report.constants';
import type { IClickhouseSession } from '../session/session.service';
import {
convertClickhouseDateToJs,
diff --git a/packages/core/src/modules/project/project.constants.ts b/packages/core/src/modules/project/project.constants.ts
index 3f2fe3fe1..38226bcde 100644
--- a/packages/core/src/modules/project/project.constants.ts
+++ b/packages/core/src/modules/project/project.constants.ts
@@ -1,15 +1,21 @@
// Moved from packages/constants/index.ts (M6-002, ADR-008's module map:
// project owns "C"). packages/constants/index.ts becomes a re-export shim of
// `ProjectTypeNames` (same shape as packages/validation/src/import.validation.ts
-// since M5-004), so existing @openpanel/constants importers keep resolving it
+// since M5-004), so existing packages/constants importers keep resolving it
// unchanged. `zCreateProject`/`zUpdateProject` are the /manage REST body
// schemas (apps/api/src/controllers/manage.controller.ts), moved here with
// the CRUD bodies they validate (project.service.ts's
// createProjectForOrganization/updateProjectForOrganization).
//
-// Isomorphic by the AGENTS.md rule: zod and nothing else.
+// The project filter/edit schemas below moved from
+// packages/validation/src/index.ts (M11-006, same module map row). `zChartEvent`
+// is imported by name, not re-exported: `zProjectFilterEvent` extends it as a
+// bound identifier.
+//
+// Isomorphic by the AGENTS.md rule: zod, another *.constants.ts, and nothing else.
import { z } from 'zod';
+import { zChartEvent } from '../report/report.constants';
export const ProjectTypeNames = {
website: 'Website',
@@ -34,3 +40,49 @@ export const zUpdateProject = z.object({
crossDomain: z.boolean().optional(),
allowUnsafeRevenueTracking: z.boolean().optional(),
});
+
+export const zProjectFilterIp = z.object({
+ type: z.literal('ip'),
+ ip: z.string(),
+});
+export type IProjectFilterIp = z.infer<typeof zProjectFilterIp>;
+
+export const zProjectFilterProfileId = z.object({
+ type: z.literal('profile_id'),
+ profileId: z.string(),
+});
+export type IProjectFilterProfileId = z.infer<typeof zProjectFilterProfileId>;
+
+export const zProjectFilterEvent = zChartEvent.extend({
+ type: z.literal('event'),
+});
+export type IProjectFilterEvent = z.infer<typeof zProjectFilterEvent>;
+
+export const zProjectFilters = z.discriminatedUnion('type', [
+ zProjectFilterIp,
+ zProjectFilterProfileId,
+ zProjectFilterEvent,
+]);
+export type IProjectFilters = z.infer<typeof zProjectFilters>;
+
+export const zProject = z.object({
+ id: z.string(),
+ name: z.string().min(1),
+ filters: z.array(zProjectFilters).default([]),
+ domain: z.string().url().or(z.literal('').or(z.null())),
+ cors: z.array(z.string()).default([]),
+ crossDomain: z.boolean().default(false),
+ allowUnsafeRevenueTracking: z.boolean().default(false),
+});
+export type IProjectEdit = z.infer<typeof zProject>;
+
+export const zProjectUpdate = z.object({
+ id: z.string(),
+ name: z.string().min(1).optional(),
+ filters: z.array(zProjectFilters).optional(),
+ domain: z.string().url().or(z.literal('').or(z.null())).optional(),
+ cors: z.array(z.string()).optional(),
+ crossDomain: z.boolean().optional(),
+ allowUnsafeRevenueTracking: z.boolean().optional(),
+});
+export type IProjectUpdate = z.infer<typeof zProjectUpdate>;
diff --git a/packages/core/src/modules/project/project.rpc.ts b/packages/core/src/modules/project/project.rpc.ts
index eb6392790..40dca3348 100644
--- a/packages/core/src/modules/project/project.rpc.ts
+++ b/packages/core/src/modules/project/project.rpc.ts
@@ -12,10 +12,11 @@
// The project-access ladder itself is bound once, in auth.service.ts
// (M10-002); every procedure here reaches it through `ctx.services.auth`.
-import { zOnboardingProject, zProjectUpdate } from '@openpanel/validation';
import { z } from 'zod';
import { createTRPCRouter, protectedProcedure } from '../../rpc/base';
import { TRPCAccessError, TRPCForbiddenError } from '../../rpc/errors';
+import { zOnboardingProject } from '../onboarding/onboarding.constants';
+import { zProjectUpdate } from './project.constants';
function requireLogin(userId: string | null | undefined): string {
if (!userId) {
diff --git a/packages/core/src/modules/project/project.service.ts b/packages/core/src/modules/project/project.service.ts
index 3a48032c8..4c14e6e68 100644
--- a/packages/core/src/modules/project/project.service.ts
+++ b/packages/core/src/modules/project/project.service.ts
@@ -21,7 +21,6 @@
// M10-009 dropped the `compatChHelpers()` hop these two used to make.
import crypto from 'node:crypto';
-import { stripTrailingSlash } from '@openpanel/common';
import { clix } from '@openpanel/db/src/clickhouse/query-builder';
import type {
Prisma,
@@ -36,6 +35,7 @@ import { convertClickhouseDateToJs } from '../../shared/ch-dates';
import { chQuery } from '../../shared/ch-query';
import { TABLE_NAMES } from '../../shared/ch-tables';
import { getId } from '../../shared/slug-id';
+import { stripTrailingSlash } from '../../shared/string';
import { hashPassword } from '../auth/auth.service';
// `clix` is a value import of `@openpanel/db` and stays one: it is a pure
diff --git a/packages/core/src/modules/reference/reference.constants.ts b/packages/core/src/modules/reference/reference.constants.ts
new file mode 100644
index 000000000..85285febc
--- /dev/null
+++ b/packages/core/src/modules/reference/reference.constants.ts
@@ -0,0 +1,15 @@
+// Moved from packages/validation/src/index.ts (M11-006, ADR-008's module map:
+// reference owns "C"). ADR-008 records two diverged `zCreateReference` copies
+// in V1 as one of the two drift bugs the dissolution exists to prevent; this
+// is now the only one.
+//
+// Isomorphic by the AGENTS.md rule: zod and nothing else.
+
+import { z } from 'zod';
+
+export const zCreateReference = z.object({
+ title: z.string(),
+ description: z.string().nullish(),
+ projectId: z.string(),
+ datetime: z.string(),
+});
diff --git a/packages/core/src/modules/reference/reference.rpc.ts b/packages/core/src/modules/reference/reference.rpc.ts
index 981ba627e..8bbfbb007 100644
--- a/packages/core/src/modules/reference/reference.rpc.ts
+++ b/packages/core/src/modules/reference/reference.rpc.ts
@@ -16,7 +16,6 @@
// no access check here either — same gap V1's router has (ported verbatim,
// not fixed).
-import { zCreateReference, zRange } from '@openpanel/validation';
import { z } from 'zod';
import {
createTRPCRouter,
@@ -24,6 +23,8 @@ import {
publicProcedure,
} from '../../rpc/base';
import { TRPCAccessError, TRPCForbiddenError } from '../../rpc/errors';
+import { zRange } from '../report/report.constants';
+import { zCreateReference } from './reference.constants';
function requireLogin(userId: string | null | undefined): string {
if (!userId) {
diff --git a/packages/core/src/modules/reference/reference.service.ts b/packages/core/src/modules/reference/reference.service.ts
index f62938592..b9317a036 100644
--- a/packages/core/src/modules/reference/reference.service.ts
+++ b/packages/core/src/modules/reference/reference.service.ts
@@ -12,10 +12,10 @@
// worker per test file — left to defer (docs/TECH_DEBT.md §4).
import type { Reference } from '@openpanel/db/src/prisma-client';
-import type { IChartRange } from '@openpanel/validation';
import type { ServiceDeps } from '../../services';
import { getChartStartEndDate } from '../../shared/date';
import { getSettingsForProject } from '../organization/organization.service';
+import type { IChartRange } from '../report/report.constants';
export type IServiceReference = Reference;
diff --git a/packages/core/src/modules/report/report.constants.ts b/packages/core/src/modules/report/report.constants.ts
index 4e370ed36..df3713ad3 100644
--- a/packages/core/src/modules/report/report.constants.ts
+++ b/packages/core/src/modules/report/report.constants.ts
@@ -2,7 +2,7 @@
// (M7-006, ADR-008's module map: report owns "C" for the chart/report/widget
// vocabulary). Both origin files become re-export shims onto this one (same
// shape as packages/validation/src/cohort.validation.ts since M5-003), so
-// existing @openpanel/constants / @openpanel/validation importers (the chart
+// existing packages/constants / packages/validation importers (the chart
// engine, apps/start's report builder, packages/trpc's report/dashboard/
// widget routers) keep resolving these symbols unchanged.
//
@@ -953,3 +953,104 @@ export const zReport = zReportInput.extend({
// Alias for backward compatibility
export const zChartInput = zReportInput;
+
+// ---------------------------------------------------------------------------
+// Inferred report/chart types, moved from packages/validation/src/types.validation.ts
+// (M11-006, ADR-008's module map: report owns "C" for the chart/report/widget
+// vocabulary). They land beside the schemas they infer from, which is what
+// removes that file's `import type { … } from './index'` back-edge.
+// `IChartEvents` and `ISetCookie` do NOT come along: the first is a dead alias
+// with no importers, the second is already ../../shared/cookie.ts.
+// `UnionOmit` has no owning module — it is kept here, with the report types it
+// is only ever applied to (apps/start's reportSlice), until M11-007 gives
+// apps/start its own copy.
+// ---------------------------------------------------------------------------
+
+export type UnionOmit<T, K extends keyof any> = T extends any
+ ? Omit<T, K>
+ : never;
+
+// For saved reports - complete report with required display fields
+export type IReport = z.infer<typeof zReport>;
+
+// For API/engine use - flexible input
+export type IReportInput = z.infer<typeof zReportInput>;
+
+// With resolved dates (engine internal)
+export interface IReportInputWithDates extends IReportInput {
+ startDate: string;
+ endDate: string;
+}
+export type IChartEvent = z.infer<typeof zChartEvent>;
+export type IChartFormula = z.infer<typeof zChartFormula>;
+export type IChartEventItem = z.infer<typeof zChartEventItem>;
+export type IChartSeries = z.infer<typeof zChartSeries>;
+export type IChartEventSegment = z.infer<typeof zChartEventSegment>;
+export type IChartEventFilter = IChartEvent['filters'][number];
+export type IChartEventFilterValue =
+ IChartEvent['filters'][number]['value'][number];
+export type IChartEventFilterOperator =
+ IChartEvent['filters'][number]['operator'];
+export type IChartFilterValueType = NonNullable<
+ IChartEvent['filters'][number]['type']
+>;
+export type IChartBreakdown = z.infer<typeof zChartBreakdown>;
+export type IInterval = z.infer<typeof zTimeInterval>;
+export type IChartType = z.infer<typeof zChartType>;
+export type IChartMetric = z.infer<typeof zMetric>;
+export type IChartLineType = z.infer<typeof zLineType>;
+export type IChartRange = z.infer<typeof zRange>;
+export type IGetChartDataInput = {
+ event: IChartEvent;
+ projectId: string;
+ startDate: string;
+ endDate: string;
+} & Omit<
+ IReportInput,
+ 'series' | 'globalFilters' | 'startDate' | 'endDate' | 'range'
+>;
+export type ICriteria = z.infer<typeof zCriteria>;
+
+export type PreviousValue =
+ | {
+ value: number;
+ diff: number | null;
+ state: 'positive' | 'negative' | 'neutral';
+ }
+ | undefined;
+
+export type Metrics = {
+ sum: number;
+ average: number;
+ min: number;
+ max: number;
+ count: number | undefined;
+ previous?: {
+ sum: PreviousValue;
+ average: PreviousValue;
+ min: PreviousValue;
+ max: PreviousValue;
+ count: PreviousValue;
+ };
+};
+
+export type IChartSerie = {
+ id: string;
+ names: string[];
+ event: {
+ id?: string;
+ name: string;
+ breakdowns?: Record<string, string>;
+ };
+ metrics: Metrics;
+ data: {
+ date: string;
+ count: number;
+ previous: PreviousValue;
+ }[];
+};
+
+export type FinalChart = {
+ series: IChartSerie[];
+ metrics: Metrics;
+};
diff --git a/packages/core/src/modules/report/report.service.test.ts b/packages/core/src/modules/report/report.service.test.ts
index e794a4808..ccf1cdd7d 100644
--- a/packages/core/src/modules/report/report.service.test.ts
+++ b/packages/core/src/modules/report/report.service.test.ts
@@ -6,7 +6,7 @@
* M10-003 moved the helper to ./src/series.ts — see that file for why.
*/
import { describe, expect, it } from 'bun:test';
-import type { IChartEventFilter, IChartEventItem } from '@openpanel/validation';
+import type { IChartEventFilter, IChartEventItem } from './report.constants';
import { mergeGlobalFilters } from './src/series';
const globalFilter: IChartEventFilter = {
diff --git a/packages/core/src/modules/report/report.service.ts b/packages/core/src/modules/report/report.service.ts
index c4ee944b1..38fc08762 100644
--- a/packages/core/src/modules/report/report.service.ts
+++ b/packages/core/src/modules/report/report.service.ts
@@ -13,15 +13,6 @@ import type {
Report as DbReport,
ReportLayout,
} from '@openpanel/db/src/prisma-client';
-import type {
- IChartBreakdown,
- IChartEventFilter,
- IChartEventItem,
- IChartLineType,
- IChartRange,
- IReport,
- IReportOptions,
-} from '@openpanel/validation';
import { TRPCBadRequestError } from '../../rpc/errors';
import type { ServiceDeps } from '../../services';
import { getChartStartEndDate } from '../../shared/date';
@@ -32,6 +23,15 @@ import {
} from '../chart/src/engine/execute';
import { getDashboardById } from '../dashboard/dashboard.service';
import { getSettingsForProject } from '../organization/organization.service';
+import type {
+ IChartBreakdown,
+ IChartEventFilter,
+ IChartEventItem,
+ IChartLineType,
+ IChartRange,
+ IReport,
+ IReportOptions,
+} from './report.constants';
import { alphabetIds, lineTypes } from './report.constants';
import { mergeGlobalFilters, onlyReportEvents } from './src/series';
diff --git a/packages/core/src/modules/report/src/series.ts b/packages/core/src/modules/report/src/series.ts
index 7df120014..e04b78959 100644
--- a/packages/core/src/modules/report/src/series.ts
+++ b/packages/core/src/modules/report/src/series.ts
@@ -5,7 +5,7 @@
// report.service). Nothing here touches a database, so both sides stay
// eager and neither needs a lazy loader (docs/TECH_DEBT.md §4 step 2).
-import type { IChartEventFilter, IChartEventItem } from '@openpanel/validation';
+import type { IChartEventFilter, IChartEventItem } from '../report.constants';
/** The event half of the discriminated series union — what every caller then
* reads `.name` / `.filters` off. */
diff --git a/packages/core/src/modules/session/session.rpc.ts b/packages/core/src/modules/session/session.rpc.ts
index 90cd67e30..75820ad9a 100644
--- a/packages/core/src/modules/session/session.rpc.ts
+++ b/packages/core/src/modules/session/session.rpc.ts
@@ -11,7 +11,6 @@
// them and `shared/pagination.ts` already has the generic pair, so they were
// not ported.
-import { zChartEventFilter } from '@openpanel/validation';
import { z } from 'zod';
import {
createTRPCRouter,
@@ -19,6 +18,7 @@ import {
type TrpcContext,
} from '../../rpc/base';
import { TRPCAccessError } from '../../rpc/errors';
+import { zChartEventFilter } from '../report/report.constants';
import {
getSessionById,
getSessionDistinctValues,
diff --git a/packages/core/src/modules/session/session.service.ts b/packages/core/src/modules/session/session.service.ts
index c6a608a7d..b9d3e0d34 100644
--- a/packages/core/src/modules/session/session.service.ts
+++ b/packages/core/src/modules/session/session.service.ts
@@ -18,11 +18,11 @@
// imports, kept lazy for a cycle, not for a client.
import { cacheable } from '@openpanel/redis';
-import type { IChartEventFilter } from '@openpanel/validation';
import type { ServiceDeps } from '../../services';
import { chQuery } from '../../shared/ch-query';
import { getSafeJson } from '../../shared/json';
import type { IServiceProfile } from '../profile/profile.service';
+import type { IChartEventFilter } from '../report/report.constants';
import { convertClickhouseDateToJs } from './src/dates';
import {
hasSessionListLookback,
diff --git a/packages/core/src/modules/share/share.constants.ts b/packages/core/src/modules/share/share.constants.ts
index dc5f6e8a8..2d46412f0 100644
--- a/packages/core/src/modules/share/share.constants.ts
+++ b/packages/core/src/modules/share/share.constants.ts
@@ -1,6 +1,6 @@
// Moved from packages/validation/src/index.ts (M6-004, ADR-008's module map:
// share owns "C"). packages/validation re-exports these for existing
-// @openpanel/validation importers — same shape as
+// packages/validation importers — same shape as
// packages/validation/src/index.ts's onboarding/auth re-exports since M6-003.
import { z } from 'zod';
diff --git a/packages/core/src/modules/subscription/subscription.constants.ts b/packages/core/src/modules/subscription/subscription.constants.ts
index 575ed1bfb..a0845e2a3 100644
--- a/packages/core/src/modules/subscription/subscription.constants.ts
+++ b/packages/core/src/modules/subscription/subscription.constants.ts
@@ -2,7 +2,7 @@
// subscription owns "C"). packages/validation/src/index.ts becomes a
// re-export shim of this file (same shape as ./notification.constants.ts
// since M6-005), so packages/trpc's subscription router and apps/start's
-// billing forms keep resolving these symbols through @openpanel/validation's
+// billing forms keep resolving these symbols through packages/validation's
// existing barrel unchanged.
//
// Isomorphic by the AGENTS.md rule: zod and nothing else.
diff --git a/packages/core/src/shared/cookie.ts b/packages/core/src/shared/cookie.ts
index a56869672..877eb4b91 100644
--- a/packages/core/src/shared/cookie.ts
+++ b/packages/core/src/shared/cookie.ts
@@ -1,4 +1,4 @@
-// Ported from @openpanel/validation's ISetCookie, unchanged shape. This is
+// Ported from packages/validation's ISetCookie, unchanged shape. This is
// the transport-agnostic type HttpCtx.setCookie exposes to every module, so
// a module depends on this instead of Elysia's cookie type directly.
diff --git a/packages/core/src/shared/date.ts b/packages/core/src/shared/date.ts
index 62dddbc7b..40b6050d1 100644
--- a/packages/core/src/shared/date.ts
+++ b/packages/core/src/shared/date.ts
@@ -1,8 +1,21 @@
// Chart date-range resolution (ADR-007 shared/ layout: "date"). Moved from
// packages/db/src/services/date.service.ts (M8-005) — pure Date/Luxon math,
// no ClickHouse or Postgres access.
-import { DateTime } from '@openpanel/common';
-import type { IChartRange, IReportInput } from '@openpanel/validation';
+//
+// M11-006: `DateTime` and `getTime` moved here from packages/common/src/date.ts,
+// which was the workspace's only luxon declaration. This file is now the one
+// place core re-exports luxon's DateTime from.
+import { DateTime } from 'luxon';
+import type {
+ IChartRange,
+ IReportInput,
+} from '../modules/report/report.constants';
+
+export { DateTime } from 'luxon';
+
+export function getTime(date: string | number | Date) {
+ return new Date(date).getTime();
+}
export function resolveDateRange(
startDate?: string,
diff --git a/packages/core/src/shared/group-by-labels.ts b/packages/core/src/shared/group-by-labels.ts
new file mode 100644
index 000000000..3b084fca1
--- /dev/null
+++ b/packages/core/src/shared/group-by-labels.ts
@@ -0,0 +1,75 @@
+// Moved from packages/common/src/group-by-labels.ts (M11-006, ADR-007 shared/
+// layout). Sole consumer: modules/chart/src/engine/fetch.ts.
+export interface ISerieDataItem {
+ label_0: string | null | undefined;
+ label_1?: string | null | undefined;
+ label_2?: string | null | undefined;
+ label_3?: string | null | undefined;
+ count: number;
+ total_count?: number;
+ date: string;
+}
+
+interface GroupedDataPoint {
+ date: string;
+ count: number;
+ total_count?: number;
+}
+
+interface GroupedResult {
+ name: string[]; // [label_0, label_1, label_2, label_3]
+ data: GroupedDataPoint[];
+}
+
+export function groupByLabels(data: ISerieDataItem[]): GroupedResult[] {
+ const groupedMap = new Map<string, GroupedResult>();
+ const timestamps = new Set<string>();
+ data.forEach((row) => {
+ timestamps.add(row.date);
+ const labels = Object.keys(row)
+ .filter((key) => key.startsWith('label_'))
+ .sort((a, b) => {
+ const numA = Number.parseInt(a.replace('label_', ''));
+ const numB = Number.parseInt(b.replace('label_', ''));
+ return numA - numB;
+ })
+ .map((key) => (row as any)[key])
+ .filter((label): label is string => !!label);
+
+ const labelKey = labels.join(':::');
+
+ if (!groupedMap.has(labelKey)) {
+ groupedMap.set(labelKey, {
+ name: labels,
+ data: [],
+ });
+ }
+
+ const group = groupedMap.get(labelKey)!;
+ group.data.push({
+ date: row.date,
+ count: row.count,
+ total_count: row.total_count,
+ });
+ });
+
+ const result = Array.from(groupedMap.values()).map((group) => ({
+ ...group,
+ data: group.data.sort(
+ (a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()
+ ),
+ }));
+
+ return result
+ .filter((group) => group.name.length > 0)
+ .map((group) => {
+ return {
+ ...group,
+ // This will ensure that all dates are present in the data array
+ data: Array.from(timestamps).map((date) => {
+ const dataPoint = group.data.find((dp) => dp.date === date);
+ return dataPoint || { date, count: 0, total_count: 0 };
+ }),
+ };
+ });
+}
diff --git a/packages/core/src/shared/id.ts b/packages/core/src/shared/id.ts
index ed47a5515..7c143bc3f 100644
--- a/packages/core/src/shared/id.ts
+++ b/packages/core/src/shared/id.ts
@@ -1,7 +1,7 @@
-// Ported from @openpanel/common's id.ts, unchanged. nanoid/non-secure is
+// Ported from packages/common's id.ts, unchanged. nanoid/non-secure is
// deliberate: these are correlation/display ids, not secrets.
-// Ported from @openpanel/common/server's id.ts (M4-003). Regular `nanoid`,
+// Ported from packages/common/server's id.ts (M4-003). Regular `nanoid`,
// not the non-secure variant above: these ids back password-reset tokens and
// invite links, so they must stay cryptographically random.
import { nanoid as secureNanoid } from 'nanoid';
diff --git a/packages/core/src/shared/json.ts b/packages/core/src/shared/json.ts
index 14403889e..711452699 100644
--- a/packages/core/src/shared/json.ts
+++ b/packages/core/src/shared/json.ts
@@ -1,4 +1,4 @@
-// Ported from @openpanel/json, same semantics: getSafeJson never throws, and
+// Ported from packages/json, same semantics: getSafeJson never throws, and
// getSuperJson only hands off to superjson's parser when the payload looks
// like superjson's own `{ json, meta }` envelope — a plain JSON payload
// round-trips through JSON.parse instead.
diff --git a/packages/core/src/shared/math.ts b/packages/core/src/shared/math.ts
new file mode 100644
index 000000000..5c3fc63b8
--- /dev/null
+++ b/packages/core/src/shared/math.ts
@@ -0,0 +1,84 @@
+// Moved from packages/common/src/math.ts and
+// packages/common/src/get-previous-metric.ts (M11-006, ADR-007 shared/ layout).
+// `isFloat` does NOT come along: no importer, anywhere.
+//
+// `isNumber` is mathjs's, not `typeof n === 'number'` — it is the filter
+// predicate for every chart aggregate below, so it stays exactly as it was.
+import { isNumber } from 'mathjs';
+import { isNil } from 'ramda';
+import type { PreviousValue } from '../modules/report/report.constants';
+
+export const round = (num: number, decimals = 2) => {
+ const factor = 10 ** decimals;
+ return Math.round((num + Number.EPSILON) * factor) / factor;
+};
+
+export const average = (arr: (number | null)[], includeZero = false) => {
+ const filtered = arr.filter(
+ (n): n is number =>
+ isNumber(n) &&
+ !Number.isNaN(n) &&
+ Number.isFinite(n) &&
+ (includeZero || n !== 0)
+ );
+ const avg = filtered.reduce((p, c) => p + c, 0) / filtered.length;
+ return Number.isNaN(avg) ? 0 : avg;
+};
+
+export const sum = (arr: (number | null | undefined)[]): number =>
+ round(arr.filter(isNumber).reduce((acc, item) => acc + item, 0));
+
+export const min = (arr: (number | null | undefined)[]): number => {
+ const filtered = arr.filter(isNumber);
+ if (filtered.length === 0) {
+ return 0;
+ }
+ return filtered.reduce((a, b) => (b < a ? b : a), filtered[0]!);
+};
+
+export const max = (arr: (number | null | undefined)[]): number => {
+ const filtered = arr.filter(isNumber);
+ if (filtered.length === 0) {
+ return 0;
+ }
+ return filtered.reduce((a, b) => (b > a ? b : a), filtered[0]!);
+};
+
+export const ifNaN = <T extends number>(
+ n: number | null | undefined,
+ defaultValue: T
+): T => (Number.isNaN(n) ? defaultValue : (n as T));
+
+export function getPreviousMetric(
+ current: number,
+ previous: number | null | undefined
+): PreviousValue {
+ if (isNil(previous)) {
+ return undefined;
+ }
+
+ const diff = round(
+ ((current > previous
+ ? current / previous
+ : current < previous
+ ? previous / current
+ : 0) -
+ 1) *
+ 100,
+ 1
+ );
+
+ return {
+ diff:
+ Number.isNaN(diff) || !Number.isFinite(diff) || current === previous
+ ? null
+ : diff,
+ state:
+ current > previous
+ ? 'positive'
+ : current < previous
+ ? 'negative'
+ : 'neutral',
+ value: previous,
+ };
+}
diff --git a/packages/common/src/object.test.ts b/packages/core/src/shared/object.test.ts
similarity index 94%
rename from packages/common/src/object.test.ts
rename to packages/core/src/shared/object.test.ts
index d33dcb789..dde579a02 100644
--- a/packages/common/src/object.test.ts
+++ b/packages/core/src/shared/object.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it } from 'bun:test';
import { toDots } from './object';
describe('toDots', () => {
@@ -10,7 +10,7 @@ describe('toDots', () => {
arrayWithObjects: [{ a: 1 }, { b: 2 }, { c: 3 }],
objectWithArrays: { a: [1, 2, 3] },
null: null,
- undefined: undefined,
+ undefined,
empty: '',
jsonString: '{"a": 1, "b": 2}',
};
diff --git a/packages/core/src/shared/object.ts b/packages/core/src/shared/object.ts
new file mode 100644
index 000000000..4fa3dc499
--- /dev/null
+++ b/packages/core/src/shared/object.ts
@@ -0,0 +1,125 @@
+// Moved from packages/common/src/object.ts (M11-006, ADR-007 shared/ layout).
+// `toDots` is the ClickHouse property flattener — its invalid-surrogate strip
+// is load-bearing on the insert path.
+import { anyPass, assocPath, isEmpty, isNil, reject } from 'ramda';
+
+function isValidJsonString(value: string): boolean {
+ return (
+ (value.startsWith('{') && value.endsWith('}')) ||
+ (value.startsWith('[') && value.endsWith(']'))
+ );
+}
+function isMalformedJsonString(value: string): boolean {
+ return (
+ (value.startsWith('{') && !value.endsWith('}')) ||
+ (value.startsWith('[') && !value.endsWith(']'))
+ );
+}
+
+export function toDots(
+ obj: Record<string, unknown>,
+ path = ''
+): Record<string, string> {
+ // Clickhouse breaks on insert if a property contains invalid surrogate pairs
+ function removeInvalidSurrogates(value: string): string {
+ const validSurrogatePairRegex =
+ /[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g;
+ return value.match(validSurrogatePairRegex)?.join('') || '';
+ }
+
+ return Object.entries(obj).reduce((acc, [key, value]) => {
+ if (typeof value === 'object' && value !== null) {
+ return {
+ ...acc,
+ ...toDots(value as Record<string, unknown>, `${path}${key}.`),
+ };
+ }
+
+ if (value === undefined || value === null || value === '') {
+ return acc;
+ }
+
+ if (typeof value === 'string' && isMalformedJsonString(value)) {
+ // Skip it
+ return acc;
+ }
+
+ // Fix nested json strings - but catch parse errors for malformed JSON
+ if (typeof value === 'string' && isValidJsonString(value)) {
+ try {
+ return {
+ ...acc,
+ ...toDots(JSON.parse(value), `${path}${key}.`),
+ };
+ } catch {
+ // Skip it
+ return acc;
+ }
+ }
+
+ const cleanedValue =
+ typeof value === 'string'
+ ? removeInvalidSurrogates(value).trim()
+ : String(value);
+
+ return {
+ ...acc,
+ [`${path}${key}`]: cleanedValue,
+ };
+ }, {});
+}
+
+export function toObject(
+ obj: Record<string, string | undefined>
+): Record<string, unknown> {
+ let result: Record<string, unknown> = {};
+ Object.entries(obj).forEach(([key, value]) => {
+ result = assocPath(key.split('.'), value, result);
+ });
+ return result;
+}
+
+export const strip = reject(anyPass([isEmpty, isNil]));
+
+type AnyObject = Record<string, any>;
+
+export function deepMergeObjects<T>(target: AnyObject, source: AnyObject): T {
+ const merged: AnyObject = {};
+ // Include all keys from both objects
+ const allKeys = new Set([...Object.keys(target), ...Object.keys(source)]);
+
+ allKeys.forEach((key) => {
+ const targetValue = target[key];
+ const sourceValue = source[key];
+
+ if (
+ (isNil(sourceValue) && !isNil(targetValue)) ||
+ (sourceValue === '' &&
+ typeof targetValue === 'string' &&
+ targetValue !== '')
+ ) {
+ // Keep target value if source value is null or undefined
+ merged[key] = targetValue;
+ } else if (
+ sourceValue !== undefined &&
+ isObject(targetValue) &&
+ isObject(sourceValue)
+ ) {
+ // Recursively merge objects
+ merged[key] = deepMergeObjects(targetValue, sourceValue);
+ } else if (sourceValue !== undefined) {
+ // Directly assign any non-undefined source values
+ merged[key] = sourceValue;
+ } else if (sourceValue === undefined && target[key] !== undefined) {
+ // Keep target value if source value is undefined
+ merged[key] = targetValue;
+ }
+ });
+
+ return merged as T;
+}
+
+// Helper function to check if a value is an object (but not null or an array)
+function isObject(value: any): boolean {
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
+}
diff --git a/packages/core/src/shared/parse-referrer.ts b/packages/core/src/shared/parse-referrer.ts
index da052e14a..87cd6f2b2 100644
--- a/packages/core/src/shared/parse-referrer.ts
+++ b/packages/core/src/shared/parse-referrer.ts
@@ -1,5 +1,5 @@
-import { stripTrailingSlash } from '@openpanel/common';
import referrers from './referrers';
+import { stripTrailingSlash } from './string';
function getHostname(url: string | undefined) {
if (!url) {
diff --git a/packages/core/src/shared/slug-id.ts b/packages/core/src/shared/slug-id.ts
index b8b5301ea..f599a13c3 100644
--- a/packages/core/src/shared/slug-id.ts
+++ b/packages/core/src/shared/slug-id.ts
@@ -10,8 +10,8 @@
// `@modelcontextprotocol/sdk` signature and only ever hold the db they got
// from the v1-compat seam.
-import { slug } from '@openpanel/common';
import type { ServiceDeps } from '../services';
+import { slug } from './slug';
export async function getId(
deps: Pick<ServiceDeps, 'db'>,
diff --git a/packages/common/src/slug.test.ts b/packages/core/src/shared/slug.test.ts
similarity index 69%
rename from packages/common/src/slug.test.ts
rename to packages/core/src/shared/slug.test.ts
index 49bf92e01..64d369a2f 100644
--- a/packages/common/src/slug.test.ts
+++ b/packages/core/src/shared/slug.test.ts
@@ -1,10 +1,10 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it } from 'bun:test';
import { slug } from './slug';
describe('slug', () => {
it('should remove pipes from string', () => {
expect(slug('Hello || World, | Test å å ä ä')).toBe(
- 'hello-world-test-a-a-a-a',
+ 'hello-world-test-a-a-a-a'
);
});
});
diff --git a/packages/core/src/shared/slug.ts b/packages/core/src/shared/slug.ts
new file mode 100644
index 000000000..33d7c6f0c
--- /dev/null
+++ b/packages/core/src/shared/slug.ts
@@ -0,0 +1,21 @@
+// Moved from packages/common/src/slug.ts (M11-006, ADR-007 shared/ layout).
+// Not to be confused with ./slug-id.ts, which calls this.
+import _slugify from 'slugify';
+
+const slugify = (str: string) => {
+ return _slugify(
+ str
+ .replaceAll('å', 'a')
+ .replaceAll('ä', 'a')
+ .replaceAll('ö', 'o')
+ .replaceAll('Å', 'A')
+ .replaceAll('Ä', 'A')
+ .replaceAll('Ö', 'O')
+ .replace(/\|+/g, '-'),
+ { lower: true, strict: true, trim: true }
+ );
+};
+
+export function slug(str: string): string {
+ return slugify(str);
+}
diff --git a/packages/core/src/shared/string.ts b/packages/core/src/shared/string.ts
new file mode 100644
index 000000000..690d66468
--- /dev/null
+++ b/packages/core/src/shared/string.ts
@@ -0,0 +1,9 @@
+// Moved from packages/common/src/string.ts (M11-006, ADR-007 shared/ layout).
+
+export function stripTrailingSlash(url: string) {
+ return url.replace(/\/+$/, '');
+}
+
+export function stripLeadingAndTrailingSlashes(url: string) {
+ return url.replace(/^[/]+|[/]+$/g, '');
+}
diff --git a/packages/core/src/shared/try-catch.ts b/packages/core/src/shared/try-catch.ts
index ab057e9d2..d12063dc8 100644
--- a/packages/core/src/shared/try-catch.ts
+++ b/packages/core/src/shared/try-catch.ts
@@ -1,4 +1,4 @@
-// Ported from @openpanel/common's try-catch.ts, unchanged.
+// Ported from packages/common's try-catch.ts, unchanged.
export type TryCatchResult<T, E = Error> =
| { ok: true; data: T; error: null }
diff --git a/packages/core/src/shared/url.ts b/packages/core/src/shared/url.ts
new file mode 100644
index 000000000..da421ec66
--- /dev/null
+++ b/packages/core/src/shared/url.ts
@@ -0,0 +1,64 @@
+// Moved from packages/common/src/url.ts (M11-006, ADR-007 shared/ layout).
+export function parseSearchParams(
+ params: URLSearchParams
+): Record<string, string> | undefined {
+ const result: Record<string, string> = {};
+ for (const [key, value] of params.entries()) {
+ result[key] = value;
+ }
+ return Object.keys(result).length ? result : undefined;
+}
+
+export function parsePath(path?: string): {
+ query?: Record<string, string>;
+ path: string;
+ origin: string;
+ hash?: string;
+} {
+ if (!path) {
+ return {
+ path: '',
+ origin: '',
+ };
+ }
+
+ const hasOrigin = path.startsWith('http');
+
+ // If path does not have a leading /,
+ // its probably a named route
+ if (!(path.startsWith('/') || hasOrigin)) {
+ return {
+ path,
+ origin: '',
+ };
+ }
+
+ try {
+ const url = new URL(path, hasOrigin ? undefined : 'http://localhost');
+ return {
+ query: parseSearchParams(url.searchParams),
+ path: url.pathname,
+ hash: url.hash || undefined,
+ origin: hasOrigin ? url.origin : '',
+ };
+ } catch (error) {
+ return {
+ path,
+ origin: '',
+ };
+ }
+}
+
+export function isSameDomain(
+ url1: string | undefined,
+ url2: string | undefined
+) {
+ if (!(url1 && url2)) {
+ return false;
+ }
+ try {
+ return new URL(url1).hostname === new URL(url2).hostname;
+ } catch (e) {
+ return false;
+ }
+}
diff --git a/packages/json/index.ts b/packages/json/index.ts
index 6a3ec6318..55eabbb34 100644
--- a/packages/json/index.ts
+++ b/packages/json/index.ts
@@ -1,21 +1,11 @@
-import superjson from 'superjson';
-
-export function getSafeJson<T>(str: string): T | null {
- try {
- return JSON.parse(str);
- } catch (e) {
- return null;
- }
-}
-
-export function getSuperJson<T>(str: string): T | null {
- const json = getSafeJson<T>(str);
- if (typeof json === 'object' && json !== null && 'json' in json) {
- return superjson.parse<T>(str);
- }
- return json;
-}
-
-export function setSuperJson(str: any): string {
- return superjson.stringify(str);
-}
+// P11 shim (ADR-008/ADR-007). The definitions live in
+// packages/core/src/shared/json.ts. Reached by relative path, not through
+// @openpanel/core: packages/redis calls these at runtime and core depends on
+// packages/redis, so the barrel would invert that edge and drag core's whole
+// import graph into the redis (and published-SDK) module graph.
+// Deleted by M11-009 once M11-007/M11-008 retarget the last importer.
+export {
+ getSafeJson,
+ getSuperJson,
+ setSuperJson,
+} from '../core/src/shared/json';
diff --git a/packages/validation/src/chat.ts b/packages/validation/src/chat.ts
deleted file mode 100644
index 07f17bd2d..000000000
--- a/packages/validation/src/chat.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-// Moved into @openpanel/core's assistant module (M5-005, ADR-008's module
-// map: assistant owns "C"). Re-exported here for existing
-// @openpanel/validation importers (apps/start's model picker + chat panel) —
-// same shape as packages/validation/src/import.validation.ts since M5-004.
-// The `./modules/assistant/assistant.constants` subpath is a leaf, isomorphic
-// file with no back-imports into @openpanel/validation, so this re-export
-// carries no runtime cycle despite @openpanel/core already depending on
-// @openpanel/validation elsewhere.
-export * from '@openpanel/core/modules/assistant/assistant.constants';
diff --git a/packages/validation/src/cohort.validation.ts b/packages/validation/src/cohort.validation.ts
deleted file mode 100644
index 779a9b4af..000000000
--- a/packages/validation/src/cohort.validation.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-// Moved into @openpanel/core's cohort module (M5-003, ADR-008's module map:
-// cohort owns "C"). Re-exported here for existing @openpanel/validation
-// importers (apps/start's cohort UI, packages/db/src/types.ts) — same shape
-// as packages/db/src/gsc.ts since M5-002. The `./modules/cohort/cohort.constants`
-// subpath is a leaf, isomorphic file with no back-imports into
-// @openpanel/validation, so this re-export carries no runtime cycle despite
-// @openpanel/core already depending on @openpanel/validation elsewhere.
-export * from '@openpanel/core/modules/cohort/cohort.constants';
diff --git a/packages/validation/src/import.validation.ts b/packages/validation/src/import.validation.ts
deleted file mode 100644
index 662da343a..000000000
--- a/packages/validation/src/import.validation.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-// Moved into @openpanel/core's import module (M5-004, ADR-008's module map:
-// import owns "C"). Re-exported here for existing @openpanel/validation
-// importers (apps/start's import UI, packages/db/src/types.ts) — same shape
-// as packages/validation/src/cohort.validation.ts since M5-003. The
-// `./modules/import/import.constants` subpath is a leaf, isomorphic file
-// with no back-imports into @openpanel/validation, so this re-export carries
-// no runtime cycle despite @openpanel/core already depending on
-// @openpanel/validation elsewhere.
-export * from '@openpanel/core/modules/import/import.constants';
diff --git a/packages/validation/src/index.ts b/packages/validation/src/index.ts
index 2296666cd..0c020bfad 100644
--- a/packages/validation/src/index.ts
+++ b/packages/validation/src/index.ts
@@ -1,152 +1,20 @@
-import { zChartEvent } from '@openpanel/core/modules/report/report.constants';
-import { z } from 'zod';
-
-// Moved into @openpanel/core's report module (M7-006, ADR-008's module map:
-// report owns "C" for the chart/report/widget vocabulary). Re-exported here
-// for existing @openpanel/validation importers (packages/trpc's chart/
-// report/dashboard/widget routers, apps/start's report builder) — same
-// shape as ./cohort.validation.ts's re-export since M5-003. `zChartEvent` is
-// imported by name too (not just re-exported): `zProjectFilterEvent` below
-// extends it as a bound identifier, which `export *` alone does not provide.
-export * from '@openpanel/core/modules/report/report.constants';
-
-/**
- * A per-project grant. `read` means exactly that: the member can look at the
- * project but no mutation will be accepted for it. `admin` is not offered here
- * - destructive operations hang off the organization role instead, so a third
- * project level would be a second way to say `write`.
- */
-export const zProjectAccessGrant = z.object({
- projectId: z.string(),
- level: z.enum(['read', 'write']),
-});
-export type IProjectAccessGrant = z.infer<typeof zProjectAccessGrant>;
-
-export const zInviteUser = z.object({
- email: z.string().email(),
- organizationId: z.string(),
- role: z.enum(['org:admin', 'org:member']),
- access: z.array(zProjectAccessGrant),
-});
-
-export const zUpdateMemberAccess = z.object({
- userId: z.string(),
- organizationId: z.string(),
- access: z.array(zProjectAccessGrant),
-});
-
-// Moved into @openpanel/core's share module (M6-004, ADR-008's module map:
-// share owns "C"). Re-exported here for existing @openpanel/validation
-// importers (packages/trpc's share router, apps/start's share modals) — same
-// shape as ./onboarding.constants.ts re-export since M6-003.
-export * from '@openpanel/core/modules/share/share.constants';
-
-export const zCreateReference = z.object({
- title: z.string(),
- description: z.string().nullish(),
- projectId: z.string(),
- datetime: z.string(),
-});
-
-// Moved into @openpanel/core's integration module (M6-006, ADR-008's module
-// map: integration owns "C"). Re-exported here for existing
-// @openpanel/validation importers (packages/trpc's integration router,
-// apps/start's integration forms) — same shape as ./onboarding.constants.ts
-// re-export since M6-003. `zSlackAuthResponse` does NOT come along: it moved
-// to the module's `src/` (Slack's own OAuth wire contract, not integration
-// config) and is now reached through @openpanel/core's curated barrel
-// instead — apps/api/src/controllers/webhook.controller.ts (the one former
-// importer) updated to match.
+// P11 shim (ADR-008). Every symbol this package ever exported is now defined
+// in @openpanel/core; this file is re-exports only and is deleted by M11-009
+// once M11-007/M11-008 have retargeted the last external importer. The
+// per-module targets are tooling/codemods/p11-map.json.
+export * from '@openpanel/core/modules/assistant/assistant.constants';
+export * from '@openpanel/core/modules/auth/auth.constants';
+export * from '@openpanel/core/modules/cohort/cohort.constants';
+export * from '@openpanel/core/modules/group/group.constants';
+export * from '@openpanel/core/modules/import/import.constants';
+export * from '@openpanel/core/modules/ingest/ingest.constants';
+export * from '@openpanel/core/modules/insight/insight.constants';
export * from '@openpanel/core/modules/integration/integration.constants';
-// Moved into @openpanel/core's notification module (M6-005, ADR-008's module
-// map: notification owns "C"). Re-exported here for existing
-// @openpanel/validation importers (packages/trpc's notification router,
-// apps/start's notification rule form) — same shape as
-// ./onboarding.constants.ts re-export since M6-003. `zChartEvent` (used
-// above, and by notification.constants.ts itself) is imported earlier in
-// this file from core's report.constants.ts (M7-006), so the resulting
-// module cycle resolves at the value level: see notification.constants.ts's
-// header.
export * from '@openpanel/core/modules/notification/notification.constants';
-// Moved into @openpanel/core's onboarding module (M6-003, ADR-008's module
-// map: onboarding owns "C"). Re-exported here for existing
-// @openpanel/validation importers (packages/trpc's onboarding/project
-// routers, apps/start's onboarding flow) — same shape as
-// ./cohort.validation.ts since M5-003.
export * from '@openpanel/core/modules/onboarding/onboarding.constants';
-
-export const zProjectFilterIp = z.object({
- type: z.literal('ip'),
- ip: z.string(),
-});
-export type IProjectFilterIp = z.infer<typeof zProjectFilterIp>;
-
-export const zProjectFilterProfileId = z.object({
- type: z.literal('profile_id'),
- profileId: z.string(),
-});
-export type IProjectFilterProfileId = z.infer<typeof zProjectFilterProfileId>;
-
-export const zProjectFilterEvent = zChartEvent.extend({
- type: z.literal('event'),
-});
-export type IProjectFilterEvent = z.infer<typeof zProjectFilterEvent>;
-
-export const zProjectFilters = z.discriminatedUnion('type', [
- zProjectFilterIp,
- zProjectFilterProfileId,
- zProjectFilterEvent,
-]);
-export type IProjectFilters = z.infer<typeof zProjectFilters>;
-
-export const zProject = z.object({
- id: z.string(),
- name: z.string().min(1),
- filters: z.array(zProjectFilters).default([]),
- domain: z.string().url().or(z.literal('').or(z.null())),
- cors: z.array(z.string()).default([]),
- crossDomain: z.boolean().default(false),
- allowUnsafeRevenueTracking: z.boolean().default(false),
-});
-export type IProjectEdit = z.infer<typeof zProject>;
-
-export const zProjectUpdate = z.object({
- id: z.string(),
- name: z.string().min(1).optional(),
- filters: z.array(zProjectFilters).optional(),
- domain: z.string().url().or(z.literal('').or(z.null())).optional(),
- cors: z.array(z.string()).optional(),
- crossDomain: z.boolean().optional(),
- allowUnsafeRevenueTracking: z.boolean().optional(),
-});
-export type IProjectUpdate = z.infer<typeof zProjectUpdate>;
-
-// Moved into @openpanel/core's auth module (M6-003, ADR-008's module map:
-// auth owns "C"). Re-exported here for existing @openpanel/validation
-// importers (packages/trpc's auth router, apps/start's sign-in/sign-up
-// forms) — same shape as ./cohort.validation.ts since M5-003.
-export * from '@openpanel/core/modules/auth/auth.constants';
-// Moved into @openpanel/core's group module (M7-002, ADR-008's module map:
-// group owns "C"). Re-exported here for existing @openpanel/validation
-// importers (packages/trpc's group router, apps/start's add-group /
-// edit-group modals) — same shape as the subscription re-export above.
-export * from '@openpanel/core/modules/group/group.constants';
-// Moved into @openpanel/core's subscription module (M6-006, ADR-008's module
-// map: subscription owns "C"). Re-exported here for existing
-// @openpanel/validation importers (packages/trpc's subscription router,
-// apps/start's billing forms) — same shape as ./onboarding.constants.ts
-// re-export since M6-003.
+export * from '@openpanel/core/modules/organization/organization.constants';
+export * from '@openpanel/core/modules/project/project.constants';
+export * from '@openpanel/core/modules/reference/reference.constants';
+export * from '@openpanel/core/modules/report/report.constants';
+export * from '@openpanel/core/modules/share/share.constants';
export * from '@openpanel/core/modules/subscription/subscription.constants';
-
-export const zEditOrganization = z.object({
- id: z.string().min(2),
- name: z.string().min(2),
- timezone: z.string().min(1),
-});
-
-export * from './chat';
-export * from './cohort.validation';
-export * from './import.validation';
-export * from './track.validation';
-export * from './types.insights';
-export * from './types.validation';
diff --git a/packages/validation/src/track.validation.ts b/packages/validation/src/track.validation.ts
deleted file mode 100644
index 4e1988679..000000000
--- a/packages/validation/src/track.validation.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-// Moved into @openpanel/core's ingest module (M8-002, ADR-008's module map:
-// ingest owns "C" — track.validation + event-blocklist + RESERVED_EVENT_NAMES
-// are one file there). Re-exported here for existing @openpanel/validation
-// importers (apps/api's ingest routes and hooks, the SDKs' shared types,
-// apps/start) — same shape as ./import.validation.ts since M5-004. The SDK
-// deep-import retarget to the constants subpath is P11.
-export * from '@openpanel/core/modules/ingest/ingest.constants';
diff --git a/packages/validation/src/types.validation.ts b/packages/validation/src/types.validation.ts
deleted file mode 100644
index 3a6430d2f..000000000
--- a/packages/validation/src/types.validation.ts
+++ /dev/null
@@ -1,123 +0,0 @@
-import type { z } from 'zod';
-
-export type UnionOmit<T, K extends keyof any> = T extends any
- ? Omit<T, K>
- : never;
-
-import type {
- zChartBreakdown,
- zChartEvent,
- zChartEventItem,
- zChartEventSegment,
- zChartFormula,
- zChartSeries,
- zChartType,
- zCriteria,
- zLineType,
- zMetric,
- zRange,
- zReport,
- zReportInput,
- zTimeInterval,
-} from './index';
-
-// For saved reports - complete report with required display fields
-export type IReport = z.infer<typeof zReport>;
-
-// For API/engine use - flexible input
-export type IReportInput = z.infer<typeof zReportInput>;
-
-// With resolved dates (engine internal)
-export interface IReportInputWithDates extends IReportInput {
- startDate: string;
- endDate: string;
-}
-export type IChartEvent = z.infer<typeof zChartEvent>;
-export type IChartFormula = z.infer<typeof zChartFormula>;
-export type IChartEventItem = z.infer<typeof zChartEventItem>;
-export type IChartSeries = z.infer<typeof zChartSeries>;
-// Backward compatibility alias
-export type IChartEvents = IChartSeries;
-export type IChartEventSegment = z.infer<typeof zChartEventSegment>;
-export type IChartEventFilter = IChartEvent['filters'][number];
-export type IChartEventFilterValue =
- IChartEvent['filters'][number]['value'][number];
-export type IChartEventFilterOperator =
- IChartEvent['filters'][number]['operator'];
-export type IChartFilterValueType = NonNullable<
- IChartEvent['filters'][number]['type']
->;
-export type IChartBreakdown = z.infer<typeof zChartBreakdown>;
-export type IInterval = z.infer<typeof zTimeInterval>;
-export type IChartType = z.infer<typeof zChartType>;
-export type IChartMetric = z.infer<typeof zMetric>;
-export type IChartLineType = z.infer<typeof zLineType>;
-export type IChartRange = z.infer<typeof zRange>;
-export type IGetChartDataInput = {
- event: IChartEvent;
- projectId: string;
- startDate: string;
- endDate: string;
-} & Omit<
- IReportInput,
- 'series' | 'globalFilters' | 'startDate' | 'endDate' | 'range'
->;
-export type ICriteria = z.infer<typeof zCriteria>;
-
-export type PreviousValue =
- | {
- value: number;
- diff: number | null;
- state: 'positive' | 'negative' | 'neutral';
- }
- | undefined;
-
-export type Metrics = {
- sum: number;
- average: number;
- min: number;
- max: number;
- count: number | undefined;
- previous?: {
- sum: PreviousValue;
- average: PreviousValue;
- min: PreviousValue;
- max: PreviousValue;
- count: PreviousValue;
- };
-};
-
-export type IChartSerie = {
- id: string;
- names: string[];
- event: {
- id?: string;
- name: string;
- breakdowns?: Record<string, string>;
- };
- metrics: Metrics;
- data: {
- date: string;
- count: number;
- previous: PreviousValue;
- }[];
-};
-
-export type FinalChart = {
- series: IChartSerie[];
- metrics: Metrics;
-};
-
-export type ISetCookie = (
- key: string,
- value: string,
- options: {
- maxAge?: number;
- domain?: string;
- path?: string;
- sameSite?: 'lax' | 'strict' | 'none';
- secure?: boolean;
- httpOnly?: boolean;
- signed?: boolean;
- },
-) => void;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6434fd3f8..95b0dd44a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -914,12 +914,6 @@ importers:
'@node-rs/argon2':
specifier: ^2.0.2
version: 2.0.2
- '@openpanel/common':
- specifier: workspace:*
- version: link:../common
- '@openpanel/constants':
- specifier: workspace:*
- version: link:../constants
'@openpanel/db':
specifier: workspace:*
version: link:../db
@@ -932,9 +926,6 @@ importers:
'@openpanel/redis':
specifier: workspace:*
version: link:../redis
- '@openpanel/validation':
- specifier: workspace:*
- version: link:../validation
'@oslojs/crypto':
specifier: ^1.0.1
version: 1.0.1
@@ -992,6 +983,9 @@ importers:
lru-cache:
specifier: ^11.2.4
version: 11.5.1
+ luxon:
+ specifier: ^3.7.2
+ version: 3.7.2
mathjs:
specifier: ^12.3.2
version: 12.3.2
@@ -1022,6 +1016,9 @@ importers:
short-unique-id:
specifier: ^5.0.3
version: 5.0.3
+ slugify:
+ specifier: ^1.6.6
+ version: 1.6.9
sqlstring:
specifier: ^2.3.3
version: 2.3.3
@@ -1056,6 +1053,9 @@ importers:
'@types/js-yaml':
specifier: ^4.0.9
version: 4.0.9
+ '@types/luxon':
+ specifier: ^3.7.1
+ version: 3.7.1
'@types/qrcode':
specifier: ^1.5.6
version: 1.5.6
@@ -22722,7 +22722,7 @@ snapshots:
require-from-string: 2.0.2
resolve-from: 5.0.0
semver: 7.5.3
- slugify: 1.6.6
+ slugify: 1.6.9
sucrase: 3.34.0
transitivePeerDependencies:
- supports-color
diff --git a/tooling/codemods/p11-map.json b/tooling/codemods/p11-map.json
new file mode 100644
index 000000000..e446bf3d2
--- /dev/null
+++ b/tooling/codemods/p11-map.json
@@ -0,0 +1,377 @@
+[
+{"from":"@openpanel/validation","symbol":"DEFAULT_ASPECT_RATIO","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"DEFAULT_ASPECT_RATIO","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"NOT_SET_VALUE","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"NOT_SET_VALUE","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"timeWindows","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"timeWindows","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"operators","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"operators","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"operatorsShort","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"operatorsShort","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"filterValueTypes","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"filterValueTypes","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IFilterValueType","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"IFilterValueType","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"getOperatorsForType","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"getOperatorsForType","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"chartTypes","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"chartTypes","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"chartSegments","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"chartSegments","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"lineTypes","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"lineTypes","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"intervals","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"intervals","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"alphabetIds","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"alphabetIds","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"metrics","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"metrics","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"isMinuteIntervalEnabledByRange","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"isMinuteIntervalEnabledByRange","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"isHourIntervalEnabledByRange","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"isHourIntervalEnabledByRange","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"getDefaultIntervalByRange","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"getDefaultIntervalByRange","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"getDefaultIntervalByDates","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"getDefaultIntervalByDates","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"countries","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"countries","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"getCountry","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"getCountry","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"chartColors","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"chartColors","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartEventFilter","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartEventFilter","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"getCohortIds","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"getCohortIds","kind":"value","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartEventSegment","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartEventSegment","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartEvent","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartEvent","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartFormula","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartFormula","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartEventWithType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartEventWithType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartEventItem","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartEventItem","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartBreakdown","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartBreakdown","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartSeries","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartSeries","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartBreakdowns","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartBreakdowns","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zLineType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zLineType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zTimeInterval","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zTimeInterval","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zMetric","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zMetric","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zRange","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zRange","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCriteria","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zCriteria","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zFunnelOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zFunnelOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zRetentionOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zRetentionOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zSankeyOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zSankeyOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zHistogramOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zHistogramOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zReportOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zReportOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IReportOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"IReportOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ISankeyOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"ISankeyOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IHistogramOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"IHistogramOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zWidgetType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zWidgetType","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IWidgetType","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"IWidgetType","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zRealtimeWidgetOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zRealtimeWidgetOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCounterWidgetOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zCounterWidgetOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zWidgetOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zWidgetOptions","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IWidgetOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"IWidgetOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ICounterWidgetOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"ICounterWidgetOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IRealtimeWidgetOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"IRealtimeWidgetOptions","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zReportInput","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zReportInput","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zReport","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zReport","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zChartInput","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"zChartInput","kind":"schema","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zShareOverview","kind":"schema","to":"@openpanel/core/modules/share/share.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zShareDashboard","kind":"schema","to":"@openpanel/core/modules/share/share.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zShareReport","kind":"schema","to":"@openpanel/core/modules/share/share.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ENCRYPTED_SECRET_PREFIX","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"looksEncrypted","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IServiceAccountKey","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IServiceAccountKeyResult","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"parseServiceAccountKey","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zSlackConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ISlackConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zWebhookConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IWebhookConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zDiscordConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IDiscordConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zAppConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IAppConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zEmailConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IEmailConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zS3ExportConfigIamRole","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IS3ExportConfigIamRole","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zS3ExportConfigAccessKey","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IS3ExportConfigAccessKey","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zS3ExportConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IS3ExportConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zGCSExportConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IGCSExportConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IIntegrationConfig","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IIntegrationType","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IIntegrationKind","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IIntegrationDescriptor","kind":"type","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"slackDescriptor","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"discordDescriptor","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"webhookDescriptor","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"appDescriptor","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"emailDescriptor","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"s3ExportDescriptor","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"gcsExportDescriptor","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"INTEGRATION_DESCRIPTORS","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"isKind","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zIntegrationConfig","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCreateSlackIntegration","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCreateWebhookIntegration","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCreateDiscordIntegration","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCreateS3ExportIntegration","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCreateGCSExportIntegration","kind":"schema","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"DISCORD_TEST_NOTIFICATION_MESSAGE","kind":"value","to":"@openpanel/core/modules/integration/integration.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zNotificationRuleEventConfig","kind":"schema","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"INotificationRuleEventConfig","kind":"type","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zNotificationRuleFunnelConfig","kind":"schema","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"INotificationRuleFunnelConfig","kind":"type","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zNotificationRuleConfig","kind":"schema","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"INotificationRuleConfig","kind":"type","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCreateNotificationRule","kind":"schema","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ICreateNotificationRule","kind":"type","to":"@openpanel/core/modules/notification/notification.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zOnboardingProject","kind":"schema","to":"@openpanel/core/modules/onboarding/onboarding.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IOnboardingProject","kind":"type","to":"@openpanel/core/modules/onboarding/onboarding.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProvider","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zPassword","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zSignInEmail","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ISignInEmail","kind":"type","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zSignUpEmail","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ISignUpEmail","kind":"type","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zResetPassword","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IResetPassword","kind":"type","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zRequestResetPassword","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IRequestResetPassword","kind":"type","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zTotpCode","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ITotpCode","kind":"type","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zTotpOrRecoveryCode","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ITotpOrRecoveryCode","kind":"type","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zSignInShare","kind":"schema","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ISignInShare","kind":"type","to":"@openpanel/core/modules/auth/auth.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zGroupId","kind":"schema","to":"@openpanel/core/modules/group/group.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCreateGroup","kind":"schema","to":"@openpanel/core/modules/group/group.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ICreateGroup","kind":"type","to":"@openpanel/core/modules/group/group.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zUpdateGroup","kind":"schema","to":"@openpanel/core/modules/group/group.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IUpdateGroup","kind":"type","to":"@openpanel/core/modules/group/group.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCheckout","kind":"schema","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ICheckout","kind":"type","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCancellationReason","kind":"schema","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ICancellationReason","kind":"type","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCancelSubscription","kind":"schema","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ICancelSubscription","kind":"type","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zPauseSubscription","kind":"schema","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IPauseSubscription","kind":"type","to":"@openpanel/core/modules/subscription/subscription.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"pageContextPageSchema","kind":"schema","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"pageContextSchema","kind":"schema","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"PageContext","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"PageContextPage","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"chatContextSchema","kind":"schema","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ChatAgentContext","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ChatProvider","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ChatModelEntry","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"CHAT_MODELS","kind":"value","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ChatModelId","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"MODEL_STORAGE_KEY","kind":"value","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"PREFERRED_DEFAULT_MODEL_ID","kind":"value","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"isValidModelId","kind":"value","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"getModelLabel","kind":"value","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"getAvailableChatModels","kind":"value","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"applyFiltersSchema","kind":"schema","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ApplyFiltersInput","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"setPropertyFiltersSchema","kind":"schema","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"SetPropertyFiltersInput","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"setEventNamesFilterSchema","kind":"schema","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"SetEventNamesFilterInput","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ChatClientToolHandlers","kind":"type","to":"@openpanel/core/modules/assistant/assistant.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zRelativeTimeframe","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zAbsoluteTimeframe","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zTimeframe","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"Timeframe","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zFrequency","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"Frequency","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zEventCriteria","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"EventCriteria","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zEventBasedCohortDefinition","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"EventBasedCohortDefinition","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zPropertyBasedCohortDefinition","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"PropertyBasedCohortDefinition","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCohortDefinition","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"CohortDefinition","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCohortInput","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"CohortInput","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCohortUpdate","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"CohortUpdate","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCohortFilter","kind":"schema","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"CohortFilter","kind":"type","to":"@openpanel/core/modules/cohort/cohort.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ImportProviderId","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ImportProviderType","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ImportProviderMeta","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IMPORT_PROVIDERS","kind":"value","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zHttpUrl","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zUmamiImportConfig","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IUmamiImportConfig","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zPlausibleImportConfig","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IPlausibleImportConfig","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zAmplitudeDataResidency","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IAmplitudeDataResidency","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zAmplitudeImportConfig","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IAmplitudeImportConfig","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zMixpanelDataResidency","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IMixpanelDataResidency","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zMixpanelImportConfig","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IMixpanelImportConfig","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IImportConfig","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zCreateImport","kind":"schema","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"ICreateImport","kind":"type","to":"@openpanel/core/modules/import/import.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"RESERVED_EVENT_NAMES","kind":"value","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"isBlockedEventName","kind":"value","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProfileId","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IGroupPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IAssignGroupPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ITrackPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IIdentifyPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IIncrementPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IDecrementPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IAliasPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IReplayPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ITrackHandlerPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProfileId","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zGroupPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zAssignGroupPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zTrackPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zIdentifyPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zIncrementPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zDecrementPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zAliasPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zReplayPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zTrackHandlerPayload","kind":"schema","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"DeprecatedOpenpanelEventOptions","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"DeprecatedPostEventPayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"DeprecatedUpdateProfilePayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"DeprecatedIncrementProfilePayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"DeprecatedDecrementProfilePayload","kind":"type","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProjectAccessGrant","kind":"schema","to":"@openpanel/core/modules/organization/organization.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProjectAccessGrant","kind":"type","to":"@openpanel/core/modules/organization/organization.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zInviteUser","kind":"schema","to":"@openpanel/core/modules/organization/organization.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zUpdateMemberAccess","kind":"schema","to":"@openpanel/core/modules/organization/organization.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zCreateReference","kind":"schema","to":"@openpanel/core/modules/reference/reference.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"zProjectFilterIp","kind":"schema","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProjectFilterIp","kind":"type","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProjectFilterProfileId","kind":"schema","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProjectFilterProfileId","kind":"type","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProjectFilterEvent","kind":"schema","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProjectFilterEvent","kind":"type","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProjectFilters","kind":"schema","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProjectFilters","kind":"type","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProject","kind":"schema","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProjectEdit","kind":"type","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zProjectUpdate","kind":"schema","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"IProjectUpdate","kind":"type","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"zEditOrganization","kind":"schema","to":"@openpanel/core/modules/organization/organization.constants","keepTypeKeyword":false},
+{"from":"@openpanel/validation","symbol":"InsightMetricKey","kind":"type","to":"@openpanel/core/modules/insight/insight.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"InsightMetricUnit","kind":"type","to":"@openpanel/core/modules/insight/insight.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"InsightMetricEntry","kind":"type","to":"@openpanel/core/modules/insight/insight.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"InsightDimension","kind":"type","to":"@openpanel/core/modules/insight/insight.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"InsightExtra","kind":"type","to":"@openpanel/core/modules/insight/insight.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"InsightPayload","kind":"type","to":"@openpanel/core/modules/insight/insight.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"UnionOmit","kind":"type","to":"apps/start/src/utils/union-omit.ts","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IReport","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IReportInput","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IReportInputWithDates","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartEvent","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartFormula","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartEventItem","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartSeries","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartEvents","kind":"type","to":"DELETE","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartEventSegment","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartEventFilter","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartEventFilterValue","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartEventFilterOperator","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartFilterValueType","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartBreakdown","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IInterval","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartType","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartMetric","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartLineType","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartRange","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IGetChartDataInput","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ICriteria","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"PreviousValue","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"Metrics","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"IChartSerie","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"FinalChart","kind":"type","to":"@openpanel/core/modules/report/report.constants","keepTypeKeyword":true},
+{"from":"@openpanel/validation","symbol":"ISetCookie","kind":"type","to":"DELETE","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"emailCategories","kind":"value","to":"@openpanel/core/modules/email/email.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"EmailCategory","kind":"type","to":"@openpanel/core/modules/email/email.constants","keepTypeKeyword":true},
+{"from":"@openpanel/constants","symbol":"RESERVED_EVENT_NAMES","kind":"value","to":"@openpanel/core/modules/ingest/ingest.constants","keepTypeKeyword":false},
+{"from":"@openpanel/constants","symbol":"ProjectTypeNames","kind":"value","to":"@openpanel/core/modules/project/project.constants","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"DateTime","kind":"value","to":"packages/core/src/shared/date.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"getTime","kind":"value","to":"packages/core/src/shared/date.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"DEFAULT_IP_HEADER_ORDER","kind":"value","to":"packages/core/src/shared/get-client-ip.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"getClientIpFromHeaders","kind":"value","to":"packages/core/src/shared/get-client-ip.ts","keepTypeKeyword":false,"toByConsumer":{"packages/sdks/express":"packages/sdks/express/get-client-ip.ts"}},
+{"from":"@openpanel/common","symbol":"getPreviousMetric","kind":"value","to":"packages/core/src/shared/math.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/math.ts"}},
+{"from":"@openpanel/common","symbol":"ISerieDataItem","kind":"type","to":"packages/core/src/shared/group-by-labels.ts","keepTypeKeyword":true},
+{"from":"@openpanel/common","symbol":"groupByLabels","kind":"value","to":"packages/core/src/shared/group-by-labels.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"shortId","kind":"value","to":"packages/core/src/shared/id.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/math.ts"}},
+{"from":"@openpanel/common","symbol":"generateId","kind":"value","to":"packages/core/src/shared/id.ts","keepTypeKeyword":false,"toByConsumer":{"apps/api":"@openpanel/core"}},
+{"from":"@openpanel/common","symbol":"round","kind":"value","to":"packages/core/src/shared/math.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/math.ts"}},
+{"from":"@openpanel/common","symbol":"average","kind":"value","to":"packages/core/src/shared/math.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/math.ts"}},
+{"from":"@openpanel/common","symbol":"sum","kind":"value","to":"packages/core/src/shared/math.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/math.ts"}},
+{"from":"@openpanel/common","symbol":"min","kind":"value","to":"packages/core/src/shared/math.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/math.ts"}},
+{"from":"@openpanel/common","symbol":"max","kind":"value","to":"packages/core/src/shared/math.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/math.ts"}},
+{"from":"@openpanel/common","symbol":"isFloat","kind":"value","to":"DELETE","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"ifNaN","kind":"value","to":"packages/core/src/shared/math.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"randomName","kind":"value","to":"DELETE","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"randomSplitName","kind":"value","to":"DELETE","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"toDots","kind":"value","to":"packages/core/src/shared/object.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"toObject","kind":"value","to":"packages/core/src/shared/object.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"strip","kind":"value","to":"packages/core/src/shared/object.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"deepMergeObjects","kind":"value","to":"packages/core/src/shared/object.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"slug","kind":"value","to":"packages/core/src/shared/slug.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/slug.ts"}},
+{"from":"@openpanel/common","symbol":"stripTrailingSlash","kind":"value","to":"packages/core/src/shared/string.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"stripLeadingAndTrailingSlashes","kind":"value","to":"packages/core/src/shared/string.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"TIMEZONES","kind":"value","to":"DELETE","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"TryCatchResult","kind":"type","to":"DELETE","keepTypeKeyword":true},
+{"from":"@openpanel/common","symbol":"tryCatch","kind":"value","to":"DELETE","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"parseSearchParams","kind":"value","to":"packages/core/src/shared/url.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"parsePath","kind":"value","to":"packages/core/src/shared/url.ts","keepTypeKeyword":false},
+{"from":"@openpanel/common","symbol":"isSameDomain","kind":"value","to":"packages/core/src/shared/url.ts","keepTypeKeyword":false},
+{"from":"@openpanel/json","symbol":"getSafeJson","kind":"value","to":"packages/core/src/shared/json.ts","keepTypeKeyword":false,"toByConsumer":{"packages/db":"@openpanel/core"}},
+{"from":"@openpanel/json","symbol":"getSuperJson","kind":"value","to":"packages/core/src/shared/json.ts","keepTypeKeyword":false,"toByConsumer":{"apps/start":"apps/start/src/utils/super-json.ts","packages/redis":"packages/redis/json.ts"}},
+{"from":"@openpanel/json","symbol":"setSuperJson","kind":"value","to":"packages/core/src/shared/json.ts","keepTypeKeyword":false,"toByConsumer":{"packages/redis":"packages/redis/json.ts"}}
+]
diff --git a/tooling/codemods/p11-repoint-imports.ts b/tooling/codemods/p11-repoint-imports.ts
new file mode 100644
index 000000000..c29168d3c
--- /dev/null
+++ b/tooling/codemods/p11-repoint-imports.ts
@@ -0,0 +1,146 @@
+/**
+ * P11 (ADR-008): repoint importers of the four dissolving packages
+ * — @openpanel/validation, @openpanel/constants, @openpanel/common,
+ * @openpanel/json — at the targets recorded in ./p11-map.json.
+ *
+ * The map is the single source of truth and is the JSON block of
+ * docs/P11_DISSOLUTION_MAP.md verbatim. A row's `to` is the default target;
+ * `toByConsumer[<workspace>]` overrides it for one workspace.
+ *
+ * Two things it does that a sed cannot:
+ * - one import statement fans out to several targets (packages/db/src/types.ts
+ * splits eight ways), so statements are regrouped by target;
+ * - per-symbol `type` keywords are preserved exactly as written. A `type`
+ * keyword can sit on a runtime binding used only in `z.infer<typeof x>`;
+ * dropping it promotes an erased import into a real one and changes the
+ * bundle (ADR-008 risk 4).
+ *
+ * Usage: bun tooling/codemods/p11-repoint-imports.ts <file...>
+ */
+
+import { readFileSync, writeFileSync } from 'node:fs';
+import { dirname, relative, resolve } from 'node:path';
+
+interface MapRow {
+ from: string;
+ symbol: string;
+ kind: 'type' | 'schema' | 'value';
+ to: string;
+ keepTypeKeyword: boolean;
+ toByConsumer?: Record<string, string>;
+}
+
+const REPO_ROOT = resolve(import.meta.dir, '../..');
+const MAP: MapRow[] = JSON.parse(
+ readFileSync(resolve(import.meta.dir, 'p11-map.json'), 'utf8')
+);
+
+const rows = new Map<string, MapRow>();
+for (const row of MAP) {
+ rows.set(`${row.from}\t${row.symbol}`, row);
+}
+
+const DYING = ['validation', 'constants', 'common', 'json']
+ .map((name) => `@openpanel/${name}`)
+ .join('|');
+const IMPORT_STATEMENT = new RegExp(
+ `import\\s+(type\\s+)?\\{([^}]*)\\}\\s*from\\s*'(${DYING})';`,
+ 'g'
+);
+
+/** `packages/core`, `apps/start`, … — the key `toByConsumer` is written in. */
+function workspaceOf(file: string): string {
+ return relative(REPO_ROOT, file).split('/').slice(0, 2).join('/');
+}
+
+function targetSpecifier(target: string, file: string): string {
+ if (target.startsWith('@openpanel/')) {
+ // A core file reaches its siblings by relative path, never through its own
+ // package (core-no-self-barrel's reasoning applies to every self-import).
+ const selfPrefix = '@openpanel/core/modules/';
+ if (
+ workspaceOf(file) === 'packages/core' &&
+ target.startsWith(selfPrefix)
+ ) {
+ return relativeTo(
+ file,
+ `packages/core/src/modules/${target.slice(selfPrefix.length)}.ts`
+ );
+ }
+ return target;
+ }
+ return relativeTo(file, target);
+}
+
+function relativeTo(file: string, repoRelativeTarget: string): string {
+ const rel = relative(
+ dirname(file),
+ resolve(REPO_ROOT, repoRelativeTarget)
+ ).replace(/\.ts$/, '');
+ return rel.startsWith('.') ? rel : `./${rel}`;
+}
+
+interface Binding {
+ text: string;
+ isType: boolean;
+ symbol: string;
+}
+
+function parseBindings(clause: string, statementIsType: boolean): Binding[] {
+ return clause
+ .split(',')
+ .map((part) => part.trim())
+ .filter(Boolean)
+ .map((text) => {
+ const isType = statementIsType || /^type\s/.test(text);
+ const symbol = text
+ .replace(/^type\s+/, '')
+ .split(/\s+as\s+/)[0]!
+ .trim();
+ return { text: text.replace(/^type\s+/, ''), isType, symbol };
+ });
+}
+
+function render(bindings: Binding[], specifier: string): string {
+ const allType = bindings.every((b) => b.isType);
+ const list = bindings
+ .map((b) => (allType || !b.isType ? b.text : `type ${b.text}`))
+ .join(', ');
+ return `import ${allType ? 'type ' : ''}{ ${list} } from '${specifier}';`;
+}
+
+let changedFiles = 0;
+const unmapped: string[] = [];
+
+for (const file of process.argv.slice(2)) {
+ const source = readFileSync(file, 'utf8');
+ const next = source.replace(
+ IMPORT_STATEMENT,
+ (statement, typeKeyword, clause, from) => {
+ const byTarget = new Map<string, Binding[]>();
+ for (const binding of parseBindings(clause, Boolean(typeKeyword))) {
+ const row = rows.get(`${from}\t${binding.symbol}`);
+ if (!row || row.to === 'DELETE') {
+ unmapped.push(`${file}: ${from} → ${binding.symbol}`);
+ return statement;
+ }
+ const target = row.toByConsumer?.[workspaceOf(file)] ?? row.to;
+ const specifier = targetSpecifier(target, file);
+ byTarget.set(specifier, [...(byTarget.get(specifier) ?? []), binding]);
+ }
+ return [...byTarget.entries()]
+ .map(([specifier, bindings]) => render(bindings, specifier))
+ .join('\n');
+ }
+ );
+ if (next !== source) {
+ writeFileSync(file, next);
+ changedFiles++;
+ }
+}
+
+if (unmapped.length > 0) {
+ console.error(`UNMAPPED (left untouched):\n ${unmapped.join('\n ')}`);
+}
+console.log(`rewrote ${changedFiles} file(s)`);
+process.exit(unmapped.length > 0 ? 1 : 0);