@usebetterdev/contract 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ import type { PluginDefinition } from "@usebetterdev/plugin";
2
+ /** Retention policy controlling automatic and CLI-driven purge of old audit logs. */
3
+ export interface RetentionPolicy {
4
+ /** Purge entries older than this many days. Must be a positive integer. */
5
+ days: number;
6
+ /** When set, only purge logs for these specific tables. */
7
+ tables?: string[];
8
+ }
9
+ /** Static configuration for @usebetterdev/audit. */
10
+ export interface BetterAuditStaticConfig {
11
+ auditTables: string[];
12
+ asyncWrite?: boolean;
13
+ maxQueryLimit?: number;
14
+ retention?: RetentionPolicy;
15
+ /** Plugins to load. Uses the full PluginDefinition type; the runtime BetterAuditConfig uses the simpler plugin shape. */
16
+ plugins?: PluginDefinition[];
17
+ }
18
+ //# sourceMappingURL=config-types-audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-types-audit.d.ts","sourceRoot":"","sources":["../src/config-types-audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,yHAAyH;IACzH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC9B"}
@@ -0,0 +1,28 @@
1
+ /** Static magic link config — serializable subset with no callbacks. */
2
+ export interface StaticMagicLinkConfig {
3
+ allowedEmails: string | string[];
4
+ /**
5
+ * Required when `allowedEmails` contains a `*` wildcard in production.
6
+ * Explicitly acknowledges that any email address can initiate a magic link session.
7
+ */
8
+ allowUnauthenticatedEmails?: boolean;
9
+ /** Maximum failed code verification attempts before lockout. Default: 5. */
10
+ maxAttempts?: number;
11
+ }
12
+ /** Static session config — serializable subset with no callbacks. */
13
+ export interface StaticConsoleSessionConfig {
14
+ magicLink?: StaticMagicLinkConfig;
15
+ autoApprove?: boolean;
16
+ /** Token lifetime as a duration string, e.g. "24h", "8h", "1h". Default: "24h". */
17
+ tokenLifetime?: string;
18
+ refreshEnabled?: boolean;
19
+ }
20
+ /** Static configuration for @usebetterdev/console. */
21
+ export interface BetterConsoleStaticConfig {
22
+ /** Origins allowed for CORS. Default: ["https://console.usebetter.dev"]. */
23
+ allowedOrigins?: string[];
24
+ sessions?: StaticConsoleSessionConfig;
25
+ /** Permission levels granted to sessions. Default: ["read", "write", "admin"]. */
26
+ allowedActions?: Array<"read" | "write" | "admin">;
27
+ }
28
+ //# sourceMappingURL=config-types-console.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-types-console.d.ts","sourceRoot":"","sources":["../src/config-types-console.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC;;;OAGG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qEAAqE;AACrE,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,sDAAsD;AACtD,MAAM,WAAW,yBAAyB;IACxC,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IACtC,kFAAkF;IAClF,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;CACpD"}
@@ -0,0 +1,38 @@
1
+ import type { PluginDefinition } from "@usebetterdev/plugin";
2
+ /** Telemetry options. On by default; set enabled: false to opt out. */
3
+ export interface TelemetryConfig {
4
+ enabled?: boolean;
5
+ debug?: boolean;
6
+ }
7
+ /** Path resolver: pattern e.g. "/t/:tenantId/*" or "/t/:tenantId". */
8
+ export interface PathResolverConfig {
9
+ pattern: string;
10
+ /** Segment index for :tenantId (default derived from pattern). */
11
+ segmentIndex?: number;
12
+ }
13
+ /** Subdomain resolver: use segment index (default 0 = first segment). */
14
+ export type SubdomainResolverConfig = boolean | {
15
+ segmentIndex?: number;
16
+ };
17
+ /** Static JWT resolver config (no runtime callbacks). */
18
+ export interface StaticJwtResolverConfig {
19
+ claim: string;
20
+ }
21
+ /** Static tenant resolver config — serializable subset with no callbacks. */
22
+ export interface StaticTenantResolverConfig {
23
+ header?: string;
24
+ path?: string | PathResolverConfig;
25
+ subdomain?: SubdomainResolverConfig;
26
+ jwt?: string | StaticJwtResolverConfig;
27
+ }
28
+ /** Static configuration for @usebetterdev/tenant. */
29
+ export interface BetterTenantStaticConfig {
30
+ tenantResolver?: StaticTenantResolverConfig;
31
+ tenantTables: string[];
32
+ /** Plugins to load. Uses the full PluginDefinition type; the runtime BetterTenantConfig uses the simpler BetterTenantPlugin shape. */
33
+ plugins?: PluginDefinition[];
34
+ basePath?: string;
35
+ loadTenant?: boolean;
36
+ telemetry?: TelemetryConfig;
37
+ }
38
+ //# sourceMappingURL=config-types-tenant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-types-tenant.d.ts","sourceRoot":"","sources":["../src/config-types-tenant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,yEAAyE;AACzE,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,yDAAyD;AACzD,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,6EAA6E;AAC7E,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAAC;IACnC,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,GAAG,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC;CACxC;AAED,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,0BAA0B,CAAC;IAC5C,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,sIAAsI;IACtI,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/config-types.ts
17
+ var config_types_exports = {};
18
+ module.exports = __toCommonJS(config_types_exports);
19
+ //# sourceMappingURL=config-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config-types.ts"],"sourcesContent":["// ── Tenant config types ──────────────────────────────────────────────────────\n\nexport type {\n TelemetryConfig,\n PathResolverConfig,\n SubdomainResolverConfig,\n StaticJwtResolverConfig,\n StaticTenantResolverConfig,\n BetterTenantStaticConfig,\n} from \"./config-types-tenant.js\";\n\n// ── Audit config types ───────────────────────────────────────────────────────\n\nexport type {\n RetentionPolicy,\n BetterAuditStaticConfig,\n} from \"./config-types-audit.js\";\n\n// ── Console config types ─────────────────────────────────────────────────────\n\nexport type {\n StaticMagicLinkConfig,\n StaticConsoleSessionConfig,\n BetterConsoleStaticConfig,\n} from \"./config-types-console.js\";\n\n// ── Top-level config ─────────────────────────────────────────────────────────\n\nimport type { BetterTenantStaticConfig } from \"./config-types-tenant.js\";\nimport type { BetterAuditStaticConfig } from \"./config-types-audit.js\";\nimport type { BetterConsoleStaticConfig } from \"./config-types-console.js\";\n\n/** Top-level static config object for a Better* application. */\nexport interface BetterConfig {\n tenant?: BetterTenantStaticConfig;\n audit?: BetterAuditStaticConfig;\n console?: BetterConsoleStaticConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,92 @@
1
+ import { PluginDefinition } from '@usebetterdev/plugin';
2
+
3
+ /** Telemetry options. On by default; set enabled: false to opt out. */
4
+ interface TelemetryConfig {
5
+ enabled?: boolean;
6
+ debug?: boolean;
7
+ }
8
+ /** Path resolver: pattern e.g. "/t/:tenantId/*" or "/t/:tenantId". */
9
+ interface PathResolverConfig {
10
+ pattern: string;
11
+ /** Segment index for :tenantId (default derived from pattern). */
12
+ segmentIndex?: number;
13
+ }
14
+ /** Subdomain resolver: use segment index (default 0 = first segment). */
15
+ type SubdomainResolverConfig = boolean | {
16
+ segmentIndex?: number;
17
+ };
18
+ /** Static JWT resolver config (no runtime callbacks). */
19
+ interface StaticJwtResolverConfig {
20
+ claim: string;
21
+ }
22
+ /** Static tenant resolver config — serializable subset with no callbacks. */
23
+ interface StaticTenantResolverConfig {
24
+ header?: string;
25
+ path?: string | PathResolverConfig;
26
+ subdomain?: SubdomainResolverConfig;
27
+ jwt?: string | StaticJwtResolverConfig;
28
+ }
29
+ /** Static configuration for @usebetterdev/tenant. */
30
+ interface BetterTenantStaticConfig {
31
+ tenantResolver?: StaticTenantResolverConfig;
32
+ tenantTables: string[];
33
+ /** Plugins to load. Uses the full PluginDefinition type; the runtime BetterTenantConfig uses the simpler BetterTenantPlugin shape. */
34
+ plugins?: PluginDefinition[];
35
+ basePath?: string;
36
+ loadTenant?: boolean;
37
+ telemetry?: TelemetryConfig;
38
+ }
39
+
40
+ /** Retention policy controlling automatic and CLI-driven purge of old audit logs. */
41
+ interface RetentionPolicy {
42
+ /** Purge entries older than this many days. Must be a positive integer. */
43
+ days: number;
44
+ /** When set, only purge logs for these specific tables. */
45
+ tables?: string[];
46
+ }
47
+ /** Static configuration for @usebetterdev/audit. */
48
+ interface BetterAuditStaticConfig {
49
+ auditTables: string[];
50
+ asyncWrite?: boolean;
51
+ maxQueryLimit?: number;
52
+ retention?: RetentionPolicy;
53
+ /** Plugins to load. Uses the full PluginDefinition type; the runtime BetterAuditConfig uses the simpler plugin shape. */
54
+ plugins?: PluginDefinition[];
55
+ }
56
+
57
+ /** Static magic link config — serializable subset with no callbacks. */
58
+ interface StaticMagicLinkConfig {
59
+ allowedEmails: string | string[];
60
+ /**
61
+ * Required when `allowedEmails` contains a `*` wildcard in production.
62
+ * Explicitly acknowledges that any email address can initiate a magic link session.
63
+ */
64
+ allowUnauthenticatedEmails?: boolean;
65
+ /** Maximum failed code verification attempts before lockout. Default: 5. */
66
+ maxAttempts?: number;
67
+ }
68
+ /** Static session config — serializable subset with no callbacks. */
69
+ interface StaticConsoleSessionConfig {
70
+ magicLink?: StaticMagicLinkConfig;
71
+ autoApprove?: boolean;
72
+ /** Token lifetime as a duration string, e.g. "24h", "8h", "1h". Default: "24h". */
73
+ tokenLifetime?: string;
74
+ refreshEnabled?: boolean;
75
+ }
76
+ /** Static configuration for @usebetterdev/console. */
77
+ interface BetterConsoleStaticConfig {
78
+ /** Origins allowed for CORS. Default: ["https://console.usebetter.dev"]. */
79
+ allowedOrigins?: string[];
80
+ sessions?: StaticConsoleSessionConfig;
81
+ /** Permission levels granted to sessions. Default: ["read", "write", "admin"]. */
82
+ allowedActions?: Array<"read" | "write" | "admin">;
83
+ }
84
+
85
+ /** Top-level static config object for a Better* application. */
86
+ interface BetterConfig {
87
+ tenant?: BetterTenantStaticConfig;
88
+ audit?: BetterAuditStaticConfig;
89
+ console?: BetterConsoleStaticConfig;
90
+ }
91
+
92
+ export type { BetterAuditStaticConfig, BetterConfig, BetterConsoleStaticConfig, BetterTenantStaticConfig, PathResolverConfig, RetentionPolicy, StaticConsoleSessionConfig, StaticJwtResolverConfig, StaticMagicLinkConfig, StaticTenantResolverConfig, SubdomainResolverConfig, TelemetryConfig };
@@ -0,0 +1,13 @@
1
+ export type { TelemetryConfig, PathResolverConfig, SubdomainResolverConfig, StaticJwtResolverConfig, StaticTenantResolverConfig, BetterTenantStaticConfig, } from "./config-types-tenant.js";
2
+ export type { RetentionPolicy, BetterAuditStaticConfig, } from "./config-types-audit.js";
3
+ export type { StaticMagicLinkConfig, StaticConsoleSessionConfig, BetterConsoleStaticConfig, } from "./config-types-console.js";
4
+ import type { BetterTenantStaticConfig } from "./config-types-tenant.js";
5
+ import type { BetterAuditStaticConfig } from "./config-types-audit.js";
6
+ import type { BetterConsoleStaticConfig } from "./config-types-console.js";
7
+ /** Top-level static config object for a Better* application. */
8
+ export interface BetterConfig {
9
+ tenant?: BetterTenantStaticConfig;
10
+ audit?: BetterAuditStaticConfig;
11
+ console?: BetterConsoleStaticConfig;
12
+ }
13
+ //# sourceMappingURL=config-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-types.d.ts","sourceRoot":"","sources":["../src/config-types.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAIlC,YAAY,EACV,eAAe,EACf,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAIjC,YAAY,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,KAAK,CAAC,EAAE,uBAAuB,CAAC;IAChC,OAAO,CAAC,EAAE,yBAAyB,CAAC;CACrC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=config-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var index_exports = {};
18
+ module.exports = __toCommonJS(index_exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/** Permission levels for console access. */\nexport type ConsolePermission = \"read\" | \"write\" | \"admin\";\n\n/** Minimal session info exposed to product handlers. */\nexport interface ConsoleProductSession {\n id: string;\n email: string;\n permissions: ConsolePermission;\n}\n\n/**\n * Request object passed to product endpoint handlers.\n * Constructed by the console after authentication — session is always present.\n */\nexport interface ConsoleProductRequest {\n params: Record<string, string>;\n query: Record<string, string>;\n body: unknown;\n session: ConsoleProductSession;\n}\n\n/** Standardized response from endpoint handlers. */\nexport interface ConsoleResponse {\n status: number;\n body: unknown;\n headers?: Record<string, string>;\n}\n\n/** A single endpoint registered by a product. */\nexport interface ConsoleProductEndpoint {\n method: \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\";\n /** Path relative to the product mount, e.g. \"/tenants\" or \"/logs/:id\". */\n path: string;\n handler: (request: ConsoleProductRequest) => Promise<ConsoleResponse>;\n requiredPermission?: ConsolePermission;\n}\n\n/** Product definition registered with the console. */\nexport interface ConsoleProduct {\n /** Short identifier, e.g. \"tenant\", \"audit\". */\n id: string;\n /** Display name, e.g. \"Better Tenant\". */\n name: string;\n endpoints: ConsoleProductEndpoint[];\n}\n\n/** Interface products use to register with the console. */\nexport interface ConsoleRegistration {\n registerProduct(product: ConsoleProduct): void;\n}\n\n// Re-export well-known endpoint types\nexport type {\n HealthResponse,\n CapabilitiesResponse,\n SessionInitRequest,\n SessionInitResponse,\n SessionVerifyRequest,\n SessionVerifyResponse,\n SessionPollRequest,\n SessionPollResponse,\n SessionClaimRequest,\n SessionClaimResponse,\n} from \"./wellknown-types.js\";\n\n// Re-export wire-format types for product endpoints\nexport type {\n ConsoleErrorResponse,\n AuditLogWire,\n AuditLogsResponse,\n AuditLogResponse,\n AuditStatsResponse,\n AuditEnrichmentSummary,\n AuditEnrichmentsResponse,\n AuditPurgeResponse,\n AuditPurgeRequest,\n AuditLogsQuery,\n AuditStatsQuery,\n TenantWire,\n TenantsResponse,\n TenantResponse,\n CreateTenantRequest,\n UpdateTenantRequest,\n TenantStatsResponse,\n TenantsQuery,\n} from \"./product-types.js\";\n\n// Re-export shared config types\nexport type {\n TelemetryConfig,\n PathResolverConfig,\n SubdomainResolverConfig,\n RetentionPolicy,\n StaticJwtResolverConfig,\n StaticTenantResolverConfig,\n BetterTenantStaticConfig,\n BetterAuditStaticConfig,\n StaticMagicLinkConfig,\n StaticConsoleSessionConfig,\n BetterConsoleStaticConfig,\n BetterConfig,\n} from \"./config-types.js\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,3 @@
1
+ export { AuditEnrichmentSummary, AuditEnrichmentsResponse, AuditLogResponse, AuditLogWire, AuditLogsQuery, AuditLogsResponse, AuditPurgeRequest, AuditPurgeResponse, AuditStatsQuery, AuditStatsResponse, C as CapabilitiesResponse, ConsoleErrorResponse, ConsolePermission, a as ConsoleProduct, b as ConsoleProductEndpoint, c as ConsoleProductRequest, d as ConsoleProductSession, e as ConsoleRegistration, f as ConsoleResponse, CreateTenantRequest, H as HealthResponse, S as SessionClaimRequest, g as SessionClaimResponse, h as SessionInitRequest, i as SessionInitResponse, j as SessionPollRequest, k as SessionPollResponse, l as SessionVerifyRequest, m as SessionVerifyResponse, TenantResponse, TenantStatsResponse, TenantWire, TenantsQuery, TenantsResponse, UpdateTenantRequest } from './product-types.cjs';
2
+ export { BetterAuditStaticConfig, BetterConfig, BetterConsoleStaticConfig, BetterTenantStaticConfig, PathResolverConfig, RetentionPolicy, StaticConsoleSessionConfig, StaticJwtResolverConfig, StaticMagicLinkConfig, StaticTenantResolverConfig, SubdomainResolverConfig, TelemetryConfig } from './config-types.cjs';
3
+ import '@usebetterdev/plugin';
@@ -0,0 +1,48 @@
1
+ /** Permission levels for console access. */
2
+ export type ConsolePermission = "read" | "write" | "admin";
3
+ /** Minimal session info exposed to product handlers. */
4
+ export interface ConsoleProductSession {
5
+ id: string;
6
+ email: string;
7
+ permissions: ConsolePermission;
8
+ }
9
+ /**
10
+ * Request object passed to product endpoint handlers.
11
+ * Constructed by the console after authentication — session is always present.
12
+ */
13
+ export interface ConsoleProductRequest {
14
+ params: Record<string, string>;
15
+ query: Record<string, string>;
16
+ body: unknown;
17
+ session: ConsoleProductSession;
18
+ }
19
+ /** Standardized response from endpoint handlers. */
20
+ export interface ConsoleResponse {
21
+ status: number;
22
+ body: unknown;
23
+ headers?: Record<string, string>;
24
+ }
25
+ /** A single endpoint registered by a product. */
26
+ export interface ConsoleProductEndpoint {
27
+ method: "GET" | "POST" | "PATCH" | "DELETE";
28
+ /** Path relative to the product mount, e.g. "/tenants" or "/logs/:id". */
29
+ path: string;
30
+ handler: (request: ConsoleProductRequest) => Promise<ConsoleResponse>;
31
+ requiredPermission?: ConsolePermission;
32
+ }
33
+ /** Product definition registered with the console. */
34
+ export interface ConsoleProduct {
35
+ /** Short identifier, e.g. "tenant", "audit". */
36
+ id: string;
37
+ /** Display name, e.g. "Better Tenant". */
38
+ name: string;
39
+ endpoints: ConsoleProductEndpoint[];
40
+ }
41
+ /** Interface products use to register with the console. */
42
+ export interface ConsoleRegistration {
43
+ registerProduct(product: ConsoleProduct): void;
44
+ }
45
+ export type { HealthResponse, CapabilitiesResponse, SessionInitRequest, SessionInitResponse, SessionVerifyRequest, SessionVerifyResponse, SessionPollRequest, SessionPollResponse, SessionClaimRequest, SessionClaimResponse, } from "./wellknown-types.js";
46
+ export type { ConsoleErrorResponse, AuditLogWire, AuditLogsResponse, AuditLogResponse, AuditStatsResponse, AuditEnrichmentSummary, AuditEnrichmentsResponse, AuditPurgeResponse, AuditPurgeRequest, AuditLogsQuery, AuditStatsQuery, TenantWire, TenantsResponse, TenantResponse, CreateTenantRequest, UpdateTenantRequest, TenantStatsResponse, TenantsQuery, } from "./product-types.js";
47
+ export type { TelemetryConfig, PathResolverConfig, SubdomainResolverConfig, RetentionPolicy, StaticJwtResolverConfig, StaticTenantResolverConfig, BetterTenantStaticConfig, BetterAuditStaticConfig, StaticMagicLinkConfig, StaticConsoleSessionConfig, BetterConsoleStaticConfig, BetterConfig, } from "./config-types.js";
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D,wDAAwD;AACxD,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,iBAAiB,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,iDAAiD;AACjD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IACtE,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;CACxC;AAED,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,sBAAsB,EAAE,CAAC;CACrC;AAED,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CAChD;AAGD,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,GACb,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/product-types.ts
17
+ var product_types_exports = {};
18
+ module.exports = __toCommonJS(product_types_exports);
19
+ //# sourceMappingURL=product-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/product-types.ts"],"sourcesContent":["/**\n * Wire-format types for product endpoints.\n *\n * These represent the JSON shapes that flow over HTTP between customer apps\n * and the console web app. Server-side types use `Date` objects; wire-format\n * types use `string` (ISO-8601) since JSON serialization converts dates.\n */\n\nimport type { ConsolePermission } from \"./index.js\";\n\n// Re-export so consumers can use a single import path\nexport type { ConsolePermission } from \"./index.js\";\n\n// ---------------------------------------------------------------------------\n// Shared\n// ---------------------------------------------------------------------------\n\n/** Standard error envelope returned by all error responses. */\nexport interface ConsoleErrorResponse {\n error: string;\n code?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Audit — wire types\n// ---------------------------------------------------------------------------\n\n/** Serialized audit log entry (Date fields become ISO-8601 strings). */\nexport interface AuditLogWire {\n id: string;\n /** ISO-8601 timestamp (serialized from Date). */\n timestamp: string;\n tableName: string;\n operation: \"INSERT\" | \"UPDATE\" | \"DELETE\";\n recordId: string;\n beforeData?: Record<string, unknown>;\n afterData?: Record<string, unknown>;\n diff?: { changedFields: string[] };\n actorId?: string;\n label?: string;\n description?: string;\n severity?: \"low\" | \"medium\" | \"high\" | \"critical\";\n compliance?: string[];\n notify?: boolean;\n reason?: string;\n metadata?: Record<string, unknown>;\n redactedFields?: string[];\n}\n\n/** GET /audit/logs response body. */\nexport interface AuditLogsResponse {\n entries: AuditLogWire[];\n nextCursor?: string;\n hasNextPage: boolean;\n}\n\n/** GET /audit/logs/:id response body. */\nexport type AuditLogResponse = AuditLogWire;\n\n/** GET /audit/stats response body. */\nexport interface AuditStatsResponse {\n totalLogs: number;\n tablesAudited: number;\n eventsPerDay: Array<{ date: string; count: number }>;\n topActors: Array<{ actorId: string; count: number }>;\n topTables: Array<{ tableName: string; count: number }>;\n operationBreakdown: Record<string, number>;\n severityBreakdown: Record<string, number>;\n}\n\n/** GET /audit/enrichments response body (single item). */\nexport interface AuditEnrichmentSummary {\n table: string;\n operation: string;\n label?: string;\n severity?: \"low\" | \"medium\" | \"high\" | \"critical\";\n compliance?: string[];\n notify?: boolean;\n redact?: string[];\n include?: string[];\n}\n\n/** GET /audit/enrichments response body. */\nexport type AuditEnrichmentsResponse = AuditEnrichmentSummary[];\n\n/** DELETE /audit/logs response body. */\nexport interface AuditPurgeResponse {\n deletedCount: number;\n}\n\n/** DELETE /audit/logs request body. */\nexport interface AuditPurgeRequest {\n /** ISO-8601 date string. */\n before: string;\n tableName?: string;\n}\n\n/** GET /audit/logs query parameters. All values are strings (URL params). */\nexport interface AuditLogsQuery {\n tableName?: string;\n operation?: string;\n actorId?: string;\n severity?: string;\n compliance?: string;\n /** ISO-8601 date string. */\n since?: string;\n /** ISO-8601 date string. */\n until?: string;\n search?: string;\n /** Stringified positive integer. */\n limit?: string;\n cursor?: string;\n}\n\n/** GET /audit/stats query parameters. */\nexport interface AuditStatsQuery {\n /** ISO-8601 date string. */\n since?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Tenant — wire types\n// ---------------------------------------------------------------------------\n\n/** Serialized tenant record (Date fields become ISO-8601 strings). */\nexport interface TenantWire {\n id: string;\n name: string;\n slug: string;\n /** ISO-8601 timestamp (serialized from Date | string). */\n createdAt: string;\n [key: string]: unknown;\n}\n\n/** GET /tenant/tenants response body. */\nexport type TenantsResponse = TenantWire[];\n\n/** GET /tenant/tenants/:id response body. */\nexport type TenantResponse = TenantWire;\n\n/** POST /tenant/tenants request body. */\nexport interface CreateTenantRequest {\n name: string;\n slug: string;\n}\n\n/** PATCH /tenant/tenants/:id request body. */\nexport interface UpdateTenantRequest {\n name?: string;\n slug?: string;\n}\n\n/** GET /tenant/stats response body. */\nexport interface TenantStatsResponse {\n tenantCount: number;\n}\n\n/** GET /tenant/tenants query parameters. All values are strings (URL params). */\nexport interface TenantsQuery {\n /** Stringified positive integer. */\n limit?: string;\n /** Stringified non-negative integer. */\n offset?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,246 @@
1
+ import './config-types.cjs';
2
+ import '@usebetterdev/plugin';
3
+
4
+ /**
5
+ * Wire-format types for console well-known endpoints.
6
+ *
7
+ * These represent the JSON request/response shapes for the
8
+ * `/.well-known/better/console/*` HTTP endpoints.
9
+ */
10
+
11
+ interface HealthResponse {
12
+ status: "ok";
13
+ }
14
+ interface CapabilitiesResponse {
15
+ products: string[];
16
+ authMethods: string[];
17
+ permissions: ConsolePermission[];
18
+ }
19
+ interface SessionInitRequest {
20
+ email?: string;
21
+ appName?: string;
22
+ baseUrl?: string;
23
+ }
24
+ type SessionInitResponse = {
25
+ method: "auto_approve";
26
+ sessionToken: string;
27
+ expiresIn: number;
28
+ } | {
29
+ method: "magic_link";
30
+ sessionId: string;
31
+ } | {
32
+ method: "redirect";
33
+ redirectUrl: string;
34
+ };
35
+ interface SessionVerifyRequest {
36
+ code: string;
37
+ session_id: string;
38
+ }
39
+ interface SessionVerifyResponse {
40
+ status: "verified";
41
+ }
42
+ interface SessionPollRequest {
43
+ session_id: string;
44
+ }
45
+ interface SessionPollResponse {
46
+ status: "pending" | "verified" | "expired";
47
+ }
48
+ interface SessionClaimRequest {
49
+ session_id: string;
50
+ }
51
+ type SessionClaimResponse = {
52
+ status: "claimed";
53
+ sessionToken: string;
54
+ expiresIn: number;
55
+ } | {
56
+ status: "already_claimed";
57
+ };
58
+
59
+ /**
60
+ * Wire-format types for product endpoints.
61
+ *
62
+ * These represent the JSON shapes that flow over HTTP between customer apps
63
+ * and the console web app. Server-side types use `Date` objects; wire-format
64
+ * types use `string` (ISO-8601) since JSON serialization converts dates.
65
+ */
66
+
67
+ /** Standard error envelope returned by all error responses. */
68
+ interface ConsoleErrorResponse {
69
+ error: string;
70
+ code?: string;
71
+ }
72
+ /** Serialized audit log entry (Date fields become ISO-8601 strings). */
73
+ interface AuditLogWire {
74
+ id: string;
75
+ /** ISO-8601 timestamp (serialized from Date). */
76
+ timestamp: string;
77
+ tableName: string;
78
+ operation: "INSERT" | "UPDATE" | "DELETE";
79
+ recordId: string;
80
+ beforeData?: Record<string, unknown>;
81
+ afterData?: Record<string, unknown>;
82
+ diff?: {
83
+ changedFields: string[];
84
+ };
85
+ actorId?: string;
86
+ label?: string;
87
+ description?: string;
88
+ severity?: "low" | "medium" | "high" | "critical";
89
+ compliance?: string[];
90
+ notify?: boolean;
91
+ reason?: string;
92
+ metadata?: Record<string, unknown>;
93
+ redactedFields?: string[];
94
+ }
95
+ /** GET /audit/logs response body. */
96
+ interface AuditLogsResponse {
97
+ entries: AuditLogWire[];
98
+ nextCursor?: string;
99
+ hasNextPage: boolean;
100
+ }
101
+ /** GET /audit/logs/:id response body. */
102
+ type AuditLogResponse = AuditLogWire;
103
+ /** GET /audit/stats response body. */
104
+ interface AuditStatsResponse {
105
+ totalLogs: number;
106
+ tablesAudited: number;
107
+ eventsPerDay: Array<{
108
+ date: string;
109
+ count: number;
110
+ }>;
111
+ topActors: Array<{
112
+ actorId: string;
113
+ count: number;
114
+ }>;
115
+ topTables: Array<{
116
+ tableName: string;
117
+ count: number;
118
+ }>;
119
+ operationBreakdown: Record<string, number>;
120
+ severityBreakdown: Record<string, number>;
121
+ }
122
+ /** GET /audit/enrichments response body (single item). */
123
+ interface AuditEnrichmentSummary {
124
+ table: string;
125
+ operation: string;
126
+ label?: string;
127
+ severity?: "low" | "medium" | "high" | "critical";
128
+ compliance?: string[];
129
+ notify?: boolean;
130
+ redact?: string[];
131
+ include?: string[];
132
+ }
133
+ /** GET /audit/enrichments response body. */
134
+ type AuditEnrichmentsResponse = AuditEnrichmentSummary[];
135
+ /** DELETE /audit/logs response body. */
136
+ interface AuditPurgeResponse {
137
+ deletedCount: number;
138
+ }
139
+ /** DELETE /audit/logs request body. */
140
+ interface AuditPurgeRequest {
141
+ /** ISO-8601 date string. */
142
+ before: string;
143
+ tableName?: string;
144
+ }
145
+ /** GET /audit/logs query parameters. All values are strings (URL params). */
146
+ interface AuditLogsQuery {
147
+ tableName?: string;
148
+ operation?: string;
149
+ actorId?: string;
150
+ severity?: string;
151
+ compliance?: string;
152
+ /** ISO-8601 date string. */
153
+ since?: string;
154
+ /** ISO-8601 date string. */
155
+ until?: string;
156
+ search?: string;
157
+ /** Stringified positive integer. */
158
+ limit?: string;
159
+ cursor?: string;
160
+ }
161
+ /** GET /audit/stats query parameters. */
162
+ interface AuditStatsQuery {
163
+ /** ISO-8601 date string. */
164
+ since?: string;
165
+ }
166
+ /** Serialized tenant record (Date fields become ISO-8601 strings). */
167
+ interface TenantWire {
168
+ id: string;
169
+ name: string;
170
+ slug: string;
171
+ /** ISO-8601 timestamp (serialized from Date | string). */
172
+ createdAt: string;
173
+ [key: string]: unknown;
174
+ }
175
+ /** GET /tenant/tenants response body. */
176
+ type TenantsResponse = TenantWire[];
177
+ /** GET /tenant/tenants/:id response body. */
178
+ type TenantResponse = TenantWire;
179
+ /** POST /tenant/tenants request body. */
180
+ interface CreateTenantRequest {
181
+ name: string;
182
+ slug: string;
183
+ }
184
+ /** PATCH /tenant/tenants/:id request body. */
185
+ interface UpdateTenantRequest {
186
+ name?: string;
187
+ slug?: string;
188
+ }
189
+ /** GET /tenant/stats response body. */
190
+ interface TenantStatsResponse {
191
+ tenantCount: number;
192
+ }
193
+ /** GET /tenant/tenants query parameters. All values are strings (URL params). */
194
+ interface TenantsQuery {
195
+ /** Stringified positive integer. */
196
+ limit?: string;
197
+ /** Stringified non-negative integer. */
198
+ offset?: string;
199
+ }
200
+
201
+ /** Permission levels for console access. */
202
+ type ConsolePermission = "read" | "write" | "admin";
203
+ /** Minimal session info exposed to product handlers. */
204
+ interface ConsoleProductSession {
205
+ id: string;
206
+ email: string;
207
+ permissions: ConsolePermission;
208
+ }
209
+ /**
210
+ * Request object passed to product endpoint handlers.
211
+ * Constructed by the console after authentication — session is always present.
212
+ */
213
+ interface ConsoleProductRequest {
214
+ params: Record<string, string>;
215
+ query: Record<string, string>;
216
+ body: unknown;
217
+ session: ConsoleProductSession;
218
+ }
219
+ /** Standardized response from endpoint handlers. */
220
+ interface ConsoleResponse {
221
+ status: number;
222
+ body: unknown;
223
+ headers?: Record<string, string>;
224
+ }
225
+ /** A single endpoint registered by a product. */
226
+ interface ConsoleProductEndpoint {
227
+ method: "GET" | "POST" | "PATCH" | "DELETE";
228
+ /** Path relative to the product mount, e.g. "/tenants" or "/logs/:id". */
229
+ path: string;
230
+ handler: (request: ConsoleProductRequest) => Promise<ConsoleResponse>;
231
+ requiredPermission?: ConsolePermission;
232
+ }
233
+ /** Product definition registered with the console. */
234
+ interface ConsoleProduct {
235
+ /** Short identifier, e.g. "tenant", "audit". */
236
+ id: string;
237
+ /** Display name, e.g. "Better Tenant". */
238
+ name: string;
239
+ endpoints: ConsoleProductEndpoint[];
240
+ }
241
+ /** Interface products use to register with the console. */
242
+ interface ConsoleRegistration {
243
+ registerProduct(product: ConsoleProduct): void;
244
+ }
245
+
246
+ export type { AuditEnrichmentSummary, AuditEnrichmentsResponse, AuditLogResponse, AuditLogWire, AuditLogsQuery, AuditLogsResponse, AuditPurgeRequest, AuditPurgeResponse, AuditStatsQuery, AuditStatsResponse, CapabilitiesResponse as C, ConsoleErrorResponse, ConsolePermission, CreateTenantRequest, HealthResponse as H, SessionClaimRequest as S, TenantResponse, TenantStatsResponse, TenantWire, TenantsQuery, TenantsResponse, UpdateTenantRequest, ConsoleProduct as a, ConsoleProductEndpoint as b, ConsoleProductRequest as c, ConsoleProductSession as d, ConsoleRegistration as e, ConsoleResponse as f, SessionClaimResponse as g, SessionInitRequest as h, SessionInitResponse as i, SessionPollRequest as j, SessionPollResponse as k, SessionVerifyRequest as l, SessionVerifyResponse as m };
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Wire-format types for product endpoints.
3
+ *
4
+ * These represent the JSON shapes that flow over HTTP between customer apps
5
+ * and the console web app. Server-side types use `Date` objects; wire-format
6
+ * types use `string` (ISO-8601) since JSON serialization converts dates.
7
+ */
8
+ export type { ConsolePermission } from "./index.js";
9
+ /** Standard error envelope returned by all error responses. */
10
+ export interface ConsoleErrorResponse {
11
+ error: string;
12
+ code?: string;
13
+ }
14
+ /** Serialized audit log entry (Date fields become ISO-8601 strings). */
15
+ export interface AuditLogWire {
16
+ id: string;
17
+ /** ISO-8601 timestamp (serialized from Date). */
18
+ timestamp: string;
19
+ tableName: string;
20
+ operation: "INSERT" | "UPDATE" | "DELETE";
21
+ recordId: string;
22
+ beforeData?: Record<string, unknown>;
23
+ afterData?: Record<string, unknown>;
24
+ diff?: {
25
+ changedFields: string[];
26
+ };
27
+ actorId?: string;
28
+ label?: string;
29
+ description?: string;
30
+ severity?: "low" | "medium" | "high" | "critical";
31
+ compliance?: string[];
32
+ notify?: boolean;
33
+ reason?: string;
34
+ metadata?: Record<string, unknown>;
35
+ redactedFields?: string[];
36
+ }
37
+ /** GET /audit/logs response body. */
38
+ export interface AuditLogsResponse {
39
+ entries: AuditLogWire[];
40
+ nextCursor?: string;
41
+ hasNextPage: boolean;
42
+ }
43
+ /** GET /audit/logs/:id response body. */
44
+ export type AuditLogResponse = AuditLogWire;
45
+ /** GET /audit/stats response body. */
46
+ export interface AuditStatsResponse {
47
+ totalLogs: number;
48
+ tablesAudited: number;
49
+ eventsPerDay: Array<{
50
+ date: string;
51
+ count: number;
52
+ }>;
53
+ topActors: Array<{
54
+ actorId: string;
55
+ count: number;
56
+ }>;
57
+ topTables: Array<{
58
+ tableName: string;
59
+ count: number;
60
+ }>;
61
+ operationBreakdown: Record<string, number>;
62
+ severityBreakdown: Record<string, number>;
63
+ }
64
+ /** GET /audit/enrichments response body (single item). */
65
+ export interface AuditEnrichmentSummary {
66
+ table: string;
67
+ operation: string;
68
+ label?: string;
69
+ severity?: "low" | "medium" | "high" | "critical";
70
+ compliance?: string[];
71
+ notify?: boolean;
72
+ redact?: string[];
73
+ include?: string[];
74
+ }
75
+ /** GET /audit/enrichments response body. */
76
+ export type AuditEnrichmentsResponse = AuditEnrichmentSummary[];
77
+ /** DELETE /audit/logs response body. */
78
+ export interface AuditPurgeResponse {
79
+ deletedCount: number;
80
+ }
81
+ /** DELETE /audit/logs request body. */
82
+ export interface AuditPurgeRequest {
83
+ /** ISO-8601 date string. */
84
+ before: string;
85
+ tableName?: string;
86
+ }
87
+ /** GET /audit/logs query parameters. All values are strings (URL params). */
88
+ export interface AuditLogsQuery {
89
+ tableName?: string;
90
+ operation?: string;
91
+ actorId?: string;
92
+ severity?: string;
93
+ compliance?: string;
94
+ /** ISO-8601 date string. */
95
+ since?: string;
96
+ /** ISO-8601 date string. */
97
+ until?: string;
98
+ search?: string;
99
+ /** Stringified positive integer. */
100
+ limit?: string;
101
+ cursor?: string;
102
+ }
103
+ /** GET /audit/stats query parameters. */
104
+ export interface AuditStatsQuery {
105
+ /** ISO-8601 date string. */
106
+ since?: string;
107
+ }
108
+ /** Serialized tenant record (Date fields become ISO-8601 strings). */
109
+ export interface TenantWire {
110
+ id: string;
111
+ name: string;
112
+ slug: string;
113
+ /** ISO-8601 timestamp (serialized from Date | string). */
114
+ createdAt: string;
115
+ [key: string]: unknown;
116
+ }
117
+ /** GET /tenant/tenants response body. */
118
+ export type TenantsResponse = TenantWire[];
119
+ /** GET /tenant/tenants/:id response body. */
120
+ export type TenantResponse = TenantWire;
121
+ /** POST /tenant/tenants request body. */
122
+ export interface CreateTenantRequest {
123
+ name: string;
124
+ slug: string;
125
+ }
126
+ /** PATCH /tenant/tenants/:id request body. */
127
+ export interface UpdateTenantRequest {
128
+ name?: string;
129
+ slug?: string;
130
+ }
131
+ /** GET /tenant/stats response body. */
132
+ export interface TenantStatsResponse {
133
+ tenantCount: number;
134
+ }
135
+ /** GET /tenant/tenants query parameters. All values are strings (URL params). */
136
+ export interface TenantsQuery {
137
+ /** Stringified positive integer. */
138
+ limit?: string;
139
+ /** Stringified non-negative integer. */
140
+ offset?: string;
141
+ }
142
+ //# sourceMappingURL=product-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-types.d.ts","sourceRoot":"","sources":["../src/product-types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=product-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Wire-format types for console well-known endpoints.
3
+ *
4
+ * These represent the JSON request/response shapes for the
5
+ * `/.well-known/better/console/*` HTTP endpoints.
6
+ */
7
+ import type { ConsolePermission } from "./index.js";
8
+ export interface HealthResponse {
9
+ status: "ok";
10
+ }
11
+ export interface CapabilitiesResponse {
12
+ products: string[];
13
+ authMethods: string[];
14
+ permissions: ConsolePermission[];
15
+ }
16
+ export interface SessionInitRequest {
17
+ email?: string;
18
+ appName?: string;
19
+ baseUrl?: string;
20
+ }
21
+ export type SessionInitResponse = {
22
+ method: "auto_approve";
23
+ sessionToken: string;
24
+ expiresIn: number;
25
+ } | {
26
+ method: "magic_link";
27
+ sessionId: string;
28
+ } | {
29
+ method: "redirect";
30
+ redirectUrl: string;
31
+ };
32
+ export interface SessionVerifyRequest {
33
+ code: string;
34
+ session_id: string;
35
+ }
36
+ export interface SessionVerifyResponse {
37
+ status: "verified";
38
+ }
39
+ export interface SessionPollRequest {
40
+ session_id: string;
41
+ }
42
+ export interface SessionPollResponse {
43
+ status: "pending" | "verified" | "expired";
44
+ }
45
+ export interface SessionClaimRequest {
46
+ session_id: string;
47
+ }
48
+ export type SessionClaimResponse = {
49
+ status: "claimed";
50
+ sessionToken: string;
51
+ expiresIn: number;
52
+ } | {
53
+ status: "already_claimed";
54
+ };
55
+ //# sourceMappingURL=wellknown-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wellknown-types.d.ts","sourceRoot":"","sources":["../src/wellknown-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAMpD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,IAAI,CAAC;CACd;AAMD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAClC;AAMD,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACnE;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAMhD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,UAAU,CAAC;CACpB;AAMD,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;CAC5C;AAMD,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC9D;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@usebetterdev/contract",
3
+ "version": "0.5.0",
4
+ "repository": "github:usebetter-dev/usebetter",
5
+ "bugs": "https://github.com/usebetter-dev/usebetter/issues",
6
+ "homepage": "https://github.com/usebetter-dev/usebetter#readme",
7
+ "publishConfig": {
8
+ "access": "public",
9
+ "registry": "https://registry.npmjs.org/"
10
+ },
11
+ "type": "module",
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.cjs"
20
+ },
21
+ "./product-types": {
22
+ "types": "./dist/product-types.d.ts",
23
+ "import": "./dist/product-types.js",
24
+ "require": "./dist/product-types.cjs"
25
+ },
26
+ "./config-types": {
27
+ "types": "./dist/config-types.d.ts",
28
+ "import": "./dist/config-types.js",
29
+ "require": "./dist/config-types.cjs"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ],
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "build:types": "tsc --build tsconfig.build.json",
39
+ "typecheck": "tsc --noEmit"
40
+ },
41
+ "dependencies": {
42
+ "@usebetterdev/plugin": "workspace:*"
43
+ },
44
+ "devDependencies": {
45
+ "tsup": "^8.3.5",
46
+ "typescript": "~5.7.2"
47
+ },
48
+ "engines": {
49
+ "node": ">=22"
50
+ }
51
+ }