@proteos/sdk 0.49.0 → 0.51.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.
- package/dist/{chunk-TDG5QFZ5.js → chunk-IRFFXJMB.js} +66 -4
- package/dist/chunk-IRFFXJMB.js.map +1 -0
- package/dist/{chunk-OD7GPJAW.cjs → chunk-RKFXHDVU.cjs} +67 -3
- package/dist/chunk-RKFXHDVU.cjs.map +1 -0
- package/dist/index.cjs +456 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1036 -9
- package/dist/index.d.ts +1036 -9
- package/dist/index.js +353 -5
- package/dist/index.js.map +1 -1
- package/dist/meta/index.cjs +65 -57
- package/dist/meta/index.d.cts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/meta/index.js +1 -1
- package/dist/{types-COxVBT4w.d.cts → types-C9flkAj-.d.cts} +208 -7
- package/dist/{types-COxVBT4w.d.ts → types-C9flkAj-.d.ts} +208 -7
- package/package.json +1 -1
- package/src/auth/index.ts +40 -11
- package/src/auth/me.ts +13 -1
- package/src/auth/platform-entities.ts +17 -0
- package/src/auth/profiles.ts +82 -0
- package/src/auth/types.ts +87 -0
- package/src/auth/user-profile-assignments.ts +41 -0
- package/src/auth/users.ts +37 -0
- package/src/conversation/index.ts +417 -10
- package/src/conversation/types.ts +731 -3
- package/src/errors.ts +20 -3
- package/src/index.ts +104 -17
- package/src/meta/app-configurations.ts +100 -0
- package/src/meta/index.ts +28 -10
- package/src/meta/types.ts +94 -4
- package/src/workflow/types.ts +13 -0
- package/dist/chunk-OD7GPJAW.cjs.map +0 -1
- package/dist/chunk-TDG5QFZ5.js.map +0 -1
|
@@ -110,6 +110,47 @@ function createIterator(listFn, options) {
|
|
|
110
110
|
return new PageIterator(listFn, options);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// src/meta/app-configurations.ts
|
|
114
|
+
var APP_CONFIGURATIONS_BASE_PATH = "/meta/v1/app-configurations";
|
|
115
|
+
var AppConfigurationServiceImpl = class {
|
|
116
|
+
constructor(client) {
|
|
117
|
+
this.client = client;
|
|
118
|
+
}
|
|
119
|
+
client;
|
|
120
|
+
list(options = {}) {
|
|
121
|
+
return new PageIterator((opts) => this.listPage(opts), options);
|
|
122
|
+
}
|
|
123
|
+
async listPage(options = {}) {
|
|
124
|
+
return this.client.requestWithQuery(
|
|
125
|
+
"GET",
|
|
126
|
+
APP_CONFIGURATIONS_BASE_PATH,
|
|
127
|
+
options
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
async get(slug) {
|
|
131
|
+
return this.client.request("GET", `${APP_CONFIGURATIONS_BASE_PATH}/${slug}`);
|
|
132
|
+
}
|
|
133
|
+
async create(request) {
|
|
134
|
+
return this.client.request("POST", APP_CONFIGURATIONS_BASE_PATH, request);
|
|
135
|
+
}
|
|
136
|
+
async upsert(slug, request) {
|
|
137
|
+
return this.client.request("PUT", `${APP_CONFIGURATIONS_BASE_PATH}/${slug}`, {
|
|
138
|
+
...request,
|
|
139
|
+
slug
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async update(slug, request) {
|
|
143
|
+
return this.client.request(
|
|
144
|
+
"PATCH",
|
|
145
|
+
`${APP_CONFIGURATIONS_BASE_PATH}/${slug}`,
|
|
146
|
+
request
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
async delete(slug) {
|
|
150
|
+
await this.client.request("DELETE", `${APP_CONFIGURATIONS_BASE_PATH}/${slug}`);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
113
154
|
// src/meta/apps.ts
|
|
114
155
|
var APPS_BASE_PATH = "/meta/v1/apps";
|
|
115
156
|
var AppServiceImpl = class {
|
|
@@ -1334,7 +1375,6 @@ var ListSchema = AuditFieldsSchema.extend({
|
|
|
1334
1375
|
columns: zod.z.array(ColumnSchema),
|
|
1335
1376
|
actions: zod.z.array(PageActionSchema).optional(),
|
|
1336
1377
|
selection_mode: SelectionModeSchema.optional(),
|
|
1337
|
-
default_page_slug: zod.z.string().optional(),
|
|
1338
1378
|
sorting: zod.z.array(SortConfigSchema),
|
|
1339
1379
|
filters: zod.z.array(FilterGroupSchema)
|
|
1340
1380
|
});
|
|
@@ -1383,6 +1423,22 @@ var MenuConfigurationSchema = AuditFieldsSchema.extend({
|
|
|
1383
1423
|
items: zod.z.array(MenuItemSchema),
|
|
1384
1424
|
is_default: zod.z.boolean()
|
|
1385
1425
|
});
|
|
1426
|
+
var AppHomeSchema = zod.z.object({
|
|
1427
|
+
type: zod.z.enum(["list", "page"]),
|
|
1428
|
+
reference: zod.z.string()
|
|
1429
|
+
});
|
|
1430
|
+
var AppConfigurationSchema = AuditFieldsSchema.extend({
|
|
1431
|
+
slug: zod.z.string(),
|
|
1432
|
+
org_id: zod.z.string(),
|
|
1433
|
+
module_slug: zod.z.string(),
|
|
1434
|
+
app_slug: zod.z.string(),
|
|
1435
|
+
profile_slug: zod.z.string(),
|
|
1436
|
+
home: AppHomeSchema.nullable().optional(),
|
|
1437
|
+
menu_slug: zod.z.string().optional(),
|
|
1438
|
+
default_agent_key: zod.z.string().optional(),
|
|
1439
|
+
agent_keys: zod.z.array(zod.z.string()).optional(),
|
|
1440
|
+
record_pages: zod.z.record(zod.z.string()).optional()
|
|
1441
|
+
});
|
|
1386
1442
|
var AppSchema = AuditFieldsSchema.extend({
|
|
1387
1443
|
slug: zod.z.string(),
|
|
1388
1444
|
org_id: zod.z.string(),
|
|
@@ -1446,6 +1502,11 @@ var MetaClient = class {
|
|
|
1446
1502
|
* Service for managing apps.
|
|
1447
1503
|
*/
|
|
1448
1504
|
apps;
|
|
1505
|
+
/**
|
|
1506
|
+
* Service for managing app configurations — the typed (app × profile)
|
|
1507
|
+
* bindings: home, menu, agents, record pages.
|
|
1508
|
+
*/
|
|
1509
|
+
appConfigurations;
|
|
1449
1510
|
/**
|
|
1450
1511
|
* Service for managing design references (stored DESIGN.md documents).
|
|
1451
1512
|
*/
|
|
@@ -1465,10 +1526,13 @@ var MetaClient = class {
|
|
|
1465
1526
|
this.pages = new PageServiceImpl(client);
|
|
1466
1527
|
this.menuConfigurations = new MenuConfigurationServiceImpl(client);
|
|
1467
1528
|
this.apps = new AppServiceImpl(client);
|
|
1529
|
+
this.appConfigurations = new AppConfigurationServiceImpl(client);
|
|
1468
1530
|
this.designReferences = new DesignReferenceServiceImpl(client);
|
|
1469
1531
|
}
|
|
1470
1532
|
};
|
|
1471
1533
|
|
|
1534
|
+
exports.AppConfigurationSchema = AppConfigurationSchema;
|
|
1535
|
+
exports.AppHomeSchema = AppHomeSchema;
|
|
1472
1536
|
exports.AppSchema = AppSchema;
|
|
1473
1537
|
exports.AttributeSchema = AttributeSchema;
|
|
1474
1538
|
exports.AuditFieldsSchema = AuditFieldsSchema;
|
|
@@ -1536,5 +1600,5 @@ exports.parsePrincipalMeta = parsePrincipalMeta;
|
|
|
1536
1600
|
exports.parseRelationMeta = parseRelationMeta;
|
|
1537
1601
|
exports.parseUserMeta = parseUserMeta;
|
|
1538
1602
|
exports.platformAttributes = platformAttributes;
|
|
1539
|
-
//# sourceMappingURL=chunk-
|
|
1540
|
-
//# sourceMappingURL=chunk-
|
|
1603
|
+
//# sourceMappingURL=chunk-RKFXHDVU.cjs.map
|
|
1604
|
+
//# sourceMappingURL=chunk-RKFXHDVU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/iterator.ts","../src/meta/app-configurations.ts","../src/meta/apps.ts","../src/meta/components.ts","../src/meta/design-references.ts","../src/meta/entities.ts","../src/meta/list-views.ts","../src/meta/lists.ts","../src/meta/menu-configurations.ts","../src/meta/modules.ts","../src/meta/pages.ts","../src/meta/variables.ts","../src/meta/currency/index.ts","../src/meta/layout/control-registry.json","../src/meta/layout/control-registry.ts","../src/meta/filters.ts","../src/meta/layout/size-value.ts","../src/meta/layout/common-props.ts","../src/meta/layout/elements.ts","../src/meta/layout/page-layout.ts","../src/types/common.ts","../src/meta/types.ts","../src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A;AACrC,IAAA,IAAA,CAAK,iBAAA,GAAoB,IAAI,2BAAA,CAA4B,MAAM,CAAA;AAC/D,IAAA,IAAA,CAAK,gBAAA,GAAmB,IAAI,0BAAA,CAA2B,MAAM,CAAA;AAAA,EAC/D;AACF","file":"chunk-RKFXHDVU.cjs","sourcesContent":["import type { ListOptions, ListResult } from './types/common.js'\n\n/**\n * Sentinel symbol indicating iteration is complete.\n */\nexport const DONE = Symbol('DONE')\nexport type Done = typeof DONE\n\n/**\n * Function type for fetching a page of results.\n * @typeParam T - The type of items in the list\n * @typeParam O - The type of options for the list request\n */\nexport type ListFn<T, O extends ListOptions> = (options: O) => Promise<ListResult<T>>\n\n/**\n * Default page size for pagination.\n */\nexport const DEFAULT_PAGE_SIZE = 100\n\n/**\n * Async iterator for paginated resources.\n * Provides Google Cloud-style iteration with automatic page fetching.\n *\n * @typeParam T - The type of items being iterated\n * @typeParam O - The type of options for list requests\n *\n * @example\n * ```ts\n * // Using for-await-of\n * const iterator = new PageIterator(fetchEntities, { page_size: 50 });\n * for await (const entity of iterator) {\n * console.log(entity);\n * }\n *\n * // Using next() directly\n * const item = await iterator.next();\n * if (item !== DONE) {\n * console.log(item);\n * }\n *\n * // Collecting all items\n * const allItems = await iterator.all();\n * ```\n */\nexport class PageIterator<T, O extends ListOptions> implements AsyncIterable<T> {\n private readonly listFn: ListFn<T, O>\n private readonly options: O\n // Pages are 0-indexed across all Proteos services. First fetch is page 0,\n // last is pagesTotal - 1.\n private page: number = 0\n private buffer: T[] = []\n private bufferIndex: number = 0\n private pagesTotal: number | undefined\n\n /**\n * Creates a new PageIterator.\n *\n * @param listFn - Function to fetch a page of results\n * @param options - Options for list requests (including pagination)\n */\n constructor(listFn: ListFn<T, O>, options: O) {\n this.listFn = listFn\n this.options = { ...options }\n\n // Set default page size if not provided\n if (!this.options.page_size) {\n this.options.page_size = DEFAULT_PAGE_SIZE\n }\n }\n\n /**\n * Returns the next item in the iterator.\n * Returns DONE symbol when iteration is complete.\n *\n * @returns The next item or DONE\n *\n * @example\n * ```ts\n * const item = await iterator.next();\n * if (item !== DONE) {\n * console.log(item);\n * }\n * ```\n */\n async next(): Promise<T | Done> {\n // Return next item from buffer if available\n if (this.bufferIndex < this.buffer.length) {\n const item = this.buffer[this.bufferIndex]\n this.bufferIndex++\n return item as T\n }\n\n // Check if we've exhausted all pages. Pages are 0-indexed, so the last\n // valid page is `pagesTotal - 1`; once `this.page` reaches `pagesTotal`\n // there are no more to fetch.\n if (this.pagesTotal !== undefined && this.page >= this.pagesTotal) {\n return DONE\n }\n\n // Fetch next page\n const result = await this.listFn({\n ...this.options,\n page: this.page,\n })\n\n // Update total pages from response\n this.pagesTotal = result.meta.pages_total\n\n // Empty page means we're done\n if (result.data.length === 0) {\n return DONE\n }\n\n // Update buffer and indices\n this.buffer = result.data\n this.bufferIndex = 1 // Start at 1 since we'll return index 0\n this.page++\n\n return this.buffer[0] as T\n }\n\n /**\n * Collects all remaining items into an array.\n * Useful when you need all items at once.\n *\n * @returns Array of all remaining items\n *\n * @example\n * ```ts\n * const allEntities = await iterator.all();\n * console.log(`Found ${allEntities.length} entities`);\n * ```\n */\n async all(): Promise<T[]> {\n const items: T[] = []\n\n while (true) {\n const item = await this.next()\n if (item === DONE) {\n break\n }\n items.push(item)\n }\n\n return items\n }\n\n /**\n * Implements AsyncIterable for use with for-await-of loops.\n *\n * @example\n * ```ts\n * for await (const entity of iterator) {\n * console.log(entity.name);\n * }\n * ```\n */\n async *[Symbol.asyncIterator](): AsyncIterator<T> {\n while (true) {\n const item = await this.next()\n if (item === DONE) {\n return\n }\n yield item\n }\n }\n}\n\n/**\n * Creates a PageIterator with the given list function and options.\n * Convenience function for creating iterators.\n *\n * @param listFn - Function to fetch a page of results\n * @param options - Options for list requests\n * @returns A new PageIterator instance\n */\nexport function createIterator<T, O extends ListOptions>(\n listFn: ListFn<T, O>,\n options: O,\n): PageIterator<T, O> {\n return new PageIterator(listFn, options)\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n AppConfiguration,\n CreateAppConfigurationRequest,\n ListAppConfigurationsOptions,\n UpdateAppConfigurationRequest,\n} from './types.js'\n\nconst APP_CONFIGURATIONS_BASE_PATH = '/meta/v1/app-configurations'\n\n/**\n * Service for app configurations — the typed (app × profile) binding rows\n * that say how an app presents itself: home, menu, agents, record pages.\n * `profile_slug: ''` is the app's base configuration for everyone; a row with\n * a profile is that profile's override (merged field-wise over the base).\n */\nexport interface AppConfigurationService {\n /** Lists app configurations (auto-paginating iterator). */\n list(\n options?: ListAppConfigurationsOptions,\n ): PageIterator<AppConfiguration, ListAppConfigurationsOptions>\n\n /** Fetches a single page of app configurations. */\n listPage(options?: ListAppConfigurationsOptions): Promise<ListResult<AppConfiguration>>\n\n /** Gets an app configuration by slug (404 when unknown). */\n get(slug: string): Promise<AppConfiguration>\n\n /**\n * Creates an app configuration. Every reference (app, home list/page, menu,\n * record pages) must exist; `profile_slug` and agent keys are other\n * services' and are not validated.\n * @throws {ProteosError} 409 `app_configuration_already_exists` when the\n * (app_slug, profile_slug) pair is already bound.\n */\n create(request: CreateAppConfigurationRequest): Promise<AppConfiguration>\n\n /**\n * Creates or replaces an app configuration idempotently by slug\n * (`PUT /meta/v1/app-configurations/:slug`). Replaces the whole\n * configuration; the (app_slug, profile_slug) binding of an existing slug\n * is immutable.\n */\n upsert(slug: string, request: CreateAppConfigurationRequest): Promise<AppConfiguration>\n\n /** Partially updates an app configuration (`home: null` clears the home). */\n update(slug: string, request: UpdateAppConfigurationRequest): Promise<AppConfiguration>\n\n /** Deletes an app configuration. */\n delete(slug: string): Promise<void>\n}\n\nexport class AppConfigurationServiceImpl implements AppConfigurationService {\n constructor(private readonly client: ProteosClient) {}\n\n list(\n options: ListAppConfigurationsOptions = {},\n ): PageIterator<AppConfiguration, ListAppConfigurationsOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(\n options: ListAppConfigurationsOptions = {},\n ): Promise<ListResult<AppConfiguration>> {\n return this.client.requestWithQuery<ListResult<AppConfiguration>>(\n 'GET',\n APP_CONFIGURATIONS_BASE_PATH,\n options,\n )\n }\n\n async get(slug: string): Promise<AppConfiguration> {\n return this.client.request<AppConfiguration>('GET', `${APP_CONFIGURATIONS_BASE_PATH}/${slug}`)\n }\n\n async create(request: CreateAppConfigurationRequest): Promise<AppConfiguration> {\n return this.client.request<AppConfiguration>('POST', APP_CONFIGURATIONS_BASE_PATH, request)\n }\n\n async upsert(slug: string, request: CreateAppConfigurationRequest): Promise<AppConfiguration> {\n return this.client.request<AppConfiguration>('PUT', `${APP_CONFIGURATIONS_BASE_PATH}/${slug}`, {\n ...request,\n slug,\n })\n }\n\n async update(slug: string, request: UpdateAppConfigurationRequest): Promise<AppConfiguration> {\n return this.client.request<AppConfiguration>(\n 'PATCH',\n `${APP_CONFIGURATIONS_BASE_PATH}/${slug}`,\n request,\n )\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${APP_CONFIGURATIONS_BASE_PATH}/${slug}`)\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type { App, CreateAppRequest, ListAppsOptions, UpdateAppRequest } from './types.js'\n\nconst APPS_BASE_PATH = '/meta/v1/apps'\n\n/**\n * Service for managing apps.\n * Apps group menu configurations and other org-scoped metadata under a\n * stable slug. Slugs are unique per org.\n */\nexport interface AppService {\n /**\n * Lists apps with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over apps\n */\n list(options?: ListAppsOptions): PageIterator<App, ListAppsOptions>\n\n /**\n * Fetches a single page of apps.\n */\n listPage(options?: ListAppsOptions): Promise<ListResult<App>>\n\n /**\n * Gets a single app by slug.\n *\n * @param slug - App slug (unique within the caller's org)\n * @returns The app\n * @throws {ProteosError} If app not found (404)\n */\n get(slug: string): Promise<App>\n\n /**\n * Creates a new app.\n *\n * @param request - App creation request\n * @returns The created app\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n */\n create(request: CreateAppRequest): Promise<App>\n\n /**\n * Creates or updates an app idempotently by slug. The URL slug wins on\n * mismatch with the body's slug field (`PUT /meta/v1/apps/:slug`).\n *\n * @param slug - App slug\n * @param request - Full app body\n * @returns The created or updated app\n */\n upsert(slug: string, request: CreateAppRequest): Promise<App>\n\n /**\n * Updates an existing app.\n *\n * @param slug - App slug\n * @param request - Fields to update\n * @returns The updated app\n * @throws {ProteosError} If app not found (404) or validation fails (400)\n */\n update(slug: string, request: UpdateAppRequest): Promise<App>\n\n /**\n * Deletes an app.\n *\n * @param slug - App slug\n * @throws {ProteosError} If app not found (404)\n */\n delete(slug: string): Promise<void>\n}\n\n/**\n * Implementation of AppService.\n */\nexport class AppServiceImpl implements AppService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListAppsOptions = {}): PageIterator<App, ListAppsOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListAppsOptions = {}): Promise<ListResult<App>> {\n return this.client.requestWithQuery<ListResult<App>>('GET', APPS_BASE_PATH, options)\n }\n\n async get(slug: string): Promise<App> {\n return this.client.request<App>('GET', `${APPS_BASE_PATH}/${slug}`)\n }\n\n async create(request: CreateAppRequest): Promise<App> {\n return this.client.request<App>('POST', APPS_BASE_PATH, request)\n }\n\n async upsert(slug: string, request: CreateAppRequest): Promise<App> {\n return this.client.request<App>('PUT', `${APPS_BASE_PATH}/${slug}`, { ...request, slug })\n }\n\n async update(slug: string, request: UpdateAppRequest): Promise<App> {\n return this.client.request<App>('PATCH', `${APPS_BASE_PATH}/${slug}`, request)\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${APPS_BASE_PATH}/${slug}`)\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n Component,\n CreateComponentRequest,\n ListComponentsOptions,\n UpdateComponentRequest,\n} from './types.js'\n\nconst COMPONENTS_BASE_PATH = '/meta/v1/components'\n\n/**\n * Service for managing UI component definitions.\n * Components define reusable UI elements in the system.\n */\nexport interface ComponentService {\n /**\n * Lists components with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over components\n */\n list(options?: ListComponentsOptions): PageIterator<Component, ListComponentsOptions>\n\n /**\n * Fetches a single page of components.\n */\n listPage(options?: ListComponentsOptions): Promise<ListResult<Component>>\n\n /**\n * Gets a single component by ID.\n *\n * @param id - Component ID\n * @returns The component\n * @throws {ProteosError} If component not found (404)\n */\n get(id: string): Promise<Component>\n\n /**\n * Creates a new component.\n *\n * @param request - Component creation request\n * @returns The created component\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n */\n create(request: CreateComponentRequest): Promise<Component>\n\n /**\n * Creates or updates a component (upsert operation).\n * If a component with the same slug exists, it is updated; otherwise, a new one is created.\n *\n * @param request - Component creation request\n * @returns The created or updated component\n */\n upsert(request: CreateComponentRequest): Promise<Component>\n\n /**\n * Updates an existing component.\n *\n * @param id - Component ID\n * @param request - Fields to update\n * @returns The updated component\n * @throws {ProteosError} If component not found (404) or validation fails (400)\n */\n update(id: string, request: UpdateComponentRequest): Promise<Component>\n\n /**\n * Deletes a component.\n *\n * @param id - Component ID\n * @throws {ProteosError} If component not found (404)\n */\n delete(id: string): Promise<void>\n\n /**\n * Returns the URL the component runtime imports to load a component's\n * compiled ESM bundle (`GET /meta/v1/components/:slug/bundle`). The path is\n * gateway-prefixed and relative; prepend the API origin to fetch it.\n *\n * @param slug - Component slug\n * @returns The relative bundle URL\n */\n bundleUrl(slug: string): string\n}\n\n/**\n * Implementation of ComponentService.\n */\nexport class ComponentServiceImpl implements ComponentService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListComponentsOptions = {}): PageIterator<Component, ListComponentsOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListComponentsOptions = {}): Promise<ListResult<Component>> {\n return this.client.requestWithQuery<ListResult<Component>>('GET', COMPONENTS_BASE_PATH, options)\n }\n\n async get(id: string): Promise<Component> {\n return this.client.request<Component>('GET', `${COMPONENTS_BASE_PATH}/${id}`)\n }\n\n async create(request: CreateComponentRequest): Promise<Component> {\n return this.client.request<Component>('POST', COMPONENTS_BASE_PATH, request)\n }\n\n async upsert(request: CreateComponentRequest): Promise<Component> {\n return this.client.request<Component>('POST', `${COMPONENTS_BASE_PATH}/upsert`, request)\n }\n\n async update(id: string, request: UpdateComponentRequest): Promise<Component> {\n return this.client.request<Component>('PATCH', `${COMPONENTS_BASE_PATH}/${id}`, request)\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', `${COMPONENTS_BASE_PATH}/${id}`)\n }\n\n bundleUrl(slug: string): string {\n return `${COMPONENTS_BASE_PATH}/${slug}/bundle`\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n CreateDesignReferenceRequest,\n DesignReference,\n DesignReferenceContent,\n ListDesignReferencesOptions,\n UpdateDesignReferenceRequest,\n} from './types.js'\n\nconst DESIGN_REFERENCES_BASE_PATH = '/meta/v1/design-references'\n\n/**\n * Service for managing an org's stored DESIGN.md documents (design references).\n *\n * The markdown body is split from the metadata methods: list/get never carry\n * `content` — read it with {@link getContent} and write it with\n * {@link setContent} (create may seed it in one shot).\n */\nexport interface DesignReferenceService {\n /** Lists design references (metadata only — no `content`). */\n list(\n options?: ListDesignReferencesOptions,\n ): PageIterator<DesignReference, ListDesignReferencesOptions>\n\n /** Fetches a single page of design references (metadata only). */\n listPage(options?: ListDesignReferencesOptions): Promise<ListResult<DesignReference>>\n\n /** Gets a single design reference by id (metadata only — no `content`). */\n get(id: string): Promise<DesignReference>\n\n /** Resolves a design reference by its per-org slug (metadata only). */\n getBySlug(slug: string): Promise<DesignReference>\n\n /** Creates a design reference; `content` optionally seeds the body. */\n create(request: CreateDesignReferenceRequest): Promise<DesignReference>\n\n /** Creates or (by slug) replaces a design reference, including its body. */\n upsert(request: CreateDesignReferenceRequest): Promise<DesignReference>\n\n /** Updates a design reference's metadata (name/description/slug). */\n update(id: string, request: UpdateDesignReferenceRequest): Promise<DesignReference>\n\n /** Deletes a design reference. */\n delete(id: string): Promise<void>\n\n /** Reads the markdown body for a design reference. */\n getContent(id: string): Promise<string>\n\n /** Overwrites the markdown body for a design reference (metadata untouched). */\n setContent(id: string, content: string): Promise<void>\n}\n\n/**\n * Implementation of DesignReferenceService.\n */\nexport class DesignReferenceServiceImpl implements DesignReferenceService {\n constructor(private readonly client: ProteosClient) {}\n\n list(\n options: ListDesignReferencesOptions = {},\n ): PageIterator<DesignReference, ListDesignReferencesOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListDesignReferencesOptions = {}): Promise<ListResult<DesignReference>> {\n return this.client.requestWithQuery<ListResult<DesignReference>>(\n 'GET',\n DESIGN_REFERENCES_BASE_PATH,\n options,\n )\n }\n\n async get(id: string): Promise<DesignReference> {\n return this.client.request<DesignReference>('GET', `${DESIGN_REFERENCES_BASE_PATH}/${id}`)\n }\n\n async getBySlug(slug: string): Promise<DesignReference> {\n const page = await this.listPage({ slug })\n const match = page.data[0]\n if (!match) {\n throw new Error(`design reference with slug \"${slug}\" not found`)\n }\n return match\n }\n\n async create(request: CreateDesignReferenceRequest): Promise<DesignReference> {\n return this.client.request<DesignReference>('POST', DESIGN_REFERENCES_BASE_PATH, request)\n }\n\n async upsert(request: CreateDesignReferenceRequest): Promise<DesignReference> {\n return this.client.request<DesignReference>(\n 'POST',\n `${DESIGN_REFERENCES_BASE_PATH}/upsert`,\n request,\n )\n }\n\n async update(id: string, request: UpdateDesignReferenceRequest): Promise<DesignReference> {\n return this.client.request<DesignReference>(\n 'PATCH',\n `${DESIGN_REFERENCES_BASE_PATH}/${id}`,\n request,\n )\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', `${DESIGN_REFERENCES_BASE_PATH}/${id}`)\n }\n\n async getContent(id: string): Promise<string> {\n const response = await this.client.request<DesignReferenceContent>(\n 'GET',\n `${DESIGN_REFERENCES_BASE_PATH}/${id}/content`,\n )\n return response.content\n }\n\n async setContent(id: string, content: string): Promise<void> {\n await this.client.request<DesignReferenceContent>(\n 'PUT',\n `${DESIGN_REFERENCES_BASE_PATH}/${id}/content`,\n { content },\n )\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n CreateEntityRequest,\n Entity,\n EntityWithSchema,\n ListEntitiesOptions,\n UpdateEntityRequest,\n} from './types.js'\n\nconst ENTITIES_BASE_PATH = '/meta/v1/entities'\n\n/**\n * Service for managing entity definitions.\n * Entities define the structure of business objects in the system.\n */\nexport interface EntityService {\n /**\n * Lists entities with optional filtering.\n * Returns an async iterator that automatically handles pagination.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over entities\n *\n * @example\n * ```ts\n * // Iterate over all entities\n * for await (const entity of service.list()) {\n * console.log(entity.slug);\n * }\n *\n * // With filtering\n * for await (const entity of service.list({ module_slug: 'my-module' })) {\n * console.log(entity.name);\n * }\n * ```\n */\n list(options?: ListEntitiesOptions): PageIterator<Entity, ListEntitiesOptions>\n\n /**\n * Fetches a single page of entities.\n *\n * @param options - Filter and pagination options (including `page`)\n * @returns A single page of entities with pagination metadata\n */\n listPage(options?: ListEntitiesOptions): Promise<ListResult<Entity>>\n\n /**\n * Lists entities including their JSON Schema representation.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over entities with schema\n */\n listWithSchema(options?: ListEntitiesOptions): PageIterator<EntityWithSchema, ListEntitiesOptions>\n\n /**\n * Fetches a single page of entities with their JSON Schema representation.\n * Useful for integrating with paginated UI frameworks (e.g. React Query's\n * useInfiniteQuery) that need direct access to a page's meta and data.\n *\n * @param options - Filter and pagination options\n * @returns A single page of entities with schema\n */\n listPageWithSchema(options?: ListEntitiesOptions): Promise<ListResult<EntityWithSchema>>\n\n /**\n * Gets a single entity by slug.\n *\n * @param slug - Entity slug\n * @returns The entity\n * @throws {ProteosError} If entity not found (404)\n */\n get(slug: string): Promise<Entity>\n\n /**\n * Gets an entity with its JSON Schema representation.\n *\n * @param slug - Entity slug\n * @returns The entity with schema\n * @throws {ProteosError} If entity not found (404)\n */\n getWithSchema(slug: string): Promise<EntityWithSchema>\n\n /**\n * Gets a public-access (read) entity (with schema) through the UNAUTHENTICATED\n * public endpoint — no Authorization header. A non-public or missing\n * entity 404s identically.\n */\n getPublic(orgId: string, slug: string): Promise<EntityWithSchema>\n\n /**\n * Creates a new entity.\n *\n * @param request - Entity creation request\n * @returns The created entity\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n *\n * @example\n * ```ts\n * const entity = await service.create({\n * slug: 'customers',\n * name: 'Customer',\n * description: 'Customer records',\n * is_remote: false,\n * module_slug: 'crm',\n * attributes: [\n * { name: 'id', type: 'string', meta: { format: 'uuid' }, label: 'ID', is_required: true, is_unique: true },\n * { name: 'name', type: 'string', label: 'Name', is_required: true, is_unique: false },\n * ],\n * });\n * ```\n */\n create(request: CreateEntityRequest): Promise<Entity>\n\n /**\n * Creates or updates an entity idempotently by slug. The URL slug wins on\n * mismatch with the body's slug field. Backs the CLI/admin idempotent deploy\n * path (`PUT /meta/v1/entities/:slug`).\n *\n * @param slug - Entity slug\n * @param request - Full entity body\n * @returns The created or updated entity\n */\n upsert(slug: string, request: CreateEntityRequest): Promise<Entity>\n\n /**\n * Updates an existing entity.\n *\n * @param slug - Entity slug\n * @param request - Fields to update\n * @returns The updated entity\n * @throws {ProteosError} If entity not found (404) or validation fails (400)\n */\n update(slug: string, request: UpdateEntityRequest): Promise<Entity>\n\n /**\n * Deletes an entity.\n *\n * @param slug - Entity slug\n * @throws {ProteosError} If entity not found (404)\n */\n delete(slug: string): Promise<void>\n}\n\n/**\n * Implementation of EntityService.\n */\nexport class EntityServiceImpl implements EntityService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListEntitiesOptions = {}): PageIterator<Entity, ListEntitiesOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListEntitiesOptions = {}): Promise<ListResult<Entity>> {\n return this.client.requestWithQuery<ListResult<Entity>>('GET', ENTITIES_BASE_PATH, options)\n }\n\n listWithSchema(\n options: ListEntitiesOptions = {},\n ): PageIterator<EntityWithSchema, ListEntitiesOptions> {\n return new PageIterator((opts) => this.listPageWithSchema(opts), options)\n }\n\n async listPageWithSchema(\n options: ListEntitiesOptions = {},\n ): Promise<ListResult<EntityWithSchema>> {\n return this.client.requestWithQuery<ListResult<EntityWithSchema>>('GET', ENTITIES_BASE_PATH, {\n ...options,\n with_schema: true,\n })\n }\n\n async get(slug: string): Promise<Entity> {\n return this.client.request<Entity>('GET', `${ENTITIES_BASE_PATH}/${slug}`)\n }\n\n async getWithSchema(slug: string): Promise<EntityWithSchema> {\n return this.client.requestWithQuery<EntityWithSchema>('GET', `${ENTITIES_BASE_PATH}/${slug}`, {\n with_schema: true,\n })\n }\n\n async getPublic(orgId: string, slug: string): Promise<EntityWithSchema> {\n return this.client.requestWithQuery<EntityWithSchema>(\n 'GET',\n `/meta/v1/public/orgs/${encodeURIComponent(orgId)}/entities/${encodeURIComponent(slug)}`,\n { with_schema: true },\n undefined,\n { skipAuth: true },\n )\n }\n\n async create(request: CreateEntityRequest): Promise<Entity> {\n return this.client.request<Entity>('POST', ENTITIES_BASE_PATH, request)\n }\n\n async upsert(slug: string, request: CreateEntityRequest): Promise<Entity> {\n return this.client.request<Entity>('PUT', `${ENTITIES_BASE_PATH}/${slug}`, { ...request, slug })\n }\n\n async update(slug: string, request: UpdateEntityRequest): Promise<Entity> {\n return this.client.request<Entity>('PATCH', `${ENTITIES_BASE_PATH}/${slug}`, request)\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${ENTITIES_BASE_PATH}/${slug}`)\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n CreateListViewRequest,\n ListListViewsOptions,\n ListView,\n UpdateListViewRequest,\n} from './types.js'\n\nconst LIST_VIEWS_BASE_PATH = '/meta/v1/list-views'\n\n/**\n * Service for managing list view configurations.\n * List views define filtered and sorted views of lists.\n */\nexport interface ListViewService {\n /**\n * Lists list views with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over list views\n */\n list(options?: ListListViewsOptions): PageIterator<ListView, ListListViewsOptions>\n\n /**\n * Fetches a single page of list views.\n */\n listPage(options?: ListListViewsOptions): Promise<ListResult<ListView>>\n\n /**\n * Gets a single list view by slug.\n *\n * @param slug - List view slug\n * @returns The list view\n * @throws {ProteosError} If list view not found (404)\n */\n get(slug: string): Promise<ListView>\n\n /**\n * Creates a new list view.\n *\n * @param request - List view creation request\n * @returns The created list view\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n */\n create(request: CreateListViewRequest): Promise<ListView>\n\n /**\n * Creates or updates a list view (upsert operation).\n *\n * @param request - List view creation request\n * @returns The created or updated list view\n */\n upsert(request: CreateListViewRequest): Promise<ListView>\n\n /**\n * Updates an existing list view.\n *\n * @param slug - List view slug\n * @param request - Fields to update\n * @returns The updated list view\n * @throws {ProteosError} If list view not found (404) or validation fails (400)\n */\n update(slug: string, request: UpdateListViewRequest): Promise<ListView>\n\n /**\n * Deletes a list view.\n *\n * @param slug - List view slug\n * @throws {ProteosError} If list view not found (404)\n */\n delete(slug: string): Promise<void>\n}\n\n/**\n * Implementation of ListViewService.\n */\nexport class ListViewServiceImpl implements ListViewService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListListViewsOptions = {}): PageIterator<ListView, ListListViewsOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListListViewsOptions = {}): Promise<ListResult<ListView>> {\n return this.client.requestWithQuery<ListResult<ListView>>('GET', LIST_VIEWS_BASE_PATH, options)\n }\n\n async get(slug: string): Promise<ListView> {\n return this.client.request<ListView>('GET', `${LIST_VIEWS_BASE_PATH}/${slug}`)\n }\n\n async create(request: CreateListViewRequest): Promise<ListView> {\n return this.client.request<ListView>('POST', LIST_VIEWS_BASE_PATH, request)\n }\n\n async upsert(request: CreateListViewRequest): Promise<ListView> {\n return this.client.request<ListView>('POST', `${LIST_VIEWS_BASE_PATH}/upsert`, request)\n }\n\n async update(slug: string, request: UpdateListViewRequest): Promise<ListView> {\n return this.client.request<ListView>('PATCH', `${LIST_VIEWS_BASE_PATH}/${slug}`, request)\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${LIST_VIEWS_BASE_PATH}/${slug}`)\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type { CreateListRequest, List, ListListsOptions, UpdateListRequest } from './types.js'\n\nconst LISTS_BASE_PATH = '/meta/v1/lists'\n\n/**\n * Service for managing list configurations.\n * Lists define how data is displayed in tabular format.\n */\nexport interface ListService {\n /**\n * Lists list configurations with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over lists\n */\n list(options?: ListListsOptions): PageIterator<List, ListListsOptions>\n\n /**\n * Fetches a single page of lists.\n */\n listPage(options?: ListListsOptions): Promise<ListResult<List>>\n\n /**\n * Gets a single list by slug.\n *\n * @param slug - List slug\n * @returns The list\n * @throws {ProteosError} If list not found (404)\n */\n get(slug: string): Promise<List>\n\n /**\n * Creates a new list.\n *\n * @param request - List creation request\n * @returns The created list\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n */\n create(request: CreateListRequest): Promise<List>\n\n /**\n * Creates or updates a list (upsert operation).\n *\n * @param request - List creation request\n * @returns The created or updated list\n */\n upsert(request: CreateListRequest): Promise<List>\n\n /**\n * Updates an existing list.\n *\n * @param slug - List slug\n * @param request - Fields to update\n * @returns The updated list\n * @throws {ProteosError} If list not found (404) or validation fails (400)\n */\n update(slug: string, request: UpdateListRequest): Promise<List>\n\n /**\n * Deletes a list.\n *\n * @param slug - List slug\n * @throws {ProteosError} If list not found (404)\n */\n delete(slug: string): Promise<void>\n}\n\n/**\n * Implementation of ListService.\n */\nexport class ListServiceImpl implements ListService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListListsOptions = {}): PageIterator<List, ListListsOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListListsOptions = {}): Promise<ListResult<List>> {\n return this.client.requestWithQuery<ListResult<List>>('GET', LISTS_BASE_PATH, options)\n }\n\n async get(slug: string): Promise<List> {\n return this.client.request<List>('GET', `${LISTS_BASE_PATH}/${slug}`)\n }\n\n async create(request: CreateListRequest): Promise<List> {\n return this.client.request<List>('POST', LISTS_BASE_PATH, request)\n }\n\n async upsert(request: CreateListRequest): Promise<List> {\n return this.client.request<List>('POST', `${LISTS_BASE_PATH}/upsert`, request)\n }\n\n async update(slug: string, request: UpdateListRequest): Promise<List> {\n return this.client.request<List>('PATCH', `${LISTS_BASE_PATH}/${slug}`, request)\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${LISTS_BASE_PATH}/${slug}`)\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n CreateMenuConfigurationRequest,\n ListMenuConfigurationsOptions,\n MenuConfiguration,\n UpdateMenuConfigurationRequest,\n} from './types.js'\n\nconst MENU_CONFIGURATIONS_BASE_PATH = '/meta/v1/menu-configurations'\n\n/**\n * Service for managing menu configurations.\n * Menu configurations define the navigation structure of applications.\n */\nexport interface MenuConfigurationService {\n /**\n * Lists menu configurations with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over menu configurations\n */\n list(\n options?: ListMenuConfigurationsOptions,\n ): PageIterator<MenuConfiguration, ListMenuConfigurationsOptions>\n\n /**\n * Fetches a single page of menu configurations.\n */\n listPage(options?: ListMenuConfigurationsOptions): Promise<ListResult<MenuConfiguration>>\n\n /**\n * Gets a single menu configuration by slug.\n *\n * @param slug - Menu configuration slug (author-controlled, kebab-case)\n * @returns The menu configuration\n * @throws {ProteosError} If menu configuration not found (404)\n */\n get(slug: string): Promise<MenuConfiguration>\n\n /**\n * Creates a new menu configuration.\n *\n * @param request - Menu configuration creation request\n * @returns The created menu configuration\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n */\n create(request: CreateMenuConfigurationRequest): Promise<MenuConfiguration>\n\n /**\n * Creates or updates a menu configuration idempotently by slug.\n *\n * @param slug - Menu configuration slug\n * @param request - Body\n * @returns The created or updated menu configuration\n */\n upsert(slug: string, request: CreateMenuConfigurationRequest): Promise<MenuConfiguration>\n\n /**\n * Updates an existing menu configuration.\n *\n * @param slug - Menu configuration slug\n * @param request - Fields to update\n * @returns The updated menu configuration\n * @throws {ProteosError} If menu configuration not found (404) or validation fails (400)\n */\n update(slug: string, request: UpdateMenuConfigurationRequest): Promise<MenuConfiguration>\n\n /**\n * Deletes a menu configuration.\n *\n * @param slug - Menu configuration slug\n * @throws {ProteosError} If menu configuration not found (404)\n */\n delete(slug: string): Promise<void>\n}\n\n/**\n * Implementation of MenuConfigurationService.\n */\nexport class MenuConfigurationServiceImpl implements MenuConfigurationService {\n constructor(private readonly client: ProteosClient) {}\n\n list(\n options: ListMenuConfigurationsOptions = {},\n ): PageIterator<MenuConfiguration, ListMenuConfigurationsOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(\n options: ListMenuConfigurationsOptions = {},\n ): Promise<ListResult<MenuConfiguration>> {\n return this.client.requestWithQuery<ListResult<MenuConfiguration>>(\n 'GET',\n MENU_CONFIGURATIONS_BASE_PATH,\n options,\n )\n }\n\n async get(slug: string): Promise<MenuConfiguration> {\n return this.client.request<MenuConfiguration>('GET', `${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`)\n }\n\n async create(request: CreateMenuConfigurationRequest): Promise<MenuConfiguration> {\n return this.client.request<MenuConfiguration>('POST', MENU_CONFIGURATIONS_BASE_PATH, request)\n }\n\n async upsert(slug: string, request: CreateMenuConfigurationRequest): Promise<MenuConfiguration> {\n return this.client.request<MenuConfiguration>(\n 'PUT',\n `${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`,\n { ...request, slug },\n )\n }\n\n async update(slug: string, request: UpdateMenuConfigurationRequest): Promise<MenuConfiguration> {\n return this.client.request<MenuConfiguration>(\n 'PATCH',\n `${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`,\n request,\n )\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${MENU_CONFIGURATIONS_BASE_PATH}/${slug}`)\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type { DeployModuleRequest, ListModulesOptions, Module } from './types.js'\n\nconst MODULES_BASE_PATH = '/meta/v1/modules'\n\n/**\n * Service for managing WebAssembly modules.\n * Modules contain business logic that runs in the Proteos runtime.\n */\nexport interface ModuleService {\n /**\n * Lists modules with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over modules\n */\n list(options?: ListModulesOptions): PageIterator<Module, ListModulesOptions>\n\n /**\n * Fetches a single page of modules.\n */\n listPage(options?: ListModulesOptions): Promise<ListResult<Module>>\n\n /**\n * Gets a single module by slug.\n *\n * @param slug - Module slug\n * @returns The module\n * @throws {ProteosError} If module not found (404)\n */\n get(slug: string): Promise<Module>\n\n /**\n * Deploys a new module.\n * Uploads a WASM file with metadata.\n *\n * @param request - Module metadata\n * @param file - WASM file (File, Blob, or ArrayBuffer)\n * @returns The deployed module\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n *\n * @example\n * ```ts\n * const wasmFile = new File([wasmBytes], 'module.wasm');\n * const module = await service.deploy(\n * {\n * slug: 'my-module',\n * version: '1.0.0',\n * name: 'My Module',\n * description: 'A custom module',\n * },\n * wasmFile\n * );\n * ```\n */\n deploy(request: DeployModuleRequest, file: File | Blob | ArrayBuffer): Promise<Module>\n\n /**\n * Deletes a module.\n *\n * @param slug - Module slug\n * @throws {ProteosError} If module not found (404)\n */\n delete(slug: string): Promise<void>\n\n /**\n * Activates a deactivated module.\n *\n * @param slug - Module slug\n * @throws {ProteosError} If module not found (404)\n */\n activate(slug: string): Promise<void>\n\n /**\n * Deactivates an active module.\n *\n * @param slug - Module slug\n * @throws {ProteosError} If module not found (404)\n */\n deactivate(slug: string): Promise<void>\n\n /**\n * Downloads the module WASM file.\n *\n * @param slug - Module slug\n * @returns Object containing the readable stream and module metadata\n * @throws {ProteosError} If module not found (404)\n *\n * @example\n * ```ts\n * const { body, module } = await service.download('my-module');\n * const reader = body.getReader();\n * // Read the stream...\n * ```\n */\n download(slug: string): Promise<{ body: ReadableStream<Uint8Array> | null; module: Module }>\n}\n\n/**\n * Implementation of ModuleService.\n */\nexport class ModuleServiceImpl implements ModuleService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListModulesOptions = {}): PageIterator<Module, ListModulesOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListModulesOptions = {}): Promise<ListResult<Module>> {\n return this.client.requestWithQuery<ListResult<Module>>('GET', MODULES_BASE_PATH, options)\n }\n\n async get(slug: string): Promise<Module> {\n return this.client.request<Module>('GET', `${MODULES_BASE_PATH}/${slug}`)\n }\n\n async deploy(request: DeployModuleRequest, file: File | Blob | ArrayBuffer): Promise<Module> {\n const formData = new FormData()\n\n // Add metadata as JSON string\n formData.append('metadata', JSON.stringify(request))\n\n // Add file\n let blob: Blob\n if (file instanceof ArrayBuffer) {\n blob = new Blob([file], { type: 'application/wasm' })\n } else {\n blob = file\n }\n formData.append('file', blob, 'module.wasm')\n\n return this.client.requestMultipart<Module>('POST', `${MODULES_BASE_PATH}/deploy`, formData)\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${MODULES_BASE_PATH}/${slug}`)\n }\n\n async activate(slug: string): Promise<void> {\n await this.client.request<void>('PATCH', `${MODULES_BASE_PATH}/${slug}/activate`)\n }\n\n async deactivate(slug: string): Promise<void> {\n await this.client.request<void>('PATCH', `${MODULES_BASE_PATH}/${slug}/deactivate`)\n }\n\n async download(\n slug: string,\n ): Promise<{ body: ReadableStream<Uint8Array> | null; module: Module }> {\n const [{ body }, module] = await Promise.all([\n this.client.requestRaw('GET', `${MODULES_BASE_PATH}/${slug}/download`),\n this.get(slug),\n ])\n\n return { body, module }\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n CreatePageRequest,\n ListPagesOptions,\n Page,\n PublicPageResponse,\n UpdatePageRequest,\n} from './types.js'\n\nconst PAGES_BASE_PATH = '/meta/v1/pages'\n\n/**\n * Service for managing page configurations.\n * Pages define the layout and content of entity detail views.\n */\nexport interface PageService {\n /**\n * Lists pages with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over pages\n */\n list(options?: ListPagesOptions): PageIterator<Page, ListPagesOptions>\n\n /**\n * Fetches a single page of page configurations.\n */\n listPage(options?: ListPagesOptions): Promise<ListResult<Page>>\n\n /**\n * Gets a single page by slug.\n *\n * @param slug - Page slug (author-controlled, kebab-case, unique per org)\n * @returns The page\n * @throws {ProteosError} If page not found (404)\n */\n get(slug: string): Promise<Page>\n\n /**\n * Gets a PUBLIC page (type='public') without authentication — no\n * Authorization header is sent. Returns the page plus the props_schema of\n * every component its layout references. Non-public pages 404\n * (indistinguishable from absent).\n *\n * @param orgId - Org id (public routes carry the org in the path — there is\n * no token to scope from)\n * @param slug - Page slug\n */\n getPublic(orgId: string, slug: string): Promise<PublicPageResponse>\n\n /**\n * Creates a new page.\n *\n * @param request - Page creation request\n * @returns The created page\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n */\n create(request: CreatePageRequest): Promise<Page>\n\n /**\n * Creates or updates a page idempotently by slug. The URL slug wins on\n * mismatch with the body's slug field.\n *\n * @param slug - Page slug\n * @param request - Page body\n * @returns The created or updated page\n */\n upsert(slug: string, request: CreatePageRequest): Promise<Page>\n\n /**\n * Updates an existing page.\n *\n * @param slug - Page slug\n * @param request - Fields to update\n * @returns The updated page\n * @throws {ProteosError} If page not found (404) or validation fails (400)\n */\n update(slug: string, request: UpdatePageRequest): Promise<Page>\n\n /**\n * Deletes a page.\n *\n * @param slug - Page slug\n * @throws {ProteosError} If page not found (404)\n */\n delete(slug: string): Promise<void>\n}\n\n/**\n * Implementation of PageService.\n */\nexport class PageServiceImpl implements PageService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListPagesOptions = {}): PageIterator<Page, ListPagesOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListPagesOptions = {}): Promise<ListResult<Page>> {\n return this.client.requestWithQuery<ListResult<Page>>('GET', PAGES_BASE_PATH, options)\n }\n\n async get(slug: string): Promise<Page> {\n return this.client.request<Page>('GET', `${PAGES_BASE_PATH}/${slug}`)\n }\n\n async getPublic(orgId: string, slug: string): Promise<PublicPageResponse> {\n return this.client.request<PublicPageResponse>(\n 'GET',\n `/meta/v1/public/orgs/${encodeURIComponent(orgId)}/pages/${encodeURIComponent(slug)}`,\n undefined,\n { skipAuth: true },\n )\n }\n\n async create(request: CreatePageRequest): Promise<Page> {\n return this.client.request<Page>('POST', PAGES_BASE_PATH, request)\n }\n\n async upsert(slug: string, request: CreatePageRequest): Promise<Page> {\n return this.client.request<Page>('PUT', `${PAGES_BASE_PATH}/${slug}`, { ...request, slug })\n }\n\n async update(slug: string, request: UpdatePageRequest): Promise<Page> {\n return this.client.request<Page>('PATCH', `${PAGES_BASE_PATH}/${slug}`, request)\n }\n\n async delete(slug: string): Promise<void> {\n await this.client.request<void>('DELETE', `${PAGES_BASE_PATH}/${slug}`)\n }\n}\n","import type { ProteosClient } from '../client.js'\nimport { PageIterator } from '../iterator.js'\nimport type { ListResult } from '../types/common.js'\nimport type {\n CreateVariableRequest,\n ListVariablesOptions,\n UpdateVariableRequest,\n Variable,\n} from './types.js'\n\nconst VARIABLES_BASE_PATH = '/meta/v1/variables'\n\n/**\n * Service for managing configuration and secret variables.\n * Variables store key-value pairs scoped to modules.\n */\nexport interface VariableService {\n /**\n * Lists variables with optional filtering.\n *\n * @param options - Filter and pagination options\n * @returns Async iterator over variables\n */\n list(options?: ListVariablesOptions): PageIterator<Variable, ListVariablesOptions>\n\n /**\n * Fetches a single page of variables.\n * Useful for paginated UI frameworks (e.g. React Query's useInfiniteQuery).\n */\n listPage(options?: ListVariablesOptions): Promise<ListResult<Variable>>\n\n /**\n * Gets a single variable by ID.\n *\n * @param id - Variable ID\n * @returns The variable\n * @throws {ProteosError} If variable not found (404)\n */\n get(id: string): Promise<Variable>\n\n /**\n * Creates a new variable.\n *\n * @param request - Variable creation request\n * @returns The created variable\n * @throws {ProteosError} If validation fails (400) or conflict (409)\n */\n create(request: CreateVariableRequest): Promise<Variable>\n\n /**\n * Updates an existing variable.\n *\n * @param id - Variable ID\n * @param request - Fields to update\n * @returns The updated variable\n * @throws {ProteosError} If variable not found (404) or validation fails (400)\n */\n update(id: string, request: UpdateVariableRequest): Promise<Variable>\n\n /**\n * Deletes a variable.\n *\n * @param id - Variable ID\n * @throws {ProteosError} If variable not found (404)\n */\n delete(id: string): Promise<void>\n}\n\n/**\n * Implementation of VariableService.\n */\nexport class VariableServiceImpl implements VariableService {\n constructor(private readonly client: ProteosClient) {}\n\n list(options: ListVariablesOptions = {}): PageIterator<Variable, ListVariablesOptions> {\n return new PageIterator((opts) => this.listPage(opts), options)\n }\n\n async listPage(options: ListVariablesOptions = {}): Promise<ListResult<Variable>> {\n return this.client.requestWithQuery<ListResult<Variable>>('GET', VARIABLES_BASE_PATH, options)\n }\n\n async get(id: string): Promise<Variable> {\n return this.client.request<Variable>('GET', `${VARIABLES_BASE_PATH}/${id}`)\n }\n\n async create(request: CreateVariableRequest): Promise<Variable> {\n return this.client.request<Variable>('POST', VARIABLES_BASE_PATH, request)\n }\n\n async update(id: string, request: UpdateVariableRequest): Promise<Variable> {\n return this.client.request<Variable>('PATCH', `${VARIABLES_BASE_PATH}/${id}`, request)\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', `${VARIABLES_BASE_PATH}/${id}`)\n }\n}\n","import type { CurrencyValue } from '../types.js'\n\n/**\n * Currency + locale-number helpers backed entirely by the runtime's built-in\n * `Intl` data — no bundled ISO-4217 table, no codegen. The platform validates\n * codes on the backend (golang.org/x/text/currency); this module sources the\n * selectable list and renders codes/symbols/amounts for the UI.\n *\n * Amounts are canonical decimal STRINGS (`^-?\\d+(\\.\\d+)?$`) end-to-end; every\n * formatter here operates on the string and never round-trips through a JS\n * number, so precision and trailing zeros are preserved.\n */\n\nlet cachedCodes: string[] | null = null\n\n/**\n * All currency codes the runtime knows, sorted and memoized. Sourced from\n * `Intl.supportedValuesOf` (ES2022). When an attribute's\n * `allowed_currency_codes` is unset, this is the full selectable set.\n */\nexport function allCurrencyCodes(): string[] {\n if (cachedCodes) return cachedCodes\n const supported =\n typeof Intl !== 'undefined' && 'supportedValuesOf' in Intl\n ? (Intl as unknown as { supportedValuesOf(key: 'currency'): string[] }).supportedValuesOf(\n 'currency',\n )\n : []\n cachedCodes = [...supported].sort()\n return cachedCodes\n}\n\n/**\n * Localized display name for a currency code (e.g. `\"US Dollar\"`), via\n * `Intl.DisplayNames`. Falls back to the code itself when unavailable.\n */\nexport function currencyLabel(code: string, locale?: string): string {\n try {\n const names = new Intl.DisplayNames(locale ? [locale] : undefined, { type: 'currency' })\n return names.of(code) ?? code\n } catch {\n return code\n }\n}\n\n/**\n * The narrow symbol for a currency code (e.g. `\"$\"`, `\"€\"`, `\"¥\"`), via\n * `Intl.NumberFormat`'s `narrowSymbol` so it's the bare glyph rather than a\n * disambiguated form like `\"US$\"`. Falls back to the code itself.\n */\nexport function currencySymbol(code: string, locale?: string): string {\n try {\n const parts = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: code,\n currencyDisplay: 'narrowSymbol',\n }).formatToParts(0)\n return parts.find((part) => part.type === 'currency')?.value ?? code\n } catch {\n return code\n }\n}\n\nexport type CurrencySymbolSide = 'prefix' | 'suffix'\n\n/**\n * Currencies whose symbol conventionally TRAILS the amount (with a space) —\n * e.g. `\"1.234,56 €\"`, `\"100 kr\"`, `\"100 zł\"`. Everything else prefixes the\n * symbol with no space — e.g. `\"$1,234.56\"`, `\"¥100\"`.\n *\n * This is deliberately currency-driven, NOT locale-driven: `Intl` would place\n * the symbol per the *viewer's* locale, but we want a dollar to always read\n * `\"$100\"` and a euro `\"100 €\"` regardless of who's looking. Extend this set as\n * needed — it's the single source of truth for symbol placement.\n */\nconst SUFFIX_SYMBOL_CURRENCIES = new Set<string>([\n 'EUR',\n 'PLN',\n 'CZK',\n 'HUF',\n 'RON',\n 'BGN',\n 'HRK',\n 'SEK',\n 'NOK',\n 'DKK',\n 'ISK',\n 'RSD',\n 'RUB',\n 'UAH',\n 'GEL',\n 'MKD',\n 'ALL',\n 'AMD',\n 'AZN',\n 'VND',\n])\n\n/**\n * Which side of the amount a currency's symbol sits on. The well-defined rule:\n * a currency in {@link SUFFIX_SYMBOL_CURRENCIES} suffixes (`\"100 €\"`), every\n * other currency prefixes (`\"$100\"`). Pure and deterministic.\n */\nexport function currencySymbolSide(code: string): CurrencySymbolSide {\n return SUFFIX_SYMBOL_CURRENCIES.has(code) ? 'suffix' : 'prefix'\n}\n\nconst separatorCache = new Map<string, { group: string; decimal: string }>()\n\n/**\n * The grouping (thousands) and decimal separators for a locale — e.g. `de-DE`\n * → `{ group: \".\", decimal: \",\" }`, `en-US` → `{ group: \",\", decimal: \".\" }`.\n * Derived from `Intl.NumberFormat.formatToParts` and memoized per locale.\n */\nexport function localeNumberSeparators(locale?: string): { group: string; decimal: string } {\n const key = locale ?? '__default__'\n const cached = separatorCache.get(key)\n if (cached) return cached\n let group = ','\n let decimal = '.'\n try {\n const parts = new Intl.NumberFormat(locale).formatToParts(11111.1)\n group = parts.find((part) => part.type === 'group')?.value ?? group\n decimal = parts.find((part) => part.type === 'decimal')?.value ?? decimal\n } catch {\n /* keep the en-US-ish defaults */\n }\n const result = { group, decimal }\n separatorCache.set(key, result)\n return result\n}\n\nconst DECIMAL_RE = /^-?\\d+(\\.\\d+)?$/\n\nfunction groupDigits(intDigits: string, groupSeparator: string): string {\n return intDigits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, groupSeparator)\n}\n\n/**\n * Render a canonical decimal string in a locale's notation — e.g. `\"1234.56\"`\n * → `\"1.234,56\"` (de) / `\"1,234.56\"` (en). `grouped: false` omits the thousands\n * separator (useful while a field is being edited). Precision-preserving: it\n * splits the string and substitutes separators, never `Number()`.\n */\nexport function formatAmount(\n canonical: string,\n locale?: string,\n options?: { grouped?: boolean },\n): string {\n if (canonical === '') return ''\n if (!DECIMAL_RE.test(canonical)) return canonical\n const grouped = options?.grouped !== false\n const { group, decimal } = localeNumberSeparators(locale)\n const negative = canonical.startsWith('-')\n const body = negative ? canonical.slice(1) : canonical\n const dotIndex = body.indexOf('.')\n const intPart = dotIndex === -1 ? body : body.slice(0, dotIndex)\n const fracPart = dotIndex === -1 ? undefined : body.slice(dotIndex + 1)\n const intOut = grouped ? groupDigits(intPart, group) : intPart\n const out = fracPart !== undefined ? `${intOut}${decimal}${fracPart}` : intOut\n return negative ? `-${out}` : out\n}\n\n/**\n * Parse locale-formatted user input back to a canonical decimal string — e.g.\n * `\"1.234,56\"` (de) → `\"1234.56\"`. Strips the locale group separator,\n * normalizes the locale decimal to `.`, and drops stray characters (symbols,\n * spaces). Returns `\"\"` for empty/invalid input.\n */\nexport function parseAmount(input: string, locale?: string): string {\n const trimmed = input.trim()\n if (trimmed === '') return ''\n const { group, decimal } = localeNumberSeparators(locale)\n const negative = trimmed.startsWith('-')\n let normalized = trimmed.split(group).join('') // strip thousands separators\n normalized = normalized.split(decimal).join('.') // locale decimal → '.'\n normalized = normalized.replace(/[^\\d.]/g, '') // drop symbols, spaces, stray chars\n const firstDot = normalized.indexOf('.')\n if (firstDot !== -1) {\n // Collapse to a single decimal point.\n normalized =\n normalized.slice(0, firstDot + 1) + normalized.slice(firstDot + 1).replace(/\\./g, '')\n }\n if (normalized === '' || normalized === '.') return ''\n return negative ? `-${normalized}` : normalized\n}\n\n/**\n * Format a currency value for read-only display: the symbol placed by currency\n * convention ({@link currencySymbolSide}) around the amount grouped per the\n * viewer's locale ({@link formatAmount}). E.g. USD → `\"$1,234.56\"`, EUR (de\n * viewer) → `\"1.234,56 €\"`. Returns a plain `\"amount code\"` string when the\n * value can't be formatted.\n */\nexport function formatMoney(value: CurrencyValue, locale?: string): string {\n const { amount, currency_code: code } = value\n if (!amount || !code) return [amount, code].filter(Boolean).join(' ')\n if (!DECIMAL_RE.test(amount)) return `${amount} ${code}`\n const number = formatAmount(amount, locale, { grouped: true })\n const symbol = currencySymbol(code, locale)\n return currencySymbolSide(code) === 'suffix' ? `${number} ${symbol}` : `${symbol}${number}`\n}\n","{\n \"_comment\": \"SOURCE OF TRUTH for the page-layout control registry. Each entry under `controls` declares the primary control slug and the full compatible list for one (type[+format|+items.type]) combination. Renderer dispatches off `primary`; inspector picker dispatches off `compatible`. Edit this file then run `go run ./scripts/codegen/page-layout-registry` from the repo root to regenerate packages/go/model/page_layout_registry_gen.go.\",\n \"_attributeTypes\": \"Top-level keys MUST match the Go canonical AttributeType union in packages/go/model/meta/attribute.go (string \\u00b7 number \\u00b7 integer \\u00b7 boolean \\u00b7 array \\u00b7 object \\u00b7 datetime \\u00b7 enum \\u00b7 relation \\u00b7 user \\u00b7 currency \\u00b7 knowledge-text \\u00b7 file). `byFormat` keys for `string` MUST match StringFormat (email \\u00b7 uri \\u00b7 uuid \\u00b7 hostname \\u00b7 ipv4 \\u00b7 ipv6). `byFormat` keys for `datetime` MUST match DatetimeFormat (date-time \\u00b7 date \\u00b7 time \\u00b7 duration). `byItemsType` for `array` keys on the item Attribute's type. A null `primary` with empty `compatible` means \\\"render-only fallback\\\" \\u2014 see plan \\u00a73.2.5.\",\n \"_slugRoster\": \"v1 ships only lib-backed slugs. Slugs without a backing @proteos/ui component (markdown \\u00b7 json-editor \\u00b7 slider \\u00b7 stepper \\u00b7 percent \\u00b7 user-card) are intentionally omitted; they return when the matching lib primitive ships. See plan \\u00a73.2.4 / \\u00a77.3. The `user-picker` slug is backed by the web client's UserCombobox (account/user-service people picker). The `currency` slug is backed by the web client's currency control (CurrencyInput: decimal amount + ISO-4217 picker).\",\n \"builtInControls\": [\n \"text\",\n \"textarea\",\n \"email\",\n \"url\",\n \"password\",\n \"number\",\n \"switch\",\n \"checkbox\",\n \"select\",\n \"radio-group\",\n \"chip-group\",\n \"multi-select\",\n \"date-picker\",\n \"datetime-picker\",\n \"time-picker\",\n \"tag-input\",\n \"entity-picker\",\n \"user-picker\",\n \"principal-picker\",\n \"currency\",\n \"knowledge-text\",\n \"file\",\n \"file-viewer\",\n \"record-filter\"\n ],\n \"controls\": {\n \"string\": {\n \"primary\": \"text\",\n \"compatible\": [\n \"text\",\n \"textarea\",\n \"password\",\n \"record-filter\"\n ],\n \"byFormat\": {\n \"email\": {\n \"primary\": \"email\",\n \"compatible\": [\n \"email\",\n \"text\"\n ]\n },\n \"uri\": {\n \"primary\": \"url\",\n \"compatible\": [\n \"url\",\n \"text\"\n ]\n },\n \"uuid\": {\n \"primary\": \"text\",\n \"compatible\": [\n \"text\"\n ]\n },\n \"hostname\": {\n \"primary\": \"text\",\n \"compatible\": [\n \"text\"\n ]\n },\n \"ipv4\": {\n \"primary\": \"text\",\n \"compatible\": [\n \"text\"\n ]\n },\n \"ipv6\": {\n \"primary\": \"text\",\n \"compatible\": [\n \"text\"\n ]\n }\n }\n },\n \"number\": {\n \"primary\": \"number\",\n \"compatible\": [\n \"number\"\n ]\n },\n \"integer\": {\n \"primary\": \"number\",\n \"compatible\": [\n \"number\"\n ]\n },\n \"boolean\": {\n \"primary\": \"switch\",\n \"compatible\": [\n \"switch\",\n \"checkbox\"\n ]\n },\n \"enum\": {\n \"primary\": \"select\",\n \"compatible\": [\n \"select\",\n \"radio-group\",\n \"chip-group\"\n ]\n },\n \"array\": {\n \"primary\": \"tag-input\",\n \"compatible\": [\n \"tag-input\"\n ],\n \"byItemsType\": {\n \"string\": {\n \"primary\": \"tag-input\",\n \"compatible\": [\n \"tag-input\"\n ]\n },\n \"enum\": {\n \"primary\": \"multi-select\",\n \"compatible\": [\n \"multi-select\"\n ]\n }\n }\n },\n \"datetime\": {\n \"primary\": null,\n \"compatible\": [],\n \"byFormat\": {\n \"date\": {\n \"primary\": \"date-picker\",\n \"compatible\": [\n \"date-picker\"\n ]\n },\n \"date-time\": {\n \"primary\": \"datetime-picker\",\n \"compatible\": [\n \"datetime-picker\"\n ]\n },\n \"time\": {\n \"primary\": \"time-picker\",\n \"compatible\": [\n \"time-picker\"\n ]\n },\n \"duration\": {\n \"primary\": null,\n \"compatible\": []\n }\n }\n },\n \"object\": {\n \"primary\": null,\n \"compatible\": []\n },\n \"relation\": {\n \"primary\": \"entity-picker\",\n \"compatible\": [\n \"entity-picker\"\n ]\n },\n \"user\": {\n \"primary\": \"user-picker\",\n \"compatible\": [\n \"user-picker\"\n ]\n },\n \"currency\": {\n \"primary\": \"currency\",\n \"compatible\": [\n \"currency\"\n ]\n },\n \"knowledge-text\": {\n \"primary\": \"knowledge-text\",\n \"compatible\": [\n \"knowledge-text\"\n ]\n },\n \"file\": {\n \"primary\": \"file\",\n \"compatible\": [\n \"file\",\n \"file-viewer\"\n ]\n },\n \"principal\": {\n \"primary\": \"principal-picker\",\n \"compatible\": [\n \"principal-picker\"\n ]\n }\n }\n}\n","import registry from './control-registry.json' with { type: 'json' }\n\n/* =========================================================================\n Field control registry — source of truth: ./control-registry.json\n (which is also the input to scripts/codegen/page-layout-registry, so\n the Go validator and the TS renderer agree on every slug).\n\n Two surfaces:\n\n - `BUILT_IN_CONTROLS` : the slug allow-list shipped by\n @proteos/ui's PageLayoutRenderer.\n - `lookupControls(attr)` : per-(type+format|items.type) bucket.\n `lookupPrimaryControl` : the bucket's primary (renderer dispatch).\n `lookupCompatibleControls` : the bucket's compatible list (inspector\n picker).\n\n Resolution walks the discriminator chain: type → byFormat[meta.format]\n for `string` and `datetime`, type → byItemsType[meta.items.type] for\n `array`. Falls back to the type-level entry when no narrower bucket\n matches. A null primary with empty compatible signals \"render-only\n fallback\" (see plan §3.2.5).\n ========================================================================= */\n\nexport const BUILT_IN_CONTROLS = registry.builtInControls as readonly string[]\nexport type BuiltInControlSlug = (typeof BUILT_IN_CONTROLS)[number]\n\nexport interface ControlBucket {\n readonly primary: string | null\n readonly compatible: readonly string[]\n}\n\ninterface ControlBucketJson extends ControlBucket {\n readonly byFormat?: Readonly<Record<string, ControlBucketJson>>\n readonly byItemsType?: Readonly<Record<string, ControlBucketJson>>\n}\n\nconst CONTROLS = registry.controls as Readonly<Record<string, ControlBucketJson>>\n\n/** True when `slug` matches a built-in control. */\nexport function isBuiltInControl(slug: string): boolean {\n return (BUILT_IN_CONTROLS as readonly string[]).includes(slug)\n}\n\n/**\n * Minimal Attribute shape the lookup helpers need. The SDK's full\n * `Attribute` type extends this; consumers can pass either.\n */\nexport interface AttributeForLookup {\n type: string\n meta?: {\n format?: string\n items?: { type?: string }\n } | null\n}\n\n/**\n * Resolves the full ControlBucket for an attribute. Walks\n * type → byFormat[meta.format] (string/datetime) or\n * type → byItemsType[meta.items.type] (array), falling back to the\n * type-level entry.\n *\n * Returns `{ primary: null, compatible: [] }` when neither the type\n * nor any narrower bucket matches — including when the attribute type\n * is unknown to the registry (e.g. legacy wire data).\n */\nexport function lookupControls(attr: AttributeForLookup): ControlBucket {\n const typeBucket = CONTROLS[attr.type]\n if (!typeBucket) return EMPTY\n\n const meta = attr.meta ?? undefined\n const format = meta?.format\n if (format && typeBucket.byFormat?.[format]) {\n return typeBucket.byFormat[format]\n }\n const itemsType = meta?.items?.type\n if (itemsType && typeBucket.byItemsType?.[itemsType]) {\n return typeBucket.byItemsType[itemsType]\n }\n return typeBucket\n}\n\n/** Convenience: the primary slug, or null for the read-only fallback. */\nexport function lookupPrimaryControl(attr: AttributeForLookup): string | null {\n return lookupControls(attr).primary\n}\n\n/** Convenience: the compatible slug list (empty for the read-only fallback). */\nexport function lookupCompatibleControls(attr: AttributeForLookup): readonly string[] {\n return lookupControls(attr).compatible\n}\n\nconst EMPTY: ControlBucket = { primary: null, compatible: [] }\n","import { z } from 'zod'\n\n/**\n * Logical operator used to combine filter elements/groups.\n */\nexport type LogicalOperator = 'and' | 'or'\n\n/**\n * Comparison operator for a single filter element. Mirrors\n * `ComparisonOperator` in `packages/go/model/comparison-operator.go`.\n */\nexport type ComparisonOperator =\n | 'eq'\n | 'gt'\n | 'lt'\n | 'gte'\n | 'lte'\n | 'ne'\n | 'in'\n | 'not_in'\n | 'contains'\n | 'starts_with'\n | 'ends_with'\n | 'empty'\n | 'not_empty'\n\n/**\n * Single filter element (atomic predicate).\n *\n * `value` is a string at the wire level — pipe-joined for `in` / `not_in`,\n * ignored for `empty` / `not_empty`. This matches the data-service URL query\n * convention so the same predicate flows through both the GET-with-filters\n * path and the layout `visible_when` JSONB path without a translation layer.\n */\nexport interface FilterElement {\n field: string\n value: string\n operator: ComparisonOperator\n}\n\n/**\n * Filter group with logical operator. Groups can be nested.\n */\nexport interface FilterGroup {\n logical_operator: LogicalOperator\n elements?: FilterElement[]\n groups?: FilterGroup[]\n}\n\nexport const FilterElementSchema = z.object({\n field: z.string(),\n value: z.string(),\n operator: z.enum([\n 'eq',\n 'gt',\n 'lt',\n 'gte',\n 'lte',\n 'ne',\n 'in',\n 'not_in',\n 'contains',\n 'starts_with',\n 'ends_with',\n 'empty',\n 'not_empty',\n ]),\n})\n\nexport const FilterGroupSchema: z.ZodType<FilterGroup> = z.lazy(() =>\n z.object({\n logical_operator: z.enum(['and', 'or']),\n elements: z.array(FilterElementSchema).optional(),\n groups: z.array(FilterGroupSchema).optional(),\n }),\n) as unknown as z.ZodType<FilterGroup>\n","import { z } from 'zod'\n\n/**\n * SizeValue is a polymorphic sizing value used by `width`, `height`, and the\n * responsive overrides. Accepted forms:\n *\n * - JSON number in [0, 1] for a fraction (0.5 → 50%)\n * - \"n/m\" fraction string (\"1/2\", \"2/3\", ...)\n * - \"Npx\" pixel string\n * - \"N%\" percent string\n * - \"auto\" — size to content\n * - \"fill\" — grow to fill remaining space\n */\nexport type SizeValue =\n | number\n | `${number}/${number}`\n | `${number}px`\n | `${number}%`\n | 'auto'\n | 'fill'\n\nconst SIZE_VALUE_STRING_RE = /^(\\d+\\/\\d+|\\d+px|\\d+%|auto|fill)$/\n\nexport const SizeValueSchema: z.ZodType<SizeValue> = z.union([\n z.number().min(0).max(1).describe('Fraction in [0, 1]'),\n z.string().regex(SIZE_VALUE_STRING_RE, 'must match n/m, Npx, N%, \"auto\", or \"fill\"'),\n]) as unknown as z.ZodType<SizeValue>\n","import { z } from 'zod'\nimport { type FilterGroup, FilterGroupSchema } from '../filters.js'\nimport { type SizeValue, SizeValueSchema } from './size-value.js'\n\n/**\n * Cross-axis alignment values. On Row / Column the same string also drives\n * arrangement of children (cross-axis); on a leaf element it acts as\n * align-self.\n */\nexport type LayoutAlign = 'start' | 'center' | 'end' | 'stretch'\n\nexport type LayoutJustify = 'start' | 'center' | 'end' | 'between' | 'around'\n\nexport type LayoutGap = 'xs' | 'sm' | 'md' | 'lg'\n\nconst AlignSchema = z.enum(['start', 'center', 'end', 'stretch'])\nconst JustifySchema = z.enum(['start', 'center', 'end', 'between', 'around'])\nconst GapSchema = z.enum(['xs', 'sm', 'md', 'lg'])\n\n/**\n * Partial sizing knobs reused by ResponsiveSizing.\n */\nexport interface SizingProps {\n width?: SizeValue\n height?: SizeValue\n grow?: number\n shrink?: number\n align?: LayoutAlign\n}\n\nconst SizingPropsSchema = z.object({\n width: SizeValueSchema.optional(),\n height: SizeValueSchema.optional(),\n grow: z.number().optional(),\n shrink: z.number().optional(),\n align: AlignSchema.optional(),\n})\n\nexport interface ResponsiveSizing {\n sm?: SizingProps\n md?: SizingProps\n lg?: SizingProps\n}\n\nconst ResponsiveSizingSchema = z.object({\n sm: SizingPropsSchema.optional(),\n md: SizingPropsSchema.optional(),\n lg: SizingPropsSchema.optional(),\n})\n\n/**\n * Common properties present on every LayoutElement.\n *\n * `visible_when` and `read_only_when` reuse the `FilterGroup` predicate model\n * already used by lists and the data-service URL query convention — same\n * operators, same and/or composition, same `value: string` (pipe-joined for\n * `in` / `not_in`).\n *\n * `align` here is align-self (override of the parent's cross-axis arrangement\n * for this child). On Row / Column it is shadowed by an outer `align` whose\n * semantic is the cross-axis arrangement applied to children.\n */\nexport interface CommonProps {\n id?: string\n visible_when?: FilterGroup\n read_only_when?: FilterGroup\n width?: SizeValue\n height?: SizeValue\n grow?: number\n shrink?: number\n align?: LayoutAlign\n responsive?: ResponsiveSizing\n}\n\n/**\n * The Zod shape for CommonProps. Exported so individual element schemas can\n * spread it via `.extend(commonPropsShape)`.\n */\nexport const commonPropsShape = {\n id: z.string().optional(),\n visible_when: FilterGroupSchema.optional(),\n read_only_when: FilterGroupSchema.optional(),\n width: SizeValueSchema.optional(),\n height: SizeValueSchema.optional(),\n grow: z.number().optional(),\n shrink: z.number().optional(),\n align: AlignSchema.optional(),\n responsive: ResponsiveSizingSchema.optional(),\n} as const\n\nexport const layoutAlignShape = AlignSchema\nexport const layoutJustifyShape = JustifySchema\nexport const layoutGapShape = GapSchema\n","import { z } from 'zod'\nimport { type FilterGroup, FilterGroupSchema } from '../filters.js'\nimport {\n type CommonProps,\n commonPropsShape,\n layoutAlignShape,\n layoutGapShape,\n layoutJustifyShape,\n} from './common-props.js'\n\nexport const LayoutElementType = {\n Row: 'row',\n Column: 'column',\n Section: 'section',\n Card: 'card',\n Tabs: 'tabs',\n Field: 'field',\n RelatedList: 'related_list',\n RelatedRecord: 'related_record',\n Component: 'component',\n Divider: 'divider',\n Text: 'text',\n RecordFilter: 'record_filter',\n List: 'list',\n WorkflowTrigger: 'workflow_trigger',\n} as const\nexport type LayoutElementType = (typeof LayoutElementType)[keyof typeof LayoutElementType]\n\nexport type RowElement = CommonProps & {\n type: 'row'\n gap?: 'xs' | 'sm' | 'md' | 'lg'\n /** When true (default), children flow to the next line if they don't fit. */\n allows_wrap?: boolean\n align?: 'start' | 'center' | 'end' | 'stretch'\n justify?: 'start' | 'center' | 'end' | 'between' | 'around'\n children: LayoutElement[]\n}\n\nexport type ColumnElement = CommonProps & {\n type: 'column'\n gap?: 'xs' | 'sm' | 'md' | 'lg'\n align?: 'start' | 'center' | 'end' | 'stretch'\n justify?: 'start' | 'center' | 'end' | 'between' | 'around'\n children: LayoutElement[]\n}\n\nexport type SectionElement = CommonProps & {\n type: 'section'\n title?: string\n description?: string\n is_collapsible?: boolean\n default_collapsed?: boolean\n content: LayoutElement\n}\n\n/**\n * Same grouping contract as {@link SectionElement}, drawn as an actual card —\n * border, surface fill, rounded corners, rest shadow — with the title in the\n * card's header bar. Reach for it when a group should read as a distinct\n * object on the page; reach for `section` when it should read as a heading\n * over open content.\n */\nexport type CardElement = CommonProps & {\n type: 'card'\n title?: string\n description?: string\n is_collapsible?: boolean\n default_collapsed?: boolean\n content: LayoutElement\n}\n\n/**\n * One switchable view inside a `tabs` element. `visible_when` hides the tab\n * when it does not match the record; `default_when` makes it the initially\n * shown tab when it matches. Both are evaluated live against the record being\n * viewed or edited. Resolution order: first visible tab (document order) whose\n * `default_when` matches → `TabsElement.default_tab_id` → first visible tab.\n */\nexport type LayoutTab = {\n id: string\n label: string\n icon?: string\n visible_when?: FilterGroup\n default_when?: FilterGroup\n content: LayoutElement\n}\n\nexport type TabsElement = CommonProps & {\n type: 'tabs'\n tabs: LayoutTab[]\n default_tab_id?: string\n}\n\nexport type FieldElement = CommonProps & {\n type: 'field'\n attribute: string\n label?: string | null\n description?: string\n placeholder?: string\n is_read_only?: boolean\n is_required?: boolean\n empty_display?: 'dash' | 'hide' | string\n control?: string\n control_props?: Record<string, unknown>\n}\n\n/**\n * Lists records of `related_entity_slug` that reference the current record\n * through the `via_attribute` relation attribute. Replaces the pre-LUM-20\n * `relationshipId` reference — the relation is identified directly by the\n * attribute on the host entity. `list_slug` optionally pins which list\n * definition drives the column / sort / filter model; when omitted, the\n * renderer falls back to the first list configured for the related entity.\n */\nexport type RelatedListElement = CommonProps & {\n type: 'related_list'\n related_entity_slug: string\n via_attribute: string\n list_slug?: string\n /**\n * When absent or true, the list enters row-edit mode together with the\n * host page's edit mode. False keeps the list independent — rows are only\n * editable through the list's own \"Edit records\" toggle.\n */\n follows_parent_edit_mode?: boolean\n}\n\n/**\n * Renders the FIRST record of `related_entity_slug` that references the\n * current record through the `via_attribute` relation attribute — the\n * singular counterpart of `related_list`, addressing the relation the same\n * inbound way. The match is taken oldest-first so the choice is stable.\n *\n * `page_slug` optionally pins which record page supplies the layout; when\n * omitted (or dangling) the renderer falls back to the related entity's\n * default record page. The element renders that page bare — wrap it in a\n * `section` element for a title or collapse affordance.\n */\nexport type RelatedRecordElement = CommonProps & {\n type: 'related_record'\n related_entity_slug: string\n via_attribute: string\n page_slug?: string\n /**\n * When absent or true, the element enters edit mode together with the host\n * page's edit mode. False keeps it independent — editable only through its\n * own hover control. Either way the element saves the related record\n * itself; the host page's Save never covers it.\n */\n follows_parent_edit_mode?: boolean\n}\n\nexport type ComponentElement = CommonProps & {\n type: 'component'\n component_slug: string\n props?: Record<string, unknown>\n /** Placeholder height (px) reserved while the component bundle loads, used\n * ONLY when `height` is unset/auto. Does not constrain the rendered\n * component — it auto-sizes to real content after load. Reserving roughly\n * the right space keeps the reveal from shoving content below it. Defaults\n * to the host's 80px fallback when unset. */\n reserved_height?: number\n}\n\n/**\n * A filter builder placed directly on a page. It owns no data of its own: it\n * publishes the filter (and the chosen subject entity) under its element id,\n * and every `list` element naming that id in `filter_element_id` renders the\n * filtered rows.\n *\n * `subject_entity` pins which entity the filter is authored against. When it is\n * absent the element renders a subject picker over the entities its bound lists\n * offer — one entry per bound list, since a list carries exactly one entity.\n *\n * The filter is in-memory: it resets on reload rather than persisting per user.\n */\nexport type RecordFilterElement = CommonProps & {\n type: 'record_filter'\n subject_entity?: string\n /** `toolbar` (default) is the Filter button + active chips, matching every\n * list view. `panel` is the always-open AND/OR editor, for a page whose\n * point IS the filter. */\n variant?: 'toolbar' | 'panel'\n /** Nested AND/OR groups. Defaults to true — the records query carries the\n * whole tree, so there is no reason to hide the affordance. */\n is_complex_enabled?: boolean\n}\n\n/**\n * Renders records of a configured List — the record-agnostic sibling of\n * `related_list`, and the only way to show records on a page that has no\n * record of its own.\n *\n * The List supplies everything about presentation and behaviour: columns,\n * sorting, base filters, toolbar actions, selection mode, and which page a row\n * opens. Naming more than one list makes the element switchable; the active one\n * is chosen by the bound filter's subject picker, or by the element's own\n * switcher when it is unbound.\n *\n * `filter_element_id` binds the element to a `record_filter` on the same page.\n * The bound filter is ANDed with the list's own saved filters — it narrows the\n * list, it never replaces what the list declared.\n */\nexport type ListElement = CommonProps & {\n type: 'list'\n /** Slugs of the lists this element can render. At least one. */\n list_slugs: string[]\n /** Element id of the `record_filter` driving this list. Unbound renders the\n * list with its own filters only. */\n filter_element_id?: string\n /**\n * Record-page alternative to `filter_element_id`: the attribute on THIS\n * page's record holding a saved filter (as written by the `record-filter`\n * control). The list then renders what the record's own filter selects —\n * a saved-segment record showing its matches.\n *\n * Mutually exclusive with `filter_element_id`: two filters driving one list\n * has no defined precedence, so the layout validator rejects both at once.\n * Record pages only — a standalone page has no record to read.\n */\n filter_attribute?: string\n /**\n * Attribute on this page's record naming the subject entity slug. The\n * element renders whichever of `list_slugs` targets that entity. Without\n * it the first configured list wins. Pairs with `filter_attribute`.\n */\n subject_entity_attribute?: string\n page_size?: number\n}\n\nexport type DividerElement = CommonProps & {\n type: 'divider'\n}\n\n/**\n * An always-visible button that starts a manual run of `workflow` (by key) —\n * the in-layout counterpart of a `kind: workflow` toolbar action. `inputs`\n * maps the manual trigger's input_schema field names to Liquid templates\n * rendered against the page scope; `skip_confirmation` fires immediately when\n * every required input resolves. While the run is in flight the element shows\n * the step progress inline in place of the button.\n */\nexport type WorkflowTriggerElement = CommonProps & {\n type: 'workflow_trigger'\n workflow: string\n label: string\n icon?: string\n inputs?: Record<string, string>\n skip_confirmation?: boolean\n /**\n * Optional string attribute on the page's record where the element persists\n * the id of the execution it starts — and reads it back, so progress\n * survives reloads and is shared by every viewer. Record pages only.\n */\n execution_attribute?: string\n}\n\nexport type TextVariant = 'heading' | 'subheading' | 'body' | 'caption' | 'callout'\n\nexport type TextElement = CommonProps & {\n type: 'text'\n variant: TextVariant\n content: string\n}\n\nexport type LayoutElement =\n | RowElement\n | ColumnElement\n | SectionElement\n | CardElement\n | TabsElement\n | FieldElement\n | RelatedListElement\n | RelatedRecordElement\n | ComponentElement\n | DividerElement\n | TextElement\n | RecordFilterElement\n | ListElement\n | WorkflowTriggerElement\n\n// ──────────────────────────────────────────────────────────── Schemas ──\n\nexport const LayoutElementSchema: z.ZodType<LayoutElement> = z.lazy(() =>\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('row'),\n ...commonPropsShape,\n gap: layoutGapShape.optional(),\n allows_wrap: z.boolean().optional(),\n align: layoutAlignShape.optional(),\n justify: layoutJustifyShape.optional(),\n children: z.array(LayoutElementSchema),\n }),\n z.object({\n type: z.literal('column'),\n ...commonPropsShape,\n gap: layoutGapShape.optional(),\n align: layoutAlignShape.optional(),\n justify: layoutJustifyShape.optional(),\n children: z.array(LayoutElementSchema),\n }),\n z.object({\n type: z.literal('section'),\n ...commonPropsShape,\n title: z.string().optional(),\n description: z.string().optional(),\n is_collapsible: z.boolean().optional(),\n default_collapsed: z.boolean().optional(),\n content: LayoutElementSchema,\n }),\n z.object({\n type: z.literal('card'),\n ...commonPropsShape,\n title: z.string().optional(),\n description: z.string().optional(),\n is_collapsible: z.boolean().optional(),\n default_collapsed: z.boolean().optional(),\n content: LayoutElementSchema,\n }),\n z.object({\n type: z.literal('tabs'),\n ...commonPropsShape,\n tabs: z.array(\n z.object({\n id: z.string().min(1),\n label: z.string().min(1),\n icon: z.string().optional(),\n visible_when: FilterGroupSchema.optional(),\n default_when: FilterGroupSchema.optional(),\n content: LayoutElementSchema,\n }),\n ),\n default_tab_id: z.string().optional(),\n }),\n z.object({\n type: z.literal('field'),\n ...commonPropsShape,\n attribute: z.string().min(1),\n label: z.string().nullable().optional(),\n description: z.string().optional(),\n placeholder: z.string().optional(),\n is_read_only: z.boolean().optional(),\n is_required: z.boolean().optional(),\n empty_display: z.string().optional(),\n control: z.string().optional(),\n control_props: z.record(z.unknown()).optional(),\n }),\n z.object({\n type: z.literal('related_list'),\n ...commonPropsShape,\n related_entity_slug: z.string().min(1),\n via_attribute: z.string().min(1),\n list_slug: z.string().min(1).optional(),\n follows_parent_edit_mode: z.boolean().optional(),\n }),\n z.object({\n type: z.literal('related_record'),\n ...commonPropsShape,\n related_entity_slug: z.string().min(1),\n via_attribute: z.string().min(1),\n page_slug: z.string().min(1).optional(),\n follows_parent_edit_mode: z.boolean().optional(),\n }),\n z.object({\n type: z.literal('component'),\n ...commonPropsShape,\n component_slug: z.string().min(1),\n props: z.record(z.unknown()).optional(),\n reserved_height: z.number().positive().optional(),\n }),\n z.object({\n type: z.literal('record_filter'),\n ...commonPropsShape,\n subject_entity: z.string().min(1).optional(),\n variant: z.enum(['toolbar', 'panel']).optional(),\n is_complex_enabled: z.boolean().optional(),\n }),\n z.object({\n type: z.literal('list'),\n ...commonPropsShape,\n list_slugs: z.array(z.string().min(1)).min(1),\n filter_element_id: z.string().min(1).optional(),\n filter_attribute: z.string().min(1).optional(),\n subject_entity_attribute: z.string().min(1).optional(),\n page_size: z.number().int().positive().optional(),\n }),\n z.object({\n type: z.literal('divider'),\n ...commonPropsShape,\n }),\n z.object({\n type: z.literal('workflow_trigger'),\n ...commonPropsShape,\n workflow: z.string().min(1),\n label: z.string().min(1),\n icon: z.string().optional(),\n inputs: z.record(z.string()).optional(),\n skip_confirmation: z.boolean().optional(),\n execution_attribute: z.string().min(1).optional(),\n }),\n z.object({\n type: z.literal('text'),\n ...commonPropsShape,\n variant: z.enum(['heading', 'subheading', 'body', 'caption', 'callout']),\n content: z.string().min(1),\n }),\n ]),\n) as unknown as z.ZodType<LayoutElement>\n","import { z } from 'zod'\nimport { type LayoutElement, LayoutElementSchema } from './elements.js'\nimport { type SizeValue, SizeValueSchema } from './size-value.js'\n\n/**\n * Side panel slot. Rendered as a sticky-by-default right rail; collapses\n * below the main column on narrow viewports.\n */\nexport interface PageLayoutSidePanel {\n width?: SizeValue\n is_sticky?: boolean\n content: LayoutElement\n}\n\nexport const PageLayoutSidePanelSchema = z.object({\n width: SizeValueSchema.optional(),\n is_sticky: z.boolean().optional(),\n content: LayoutElementSchema,\n})\n\n/**\n * Design-token keys a page background may name instead of a raw CSS color. The\n * web resolver maps each to `var(--color-<key>)`. Keep in sync with\n * `pageBackgroundTokens` in the metadata-service layout validator.\n */\nexport const PAGE_BACKGROUND_TOKENS = [\n 'bg',\n 'bg-2',\n 'bg-3',\n 'ink',\n 'ink-2',\n 'ink-3',\n 'ink-4',\n 'rule',\n 'rule-2',\n 'accent',\n 'accent-2',\n 'accent-ink',\n 'success',\n 'warning',\n 'danger',\n 'info',\n] as const\n\nexport type PageBackgroundToken = (typeof PAGE_BACKGROUND_TOKENS)[number]\n\n/**\n * Per-page presentation of a standalone page shell: background color plus the\n * content container's max-width and side / top padding. Every field is\n * optional; an omitted field falls back to the renderer default (the historical\n * bg / 1200px / 24px-32px look). `max_width: \"fill\"` (or `\"auto\"`) with zero\n * padding lets a component fill the page edge-to-edge.\n *\n * Honored on `platform`, `public` and `kiosk` pages; record pages reject it\n * (enforced server-side). On platform pages it styles the app shell's content\n * area rather than a standalone shell.\n */\nexport interface PageStyle {\n /** Design-token key (see PAGE_BACKGROUND_TOKENS) or a raw CSS color. */\n background?: string\n /** Content max-width; `\"fill\"` / `\"auto\"` removes the cap. */\n max_width?: SizeValue\n /** Horizontal / vertical padding of the content container (Tailwind px/py). */\n padding_x?: SizeValue\n padding_y?: SizeValue\n}\n\nexport const PageStyleSchema = z.object({\n background: z.string().optional(),\n max_width: SizeValueSchema.optional(),\n padding_x: SizeValueSchema.optional(),\n padding_y: SizeValueSchema.optional(),\n})\n\n/**\n * Top-level page layout. Replaces the legacy `mainContent` / `side_panel`\n * arrays of `PageSection`s with a single typed element tree.\n */\nexport interface PageLayout {\n version: 1\n main: LayoutElement\n side_panel?: PageLayoutSidePanel\n style?: PageStyle\n}\n\nexport const PageLayoutSchema = z.object({\n version: z.literal(1),\n main: LayoutElementSchema,\n side_panel: PageLayoutSidePanelSchema.optional(),\n style: PageStyleSchema.optional(),\n})\n","import { z } from 'zod'\n\n/**\n * Pagination metadata from list responses.\n * Field names match the backend wire format exactly.\n */\nexport interface ResponseMeta {\n /** Current page number (0-indexed across all services). */\n page: number\n /** Number of items per page */\n page_size: number\n /** Total number of items across all pages */\n items_total: number\n /** Total number of pages */\n pages_total: number\n}\n\n/**\n * Zod schema for ResponseMeta validation.\n */\nexport const ResponseMetaSchema = z.object({\n page: z.number(),\n page_size: z.number(),\n items_total: z.number(),\n pages_total: z.number(),\n})\n\n/**\n * Generic paginated response wrapper.\n */\nexport interface ListResult<T> {\n meta: ResponseMeta\n data: T[]\n}\n\n/**\n * Creates a Zod schema for ListResult with a given item schema.\n */\nexport function createListResultSchema<T>(itemSchema: z.ZodType<T>) {\n return z.object({\n meta: ResponseMetaSchema,\n data: z.array(itemSchema),\n })\n}\n\n/**\n * Base list options with pagination and sorting.\n */\nexport interface ListOptions {\n /** Page number (0-indexed). First page is 0. */\n page?: number\n /** Number of items per page (default: 100) */\n page_size?: number\n /** Field to sort by */\n sort_by?: string\n /** Sort direction */\n sort_direction?: 'asc' | 'desc'\n}\n\n/**\n * Common timestamp fields for entities.\n */\nexport interface Timestamps {\n /** ISO 8601 timestamp when the entity was created */\n created_at: string\n /** ISO 8601 timestamp when the entity was last updated */\n updated_at: string\n}\n\n/**\n * The kind of user a {@link UserRef} points at. `person` is a human; `agent`\n * is an AI actor; `api` is a non-interactive client (reserved). The `\"platform\"`\n * sentinel id (system/bootstrap writes) carries `person`.\n */\nexport type UserType = 'person' | 'agent' | 'api'\n\n/**\n * A reference to a platform user — the value stored by every `user` attribute\n * (including `created_by`/`updated_by`). `id` is the platform user id (or the\n * `\"platform\"` sentinel for system writes); `type` is the user kind. The people\n * picker resolves and filters on `id`.\n */\nexport interface UserRef {\n type: UserType\n id: string\n}\n\n/**\n * Zod schema for a UserRef value.\n */\nexport const UserRefSchema = z.object({\n type: z.enum(['person', 'agent', 'api']),\n id: z.string(),\n})\n\n/**\n * Sentinel id stored in created_by/updated_by for writes that didn't originate\n * from a real user (bootstrap / system). Mirrors the backend's\n * `common.PlatformUserId`.\n */\nexport const PLATFORM_USER_ID = 'platform'\n\n/**\n * A reference to a stored file — the value stored by every `file` attribute.\n * `id` is the storage-service file id; `name` is the denormalised filename the\n * record carries so it has a human label without a storage round-trip.\n * `content_type` is an optional denormalised MIME hint so renderers can pick a\n * viewer without a storage round-trip; when absent (legacy values), size and\n * content type are resolved from the storage-service by `id` on read. Mirrors\n * the backend's `common.FileRef`.\n */\nexport interface FileRef {\n id: string\n name: string\n content_type?: string\n}\n\n/**\n * Zod schema for a FileRef value.\n */\nexport const FileRefSchema = z.object({\n id: z.string(),\n name: z.string(),\n // Mirrors the server-side validator: when present, must be non-empty.\n content_type: z.string().min(1).optional(),\n})\n\n/**\n * Common audit fields for entities. `created_by`/`updated_by` hold a\n * {@link UserRef} for the user who made the change (the `\"platform\"` sentinel\n * id for system writes).\n */\nexport interface AuditFields extends Timestamps {\n /** Who created the entity (the \"platform\" sentinel id for system writes). */\n created_by: UserRef\n /** Who last updated the entity (the \"platform\" sentinel id for system writes). */\n updated_by: UserRef\n}\n\n/**\n * Zod schema for audit fields validation.\n */\nexport const AuditFieldsSchema = z.object({\n created_at: z.string(),\n updated_at: z.string(),\n created_by: UserRefSchema,\n updated_by: UserRefSchema,\n})\n","import { z } from 'zod'\nimport type { AuditFields, ListOptions } from '../types/common.js'\nimport { AuditFieldsSchema } from '../types/common.js'\nimport { type PageLayout, PageLayoutSchema } from './layout/page-layout.js'\n\nexport type { PageLayout } from './layout/page-layout.js'\n\n// ============================================================================\n// Shared Types\n// ============================================================================\n\n/**\n * Base list options with source filters for the meta namespace.\n */\nexport interface MetaListOptions extends ListOptions {\n created_by?: string\n updated_by?: string\n}\n\n// ============================================================================\n// Entity Types\n// ============================================================================\n\n/**\n * Attribute type — canonical to the Go `model.AttributeType` union\n * (packages/go/model/meta/attribute.go). The members below are the\n * full set; format/structural variation lives on `Attribute.meta` (see\n * `AttributeMeta` below), not on the type discriminator.\n */\nexport type AttributeType =\n | 'string'\n | 'number'\n | 'integer'\n | 'boolean'\n | 'array'\n | 'object'\n | 'datetime'\n | 'enum'\n | 'relation'\n | 'user'\n | 'principal'\n | 'currency'\n | 'knowledge-text'\n | 'file'\n\n/**\n * Attribute-level permissions: restricting a FIELD rather than a record — a\n * salary column readable only by the people team, a margin column writable only\n * by finance. Mirror of the Go `metamodel.AttributeRestrictions`.\n *\n * Orthogonal to instance-level access: a caller who may see a record may still\n * be blocked from one of its fields.\n *\n * Absent means unrestricted. Both arms FAIL CLOSED — an empty rule matches\n * nobody rather than everybody, and an unknown role or team slug never matches,\n * so a typo removes access rather than granting it.\n */\nexport interface AttributeAccessRule {\n /** Role slugs, matched against the caller's roles. */\n roles?: string[]\n /**\n * Team slugs. Matched through the caller's team closure, so a member of a\n * CHILD team is matched by a rule naming an ancestor.\n */\n teams?: string[]\n}\n\nexport const AttributeAccessRuleSchema = z.object({\n roles: z.array(z.string()).optional(),\n teams: z.array(z.string()).optional(),\n})\n\n/**\n * Read and write are gated independently, so `write` alone yields a field\n * everyone can see and only some can change.\n */\nexport interface AttributeRestrictions {\n read?: AttributeAccessRule\n write?: AttributeAccessRule\n}\n\nexport const AttributeRestrictionsSchema = z.object({\n read: AttributeAccessRuleSchema.optional(),\n write: AttributeAccessRuleSchema.optional(),\n})\n\n// ── Attribute meta (sub-discriminators) ──────────────────────────────\n// Mirrors the Go `*AttributeMeta` types in\n// packages/go/model/attribute-{string,number,datetime,array,object,enum}.go.\n\n/** JSON-Schema string formats carried by `string` attributes. */\nexport type StringFormat = 'email' | 'uri' | 'uuid' | 'hostname' | 'ipv4' | 'ipv6'\n\nexport interface StringAttributeMeta {\n format?: StringFormat\n min_length?: number\n max_length?: number\n pattern?: string\n}\n\nexport interface NumberAttributeMeta {\n minimum?: number\n maximum?: number\n exclusive_minimum?: number\n exclusive_maximum?: number\n multiple_of?: number\n}\n\n/** Datetime storage/display behavior. `format` is required. */\nexport type DatetimeFormat = 'date-time' | 'date' | 'time' | 'duration'\n\nexport interface DatetimeAttributeMeta {\n format: DatetimeFormat\n minimum?: string\n maximum?: string\n}\n\nexport interface ArrayAttributeMeta {\n items?: Attribute\n min_items?: number\n max_items?: number\n items_must_be_unique?: boolean\n}\n\nexport interface ObjectAttributeMeta {\n attributes?: Attribute[]\n}\n\nexport interface EnumValue {\n value: string\n label?: string\n description?: string\n /** Lucide icon name, canonical PascalCase (e.g. `CircleCheck`). Replaces the badge dot. */\n icon?: string\n /** Tint as `#rrggbb`. Renderers derive dot/border/background from it; text stays ink. */\n color?: string\n}\n\nexport interface EnumAttributeMeta {\n values: EnumValue[]\n}\n\n/**\n * Policy applied to the host row when the related row is deleted. Mirror\n * of `model.OnDeleteAction`. The runtime semantic is enforced at the\n * data-service level; this metadata declares the intent.\n */\nexport type OnDeleteAction = 'cascade' | 'restrict' | 'set-null'\n\nexport const OnDeleteActionSchema = z.enum(['cascade', 'restrict', 'set-null'])\n\n/**\n * Metadata for a `relation`-typed attribute. The attribute is a foreign-key\n * column on the host entity pointing at `related_attribute` on\n * `related_entity_slug`. `predicate` reads from the host outward (e.g. on\n * `Order.customerId` with `predicate: \"is placed by\"`, the sentence is\n * \"Order is placed by Customer\").\n */\nexport interface RelationAttributeMeta {\n related_entity_slug: string\n related_attribute: string\n predicate: string\n description?: string\n on_delete: OnDeleteAction\n}\n\nexport const RelationAttributeMetaSchema = z.object({\n related_entity_slug: z.string(),\n related_attribute: z.string(),\n predicate: z.string(),\n description: z.string().optional(),\n on_delete: OnDeleteActionSchema,\n})\n\n/**\n * Metadata for a `user`-typed attribute. A user attribute stores a\n * {@link UserRef} `{ type, id }` (the account-service identity plus its\n * kind), rendered as a people picker that resolves and filters on `id`. Mirror\n * of the Go `metamodel.UserAttributeMeta`.\n *\n * It carries no required configuration today; the shape exists for parity\n * with the other metas and reserves room for future options (e.g.\n * multi-user selection).\n */\nexport interface UserAttributeMeta {\n description?: string\n}\n\nexport const UserAttributeMetaSchema = z.object({\n description: z.string().optional(),\n})\n\n/**\n * The stored value of a `principal`-typed attribute: a {@link PrincipalRef}\n * `{ type, id }` naming anything that can HOLD ACCESS — a user (person, agent\n * or api client), a team, or the whole organization. Mirror of the Go\n * `metamodel.PrincipalAttributeMeta`.\n *\n * Distinct from `user` on purpose. `user` means \"a person did this\" — it is\n * authorship, and its value can never be a team. `principal` means \"this party\n * may be granted access\", a different question with a strictly larger\n * vocabulary. Widening `user` would have made every existing user attribute\n * silently accept a team, including the created_by / updated_by audit columns.\n */\nexport interface PrincipalAttributeMeta {\n description?: string\n /**\n * Turns the attribute into a GRANTING attribute: the verbs its value confers\n * on the record. `deals.account_manager` with `[\"read\",\"write\"]` means setting\n * it gives that principal access with no share call — the business field IS\n * the ACL.\n *\n * `share` is the right to hand access on — share the record, set other\n * granting attributes, revoke shares. `[\"read\",\"write\",\"delete\",\"share\"]` is\n * full ownership: there is no separate owner field on the platform, the\n * business field that grants `share` IS the owner. `share` must accompany\n * at least one of read/write/delete, and an attribute granting it never\n * accepts an `org` principal.\n *\n * Empty (the default) means an ordinary reference that confers nothing, so an\n * existing principal attribute cannot start granting access by accident.\n */\n grants?: Array<'read' | 'write' | 'delete' | 'share'>\n /**\n * Narrows which principal kinds this attribute accepts; empty means all\n * (except that an attribute granting `share` refuses `org` regardless —\n * an org-wide right to re-grant would hand record management to every\n * member).\n */\n allowed_types?: PrincipalType[]\n}\n\nexport const PrincipalAttributeMetaSchema = z.object({\n description: z.string().optional(),\n grants: z.array(z.enum(['read', 'write', 'delete', 'share'])).optional(),\n allowed_types: z.array(z.enum(['person', 'agent', 'api', 'team', 'org'])).optional(),\n})\n\n/** The kinds a principal reference may name. */\nexport type PrincipalType = 'person' | 'agent' | 'api' | 'team' | 'org'\n\n/**\n * The stored value of a `principal`-typed attribute.\n */\nexport interface PrincipalRef {\n type: PrincipalType\n id: string\n}\n\nexport const PrincipalRefSchema = z.object({\n type: z.enum(['person', 'agent', 'api', 'team', 'org']),\n id: z.string(),\n})\n\n/**\n * The stored value of a `currency`-typed attribute: an exact decimal `amount`\n * (a STRING, never a JS number — preserves financial-system precision and\n * trailing zeros) paired with an ISO-4217 `currency_code`. This is the wire\n * shape; the `@proteos/ui` `CurrencyInput` and the web control both read/write\n * it directly to avoid an adapter.\n */\nexport interface CurrencyValue {\n amount: string\n currency_code: string\n}\n\n/**\n * Metadata for a `currency`-typed attribute. Both fields are optional: when\n * `allowed_currency_codes` is empty/absent, any ISO-4217 code is accepted;\n * `default_currency_code` seeds the picker for new values and must be a member\n * of `allowed_currency_codes` when that allow-list is set. Mirror of the Go\n * `metamodel.CurrencyAttributeMeta`.\n */\nexport interface CurrencyAttributeMeta {\n default_currency_code?: string\n allowed_currency_codes?: string[]\n}\n\nexport const CurrencyAttributeMetaSchema = z.object({\n default_currency_code: z.string().optional(),\n allowed_currency_codes: z.array(z.string()).optional(),\n})\n\n/**\n * The value of a `knowledge-text`-typed attribute: a reference to the\n * knowledge node (knowledge-service) that owns the text body. The record\n * persists only `{ id }`; `content` is transient — accepted on writes (the\n * text to materialize into the node) and filled on single-record reads.\n * Clients may also write a bare string as shorthand for `{ content }`.\n * Mirror of the Go `common.KnowledgeNodeRef`.\n */\nexport interface KnowledgeNodeRef {\n id: string\n content?: string\n}\n\n/**\n * Metadata for a `knowledge-text`-typed attribute. The value is a\n * {@link KnowledgeNodeRef}; the data-service materializes client-sent text\n * into a knowledge node before persisting. Mirror of the Go\n * `metamodel.KnowledgeTextAttributeMeta`.\n *\n * It carries no required configuration today; the shape exists for parity\n * with the other metas and reserves room for future options (e.g. node\n * labels, status overrides).\n */\nexport interface KnowledgeTextAttributeMeta {\n description?: string\n}\n\nexport const KnowledgeTextAttributeMetaSchema = z.object({\n description: z.string().optional(),\n})\n\n/**\n * Metadata for a `file`-typed attribute. The value is a {@link FileRef}\n * `{ id, name }` referencing a storage-service file; the frontend uploads to\n * the storage-service and writes the resulting id + name. Mirror of the Go\n * `metamodel.FileAttributeMeta`.\n *\n * It carries no required configuration today; the shape exists for parity with\n * the other metas and reserves room for future options (e.g. accepted content\n * types, max size).\n */\nexport interface FileAttributeMeta {\n description?: string\n}\n\nexport const FileAttributeMetaSchema = z.object({\n description: z.string().optional(),\n})\n\n/**\n * Discriminated union of attribute metas. The wire JSON carries the\n * appropriate shape based on `Attribute.type`; runtime consumers can\n * narrow via the `type` field.\n */\nexport type AttributeMeta =\n | StringAttributeMeta\n | NumberAttributeMeta\n | DatetimeAttributeMeta\n | ArrayAttributeMeta\n | ObjectAttributeMeta\n | EnumAttributeMeta\n | RelationAttributeMeta\n | UserAttributeMeta\n | PrincipalAttributeMeta\n | CurrencyAttributeMeta\n | KnowledgeTextAttributeMeta\n | FileAttributeMeta\n\n/**\n * Entity attribute definition. Mirrors `model.Attribute` in the Go SDK.\n */\nexport interface Attribute {\n name: string\n type: AttributeType\n label: string\n description?: string\n is_required: boolean\n is_nullable?: boolean\n is_unique: boolean\n is_read_only?: boolean\n /**\n * Platform-managed flag. Marks the canonical platform attributes (id,\n * created_at, updated_at, created_by, updated_by) — auto-added to every\n * entity, locked in the designer, and rejected from client redefinition.\n * Mirrors `IsPlatformManaged` in the Go `metamodel.Attribute`.\n */\n is_platform_managed?: boolean\n /**\n * Attribute-level permissions. Absent means unrestricted (today's behaviour).\n * Platform-managed attributes cannot carry restrictions.\n */\n restrictions?: AttributeRestrictions\n /**\n * Literal default, or — on a `user` / `principal` attribute only — the\n * current-user sentinel `{ type: 'current_user' }` (see\n * `CURRENT_USER_DEFAULT`), which data-service resolves to the writer at\n * record-write time.\n */\n default_value?: unknown\n /**\n * Type-specific metadata. The concrete shape is determined by `type`\n * — e.g. `type: 'string'` carries `StringAttributeMeta`. The wire\n * field name is `meta`; `options` is an older alias still emitted by\n * some service paths and accepted for backwards compatibility.\n */\n meta?: AttributeMeta\n /** @deprecated Older wire alias for `meta`. Prefer `meta`. */\n options?: Record<string, unknown>\n}\n\n/**\n * Canonical platform attribute names — the system-managed set every entity\n * carries. Mirrors `metamodel.PlatformAttribute*` constants in the Go model.\n */\nexport const PLATFORM_ATTRIBUTE_NAMES = [\n 'id',\n 'created_at',\n 'updated_at',\n 'created_by',\n 'updated_by',\n] as const\n\n/** True when `name` is one of the canonical platform attributes. */\nexport function isPlatformAttributeName(name: string): boolean {\n return (PLATFORM_ATTRIBUTE_NAMES as readonly string[]).includes(name)\n}\n\n/**\n * The canonical platform attributes, in display order. Mirror of the Go\n * `metamodel.PlatformAttributes()`. Used by the entity designer to seed new\n * entities; the backend re-asserts these on save regardless.\n */\nexport function platformAttributes(): Attribute[] {\n return [\n {\n name: 'id',\n type: 'string',\n label: 'Id',\n description: 'Unique identifier of the record.',\n is_required: false,\n is_unique: true,\n is_read_only: true,\n is_platform_managed: true,\n },\n {\n name: 'created_at',\n type: 'datetime',\n label: 'Created At',\n description: 'Timestamp when the record was created.',\n is_required: false,\n is_unique: false,\n is_read_only: true,\n is_platform_managed: true,\n meta: { format: 'date-time' },\n },\n {\n name: 'updated_at',\n type: 'datetime',\n label: 'Updated At',\n description: 'Timestamp when the record was last updated.',\n is_required: false,\n is_unique: false,\n is_read_only: true,\n is_platform_managed: true,\n meta: { format: 'date-time' },\n },\n {\n name: 'created_by',\n type: 'user',\n label: 'Created By',\n description: 'User who created the record (\"platform\" for system writes).',\n is_required: false,\n is_unique: false,\n is_read_only: true,\n is_platform_managed: true,\n },\n {\n name: 'updated_by',\n type: 'user',\n label: 'Updated By',\n description: 'User who last updated the record (\"platform\" for system writes).',\n is_required: false,\n is_unique: false,\n is_read_only: true,\n is_platform_managed: true,\n },\n ]\n}\n\n// Schema validation is intentionally lax on `type` (z.string()) and\n// `meta` (z.unknown()) because (a) wire data may carry legacy values\n// from older service deploys, and (b) the renderer narrows on\n// `attribute.type` at the use site. Stricter narrowing happens in\n// renderer-side helpers (e.g. `lookupControls(attr)` from the layout\n// module), not in the schema parse.\nexport const AttributeSchema = z.object({\n name: z.string(),\n type: z.string(),\n label: z.string(),\n description: z.string().optional(),\n is_required: z.boolean(),\n is_nullable: z.boolean().optional(),\n is_unique: z.boolean(),\n is_read_only: z.boolean().optional(),\n restrictions: AttributeRestrictionsSchema.optional(),\n default_value: z.unknown().optional(),\n meta: z.unknown().optional(),\n options: z.record(z.unknown()).optional(),\n})\n\n/**\n * Returns the typed `RelationAttributeMeta` when `attr` is a relation\n * attribute with a valid meta shape; null otherwise. The `AttributeSchema`\n * intentionally keeps `meta` lax, so callers that need the relation fields\n * narrowed should go through this helper rather than casting.\n */\nexport function parseRelationMeta(attr: Attribute): RelationAttributeMeta | null {\n if (attr.type !== 'relation') return null\n const parsed = RelationAttributeMetaSchema.safeParse(attr.meta)\n return parsed.success ? parsed.data : null\n}\n\n/**\n * Returns the typed `UserAttributeMeta` when `attr` is a user attribute;\n * null otherwise. User meta is optional (and usually absent), so a user\n * attribute with no meta still resolves to an empty `{}` rather than null.\n */\nexport function parseCurrencyMeta(attr: Attribute): CurrencyAttributeMeta | null {\n if (attr.type !== 'currency') return null\n const parsed = CurrencyAttributeMetaSchema.safeParse(attr.meta ?? {})\n return parsed.success ? parsed.data : null\n}\n\n/**\n * Returns the typed `PrincipalAttributeMeta` when `attr` is a principal\n * attribute; null otherwise. Principal meta is optional, so an attribute with\n * no meta resolves to an empty `{}` rather than null.\n */\nexport function parsePrincipalMeta(attr: Attribute): PrincipalAttributeMeta | null {\n if (attr.type !== 'principal') return null\n if (attr.meta == null) return {}\n const parsed = PrincipalAttributeMetaSchema.safeParse(attr.meta)\n return parsed.success ? parsed.data : {}\n}\n\nexport function parseUserMeta(attr: Attribute): UserAttributeMeta | null {\n if (attr.type !== 'user') return null\n if (attr.meta == null) return {}\n const parsed = UserAttributeMetaSchema.safeParse(attr.meta)\n return parsed.success ? parsed.data : {}\n}\n\n/**\n * Returns the typed `KnowledgeTextAttributeMeta` when `attr` is a\n * knowledge-text attribute; null otherwise. Knowledge-text meta is optional\n * (and usually absent), so a knowledge-text attribute with no meta still\n * resolves to an empty `{}` rather than null.\n */\nexport function parseKnowledgeTextMeta(attr: Attribute): KnowledgeTextAttributeMeta | null {\n if (attr.type !== 'knowledge-text') return null\n if (attr.meta == null) return {}\n const parsed = KnowledgeTextAttributeMetaSchema.safeParse(attr.meta)\n return parsed.success ? parsed.data : {}\n}\n\n/**\n * Returns the typed `FileAttributeMeta` when `attr` is a file attribute; null\n * otherwise. File meta is optional (and usually absent), so a file attribute\n * with no meta still resolves to an empty `{}` rather than null.\n */\nexport function parseFileMeta(attr: Attribute): FileAttributeMeta | null {\n if (attr.type !== 'file') return null\n if (attr.meta == null) return {}\n const parsed = FileAttributeMetaSchema.safeParse(attr.meta)\n return parsed.success ? parsed.data : {}\n}\n\n/**\n * A single operation a resource may be publicly exposed for. Independent set\n * (not a level): a resource can be public for `write` without `read`. Only\n * `read` is honored on the platform today; `write`/`delete` are reserved.\n */\nexport type PublicAccessOperation = 'read' | 'write' | 'delete'\n\nexport const PublicAccessOperationSchema = z.enum(['read', 'write', 'delete'])\n\n/**\n * Entity definition.\n * Note: Entity uses `slug` as its primary identifier, not `id`.\n */\nexport interface Entity extends AuditFields {\n slug: string\n name: string\n description: string\n is_remote: boolean\n /**\n * Operations ALL records of the entity are exposed for on the\n * unauthenticated public surface. Only `[\"read\"]` is honored today (records\n * become world-readable; the entity definition is implicitly readable so\n * they can be interpreted); `write`/`delete` are reserved. Empty = private\n * (default).\n */\n public_record_access: PublicAccessOperation[]\n module_slug: string\n /**\n * Liquid template that renders a human-readable title for an instance\n * (record) of this entity — e.g. `{{ first_name }} {{ last_name }}` for a\n * Customer, `{{ number }}` for an Order. Empty string means \"no template\n * configured\"; consumers fall back to the record id.\n *\n * Render via `renderRecordTitle(entity, record)` rather than evaluating\n * the template directly, so the fallback chain stays consistent.\n */\n title_template: string\n attributes: Attribute[]\n}\n\nexport const EntitySchema = AuditFieldsSchema.extend({\n slug: z.string(),\n name: z.string(),\n description: z.string(),\n is_remote: z.boolean(),\n // Default keeps older API responses (pre-`public_record_access` rollout)\n // parsing cleanly.\n public_record_access: z.array(PublicAccessOperationSchema).default([]),\n module_slug: z.string(),\n // Default keeps older API responses (pre-`title_template` rollout) parsing\n // cleanly — the field is non-optional in the TS surface but tolerant on\n // the wire.\n title_template: z.string().default(''),\n attributes: z.array(AttributeSchema),\n})\n\n/**\n * Entity with JSON Schema representation.\n */\nexport interface EntityWithSchema extends Entity {\n schema: Record<string, unknown>\n}\n\nexport const EntityWithSchemaSchema = EntitySchema.extend({\n schema: z.record(z.unknown()),\n})\n\n/**\n * Options for listing entities.\n */\nexport interface ListEntitiesOptions extends MetaListOptions {\n slug?: string\n name?: string\n is_remote?: boolean\n module_slug?: string\n}\n\n/**\n * Request to create an entity.\n */\nexport interface CreateEntityRequest {\n slug: string\n name: string\n is_remote: boolean\n /**\n * Operations to expose all records of the entity for, unauthenticated (only\n * `[\"read\"]` accepted today). Full-replacement on upsert: an upsert without\n * the field resets it to private.\n */\n public_record_access?: PublicAccessOperation[]\n module_slug: string\n description: string\n title_template?: string\n attributes: Attribute[]\n}\n\n/**\n * Request to update an entity.\n */\nexport interface UpdateEntityRequest {\n name?: string\n is_remote?: boolean\n public_record_access?: PublicAccessOperation[]\n module_slug?: string\n description?: string\n title_template?: string\n attributes?: Attribute[]\n}\n\n// ============================================================================\n// Module Types\n// ============================================================================\n\n/**\n * Module deployment status.\n */\nexport type ModuleStatus =\n | 'pending'\n | 'deploying'\n | 'active'\n | 'failed'\n | 'deactivating'\n | 'inactive'\n\n/**\n * Module definition.\n */\nexport interface Module extends AuditFields {\n slug: string\n org_id: string\n name: string\n description: string\n version: string\n file_id: string\n status: ModuleStatus\n status_details: string\n is_deactivated: boolean\n}\n\nexport const ModuleSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n name: z.string(),\n description: z.string(),\n version: z.string(),\n file_id: z.string(),\n status: z.enum(['pending', 'deploying', 'active', 'failed', 'deactivating', 'inactive']),\n status_details: z.string(),\n is_deactivated: z.boolean(),\n})\n\n/**\n * Options for listing modules.\n */\nexport interface ListModulesOptions extends MetaListOptions {\n slug?: string\n name?: string\n is_deactivated?: boolean\n file_id?: string\n status?: ModuleStatus\n version?: string\n}\n\n/**\n * Request to deploy a module.\n */\nexport interface DeployModuleRequest {\n slug: string\n version: string\n name: string\n description: string\n}\n\n// ============================================================================\n// Variable Types\n// ============================================================================\n\n/**\n * Configuration/secret variable.\n */\nexport interface Variable extends AuditFields {\n id: string\n org_id: string\n key: string\n value: string\n is_secret: boolean\n module: string\n}\n\nexport const VariableSchema = AuditFieldsSchema.extend({\n id: z.string(),\n key: z.string(),\n value: z.string(),\n is_secret: z.boolean(),\n module: z.string(),\n})\n\n/**\n * Options for listing variables.\n */\nexport interface ListVariablesOptions extends MetaListOptions {\n id?: string\n key?: string\n is_secret?: boolean\n module?: string\n}\n\n/**\n * Request to create a variable.\n */\nexport interface CreateVariableRequest {\n key: string\n value: string\n is_secret: boolean\n module: string\n}\n\n/**\n * Request to update a variable.\n */\nexport interface UpdateVariableRequest {\n value?: string\n}\n\n// ============================================================================\n// Component Types\n// ============================================================================\n\n/**\n * UI component definition.\n * Note: Component uses `slug` as its primary identifier, not `id`.\n */\nexport interface Component extends AuditFields {\n slug: string\n org_id: string\n name: string\n description: string\n module_slug: string\n /** FK to the compiled, single-file ESM bundle in storage. Empty until deployed. Served via {@link ComponentService.bundleUrl}. */\n bundle_file_id: string\n /** FK to a tar.gz of the component source directory in storage (provenance / rebuild). Empty until deployed. */\n source_file_id: string\n /** The component's JSON Schema, driving the page-designer props editor + runtime validation. `null` until set. */\n props_schema: Record<string, unknown> | null\n /**\n * Opts the compiled bundle into UNAUTHENTICATED serving. Public\n * (type='public') pages may only reference public components (enforced at\n * page save), and a public component's only platform reach at runtime is\n * `functions.actions.invokePublic`.\n */\n is_public: boolean\n}\n\nexport const ComponentSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n name: z.string(),\n description: z.string(),\n module_slug: z.string(),\n bundle_file_id: z.string(),\n source_file_id: z.string(),\n // default(false): rows serialized before the flag existed lack the field.\n props_schema: z.record(z.unknown()).nullable(),\n is_public: z.boolean().default(false),\n})\n\n/**\n * Options for listing components.\n */\nexport interface ListComponentsOptions extends MetaListOptions {\n slug?: string\n name?: string\n module_slug?: string\n}\n\n/**\n * Request to create a component.\n */\nexport interface CreateComponentRequest {\n slug: string\n name: string\n module_slug: string\n description: string\n bundle_file_id?: string\n source_file_id?: string\n props_schema?: Record<string, unknown>\n /** See {@link Component.is_public}. Manifest-driven: omitting it sets false. */\n is_public?: boolean\n}\n\n/**\n * Request to update a component.\n */\nexport interface UpdateComponentRequest {\n name?: string\n description?: string\n bundle_file_id?: string\n source_file_id?: string\n props_schema?: Record<string, unknown>\n is_public?: boolean\n}\n\n// ============================================================================\n// List Types\n// ============================================================================\n\n/**\n * List column definition.\n *\n * `attribute` is an attribute name or a dot path, told apart by the type of\n * the first segment:\n *\n * - `name` — an attribute on the list's own entity.\n * - `address.city` — a leaf inside one of its `object` attributes.\n * - `company_id.name` — a field of the RELATED record, reached through a\n * relation attribute (the first segment is the FK).\n *\n * A bare `object` attribute is not a valid column — it carries no value of\n * its own, only leaves. Sorting follows the same grammar minus the relation\n * hop: an attribute or an object path can be ordered by, a related field\n * cannot (it would need a join).\n */\nexport interface Column {\n attribute: string\n label: string\n width: number\n}\n\n/**\n * Sort direction.\n */\nexport type SortDirection = 'asc' | 'desc'\n\n/**\n * Sort configuration. `attribute` is an attribute name or an object path\n * (`address.city`); relation paths are not sortable — ordering by a related\n * field would need a join the records query doesn't do.\n */\nexport interface SortConfig {\n attribute: string\n direction: SortDirection\n}\n\n// Filter / predicate types live in ./filters.js so the layout module can\n// import FilterGroup without inducing a types.ts ↔ layout cycle.\nimport {\n type ComparisonOperator,\n type FilterElement,\n FilterElementSchema,\n type FilterGroup,\n FilterGroupSchema,\n type LogicalOperator,\n} from './filters.js'\n\nexport {\n type ComparisonOperator,\n type FilterElement,\n FilterElementSchema,\n type FilterGroup,\n FilterGroupSchema,\n type LogicalOperator,\n}\n\n// ============================================================================\n// Toolbar action buttons (shared by pages and lists)\n// ============================================================================\n\n/**\n * What a page toolbar button invokes. Absent normalizes to `action` (pages\n * persisted before `kind` existed).\n */\nexport type PageActionKind = 'action' | 'workflow'\n\n/**\n * Page action definition — one toolbar button. `kind: action` invokes a\n * function-service Action by slug (`action`) and may prefill its params;\n * `kind: workflow` starts a manual run of a workflow by key (`workflow`) and\n * may prefill its manual-trigger inputs. `params` / `inputs` map target field\n * names to Liquid templates rendered against the page scope\n * `{ record, entity, params, user }`; a resolved field is locked in the invoke\n * dialog. `skip_confirmation` fires the target immediately when every required\n * field resolved from the templates.\n */\nexport interface PageAction {\n label: string\n icon: string\n kind?: PageActionKind\n action?: string\n workflow?: string\n params?: Record<string, string>\n inputs?: Record<string, string>\n skip_confirmation?: boolean\n}\n\nexport const PageActionSchema = z.object({\n label: z.string(),\n icon: z.string(),\n kind: z.enum(['action', 'workflow']).optional(),\n action: z.string().optional(),\n workflow: z.string().optional(),\n params: z.record(z.string()).optional(),\n inputs: z.record(z.string()).optional(),\n skip_confirmation: z.boolean().optional(),\n})\n\n/**\n * Whether a list's rows can be checked, and whether the checkboxes show from\n * the start:\n *\n * - `on_demand` (default) — a Select toggle in the toolbar reveals them.\n * - `always` — checkboxes are showing from the start.\n * - `off` — rows can never be checked, even when the list carries actions.\n */\nexport type SelectionMode = 'on_demand' | 'always' | 'off'\n\nexport const SelectionModeSchema = z.enum(['on_demand', 'always', 'off'])\n\n/**\n * List configuration.\n * Note: List uses `slug` as its primary identifier, not `id`.\n */\nexport interface List extends AuditFields {\n slug: string\n org_id: string\n module_slug: string\n name: string\n entity_slug: string\n columns: Column[]\n /**\n * Toolbar buttons on the list, same shape a page carries. They act on the\n * rows SELECTED in the list, so an `action` button names an `entity_batch`\n * action (invoked once with every selected record id) and prefill templates\n * resolve against the list scope `{ selection, entity, user }`.\n */\n actions?: PageAction[]\n /** Row-selection affordance; absent normalizes to `on_demand`. */\n selection_mode?: SelectionMode\n /** Record page to open from this list; empty/absent = org default for the entity. */\n sorting: SortConfig[]\n filters: FilterGroup[]\n}\n\nexport const ColumnSchema = z.object({\n attribute: z.string(),\n label: z.string(),\n width: z.number(),\n})\n\nexport const SortConfigSchema = z.object({\n attribute: z.string(),\n direction: z.enum(['asc', 'desc']),\n})\n\nexport const ListSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n module_slug: z.string(),\n name: z.string(),\n entity_slug: z.string(),\n columns: z.array(ColumnSchema),\n actions: z.array(PageActionSchema).optional(),\n selection_mode: SelectionModeSchema.optional(),\n sorting: z.array(SortConfigSchema),\n filters: z.array(FilterGroupSchema),\n})\n\n/**\n * Options for listing lists.\n */\nexport interface ListListsOptions extends MetaListOptions {\n slug?: string\n name?: string\n module_slug?: string\n entity_slug?: string\n}\n\n/**\n * Request to create a list.\n */\nexport interface CreateListRequest {\n slug: string\n module_slug?: string\n entity_slug: string\n name: string\n columns: Column[]\n actions?: PageAction[]\n selection_mode?: SelectionMode\n sorting: SortConfig[]\n filters: FilterGroup[]\n}\n\n/**\n * Request to update a list.\n */\nexport interface UpdateListRequest {\n name?: string\n module_slug?: string\n columns?: Column[]\n actions?: PageAction[]\n selection_mode?: SelectionMode\n /** Set to '' to clear back to the org default. */\n sorting?: SortConfig[]\n filters?: FilterGroup[]\n}\n\n// ============================================================================\n// ListView Types\n// ============================================================================\n\n/**\n * List view configuration.\n * Note: ListView uses `slug` as its primary identifier, not `id`.\n */\nexport interface ListView extends AuditFields {\n slug: string\n org_id: string\n module_slug: string\n list_slug: string\n name: string\n columns: Column[]\n sorting: SortConfig[]\n filters: FilterGroup[]\n}\n\nexport const ListViewSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n module_slug: z.string(),\n list_slug: z.string(),\n name: z.string(),\n columns: z.array(ColumnSchema),\n sorting: z.array(SortConfigSchema),\n filters: z.array(FilterGroupSchema),\n})\n\n/**\n * Options for listing list views.\n */\nexport interface ListListViewsOptions extends MetaListOptions {\n slug?: string\n name?: string\n module_slug?: string\n list_slug?: string\n}\n\n/**\n * Request to create a list view.\n */\nexport interface CreateListViewRequest {\n slug: string\n module_slug?: string\n list_slug: string\n name: string\n columns: Column[]\n sorting?: SortConfig[]\n filters?: FilterGroup[]\n}\n\n/**\n * Request to update a list view.\n */\nexport interface UpdateListViewRequest {\n name?: string\n module_slug?: string\n columns?: Column[]\n sorting?: SortConfig[]\n filters?: FilterGroup[]\n}\n\n// ============================================================================\n// Page Types\n// ============================================================================\n\n/**\n * Page type — encodes what the page binds to and how it is served (chrome +\n * auth posture both follow from it):\n *\n * - `record`: rendered against a single record of `entity_slug`; app chrome;\n * authenticated.\n * - `platform`: standalone, no record context (e.g. a dashboard launched from\n * a menu item); app chrome; authenticated.\n * - `kiosk`: standalone, NO app chrome (bare page at `/k/…`); authenticated.\n * - `public`: standalone, NO app chrome (bare page at `/p/…`);\n * UNAUTHENTICATED — the layout is world-readable and its components may only\n * call `is_public` global actions.\n */\nexport type PageType = 'record' | 'platform' | 'kiosk' | 'public'\n\nexport const PageTypeSchema = z.enum(['record', 'platform', 'kiosk', 'public'])\n\n/**\n * Page configuration. A `record` page is the detail-page shape for a single\n * entity; a `platform` page is standalone (no entity, no record).\n *\n * `layout` is a typed tree of LayoutElements (see `./layout`). The legacy\n * `mainContent` / `side_panel` / `formLayout` shape was replaced in the\n * v1 PageLayout design.\n */\nexport interface Page extends AuditFields {\n slug: string\n name: string\n module_slug: string\n type: PageType\n /** Required for `record` pages; absent on `platform` pages. */\n entity_slug?: string\n actions: PageAction[]\n layout: PageLayout\n}\n\nexport const PageSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n name: z.string(),\n module_slug: z.string(),\n type: PageTypeSchema,\n entity_slug: z.string().optional(),\n actions: z.array(PageActionSchema),\n layout: PageLayoutSchema,\n})\n\n/**\n * Component metadata slice riding on the public page payload — just the slug\n * and props schema (deliberately not the full Component: this is served\n * unauthenticated).\n */\nexport interface PublicPageComponent {\n slug: string\n props_schema?: Record<string, unknown>\n}\n\n/**\n * Payload of the unauthenticated `GET /meta/v1/public/orgs/{orgId}/pages/{slug}`:\n * the page plus the props_schema of every component its layout references, so\n * a public renderer needs no follow-up authenticated calls.\n */\nexport interface PublicPageResponse {\n page: Page\n components: PublicPageComponent[]\n}\n\n/**\n * Options for listing pages.\n */\nexport interface ListPagesOptions extends MetaListOptions {\n slug?: string\n name?: string\n module_slug?: string\n type?: PageType\n entity_slug?: string\n}\n\n/**\n * Request to create a page. `type` defaults to `record` when omitted.\n * `entity_slug` is required for record pages and must be absent for platform\n * pages.\n */\nexport interface CreatePageRequest {\n slug: string\n name: string\n module_slug?: string\n type?: PageType\n entity_slug?: string\n actions: PageAction[]\n layout: PageLayout\n}\n\n/**\n * Request to update a page. Layout, when present, must be a complete valid\n * tree — partial / element-level patches are not supported.\n */\nexport interface UpdatePageRequest {\n name?: string\n module_slug?: string\n actions?: PageAction[]\n layout?: PageLayout\n}\n\n// ============================================================================\n// Menu Configuration Types\n// ============================================================================\n\n/**\n * Menu item type values. Use as both enum-like constant and type union.\n */\nexport const MenuItemType = {\n Link: 'link',\n Group: 'group',\n Entity: 'entity',\n Page: 'page',\n List: 'list',\n} as const\nexport type MenuItemType = (typeof MenuItemType)[keyof typeof MenuItemType]\n\n/**\n * Menu item definition. Matches the backend JSON shape for nested menus.\n */\nexport interface MenuItem {\n id: string\n order: number\n label: string\n type: MenuItemType\n icon: string\n reference?: string\n children: MenuItem[] | null\n}\n\n/**\n * Menu configuration.\n */\nexport interface MenuConfiguration extends AuditFields {\n slug: string\n name: string\n module_slug: string\n app_slug: string\n items: MenuItem[]\n is_default: boolean\n}\n\nexport const MenuItemSchema = z.lazy(() =>\n z.object({\n id: z.string(),\n order: z.number(),\n label: z.string(),\n type: z.enum(['link', 'group', 'entity', 'page', 'list']),\n icon: z.string(),\n reference: z.string().optional(),\n children: z.array(MenuItemSchema).nullable(),\n }),\n) as unknown as z.ZodType<MenuItem>\n\nexport const MenuConfigurationSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n name: z.string(),\n module_slug: z.string(),\n app_slug: z.string(),\n items: z.array(MenuItemSchema),\n is_default: z.boolean(),\n})\n\n/**\n * Options for listing menu configurations.\n */\nexport interface ListMenuConfigurationsOptions extends MetaListOptions {\n slug?: string\n name?: string\n module_slug?: string\n app_slug?: string\n is_default?: boolean\n}\n\n/**\n * Request to create a menu configuration.\n */\nexport interface CreateMenuConfigurationRequest {\n slug: string\n module_slug?: string\n name: string\n app_slug: string\n items: MenuItem[]\n is_default: boolean\n}\n\n/**\n * Request to update a menu configuration.\n */\nexport interface UpdateMenuConfigurationRequest {\n name?: string\n module_slug?: string\n items?: MenuItem[]\n is_default?: boolean\n}\n\n// ============================================================================\n// AppConfiguration Types\n// ============================================================================\n\n/** What an app opens on: a list (records table) or a platform page. */\nexport type AppHomeType = 'list' | 'page'\n\nexport interface AppHome {\n type: AppHomeType\n reference: string\n}\n\nexport const AppHomeSchema = z.object({\n type: z.enum(['list', 'page']),\n reference: z.string(),\n})\n\n/**\n * AppConfiguration — a TYPED binding row: \"how app X presents itself\" to\n * everyone (`profile_slug: ''` = the app's default configuration) or to one\n * profile (an override). One row per (app, profile). The web merges\n * override ⊕ default field-wise and falls through to structural defaults (menu\n * `is_default`, first menu leaf, org-default agent, first page) for anything\n * still unset.\n */\nexport interface AppConfiguration extends AuditFields {\n slug: string\n org_id: string\n module_slug: string\n app_slug: string\n /** Bound profile; `''` = the default configuration for everyone. */\n profile_slug: string\n /** Home; absent = the first list/page leaf of the resolved menu. */\n home?: AppHome | null\n /** Menu to show; `''` = the app's `is_default` menu. */\n menu_slug?: string\n /** Agent Ask Proteos preselects in this app; `''` = the org default. */\n default_agent_key?: string\n /** Agents offered in this app; empty = every org agent. */\n agent_keys?: string[]\n /** entity_slug → record page slug opened from this app. */\n record_pages?: Record<string, string>\n}\n\nexport const AppConfigurationSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n org_id: z.string(),\n module_slug: z.string(),\n app_slug: z.string(),\n profile_slug: z.string(),\n home: AppHomeSchema.nullable().optional(),\n menu_slug: z.string().optional(),\n default_agent_key: z.string().optional(),\n agent_keys: z.array(z.string()).optional(),\n record_pages: z.record(z.string()).optional(),\n})\n\nexport interface ListAppConfigurationsOptions extends MetaListOptions {\n slug?: string\n module_slug?: string\n app_slug?: string\n profile_slug?: string\n /** `true` = only default rows (no profile), `false` = only profile overrides.\n * An empty `profile_slug` is never sent, so this is how default rows are\n * selected. */\n is_default?: boolean\n menu_slug?: string\n}\n\nexport interface CreateAppConfigurationRequest {\n slug: string\n module_slug?: string\n app_slug: string\n profile_slug?: string\n home?: AppHome | null\n menu_slug?: string\n default_agent_key?: string\n agent_keys?: string[]\n record_pages?: Record<string, string>\n}\n\n/**\n * Partial update. `home` is tri-state: absent = unchanged, `null` = clear,\n * object = set. The (app_slug, profile_slug) binding is immutable.\n */\nexport interface UpdateAppConfigurationRequest {\n module_slug?: string\n home?: AppHome | null\n menu_slug?: string\n default_agent_key?: string\n agent_keys?: string[]\n record_pages?: Record<string, string>\n}\n\n// ============================================================================\n// App Types\n// ============================================================================\n\n/**\n * App definition. Apps group menu configurations and other org-scoped\n * metadata under a stable slug. Slug is unique per org (composite key\n * `(org_id, slug)`).\n */\nexport interface App extends AuditFields {\n slug: string\n org_id: string\n module_slug: string\n name: string\n description: string\n icon_slug: string\n}\n\nexport const AppSchema = AuditFieldsSchema.extend({\n slug: z.string(),\n org_id: z.string(),\n module_slug: z.string(),\n name: z.string(),\n description: z.string(),\n icon_slug: z.string(),\n})\n\n/**\n * Options for listing apps.\n */\nexport interface ListAppsOptions extends MetaListOptions {\n slug?: string\n name?: string\n module_slug?: string\n icon_slug?: string\n}\n\n/**\n * Request to create an app.\n */\nexport interface CreateAppRequest {\n slug: string\n module_slug?: string\n name: string\n icon_slug: string\n description?: string\n}\n\n/**\n * Request to update an app. Slug and org_id are immutable.\n */\nexport interface UpdateAppRequest {\n name?: string\n module_slug?: string\n description?: string\n icon_slug?: string\n}\n\n// ============================================================================\n// DesignReference Types\n// ============================================================================\n\n/**\n * A stored DESIGN.md document — a named design reference an org authors and that\n * design agents read as the source of truth for a surface. `name` + `description`\n * are the selector (\"which reference, and when to use it\").\n *\n * `content` (the markdown body) is NOT returned by list/get — fetch it via\n * {@link DesignReferenceService.getContent} and write it via `setContent`.\n */\nexport interface DesignReference extends AuditFields {\n id: string\n org_id: string\n slug: string\n name: string\n description: string\n /** The DESIGN.md body. Only present on the dedicated content endpoint; undefined on list/get. */\n content?: string\n}\n\nexport const DesignReferenceSchema = AuditFieldsSchema.extend({\n id: z.string(),\n slug: z.string(),\n name: z.string(),\n description: z.string(),\n content: z.string().optional(),\n})\n\n/**\n * Options for listing design references.\n */\nexport interface ListDesignReferencesOptions extends MetaListOptions {\n id?: string\n slug?: string\n name?: string\n description?: string\n}\n\n/**\n * Request to create a design reference. `content` optionally seeds the body.\n */\nexport interface CreateDesignReferenceRequest {\n slug: string\n name: string\n description?: string\n content?: string\n}\n\n/**\n * Request to update a design reference's metadata. Content is edited via the\n * dedicated content endpoint, not here.\n */\nexport interface UpdateDesignReferenceRequest {\n slug?: string\n name?: string\n description?: string\n}\n\n/**\n * The markdown body, from GET/PUT /design-references/:id/content.\n */\nexport interface DesignReferenceContent {\n content: string\n}\n\n/* -------------------------------------------------------------------------\n Default-value sentinel\n ------------------------------------------------------------------------- */\n\n/**\n * The one non-literal `default_value`: \"whoever is writing the record\".\n * Meaningful only on `user` and `principal` attributes, where data-service\n * resolves it to the caller's `{ type, id }` at write time — an owner field\n * granting `share`, an `assignee`, a `requested_by` fill themselves without a\n * hook. An object rather than a bare string because a bare string IS a valid\n * user value (clients send bare ids). Mirrors `metamodel.CurrentUserDefault`.\n */\nexport const CURRENT_USER_DEFAULT = { type: 'current_user' } as const\nexport type CurrentUserDefault = { type: 'current_user' }\n\n/** True when a `default_value` is the current-user sentinel (and nothing else). */\nexport function isCurrentUserDefault(value: unknown): value is CurrentUserDefault {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false\n const keys = Object.keys(value)\n return keys.length === 1 && (value as { type?: unknown }).type === 'current_user'\n}\n\n/** Only the identity-valued attribute types can carry the sentinel. */\nexport function acceptsCurrentUserDefault(type: AttributeType): boolean {\n return type === 'user' || type === 'principal'\n}\n","import type { ProteosClient } from '../client.js'\nimport { type AppConfigurationService, AppConfigurationServiceImpl } from './app-configurations.js'\nimport { type AppService, AppServiceImpl } from './apps.js'\nimport { type ComponentService, ComponentServiceImpl } from './components.js'\nimport { type DesignReferenceService, DesignReferenceServiceImpl } from './design-references.js'\nimport { type EntityService, EntityServiceImpl } from './entities.js'\nimport { type ListViewService, ListViewServiceImpl } from './list-views.js'\nimport { type ListService, ListServiceImpl } from './lists.js'\nimport {\n type MenuConfigurationService,\n MenuConfigurationServiceImpl,\n} from './menu-configurations.js'\nimport { type ModuleService, ModuleServiceImpl } from './modules.js'\nimport { type PageService, PageServiceImpl } from './pages.js'\nimport { type VariableService, VariableServiceImpl } from './variables.js'\n\n/**\n * Client for the Proteos Metadata Service API.\n * Provides access to all metadata management services.\n *\n * @example\n * ```ts\n * import { ProteosClient, MetaClient } from 'proteos-sdk';\n *\n * const client = new ProteosClient({\n * baseUrl: 'https://api.proteos.ai',\n * token: 'your-api-token',\n * });\n *\n * const meta = new MetaClient(client);\n *\n * // Use services\n * const entities = await meta.entities.list().all();\n * const module = await meta.modules.get('my-module');\n * ```\n */\nexport class MetaClient {\n /**\n * Service for managing entity definitions.\n */\n readonly entities: EntityService\n\n /**\n * Service for managing WebAssembly modules.\n */\n readonly modules: ModuleService\n\n /**\n * Service for managing configuration and secret variables.\n */\n readonly variables: VariableService\n\n /**\n * Service for managing UI component definitions.\n */\n readonly components: ComponentService\n\n /**\n * Service for managing list configurations.\n */\n readonly lists: ListService\n\n /**\n * Service for managing list view configurations.\n */\n readonly listViews: ListViewService\n\n /**\n * Service for managing page configurations.\n */\n readonly pages: PageService\n\n /**\n * Service for managing menu configurations.\n */\n readonly menuConfigurations: MenuConfigurationService\n\n /**\n * Service for managing apps.\n */\n readonly apps: AppService\n\n /**\n * Service for managing app configurations — the typed (app × profile)\n * bindings: home, menu, agents, record pages.\n */\n readonly appConfigurations: AppConfigurationService\n\n /**\n * Service for managing design references (stored DESIGN.md documents).\n */\n readonly designReferences: DesignReferenceService\n\n /**\n * Creates a new MetaClient instance.\n *\n * @param client - The base ProteosClient to use for API requests\n */\n constructor(client: ProteosClient) {\n this.entities = new EntityServiceImpl(client)\n this.modules = new ModuleServiceImpl(client)\n this.variables = new VariableServiceImpl(client)\n this.components = new ComponentServiceImpl(client)\n this.lists = new ListServiceImpl(client)\n this.listViews = new ListViewServiceImpl(client)\n this.pages = new PageServiceImpl(client)\n this.menuConfigurations = new MenuConfigurationServiceImpl(client)\n this.apps = new AppServiceImpl(client)\n this.appConfigurations = new AppConfigurationServiceImpl(client)\n this.designReferences = new DesignReferenceServiceImpl(client)\n }\n}\n\nexport type { AppConfigurationService } from './app-configurations.js'\nexport type { AppService } from './apps.js'\nexport type { ComponentService } from './components.js'\nexport * from './currency/index.js'\nexport type { DesignReferenceService } from './design-references.js'\n// Re-export service interfaces\nexport type { EntityService } from './entities.js'\n// Re-export the layout module (PageLayout types + Zod schemas + control registry)\nexport * from './layout/index.js'\nexport type { ListViewService } from './list-views.js'\nexport type { ListService } from './lists.js'\nexport type { MenuConfigurationService } from './menu-configurations.js'\nexport type { ModuleService } from './modules.js'\nexport type { PageService } from './pages.js'\n// Re-export types\nexport type {\n // App types\n App,\n // AppConfiguration types\n AppConfiguration,\n AppHome,\n AppHomeType,\n ArrayAttributeMeta,\n Attribute,\n AttributeAccessRule,\n AttributeMeta,\n AttributeRestrictions,\n AttributeType,\n Column,\n ComparisonOperator,\n // Component types\n Component,\n CreateAppConfigurationRequest,\n CreateAppRequest,\n CreateComponentRequest,\n CreateDesignReferenceRequest,\n CreateEntityRequest,\n CreateListRequest,\n CreateListViewRequest,\n CreateMenuConfigurationRequest,\n CreatePageRequest,\n CreateVariableRequest,\n // Currency attribute meta + value\n CurrencyAttributeMeta,\n CurrencyValue,\n CurrentUserDefault,\n DatetimeAttributeMeta,\n DatetimeFormat,\n DeployModuleRequest,\n // DesignReference types\n DesignReference,\n DesignReferenceContent,\n // Entity types\n Entity,\n EntityWithSchema,\n EnumAttributeMeta,\n EnumValue,\n // File attribute meta\n FileAttributeMeta,\n FilterElement,\n FilterGroup,\n // List types\n List,\n ListAppConfigurationsOptions,\n ListAppsOptions,\n ListComponentsOptions,\n ListDesignReferencesOptions,\n ListEntitiesOptions,\n ListListsOptions,\n ListListViewsOptions,\n ListMenuConfigurationsOptions,\n ListModulesOptions,\n ListPagesOptions,\n ListVariablesOptions,\n // ListView types\n ListView,\n LogicalOperator,\n // MenuConfiguration types\n MenuConfiguration,\n MenuItem,\n // Shared types\n MetaListOptions,\n // Module types\n Module,\n ModuleStatus,\n NumberAttributeMeta,\n ObjectAttributeMeta,\n OnDeleteAction,\n // Page types\n Page,\n PageAction,\n PageActionKind,\n PageType,\n // User attribute meta\n PrincipalAttributeMeta,\n PrincipalRef,\n PrincipalType,\n PublicAccessOperation,\n PublicPageComponent,\n PublicPageResponse,\n // Relation attribute meta\n RelationAttributeMeta,\n SortConfig,\n SortDirection,\n StringAttributeMeta,\n StringFormat,\n UpdateAppConfigurationRequest,\n UpdateAppRequest,\n UpdateComponentRequest,\n UpdateDesignReferenceRequest,\n UpdateEntityRequest,\n UpdateListRequest,\n UpdateListViewRequest,\n UpdateMenuConfigurationRequest,\n UpdatePageRequest,\n UpdateVariableRequest,\n UserAttributeMeta,\n // Variable types\n Variable,\n} from './types.js'\n// Re-export value-level constants\n// Re-export Zod schemas\nexport {\n AppConfigurationSchema,\n AppHomeSchema,\n AppSchema,\n AttributeSchema,\n acceptsCurrentUserDefault,\n ColumnSchema,\n ComponentSchema,\n CURRENT_USER_DEFAULT,\n CurrencyAttributeMetaSchema,\n DesignReferenceSchema,\n EntitySchema,\n EntityWithSchemaSchema,\n FileAttributeMetaSchema,\n FilterElementSchema,\n FilterGroupSchema,\n isCurrentUserDefault,\n isPlatformAttributeName,\n ListSchema,\n ListViewSchema,\n MenuConfigurationSchema,\n MenuItemSchema,\n MenuItemType,\n ModuleSchema,\n OnDeleteActionSchema,\n PageActionSchema,\n PageSchema,\n PLATFORM_ATTRIBUTE_NAMES,\n parseCurrencyMeta,\n parseFileMeta,\n parsePrincipalMeta,\n parseRelationMeta,\n parseUserMeta,\n platformAttributes,\n RelationAttributeMetaSchema,\n SortConfigSchema,\n UserAttributeMetaSchema,\n VariableSchema,\n} from './types.js'\nexport type { VariableService } from './variables.js'\n"]}
|