@stndrds/schema 1.0.0-alpha.330 → 1.0.0-alpha.332
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/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{object-BQuWeYKA.js → object-DGu0m2Y1.js} +1 -1
- package/dist/{object-tz3P8Pgh.mjs → object-DSRy1coV.mjs} +1 -1
- package/dist/{phone-DHUJN7SI.mjs → phone-BawtTYVi.mjs} +1 -1
- package/dist/{phone-C0QEfySq.js → phone-DVaELsa3.js} +1 -1
- package/dist/validation/all.js +1 -1
- package/dist/validation/all.mjs +1 -1
- package/dist/validation/complex/phone.js +1 -1
- package/dist/validation/complex/phone.mjs +1 -1
- package/dist/validation/object/index.js +1 -1
- package/dist/validation/object/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config-BQJJHopR.js"),t=require("./view-config.schema-to6p1m8L.js"),n=require("./exceptions.js"),r=require("./utils-gY3d9Dwp.js"),i=require("./object-BQuWeYKA.js"),a=require("./text-A9AJ1wUO.js"),o=require("./phone-C0QEfySq.js"),s=require("./core-397tQy5q.js"),c=require("./validation/primitives/checkbox.js"),l=require("./validation/primitives/date.js"),u=require("./validation/primitives/number.js");let d=require("@stndrds/constants"),f=require("zod");const p=[`fyi`,`task`,`question`,`handoff`,`system`],m=[`low`,`normal`,`high`,`urgent`],h=[`public`,`internal`,`sensitive`],g=[`unread`,`read`,`archived`,`snoozed`],_=[`none`,`pending`,`processing`,`completed`,`dismissed`,`expired`,`failed`],v=`agent.session.waiting_human`,y=`agent.task.assigned`,b=`agent.question.requested`,x=[v,y,b],S=[`name`,`type`],ee=[`required`,`hidden`,`archived`,`deprecated`,`defaultValue`,`config`,`order`,`unique`],C=[`label`,`description`,`placeholder`,`icon`],w=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`];function relationTargetsOf(e){return e.type!==`relation`||!Array.isArray(e.targets)?[]:e.targets.map(e=>e.object).filter(e=>e!==`*`)}function isUniversalRelation(e){return e.targets.length===1&&e.targets[0].object===`*`}function isBilateralRelation(e){return e.bilateral!==void 0}function inferInverseCardinality(e){return`many`}function isAttributeSortable(e){return t.K(e)}const te=[`record`,`object`,`attribute`,`view`,`user`,`role`,`settings`,`file`,`agent`,`schema_source`],ne=`record.created,record.updated,record.deleted,record.restored,record.purged,object.created,object.updated,object.deleted,attribute.created,attribute.updated,attribute.deleted,view.created,view.updated,view.deleted,schema_source.applied,schema_source.removed,user.created,user.invited,user.updated,user.deleted,user.login,user.logout,role.created,role.updated,role.deleted,role.assigned,role.revoked,settings.updated,file.uploaded,file.updated,file.deleted`.split(`,`);function isTerminalState(e){return e.phase===`terminal`}function sessionStateToLegacyStatus(e){switch(e.phase){case`running`:return`active`;case`queued`:return`idle`;case`parked`:if(e.parkedOn===void 0)throw new n.SchemaError(`parked state without parkedOn`,n.SchemaErrorCode.INVARIANT_VIOLATION);return e.parkedOn===`agents`?`waiting_agents`:`waiting_human`;case`terminal`:if(e.outcome===void 0)throw new n.SchemaError(`terminal state without outcome`,n.SchemaErrorCode.INVARIANT_VIOLATION);return e.outcome}}function legacyStatusToSessionState(e){switch(e){case`active`:return{phase:`running`};case`idle`:return{phase:`queued`};case`waiting_human`:return{phase:`parked`,parkedOn:`human`,humanRequestIds:[]};case`waiting_agents`:return{phase:`parked`,parkedOn:`agents`};default:return{phase:`terminal`,outcome:e}}}const re=[`completed`,`failed`,`cancelled`,`timeout`,`expired`];function isTerminalSessionStatus(e){return re.includes(e)}const ie=[`idle`,`completed`,`waiting_human`,`waiting_agents`,`cancelled`,`failed`,`timeout`];function isClaimableSessionStatus(e){return ie.includes(e)}const ae=Object.freeze({mutation:`ask`,destructive:`ask`,outward:`ask`}),oe=[`active`,`completed`,`abandoned`],se=[`openai`,`anthropic`,`google`,`spacexai`,`deepseek`,`moonshotai`,`alibaba`,`mistral`,`minimax`,`meta`,`zai`],ce=[`standard`,`fast`],le=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`];function agentDisplayName(e){return e.label?.trim()||e.name}const ue=[`approval-requested`,`approval-responded`,`approval-dispatched`],de=[`streaming`,`running`,`pending`,...ue];function isOpenToolPartState(e){return de.includes(e)}function isToolApprovalState(e){return ue.includes(e)}const fe=[`CREDITS_EXHAUSTED`];function isSystemPartCode(e){return typeof e==`string`&&fe.includes(e)}function compareAgentSessionMessages(e,t){let n=e.createdAt.getTime()-t.createdAt.getTime();return n===0?e.id.localeCompare(t.id):n}function orderAgentSessionMessages(e){return[...e].sort(compareAgentSessionMessages)}const pe=[`pending`,`in_progress`,`completed`,`blocked`],me=`__stndrdsNativeUiPartIds`;function invalidNativePartIds(){throw new n.ValidationError(`Native agent UI part IDs metadata is invalid`,[])}function isPlainRecord$1(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function nativeAgentUIPartIdMetadataKey(e,t){if(e.type===`text`||e.type===`reasoning`)return`${e.type}:${t}`;if(e.type===`tool`)return`tool:${e.toolCallId}`}function parseNativeAgentUIPartIdsMetadata(e){let t=e.metadata?.[me];isPlainRecord$1(t)||invalidNativePartIds(),(Object.keys(t).length!==2||t.schemaVersion!==1||!isPlainRecord$1(t.partIds))&&invalidNativePartIds();let n=new Map;for(let[t,r]of e.parts.entries()){let e=nativeAgentUIPartIdMetadataKey(r,t);if(!e||n.has(e)){e&&invalidNativePartIds();continue}n.set(e,r)}let r=Object.entries(t.partIds);r.length!==n.size&&invalidNativePartIds();let i=new Map,a={};for(let[e,t]of r){let r=n.get(e);r&&typeof t==`string`&&t.length>0||invalidNativePartIds();let o=i.get(t);o&&(r.type===`tool`||o!==r.type)&&invalidNativePartIds(),r.type===`tool`&&t!==r.toolCallId&&invalidNativePartIds(),i.set(t,r.type),a[e]=t}return a}const he={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2},ge=[`web`,`presentation`,`document`,`spreadsheet`,`image`,`code`,`other`],_e=[`ephemeral`,`conversation`,`persistent`],ve=[`source`,`preview`,`entrypoint`,`asset`];function getErrorMessage(e){return e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`?`message`in e&&typeof e.message==`string`?e.message:JSON.stringify(e):String(e)}function isFormDefinition(e){return typeof e==`object`&&!!e&&`slots`in e&&`steps`in e&&`name`in e&&typeof e.name==`string`&&Array.isArray(e.slots)&&Array.isArray(e.steps)}const ye=[`relation`,`multiRelation`,`formula`,`rollup`,`document`,`richtext`,`user`];function isFormSlotFieldRef(e){return e.type===`slot`}function isFormFreeFieldRef(e){return e.type===`free`}function resolveFieldRequired(e){return e.fieldRequired===void 0?e.slotMode===`create`&&e.attributeRequired===!0:e.fieldRequired}function getSlotFieldTargets(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}function formFieldKey(e){return isFormSlotFieldRef(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}function formFieldFlatKey(e){return isFormSlotFieldRef(e)?e.attribute:e.attribute.name}function readFormFieldValue(e,t){return e[formFieldKey(t)]??e[formFieldFlatKey(t)]}function isFormFieldsRow(e){return e.type===`fields`}function isFormHeadingRow(e){return e.type===`heading`}function isFormSeparatorRow(e){return e.type===`separator`}function isFormTextRow(e){return e.type===`text`}var NoopGeocodingAdapter=class{async autocomplete(){return await Promise.resolve([])}async reverse(){return await Promise.resolve(null)}async geocode(){return await Promise.resolve(null)}};const T=[`read`,`create`,`update`,`delete`,`manage`];function actionsToAccessLevel(e){return e.length===0?`none`:e.length===1&&e[0]===`read`?`read-only`:e.length===T.length&&T.every(t=>e.includes(t))?`full`:`custom`}function accessLevelToActions(e){switch(e){case`full`:return[...T];case`read-only`:return[`read`];case`none`:return[]}}function resolvePropertyDefinitions(e){let t=e.properties;if(!t)return[];if(Array.isArray(t))return t;let n=t;return Array.isArray(n.definitions)?n.definitions:[]}function hasOptions(e){return e.type===`select`||e.type===`status`||e.type===`multiselect`}const be=`Notetaker`,xe={systemPrompt:null,meetingRecordingPolicy:`none`,meetingBotDisplayName:be},Se=[`active`,`suspended`],Ce=[`architect`,`manual`,`auto`],we=[`square`,`landscape`,`portrait`],Te=[`none`,`estimated`,`exact`];function parseCountMode(e){if(typeof e==`string`&&Te.includes(e))return e;throw new n.ValidationError(`countMode must be one of: ${Te.join(`, `)} (received: ${String(e)})`,[])}function parseOptionalCountMode(e){return e===void 0?void 0:parseCountMode(e)}const Ee=[`storage.bytes`,`members.seats`,`data.live_records`];function isEmptyObject(e){return e==null||typeof e==`object`&&Object.keys(e).length===0}function isNotEmpty(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0}function toUndefinedIfEmpty(e){return isNotEmpty(e)?e:void 0}function computeByteMagnitude(e){if(e<=0)return{value:0,unitIndex:0};let t=1e3,n=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return{value:Number.parseFloat((e/t**n).toFixed(1)),unitIndex:n}}const De=[`B`,`KB`,`MB`,`GB`,`TB`];function formatByteSize(e){let{value:t,unitIndex:n}=computeByteMagnitude(e);return`${t} ${De[n]}`}const Oe={ATTACHMENTS:`attachments`};function isDocumentAttribute(e){return e.type===`document`}function matchesAccepts(e,t){if(!t||t.length===0)return!0;let n=e.name.toLowerCase();return t.some(t=>t.endsWith(`/*`)?e.mimeType.startsWith(t.slice(0,-1)):t.startsWith(`.`)?n.endsWith(t.toLowerCase()):e.mimeType===t)}const ke=Object.freeze([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`,`multiselect`,`location`]);function buildPropertySchema(e){let t=[];for(let n of e){let e=n.build();if(!ke.includes(e.type))throw Error(`Property type "${e.type}" is not supported in .qualifyWith()`);t.push(e)}return{definitions:t}}function parseQualifiedAttribute(e){let t=e.indexOf(`__`);return t<=0||t+2>=e.length?{kind:`scalar`,attribute:e}:{kind:`qualified`,root:e.slice(0,t),property:e.slice(t+2)}}function buildQualifiedAttribute(e,t){return`${e}__${t}`}function isDateRangeValue(e){return typeof e==`object`&&!!e&&typeof e.start==`string`}function normalizeDateValue(e,t){return i.p(e)?null:isDateRangeValue(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e==`string`?t.endDate?{start:e,end:null}:e:null}function dateValueStart(e){return typeof e==`string`&&e!==``?e:isDateRangeValue(e)&&e.start!==``?e.start:null}function formatText(e){return String(e)}function formatCheckbox(e){return e?`Yes`:`No`}function formatNumber(e,t){if(typeof e!=`number`)return String(e);if(t.renderAs===`rating`)return`${e}/${t.max??5}`;let n=t.decimals;return t.unit===`integer`?e.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}):t.unit===`percentage`?(e/100).toLocaleString(void 0,{style:`percent`,minimumFractionDigits:n,maximumFractionDigits:n}):e.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n})}function formatCurrency(e,t){if(typeof e!=`object`||!e)return String(e);let n=e;return`value`in n&&`code`in n?`${n.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})} ${n.code}`:String(e)}function formatDate(e){if(isDateRangeValue(e)){let t=formatDate(e.start);return e.end?`${t} → ${formatDate(e.end)}`:t}if(e instanceof Date)return e.toISOString().split(`T`)[0];if(typeof e==`string`){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toISOString().split(`T`)[0]}return String(e)}function formatPhone(e){if(typeof e!=`object`||!e)return String(e);let t=e;return`phoneNumber`in t?t.phoneNumber?t.countryCode?o.n(t):t.phoneNumber:``:String(e)}function formatLocationValue(e,t=`full`){if(typeof e!=`object`||!e)return``;let n=e,r=[];switch(t){case`country`:n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;case`state`:n.state&&r.push(n.state),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;case`city`:n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;case`coordinates`:n.latitude!==void 0&&n.longitude!==void 0&&r.push(`${n.latitude}, ${n.longitude}`);break;case`address`:n.address&&r.push(n.address),n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;default:n.address&&r.push(n.address),n.address2&&r.push(n.address2),n.city&&r.push(n.city),n.state&&r.push(n.state),n.postalCode&&r.push(n.postalCode),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country))}return r.join(`, `)}function formatLocation(e,t){return typeof e!=`object`||!e?String(e):formatLocationValue(e,t.granularity??`full`)||`—`}function formatSelect(e,t){return typeof e==`string`?t.options?.find(t=>t.value===e)?.label??String(e):String(e)}function formatMultiselect(e,t){return Array.isArray(e)?t.options?e.map(e=>t.options.find(t=>t.value===e)?.label).filter(Boolean).join(`, `):e.join(`, `):String(e)}function formatAttributeValue(e,t){if(i.p(e))return`—`;switch(t.type){case`text`:return formatText(e);case`checkbox`:return formatCheckbox(e);case`number`:return formatNumber(e,t);case`currency`:return formatCurrency(e,t);case`date`:return formatDate(e);case`phone`:return formatPhone(e);case`location`:return formatLocation(e,t);case`select`:case`status`:return formatSelect(e,t);case`multiselect`:return formatMultiselect(e,t);case`user`:case`relation`:return Array.isArray(e)?e.join(`, `):String(e);default:return Array.isArray(e)?e.join(`, `):String(e)}}const Ae=[`UPPER`,`LOWER`,`capitalize`,`trim`],je=[`prefix`,`suffix`,`wrap`,`default`],E=[...Ae,...je],D=f.z.string().min(1,`labelExpression cannot be empty`).refine(e=>isLabelExpression(e),{message:`labelExpression must contain at least one {{ attribute }} interpolation`}).refine(e=>!/\{\{\s*\}\}/.test(e),{message:`labelExpression contains empty {{ }} interpolation`}).refine(e=>{let t=/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g,n;for(;(n=t.exec(e))!==null;){let e=n[1];if(!E.includes(e))return!1}return!0},{message:`Invalid pipe name. Valid pipes: ${E.join(`, `)}`});function validateLabelExpression(e){let t=D.safeParse(e);return t.success?{success:!0,attributes:extractAttributeNames(e)}:{success:!1,error:t.error.issues[0]?.message??`Invalid labelExpression`}}function applyPipe(e,t){let{name:n,args:r}=parsePipeExpression(t);switch(n){case`UPPER`:return e.toUpperCase();case`LOWER`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|\s)\S/g,e=>e.toUpperCase());case`trim`:return e.trim();case`prefix`:return e?`${r[0]??``}${e}`:``;case`suffix`:return e?`${e}${r[0]??``}`:``;case`wrap`:return e?`${r[0]??``}${e}${r[1]??``}`:``;case`default`:return e||r[0]||``;default:return e}}function applyPipes(e,t){let n=e;for(let e of t)n=applyPipe(n,e);return n}function getValue(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}const Me=`(Untitled)`;function parsePipeExpression(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return{name:e,args:[]};let n=t[1],r=t[2];if(!r)return{name:n,args:[]};let i=[],a=/["']([^"']*?)["']/g,o;for(;(o=a.exec(r))!==null;)i.push(o[1]);return{name:n,args:i}}function*templateBlocks(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return;let r=e.indexOf(`}`,n+2);if(r<0)return;if(e[r+1]!==`}`){t=r+1;continue}t=r+2;let i=e.slice(n+2,r);i.length>0&&(yield{start:n,end:t,expr:i})}}function resolveLabelBlock(e,t){let n=e.split(`||`).map(e=>e.trim()),r=n[n.length-1].split(`|`).map(e=>e.trim());n[n.length-1]=r[0];let i=r.slice(1).filter(Boolean),a=n.filter(Boolean),o=``;for(let e of a){let n=toText(getValue(t,e));if(n!==``){o=n;break}}return applyPipes(o,i)}function renderLabelExpression(e,t,n=Me){let r=[],i=0;for(let n of templateBlocks(e))r.push(e.slice(i,n.start),resolveLabelBlock(n.expr,t)),i=n.end;return r.push(e.slice(i)),r.join(``).trim()||n}function toText(e){if(e==null||typeof e==`function`)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return e.map(toText).filter(Boolean).join(`,`);let t=e.toString;return typeof t==`function`&&t!==Object.prototype.toString?String(e):``}function isLabelExpression(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return!1;let r=e.indexOf(`}}`,n+2);if(r<0)return!1;if(e.slice(n+2,r).trim().length>0)return!0;t=r+2}return!1}function extractAttributeNames(e){let t=[];for(let n of templateBlocks(e)){let e=n.expr.trim();if(!e)continue;let r=e.split(`||`).map(e=>e.trim()),i=r[r.length-1];r[r.length-1]=i.split(`|`)[0].trim();for(let e of r){if(!e)continue;let n=e.split(`.`)[0];n&&!t.includes(n)&&t.push(n)}}return t}const Ne=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function getSingleAttributeFromExpression(e){let t=e.trim().match(Ne);return t?t[1]:null}function getEditableLabelAttribute(e,n){let r=getSingleAttributeFromExpression(e);if(r===null)return null;let i=n.find(e=>e.name===r);return!i||i.type!==`text`||t.B(i).authoring.readOnly?null:i}const Pe=/\{\{\s*props\./;function applyRelationProps(e,t,n){if(!Pe.test(e))return e;let r={},i=new Map(n?.map(e=>[e.name,e]));if(t)for(let[e,n]of Object.entries(t)){if(n==null)continue;let t=i.get(e);if(t){let i=formatAttributeValue(n,t);r[e]=i===`—`?``:i}else r[e]=n}return renderLabelExpression(e,{props:r},``).replace(/\(\s*\)/g,``).replace(/\[\s*\]/g,``).replace(/\s*[-—|:]\s*$/g,``).replace(/\s{2,}/g,` `).trim()}function relationPropertyDefs(e){if(e?.type===`relation`)return e.properties?.definitions}function qualifiedPropertyDefs(e){if(e?.type===`relation`||e?.type===`document`)return e.properties?.definitions}function extractValueRefs(e){if(i.p(e))return[];if(typeof e==`string`)return[{id:e}];if(Array.isArray(e))return e.flatMap(e=>extractValueRefs(e));if(typeof e==`object`&&`id`in e){let t=e;if(typeof t.id==`string`)return[{id:t.id,props:t.props}]}return[]}function getUserDisplayName(e){let t=[e.firstName,e.lastName].map(e=>e?.trim()).filter(Boolean).join(` `);return t===``?e.email?.split(`@`)[0]??``:t}const Fe=/\p{L}|\p{N}/u;function deriveInitials(e,t){let n=e?.trim()??``;if(n===``)return t;let r=n.split(/\s+/),i=(r.length===1?n.split(`@`)[0].split(/[._-]/):r).map(e=>{let t=e.match(Fe)?.[0];return t===void 0?``:[...t.toUpperCase()][0]??``}).filter(Boolean).slice(0,2).join(``);return i===``?t:i}const Ie=`__creatorRootActorId`;function getRecordCreatorPrincipalId(e){let t=e.metadata?.[Ie];return typeof t==`string`&&t.length>0?t:e.createdBy}function includesAction(e,t){return e?.includes(`*`)===!0||e?.includes(t)===!0}function buildPermissionFlags(e){return{canRead:includesAction(e,`read`),canCreate:includesAction(e,`create`),canUpdate:includesAction(e,`update`),canDelete:includesAction(e,`delete`),canManage:includesAction(e,`manage`)}}const Le=new Set([`id`,`name`,`label`,`type`,`required`,`system`,`unique`,`order`]),O={PEOPLE:`people`,WORKSPACE:`workspace`,ARCHITECT:`architect`,FEATURE_FLAGS:`feature-flags`,FILES:`files`,VIEWS:`views`,FORMS:`forms`,DOCUMENTS:`documents`,AUDIT:`audit`,API_KEYS:`api-keys`,CONNECTORS:`connectors`,ENV_VARS:`env-vars`,SESSION:`session`},Re=[O.PEOPLE,O.WORKSPACE,O.ARCHITECT,O.FEATURE_FLAGS,O.FILES,O.VIEWS,O.FORMS,O.DOCUMENTS,O.AUDIT,O.API_KEYS,O.CONNECTORS,O.ENV_VARS,O.SESSION],ze={people:`People`,workspace:`Workspace`,architect:`Architect`,"feature-flags":`Feature flags`,files:`Files`,views:`Views`,forms:`Forms`,documents:`Documents`,audit:`Audit`,"api-keys":`API keys`,connectors:`Connected accounts`,"env-vars":`Environment variables`,session:`Agent sessions`},Be={OWNER:`owner`,MEMBER:`member`,AGENT_DEFAULT:`agent_default`,REFLEX_DEFAULT:`reflex_default`},Ve={owner:`Owner`,member:`Member`,agent_default:`Agent Default`,reflex_default:`Reflex Default`},He={owner:`Full access to all platform features and data`,member:`Can view, create, edit and delete business data`,agent_default:`Default role for AI agents — CRUD on records plus documents and files`,reflex_default:`Default role for reflexes — no data access; each reflex is granted exactly what its rehearsal showed it uses`},k=[`read`,`create`,`update`,`delete`,`manage`],Ue=[`read`,`create`,`update`,`delete`],We=[`read`,`create`,`update`,`delete`],Ge={owner:{system:[{target:`*`,actions:k}],object:[{target:`*`,actions:k}]},member:{system:[{target:`people`,actions:[`read`]},{target:`workspace`,actions:[`read`]},{target:`connectors`,actions:Ue},{target:`files`,actions:We},{target:`documents`,actions:We}],object:[{target:`*`,actions:k}]},agent_default:{system:[{target:`documents`,actions:[`read`,`create`,`update`]},{target:`files`,actions:[`read`,`create`,`update`]},{target:`env-vars`,actions:[`read`]},{target:`session`,actions:[`observe`]}],object:[{target:`*`,actions:[`read`,`create`,`update`,`delete`]}]},reflex_default:{system:[],object:[]}};function isDefaultRole(e){return Object.values(Be).includes(e)}const A={maxConcurrentRuns:3,retryPolicy:{maxRetries:3,backoffMs:1e3,backoffMultiplier:2},timeoutMs:3e5};var AgentBuilder=class{constructor(e){if(!e.name||e.name.trim().length===0)throw new n.ValidationError(`Agent name is required`,[]);this.bp={name:e.name,system:!0,visibility:`workspace`,triggers:[]}}description(e){return this.bp.description=e,this}label(e){return this.bp.label=e,this}icon(e){return this.bp.icon=e,this}systemPrompt(e){return this.bp.systemPrompt=e,this}model(e,t,n){return this.bp.model={provider:e,model:t,...n},this}tools(e){return this.bp.tools=[...e],this}schedule(e){return this.bp.schedule={...e,enabled:e.enabled??!0},this}config(e){let t=this.bp.config??A,n=e.inference===void 0?t.inference:{...t.inference,...e.inference};return this.bp.config={...t,...e,...n===void 0?{}:{inference:n}},this}delegation(e){return Object.assign(this.bp,e),this}mcpServers(e){return this.bp.mcpServers=Array.isArray(e)?[...e]:e,this}approval(e){return this.bp.approval={...ae,...this.bp.approval,...e},this}visibility(e){return this.bp.visibility=e,this}requiresPermission(e,t){return this.bp.requiredPermission={resource:e,action:t},this}trigger(e,t,n){return this.bp.triggers.push({name:e,eventType:t,...n,enabled:n?.enabled??!0}),this}runtime(){return this.bp.system=!1,this}build(){if(!this.bp.systemPrompt)throw new n.ValidationError(`Agent "${this.bp.name}": systemPrompt is required`,[]);if(!this.bp.model)throw new n.ValidationError(`Agent "${this.bp.name}": model is required`,[]);if(this.bp.system&&this.bp.visibility===`private`)throw new n.ValidationError(`Agent "${this.bp.name}": system agents must use workspace visibility`,[]);return e.T(this.bp.triggers,e=>e.name,e=>new n.ValidationError(`Agent "${this.bp.name}": duplicate trigger name "${e}"`,[])),{...this.bp,visibility:this.bp.visibility??`workspace`,config:this.bp.config??A,systemPrompt:this.bp.systemPrompt,model:this.bp.model}}};function agent(e){return new AgentBuilder(e)}const Ke=`@stndrds/schema`;function createStandardSchemaProps(e){return{version:1,vendor:Ke,validate:t=>{let n=e.safeParse(t);return n.success?{value:n.data}:{issues:n.error.issues.map(e=>({message:e.message,path:e.path}))}}}}function isStandardSchema(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`&&e[`~standard`].version===1}function asMutableArray(e){return e}var BaseAttributeBuilder=class{get"~standard"(){return createStandardSchemaProps(i.d(this.build()))}constructor(t,n,r){e.E(n),e.O(r),this.attr={name:n,label:r,type:t,required:!1,system:!0}}setRequired(e){this.attr.required=e}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=!1,this}hidden(){return this.attr.hidden=!0,this}placeholder(e){return this.attr.placeholder=e,this}description(e){return this.attr.description=e,this}icon(t){return e.D(t,`attribute "${this.attr.name}"`),this.attr.icon=t,this}order(e){return this.attr.order=e,this}defaultValue(e){return(`defaultValue`in this.attr||![`formula`,`rollup`].includes(this.attr.type))&&(this.attr.defaultValue=e),this}metadata(e){return this.attr.metadata=e,this}build(){return this.attr}},TextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`text`,e,t)}minLength(e){return this.attr.minLength=e,this}maxLength(e){return this.attr.maxLength=e,this}pattern(e){return this.attr.pattern=e,this.attr.format=void 0,this}multiline(e=!0){return this.attr.multiline=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}email(){return this.attr.format=`email`,this.attr.pattern=void 0,this}url(){return this.attr.format=`url`,this.attr.pattern=void 0,this}slug(){return this.attr.format=`slug`,this.attr.pattern=void 0,this}};function text(e){return new TextAttributeBuilder(e.name,e.label)}var RichtextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`richtext`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function richtext(e){return new RichtextAttributeBuilder(e.name,e.label)}var NumberAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`number`,e,t)}min(e){return this.attr.min=e,this}max(e){return this.attr.max=e,this}integer(){return this.attr.unit=`integer`,this.attr.decimals=0,this}decimal(e=2){return this.attr.unit=`decimal`,this.attr.decimals=e,this}percentage(){return this.attr.unit=`percentage`,this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function number(e){return new NumberAttributeBuilder(e.name,e.label)}var CheckboxAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`checkbox`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function checkbox(e){return new CheckboxAttributeBuilder(e.name,e.label)}var DateAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`date`,e,t)}format(e){return this.attr.dateFormat=e,this}minDate(e){return this.attr.minDate=e,this}maxDate(e){return this.attr.maxDate=e,this}endDate(){return this.attr.endDate=!0,this.asPhantomState()}includeTime(){return this.attr.includeTime=!0,this}timeFormat(e){return this.attr.timeFormat=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function date(e){return new DateAttributeBuilder(e.name,e.label)}var PhoneAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`phone`,e,t)}defaultCountry(e){return this.attr.defaultCountryCode=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function phone(e){return new PhoneAttributeBuilder(e.name,e.label)}var CurrencyAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`currency`,e,t)}defaultCurrency(e){return this.attr.defaultCurrency=e,this}allowedCurrencies(e){return this.attr.allowedCurrencies=e,this}allowNegative(e=!0){return this.attr.allowNegative=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function currency(e){return new CurrencyAttributeBuilder(e.name,e.label)}var StatusAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`status`,e,t)}options(t){let n=asMutableArray(t);return e.A(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.A(this.attr.name??`unknown`,n),this.attr.options.push(t),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function status(e){return new StatusAttributeBuilder(e.name,e.label)}var SelectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`select`,e,t)}options(t){let n=asMutableArray(t);return e.A(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.A(this.attr.name??`unknown`,n),this.attr.options.push(t),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function select(e){return new SelectAttributeBuilder(e.name,e.label)}var MultiselectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`multiselect`,e,t)}options(t){let n=asMutableArray(t);return e.A(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.A(this.attr.name??`unknown`,n),this.attr.options.push(t),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function multiselect(e){return new MultiselectAttributeBuilder(e.name,e.label)}var LocationAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`location`,e,t)}granularity(e){return this.attr.granularity=e,this}defaultCountry(e){return this.attr.defaultCountry=e,this}allowedCountries(e){return this.attr.allowedCountries=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function location(e){return new LocationAttributeBuilder(e.name,e.label)}var UserAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`user`,e,t),this.attr.types=[`user`,`agent`]}types(e){let t=[...new Set(e)];if(t.length===0)throw Error(`[AttributeBuilder] user.types must contain at least one type.`);return this.attr.types=t,this}multiple(){return this.attr.multiple=!0,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function user(e){return new UserAttributeBuilder(e.name,e.label)}var BaseRelationAttributeBuilder=class extends BaseAttributeBuilder{to(e,t){let n={object:e,...t};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:`*`}],this}qualifyWith(...e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.qualifyWith() must be called AFTER .to(). Example: relation({ name: "companies" }).to("companies").qualifyWith(...)`);return this.attr.properties=buildPropertySchema(e),this}bilateral(e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.bilateral() must be called AFTER .to(). Example: relation({ name: "company" }).to("companies").bilateral({ ... })`);if(t.length>1)throw Error(`Bilateral relations are not supported for polymorphic relations (multiple .to() targets).`);if(isUniversalRelation(this.attr))throw Error(`Bilateral relations are not supported for universal relations (.toAny()).`);let r=t[0]?.object;if(!r)throw new n.ValidationError(`Bilateral relation requires one target object`,[{path:[`bilateral`,`object`],message:`Bilateral relation requires one target object`}]);if(e.object&&e.object!==r){let t=`Bilateral inverse object ${e.object} must match relation target ${r}`;throw new n.ValidationError(t,[{path:[`bilateral`,`object`],message:t}])}return this.attr.bilateral={...e,object:r},this}},SingleRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t){super(`relation`,e,t),this.attr.cardinality=`one`,this.attr.targets=[]}many(){let e=new MultiRelationAttributeBuilder(this.attr.name,this.attr.label??``,{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===!1&&e.runtime(),this.attr.hidden&&e.hidden(),this.attr.placeholder&&e.placeholder(this.attr.placeholder),this.attr.description&&e.description(this.attr.description),this.attr.icon&&e.icon(this.attr.icon),this.attr.order!==void 0&&e.order(this.attr.order),this.attr.metadata&&e.metadata(this.attr.metadata),e}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}},MultiRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t,n){super(`relation`,e,t),this.attr.cardinality=`many`,this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(!0)}maxItems(e){return this.attr.maxItems=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function relation(e){return new SingleRelationAttributeBuilder(e.name,e.label)}var FormulaAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`formula`,e,t),this.attr.required=!1}expression(e){return this.attr.expression=e,this}returns(e){return this.attr.returnType=e,this}decimals(e){return this.attr.decimals=e,this}required(){throw Error(`Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function formula(e){return new FormulaAttributeBuilder(e.name,e.label)}var RollupAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`rollup`,e,t),this.attr.required=!1}from(e){return this.attr.relationAttribute=e,this}aggregate(e){return this.attr.targetAttribute=e,this}using(e){return this.attr.function=e,this}decimals(e){return this.attr.decimals=e,this}path(e){return this.attr.relationPath=e,this}targetType(e){return this.attr.targetAttributeType=e,this}targetOptions(e){return this.attr.targetAttributeOptions=e,this}targetCurrency(e){return this.attr.targetCurrencyCode=e,this}build(){let e=this.attr.function,t=this.attr.targetAttributeType;if(e===`original`&&t!==void 0&&t!==`select`&&t!==`status`&&t!==`multiselect`){let e=this.attr.relationAttribute??`relation`,r=this.attr.targetAttribute??`field`;throw new n.SchemaError(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${t}") was given. To surface a plain ${t} value from a related record, use a formula instead — e.g. formula({ name: "${this.attr.name}", label: "…" }).expression("${e}.${r}").`,n.SchemaErrorCode.VALIDATION_FAILED)}return super.build()}required(){throw Error(`Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function rollup(e){return new RollupAttributeBuilder(e.name,e.label)}var DocumentAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`document`,e,t)}accepts(e){return this.attr.accepts=e,this}maxFileSize(e){return this.attr.maxFileSize=e,this}qualifyWith(...e){return this.attr.properties=buildPropertySchema(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function document(e){return new DocumentAttributeBuilder(e.name,e.label)}function buildSlotFieldRef(e,t,n){let[r,...i]=Array.isArray(e)?e:[e];return{type:`slot`,slotId:r,additionalSlotIds:i.length>0?i:void 0,attribute:t,label:n?.label,required:n?.required,tooltip:n?.tooltip}}var FormRowBuilder=class{constructor(e,t,n){this._finalized=!1,this.stepBuilder=e,this.rowData={id:t,order:n,type:`fields`,fields:[]}}field(e,t,n){return this.rowData.fields.push(buildSlotFieldRef(e,t,n)),this}freeField(e,t){let n={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression};return this.rowData.fields.push(n),this}row(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).row(e)}heading(e,t){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).heading(e,t)}separator(){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).separator()}text(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).text(e)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData))}},FormStepBuilder=class{constructor(e,t,n){this.rowOrder=0,this.formBuilder=e,this.stepData={id:t,label:n,rows:[]}}description(e){return this.stepData.description=e,this}field(e,t,n){this.rowOrder++;let r=`row-${this.stepData.id}-${this.rowOrder}`,i=buildSlotFieldRef(e,t,n),a={id:r,order:this.rowOrder,type:`fields`,fields:[i]};return this.stepData.rows.push(a),this}freeField(e,t){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,r={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression},i={id:n,order:this.rowOrder,type:`fields`,fields:[r]};return this.stepData.rows.push(i),this}row(e){return this.rowOrder++,new FormRowBuilder(this,e,this.rowOrder)}heading(e,t){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`heading`,content:e,level:t};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let e={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`separator`};return this.stepData.rows.push(e),this}text(e){this.rowOrder++;let t={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`text`,content:e};return this.stepData.rows.push(t),this}step(e,t){return this.formBuilder._finalizeStep(this.stepData).step(e,t)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(e){return e.fields.length>0&&this.stepData.rows.push(e),this}_getData(){return this.stepData}},FormBuilder=class{constructor(e,t){this.data={slots:[],steps:[],status:`draft`,version:1},this.validateName(e),this.data.name=e,this.data.label=t}description(e){return this.data.description=e,this}icon(e){return this.data.icon=e,this}status(e){return this.data.status=e,this}metadata(e){return this.data.metadata=e,this}slot(e,t,n){if(this.data.slots.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate slot id: "${e}"`);let r={id:e,objectName:t,label:n.label,mode:n.mode??`create`,color:n.color,icon:n.icon};return this.data.slots.push(r),this}step(e,t){if(this.data.steps.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate step id: "${e}"`);return new FormStepBuilder(this,e,t)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.data}_finalizeStep(e){return this.data.steps.push(e),this}validateName(e){let t=f.z.string().min(1,`Form name cannot be empty`).max(63,`Form name is too long (max 63 characters)`).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:`Invalid form name format. Name must be in kebab-case: 'client-onboarding', 'contact-creation'`});try{t.parse(e)}catch(e){throw e instanceof f.z.ZodError?Error(`[FormBuilder] ${e.issues[0].message}`):e}}validateRequiredData(){if(this.data.slots.length===0)throw Error(`[FormBuilder] At least one slot is required. Use .slot() to add slots.`);if(this.data.steps.length===0)throw Error(`[FormBuilder] At least one step is required. Use .step() to add steps.`)}validateSlotReferences(){let e=new Map(this.data.slots.map(e=>[e.id,e.objectName]));for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(r.type!==`slot`)continue;let n=getSlotFieldTargets(r);for(let r of n)if(!e.has(r))throw Error(`[FormBuilder] Step "${t.id}" references unknown slot "${r}". Declare it with .slot("${r}", ...) first.`);let i=new Set(n.map(t=>e.get(t)));if(i.size>1)throw Error(`[FormBuilder] Step "${t.id}" field on attribute "${r.attribute}" targets slots of different objects (${[...i].join(`, `)}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let e=[...E,`join`];for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(!isFormFreeFieldRef(r)||!r.prefillExpression)continue;let n=r.prefillExpression,i=`prefillExpression on free field "${r.attribute.name}" in step "${t.id}"`;if(!isLabelExpression(n))throw Error(`[FormBuilder] ${i} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(n))throw Error(`[FormBuilder] ${i} contains empty {{ }} interpolation.`);for(let t of n.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g)){let n=t[1];if(!e.includes(n))throw Error(`[FormBuilder] ${i} uses invalid pipe "${n}". Valid pipes: ${e.join(`, `)}`)}}}validateFreeFields(){let e=new Set(ye);for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n)){for(let r of n.fields)if(isFormFreeFieldRef(r)){let n=r.attribute.type;if(e.has(n))throw Error(`[FormBuilder] Free field in step "${t.id}" uses forbidden attribute type "${n}". Forbidden types: ${ye.join(`, `)}`)}}}};function form(e,t){return new FormBuilder(e,t)}function resolveBuiltInTransform(e){return{text:`toString`,richtext:`toString`,number:`toNumber`,currency:`toNumber`,date:`toDate`,checkbox:`toBoolean`}[e]}var MigrationBuilder=class{constructor(e){this.operations=[],this.touchedAttributes=new Set,this.version=e}assertNotTouched(e,t){if(this.touchedAttributes.has(e))throw new n.ValidationError(`[MigrationBuilder] Conflicting operations on attribute "${e}": it was already modified earlier in this migration (attempted: ${t}).`,[])}renameAttribute(e,t){return this.assertNotTouched(e,`rename_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`rename_attribute`,from:e,to:t}),this}changeType(e,t,n,r){this.assertNotTouched(e,`change_type`),this.touchedAttributes.add(e);let i=r?.transform?resolveBuiltInTransform(n):void 0;return this.operations.push({type:`change_type`,name:e,from:t,to:n,transform:i}),this}removeAttribute(e){return this.assertNotTouched(e,`remove_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`remove_attribute`,name:e}),this}addAttribute(e){return this.assertNotTouched(e.name,`add_attribute`),this.touchedAttributes.add(e.name),this.operations.push({type:`add_attribute`,attribute:e}),this}updateConfig(e,t){return this.assertNotTouched(e,`update_config`),this.touchedAttributes.add(e),this.operations.push({type:`update_config`,name:e,from:{},to:t}),this}build(){return{version:this.version,operations:[...this.operations]}}};function validateObjectExpressions(e){let{name:t,labelExpression:r,embeddingExpression:i}=e;if(!r)throw new n.SchemaError(`Object "${t}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,n.SchemaErrorCode.VALIDATION_FAILED);let a=D.safeParse(r);if(!a.success){let e=a.error.issues[0]?.message??`Invalid labelExpression`;throw new n.SchemaError(`Invalid labelExpression for "${t}": ${e}`,n.SchemaErrorCode.VALIDATION_FAILED)}if(i!==void 0){let e=D.safeParse(i);if(!e.success){let r=e.error.issues[0]?.message??`Invalid embeddingExpression`;throw new n.SchemaError(`Invalid embeddingExpression for "${t}": ${r}`,n.SchemaErrorCode.VALIDATION_FAILED)}}}var ObjectBuilder=class{get"~standard"(){return createStandardSchemaProps(i.u(this.build()))}constructor(e){this._migrations=[],this._sealed=!1,this._toleratedAttributes=[],this.validateName(e.name),this.obj={name:e.name,label:e.label,attributes:[],system:!0},e.id&&(this.obj.id=e.id)}description(e){return this.obj.description=e,this}pluralLabel(e){return this._pluralLabel=e,this}icon(e){return this.obj.icon=e,this}runtime(){return this.obj.system=!1,this}sealed(){return this._sealed=!0,this}tolerate(e){return this._toleratedAttributes=[...this._toleratedAttributes,...e],this}attribute(e){return this.pushAttributes([e]),this}attributes(e){return this.pushAttributes(e),this}pushAttributes(t){let r=t.map(e=>`build`in e&&typeof e.build==`function`?e.build():e);e.T([...this.obj.attributes,...r],e=>e.name,e=>new n.DuplicateError(`attribute`,e,`Object "${this.obj.name}": duplicate attribute name "${e}"`)),this.obj.attributes.push(...r)}metadata(e){return this.obj.metadata={...this.obj.metadata,...e},this}order(e){return this.obj.metadata={...this.obj.metadata,order:e},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:!0},this}labelExpression(e){return this._labelExpression=e,this}embeddingExpression(e){return this._embeddingExpression=e,this}documentLayout(e){if(e.presets)for(let t of e.presets)validatePresetStructure(t.id,t.structure,1);return this.obj.documentLayout=e,this}migration(e,t){if(e<2)throw Error(`[ObjectBuilder] Migration version must be >= 2 (version 1 is implicit). Got: ${e}`);if(this._migrations.some(t=>t.version===e))throw Error(`[ObjectBuilder] Duplicate migration version: ${e}`);let n=new MigrationBuilder(e);return t(n),this._migrations.push(n.build()),this}build(){if(!this.obj.name)throw new n.ValidationError(`[ObjectBuilder] Missing required field: name`,[{path:[`name`],message:`name is required`}]);if(!this.obj.label)throw new n.ValidationError(`[ObjectBuilder] Missing required field: label`,[{path:[`label`],message:`label is required`}]);validateObjectExpressions({name:this.obj.name,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression});let e=[...this._migrations].sort((e,t)=>e.version-t.version);for(let t=0;t<e.length;t++){let n=t+2;if(e[t].version!==n)throw Error(`[ObjectBuilder] Migration versions must be sequential starting at 2. Expected version ${n}, got ${e[t].version}.`)}let t=e.length>0?e[e.length-1].version:1;return{...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,schema_version:t,migrations:e,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(t){t!==void 0&&e.k(t)}};function object(t){if(e.z(t.name))throw new n.ReservedObjectNameError(t.name,`builder`);return new ObjectBuilder(t)}function validatePresetStructure(e,t,r){let fail=(t,r)=>{throw new n.ValidationError(t,[{path:[`documentLayout`,`presets`,e],message:r}])};r>5&&fail(`Preset structure exceeds max depth of 5`,`Preset structure too deep`);let i=new Set;for(let n of t){let t=n.title.trim();t.length===0&&fail(`Folder preset node title is required`,`Empty folder title`),t.includes(`/`)&&fail(`Folder preset node title cannot contain /`,`Folder title contains /: "${t}"`),i.has(t)&&fail(`Folder preset sibling titles must be unique`,`Duplicate folder title: "${t}"`),i.add(t),n.children&&n.children.length>0&&validatePresetStructure(e,n.children,r+1)}}function cloneBuilderValue(e,t){try{return structuredClone(e)}catch{let e=`Builder configuration must contain cloneable data`;throw new n.ValidationError(e,[{path:t,message:e}])}}function requireBuilderName(e,t){if(typeof e!=`string`||e.trim().length===0)throw new n.ValidationError(`Name must not be blank`,[{path:t,message:`Name must not be blank`}])}function validateContentConfiguration(e,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new n.ValidationError(`Invalid content configuration`,[{path:r,message:`Expected content configuration`}]);for(let t of[`name`,`label`,`placement`])if(Object.hasOwn(e,t)){let e=`Independent content configuration cannot define ${t}`;throw new n.ValidationError(e,[{path:[...r,t],message:e}])}let i=t.u.safeParse({...e,name:`content`,placement:`main`});if(!i.success)throw n.ValidationError.fromZodErrors(i.error.issues.map(e=>({path:[...r,...e.path.map(String)],message:e.message})));i.data.type===`form`&&i.data.groups.forEach((e,t)=>requireBuilderName(e.name,[...r,`groups`,String(t),`name`]));let{name:a,label:o,placement:s,...c}=i.data;return cloneBuilderValue(c,r)}function validateLiteralContent(e,t){return validateContentConfiguration(e,t),cloneBuilderValue(e,t)}function collectionSourceAddress(e){return e.relation===void 0?{kind:`object`,object:e.object}:e.object===void 0?{kind:`related`,relation:e.relation}:{kind:`relatedFrom`,object:e.object,relation:e.relation}}function collectionSourceAddressOf(e){if(!e||typeof e!=`object`)return;let t=`object`in e?e.object:void 0,n=`relation`in e?e.relation:void 0;if(typeof t==`string`&&typeof n==`string`)return{kind:`relatedFrom`,object:t,relation:n};if(typeof t==`string`&&n===void 0)return{kind:`object`,object:t};if(typeof n==`string`&&t===void 0)return{kind:`related`,relation:n}}function requireRecordContentContext(e,t,r){if(t!==`record`){let t=`Content "${e}" requires record context. In a collection view only a collection that lists a whole object, or a custom content that does not require a record, is allowed.`;throw new n.ValidationError(t,[{path:r,message:t}])}}function resolveContentNavigation(e){let t=e.openMode??`page`;return{openMode:t,createMode:e.createMode??t}}function resolveCollectionActions(e,t){return[...new Set(t)].filter(t=>e.actions===void 0||e.actions.includes(t))}var qe=class ViewBuilder{constructor(e,t=[]){this.kind=`view`,this.data=cloneBuilderValue(e,[`views`,`0`]),this.extensions=t.map(e=>e&&{...e})}for(e){return new ViewBuilder({...this.data,object:e},this.extensions)}default(){return new ViewBuilder({...this.data,default:!0},this.extensions)}description(e){return new ViewBuilder({...this.data,description:e},this.extensions)}icon(e){return new ViewBuilder({...this.data,icon:e},this.extensions)}place(e,t,r,i){let a=[`views`,`0`,`contents`,String(this.data.contents.length)],o,s;try{typeof r==`object`&&r&&`build`in r&&typeof r.build==`function`?(o=validateContentConfiguration(r.build(),a),s=r.extension):o=validateContentConfiguration(r,a)}catch(e){throw e instanceof n.ValidationError?new n.ValidationError(e.message,e.errors.map(e=>({...e,path:e.path[0]===`content`?[...a,...e.path.slice(1)]:e.path}))):e}let c={...o,name:e,label:t,placement:i},l=[...this.data.contents,c];return new ViewBuilder({...this.data,contents:l},[...this.extensions,s])}tab(e,t,n){return this.place(e,t,n,`main`)}aside(e,t,n){return this.place(e,t,n,`aside`)}build(){let e=[`views`,`0`];requireBuilderName(this.data.name,[...e,`name`]),requireBuilderName(this.data.object,[...e,`object`]);let r=t.i.safeParse(this.data);if(!r.success)throw n.ValidationError.fromZodErrors(r.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return this.data.contents.forEach((t,n)=>{let r=[...e,`contents`,String(n)];requireBuilderName(t.name,[...r,`name`]),t.type===`form`&&t.groups.forEach((e,t)=>requireBuilderName(e.name,[...r,`groups`,String(t),`name`])),(t.type===`custom`?this.extensions[n]?.requiresRecord:t.type!==`collection`||collectionSourceAddress(t.source).kind!==`object`)&&requireRecordContentContext(t.name,this.data.context,r)}),{kind:`view`,definition:cloneBuilderValue(this.data,e)}}};function detailView(e,t){return new qe({name:e,label:t,object:void 0,context:`record`,contents:[]})}function listView(e,t){return new qe({name:e,label:t,object:void 0,context:`collection`,contents:[]})}function relationProperty(e){return requireBuilderName(e,[`relationProperty`]),{relationProperty:e}}var j=class ContentBuilder{constructor(e,t){this.data=cloneBuilderValue(e,[`content`]),this.extension=t===void 0?void 0:Object.freeze({name:t.name,requiresRecord:t.requiresRecord,parameters:t.parameters})}set(e){return new ContentBuilder({...this.data,...e},this.extension)}icon(e){return this.set({icon:e})}object(e){return this.data.type===`forms`?this.set({objectName:e}):this.set({source:{object:e}})}related(e){return this.set({source:{relation:e}})}relatedFrom(e,t){return this.set({source:{object:e,relation:t}})}layout(e){let{layout:t,groupByAttribute:n,columnSizing:r,kanbanColumnOrder:i,kanbanColumnVisibility:a,kanbanPinnedColumns:o,...s}={...this.data,layout:void 0,groupByAttribute:void 0,columnSizing:void 0,kanbanColumnOrder:void 0,kanbanColumnVisibility:void 0,kanbanPinnedColumns:void 0};return new ContentBuilder({...s,...e},this.extension)}table(){return this.layout({layout:`table`})}list(){return this.layout({layout:`list`})}kanban(e){return this.layout({layout:`kanban`,groupByAttribute:e})}columns(...e){return this.set({columns:e})}filter(e){return this.set({filters:e})}sort(e,t=`asc`){let n=[...`sorts`in this.data&&Array.isArray(this.data.sorts)?this.data.sorts:[],{attribute:e,direction:t}];return this.set({sorts:n})}actions(...e){return this.set({actions:e})}openMode(e){return this.set({openMode:e})}createMode(e){return this.set({createMode:e})}visibility(e){return this.set({visibility:e})}descriptionAttribute(e){return this.set({descriptionAttribute:e})}displayAttributes(...e){return this.set({displayAttributes:e})}columnSizing(e){return this.set({columnSizing:e})}kanbanColumnOrder(...e){return this.set({kanbanColumnOrder:e})}kanbanColumnVisibility(e){return this.set({kanbanColumnVisibility:e})}kanbanPinnedColumns(...e){return this.set({kanbanPinnedColumns:e})}formColumns(e){return this.set({formColumns:e})}density(e){return this.set({density:e})}titleAttribute(e){return this.set({titleAttribute:e})}allowUpload(e){return this.set({allowUpload:e})}allowRemove(e){return this.set({allowRemove:e})}hideAttachments(e){return this.set({hideAttachments:e})}relations(...e){return this.set({relations:e})}build(){let e=validateLiteralContent(this.data,[`content`]);if(this.extension&&e.type===`custom`){let t=this.extension.parameters.safeParse(cloneBuilderValue(e.parameters??{},[`content`,`parameters`]));if(!t.success)throw n.ValidationError.fromZodErrors(t.error.issues.map(e=>({path:[`content`,`parameters`,...e.path.map(String)],message:e.message})))}return e}},Je=class GroupBuilder{constructor(e,t,n,r={}){this.data=cloneBuilderValue({name:e,label:t,fields:n,...r},[`group`])}field(e,t){let{name:n,label:r,fields:i,...a}=this.data;return new GroupBuilder(n,r,[...i,{attribute:e,...t}],a)}fields(...e){let{name:t,label:n,fields:r,...i}=this.data;return new GroupBuilder(t,n,[...r,...e.map(e=>({attribute:e}))],i)}description(e){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),description:e})}collapsible(e=!1){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),collapsible:!0,collapsed:e})}presentation(){let{name:e,label:t,fields:n,...r}=this.data;return r}build(){requireBuilderName(this.data.name,[`group`,`name`]);try{validateLiteralContent({type:`form`,groups:[this.data]},[`group`])}catch(e){throw e instanceof n.ValidationError?new n.ValidationError(e.message,e.errors.map(e=>({...e,path:e.path[1]===`groups`?[`group`,...e.path.slice(3)]:e.path}))):e}return cloneBuilderValue(this.data,[`group`])}};function group(e,t){return new Je(e,t,[])}function collection(){return new j({type:`collection`})}function form$1(...e){return new j({type:`form`,groups:e.map(e=>`build`in e?e.build():e)})}function activity(){return new j({type:`activity`})}function richtext$1(e){return new j({type:`richtext`,attribute:e})}function documents(){return new j({type:`documents`})}function forms(){return new j({type:`forms`})}function emails(...e){return new j({type:`emails`,emailAttributes:e})}function meetings(...e){return new j({type:`meetings`,emailAttributes:e})}function custom(e,t){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw new n.ValidationError(`Expected registered extension declaration`,[{path:[`content`,`extension`],message:`Expected registered extension declaration`}]);let r=validateContentConfiguration({type:`custom`,extension:e.name,parameters:t},[`content`]);if(r.type!==`custom`)throw new n.ValidationError(`Expected custom content`,[]);let i=new j({...r,extension:e.name},e);return i.build(),i}const M={collection,form:form$1,activity,richtext:richtext$1,documents,forms,emails,meetings,custom};function validateFlagName(e){if(!/^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/.test(e))throw Error(`Invalid flag name "${e}". Flag names must be kebab-case (e.g., "architect-mode", "ai-features").`)}var BaseFlagBuilder=class{constructor(e,t,n){validateFlagName(e),this.flag={name:e,valueType:t,defaultValue:n,allowedLevels:[`global`,`tenant`,`user`]}}label(e){return this.flag.label=e,this}description(e){return this.flag.description=e,this}category(e){return this.flag.category=e,this}system(){return this.flag.system=!0,this}tenantScoped(){return this.flag.allowedLevels=[`global`,`tenant`],this}globalOnly(){return this.flag.allowedLevels=[`global`],this}allowedLevels(e){return this.flag.allowedLevels=[...e],this}build(){if(!this.flag.label?.trim())throw Error(`Flag "${this.flag.name}" must have a label. Use .label("Human-readable label").`);return{...this.flag,allowedLevels:[...this.flag.allowedLevels||[]]}}},BooleanFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`boolean`,!1)}defaultValue(e){return this.flag.defaultValue=e,this}enabledByDefault(){return this.flag.defaultValue=!0,this}},StringFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`string`,``)}defaultValue(e){return this.flag.defaultValue=e,this}},NumberFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`number`,0)}defaultValue(e){return this.flag.defaultValue=e,this}},JsonFlagBuilder=class extends BaseFlagBuilder{constructor(e,t){super(e,`json`,t)}defaultValue(e){return this.flag.defaultValue=e,this}};function booleanFlag(e){return new BooleanFlagBuilder(e)}function stringFlag(e){return new StringFlagBuilder(e)}function numberFlag(e){return new NumberFlagBuilder(e)}function jsonFlag(e,t){return new JsonFlagBuilder(e,t)}function duplicateFlagError(e){return new n.DuplicateError(`feature flag`,e,`Flag "${e}" is already registered. Each flag name must be unique.`)}function cloneFlagDefinition(e){return{...e,allowedLevels:[...e.allowedLevels]}}var FlagRegistry=class{constructor(){this.flags=new Map}register(e){if(this.flags.has(e.name))throw duplicateFlagError(e.name);this.flags.set(e.name,cloneFlagDefinition(e))}registerAll(e){let t=new Set;for(let n of e){if(this.flags.has(n.name)||t.has(n.name))throw duplicateFlagError(n.name);t.add(n.name)}for(let t of e)this.register(t)}get(e){let t=this.flags.get(e);return t?cloneFlagDefinition(t):void 0}getOrThrow(e){let t=this.get(e);if(!t)throw new n.NotFoundError(`Feature flag`,e,void 0,`Flag "${e}" is not registered. Available flags: ${this.listNames().join(`, `)}`);return t}has(e){return this.flags.has(e)}list(){return Array.from(this.flags.values(),cloneFlagDefinition)}listNames(){return Array.from(this.flags.keys())}unregister(e){return this.flags.delete(e)}clear(){this.flags.clear()}get size(){return this.flags.size}};const Ye=new FlagRegistry;function createFlagRegistry(){return new FlagRegistry}function emptyOverrides(){return{global:new Map,tenant:new Map,user:new Map}}function isActiveOverride(e,t){return e.expiresAt===void 0||e.expiresAt.getTime()>t}function indexOverrides(e,t){let n=new Map;for(let r of e){if(!isActiveOverride(r,t))continue;let e=r.flagName;n.has(e)||n.set(e,r)}return n}var FlagService=class{constructor(e){this.repository=e.repository,this.registry=e.registry,this.staticDefaults=new Map(e.staticDefaults?.map(e=>[e.name,e.value])??[])}async resolveAll(e={}){let t=this.collectFlagNames(),n=this.repository&&t.size>0?await this.getAllOverrides(e,[...t]):emptyOverrides();return this.resolveNames(t,n,e)}resolveAllStatic(){return this.resolveNames(this.collectFlagNames(),emptyOverrides(),{})}collectFlagNames(){let e=new Set;for(let t of this.registry.listNames())e.add(t);for(let t of this.staticDefaults.keys())e.add(t);return e}resolveNames(e,t,n){let r=new Map;for(let i of e)r.set(i,this.resolveValue(i,t,n));return r}async resolve(e,t={}){let n=this.repository?await this.getAllOverrides(t,[e]):emptyOverrides();return this.resolveWithSource(e,n,t)}async isEnabled(e,t={}){return(await this.resolve(e,t)).value===!0}async getValue(e,t={}){return(await this.resolve(e,t)).value}async setOverride(e,t,r,i={}){if(!this.repository)throw new n.SchemaError(`Cannot set override: no FeatureFlagsRepository configured. Add featureFlags to your DatabaseAdapter to enable runtime overrides.`,n.SchemaErrorCode.CONFIGURATION_REQUIRED);let a=this.registry.get(e);if(a&&!a.allowedLevels.includes(t)){let r=`Flag "${e}" does not allow ${t}-level overrides. Allowed levels: ${a.allowedLevels.join(`, `)}`;throw new n.ValidationError(r,[{path:[`level`],message:r}])}if(a?.system){let t=`Flag "${e}" is a system flag and cannot be overridden via API.`;throw new n.ValidationError(t,[{path:[`flagName`],message:t}])}await this.repository.setOverride({flagName:e,level:t,value:r,targetId:i.targetId,expiresAt:i.expiresAt,createdBy:i.createdBy})}async deleteOverride(e,t,r){if(!this.repository)throw new n.SchemaError(`Cannot delete override: no FeatureFlagsRepository configured.`,n.SchemaErrorCode.CONFIGURATION_REQUIRED);await this.repository.deleteOverride(e,t,r)}async getAllOverrides(e,t){if(!this.repository)return emptyOverrides();let[n,r,i]=await Promise.all([this.repository.getOverrides({level:`global`,flagNames:t}),e.tenantId?this.repository.getOverrides({level:`tenant`,targetId:e.tenantId,flagNames:t}):Promise.resolve([]),e.userId?this.repository.getOverrides({level:`user`,targetId:e.userId,flagNames:t}):Promise.resolve([])]),a=Date.now();return{global:indexOverrides(n,a),tenant:indexOverrides(r,a),user:indexOverrides(i,a)}}resolveValue(e,t,n){return this.resolveWithSource(e,t,n).value}resolveWithSource(e,t,n){let r=this.registry.get(e),i=r?.allowedLevels??[`global`,`tenant`,`user`];if(n.userId&&i.includes(`user`)){let r=t.user.get(e);if(r)return{name:e,value:r.value,source:`user`,sourceId:n.userId}}if(n.tenantId&&i.includes(`tenant`)){let r=t.tenant.get(e);if(r)return{name:e,value:r.value,source:`tenant`,sourceId:n.tenantId}}if(i.includes(`global`)){let n=t.global.get(e);if(n)return{name:e,value:n.value,source:`global`}}return this.staticDefaults.has(e)?{name:e,value:this.staticDefaults.get(e),source:`default`}:{name:e,value:r?.defaultValue??void 0,source:`default`}}};function createFlagService(e){return new FlagService(e)}const Xe=Symbol(`stndrds.native-object`);function markNativeDefinition(e){return Object.defineProperty(e,Xe,{value:!0,enumerable:!1}),e}var NativeObjectBuilder=class extends ObjectBuilder{build(){return markNativeDefinition(super.build())}};function nativeObject(e){return new NativeObjectBuilder(e)}function isNativeDefinition(e){return e[Xe]===!0}function cloneObjectDefinition(e){let t=structuredClone(e);return isNativeDefinition(e)?markNativeDefinition(t):t}var NativeObjectRegistryClass=class{constructor(){this.objects=new Map}register(e){let t=(Array.isArray(e)?e:[e]).map(e=>`build`in e&&typeof e.build==`function`?e.build():e),r=new Set;for(let e of t){if(this.validate(e),r.has(e.name))throw new n.DuplicateError(`object`,e.name,`[NativeObjectRegistry] Duplicate object name "${e.name}" within a single register() batch.`);r.add(e.name)}for(let e of t)this.objects.set(e.name,cloneObjectDefinition(e));return this}validate(t){if(!t.system){let e=`[NativeObjectRegistry] Cannot register object "${t.name}" (id: ${t.id}): missing system flag.\nNative objects must have system=true. Did you call .runtime() on the builder? Remove that call — objects are system:true by default.`;throw new n.ValidationError(e,[])}if(e.z(t.name)&&!isNativeDefinition(t))throw new n.ReservedObjectNameError(t.name,`registry`);if(this.objects.has(t.name)){let e=this.objects.get(t.name),r=`[NativeObjectRegistry] Duplicate object name "${t.name}":\n - Existing: "${e?.label}" (id: ${e?.id})\n - New: "${t.label}" (id: ${t.id})\nPlease use unique names for each native object.`;throw new n.DuplicateError(`object`,t.name,r)}}getByName(e){let t=this.objects.get(e);return t?cloneObjectDefinition(t):void 0}getByNameOrThrow(e){let t=this.getByName(e);if(!t){let t=`[NativeObjectRegistry] Native object "${e}" not found.\nAvailable objects: ${this.listNames().join(`, `)}`;throw new n.NotFoundError(`Native object`,e,n.SchemaErrorCode.OBJECT_NOT_FOUND,t)}return t}getAll(){return Array.from(this.objects.values(),cloneObjectDefinition)}listNames(){return Array.from(this.objects.keys())}has(e){return this.objects.has(e)}get size(){return this.objects.size}clear(){this.objects.clear()}summary(){let e=this.getAll();return[`[NativeObjectRegistry] ${this.size} native object(s) registered:`,...e.map(e=>` - ${e.name}: "${e.label}" (${e.attributes.length} attributes)`)].join(`
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config-BQJJHopR.js"),t=require("./view-config.schema-to6p1m8L.js"),n=require("./exceptions.js"),r=require("./utils-gY3d9Dwp.js"),i=require("./object-DGu0m2Y1.js"),a=require("./text-A9AJ1wUO.js"),o=require("./phone-DVaELsa3.js"),s=require("./core-397tQy5q.js"),c=require("./validation/primitives/checkbox.js"),l=require("./validation/primitives/date.js"),u=require("./validation/primitives/number.js");let d=require("@stndrds/constants"),f=require("zod");const p=[`fyi`,`task`,`question`,`handoff`,`system`],m=[`low`,`normal`,`high`,`urgent`],h=[`public`,`internal`,`sensitive`],g=[`unread`,`read`,`archived`,`snoozed`],_=[`none`,`pending`,`processing`,`completed`,`dismissed`,`expired`,`failed`],v=`agent.session.waiting_human`,y=`agent.task.assigned`,b=`agent.question.requested`,x=[v,y,b],S=[`name`,`type`],ee=[`required`,`hidden`,`archived`,`deprecated`,`defaultValue`,`config`,`order`,`unique`],C=[`label`,`description`,`placeholder`,`icon`],w=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`];function relationTargetsOf(e){return e.type!==`relation`||!Array.isArray(e.targets)?[]:e.targets.map(e=>e.object).filter(e=>e!==`*`)}function isUniversalRelation(e){return e.targets.length===1&&e.targets[0].object===`*`}function isBilateralRelation(e){return e.bilateral!==void 0}function inferInverseCardinality(e){return`many`}function isAttributeSortable(e){return t.K(e)}const te=[`record`,`object`,`attribute`,`view`,`user`,`role`,`settings`,`file`,`agent`,`schema_source`],ne=`record.created,record.updated,record.deleted,record.restored,record.purged,object.created,object.updated,object.deleted,attribute.created,attribute.updated,attribute.deleted,view.created,view.updated,view.deleted,schema_source.applied,schema_source.removed,user.created,user.invited,user.updated,user.deleted,user.login,user.logout,role.created,role.updated,role.deleted,role.assigned,role.revoked,settings.updated,file.uploaded,file.updated,file.deleted`.split(`,`);function isTerminalState(e){return e.phase===`terminal`}function sessionStateToLegacyStatus(e){switch(e.phase){case`running`:return`active`;case`queued`:return`idle`;case`parked`:if(e.parkedOn===void 0)throw new n.SchemaError(`parked state without parkedOn`,n.SchemaErrorCode.INVARIANT_VIOLATION);return e.parkedOn===`agents`?`waiting_agents`:`waiting_human`;case`terminal`:if(e.outcome===void 0)throw new n.SchemaError(`terminal state without outcome`,n.SchemaErrorCode.INVARIANT_VIOLATION);return e.outcome}}function legacyStatusToSessionState(e){switch(e){case`active`:return{phase:`running`};case`idle`:return{phase:`queued`};case`waiting_human`:return{phase:`parked`,parkedOn:`human`,humanRequestIds:[]};case`waiting_agents`:return{phase:`parked`,parkedOn:`agents`};default:return{phase:`terminal`,outcome:e}}}const re=[`completed`,`failed`,`cancelled`,`timeout`,`expired`];function isTerminalSessionStatus(e){return re.includes(e)}const ie=[`idle`,`completed`,`waiting_human`,`waiting_agents`,`cancelled`,`failed`,`timeout`];function isClaimableSessionStatus(e){return ie.includes(e)}const ae=Object.freeze({mutation:`ask`,destructive:`ask`,outward:`ask`}),oe=[`active`,`completed`,`abandoned`],se=[`openai`,`anthropic`,`google`,`spacexai`,`deepseek`,`moonshotai`,`alibaba`,`mistral`,`minimax`,`meta`,`zai`],ce=[`standard`,`fast`],le=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`];function agentDisplayName(e){return e.label?.trim()||e.name}const ue=[`approval-requested`,`approval-responded`,`approval-dispatched`],de=[`streaming`,`running`,`pending`,...ue];function isOpenToolPartState(e){return de.includes(e)}function isToolApprovalState(e){return ue.includes(e)}const fe=[`CREDITS_EXHAUSTED`];function isSystemPartCode(e){return typeof e==`string`&&fe.includes(e)}function compareAgentSessionMessages(e,t){let n=e.createdAt.getTime()-t.createdAt.getTime();return n===0?e.id.localeCompare(t.id):n}function orderAgentSessionMessages(e){return[...e].sort(compareAgentSessionMessages)}const pe=[`pending`,`in_progress`,`completed`,`blocked`],me=`__stndrdsNativeUiPartIds`;function invalidNativePartIds(){throw new n.ValidationError(`Native agent UI part IDs metadata is invalid`,[])}function isPlainRecord$1(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function nativeAgentUIPartIdMetadataKey(e,t){if(e.type===`text`||e.type===`reasoning`)return`${e.type}:${t}`;if(e.type===`tool`)return`tool:${e.toolCallId}`}function parseNativeAgentUIPartIdsMetadata(e){let t=e.metadata?.[me];isPlainRecord$1(t)||invalidNativePartIds(),(Object.keys(t).length!==2||t.schemaVersion!==1||!isPlainRecord$1(t.partIds))&&invalidNativePartIds();let n=new Map;for(let[t,r]of e.parts.entries()){let e=nativeAgentUIPartIdMetadataKey(r,t);if(!e||n.has(e)){e&&invalidNativePartIds();continue}n.set(e,r)}let r=Object.entries(t.partIds);r.length!==n.size&&invalidNativePartIds();let i=new Map,a={};for(let[e,t]of r){let r=n.get(e);r&&typeof t==`string`&&t.length>0||invalidNativePartIds();let o=i.get(t);o&&(r.type===`tool`||o!==r.type)&&invalidNativePartIds(),r.type===`tool`&&t!==r.toolCallId&&invalidNativePartIds(),i.set(t,r.type),a[e]=t}return a}const he={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2},ge=[`web`,`presentation`,`document`,`spreadsheet`,`image`,`code`,`other`],_e=[`ephemeral`,`conversation`,`persistent`],ve=[`source`,`preview`,`entrypoint`,`asset`];function getErrorMessage(e){return e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`?`message`in e&&typeof e.message==`string`?e.message:JSON.stringify(e):String(e)}function isFormDefinition(e){return typeof e==`object`&&!!e&&`slots`in e&&`steps`in e&&`name`in e&&typeof e.name==`string`&&Array.isArray(e.slots)&&Array.isArray(e.steps)}const ye=[`relation`,`multiRelation`,`formula`,`rollup`,`document`,`richtext`,`user`];function isFormSlotFieldRef(e){return e.type===`slot`}function isFormFreeFieldRef(e){return e.type===`free`}function resolveFieldRequired(e){return e.fieldRequired===void 0?e.slotMode===`create`&&e.attributeRequired===!0:e.fieldRequired}function getSlotFieldTargets(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}function formFieldKey(e){return isFormSlotFieldRef(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}function formFieldFlatKey(e){return isFormSlotFieldRef(e)?e.attribute:e.attribute.name}function readFormFieldValue(e,t){return e[formFieldKey(t)]??e[formFieldFlatKey(t)]}function isFormFieldsRow(e){return e.type===`fields`}function isFormHeadingRow(e){return e.type===`heading`}function isFormSeparatorRow(e){return e.type===`separator`}function isFormTextRow(e){return e.type===`text`}var NoopGeocodingAdapter=class{async autocomplete(){return await Promise.resolve([])}async reverse(){return await Promise.resolve(null)}async geocode(){return await Promise.resolve(null)}};const T=[`read`,`create`,`update`,`delete`,`manage`];function actionsToAccessLevel(e){return e.length===0?`none`:e.length===1&&e[0]===`read`?`read-only`:e.length===T.length&&T.every(t=>e.includes(t))?`full`:`custom`}function accessLevelToActions(e){switch(e){case`full`:return[...T];case`read-only`:return[`read`];case`none`:return[]}}function resolvePropertyDefinitions(e){let t=e.properties;if(!t)return[];if(Array.isArray(t))return t;let n=t;return Array.isArray(n.definitions)?n.definitions:[]}function hasOptions(e){return e.type===`select`||e.type===`status`||e.type===`multiselect`}const be=`Notetaker`,xe={systemPrompt:null,meetingRecordingPolicy:`none`,meetingBotDisplayName:be},Se=[`active`,`suspended`],Ce=[`architect`,`manual`,`auto`],we=[`square`,`landscape`,`portrait`],Te=[`none`,`estimated`,`exact`];function parseCountMode(e){if(typeof e==`string`&&Te.includes(e))return e;throw new n.ValidationError(`countMode must be one of: ${Te.join(`, `)} (received: ${String(e)})`,[])}function parseOptionalCountMode(e){return e===void 0?void 0:parseCountMode(e)}const Ee=[`storage.bytes`,`members.seats`,`data.live_records`];function isEmptyObject(e){return e==null||typeof e==`object`&&Object.keys(e).length===0}function isNotEmpty(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0}function toUndefinedIfEmpty(e){return isNotEmpty(e)?e:void 0}function computeByteMagnitude(e){if(e<=0)return{value:0,unitIndex:0};let t=1e3,n=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return{value:Number.parseFloat((e/t**n).toFixed(1)),unitIndex:n}}const De=[`B`,`KB`,`MB`,`GB`,`TB`];function formatByteSize(e){let{value:t,unitIndex:n}=computeByteMagnitude(e);return`${t} ${De[n]}`}const Oe={ATTACHMENTS:`attachments`};function isDocumentAttribute(e){return e.type===`document`}function matchesAccepts(e,t){if(!t||t.length===0)return!0;let n=e.name.toLowerCase();return t.some(t=>t.endsWith(`/*`)?e.mimeType.startsWith(t.slice(0,-1)):t.startsWith(`.`)?n.endsWith(t.toLowerCase()):e.mimeType===t)}const ke=Object.freeze([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`,`multiselect`,`location`]);function buildPropertySchema(e){let t=[];for(let n of e){let e=n.build();if(!ke.includes(e.type))throw Error(`Property type "${e.type}" is not supported in .qualifyWith()`);t.push(e)}return{definitions:t}}function parseQualifiedAttribute(e){let t=e.indexOf(`__`);return t<=0||t+2>=e.length?{kind:`scalar`,attribute:e}:{kind:`qualified`,root:e.slice(0,t),property:e.slice(t+2)}}function buildQualifiedAttribute(e,t){return`${e}__${t}`}function isDateRangeValue(e){return typeof e==`object`&&!!e&&typeof e.start==`string`}function normalizeDateValue(e,t){return i.p(e)?null:isDateRangeValue(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e==`string`?t.endDate?{start:e,end:null}:e:null}function dateValueStart(e){return typeof e==`string`&&e!==``?e:isDateRangeValue(e)&&e.start!==``?e.start:null}function formatText(e){return String(e)}function formatCheckbox(e){return e?`Yes`:`No`}function formatNumber(e,t){if(typeof e!=`number`)return String(e);if(t.renderAs===`rating`)return`${e}/${t.max??5}`;let n=t.decimals;return t.unit===`integer`?e.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}):t.unit===`percentage`?(e/100).toLocaleString(void 0,{style:`percent`,minimumFractionDigits:n,maximumFractionDigits:n}):e.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n})}function formatCurrency(e,t){if(typeof e!=`object`||!e)return String(e);let n=e;return`value`in n&&`code`in n?`${n.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})} ${n.code}`:String(e)}function formatDate(e){if(isDateRangeValue(e)){let t=formatDate(e.start);return e.end?`${t} → ${formatDate(e.end)}`:t}if(e instanceof Date)return e.toISOString().split(`T`)[0];if(typeof e==`string`){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toISOString().split(`T`)[0]}return String(e)}function formatPhone(e){if(typeof e!=`object`||!e)return String(e);let t=e;return`phoneNumber`in t?t.phoneNumber?t.countryCode?o.n(t):t.phoneNumber:``:String(e)}function formatLocationValue(e,t=`full`){if(typeof e!=`object`||!e)return``;let n=e,r=[];switch(t){case`country`:n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;case`state`:n.state&&r.push(n.state),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;case`city`:n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;case`coordinates`:n.latitude!==void 0&&n.longitude!==void 0&&r.push(`${n.latitude}, ${n.longitude}`);break;case`address`:n.address&&r.push(n.address),n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country));break;default:n.address&&r.push(n.address),n.address2&&r.push(n.address2),n.city&&r.push(n.city),n.state&&r.push(n.state),n.postalCode&&r.push(n.postalCode),n.country&&r.push((0,d.getCountryDisplayNameByIso3)(n.country))}return r.join(`, `)}function formatLocation(e,t){return typeof e!=`object`||!e?String(e):formatLocationValue(e,t.granularity??`full`)||`—`}function formatSelect(e,t){return typeof e==`string`?t.options?.find(t=>t.value===e)?.label??String(e):String(e)}function formatMultiselect(e,t){return Array.isArray(e)?t.options?e.map(e=>t.options.find(t=>t.value===e)?.label).filter(Boolean).join(`, `):e.join(`, `):String(e)}function formatAttributeValue(e,t){if(i.p(e))return`—`;switch(t.type){case`text`:return formatText(e);case`checkbox`:return formatCheckbox(e);case`number`:return formatNumber(e,t);case`currency`:return formatCurrency(e,t);case`date`:return formatDate(e);case`phone`:return formatPhone(e);case`location`:return formatLocation(e,t);case`select`:case`status`:return formatSelect(e,t);case`multiselect`:return formatMultiselect(e,t);case`user`:case`relation`:return Array.isArray(e)?e.join(`, `):String(e);default:return Array.isArray(e)?e.join(`, `):String(e)}}const Ae=[`UPPER`,`LOWER`,`capitalize`,`trim`],je=[`prefix`,`suffix`,`wrap`,`default`],E=[...Ae,...je],D=f.z.string().min(1,`labelExpression cannot be empty`).refine(e=>isLabelExpression(e),{message:`labelExpression must contain at least one {{ attribute }} interpolation`}).refine(e=>!/\{\{\s*\}\}/.test(e),{message:`labelExpression contains empty {{ }} interpolation`}).refine(e=>{let t=/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g,n;for(;(n=t.exec(e))!==null;){let e=n[1];if(!E.includes(e))return!1}return!0},{message:`Invalid pipe name. Valid pipes: ${E.join(`, `)}`});function validateLabelExpression(e){let t=D.safeParse(e);return t.success?{success:!0,attributes:extractAttributeNames(e)}:{success:!1,error:t.error.issues[0]?.message??`Invalid labelExpression`}}function applyPipe(e,t){let{name:n,args:r}=parsePipeExpression(t);switch(n){case`UPPER`:return e.toUpperCase();case`LOWER`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|\s)\S/g,e=>e.toUpperCase());case`trim`:return e.trim();case`prefix`:return e?`${r[0]??``}${e}`:``;case`suffix`:return e?`${e}${r[0]??``}`:``;case`wrap`:return e?`${r[0]??``}${e}${r[1]??``}`:``;case`default`:return e||r[0]||``;default:return e}}function applyPipes(e,t){let n=e;for(let e of t)n=applyPipe(n,e);return n}function getValue(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}const Me=`(Untitled)`;function parsePipeExpression(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return{name:e,args:[]};let n=t[1],r=t[2];if(!r)return{name:n,args:[]};let i=[],a=/["']([^"']*?)["']/g,o;for(;(o=a.exec(r))!==null;)i.push(o[1]);return{name:n,args:i}}function*templateBlocks(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return;let r=e.indexOf(`}`,n+2);if(r<0)return;if(e[r+1]!==`}`){t=r+1;continue}t=r+2;let i=e.slice(n+2,r);i.length>0&&(yield{start:n,end:t,expr:i})}}function resolveLabelBlock(e,t){let n=e.split(`||`).map(e=>e.trim()),r=n[n.length-1].split(`|`).map(e=>e.trim());n[n.length-1]=r[0];let i=r.slice(1).filter(Boolean),a=n.filter(Boolean),o=``;for(let e of a){let n=toText(getValue(t,e));if(n!==``){o=n;break}}return applyPipes(o,i)}function renderLabelExpression(e,t,n=Me){let r=[],i=0;for(let n of templateBlocks(e))r.push(e.slice(i,n.start),resolveLabelBlock(n.expr,t)),i=n.end;return r.push(e.slice(i)),r.join(``).trim()||n}function toText(e){if(e==null||typeof e==`function`)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return e.map(toText).filter(Boolean).join(`,`);let t=e.toString;return typeof t==`function`&&t!==Object.prototype.toString?String(e):``}function isLabelExpression(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return!1;let r=e.indexOf(`}}`,n+2);if(r<0)return!1;if(e.slice(n+2,r).trim().length>0)return!0;t=r+2}return!1}function extractAttributeNames(e){let t=[];for(let n of templateBlocks(e)){let e=n.expr.trim();if(!e)continue;let r=e.split(`||`).map(e=>e.trim()),i=r[r.length-1];r[r.length-1]=i.split(`|`)[0].trim();for(let e of r){if(!e)continue;let n=e.split(`.`)[0];n&&!t.includes(n)&&t.push(n)}}return t}const Ne=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function getSingleAttributeFromExpression(e){let t=e.trim().match(Ne);return t?t[1]:null}function getEditableLabelAttribute(e,n){let r=getSingleAttributeFromExpression(e);if(r===null)return null;let i=n.find(e=>e.name===r);return!i||i.type!==`text`||t.B(i).authoring.readOnly?null:i}const Pe=/\{\{\s*props\./;function applyRelationProps(e,t,n){if(!Pe.test(e))return e;let r={},i=new Map(n?.map(e=>[e.name,e]));if(t)for(let[e,n]of Object.entries(t)){if(n==null)continue;let t=i.get(e);if(t){let i=formatAttributeValue(n,t);r[e]=i===`—`?``:i}else r[e]=n}return renderLabelExpression(e,{props:r},``).replace(/\(\s*\)/g,``).replace(/\[\s*\]/g,``).replace(/\s*[-—|:]\s*$/g,``).replace(/\s{2,}/g,` `).trim()}function relationPropertyDefs(e){if(e?.type===`relation`)return e.properties?.definitions}function qualifiedPropertyDefs(e){if(e?.type===`relation`||e?.type===`document`)return e.properties?.definitions}function extractValueRefs(e){if(i.p(e))return[];if(typeof e==`string`)return[{id:e}];if(Array.isArray(e))return e.flatMap(e=>extractValueRefs(e));if(typeof e==`object`&&`id`in e){let t=e;if(typeof t.id==`string`)return[{id:t.id,props:t.props}]}return[]}function getUserDisplayName(e){let t=[e.firstName,e.lastName].map(e=>e?.trim()).filter(Boolean).join(` `);return t===``?e.email?.split(`@`)[0]??``:t}const Fe=/\p{L}|\p{N}/u;function deriveInitials(e,t){let n=e?.trim()??``;if(n===``)return t;let r=n.split(/\s+/),i=(r.length===1?n.split(`@`)[0].split(/[._-]/):r).map(e=>{let t=e.match(Fe)?.[0];return t===void 0?``:[...t.toUpperCase()][0]??``}).filter(Boolean).slice(0,2).join(``);return i===``?t:i}const Ie=`__creatorRootActorId`;function getRecordCreatorPrincipalId(e){let t=e.metadata?.[Ie];return typeof t==`string`&&t.length>0?t:e.createdBy}function includesAction(e,t){return e?.includes(`*`)===!0||e?.includes(t)===!0}function buildPermissionFlags(e){return{canRead:includesAction(e,`read`),canCreate:includesAction(e,`create`),canUpdate:includesAction(e,`update`),canDelete:includesAction(e,`delete`),canManage:includesAction(e,`manage`)}}const Le=new Set([`id`,`name`,`label`,`type`,`required`,`system`,`unique`,`order`]),O={PEOPLE:`people`,WORKSPACE:`workspace`,ARCHITECT:`architect`,FEATURE_FLAGS:`feature-flags`,FILES:`files`,VIEWS:`views`,FORMS:`forms`,DOCUMENTS:`documents`,AUDIT:`audit`,API_KEYS:`api-keys`,CONNECTORS:`connectors`,ENV_VARS:`env-vars`,SESSION:`session`},Re=[O.PEOPLE,O.WORKSPACE,O.ARCHITECT,O.FEATURE_FLAGS,O.FILES,O.VIEWS,O.FORMS,O.DOCUMENTS,O.AUDIT,O.API_KEYS,O.CONNECTORS,O.ENV_VARS,O.SESSION],ze={people:`People`,workspace:`Workspace`,architect:`Architect`,"feature-flags":`Feature flags`,files:`Files`,views:`Views`,forms:`Forms`,documents:`Documents`,audit:`Audit`,"api-keys":`API keys`,connectors:`Connected accounts`,"env-vars":`Environment variables`,session:`Agent sessions`},Be={OWNER:`owner`,MEMBER:`member`,AGENT_DEFAULT:`agent_default`,REFLEX_DEFAULT:`reflex_default`},Ve={owner:`Owner`,member:`Member`,agent_default:`Agent Default`,reflex_default:`Reflex Default`},He={owner:`Full access to all platform features and data`,member:`Can view, create, edit and delete business data`,agent_default:`Default role for AI agents — CRUD on records plus documents and files`,reflex_default:`Default role for reflexes — no data access; each reflex is granted exactly what its rehearsal showed it uses`},k=[`read`,`create`,`update`,`delete`,`manage`],Ue=[`read`,`create`,`update`,`delete`],We=[`read`,`create`,`update`,`delete`],Ge={owner:{system:[{target:`*`,actions:k}],object:[{target:`*`,actions:k}]},member:{system:[{target:`people`,actions:[`read`]},{target:`workspace`,actions:[`read`]},{target:`connectors`,actions:Ue},{target:`files`,actions:We},{target:`documents`,actions:We}],object:[{target:`*`,actions:k}]},agent_default:{system:[{target:`documents`,actions:[`read`,`create`,`update`]},{target:`files`,actions:[`read`,`create`,`update`]},{target:`env-vars`,actions:[`read`]},{target:`session`,actions:[`observe`]}],object:[{target:`*`,actions:[`read`,`create`,`update`,`delete`]}]},reflex_default:{system:[],object:[]}};function isDefaultRole(e){return Object.values(Be).includes(e)}const A={maxConcurrentRuns:3,retryPolicy:{maxRetries:3,backoffMs:1e3,backoffMultiplier:2},timeoutMs:3e5};var AgentBuilder=class{constructor(e){if(!e.name||e.name.trim().length===0)throw new n.ValidationError(`Agent name is required`,[]);this.bp={name:e.name,system:!0,visibility:`workspace`,triggers:[]}}description(e){return this.bp.description=e,this}label(e){return this.bp.label=e,this}icon(e){return this.bp.icon=e,this}systemPrompt(e){return this.bp.systemPrompt=e,this}model(e,t,n){return this.bp.model={provider:e,model:t,...n},this}tools(e){return this.bp.tools=[...e],this}schedule(e){return this.bp.schedule={...e,enabled:e.enabled??!0},this}config(e){let t=this.bp.config??A,n=e.inference===void 0?t.inference:{...t.inference,...e.inference};return this.bp.config={...t,...e,...n===void 0?{}:{inference:n}},this}delegation(e){return Object.assign(this.bp,e),this}mcpServers(e){return this.bp.mcpServers=Array.isArray(e)?[...e]:e,this}approval(e){return this.bp.approval={...ae,...this.bp.approval,...e},this}visibility(e){return this.bp.visibility=e,this}requiresPermission(e,t){return this.bp.requiredPermission={resource:e,action:t},this}trigger(e,t,n){return this.bp.triggers.push({name:e,eventType:t,...n,enabled:n?.enabled??!0}),this}runtime(){return this.bp.system=!1,this}build(){if(!this.bp.systemPrompt)throw new n.ValidationError(`Agent "${this.bp.name}": systemPrompt is required`,[]);if(!this.bp.model)throw new n.ValidationError(`Agent "${this.bp.name}": model is required`,[]);if(this.bp.system&&this.bp.visibility===`private`)throw new n.ValidationError(`Agent "${this.bp.name}": system agents must use workspace visibility`,[]);return e.T(this.bp.triggers,e=>e.name,e=>new n.ValidationError(`Agent "${this.bp.name}": duplicate trigger name "${e}"`,[])),{...this.bp,visibility:this.bp.visibility??`workspace`,config:this.bp.config??A,systemPrompt:this.bp.systemPrompt,model:this.bp.model}}};function agent(e){return new AgentBuilder(e)}const Ke=`@stndrds/schema`;function createStandardSchemaProps(e){return{version:1,vendor:Ke,validate:t=>{let n=e.safeParse(t);return n.success?{value:n.data}:{issues:n.error.issues.map(e=>({message:e.message,path:e.path}))}}}}function isStandardSchema(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`&&e[`~standard`].version===1}function asMutableArray(e){return e}var BaseAttributeBuilder=class{get"~standard"(){return createStandardSchemaProps(i.d(this.build()))}constructor(t,n,r){e.E(n),e.O(r),this.attr={name:n,label:r,type:t,required:!1,system:!0}}setRequired(e){this.attr.required=e}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=!1,this}hidden(){return this.attr.hidden=!0,this}placeholder(e){return this.attr.placeholder=e,this}description(e){return this.attr.description=e,this}icon(t){return e.D(t,`attribute "${this.attr.name}"`),this.attr.icon=t,this}order(e){return this.attr.order=e,this}defaultValue(e){return(`defaultValue`in this.attr||![`formula`,`rollup`].includes(this.attr.type))&&(this.attr.defaultValue=e),this}metadata(e){return this.attr.metadata=e,this}build(){return this.attr}},TextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`text`,e,t)}minLength(e){return this.attr.minLength=e,this}maxLength(e){return this.attr.maxLength=e,this}pattern(e){return this.attr.pattern=e,this.attr.format=void 0,this}multiline(e=!0){return this.attr.multiline=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}email(){return this.attr.format=`email`,this.attr.pattern=void 0,this}url(){return this.attr.format=`url`,this.attr.pattern=void 0,this}slug(){return this.attr.format=`slug`,this.attr.pattern=void 0,this}};function text(e){return new TextAttributeBuilder(e.name,e.label)}var RichtextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`richtext`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function richtext(e){return new RichtextAttributeBuilder(e.name,e.label)}var NumberAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`number`,e,t)}min(e){return this.attr.min=e,this}max(e){return this.attr.max=e,this}integer(){return this.attr.unit=`integer`,this.attr.decimals=0,this}decimal(e=2){return this.attr.unit=`decimal`,this.attr.decimals=e,this}percentage(){return this.attr.unit=`percentage`,this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function number(e){return new NumberAttributeBuilder(e.name,e.label)}var CheckboxAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`checkbox`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function checkbox(e){return new CheckboxAttributeBuilder(e.name,e.label)}var DateAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`date`,e,t)}format(e){return this.attr.dateFormat=e,this}minDate(e){return this.attr.minDate=e,this}maxDate(e){return this.attr.maxDate=e,this}endDate(){return this.attr.endDate=!0,this.asPhantomState()}includeTime(){return this.attr.includeTime=!0,this}timeFormat(e){return this.attr.timeFormat=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function date(e){return new DateAttributeBuilder(e.name,e.label)}var PhoneAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`phone`,e,t)}defaultCountry(e){return this.attr.defaultCountryCode=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function phone(e){return new PhoneAttributeBuilder(e.name,e.label)}var CurrencyAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`currency`,e,t)}defaultCurrency(e){return this.attr.defaultCurrency=e,this}allowedCurrencies(e){return this.attr.allowedCurrencies=e,this}allowNegative(e=!0){return this.attr.allowNegative=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function currency(e){return new CurrencyAttributeBuilder(e.name,e.label)}var StatusAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`status`,e,t)}options(t){let n=asMutableArray(t);return e.A(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.A(this.attr.name??`unknown`,n),this.attr.options.push(t),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function status(e){return new StatusAttributeBuilder(e.name,e.label)}var SelectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`select`,e,t)}options(t){let n=asMutableArray(t);return e.A(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.A(this.attr.name??`unknown`,n),this.attr.options.push(t),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function select(e){return new SelectAttributeBuilder(e.name,e.label)}var MultiselectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`multiselect`,e,t)}options(t){let n=asMutableArray(t);return e.A(this.attr.name??`unknown`,n),this.attr.options=n,this.asPhantomState()}option(t){this.attr.options||(this.attr.options=[]);let n=[...this.attr.options,t];return e.A(this.attr.name??`unknown`,n),this.attr.options.push(t),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function multiselect(e){return new MultiselectAttributeBuilder(e.name,e.label)}var LocationAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`location`,e,t)}granularity(e){return this.attr.granularity=e,this}defaultCountry(e){return this.attr.defaultCountry=e,this}allowedCountries(e){return this.attr.allowedCountries=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function location(e){return new LocationAttributeBuilder(e.name,e.label)}var UserAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`user`,e,t),this.attr.types=[`user`,`agent`]}types(e){let t=[...new Set(e)];if(t.length===0)throw Error(`[AttributeBuilder] user.types must contain at least one type.`);return this.attr.types=t,this}multiple(){return this.attr.multiple=!0,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function user(e){return new UserAttributeBuilder(e.name,e.label)}var BaseRelationAttributeBuilder=class extends BaseAttributeBuilder{to(e,t){let n={object:e,...t};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:`*`}],this}qualifyWith(...e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.qualifyWith() must be called AFTER .to(). Example: relation({ name: "companies" }).to("companies").qualifyWith(...)`);return this.attr.properties=buildPropertySchema(e),this}bilateral(e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.bilateral() must be called AFTER .to(). Example: relation({ name: "company" }).to("companies").bilateral({ ... })`);if(t.length>1)throw Error(`Bilateral relations are not supported for polymorphic relations (multiple .to() targets).`);if(isUniversalRelation(this.attr))throw Error(`Bilateral relations are not supported for universal relations (.toAny()).`);let r=t[0]?.object;if(!r)throw new n.ValidationError(`Bilateral relation requires one target object`,[{path:[`bilateral`,`object`],message:`Bilateral relation requires one target object`}]);if(e.object&&e.object!==r){let t=`Bilateral inverse object ${e.object} must match relation target ${r}`;throw new n.ValidationError(t,[{path:[`bilateral`,`object`],message:t}])}return this.attr.bilateral={...e,object:r},this}},SingleRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t){super(`relation`,e,t),this.attr.cardinality=`one`,this.attr.targets=[]}many(){let e=new MultiRelationAttributeBuilder(this.attr.name,this.attr.label??``,{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===!1&&e.runtime(),this.attr.hidden&&e.hidden(),this.attr.placeholder&&e.placeholder(this.attr.placeholder),this.attr.description&&e.description(this.attr.description),this.attr.icon&&e.icon(this.attr.icon),this.attr.order!==void 0&&e.order(this.attr.order),this.attr.metadata&&e.metadata(this.attr.metadata),e}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}},MultiRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t,n){super(`relation`,e,t),this.attr.cardinality=`many`,this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(!0)}maxItems(e){return this.attr.maxItems=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function relation(e){return new SingleRelationAttributeBuilder(e.name,e.label)}var FormulaAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`formula`,e,t),this.attr.required=!1}expression(e){return this.attr.expression=e,this}returns(e){return this.attr.returnType=e,this}decimals(e){return this.attr.decimals=e,this}required(){throw Error(`Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function formula(e){return new FormulaAttributeBuilder(e.name,e.label)}var RollupAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`rollup`,e,t),this.attr.required=!1}from(e){return this.attr.relationAttribute=e,this}aggregate(e){return this.attr.targetAttribute=e,this}using(e){return this.attr.function=e,this}decimals(e){return this.attr.decimals=e,this}path(e){return this.attr.relationPath=e,this}targetType(e){return this.attr.targetAttributeType=e,this}targetOptions(e){return this.attr.targetAttributeOptions=e,this}targetCurrency(e){return this.attr.targetCurrencyCode=e,this}build(){let e=this.attr.function,t=this.attr.targetAttributeType;if(e===`original`&&t!==void 0&&t!==`select`&&t!==`status`&&t!==`multiselect`){let e=this.attr.relationAttribute??`relation`,r=this.attr.targetAttribute??`field`;throw new n.SchemaError(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${t}") was given. To surface a plain ${t} value from a related record, use a formula instead — e.g. formula({ name: "${this.attr.name}", label: "…" }).expression("${e}.${r}").`,n.SchemaErrorCode.VALIDATION_FAILED)}return super.build()}required(){throw Error(`Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function rollup(e){return new RollupAttributeBuilder(e.name,e.label)}var DocumentAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`document`,e,t)}accepts(e){return this.attr.accepts=e,this}maxFileSize(e){return this.attr.maxFileSize=e,this}qualifyWith(...e){return this.attr.properties=buildPropertySchema(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function document(e){return new DocumentAttributeBuilder(e.name,e.label)}function buildSlotFieldRef(e,t,n){let[r,...i]=Array.isArray(e)?e:[e];return{type:`slot`,slotId:r,additionalSlotIds:i.length>0?i:void 0,attribute:t,label:n?.label,required:n?.required,tooltip:n?.tooltip}}var FormRowBuilder=class{constructor(e,t,n){this._finalized=!1,this.stepBuilder=e,this.rowData={id:t,order:n,type:`fields`,fields:[]}}field(e,t,n){return this.rowData.fields.push(buildSlotFieldRef(e,t,n)),this}freeField(e,t){let n={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression};return this.rowData.fields.push(n),this}row(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).row(e)}heading(e,t){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).heading(e,t)}separator(){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).separator()}text(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).text(e)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData))}},FormStepBuilder=class{constructor(e,t,n){this.rowOrder=0,this.formBuilder=e,this.stepData={id:t,label:n,rows:[]}}description(e){return this.stepData.description=e,this}field(e,t,n){this.rowOrder++;let r=`row-${this.stepData.id}-${this.rowOrder}`,i=buildSlotFieldRef(e,t,n),a={id:r,order:this.rowOrder,type:`fields`,fields:[i]};return this.stepData.rows.push(a),this}freeField(e,t){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,r={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression},i={id:n,order:this.rowOrder,type:`fields`,fields:[r]};return this.stepData.rows.push(i),this}row(e){return this.rowOrder++,new FormRowBuilder(this,e,this.rowOrder)}heading(e,t){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`heading`,content:e,level:t};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let e={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`separator`};return this.stepData.rows.push(e),this}text(e){this.rowOrder++;let t={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`text`,content:e};return this.stepData.rows.push(t),this}step(e,t){return this.formBuilder._finalizeStep(this.stepData).step(e,t)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(e){return e.fields.length>0&&this.stepData.rows.push(e),this}_getData(){return this.stepData}},FormBuilder=class{constructor(e,t){this.data={slots:[],steps:[],status:`draft`,version:1},this.validateName(e),this.data.name=e,this.data.label=t}description(e){return this.data.description=e,this}icon(e){return this.data.icon=e,this}status(e){return this.data.status=e,this}metadata(e){return this.data.metadata=e,this}slot(e,t,n){if(this.data.slots.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate slot id: "${e}"`);let r={id:e,objectName:t,label:n.label,mode:n.mode??`create`,color:n.color,icon:n.icon};return this.data.slots.push(r),this}step(e,t){if(this.data.steps.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate step id: "${e}"`);return new FormStepBuilder(this,e,t)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.data}_finalizeStep(e){return this.data.steps.push(e),this}validateName(e){let t=f.z.string().min(1,`Form name cannot be empty`).max(63,`Form name is too long (max 63 characters)`).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:`Invalid form name format. Name must be in kebab-case: 'client-onboarding', 'contact-creation'`});try{t.parse(e)}catch(e){throw e instanceof f.z.ZodError?Error(`[FormBuilder] ${e.issues[0].message}`):e}}validateRequiredData(){if(this.data.slots.length===0)throw Error(`[FormBuilder] At least one slot is required. Use .slot() to add slots.`);if(this.data.steps.length===0)throw Error(`[FormBuilder] At least one step is required. Use .step() to add steps.`)}validateSlotReferences(){let e=new Map(this.data.slots.map(e=>[e.id,e.objectName]));for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(r.type!==`slot`)continue;let n=getSlotFieldTargets(r);for(let r of n)if(!e.has(r))throw Error(`[FormBuilder] Step "${t.id}" references unknown slot "${r}". Declare it with .slot("${r}", ...) first.`);let i=new Set(n.map(t=>e.get(t)));if(i.size>1)throw Error(`[FormBuilder] Step "${t.id}" field on attribute "${r.attribute}" targets slots of different objects (${[...i].join(`, `)}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let e=[...E,`join`];for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(!isFormFreeFieldRef(r)||!r.prefillExpression)continue;let n=r.prefillExpression,i=`prefillExpression on free field "${r.attribute.name}" in step "${t.id}"`;if(!isLabelExpression(n))throw Error(`[FormBuilder] ${i} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(n))throw Error(`[FormBuilder] ${i} contains empty {{ }} interpolation.`);for(let t of n.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g)){let n=t[1];if(!e.includes(n))throw Error(`[FormBuilder] ${i} uses invalid pipe "${n}". Valid pipes: ${e.join(`, `)}`)}}}validateFreeFields(){let e=new Set(ye);for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n)){for(let r of n.fields)if(isFormFreeFieldRef(r)){let n=r.attribute.type;if(e.has(n))throw Error(`[FormBuilder] Free field in step "${t.id}" uses forbidden attribute type "${n}". Forbidden types: ${ye.join(`, `)}`)}}}};function form(e,t){return new FormBuilder(e,t)}function resolveBuiltInTransform(e){return{text:`toString`,richtext:`toString`,number:`toNumber`,currency:`toNumber`,date:`toDate`,checkbox:`toBoolean`}[e]}var MigrationBuilder=class{constructor(e){this.operations=[],this.touchedAttributes=new Set,this.version=e}assertNotTouched(e,t){if(this.touchedAttributes.has(e))throw new n.ValidationError(`[MigrationBuilder] Conflicting operations on attribute "${e}": it was already modified earlier in this migration (attempted: ${t}).`,[])}renameAttribute(e,t){return this.assertNotTouched(e,`rename_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`rename_attribute`,from:e,to:t}),this}changeType(e,t,n,r){this.assertNotTouched(e,`change_type`),this.touchedAttributes.add(e);let i=r?.transform?resolveBuiltInTransform(n):void 0;return this.operations.push({type:`change_type`,name:e,from:t,to:n,transform:i}),this}removeAttribute(e){return this.assertNotTouched(e,`remove_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`remove_attribute`,name:e}),this}addAttribute(e){return this.assertNotTouched(e.name,`add_attribute`),this.touchedAttributes.add(e.name),this.operations.push({type:`add_attribute`,attribute:e}),this}updateConfig(e,t){return this.assertNotTouched(e,`update_config`),this.touchedAttributes.add(e),this.operations.push({type:`update_config`,name:e,from:{},to:t}),this}build(){return{version:this.version,operations:[...this.operations]}}};function validateObjectExpressions(e){let{name:t,labelExpression:r,embeddingExpression:i}=e;if(!r)throw new n.SchemaError(`Object "${t}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,n.SchemaErrorCode.VALIDATION_FAILED);let a=D.safeParse(r);if(!a.success){let e=a.error.issues[0]?.message??`Invalid labelExpression`;throw new n.SchemaError(`Invalid labelExpression for "${t}": ${e}`,n.SchemaErrorCode.VALIDATION_FAILED)}if(i!==void 0){let e=D.safeParse(i);if(!e.success){let r=e.error.issues[0]?.message??`Invalid embeddingExpression`;throw new n.SchemaError(`Invalid embeddingExpression for "${t}": ${r}`,n.SchemaErrorCode.VALIDATION_FAILED)}}}var ObjectBuilder=class{get"~standard"(){return createStandardSchemaProps(i.u(this.build()))}constructor(e){this._migrations=[],this._sealed=!1,this._toleratedAttributes=[],this.validateName(e.name),this.obj={name:e.name,label:e.label,attributes:[],system:!0},e.id&&(this.obj.id=e.id)}description(e){return this.obj.description=e,this}pluralLabel(e){return this._pluralLabel=e,this}icon(e){return this.obj.icon=e,this}runtime(){return this.obj.system=!1,this}sealed(){return this._sealed=!0,this}tolerate(e){return this._toleratedAttributes=[...this._toleratedAttributes,...e],this}attribute(e){return this.pushAttributes([e]),this}attributes(e){return this.pushAttributes(e),this}pushAttributes(t){let r=t.map(e=>`build`in e&&typeof e.build==`function`?e.build():e);e.T([...this.obj.attributes,...r],e=>e.name,e=>new n.DuplicateError(`attribute`,e,`Object "${this.obj.name}": duplicate attribute name "${e}"`)),this.obj.attributes.push(...r)}metadata(e){return this.obj.metadata={...this.obj.metadata,...e},this}order(e){return this.obj.metadata={...this.obj.metadata,order:e},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:!0},this}labelExpression(e){return this._labelExpression=e,this}embeddingExpression(e){return this._embeddingExpression=e,this}documentLayout(e){if(e.presets)for(let t of e.presets)validatePresetStructure(t.id,t.structure,1);return this.obj.documentLayout=e,this}migration(e,t){if(e<2)throw Error(`[ObjectBuilder] Migration version must be >= 2 (version 1 is implicit). Got: ${e}`);if(this._migrations.some(t=>t.version===e))throw Error(`[ObjectBuilder] Duplicate migration version: ${e}`);let n=new MigrationBuilder(e);return t(n),this._migrations.push(n.build()),this}build(){if(!this.obj.name)throw new n.ValidationError(`[ObjectBuilder] Missing required field: name`,[{path:[`name`],message:`name is required`}]);if(!this.obj.label)throw new n.ValidationError(`[ObjectBuilder] Missing required field: label`,[{path:[`label`],message:`label is required`}]);validateObjectExpressions({name:this.obj.name,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression});let e=[...this._migrations].sort((e,t)=>e.version-t.version);for(let t=0;t<e.length;t++){let n=t+2;if(e[t].version!==n)throw Error(`[ObjectBuilder] Migration versions must be sequential starting at 2. Expected version ${n}, got ${e[t].version}.`)}let t=e.length>0?e[e.length-1].version:1;return{...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,schema_version:t,migrations:e,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(t){t!==void 0&&e.k(t)}};function object(t){if(e.z(t.name))throw new n.ReservedObjectNameError(t.name,`builder`);return new ObjectBuilder(t)}function validatePresetStructure(e,t,r){let fail=(t,r)=>{throw new n.ValidationError(t,[{path:[`documentLayout`,`presets`,e],message:r}])};r>5&&fail(`Preset structure exceeds max depth of 5`,`Preset structure too deep`);let i=new Set;for(let n of t){let t=n.title.trim();t.length===0&&fail(`Folder preset node title is required`,`Empty folder title`),t.includes(`/`)&&fail(`Folder preset node title cannot contain /`,`Folder title contains /: "${t}"`),i.has(t)&&fail(`Folder preset sibling titles must be unique`,`Duplicate folder title: "${t}"`),i.add(t),n.children&&n.children.length>0&&validatePresetStructure(e,n.children,r+1)}}function cloneBuilderValue(e,t){try{return structuredClone(e)}catch{let e=`Builder configuration must contain cloneable data`;throw new n.ValidationError(e,[{path:t,message:e}])}}function requireBuilderName(e,t){if(typeof e!=`string`||e.trim().length===0)throw new n.ValidationError(`Name must not be blank`,[{path:t,message:`Name must not be blank`}])}function validateContentConfiguration(e,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new n.ValidationError(`Invalid content configuration`,[{path:r,message:`Expected content configuration`}]);for(let t of[`name`,`label`,`placement`])if(Object.hasOwn(e,t)){let e=`Independent content configuration cannot define ${t}`;throw new n.ValidationError(e,[{path:[...r,t],message:e}])}let i=t.u.safeParse({...e,name:`content`,placement:`main`});if(!i.success)throw n.ValidationError.fromZodErrors(i.error.issues.map(e=>({path:[...r,...e.path.map(String)],message:e.message})));i.data.type===`form`&&i.data.groups.forEach((e,t)=>requireBuilderName(e.name,[...r,`groups`,String(t),`name`]));let{name:a,label:o,placement:s,...c}=i.data;return cloneBuilderValue(c,r)}function validateLiteralContent(e,t){return validateContentConfiguration(e,t),cloneBuilderValue(e,t)}function collectionSourceAddress(e){return e.relation===void 0?{kind:`object`,object:e.object}:e.object===void 0?{kind:`related`,relation:e.relation}:{kind:`relatedFrom`,object:e.object,relation:e.relation}}function collectionSourceAddressOf(e){if(!e||typeof e!=`object`)return;let t=`object`in e?e.object:void 0,n=`relation`in e?e.relation:void 0;if(typeof t==`string`&&typeof n==`string`)return{kind:`relatedFrom`,object:t,relation:n};if(typeof t==`string`&&n===void 0)return{kind:`object`,object:t};if(typeof n==`string`&&t===void 0)return{kind:`related`,relation:n}}function requireRecordContentContext(e,t,r){if(t!==`record`){let t=`Content "${e}" requires record context. In a collection view only a collection that lists a whole object, or a custom content that does not require a record, is allowed.`;throw new n.ValidationError(t,[{path:r,message:t}])}}function resolveContentNavigation(e){let t=e.openMode??`page`;return{openMode:t,createMode:e.createMode??t}}function resolveCollectionActions(e,t){return[...new Set(t)].filter(t=>e.actions===void 0||e.actions.includes(t))}var qe=class ViewBuilder{constructor(e,t=[]){this.kind=`view`,this.data=cloneBuilderValue(e,[`views`,`0`]),this.extensions=t.map(e=>e&&{...e})}for(e){return new ViewBuilder({...this.data,object:e},this.extensions)}default(){return new ViewBuilder({...this.data,default:!0},this.extensions)}description(e){return new ViewBuilder({...this.data,description:e},this.extensions)}icon(e){return new ViewBuilder({...this.data,icon:e},this.extensions)}place(e,t,r,i){let a=[`views`,`0`,`contents`,String(this.data.contents.length)],o,s;try{typeof r==`object`&&r&&`build`in r&&typeof r.build==`function`?(o=validateContentConfiguration(r.build(),a),s=r.extension):o=validateContentConfiguration(r,a)}catch(e){throw e instanceof n.ValidationError?new n.ValidationError(e.message,e.errors.map(e=>({...e,path:e.path[0]===`content`?[...a,...e.path.slice(1)]:e.path}))):e}let c={...o,name:e,label:t,placement:i},l=[...this.data.contents,c];return new ViewBuilder({...this.data,contents:l},[...this.extensions,s])}tab(e,t,n){return this.place(e,t,n,`main`)}aside(e,t,n){return this.place(e,t,n,`aside`)}build(){let e=[`views`,`0`];requireBuilderName(this.data.name,[...e,`name`]),requireBuilderName(this.data.object,[...e,`object`]);let r=t.i.safeParse(this.data);if(!r.success)throw n.ValidationError.fromZodErrors(r.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return this.data.contents.forEach((t,n)=>{let r=[...e,`contents`,String(n)];requireBuilderName(t.name,[...r,`name`]),t.type===`form`&&t.groups.forEach((e,t)=>requireBuilderName(e.name,[...r,`groups`,String(t),`name`])),(t.type===`custom`?this.extensions[n]?.requiresRecord:t.type!==`collection`||collectionSourceAddress(t.source).kind!==`object`)&&requireRecordContentContext(t.name,this.data.context,r)}),{kind:`view`,definition:cloneBuilderValue(this.data,e)}}};function detailView(e,t){return new qe({name:e,label:t,object:void 0,context:`record`,contents:[]})}function listView(e,t){return new qe({name:e,label:t,object:void 0,context:`collection`,contents:[]})}function relationProperty(e){return requireBuilderName(e,[`relationProperty`]),{relationProperty:e}}var j=class ContentBuilder{constructor(e,t){this.data=cloneBuilderValue(e,[`content`]),this.extension=t===void 0?void 0:Object.freeze({name:t.name,requiresRecord:t.requiresRecord,parameters:t.parameters})}set(e){return new ContentBuilder({...this.data,...e},this.extension)}icon(e){return this.set({icon:e})}object(e){return this.data.type===`forms`?this.set({objectName:e}):this.set({source:{object:e}})}related(e){return this.set({source:{relation:e}})}relatedFrom(e,t){return this.set({source:{object:e,relation:t}})}layout(e){let{layout:t,groupByAttribute:n,columnSizing:r,kanbanColumnOrder:i,kanbanColumnVisibility:a,kanbanPinnedColumns:o,...s}={...this.data,layout:void 0,groupByAttribute:void 0,columnSizing:void 0,kanbanColumnOrder:void 0,kanbanColumnVisibility:void 0,kanbanPinnedColumns:void 0};return new ContentBuilder({...s,...e},this.extension)}table(){return this.layout({layout:`table`})}list(){return this.layout({layout:`list`})}kanban(e){return this.layout({layout:`kanban`,groupByAttribute:e})}columns(...e){return this.set({columns:e})}filter(e){return this.set({filters:e})}sort(e,t=`asc`){let n=[...`sorts`in this.data&&Array.isArray(this.data.sorts)?this.data.sorts:[],{attribute:e,direction:t}];return this.set({sorts:n})}actions(...e){return this.set({actions:e})}openMode(e){return this.set({openMode:e})}createMode(e){return this.set({createMode:e})}visibility(e){return this.set({visibility:e})}descriptionAttribute(e){return this.set({descriptionAttribute:e})}displayAttributes(...e){return this.set({displayAttributes:e})}columnSizing(e){return this.set({columnSizing:e})}kanbanColumnOrder(...e){return this.set({kanbanColumnOrder:e})}kanbanColumnVisibility(e){return this.set({kanbanColumnVisibility:e})}kanbanPinnedColumns(...e){return this.set({kanbanPinnedColumns:e})}formColumns(e){return this.set({formColumns:e})}density(e){return this.set({density:e})}titleAttribute(e){return this.set({titleAttribute:e})}allowUpload(e){return this.set({allowUpload:e})}allowRemove(e){return this.set({allowRemove:e})}hideAttachments(e){return this.set({hideAttachments:e})}relations(...e){return this.set({relations:e})}build(){let e=validateLiteralContent(this.data,[`content`]);if(this.extension&&e.type===`custom`){let t=this.extension.parameters.safeParse(cloneBuilderValue(e.parameters??{},[`content`,`parameters`]));if(!t.success)throw n.ValidationError.fromZodErrors(t.error.issues.map(e=>({path:[`content`,`parameters`,...e.path.map(String)],message:e.message})))}return e}},Je=class GroupBuilder{constructor(e,t,n,r={}){this.data=cloneBuilderValue({name:e,label:t,fields:n,...r},[`group`])}field(e,t){let{name:n,label:r,fields:i,...a}=this.data;return new GroupBuilder(n,r,[...i,{attribute:e,...t}],a)}fields(...e){let{name:t,label:n,fields:r,...i}=this.data;return new GroupBuilder(t,n,[...r,...e.map(e=>({attribute:e}))],i)}description(e){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),description:e})}collapsible(e=!1){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),collapsible:!0,collapsed:e})}presentation(){let{name:e,label:t,fields:n,...r}=this.data;return r}build(){requireBuilderName(this.data.name,[`group`,`name`]);try{validateLiteralContent({type:`form`,groups:[this.data]},[`group`])}catch(e){throw e instanceof n.ValidationError?new n.ValidationError(e.message,e.errors.map(e=>({...e,path:e.path[1]===`groups`?[`group`,...e.path.slice(3)]:e.path}))):e}return cloneBuilderValue(this.data,[`group`])}};function group(e,t){return new Je(e,t,[])}function collection(){return new j({type:`collection`})}function form$1(...e){return new j({type:`form`,groups:e.map(e=>`build`in e?e.build():e)})}function activity(){return new j({type:`activity`})}function richtext$1(e){return new j({type:`richtext`,attribute:e})}function documents(){return new j({type:`documents`})}function forms(){return new j({type:`forms`})}function emails(...e){return new j({type:`emails`,emailAttributes:e})}function meetings(...e){return new j({type:`meetings`,emailAttributes:e})}function custom(e,t){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw new n.ValidationError(`Expected registered extension declaration`,[{path:[`content`,`extension`],message:`Expected registered extension declaration`}]);let r=validateContentConfiguration({type:`custom`,extension:e.name,parameters:t},[`content`]);if(r.type!==`custom`)throw new n.ValidationError(`Expected custom content`,[]);let i=new j({...r,extension:e.name},e);return i.build(),i}const M={collection,form:form$1,activity,richtext:richtext$1,documents,forms,emails,meetings,custom};function validateFlagName(e){if(!/^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/.test(e))throw Error(`Invalid flag name "${e}". Flag names must be kebab-case (e.g., "architect-mode", "ai-features").`)}var BaseFlagBuilder=class{constructor(e,t,n){validateFlagName(e),this.flag={name:e,valueType:t,defaultValue:n,allowedLevels:[`global`,`tenant`,`user`]}}label(e){return this.flag.label=e,this}description(e){return this.flag.description=e,this}category(e){return this.flag.category=e,this}system(){return this.flag.system=!0,this}tenantScoped(){return this.flag.allowedLevels=[`global`,`tenant`],this}globalOnly(){return this.flag.allowedLevels=[`global`],this}allowedLevels(e){return this.flag.allowedLevels=[...e],this}build(){if(!this.flag.label?.trim())throw Error(`Flag "${this.flag.name}" must have a label. Use .label("Human-readable label").`);return{...this.flag,allowedLevels:[...this.flag.allowedLevels||[]]}}},BooleanFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`boolean`,!1)}defaultValue(e){return this.flag.defaultValue=e,this}enabledByDefault(){return this.flag.defaultValue=!0,this}},StringFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`string`,``)}defaultValue(e){return this.flag.defaultValue=e,this}},NumberFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`number`,0)}defaultValue(e){return this.flag.defaultValue=e,this}},JsonFlagBuilder=class extends BaseFlagBuilder{constructor(e,t){super(e,`json`,t)}defaultValue(e){return this.flag.defaultValue=e,this}};function booleanFlag(e){return new BooleanFlagBuilder(e)}function stringFlag(e){return new StringFlagBuilder(e)}function numberFlag(e){return new NumberFlagBuilder(e)}function jsonFlag(e,t){return new JsonFlagBuilder(e,t)}function duplicateFlagError(e){return new n.DuplicateError(`feature flag`,e,`Flag "${e}" is already registered. Each flag name must be unique.`)}function cloneFlagDefinition(e){return{...e,allowedLevels:[...e.allowedLevels]}}var FlagRegistry=class{constructor(){this.flags=new Map}register(e){if(this.flags.has(e.name))throw duplicateFlagError(e.name);this.flags.set(e.name,cloneFlagDefinition(e))}registerAll(e){let t=new Set;for(let n of e){if(this.flags.has(n.name)||t.has(n.name))throw duplicateFlagError(n.name);t.add(n.name)}for(let t of e)this.register(t)}get(e){let t=this.flags.get(e);return t?cloneFlagDefinition(t):void 0}getOrThrow(e){let t=this.get(e);if(!t)throw new n.NotFoundError(`Feature flag`,e,void 0,`Flag "${e}" is not registered. Available flags: ${this.listNames().join(`, `)}`);return t}has(e){return this.flags.has(e)}list(){return Array.from(this.flags.values(),cloneFlagDefinition)}listNames(){return Array.from(this.flags.keys())}unregister(e){return this.flags.delete(e)}clear(){this.flags.clear()}get size(){return this.flags.size}};const Ye=new FlagRegistry;function createFlagRegistry(){return new FlagRegistry}function emptyOverrides(){return{global:new Map,tenant:new Map,user:new Map}}function isActiveOverride(e,t){return e.expiresAt===void 0||e.expiresAt.getTime()>t}function indexOverrides(e,t){let n=new Map;for(let r of e){if(!isActiveOverride(r,t))continue;let e=r.flagName;n.has(e)||n.set(e,r)}return n}var FlagService=class{constructor(e){this.repository=e.repository,this.registry=e.registry,this.staticDefaults=new Map(e.staticDefaults?.map(e=>[e.name,e.value])??[])}async resolveAll(e={}){let t=this.collectFlagNames(),n=this.repository&&t.size>0?await this.getAllOverrides(e,[...t]):emptyOverrides();return this.resolveNames(t,n,e)}resolveAllStatic(){return this.resolveNames(this.collectFlagNames(),emptyOverrides(),{})}collectFlagNames(){let e=new Set;for(let t of this.registry.listNames())e.add(t);for(let t of this.staticDefaults.keys())e.add(t);return e}resolveNames(e,t,n){let r=new Map;for(let i of e)r.set(i,this.resolveValue(i,t,n));return r}async resolve(e,t={}){let n=this.repository?await this.getAllOverrides(t,[e]):emptyOverrides();return this.resolveWithSource(e,n,t)}async isEnabled(e,t={}){return(await this.resolve(e,t)).value===!0}async getValue(e,t={}){return(await this.resolve(e,t)).value}async setOverride(e,t,r,i={}){if(!this.repository)throw new n.SchemaError(`Cannot set override: no FeatureFlagsRepository configured. Add featureFlags to your DatabaseAdapter to enable runtime overrides.`,n.SchemaErrorCode.CONFIGURATION_REQUIRED);let a=this.registry.get(e);if(a&&!a.allowedLevels.includes(t)){let r=`Flag "${e}" does not allow ${t}-level overrides. Allowed levels: ${a.allowedLevels.join(`, `)}`;throw new n.ValidationError(r,[{path:[`level`],message:r}])}if(a?.system){let t=`Flag "${e}" is a system flag and cannot be overridden via API.`;throw new n.ValidationError(t,[{path:[`flagName`],message:t}])}await this.repository.setOverride({flagName:e,level:t,value:r,targetId:i.targetId,expiresAt:i.expiresAt,createdBy:i.createdBy})}async deleteOverride(e,t,r){if(!this.repository)throw new n.SchemaError(`Cannot delete override: no FeatureFlagsRepository configured.`,n.SchemaErrorCode.CONFIGURATION_REQUIRED);await this.repository.deleteOverride(e,t,r)}async getAllOverrides(e,t){if(!this.repository)return emptyOverrides();let[n,r,i]=await Promise.all([this.repository.getOverrides({level:`global`,flagNames:t}),e.tenantId?this.repository.getOverrides({level:`tenant`,targetId:e.tenantId,flagNames:t}):Promise.resolve([]),e.userId?this.repository.getOverrides({level:`user`,targetId:e.userId,flagNames:t}):Promise.resolve([])]),a=Date.now();return{global:indexOverrides(n,a),tenant:indexOverrides(r,a),user:indexOverrides(i,a)}}resolveValue(e,t,n){return this.resolveWithSource(e,t,n).value}resolveWithSource(e,t,n){let r=this.registry.get(e),i=r?.allowedLevels??[`global`,`tenant`,`user`];if(n.userId&&i.includes(`user`)){let r=t.user.get(e);if(r)return{name:e,value:r.value,source:`user`,sourceId:n.userId}}if(n.tenantId&&i.includes(`tenant`)){let r=t.tenant.get(e);if(r)return{name:e,value:r.value,source:`tenant`,sourceId:n.tenantId}}if(i.includes(`global`)){let n=t.global.get(e);if(n)return{name:e,value:n.value,source:`global`}}return this.staticDefaults.has(e)?{name:e,value:this.staticDefaults.get(e),source:`default`}:{name:e,value:r?.defaultValue??void 0,source:`default`}}};function createFlagService(e){return new FlagService(e)}const Xe=Symbol(`stndrds.native-object`);function markNativeDefinition(e){return Object.defineProperty(e,Xe,{value:!0,enumerable:!1}),e}var NativeObjectBuilder=class extends ObjectBuilder{build(){return markNativeDefinition(super.build())}};function nativeObject(e){return new NativeObjectBuilder(e)}function isNativeDefinition(e){return e[Xe]===!0}function cloneObjectDefinition(e){let t=structuredClone(e);return isNativeDefinition(e)?markNativeDefinition(t):t}var NativeObjectRegistryClass=class{constructor(){this.objects=new Map}register(e){let t=(Array.isArray(e)?e:[e]).map(e=>`build`in e&&typeof e.build==`function`?e.build():e),r=new Set;for(let e of t){if(this.validate(e),r.has(e.name))throw new n.DuplicateError(`object`,e.name,`[NativeObjectRegistry] Duplicate object name "${e.name}" within a single register() batch.`);r.add(e.name)}for(let e of t)this.objects.set(e.name,cloneObjectDefinition(e));return this}validate(t){if(!t.system){let e=`[NativeObjectRegistry] Cannot register object "${t.name}" (id: ${t.id}): missing system flag.\nNative objects must have system=true. Did you call .runtime() on the builder? Remove that call — objects are system:true by default.`;throw new n.ValidationError(e,[])}if(e.z(t.name)&&!isNativeDefinition(t))throw new n.ReservedObjectNameError(t.name,`registry`);if(this.objects.has(t.name)){let e=this.objects.get(t.name),r=`[NativeObjectRegistry] Duplicate object name "${t.name}":\n - Existing: "${e?.label}" (id: ${e?.id})\n - New: "${t.label}" (id: ${t.id})\nPlease use unique names for each native object.`;throw new n.DuplicateError(`object`,t.name,r)}}getByName(e){let t=this.objects.get(e);return t?cloneObjectDefinition(t):void 0}getByNameOrThrow(e){let t=this.getByName(e);if(!t){let t=`[NativeObjectRegistry] Native object "${e}" not found.\nAvailable objects: ${this.listNames().join(`, `)}`;throw new n.NotFoundError(`Native object`,e,n.SchemaErrorCode.OBJECT_NOT_FOUND,t)}return t}getAll(){return Array.from(this.objects.values(),cloneObjectDefinition)}listNames(){return Array.from(this.objects.keys())}has(e){return this.objects.has(e)}get size(){return this.objects.size}clear(){this.objects.clear()}summary(){let e=this.getAll();return[`[NativeObjectRegistry] ${this.size} native object(s) registered:`,...e.map(e=>` - ${e.name}: "${e.label}" (${e.attributes.length} attributes)`)].join(`
|
|
3
3
|
`)}debug(e){let t=this.summary();return e?.(t),t}};const Ze=new NativeObjectRegistryClass,Qe=new WeakSet;function markSystemView(e){return Qe.add(e.definition),e}function isSystemViewDefinition(e){return typeof e==`object`&&!!e&&Qe.has(e)}const $e=`## Overview
|
|
4
4
|
|
|
5
5
|
Describe in one or two sentences what this skill does and the outcome it produces. The agent reads this page when it uses the skill — write instructions for the agent, not documentation for people.
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as ee,S as v,T as y,U as b,V as te,W as ne,X as re,Y as ie,Z as ae,_ as oe,a as se,b as ce,c as le,d as ue,et as de,f as fe,g as pe,h as me,i as he,j as ge,k as _e,l as ve,m as ye,n as be,o as xe,p as Se,q as Ce,r as we,s as Te,t as Ee,u as x,v as De,w as Oe,x as ke,y as Ae,z as je}from"./view-config.schema-B4AkqLKQ.mjs";import{AccessDeniedError as Me,AttributeInUseError as Ne,AttributeNotFoundError as Pe,ChangeTypeNotSupportedError as Fe,ConcurrentModificationError as Ie,DestructiveSyncNotAllowedError as Le,DuplicateError as S,ForbiddenError as Re,MemoryNotFoundError as ze,MigrationTimeoutError as Be,NotFoundError as C,NotImplementedError as Ve,ObjectNotFoundError as He,ObjectReferencedError as Ue,OrphanSystemAttributeError as We,ProtectedResourceError as Ge,ProtectedRoleError as Ke,RecordNotFoundError as qe,RecordReferencedError as Je,RepositoryError as Ye,ReservedObjectNameError as Xe,RoleNotFoundError as Ze,SchemaError as w,SchemaErrorCode as T,SchemaPlanNotFoundError as Qe,SearchBackendError as $e,StorageError as et,SyncCascadeError as tt,SyncConflictError as nt,SyncError as rt,SystemEntityImmutableError as it,ValidationError as E,isAttributeInUseError as at,isNotFoundError as ot,isObjectReferencedError as st,isProtectedResourceError as ct,isRecordReferencedError as lt,isSchemaError as ut,isValidationError as dt}from"./exceptions.mjs";import{A as D,C as ft,D as pt,E as mt,F as ht,I as gt,L as _t,M as vt,N as yt,O as bt,P as xt,R as St,S as Ct,T as wt,_ as Tt,a as Et,b as Dt,c as Ot,d as kt,f as At,g as jt,h as Mt,i as Nt,j as Pt,k as Ft,l as It,m as Lt,n as Rt,o as zt,p as Bt,r as Vt,s as Ht,t as Ut,u as Wt,v as Gt,w as Kt,x as O,y as k,z as A}from"./config-_sOeudpS.mjs";import{a as qt,c as Jt,i as Yt,l as Xt,n as Zt,o as Qt,r as $t,s as j,t as en,u as tn}from"./utils-fXIvFFl6.mjs";import{a as nn,c as rn,d as an,f as on,i as sn,m as cn,o as ln,p as M,r as un,s as dn,u as fn}from"./object-tz3P8Pgh.mjs";import{n as pn,r as mn,t as hn}from"./text-C8Lb-NFo.mjs";import{i as gn,n as _n,r as vn}from"./phone-DHUJN7SI.mjs";import{n as yn,t as bn}from"./core-BLHhNykL.mjs";import{createCheckboxValidator as xn}from"./validation/primitives/checkbox.mjs";import{createDateValidator as Sn}from"./validation/primitives/date.mjs";import{createNumberValidator as Cn}from"./validation/primitives/number.mjs";import{MEMORY_DESCRIPTION_MAX_LENGTH as wn,MEMORY_NAME_MAX_LENGTH as Tn,SKILL_DESCRIPTION_MAX_LENGTH as En,SKILL_NAME_MAX_LENGTH as Dn,getCountryDisplayNameByIso3 as N}from"@stndrds/constants";import{z as P}from"zod";const On=[`fyi`,`task`,`question`,`handoff`,`system`],kn=[`low`,`normal`,`high`,`urgent`],An=[`public`,`internal`,`sensitive`],jn=[`unread`,`read`,`archived`,`snoozed`],Mn=[`none`,`pending`,`processing`,`completed`,`dismissed`,`expired`,`failed`],Nn=`agent.session.waiting_human`,Pn=`agent.task.assigned`,Fn=`agent.question.requested`,In=[Nn,Pn,Fn],Ln=[`name`,`type`],Rn=[`required`,`hidden`,`archived`,`deprecated`,`defaultValue`,`config`,`order`,`unique`],zn=[`label`,`description`,`placeholder`,`icon`],Bn=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`],Vn=`*`;function relationTargetsOf(e){return e.type!==`relation`||!Array.isArray(e.targets)?[]:e.targets.map(e=>e.object).filter(e=>e!==`*`)}function isUniversalRelation(e){return e.targets.length===1&&e.targets[0].object===`*`}function isBilateralRelation(e){return e.bilateral!==void 0}function inferInverseCardinality(e){return`many`}function isAttributeSortable(e){return d(e)}const Hn=[`record`,`object`,`attribute`,`view`,`user`,`role`,`settings`,`file`,`agent`,`schema_source`],Un=`record.created,record.updated,record.deleted,record.restored,record.purged,object.created,object.updated,object.deleted,attribute.created,attribute.updated,attribute.deleted,view.created,view.updated,view.deleted,schema_source.applied,schema_source.removed,user.created,user.invited,user.updated,user.deleted,user.login,user.logout,role.created,role.updated,role.deleted,role.assigned,role.revoked,settings.updated,file.uploaded,file.updated,file.deleted`.split(`,`);function isTerminalState(e){return e.phase===`terminal`}function sessionStateToLegacyStatus(e){switch(e.phase){case`running`:return`active`;case`queued`:return`idle`;case`parked`:if(e.parkedOn===void 0)throw new w(`parked state without parkedOn`,T.INVARIANT_VIOLATION);return e.parkedOn===`agents`?`waiting_agents`:`waiting_human`;case`terminal`:if(e.outcome===void 0)throw new w(`terminal state without outcome`,T.INVARIANT_VIOLATION);return e.outcome}}function legacyStatusToSessionState(e){switch(e){case`active`:return{phase:`running`};case`idle`:return{phase:`queued`};case`waiting_human`:return{phase:`parked`,parkedOn:`human`,humanRequestIds:[]};case`waiting_agents`:return{phase:`parked`,parkedOn:`agents`};default:return{phase:`terminal`,outcome:e}}}const Wn=[`completed`,`failed`,`cancelled`,`timeout`,`expired`];function isTerminalSessionStatus(e){return Wn.includes(e)}const Gn=[`idle`,`completed`,`waiting_human`,`waiting_agents`,`cancelled`,`failed`,`timeout`];function isClaimableSessionStatus(e){return Gn.includes(e)}const Kn=Object.freeze({mutation:`ask`,destructive:`ask`,outward:`ask`}),qn=[`active`,`completed`,`abandoned`],Jn=[`openai`,`anthropic`,`google`,`spacexai`,`deepseek`,`moonshotai`,`alibaba`,`mistral`,`minimax`,`meta`,`zai`],Yn=[`standard`,`fast`],Xn=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`];function agentDisplayName(e){return e.label?.trim()||e.name}const Zn=[`approval-requested`,`approval-responded`,`approval-dispatched`],Qn=[`streaming`,`running`,`pending`,...Zn];function isOpenToolPartState(e){return Qn.includes(e)}function isToolApprovalState(e){return Zn.includes(e)}const $n=[`CREDITS_EXHAUSTED`];function isSystemPartCode(e){return typeof e==`string`&&$n.includes(e)}function compareAgentSessionMessages(e,t){let n=e.createdAt.getTime()-t.createdAt.getTime();return n===0?e.id.localeCompare(t.id):n}function orderAgentSessionMessages(e){return[...e].sort(compareAgentSessionMessages)}const er=[`pending`,`in_progress`,`completed`,`blocked`],tr=50,nr=80,rr=500,ir=`session-state`,ar=`__stndrdsNativeUiPartIds`,or=1;function invalidNativePartIds(){throw new E(`Native agent UI part IDs metadata is invalid`,[])}function isPlainRecord$1(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function nativeAgentUIPartIdMetadataKey(e,t){if(e.type===`text`||e.type===`reasoning`)return`${e.type}:${t}`;if(e.type===`tool`)return`tool:${e.toolCallId}`}function parseNativeAgentUIPartIdsMetadata(e){let t=e.metadata?.[ar];isPlainRecord$1(t)||invalidNativePartIds(),(Object.keys(t).length!==2||t.schemaVersion!==1||!isPlainRecord$1(t.partIds))&&invalidNativePartIds();let n=new Map;for(let[t,r]of e.parts.entries()){let e=nativeAgentUIPartIdMetadataKey(r,t);if(!e||n.has(e)){e&&invalidNativePartIds();continue}n.set(e,r)}let r=Object.entries(t.partIds);r.length!==n.size&&invalidNativePartIds();let i=new Map,a={};for(let[e,t]of r){let r=n.get(e);r&&typeof t==`string`&&t.length>0||invalidNativePartIds();let o=i.get(t);o&&(r.type===`tool`||o!==r.type)&&invalidNativePartIds(),r.type===`tool`&&t!==r.toolCallId&&invalidNativePartIds(),i.set(t,r.type),a[e]=t}return a}const sr=16e3,cr=3200,lr=6400,ur=16e3,dr=65536,fr=15e3,pr=1e4,mr=5e3,hr=`google/gemini-3.5-transcribe-live`,gr={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2},_r=[`web`,`presentation`,`document`,`spreadsheet`,`image`,`code`,`other`],vr=[`ephemeral`,`conversation`,`persistent`],yr=[`source`,`preview`,`entrypoint`,`asset`],br=5;function getErrorMessage(e){return e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`?`message`in e&&typeof e.message==`string`?e.message:JSON.stringify(e):String(e)}function isFormDefinition(e){return typeof e==`object`&&!!e&&`slots`in e&&`steps`in e&&`name`in e&&typeof e.name==`string`&&Array.isArray(e.slots)&&Array.isArray(e.steps)}const xr=[`relation`,`multiRelation`,`formula`,`rollup`,`document`,`richtext`,`user`];function isFormSlotFieldRef(e){return e.type===`slot`}function isFormFreeFieldRef(e){return e.type===`free`}function resolveFieldRequired(e){return e.fieldRequired===void 0?e.slotMode===`create`&&e.attributeRequired===!0:e.fieldRequired}function getSlotFieldTargets(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}function formFieldKey(e){return isFormSlotFieldRef(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}function formFieldFlatKey(e){return isFormSlotFieldRef(e)?e.attribute:e.attribute.name}function readFormFieldValue(e,t){return e[formFieldKey(t)]??e[formFieldFlatKey(t)]}function isFormFieldsRow(e){return e.type===`fields`}function isFormHeadingRow(e){return e.type===`heading`}function isFormSeparatorRow(e){return e.type===`separator`}function isFormTextRow(e){return e.type===`text`}var NoopGeocodingAdapter=class{async autocomplete(){return await Promise.resolve([])}async reverse(){return await Promise.resolve(null)}async geocode(){return await Promise.resolve(null)}};const F=[`read`,`create`,`update`,`delete`,`manage`];function actionsToAccessLevel(e){return e.length===0?`none`:e.length===1&&e[0]===`read`?`read-only`:e.length===F.length&&F.every(t=>e.includes(t))?`full`:`custom`}function accessLevelToActions(e){switch(e){case`full`:return[...F];case`read-only`:return[`read`];case`none`:return[]}}function resolvePropertyDefinitions(e){let t=e.properties;if(!t)return[];if(Array.isArray(t))return t;let n=t;return Array.isArray(n.definitions)?n.definitions:[]}function hasOptions(e){return e.type===`select`||e.type===`status`||e.type===`multiselect`}const Sr=`Notetaker`,Cr={systemPrompt:null,meetingRecordingPolicy:`none`,meetingBotDisplayName:Sr},wr=[`active`,`suspended`],Tr=[`architect`,`manual`,`auto`],Er=[`square`,`landscape`,`portrait`],Dr=[`none`,`estimated`,`exact`];function parseCountMode(e){if(typeof e==`string`&&Dr.includes(e))return e;throw new E(`countMode must be one of: ${Dr.join(`, `)} (received: ${String(e)})`,[])}function parseOptionalCountMode(e){return e===void 0?void 0:parseCountMode(e)}const Or=1e4,kr=[`storage.bytes`,`members.seats`,`data.live_records`];function isEmptyObject(e){return e==null||typeof e==`object`&&Object.keys(e).length===0}function isNotEmpty(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0}function toUndefinedIfEmpty(e){return isNotEmpty(e)?e:void 0}function computeByteMagnitude(e){if(e<=0)return{value:0,unitIndex:0};let t=1e3,n=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return{value:Number.parseFloat((e/t**n).toFixed(1)),unitIndex:n}}const Ar=[`B`,`KB`,`MB`,`GB`,`TB`];function formatByteSize(e){let{value:t,unitIndex:n}=computeByteMagnitude(e);return`${t} ${Ar[n]}`}const jr={ATTACHMENTS:`attachments`};function isDocumentAttribute(e){return e.type===`document`}function matchesAccepts(e,t){if(!t||t.length===0)return!0;let n=e.name.toLowerCase();return t.some(t=>t.endsWith(`/*`)?e.mimeType.startsWith(t.slice(0,-1)):t.startsWith(`.`)?n.endsWith(t.toLowerCase()):e.mimeType===t)}const Mr=Object.freeze([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`,`multiselect`,`location`]);function buildPropertySchema(e){let t=[];for(let n of e){let e=n.build();if(!Mr.includes(e.type))throw Error(`Property type "${e.type}" is not supported in .qualifyWith()`);t.push(e)}return{definitions:t}}const Nr=`__`;function parseQualifiedAttribute(e){let t=e.indexOf(`__`);return t<=0||t+2>=e.length?{kind:`scalar`,attribute:e}:{kind:`qualified`,root:e.slice(0,t),property:e.slice(t+2)}}function buildQualifiedAttribute(e,t){return`${e}__${t}`}function isDateRangeValue(e){return typeof e==`object`&&!!e&&typeof e.start==`string`}function normalizeDateValue(e,t){return M(e)?null:isDateRangeValue(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e==`string`?t.endDate?{start:e,end:null}:e:null}function dateValueStart(e){return typeof e==`string`&&e!==``?e:isDateRangeValue(e)&&e.start!==``?e.start:null}const Pr=`—`;function formatText(e){return String(e)}function formatCheckbox(e){return e?`Yes`:`No`}function formatNumber(e,t){if(typeof e!=`number`)return String(e);if(t.renderAs===`rating`)return`${e}/${t.max??5}`;let n=t.decimals;return t.unit===`integer`?e.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}):t.unit===`percentage`?(e/100).toLocaleString(void 0,{style:`percent`,minimumFractionDigits:n,maximumFractionDigits:n}):e.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n})}function formatCurrency(e,t){if(typeof e!=`object`||!e)return String(e);let n=e;return`value`in n&&`code`in n?`${n.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})} ${n.code}`:String(e)}function formatDate(e){if(isDateRangeValue(e)){let t=formatDate(e.start);return e.end?`${t} → ${formatDate(e.end)}`:t}if(e instanceof Date)return e.toISOString().split(`T`)[0];if(typeof e==`string`){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toISOString().split(`T`)[0]}return String(e)}function formatPhone(e){if(typeof e!=`object`||!e)return String(e);let t=e;return`phoneNumber`in t?t.phoneNumber?t.countryCode?_n(t):t.phoneNumber:``:String(e)}function formatLocationValue(e,t=`full`){if(typeof e!=`object`||!e)return``;let n=e,r=[];switch(t){case`country`:n.country&&r.push(N(n.country));break;case`state`:n.state&&r.push(n.state),n.country&&r.push(N(n.country));break;case`city`:n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push(N(n.country));break;case`coordinates`:n.latitude!==void 0&&n.longitude!==void 0&&r.push(`${n.latitude}, ${n.longitude}`);break;case`address`:n.address&&r.push(n.address),n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push(N(n.country));break;default:n.address&&r.push(n.address),n.address2&&r.push(n.address2),n.city&&r.push(n.city),n.state&&r.push(n.state),n.postalCode&&r.push(n.postalCode),n.country&&r.push(N(n.country))}return r.join(`, `)}function formatLocation(e,t){return typeof e!=`object`||!e?String(e):formatLocationValue(e,t.granularity??`full`)||`—`}function formatSelect(e,t){return typeof e==`string`?t.options?.find(t=>t.value===e)?.label??String(e):String(e)}function formatMultiselect(e,t){return Array.isArray(e)?t.options?e.map(e=>t.options.find(t=>t.value===e)?.label).filter(Boolean).join(`, `):e.join(`, `):String(e)}function formatAttributeValue(e,t){if(M(e))return`—`;switch(t.type){case`text`:return formatText(e);case`checkbox`:return formatCheckbox(e);case`number`:return formatNumber(e,t);case`currency`:return formatCurrency(e,t);case`date`:return formatDate(e);case`phone`:return formatPhone(e);case`location`:return formatLocation(e,t);case`select`:case`status`:return formatSelect(e,t);case`multiselect`:return formatMultiselect(e,t);case`user`:case`relation`:return Array.isArray(e)?e.join(`, `):String(e);default:return Array.isArray(e)?e.join(`, `):String(e)}}const Fr=[`UPPER`,`LOWER`,`capitalize`,`trim`],Ir=[`prefix`,`suffix`,`wrap`,`default`],I=[...Fr,...Ir],L=P.string().min(1,`labelExpression cannot be empty`).refine(e=>isLabelExpression(e),{message:`labelExpression must contain at least one {{ attribute }} interpolation`}).refine(e=>!/\{\{\s*\}\}/.test(e),{message:`labelExpression contains empty {{ }} interpolation`}).refine(e=>{let t=/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g,n;for(;(n=t.exec(e))!==null;){let e=n[1];if(!I.includes(e))return!1}return!0},{message:`Invalid pipe name. Valid pipes: ${I.join(`, `)}`});function validateLabelExpression(e){let t=L.safeParse(e);return t.success?{success:!0,attributes:extractAttributeNames(e)}:{success:!1,error:t.error.issues[0]?.message??`Invalid labelExpression`}}function applyPipe(e,t){let{name:n,args:r}=parsePipeExpression(t);switch(n){case`UPPER`:return e.toUpperCase();case`LOWER`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|\s)\S/g,e=>e.toUpperCase());case`trim`:return e.trim();case`prefix`:return e?`${r[0]??``}${e}`:``;case`suffix`:return e?`${e}${r[0]??``}`:``;case`wrap`:return e?`${r[0]??``}${e}${r[1]??``}`:``;case`default`:return e||r[0]||``;default:return e}}function applyPipes(e,t){let n=e;for(let e of t)n=applyPipe(n,e);return n}function getValue(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}const Lr=`(Untitled)`;function parsePipeExpression(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return{name:e,args:[]};let n=t[1],r=t[2];if(!r)return{name:n,args:[]};let i=[],a=/["']([^"']*?)["']/g,o;for(;(o=a.exec(r))!==null;)i.push(o[1]);return{name:n,args:i}}function*templateBlocks(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return;let r=e.indexOf(`}`,n+2);if(r<0)return;if(e[r+1]!==`}`){t=r+1;continue}t=r+2;let i=e.slice(n+2,r);i.length>0&&(yield{start:n,end:t,expr:i})}}function resolveLabelBlock(e,t){let n=e.split(`||`).map(e=>e.trim()),r=n[n.length-1].split(`|`).map(e=>e.trim());n[n.length-1]=r[0];let i=r.slice(1).filter(Boolean),a=n.filter(Boolean),o=``;for(let e of a){let n=toText(getValue(t,e));if(n!==``){o=n;break}}return applyPipes(o,i)}function renderLabelExpression(e,t,n=Lr){let r=[],i=0;for(let n of templateBlocks(e))r.push(e.slice(i,n.start),resolveLabelBlock(n.expr,t)),i=n.end;return r.push(e.slice(i)),r.join(``).trim()||n}function toText(e){if(e==null||typeof e==`function`)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return e.map(toText).filter(Boolean).join(`,`);let t=e.toString;return typeof t==`function`&&t!==Object.prototype.toString?String(e):``}function isLabelExpression(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return!1;let r=e.indexOf(`}}`,n+2);if(r<0)return!1;if(e.slice(n+2,r).trim().length>0)return!0;t=r+2}return!1}function extractAttributeNames(e){let t=[];for(let n of templateBlocks(e)){let e=n.expr.trim();if(!e)continue;let r=e.split(`||`).map(e=>e.trim()),i=r[r.length-1];r[r.length-1]=i.split(`|`)[0].trim();for(let e of r){if(!e)continue;let n=e.split(`.`)[0];n&&!t.includes(n)&&t.push(n)}}return t}const Rr=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function getSingleAttributeFromExpression(e){let t=e.trim().match(Rr);return t?t[1]:null}function getEditableLabelAttribute(e,t){let r=getSingleAttributeFromExpression(e);if(r===null)return null;let i=t.find(e=>e.name===r);return!i||i.type!==`text`||n(i).authoring.readOnly?null:i}const zr=/\{\{\s*props\./;function applyRelationProps(e,t,n){if(!zr.test(e))return e;let r={},i=new Map(n?.map(e=>[e.name,e]));if(t)for(let[e,n]of Object.entries(t)){if(n==null)continue;let t=i.get(e);if(t){let i=formatAttributeValue(n,t);r[e]=i===`—`?``:i}else r[e]=n}return renderLabelExpression(e,{props:r},``).replace(/\(\s*\)/g,``).replace(/\[\s*\]/g,``).replace(/\s*[-—|:]\s*$/g,``).replace(/\s{2,}/g,` `).trim()}function relationPropertyDefs(e){if(e?.type===`relation`)return e.properties?.definitions}function qualifiedPropertyDefs(e){if(e?.type===`relation`||e?.type===`document`)return e.properties?.definitions}function extractValueRefs(e){if(M(e))return[];if(typeof e==`string`)return[{id:e}];if(Array.isArray(e))return e.flatMap(e=>extractValueRefs(e));if(typeof e==`object`&&`id`in e){let t=e;if(typeof t.id==`string`)return[{id:t.id,props:t.props}]}return[]}function getUserDisplayName(e){let t=[e.firstName,e.lastName].map(e=>e?.trim()).filter(Boolean).join(` `);return t===``?e.email?.split(`@`)[0]??``:t}const Br=/\p{L}|\p{N}/u;function deriveInitials(e,t){let n=e?.trim()??``;if(n===``)return t;let r=n.split(/\s+/),i=(r.length===1?n.split(`@`)[0].split(/[._-]/):r).map(e=>{let t=e.match(Br)?.[0];return t===void 0?``:[...t.toUpperCase()][0]??``}).filter(Boolean).slice(0,2).join(``);return i===``?t:i}const Vr=`__creatorRootActorId`;function getRecordCreatorPrincipalId(e){let t=e.metadata?.[Vr];return typeof t==`string`&&t.length>0?t:e.createdBy}function includesAction(e,t){return e?.includes(`*`)===!0||e?.includes(t)===!0}function buildPermissionFlags(e){return{canRead:includesAction(e,`read`),canCreate:includesAction(e,`create`),canUpdate:includesAction(e,`update`),canDelete:includesAction(e,`delete`),canManage:includesAction(e,`manage`)}}const Hr=new Set([`id`,`name`,`label`,`type`,`required`,`system`,`unique`,`order`]),R={PEOPLE:`people`,WORKSPACE:`workspace`,ARCHITECT:`architect`,FEATURE_FLAGS:`feature-flags`,FILES:`files`,VIEWS:`views`,FORMS:`forms`,DOCUMENTS:`documents`,AUDIT:`audit`,API_KEYS:`api-keys`,CONNECTORS:`connectors`,ENV_VARS:`env-vars`,SESSION:`session`},Ur=[R.PEOPLE,R.WORKSPACE,R.ARCHITECT,R.FEATURE_FLAGS,R.FILES,R.VIEWS,R.FORMS,R.DOCUMENTS,R.AUDIT,R.API_KEYS,R.CONNECTORS,R.ENV_VARS,R.SESSION],Wr={people:`People`,workspace:`Workspace`,architect:`Architect`,"feature-flags":`Feature flags`,files:`Files`,views:`Views`,forms:`Forms`,documents:`Documents`,audit:`Audit`,"api-keys":`API keys`,connectors:`Connected accounts`,"env-vars":`Environment variables`,session:`Agent sessions`},Gr={OWNER:`owner`,MEMBER:`member`,AGENT_DEFAULT:`agent_default`,REFLEX_DEFAULT:`reflex_default`},Kr={owner:`Owner`,member:`Member`,agent_default:`Agent Default`,reflex_default:`Reflex Default`},qr={owner:`Full access to all platform features and data`,member:`Can view, create, edit and delete business data`,agent_default:`Default role for AI agents — CRUD on records plus documents and files`,reflex_default:`Default role for reflexes — no data access; each reflex is granted exactly what its rehearsal showed it uses`},Jr=[`read`,`create`,`update`,`delete`,`manage`],Yr=[`read`,`create`,`update`,`delete`],Xr=[`read`,`create`,`update`,`delete`],Zr={owner:{system:[{target:`*`,actions:Jr}],object:[{target:`*`,actions:Jr}]},member:{system:[{target:`people`,actions:[`read`]},{target:`workspace`,actions:[`read`]},{target:`connectors`,actions:Yr},{target:`files`,actions:Xr},{target:`documents`,actions:Xr}],object:[{target:`*`,actions:Jr}]},agent_default:{system:[{target:`documents`,actions:[`read`,`create`,`update`]},{target:`files`,actions:[`read`,`create`,`update`]},{target:`env-vars`,actions:[`read`]},{target:`session`,actions:[`observe`]}],object:[{target:`*`,actions:[`read`,`create`,`update`,`delete`]}]},reflex_default:{system:[],object:[]}};function isDefaultRole(e){return Object.values(Gr).includes(e)}const Qr={maxConcurrentRuns:3,retryPolicy:{maxRetries:3,backoffMs:1e3,backoffMultiplier:2},timeoutMs:3e5};var AgentBuilder=class{constructor(e){if(!e.name||e.name.trim().length===0)throw new E(`Agent name is required`,[]);this.bp={name:e.name,system:!0,visibility:`workspace`,triggers:[]}}description(e){return this.bp.description=e,this}label(e){return this.bp.label=e,this}icon(e){return this.bp.icon=e,this}systemPrompt(e){return this.bp.systemPrompt=e,this}model(e,t,n){return this.bp.model={provider:e,model:t,...n},this}tools(e){return this.bp.tools=[...e],this}schedule(e){return this.bp.schedule={...e,enabled:e.enabled??!0},this}config(e){let t=this.bp.config??Qr,n=e.inference===void 0?t.inference:{...t.inference,...e.inference};return this.bp.config={...t,...e,...n===void 0?{}:{inference:n}},this}delegation(e){return Object.assign(this.bp,e),this}mcpServers(e){return this.bp.mcpServers=Array.isArray(e)?[...e]:e,this}approval(e){return this.bp.approval={...Kn,...this.bp.approval,...e},this}visibility(e){return this.bp.visibility=e,this}requiresPermission(e,t){return this.bp.requiredPermission={resource:e,action:t},this}trigger(e,t,n){return this.bp.triggers.push({name:e,eventType:t,...n,enabled:n?.enabled??!0}),this}runtime(){return this.bp.system=!1,this}build(){if(!this.bp.systemPrompt)throw new E(`Agent "${this.bp.name}": systemPrompt is required`,[]);if(!this.bp.model)throw new E(`Agent "${this.bp.name}": model is required`,[]);if(this.bp.system&&this.bp.visibility===`private`)throw new E(`Agent "${this.bp.name}": system agents must use workspace visibility`,[]);return wt(this.bp.triggers,e=>e.name,e=>new E(`Agent "${this.bp.name}": duplicate trigger name "${e}"`,[])),{...this.bp,visibility:this.bp.visibility??`workspace`,config:this.bp.config??Qr,systemPrompt:this.bp.systemPrompt,model:this.bp.model}}};function agent(e){return new AgentBuilder(e)}const $r=`@stndrds/schema`;function createStandardSchemaProps(e){return{version:1,vendor:$r,validate:t=>{let n=e.safeParse(t);return n.success?{value:n.data}:{issues:n.error.issues.map(e=>({message:e.message,path:e.path}))}}}}function isStandardSchema(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`&&e[`~standard`].version===1}function asMutableArray(e){return e}var BaseAttributeBuilder=class{get"~standard"(){return createStandardSchemaProps(an(this.build()))}constructor(e,t,n){mt(t),bt(n),this.attr={name:t,label:n,type:e,required:!1,system:!0}}setRequired(e){this.attr.required=e}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=!1,this}hidden(){return this.attr.hidden=!0,this}placeholder(e){return this.attr.placeholder=e,this}description(e){return this.attr.description=e,this}icon(e){return pt(e,`attribute "${this.attr.name}"`),this.attr.icon=e,this}order(e){return this.attr.order=e,this}defaultValue(e){return(`defaultValue`in this.attr||![`formula`,`rollup`].includes(this.attr.type))&&(this.attr.defaultValue=e),this}metadata(e){return this.attr.metadata=e,this}build(){return this.attr}},TextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`text`,e,t)}minLength(e){return this.attr.minLength=e,this}maxLength(e){return this.attr.maxLength=e,this}pattern(e){return this.attr.pattern=e,this.attr.format=void 0,this}multiline(e=!0){return this.attr.multiline=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}email(){return this.attr.format=`email`,this.attr.pattern=void 0,this}url(){return this.attr.format=`url`,this.attr.pattern=void 0,this}slug(){return this.attr.format=`slug`,this.attr.pattern=void 0,this}};function text(e){return new TextAttributeBuilder(e.name,e.label)}var RichtextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`richtext`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function richtext(e){return new RichtextAttributeBuilder(e.name,e.label)}var NumberAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`number`,e,t)}min(e){return this.attr.min=e,this}max(e){return this.attr.max=e,this}integer(){return this.attr.unit=`integer`,this.attr.decimals=0,this}decimal(e=2){return this.attr.unit=`decimal`,this.attr.decimals=e,this}percentage(){return this.attr.unit=`percentage`,this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function number(e){return new NumberAttributeBuilder(e.name,e.label)}var CheckboxAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`checkbox`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function checkbox(e){return new CheckboxAttributeBuilder(e.name,e.label)}var DateAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`date`,e,t)}format(e){return this.attr.dateFormat=e,this}minDate(e){return this.attr.minDate=e,this}maxDate(e){return this.attr.maxDate=e,this}endDate(){return this.attr.endDate=!0,this.asPhantomState()}includeTime(){return this.attr.includeTime=!0,this}timeFormat(e){return this.attr.timeFormat=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function date(e){return new DateAttributeBuilder(e.name,e.label)}var PhoneAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`phone`,e,t)}defaultCountry(e){return this.attr.defaultCountryCode=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function phone(e){return new PhoneAttributeBuilder(e.name,e.label)}var CurrencyAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`currency`,e,t)}defaultCurrency(e){return this.attr.defaultCurrency=e,this}allowedCurrencies(e){return this.attr.allowedCurrencies=e,this}allowNegative(e=!0){return this.attr.allowNegative=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function currency(e){return new CurrencyAttributeBuilder(e.name,e.label)}var StatusAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`status`,e,t)}options(e){let t=asMutableArray(e);return D(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return D(this.attr.name??`unknown`,t),this.attr.options.push(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function status(e){return new StatusAttributeBuilder(e.name,e.label)}var SelectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`select`,e,t)}options(e){let t=asMutableArray(e);return D(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return D(this.attr.name??`unknown`,t),this.attr.options.push(e),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function select(e){return new SelectAttributeBuilder(e.name,e.label)}var MultiselectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`multiselect`,e,t)}options(e){let t=asMutableArray(e);return D(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return D(this.attr.name??`unknown`,t),this.attr.options.push(e),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function multiselect(e){return new MultiselectAttributeBuilder(e.name,e.label)}var LocationAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`location`,e,t)}granularity(e){return this.attr.granularity=e,this}defaultCountry(e){return this.attr.defaultCountry=e,this}allowedCountries(e){return this.attr.allowedCountries=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function location(e){return new LocationAttributeBuilder(e.name,e.label)}var UserAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`user`,e,t),this.attr.types=[`user`,`agent`]}types(e){let t=[...new Set(e)];if(t.length===0)throw Error(`[AttributeBuilder] user.types must contain at least one type.`);return this.attr.types=t,this}multiple(){return this.attr.multiple=!0,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function user(e){return new UserAttributeBuilder(e.name,e.label)}var BaseRelationAttributeBuilder=class extends BaseAttributeBuilder{to(e,t){let n={object:e,...t};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:`*`}],this}qualifyWith(...e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.qualifyWith() must be called AFTER .to(). Example: relation({ name: "companies" }).to("companies").qualifyWith(...)`);return this.attr.properties=buildPropertySchema(e),this}bilateral(e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.bilateral() must be called AFTER .to(). Example: relation({ name: "company" }).to("companies").bilateral({ ... })`);if(t.length>1)throw Error(`Bilateral relations are not supported for polymorphic relations (multiple .to() targets).`);if(isUniversalRelation(this.attr))throw Error(`Bilateral relations are not supported for universal relations (.toAny()).`);let n=t[0]?.object;if(!n)throw new E(`Bilateral relation requires one target object`,[{path:[`bilateral`,`object`],message:`Bilateral relation requires one target object`}]);if(e.object&&e.object!==n){let t=`Bilateral inverse object ${e.object} must match relation target ${n}`;throw new E(t,[{path:[`bilateral`,`object`],message:t}])}return this.attr.bilateral={...e,object:n},this}},SingleRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t){super(`relation`,e,t),this.attr.cardinality=`one`,this.attr.targets=[]}many(){let e=new MultiRelationAttributeBuilder(this.attr.name,this.attr.label??``,{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===!1&&e.runtime(),this.attr.hidden&&e.hidden(),this.attr.placeholder&&e.placeholder(this.attr.placeholder),this.attr.description&&e.description(this.attr.description),this.attr.icon&&e.icon(this.attr.icon),this.attr.order!==void 0&&e.order(this.attr.order),this.attr.metadata&&e.metadata(this.attr.metadata),e}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}},MultiRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t,n){super(`relation`,e,t),this.attr.cardinality=`many`,this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(!0)}maxItems(e){return this.attr.maxItems=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function relation(e){return new SingleRelationAttributeBuilder(e.name,e.label)}var FormulaAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`formula`,e,t),this.attr.required=!1}expression(e){return this.attr.expression=e,this}returns(e){return this.attr.returnType=e,this}decimals(e){return this.attr.decimals=e,this}required(){throw Error(`Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function formula(e){return new FormulaAttributeBuilder(e.name,e.label)}var RollupAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`rollup`,e,t),this.attr.required=!1}from(e){return this.attr.relationAttribute=e,this}aggregate(e){return this.attr.targetAttribute=e,this}using(e){return this.attr.function=e,this}decimals(e){return this.attr.decimals=e,this}path(e){return this.attr.relationPath=e,this}targetType(e){return this.attr.targetAttributeType=e,this}targetOptions(e){return this.attr.targetAttributeOptions=e,this}targetCurrency(e){return this.attr.targetCurrencyCode=e,this}build(){let e=this.attr.function,t=this.attr.targetAttributeType;if(e===`original`&&t!==void 0&&t!==`select`&&t!==`status`&&t!==`multiselect`){let e=this.attr.relationAttribute??`relation`,n=this.attr.targetAttribute??`field`;throw new w(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${t}") was given. To surface a plain ${t} value from a related record, use a formula instead — e.g. formula({ name: "${this.attr.name}", label: "…" }).expression("${e}.${n}").`,T.VALIDATION_FAILED)}return super.build()}required(){throw Error(`Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function rollup(e){return new RollupAttributeBuilder(e.name,e.label)}var DocumentAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`document`,e,t)}accepts(e){return this.attr.accepts=e,this}maxFileSize(e){return this.attr.maxFileSize=e,this}qualifyWith(...e){return this.attr.properties=buildPropertySchema(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function document(e){return new DocumentAttributeBuilder(e.name,e.label)}function buildSlotFieldRef(e,t,n){let[r,...i]=Array.isArray(e)?e:[e];return{type:`slot`,slotId:r,additionalSlotIds:i.length>0?i:void 0,attribute:t,label:n?.label,required:n?.required,tooltip:n?.tooltip}}var FormRowBuilder=class{constructor(e,t,n){this._finalized=!1,this.stepBuilder=e,this.rowData={id:t,order:n,type:`fields`,fields:[]}}field(e,t,n){return this.rowData.fields.push(buildSlotFieldRef(e,t,n)),this}freeField(e,t){let n={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression};return this.rowData.fields.push(n),this}row(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).row(e)}heading(e,t){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).heading(e,t)}separator(){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).separator()}text(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).text(e)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData))}},FormStepBuilder=class{constructor(e,t,n){this.rowOrder=0,this.formBuilder=e,this.stepData={id:t,label:n,rows:[]}}description(e){return this.stepData.description=e,this}field(e,t,n){this.rowOrder++;let r=`row-${this.stepData.id}-${this.rowOrder}`,i=buildSlotFieldRef(e,t,n),a={id:r,order:this.rowOrder,type:`fields`,fields:[i]};return this.stepData.rows.push(a),this}freeField(e,t){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,r={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression},i={id:n,order:this.rowOrder,type:`fields`,fields:[r]};return this.stepData.rows.push(i),this}row(e){return this.rowOrder++,new FormRowBuilder(this,e,this.rowOrder)}heading(e,t){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`heading`,content:e,level:t};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let e={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`separator`};return this.stepData.rows.push(e),this}text(e){this.rowOrder++;let t={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`text`,content:e};return this.stepData.rows.push(t),this}step(e,t){return this.formBuilder._finalizeStep(this.stepData).step(e,t)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(e){return e.fields.length>0&&this.stepData.rows.push(e),this}_getData(){return this.stepData}},FormBuilder=class{constructor(e,t){this.data={slots:[],steps:[],status:`draft`,version:1},this.validateName(e),this.data.name=e,this.data.label=t}description(e){return this.data.description=e,this}icon(e){return this.data.icon=e,this}status(e){return this.data.status=e,this}metadata(e){return this.data.metadata=e,this}slot(e,t,n){if(this.data.slots.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate slot id: "${e}"`);let r={id:e,objectName:t,label:n.label,mode:n.mode??`create`,color:n.color,icon:n.icon};return this.data.slots.push(r),this}step(e,t){if(this.data.steps.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate step id: "${e}"`);return new FormStepBuilder(this,e,t)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.data}_finalizeStep(e){return this.data.steps.push(e),this}validateName(e){let t=P.string().min(1,`Form name cannot be empty`).max(63,`Form name is too long (max 63 characters)`).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:`Invalid form name format. Name must be in kebab-case: 'client-onboarding', 'contact-creation'`});try{t.parse(e)}catch(e){throw e instanceof P.ZodError?Error(`[FormBuilder] ${e.issues[0].message}`):e}}validateRequiredData(){if(this.data.slots.length===0)throw Error(`[FormBuilder] At least one slot is required. Use .slot() to add slots.`);if(this.data.steps.length===0)throw Error(`[FormBuilder] At least one step is required. Use .step() to add steps.`)}validateSlotReferences(){let e=new Map(this.data.slots.map(e=>[e.id,e.objectName]));for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(r.type!==`slot`)continue;let n=getSlotFieldTargets(r);for(let r of n)if(!e.has(r))throw Error(`[FormBuilder] Step "${t.id}" references unknown slot "${r}". Declare it with .slot("${r}", ...) first.`);let i=new Set(n.map(t=>e.get(t)));if(i.size>1)throw Error(`[FormBuilder] Step "${t.id}" field on attribute "${r.attribute}" targets slots of different objects (${[...i].join(`, `)}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let e=[...I,`join`];for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(!isFormFreeFieldRef(r)||!r.prefillExpression)continue;let n=r.prefillExpression,i=`prefillExpression on free field "${r.attribute.name}" in step "${t.id}"`;if(!isLabelExpression(n))throw Error(`[FormBuilder] ${i} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(n))throw Error(`[FormBuilder] ${i} contains empty {{ }} interpolation.`);for(let t of n.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g)){let n=t[1];if(!e.includes(n))throw Error(`[FormBuilder] ${i} uses invalid pipe "${n}". Valid pipes: ${e.join(`, `)}`)}}}validateFreeFields(){let e=new Set(xr);for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n)){for(let r of n.fields)if(isFormFreeFieldRef(r)){let n=r.attribute.type;if(e.has(n))throw Error(`[FormBuilder] Free field in step "${t.id}" uses forbidden attribute type "${n}". Forbidden types: ${xr.join(`, `)}`)}}}};function form(e,t){return new FormBuilder(e,t)}function resolveBuiltInTransform(e){return{text:`toString`,richtext:`toString`,number:`toNumber`,currency:`toNumber`,date:`toDate`,checkbox:`toBoolean`}[e]}var MigrationBuilder=class{constructor(e){this.operations=[],this.touchedAttributes=new Set,this.version=e}assertNotTouched(e,t){if(this.touchedAttributes.has(e))throw new E(`[MigrationBuilder] Conflicting operations on attribute "${e}": it was already modified earlier in this migration (attempted: ${t}).`,[])}renameAttribute(e,t){return this.assertNotTouched(e,`rename_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`rename_attribute`,from:e,to:t}),this}changeType(e,t,n,r){this.assertNotTouched(e,`change_type`),this.touchedAttributes.add(e);let i=r?.transform?resolveBuiltInTransform(n):void 0;return this.operations.push({type:`change_type`,name:e,from:t,to:n,transform:i}),this}removeAttribute(e){return this.assertNotTouched(e,`remove_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`remove_attribute`,name:e}),this}addAttribute(e){return this.assertNotTouched(e.name,`add_attribute`),this.touchedAttributes.add(e.name),this.operations.push({type:`add_attribute`,attribute:e}),this}updateConfig(e,t){return this.assertNotTouched(e,`update_config`),this.touchedAttributes.add(e),this.operations.push({type:`update_config`,name:e,from:{},to:t}),this}build(){return{version:this.version,operations:[...this.operations]}}};function validateObjectExpressions(e){let{name:t,labelExpression:n,embeddingExpression:r}=e;if(!n)throw new w(`Object "${t}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,T.VALIDATION_FAILED);let i=L.safeParse(n);if(!i.success){let e=i.error.issues[0]?.message??`Invalid labelExpression`;throw new w(`Invalid labelExpression for "${t}": ${e}`,T.VALIDATION_FAILED)}if(r!==void 0){let e=L.safeParse(r);if(!e.success){let n=e.error.issues[0]?.message??`Invalid embeddingExpression`;throw new w(`Invalid embeddingExpression for "${t}": ${n}`,T.VALIDATION_FAILED)}}}var ObjectBuilder=class{get"~standard"(){return createStandardSchemaProps(fn(this.build()))}constructor(e){this._migrations=[],this._sealed=!1,this._toleratedAttributes=[],this.validateName(e.name),this.obj={name:e.name,label:e.label,attributes:[],system:!0},e.id&&(this.obj.id=e.id)}description(e){return this.obj.description=e,this}pluralLabel(e){return this._pluralLabel=e,this}icon(e){return this.obj.icon=e,this}runtime(){return this.obj.system=!1,this}sealed(){return this._sealed=!0,this}tolerate(e){return this._toleratedAttributes=[...this._toleratedAttributes,...e],this}attribute(e){return this.pushAttributes([e]),this}attributes(e){return this.pushAttributes(e),this}pushAttributes(e){let t=e.map(e=>`build`in e&&typeof e.build==`function`?e.build():e);wt([...this.obj.attributes,...t],e=>e.name,e=>new S(`attribute`,e,`Object "${this.obj.name}": duplicate attribute name "${e}"`)),this.obj.attributes.push(...t)}metadata(e){return this.obj.metadata={...this.obj.metadata,...e},this}order(e){return this.obj.metadata={...this.obj.metadata,order:e},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:!0},this}labelExpression(e){return this._labelExpression=e,this}embeddingExpression(e){return this._embeddingExpression=e,this}documentLayout(e){if(e.presets)for(let t of e.presets)validatePresetStructure(t.id,t.structure,1);return this.obj.documentLayout=e,this}migration(e,t){if(e<2)throw Error(`[ObjectBuilder] Migration version must be >= 2 (version 1 is implicit). Got: ${e}`);if(this._migrations.some(t=>t.version===e))throw Error(`[ObjectBuilder] Duplicate migration version: ${e}`);let n=new MigrationBuilder(e);return t(n),this._migrations.push(n.build()),this}build(){if(!this.obj.name)throw new E(`[ObjectBuilder] Missing required field: name`,[{path:[`name`],message:`name is required`}]);if(!this.obj.label)throw new E(`[ObjectBuilder] Missing required field: label`,[{path:[`label`],message:`label is required`}]);validateObjectExpressions({name:this.obj.name,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression});let e=[...this._migrations].sort((e,t)=>e.version-t.version);for(let t=0;t<e.length;t++){let n=t+2;if(e[t].version!==n)throw Error(`[ObjectBuilder] Migration versions must be sequential starting at 2. Expected version ${n}, got ${e[t].version}.`)}let t=e.length>0?e[e.length-1].version:1;return{...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,schema_version:t,migrations:e,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(e){e!==void 0&&Ft(e)}};function object(e){if(A(e.name))throw new Xe(e.name,`builder`);return new ObjectBuilder(e)}function validatePresetStructure(e,t,n){let fail=(t,n)=>{throw new E(t,[{path:[`documentLayout`,`presets`,e],message:n}])};n>5&&fail(`Preset structure exceeds max depth of 5`,`Preset structure too deep`);let r=new Set;for(let i of t){let t=i.title.trim();t.length===0&&fail(`Folder preset node title is required`,`Empty folder title`),t.includes(`/`)&&fail(`Folder preset node title cannot contain /`,`Folder title contains /: "${t}"`),r.has(t)&&fail(`Folder preset sibling titles must be unique`,`Duplicate folder title: "${t}"`),r.add(t),i.children&&i.children.length>0&&validatePresetStructure(e,i.children,n+1)}}function cloneBuilderValue(e,t){try{return structuredClone(e)}catch{let e=`Builder configuration must contain cloneable data`;throw new E(e,[{path:t,message:e}])}}function requireBuilderName(e,t){if(typeof e!=`string`||e.trim().length===0)throw new E(`Name must not be blank`,[{path:t,message:`Name must not be blank`}])}function validateContentConfiguration(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new E(`Invalid content configuration`,[{path:t,message:`Expected content configuration`}]);for(let n of[`name`,`label`,`placement`])if(Object.hasOwn(e,n)){let e=`Independent content configuration cannot define ${n}`;throw new E(e,[{path:[...t,n],message:e}])}let n=x.safeParse({...e,name:`content`,placement:`main`});if(!n.success)throw E.fromZodErrors(n.error.issues.map(e=>({path:[...t,...e.path.map(String)],message:e.message})));n.data.type===`form`&&n.data.groups.forEach((e,n)=>requireBuilderName(e.name,[...t,`groups`,String(n),`name`]));let{name:r,label:i,placement:a,...o}=n.data;return cloneBuilderValue(o,t)}function validateLiteralContent(e,t){return validateContentConfiguration(e,t),cloneBuilderValue(e,t)}function collectionSourceAddress(e){return e.relation===void 0?{kind:`object`,object:e.object}:e.object===void 0?{kind:`related`,relation:e.relation}:{kind:`relatedFrom`,object:e.object,relation:e.relation}}function collectionSourceAddressOf(e){if(!e||typeof e!=`object`)return;let t=`object`in e?e.object:void 0,n=`relation`in e?e.relation:void 0;if(typeof t==`string`&&typeof n==`string`)return{kind:`relatedFrom`,object:t,relation:n};if(typeof t==`string`&&n===void 0)return{kind:`object`,object:t};if(typeof n==`string`&&t===void 0)return{kind:`related`,relation:n}}function requireRecordContentContext(e,t,n){if(t!==`record`){let t=`Content "${e}" requires record context. In a collection view only a collection that lists a whole object, or a custom content that does not require a record, is allowed.`;throw new E(t,[{path:n,message:t}])}}function resolveContentNavigation(e){let t=e.openMode??`page`;return{openMode:t,createMode:e.createMode??t}}function resolveCollectionActions(e,t){return[...new Set(t)].filter(t=>e.actions===void 0||e.actions.includes(t))}var ei=class ViewBuilder{constructor(e,t=[]){this.kind=`view`,this.data=cloneBuilderValue(e,[`views`,`0`]),this.extensions=t.map(e=>e&&{...e})}for(e){return new ViewBuilder({...this.data,object:e},this.extensions)}default(){return new ViewBuilder({...this.data,default:!0},this.extensions)}description(e){return new ViewBuilder({...this.data,description:e},this.extensions)}icon(e){return new ViewBuilder({...this.data,icon:e},this.extensions)}place(e,t,n,r){let i=[`views`,`0`,`contents`,String(this.data.contents.length)],a,o;try{typeof n==`object`&&n&&`build`in n&&typeof n.build==`function`?(a=validateContentConfiguration(n.build(),i),o=n.extension):a=validateContentConfiguration(n,i)}catch(e){throw e instanceof E?new E(e.message,e.errors.map(e=>({...e,path:e.path[0]===`content`?[...i,...e.path.slice(1)]:e.path}))):e}let s={...a,name:e,label:t,placement:r},c=[...this.data.contents,s];return new ViewBuilder({...this.data,contents:c},[...this.extensions,o])}tab(e,t,n){return this.place(e,t,n,`main`)}aside(e,t,n){return this.place(e,t,n,`aside`)}build(){let e=[`views`,`0`];requireBuilderName(this.data.name,[...e,`name`]),requireBuilderName(this.data.object,[...e,`object`]);let t=he.safeParse(this.data);if(!t.success)throw E.fromZodErrors(t.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return this.data.contents.forEach((t,n)=>{let r=[...e,`contents`,String(n)];requireBuilderName(t.name,[...r,`name`]),t.type===`form`&&t.groups.forEach((e,t)=>requireBuilderName(e.name,[...r,`groups`,String(t),`name`])),(t.type===`custom`?this.extensions[n]?.requiresRecord:t.type!==`collection`||collectionSourceAddress(t.source).kind!==`object`)&&requireRecordContentContext(t.name,this.data.context,r)}),{kind:`view`,definition:cloneBuilderValue(this.data,e)}}};function detailView(e,t){return new ei({name:e,label:t,object:void 0,context:`record`,contents:[]})}function listView(e,t){return new ei({name:e,label:t,object:void 0,context:`collection`,contents:[]})}function relationProperty(e){return requireBuilderName(e,[`relationProperty`]),{relationProperty:e}}var z=class ContentBuilder{constructor(e,t){this.data=cloneBuilderValue(e,[`content`]),this.extension=t===void 0?void 0:Object.freeze({name:t.name,requiresRecord:t.requiresRecord,parameters:t.parameters})}set(e){return new ContentBuilder({...this.data,...e},this.extension)}icon(e){return this.set({icon:e})}object(e){return this.data.type===`forms`?this.set({objectName:e}):this.set({source:{object:e}})}related(e){return this.set({source:{relation:e}})}relatedFrom(e,t){return this.set({source:{object:e,relation:t}})}layout(e){let{layout:t,groupByAttribute:n,columnSizing:r,kanbanColumnOrder:i,kanbanColumnVisibility:a,kanbanPinnedColumns:o,...s}={...this.data,layout:void 0,groupByAttribute:void 0,columnSizing:void 0,kanbanColumnOrder:void 0,kanbanColumnVisibility:void 0,kanbanPinnedColumns:void 0};return new ContentBuilder({...s,...e},this.extension)}table(){return this.layout({layout:`table`})}list(){return this.layout({layout:`list`})}kanban(e){return this.layout({layout:`kanban`,groupByAttribute:e})}columns(...e){return this.set({columns:e})}filter(e){return this.set({filters:e})}sort(e,t=`asc`){let n=[...`sorts`in this.data&&Array.isArray(this.data.sorts)?this.data.sorts:[],{attribute:e,direction:t}];return this.set({sorts:n})}actions(...e){return this.set({actions:e})}openMode(e){return this.set({openMode:e})}createMode(e){return this.set({createMode:e})}visibility(e){return this.set({visibility:e})}descriptionAttribute(e){return this.set({descriptionAttribute:e})}displayAttributes(...e){return this.set({displayAttributes:e})}columnSizing(e){return this.set({columnSizing:e})}kanbanColumnOrder(...e){return this.set({kanbanColumnOrder:e})}kanbanColumnVisibility(e){return this.set({kanbanColumnVisibility:e})}kanbanPinnedColumns(...e){return this.set({kanbanPinnedColumns:e})}formColumns(e){return this.set({formColumns:e})}density(e){return this.set({density:e})}titleAttribute(e){return this.set({titleAttribute:e})}allowUpload(e){return this.set({allowUpload:e})}allowRemove(e){return this.set({allowRemove:e})}hideAttachments(e){return this.set({hideAttachments:e})}relations(...e){return this.set({relations:e})}build(){let e=validateLiteralContent(this.data,[`content`]);if(this.extension&&e.type===`custom`){let t=this.extension.parameters.safeParse(cloneBuilderValue(e.parameters??{},[`content`,`parameters`]));if(!t.success)throw E.fromZodErrors(t.error.issues.map(e=>({path:[`content`,`parameters`,...e.path.map(String)],message:e.message})))}return e}},ti=class GroupBuilder{constructor(e,t,n,r={}){this.data=cloneBuilderValue({name:e,label:t,fields:n,...r},[`group`])}field(e,t){let{name:n,label:r,fields:i,...a}=this.data;return new GroupBuilder(n,r,[...i,{attribute:e,...t}],a)}fields(...e){let{name:t,label:n,fields:r,...i}=this.data;return new GroupBuilder(t,n,[...r,...e.map(e=>({attribute:e}))],i)}description(e){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),description:e})}collapsible(e=!1){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),collapsible:!0,collapsed:e})}presentation(){let{name:e,label:t,fields:n,...r}=this.data;return r}build(){requireBuilderName(this.data.name,[`group`,`name`]);try{validateLiteralContent({type:`form`,groups:[this.data]},[`group`])}catch(e){throw e instanceof E?new E(e.message,e.errors.map(e=>({...e,path:e.path[1]===`groups`?[`group`,...e.path.slice(3)]:e.path}))):e}return cloneBuilderValue(this.data,[`group`])}};function group(e,t){return new ti(e,t,[])}function collection(){return new z({type:`collection`})}function form$1(...e){return new z({type:`form`,groups:e.map(e=>`build`in e?e.build():e)})}function activity(){return new z({type:`activity`})}function richtext$1(e){return new z({type:`richtext`,attribute:e})}function documents(){return new z({type:`documents`})}function forms(){return new z({type:`forms`})}function emails(...e){return new z({type:`emails`,emailAttributes:e})}function meetings(...e){return new z({type:`meetings`,emailAttributes:e})}function custom(e,t){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw new E(`Expected registered extension declaration`,[{path:[`content`,`extension`],message:`Expected registered extension declaration`}]);let n=validateContentConfiguration({type:`custom`,extension:e.name,parameters:t},[`content`]);if(n.type!==`custom`)throw new E(`Expected custom content`,[]);let r=new z({...n,extension:e.name},e);return r.build(),r}const B={collection,form:form$1,activity,richtext:richtext$1,documents,forms,emails,meetings,custom};function validateFlagName(e){if(!/^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/.test(e))throw Error(`Invalid flag name "${e}". Flag names must be kebab-case (e.g., "architect-mode", "ai-features").`)}var BaseFlagBuilder=class{constructor(e,t,n){validateFlagName(e),this.flag={name:e,valueType:t,defaultValue:n,allowedLevels:[`global`,`tenant`,`user`]}}label(e){return this.flag.label=e,this}description(e){return this.flag.description=e,this}category(e){return this.flag.category=e,this}system(){return this.flag.system=!0,this}tenantScoped(){return this.flag.allowedLevels=[`global`,`tenant`],this}globalOnly(){return this.flag.allowedLevels=[`global`],this}allowedLevels(e){return this.flag.allowedLevels=[...e],this}build(){if(!this.flag.label?.trim())throw Error(`Flag "${this.flag.name}" must have a label. Use .label("Human-readable label").`);return{...this.flag,allowedLevels:[...this.flag.allowedLevels||[]]}}},BooleanFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`boolean`,!1)}defaultValue(e){return this.flag.defaultValue=e,this}enabledByDefault(){return this.flag.defaultValue=!0,this}},StringFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`string`,``)}defaultValue(e){return this.flag.defaultValue=e,this}},NumberFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`number`,0)}defaultValue(e){return this.flag.defaultValue=e,this}},JsonFlagBuilder=class extends BaseFlagBuilder{constructor(e,t){super(e,`json`,t)}defaultValue(e){return this.flag.defaultValue=e,this}};function booleanFlag(e){return new BooleanFlagBuilder(e)}function stringFlag(e){return new StringFlagBuilder(e)}function numberFlag(e){return new NumberFlagBuilder(e)}function jsonFlag(e,t){return new JsonFlagBuilder(e,t)}function duplicateFlagError(e){return new S(`feature flag`,e,`Flag "${e}" is already registered. Each flag name must be unique.`)}function cloneFlagDefinition(e){return{...e,allowedLevels:[...e.allowedLevels]}}var FlagRegistry=class{constructor(){this.flags=new Map}register(e){if(this.flags.has(e.name))throw duplicateFlagError(e.name);this.flags.set(e.name,cloneFlagDefinition(e))}registerAll(e){let t=new Set;for(let n of e){if(this.flags.has(n.name)||t.has(n.name))throw duplicateFlagError(n.name);t.add(n.name)}for(let t of e)this.register(t)}get(e){let t=this.flags.get(e);return t?cloneFlagDefinition(t):void 0}getOrThrow(e){let t=this.get(e);if(!t)throw new C(`Feature flag`,e,void 0,`Flag "${e}" is not registered. Available flags: ${this.listNames().join(`, `)}`);return t}has(e){return this.flags.has(e)}list(){return Array.from(this.flags.values(),cloneFlagDefinition)}listNames(){return Array.from(this.flags.keys())}unregister(e){return this.flags.delete(e)}clear(){this.flags.clear()}get size(){return this.flags.size}};const ni=new FlagRegistry;function createFlagRegistry(){return new FlagRegistry}function emptyOverrides(){return{global:new Map,tenant:new Map,user:new Map}}function isActiveOverride(e,t){return e.expiresAt===void 0||e.expiresAt.getTime()>t}function indexOverrides(e,t){let n=new Map;for(let r of e){if(!isActiveOverride(r,t))continue;let e=r.flagName;n.has(e)||n.set(e,r)}return n}var FlagService=class{constructor(e){this.repository=e.repository,this.registry=e.registry,this.staticDefaults=new Map(e.staticDefaults?.map(e=>[e.name,e.value])??[])}async resolveAll(e={}){let t=this.collectFlagNames(),n=this.repository&&t.size>0?await this.getAllOverrides(e,[...t]):emptyOverrides();return this.resolveNames(t,n,e)}resolveAllStatic(){return this.resolveNames(this.collectFlagNames(),emptyOverrides(),{})}collectFlagNames(){let e=new Set;for(let t of this.registry.listNames())e.add(t);for(let t of this.staticDefaults.keys())e.add(t);return e}resolveNames(e,t,n){let r=new Map;for(let i of e)r.set(i,this.resolveValue(i,t,n));return r}async resolve(e,t={}){let n=this.repository?await this.getAllOverrides(t,[e]):emptyOverrides();return this.resolveWithSource(e,n,t)}async isEnabled(e,t={}){return(await this.resolve(e,t)).value===!0}async getValue(e,t={}){return(await this.resolve(e,t)).value}async setOverride(e,t,n,r={}){if(!this.repository)throw new w(`Cannot set override: no FeatureFlagsRepository configured. Add featureFlags to your DatabaseAdapter to enable runtime overrides.`,T.CONFIGURATION_REQUIRED);let i=this.registry.get(e);if(i&&!i.allowedLevels.includes(t)){let n=`Flag "${e}" does not allow ${t}-level overrides. Allowed levels: ${i.allowedLevels.join(`, `)}`;throw new E(n,[{path:[`level`],message:n}])}if(i?.system){let t=`Flag "${e}" is a system flag and cannot be overridden via API.`;throw new E(t,[{path:[`flagName`],message:t}])}await this.repository.setOverride({flagName:e,level:t,value:n,targetId:r.targetId,expiresAt:r.expiresAt,createdBy:r.createdBy})}async deleteOverride(e,t,n){if(!this.repository)throw new w(`Cannot delete override: no FeatureFlagsRepository configured.`,T.CONFIGURATION_REQUIRED);await this.repository.deleteOverride(e,t,n)}async getAllOverrides(e,t){if(!this.repository)return emptyOverrides();let[n,r,i]=await Promise.all([this.repository.getOverrides({level:`global`,flagNames:t}),e.tenantId?this.repository.getOverrides({level:`tenant`,targetId:e.tenantId,flagNames:t}):Promise.resolve([]),e.userId?this.repository.getOverrides({level:`user`,targetId:e.userId,flagNames:t}):Promise.resolve([])]),a=Date.now();return{global:indexOverrides(n,a),tenant:indexOverrides(r,a),user:indexOverrides(i,a)}}resolveValue(e,t,n){return this.resolveWithSource(e,t,n).value}resolveWithSource(e,t,n){let r=this.registry.get(e),i=r?.allowedLevels??[`global`,`tenant`,`user`];if(n.userId&&i.includes(`user`)){let r=t.user.get(e);if(r)return{name:e,value:r.value,source:`user`,sourceId:n.userId}}if(n.tenantId&&i.includes(`tenant`)){let r=t.tenant.get(e);if(r)return{name:e,value:r.value,source:`tenant`,sourceId:n.tenantId}}if(i.includes(`global`)){let n=t.global.get(e);if(n)return{name:e,value:n.value,source:`global`}}return this.staticDefaults.has(e)?{name:e,value:this.staticDefaults.get(e),source:`default`}:{name:e,value:r?.defaultValue??void 0,source:`default`}}};function createFlagService(e){return new FlagService(e)}const ri=Symbol(`stndrds.native-object`);function markNativeDefinition(e){return Object.defineProperty(e,ri,{value:!0,enumerable:!1}),e}var NativeObjectBuilder=class extends ObjectBuilder{build(){return markNativeDefinition(super.build())}};function nativeObject(e){return new NativeObjectBuilder(e)}function isNativeDefinition(e){return e[ri]===!0}function cloneObjectDefinition(e){let t=structuredClone(e);return isNativeDefinition(e)?markNativeDefinition(t):t}var NativeObjectRegistryClass=class{constructor(){this.objects=new Map}register(e){let t=(Array.isArray(e)?e:[e]).map(e=>`build`in e&&typeof e.build==`function`?e.build():e),n=new Set;for(let e of t){if(this.validate(e),n.has(e.name))throw new S(`object`,e.name,`[NativeObjectRegistry] Duplicate object name "${e.name}" within a single register() batch.`);n.add(e.name)}for(let e of t)this.objects.set(e.name,cloneObjectDefinition(e));return this}validate(e){if(!e.system){let t=`[NativeObjectRegistry] Cannot register object "${e.name}" (id: ${e.id}): missing system flag.\nNative objects must have system=true. Did you call .runtime() on the builder? Remove that call — objects are system:true by default.`;throw new E(t,[])}if(A(e.name)&&!isNativeDefinition(e))throw new Xe(e.name,`registry`);if(this.objects.has(e.name)){let t=this.objects.get(e.name),n=`[NativeObjectRegistry] Duplicate object name "${e.name}":\n - Existing: "${t?.label}" (id: ${t?.id})\n - New: "${e.label}" (id: ${e.id})\nPlease use unique names for each native object.`;throw new S(`object`,e.name,n)}}getByName(e){let t=this.objects.get(e);return t?cloneObjectDefinition(t):void 0}getByNameOrThrow(e){let t=this.getByName(e);if(!t){let t=`[NativeObjectRegistry] Native object "${e}" not found.\nAvailable objects: ${this.listNames().join(`, `)}`;throw new C(`Native object`,e,T.OBJECT_NOT_FOUND,t)}return t}getAll(){return Array.from(this.objects.values(),cloneObjectDefinition)}listNames(){return Array.from(this.objects.keys())}has(e){return this.objects.has(e)}get size(){return this.objects.size}clear(){this.objects.clear()}summary(){let e=this.getAll();return[`[NativeObjectRegistry] ${this.size} native object(s) registered:`,...e.map(e=>` - ${e.name}: "${e.label}" (${e.attributes.length} attributes)`)].join(`
|
|
2
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as ee,S as v,T as y,U as b,V as te,W as ne,X as re,Y as ie,Z as ae,_ as oe,a as se,b as ce,c as le,d as ue,et as de,f as fe,g as pe,h as me,i as he,j as ge,k as _e,l as ve,m as ye,n as be,o as xe,p as Se,q as Ce,r as we,s as Te,t as Ee,u as x,v as De,w as Oe,x as ke,y as Ae,z as je}from"./view-config.schema-B4AkqLKQ.mjs";import{AccessDeniedError as Me,AttributeInUseError as Ne,AttributeNotFoundError as Pe,ChangeTypeNotSupportedError as Fe,ConcurrentModificationError as Ie,DestructiveSyncNotAllowedError as Le,DuplicateError as S,ForbiddenError as Re,MemoryNotFoundError as ze,MigrationTimeoutError as Be,NotFoundError as C,NotImplementedError as Ve,ObjectNotFoundError as He,ObjectReferencedError as Ue,OrphanSystemAttributeError as We,ProtectedResourceError as Ge,ProtectedRoleError as Ke,RecordNotFoundError as qe,RecordReferencedError as Je,RepositoryError as Ye,ReservedObjectNameError as Xe,RoleNotFoundError as Ze,SchemaError as w,SchemaErrorCode as T,SchemaPlanNotFoundError as Qe,SearchBackendError as $e,StorageError as et,SyncCascadeError as tt,SyncConflictError as nt,SyncError as rt,SystemEntityImmutableError as it,ValidationError as E,isAttributeInUseError as at,isNotFoundError as ot,isObjectReferencedError as st,isProtectedResourceError as ct,isRecordReferencedError as lt,isSchemaError as ut,isValidationError as dt}from"./exceptions.mjs";import{A as D,C as ft,D as pt,E as mt,F as ht,I as gt,L as _t,M as vt,N as yt,O as bt,P as xt,R as St,S as Ct,T as wt,_ as Tt,a as Et,b as Dt,c as Ot,d as kt,f as At,g as jt,h as Mt,i as Nt,j as Pt,k as Ft,l as It,m as Lt,n as Rt,o as zt,p as Bt,r as Vt,s as Ht,t as Ut,u as Wt,v as Gt,w as Kt,x as O,y as k,z as A}from"./config-_sOeudpS.mjs";import{a as qt,c as Jt,i as Yt,l as Xt,n as Zt,o as Qt,r as $t,s as j,t as en,u as tn}from"./utils-fXIvFFl6.mjs";import{a as nn,c as rn,d as an,f as on,i as sn,m as cn,o as ln,p as M,r as un,s as dn,u as fn}from"./object-DSRy1coV.mjs";import{n as pn,r as mn,t as hn}from"./text-C8Lb-NFo.mjs";import{i as gn,n as _n,r as vn}from"./phone-BawtTYVi.mjs";import{n as yn,t as bn}from"./core-BLHhNykL.mjs";import{createCheckboxValidator as xn}from"./validation/primitives/checkbox.mjs";import{createDateValidator as Sn}from"./validation/primitives/date.mjs";import{createNumberValidator as Cn}from"./validation/primitives/number.mjs";import{MEMORY_DESCRIPTION_MAX_LENGTH as wn,MEMORY_NAME_MAX_LENGTH as Tn,SKILL_DESCRIPTION_MAX_LENGTH as En,SKILL_NAME_MAX_LENGTH as Dn,getCountryDisplayNameByIso3 as N}from"@stndrds/constants";import{z as P}from"zod";const On=[`fyi`,`task`,`question`,`handoff`,`system`],kn=[`low`,`normal`,`high`,`urgent`],An=[`public`,`internal`,`sensitive`],jn=[`unread`,`read`,`archived`,`snoozed`],Mn=[`none`,`pending`,`processing`,`completed`,`dismissed`,`expired`,`failed`],Nn=`agent.session.waiting_human`,Pn=`agent.task.assigned`,Fn=`agent.question.requested`,In=[Nn,Pn,Fn],Ln=[`name`,`type`],Rn=[`required`,`hidden`,`archived`,`deprecated`,`defaultValue`,`config`,`order`,`unique`],zn=[`label`,`description`,`placeholder`,`icon`],Bn=[`text`,`richtext`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`location`,`select`,`multiselect`,`user`,`relation`,`formula`,`rollup`,`document`],Vn=`*`;function relationTargetsOf(e){return e.type!==`relation`||!Array.isArray(e.targets)?[]:e.targets.map(e=>e.object).filter(e=>e!==`*`)}function isUniversalRelation(e){return e.targets.length===1&&e.targets[0].object===`*`}function isBilateralRelation(e){return e.bilateral!==void 0}function inferInverseCardinality(e){return`many`}function isAttributeSortable(e){return d(e)}const Hn=[`record`,`object`,`attribute`,`view`,`user`,`role`,`settings`,`file`,`agent`,`schema_source`],Un=`record.created,record.updated,record.deleted,record.restored,record.purged,object.created,object.updated,object.deleted,attribute.created,attribute.updated,attribute.deleted,view.created,view.updated,view.deleted,schema_source.applied,schema_source.removed,user.created,user.invited,user.updated,user.deleted,user.login,user.logout,role.created,role.updated,role.deleted,role.assigned,role.revoked,settings.updated,file.uploaded,file.updated,file.deleted`.split(`,`);function isTerminalState(e){return e.phase===`terminal`}function sessionStateToLegacyStatus(e){switch(e.phase){case`running`:return`active`;case`queued`:return`idle`;case`parked`:if(e.parkedOn===void 0)throw new w(`parked state without parkedOn`,T.INVARIANT_VIOLATION);return e.parkedOn===`agents`?`waiting_agents`:`waiting_human`;case`terminal`:if(e.outcome===void 0)throw new w(`terminal state without outcome`,T.INVARIANT_VIOLATION);return e.outcome}}function legacyStatusToSessionState(e){switch(e){case`active`:return{phase:`running`};case`idle`:return{phase:`queued`};case`waiting_human`:return{phase:`parked`,parkedOn:`human`,humanRequestIds:[]};case`waiting_agents`:return{phase:`parked`,parkedOn:`agents`};default:return{phase:`terminal`,outcome:e}}}const Wn=[`completed`,`failed`,`cancelled`,`timeout`,`expired`];function isTerminalSessionStatus(e){return Wn.includes(e)}const Gn=[`idle`,`completed`,`waiting_human`,`waiting_agents`,`cancelled`,`failed`,`timeout`];function isClaimableSessionStatus(e){return Gn.includes(e)}const Kn=Object.freeze({mutation:`ask`,destructive:`ask`,outward:`ask`}),qn=[`active`,`completed`,`abandoned`],Jn=[`openai`,`anthropic`,`google`,`spacexai`,`deepseek`,`moonshotai`,`alibaba`,`mistral`,`minimax`,`meta`,`zai`],Yn=[`standard`,`fast`],Xn=[`none`,`minimal`,`low`,`medium`,`high`,`xhigh`];function agentDisplayName(e){return e.label?.trim()||e.name}const Zn=[`approval-requested`,`approval-responded`,`approval-dispatched`],Qn=[`streaming`,`running`,`pending`,...Zn];function isOpenToolPartState(e){return Qn.includes(e)}function isToolApprovalState(e){return Zn.includes(e)}const $n=[`CREDITS_EXHAUSTED`];function isSystemPartCode(e){return typeof e==`string`&&$n.includes(e)}function compareAgentSessionMessages(e,t){let n=e.createdAt.getTime()-t.createdAt.getTime();return n===0?e.id.localeCompare(t.id):n}function orderAgentSessionMessages(e){return[...e].sort(compareAgentSessionMessages)}const er=[`pending`,`in_progress`,`completed`,`blocked`],tr=50,nr=80,rr=500,ir=`session-state`,ar=`__stndrdsNativeUiPartIds`,or=1;function invalidNativePartIds(){throw new E(`Native agent UI part IDs metadata is invalid`,[])}function isPlainRecord$1(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function nativeAgentUIPartIdMetadataKey(e,t){if(e.type===`text`||e.type===`reasoning`)return`${e.type}:${t}`;if(e.type===`tool`)return`tool:${e.toolCallId}`}function parseNativeAgentUIPartIdsMetadata(e){let t=e.metadata?.[ar];isPlainRecord$1(t)||invalidNativePartIds(),(Object.keys(t).length!==2||t.schemaVersion!==1||!isPlainRecord$1(t.partIds))&&invalidNativePartIds();let n=new Map;for(let[t,r]of e.parts.entries()){let e=nativeAgentUIPartIdMetadataKey(r,t);if(!e||n.has(e)){e&&invalidNativePartIds();continue}n.set(e,r)}let r=Object.entries(t.partIds);r.length!==n.size&&invalidNativePartIds();let i=new Map,a={};for(let[e,t]of r){let r=n.get(e);r&&typeof t==`string`&&t.length>0||invalidNativePartIds();let o=i.get(t);o&&(r.type===`tool`||o!==r.type)&&invalidNativePartIds(),r.type===`tool`&&t!==r.toolCallId&&invalidNativePartIds(),i.set(t,r.type),a[e]=t}return a}const sr=16e3,cr=3200,lr=6400,ur=16e3,dr=65536,fr=15e3,pr=1e4,mr=5e3,hr=`google/gemini-3.5-transcribe-live`,gr={maxDurationMs:3e5,dailyDurationMs:36e5,monthlyDurationMs:72e6,tenantMonthlyBudgetMicrousd:5e7,globalMonthlyBudgetMicrousd:5e7,estimatedMicrousdPerSecond:150,reservationMultiplier:2},_r=[`web`,`presentation`,`document`,`spreadsheet`,`image`,`code`,`other`],vr=[`ephemeral`,`conversation`,`persistent`],yr=[`source`,`preview`,`entrypoint`,`asset`],br=5;function getErrorMessage(e){return e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`?`message`in e&&typeof e.message==`string`?e.message:JSON.stringify(e):String(e)}function isFormDefinition(e){return typeof e==`object`&&!!e&&`slots`in e&&`steps`in e&&`name`in e&&typeof e.name==`string`&&Array.isArray(e.slots)&&Array.isArray(e.steps)}const xr=[`relation`,`multiRelation`,`formula`,`rollup`,`document`,`richtext`,`user`];function isFormSlotFieldRef(e){return e.type===`slot`}function isFormFreeFieldRef(e){return e.type===`free`}function resolveFieldRequired(e){return e.fieldRequired===void 0?e.slotMode===`create`&&e.attributeRequired===!0:e.fieldRequired}function getSlotFieldTargets(e){return e.additionalSlotIds?.length?[e.slotId,...e.additionalSlotIds]:[e.slotId]}function formFieldKey(e){return isFormSlotFieldRef(e)?`${e.slotId}.${e.attribute}`:`free.${e.attribute.name}`}function formFieldFlatKey(e){return isFormSlotFieldRef(e)?e.attribute:e.attribute.name}function readFormFieldValue(e,t){return e[formFieldKey(t)]??e[formFieldFlatKey(t)]}function isFormFieldsRow(e){return e.type===`fields`}function isFormHeadingRow(e){return e.type===`heading`}function isFormSeparatorRow(e){return e.type===`separator`}function isFormTextRow(e){return e.type===`text`}var NoopGeocodingAdapter=class{async autocomplete(){return await Promise.resolve([])}async reverse(){return await Promise.resolve(null)}async geocode(){return await Promise.resolve(null)}};const F=[`read`,`create`,`update`,`delete`,`manage`];function actionsToAccessLevel(e){return e.length===0?`none`:e.length===1&&e[0]===`read`?`read-only`:e.length===F.length&&F.every(t=>e.includes(t))?`full`:`custom`}function accessLevelToActions(e){switch(e){case`full`:return[...F];case`read-only`:return[`read`];case`none`:return[]}}function resolvePropertyDefinitions(e){let t=e.properties;if(!t)return[];if(Array.isArray(t))return t;let n=t;return Array.isArray(n.definitions)?n.definitions:[]}function hasOptions(e){return e.type===`select`||e.type===`status`||e.type===`multiselect`}const Sr=`Notetaker`,Cr={systemPrompt:null,meetingRecordingPolicy:`none`,meetingBotDisplayName:Sr},wr=[`active`,`suspended`],Tr=[`architect`,`manual`,`auto`],Er=[`square`,`landscape`,`portrait`],Dr=[`none`,`estimated`,`exact`];function parseCountMode(e){if(typeof e==`string`&&Dr.includes(e))return e;throw new E(`countMode must be one of: ${Dr.join(`, `)} (received: ${String(e)})`,[])}function parseOptionalCountMode(e){return e===void 0?void 0:parseCountMode(e)}const Or=1e4,kr=[`storage.bytes`,`members.seats`,`data.live_records`];function isEmptyObject(e){return e==null||typeof e==`object`&&Object.keys(e).length===0}function isNotEmpty(e){return typeof e==`object`&&!!e&&Object.keys(e).length>0}function toUndefinedIfEmpty(e){return isNotEmpty(e)?e:void 0}function computeByteMagnitude(e){if(e<=0)return{value:0,unitIndex:0};let t=1e3,n=Math.min(4,Math.floor(Math.log(e)/Math.log(t)));return{value:Number.parseFloat((e/t**n).toFixed(1)),unitIndex:n}}const Ar=[`B`,`KB`,`MB`,`GB`,`TB`];function formatByteSize(e){let{value:t,unitIndex:n}=computeByteMagnitude(e);return`${t} ${Ar[n]}`}const jr={ATTACHMENTS:`attachments`};function isDocumentAttribute(e){return e.type===`document`}function matchesAccepts(e,t){if(!t||t.length===0)return!0;let n=e.name.toLowerCase();return t.some(t=>t.endsWith(`/*`)?e.mimeType.startsWith(t.slice(0,-1)):t.startsWith(`.`)?n.endsWith(t.toLowerCase()):e.mimeType===t)}const Mr=Object.freeze([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`,`multiselect`,`location`]);function buildPropertySchema(e){let t=[];for(let n of e){let e=n.build();if(!Mr.includes(e.type))throw Error(`Property type "${e.type}" is not supported in .qualifyWith()`);t.push(e)}return{definitions:t}}const Nr=`__`;function parseQualifiedAttribute(e){let t=e.indexOf(`__`);return t<=0||t+2>=e.length?{kind:`scalar`,attribute:e}:{kind:`qualified`,root:e.slice(0,t),property:e.slice(t+2)}}function buildQualifiedAttribute(e,t){return`${e}__${t}`}function isDateRangeValue(e){return typeof e==`object`&&!!e&&typeof e.start==`string`}function normalizeDateValue(e,t){return M(e)?null:isDateRangeValue(e)?t.endDate?{start:e.start,end:e.end??null}:e.start:typeof e==`string`?t.endDate?{start:e,end:null}:e:null}function dateValueStart(e){return typeof e==`string`&&e!==``?e:isDateRangeValue(e)&&e.start!==``?e.start:null}const Pr=`—`;function formatText(e){return String(e)}function formatCheckbox(e){return e?`Yes`:`No`}function formatNumber(e,t){if(typeof e!=`number`)return String(e);if(t.renderAs===`rating`)return`${e}/${t.max??5}`;let n=t.decimals;return t.unit===`integer`?e.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0}):t.unit===`percentage`?(e/100).toLocaleString(void 0,{style:`percent`,minimumFractionDigits:n,maximumFractionDigits:n}):e.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n})}function formatCurrency(e,t){if(typeof e!=`object`||!e)return String(e);let n=e;return`value`in n&&`code`in n?`${n.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})} ${n.code}`:String(e)}function formatDate(e){if(isDateRangeValue(e)){let t=formatDate(e.start);return e.end?`${t} → ${formatDate(e.end)}`:t}if(e instanceof Date)return e.toISOString().split(`T`)[0];if(typeof e==`string`){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toISOString().split(`T`)[0]}return String(e)}function formatPhone(e){if(typeof e!=`object`||!e)return String(e);let t=e;return`phoneNumber`in t?t.phoneNumber?t.countryCode?_n(t):t.phoneNumber:``:String(e)}function formatLocationValue(e,t=`full`){if(typeof e!=`object`||!e)return``;let n=e,r=[];switch(t){case`country`:n.country&&r.push(N(n.country));break;case`state`:n.state&&r.push(n.state),n.country&&r.push(N(n.country));break;case`city`:n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push(N(n.country));break;case`coordinates`:n.latitude!==void 0&&n.longitude!==void 0&&r.push(`${n.latitude}, ${n.longitude}`);break;case`address`:n.address&&r.push(n.address),n.city&&r.push(n.city),n.state&&r.push(n.state),n.country&&r.push(N(n.country));break;default:n.address&&r.push(n.address),n.address2&&r.push(n.address2),n.city&&r.push(n.city),n.state&&r.push(n.state),n.postalCode&&r.push(n.postalCode),n.country&&r.push(N(n.country))}return r.join(`, `)}function formatLocation(e,t){return typeof e!=`object`||!e?String(e):formatLocationValue(e,t.granularity??`full`)||`—`}function formatSelect(e,t){return typeof e==`string`?t.options?.find(t=>t.value===e)?.label??String(e):String(e)}function formatMultiselect(e,t){return Array.isArray(e)?t.options?e.map(e=>t.options.find(t=>t.value===e)?.label).filter(Boolean).join(`, `):e.join(`, `):String(e)}function formatAttributeValue(e,t){if(M(e))return`—`;switch(t.type){case`text`:return formatText(e);case`checkbox`:return formatCheckbox(e);case`number`:return formatNumber(e,t);case`currency`:return formatCurrency(e,t);case`date`:return formatDate(e);case`phone`:return formatPhone(e);case`location`:return formatLocation(e,t);case`select`:case`status`:return formatSelect(e,t);case`multiselect`:return formatMultiselect(e,t);case`user`:case`relation`:return Array.isArray(e)?e.join(`, `):String(e);default:return Array.isArray(e)?e.join(`, `):String(e)}}const Fr=[`UPPER`,`LOWER`,`capitalize`,`trim`],Ir=[`prefix`,`suffix`,`wrap`,`default`],I=[...Fr,...Ir],L=P.string().min(1,`labelExpression cannot be empty`).refine(e=>isLabelExpression(e),{message:`labelExpression must contain at least one {{ attribute }} interpolation`}).refine(e=>!/\{\{\s*\}\}/.test(e),{message:`labelExpression contains empty {{ }} interpolation`}).refine(e=>{let t=/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g,n;for(;(n=t.exec(e))!==null;){let e=n[1];if(!I.includes(e))return!1}return!0},{message:`Invalid pipe name. Valid pipes: ${I.join(`, `)}`});function validateLabelExpression(e){let t=L.safeParse(e);return t.success?{success:!0,attributes:extractAttributeNames(e)}:{success:!1,error:t.error.issues[0]?.message??`Invalid labelExpression`}}function applyPipe(e,t){let{name:n,args:r}=parsePipeExpression(t);switch(n){case`UPPER`:return e.toUpperCase();case`LOWER`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|\s)\S/g,e=>e.toUpperCase());case`trim`:return e.trim();case`prefix`:return e?`${r[0]??``}${e}`:``;case`suffix`:return e?`${e}${r[0]??``}`:``;case`wrap`:return e?`${r[0]??``}${e}${r[1]??``}`:``;case`default`:return e||r[0]||``;default:return e}}function applyPipes(e,t){let n=e;for(let e of t)n=applyPipe(n,e);return n}function getValue(e,t){return t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e)return e[t]},e)}const Lr=`(Untitled)`;function parsePipeExpression(e){let t=e.match(/^(\w+)(?::(.*))?$/);if(!t)return{name:e,args:[]};let n=t[1],r=t[2];if(!r)return{name:n,args:[]};let i=[],a=/["']([^"']*?)["']/g,o;for(;(o=a.exec(r))!==null;)i.push(o[1]);return{name:n,args:i}}function*templateBlocks(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return;let r=e.indexOf(`}`,n+2);if(r<0)return;if(e[r+1]!==`}`){t=r+1;continue}t=r+2;let i=e.slice(n+2,r);i.length>0&&(yield{start:n,end:t,expr:i})}}function resolveLabelBlock(e,t){let n=e.split(`||`).map(e=>e.trim()),r=n[n.length-1].split(`|`).map(e=>e.trim());n[n.length-1]=r[0];let i=r.slice(1).filter(Boolean),a=n.filter(Boolean),o=``;for(let e of a){let n=toText(getValue(t,e));if(n!==``){o=n;break}}return applyPipes(o,i)}function renderLabelExpression(e,t,n=Lr){let r=[],i=0;for(let n of templateBlocks(e))r.push(e.slice(i,n.start),resolveLabelBlock(n.expr,t)),i=n.end;return r.push(e.slice(i)),r.join(``).trim()||n}function toText(e){if(e==null||typeof e==`function`)return``;if(typeof e!=`object`)return String(e);if(Array.isArray(e))return e.map(toText).filter(Boolean).join(`,`);let t=e.toString;return typeof t==`function`&&t!==Object.prototype.toString?String(e):``}function isLabelExpression(e){let t=0;for(;t<e.length;){let n=e.indexOf(`{{`,t);if(n<0)return!1;let r=e.indexOf(`}}`,n+2);if(r<0)return!1;if(e.slice(n+2,r).trim().length>0)return!0;t=r+2}return!1}function extractAttributeNames(e){let t=[];for(let n of templateBlocks(e)){let e=n.expr.trim();if(!e)continue;let r=e.split(`||`).map(e=>e.trim()),i=r[r.length-1];r[r.length-1]=i.split(`|`)[0].trim();for(let e of r){if(!e)continue;let n=e.split(`.`)[0];n&&!t.includes(n)&&t.push(n)}}return t}const Rr=/^\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}$/;function getSingleAttributeFromExpression(e){let t=e.trim().match(Rr);return t?t[1]:null}function getEditableLabelAttribute(e,t){let r=getSingleAttributeFromExpression(e);if(r===null)return null;let i=t.find(e=>e.name===r);return!i||i.type!==`text`||n(i).authoring.readOnly?null:i}const zr=/\{\{\s*props\./;function applyRelationProps(e,t,n){if(!zr.test(e))return e;let r={},i=new Map(n?.map(e=>[e.name,e]));if(t)for(let[e,n]of Object.entries(t)){if(n==null)continue;let t=i.get(e);if(t){let i=formatAttributeValue(n,t);r[e]=i===`—`?``:i}else r[e]=n}return renderLabelExpression(e,{props:r},``).replace(/\(\s*\)/g,``).replace(/\[\s*\]/g,``).replace(/\s*[-—|:]\s*$/g,``).replace(/\s{2,}/g,` `).trim()}function relationPropertyDefs(e){if(e?.type===`relation`)return e.properties?.definitions}function qualifiedPropertyDefs(e){if(e?.type===`relation`||e?.type===`document`)return e.properties?.definitions}function extractValueRefs(e){if(M(e))return[];if(typeof e==`string`)return[{id:e}];if(Array.isArray(e))return e.flatMap(e=>extractValueRefs(e));if(typeof e==`object`&&`id`in e){let t=e;if(typeof t.id==`string`)return[{id:t.id,props:t.props}]}return[]}function getUserDisplayName(e){let t=[e.firstName,e.lastName].map(e=>e?.trim()).filter(Boolean).join(` `);return t===``?e.email?.split(`@`)[0]??``:t}const Br=/\p{L}|\p{N}/u;function deriveInitials(e,t){let n=e?.trim()??``;if(n===``)return t;let r=n.split(/\s+/),i=(r.length===1?n.split(`@`)[0].split(/[._-]/):r).map(e=>{let t=e.match(Br)?.[0];return t===void 0?``:[...t.toUpperCase()][0]??``}).filter(Boolean).slice(0,2).join(``);return i===``?t:i}const Vr=`__creatorRootActorId`;function getRecordCreatorPrincipalId(e){let t=e.metadata?.[Vr];return typeof t==`string`&&t.length>0?t:e.createdBy}function includesAction(e,t){return e?.includes(`*`)===!0||e?.includes(t)===!0}function buildPermissionFlags(e){return{canRead:includesAction(e,`read`),canCreate:includesAction(e,`create`),canUpdate:includesAction(e,`update`),canDelete:includesAction(e,`delete`),canManage:includesAction(e,`manage`)}}const Hr=new Set([`id`,`name`,`label`,`type`,`required`,`system`,`unique`,`order`]),R={PEOPLE:`people`,WORKSPACE:`workspace`,ARCHITECT:`architect`,FEATURE_FLAGS:`feature-flags`,FILES:`files`,VIEWS:`views`,FORMS:`forms`,DOCUMENTS:`documents`,AUDIT:`audit`,API_KEYS:`api-keys`,CONNECTORS:`connectors`,ENV_VARS:`env-vars`,SESSION:`session`},Ur=[R.PEOPLE,R.WORKSPACE,R.ARCHITECT,R.FEATURE_FLAGS,R.FILES,R.VIEWS,R.FORMS,R.DOCUMENTS,R.AUDIT,R.API_KEYS,R.CONNECTORS,R.ENV_VARS,R.SESSION],Wr={people:`People`,workspace:`Workspace`,architect:`Architect`,"feature-flags":`Feature flags`,files:`Files`,views:`Views`,forms:`Forms`,documents:`Documents`,audit:`Audit`,"api-keys":`API keys`,connectors:`Connected accounts`,"env-vars":`Environment variables`,session:`Agent sessions`},Gr={OWNER:`owner`,MEMBER:`member`,AGENT_DEFAULT:`agent_default`,REFLEX_DEFAULT:`reflex_default`},Kr={owner:`Owner`,member:`Member`,agent_default:`Agent Default`,reflex_default:`Reflex Default`},qr={owner:`Full access to all platform features and data`,member:`Can view, create, edit and delete business data`,agent_default:`Default role for AI agents — CRUD on records plus documents and files`,reflex_default:`Default role for reflexes — no data access; each reflex is granted exactly what its rehearsal showed it uses`},Jr=[`read`,`create`,`update`,`delete`,`manage`],Yr=[`read`,`create`,`update`,`delete`],Xr=[`read`,`create`,`update`,`delete`],Zr={owner:{system:[{target:`*`,actions:Jr}],object:[{target:`*`,actions:Jr}]},member:{system:[{target:`people`,actions:[`read`]},{target:`workspace`,actions:[`read`]},{target:`connectors`,actions:Yr},{target:`files`,actions:Xr},{target:`documents`,actions:Xr}],object:[{target:`*`,actions:Jr}]},agent_default:{system:[{target:`documents`,actions:[`read`,`create`,`update`]},{target:`files`,actions:[`read`,`create`,`update`]},{target:`env-vars`,actions:[`read`]},{target:`session`,actions:[`observe`]}],object:[{target:`*`,actions:[`read`,`create`,`update`,`delete`]}]},reflex_default:{system:[],object:[]}};function isDefaultRole(e){return Object.values(Gr).includes(e)}const Qr={maxConcurrentRuns:3,retryPolicy:{maxRetries:3,backoffMs:1e3,backoffMultiplier:2},timeoutMs:3e5};var AgentBuilder=class{constructor(e){if(!e.name||e.name.trim().length===0)throw new E(`Agent name is required`,[]);this.bp={name:e.name,system:!0,visibility:`workspace`,triggers:[]}}description(e){return this.bp.description=e,this}label(e){return this.bp.label=e,this}icon(e){return this.bp.icon=e,this}systemPrompt(e){return this.bp.systemPrompt=e,this}model(e,t,n){return this.bp.model={provider:e,model:t,...n},this}tools(e){return this.bp.tools=[...e],this}schedule(e){return this.bp.schedule={...e,enabled:e.enabled??!0},this}config(e){let t=this.bp.config??Qr,n=e.inference===void 0?t.inference:{...t.inference,...e.inference};return this.bp.config={...t,...e,...n===void 0?{}:{inference:n}},this}delegation(e){return Object.assign(this.bp,e),this}mcpServers(e){return this.bp.mcpServers=Array.isArray(e)?[...e]:e,this}approval(e){return this.bp.approval={...Kn,...this.bp.approval,...e},this}visibility(e){return this.bp.visibility=e,this}requiresPermission(e,t){return this.bp.requiredPermission={resource:e,action:t},this}trigger(e,t,n){return this.bp.triggers.push({name:e,eventType:t,...n,enabled:n?.enabled??!0}),this}runtime(){return this.bp.system=!1,this}build(){if(!this.bp.systemPrompt)throw new E(`Agent "${this.bp.name}": systemPrompt is required`,[]);if(!this.bp.model)throw new E(`Agent "${this.bp.name}": model is required`,[]);if(this.bp.system&&this.bp.visibility===`private`)throw new E(`Agent "${this.bp.name}": system agents must use workspace visibility`,[]);return wt(this.bp.triggers,e=>e.name,e=>new E(`Agent "${this.bp.name}": duplicate trigger name "${e}"`,[])),{...this.bp,visibility:this.bp.visibility??`workspace`,config:this.bp.config??Qr,systemPrompt:this.bp.systemPrompt,model:this.bp.model}}};function agent(e){return new AgentBuilder(e)}const $r=`@stndrds/schema`;function createStandardSchemaProps(e){return{version:1,vendor:$r,validate:t=>{let n=e.safeParse(t);return n.success?{value:n.data}:{issues:n.error.issues.map(e=>({message:e.message,path:e.path}))}}}}function isStandardSchema(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`&&e[`~standard`].version===1}function asMutableArray(e){return e}var BaseAttributeBuilder=class{get"~standard"(){return createStandardSchemaProps(an(this.build()))}constructor(e,t,n){mt(t),bt(n),this.attr={name:t,label:n,type:e,required:!1,system:!0}}setRequired(e){this.attr.required=e}asRequiredState(){return this}asPhantomState(){return this}runtime(){return this.attr.system=!1,this}hidden(){return this.attr.hidden=!0,this}placeholder(e){return this.attr.placeholder=e,this}description(e){return this.attr.description=e,this}icon(e){return pt(e,`attribute "${this.attr.name}"`),this.attr.icon=e,this}order(e){return this.attr.order=e,this}defaultValue(e){return(`defaultValue`in this.attr||![`formula`,`rollup`].includes(this.attr.type))&&(this.attr.defaultValue=e),this}metadata(e){return this.attr.metadata=e,this}build(){return this.attr}},TextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`text`,e,t)}minLength(e){return this.attr.minLength=e,this}maxLength(e){return this.attr.maxLength=e,this}pattern(e){return this.attr.pattern=e,this.attr.format=void 0,this}multiline(e=!0){return this.attr.multiline=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}email(){return this.attr.format=`email`,this.attr.pattern=void 0,this}url(){return this.attr.format=`url`,this.attr.pattern=void 0,this}slug(){return this.attr.format=`slug`,this.attr.pattern=void 0,this}};function text(e){return new TextAttributeBuilder(e.name,e.label)}var RichtextAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`richtext`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function richtext(e){return new RichtextAttributeBuilder(e.name,e.label)}var NumberAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`number`,e,t)}min(e){return this.attr.min=e,this}max(e){return this.attr.max=e,this}integer(){return this.attr.unit=`integer`,this.attr.decimals=0,this}decimal(e=2){return this.attr.unit=`decimal`,this.attr.decimals=e,this}percentage(){return this.attr.unit=`percentage`,this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function number(e){return new NumberAttributeBuilder(e.name,e.label)}var CheckboxAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`checkbox`,e,t)}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function checkbox(e){return new CheckboxAttributeBuilder(e.name,e.label)}var DateAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`date`,e,t)}format(e){return this.attr.dateFormat=e,this}minDate(e){return this.attr.minDate=e,this}maxDate(e){return this.attr.maxDate=e,this}endDate(){return this.attr.endDate=!0,this.asPhantomState()}includeTime(){return this.attr.includeTime=!0,this}timeFormat(e){return this.attr.timeFormat=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function date(e){return new DateAttributeBuilder(e.name,e.label)}var PhoneAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`phone`,e,t)}defaultCountry(e){return this.attr.defaultCountryCode=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function phone(e){return new PhoneAttributeBuilder(e.name,e.label)}var CurrencyAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`currency`,e,t)}defaultCurrency(e){return this.attr.defaultCurrency=e,this}allowedCurrencies(e){return this.attr.allowedCurrencies=e,this}allowNegative(e=!0){return this.attr.allowNegative=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function currency(e){return new CurrencyAttributeBuilder(e.name,e.label)}var StatusAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`status`,e,t)}options(e){let t=asMutableArray(e);return D(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return D(this.attr.name??`unknown`,t),this.attr.options.push(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function status(e){return new StatusAttributeBuilder(e.name,e.label)}var SelectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`select`,e,t)}options(e){let t=asMutableArray(e);return D(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return D(this.attr.name??`unknown`,t),this.attr.options.push(e),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function select(e){return new SelectAttributeBuilder(e.name,e.label)}var MultiselectAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`multiselect`,e,t)}options(e){let t=asMutableArray(e);return D(this.attr.name??`unknown`,t),this.attr.options=t,this.asPhantomState()}option(e){this.attr.options||(this.attr.options=[]);let t=[...this.attr.options,e];return D(this.attr.name??`unknown`,t),this.attr.options.push(e),this}renderAs(e){return this.attr.renderAs=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function multiselect(e){return new MultiselectAttributeBuilder(e.name,e.label)}var LocationAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`location`,e,t)}granularity(e){return this.attr.granularity=e,this}defaultCountry(e){return this.attr.defaultCountry=e,this}allowedCountries(e){return this.attr.allowedCountries=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function location(e){return new LocationAttributeBuilder(e.name,e.label)}var UserAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`user`,e,t),this.attr.types=[`user`,`agent`]}types(e){let t=[...new Set(e)];if(t.length===0)throw Error(`[AttributeBuilder] user.types must contain at least one type.`);return this.attr.types=t,this}multiple(){return this.attr.multiple=!0,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function user(e){return new UserAttributeBuilder(e.name,e.label)}var BaseRelationAttributeBuilder=class extends BaseAttributeBuilder{to(e,t){let n={object:e,...t};return this.attr.targets?.push(n),this}toAny(){return this.attr.targets=[{object:`*`}],this}qualifyWith(...e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.qualifyWith() must be called AFTER .to(). Example: relation({ name: "companies" }).to("companies").qualifyWith(...)`);return this.attr.properties=buildPropertySchema(e),this}bilateral(e){let t=this.attr.targets;if(!t||t.length===0)throw Error(`.bilateral() must be called AFTER .to(). Example: relation({ name: "company" }).to("companies").bilateral({ ... })`);if(t.length>1)throw Error(`Bilateral relations are not supported for polymorphic relations (multiple .to() targets).`);if(isUniversalRelation(this.attr))throw Error(`Bilateral relations are not supported for universal relations (.toAny()).`);let n=t[0]?.object;if(!n)throw new E(`Bilateral relation requires one target object`,[{path:[`bilateral`,`object`],message:`Bilateral relation requires one target object`}]);if(e.object&&e.object!==n){let t=`Bilateral inverse object ${e.object} must match relation target ${n}`;throw new E(t,[{path:[`bilateral`,`object`],message:t}])}return this.attr.bilateral={...e,object:n},this}},SingleRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t){super(`relation`,e,t),this.attr.cardinality=`one`,this.attr.targets=[]}many(){let e=new MultiRelationAttributeBuilder(this.attr.name,this.attr.label??``,{targets:this.attr.targets,isRequired:this.attr.required});return this.attr.system===!1&&e.runtime(),this.attr.hidden&&e.hidden(),this.attr.placeholder&&e.placeholder(this.attr.placeholder),this.attr.description&&e.description(this.attr.description),this.attr.icon&&e.icon(this.attr.icon),this.attr.order!==void 0&&e.order(this.attr.order),this.attr.metadata&&e.metadata(this.attr.metadata),e}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}},MultiRelationAttributeBuilder=class extends BaseRelationAttributeBuilder{constructor(e,t,n){super(`relation`,e,t),this.attr.cardinality=`many`,this.attr.targets=n?.targets??[],this.attr.defaultValue=[],n?.isRequired&&this.setRequired(!0)}maxItems(e){return this.attr.maxItems=e,this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function relation(e){return new SingleRelationAttributeBuilder(e.name,e.label)}var FormulaAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`formula`,e,t),this.attr.required=!1}expression(e){return this.attr.expression=e,this}returns(e){return this.attr.returnType=e,this}decimals(e){return this.attr.decimals=e,this}required(){throw Error(`Formula attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function formula(e){return new FormulaAttributeBuilder(e.name,e.label)}var RollupAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`rollup`,e,t),this.attr.required=!1}from(e){return this.attr.relationAttribute=e,this}aggregate(e){return this.attr.targetAttribute=e,this}using(e){return this.attr.function=e,this}decimals(e){return this.attr.decimals=e,this}path(e){return this.attr.relationPath=e,this}targetType(e){return this.attr.targetAttributeType=e,this}targetOptions(e){return this.attr.targetAttributeOptions=e,this}targetCurrency(e){return this.attr.targetCurrencyCode=e,this}build(){let e=this.attr.function,t=this.attr.targetAttributeType;if(e===`original`&&t!==void 0&&t!==`select`&&t!==`status`&&t!==`multiselect`){let e=this.attr.relationAttribute??`relation`,n=this.attr.targetAttribute??`field`;throw new w(`Rollup "${this.attr.name}": .using("original") only supports a "select", "status", or "multiselect" target, but .targetType("${t}") was given. To surface a plain ${t} value from a related record, use a formula instead — e.g. formula({ name: "${this.attr.name}", label: "…" }).expression("${e}.${n}").`,T.VALIDATION_FAILED)}return super.build()}required(){throw Error(`Rollup attributes cannot be required: they are computed read-only values. Remove .required() from this attribute definition.`)}optional(){return this}};function rollup(e){return new RollupAttributeBuilder(e.name,e.label)}var DocumentAttributeBuilder=class extends BaseAttributeBuilder{constructor(e,t){super(`document`,e,t)}accepts(e){return this.attr.accepts=e,this}maxFileSize(e){return this.attr.maxFileSize=e,this}qualifyWith(...e){return this.attr.properties=buildPropertySchema(e),this}required(){return this.setRequired(!0),this.asRequiredState()}optional(){return this.setRequired(!1),this.asRequiredState()}};function document(e){return new DocumentAttributeBuilder(e.name,e.label)}function buildSlotFieldRef(e,t,n){let[r,...i]=Array.isArray(e)?e:[e];return{type:`slot`,slotId:r,additionalSlotIds:i.length>0?i:void 0,attribute:t,label:n?.label,required:n?.required,tooltip:n?.tooltip}}var FormRowBuilder=class{constructor(e,t,n){this._finalized=!1,this.stepBuilder=e,this.rowData={id:t,order:n,type:`fields`,fields:[]}}field(e,t,n){return this.rowData.fields.push(buildSlotFieldRef(e,t,n)),this}freeField(e,t){let n={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression};return this.rowData.fields.push(n),this}row(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).row(e)}heading(e,t){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).heading(e,t)}separator(){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).separator()}text(e){return this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData).text(e)}endRow(){return this._finalized?this.stepBuilder:(this._finalized=!0,this.stepBuilder._finalizeRow(this.rowData))}},FormStepBuilder=class{constructor(e,t,n){this.rowOrder=0,this.formBuilder=e,this.stepData={id:t,label:n,rows:[]}}description(e){return this.stepData.description=e,this}field(e,t,n){this.rowOrder++;let r=`row-${this.stepData.id}-${this.rowOrder}`,i=buildSlotFieldRef(e,t,n),a={id:r,order:this.rowOrder,type:`fields`,fields:[i]};return this.stepData.rows.push(a),this}freeField(e,t){this.rowOrder++;let n=`row-${this.stepData.id}-${this.rowOrder}`,r={type:`free`,attribute:e.build(),label:t?.label,required:t?.required,prefillExpression:t?.prefillExpression},i={id:n,order:this.rowOrder,type:`fields`,fields:[r]};return this.stepData.rows.push(i),this}row(e){return this.rowOrder++,new FormRowBuilder(this,e,this.rowOrder)}heading(e,t){this.rowOrder++;let n={id:`heading-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`heading`,content:e,level:t};return this.stepData.rows.push(n),this}separator(){this.rowOrder++;let e={id:`sep-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`separator`};return this.stepData.rows.push(e),this}text(e){this.rowOrder++;let t={id:`text-${this.stepData.id}-${this.rowOrder}`,order:this.rowOrder,type:`text`,content:e};return this.stepData.rows.push(t),this}step(e,t){return this.formBuilder._finalizeStep(this.stepData).step(e,t)}build(){return this.formBuilder._finalizeStep(this.stepData).build()}_finalizeRow(e){return e.fields.length>0&&this.stepData.rows.push(e),this}_getData(){return this.stepData}},FormBuilder=class{constructor(e,t){this.data={slots:[],steps:[],status:`draft`,version:1},this.validateName(e),this.data.name=e,this.data.label=t}description(e){return this.data.description=e,this}icon(e){return this.data.icon=e,this}status(e){return this.data.status=e,this}metadata(e){return this.data.metadata=e,this}slot(e,t,n){if(this.data.slots.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate slot id: "${e}"`);let r={id:e,objectName:t,label:n.label,mode:n.mode??`create`,color:n.color,icon:n.icon};return this.data.slots.push(r),this}step(e,t){if(this.data.steps.some(t=>t.id===e))throw Error(`[FormBuilder] Duplicate step id: "${e}"`);return new FormStepBuilder(this,e,t)}build(){return this.validateRequiredData(),this.validateSlotReferences(),this.validateFreeFields(),this.validatePrefillExpressions(),this.data}_finalizeStep(e){return this.data.steps.push(e),this}validateName(e){let t=P.string().min(1,`Form name cannot be empty`).max(63,`Form name is too long (max 63 characters)`).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,{message:`Invalid form name format. Name must be in kebab-case: 'client-onboarding', 'contact-creation'`});try{t.parse(e)}catch(e){throw e instanceof P.ZodError?Error(`[FormBuilder] ${e.issues[0].message}`):e}}validateRequiredData(){if(this.data.slots.length===0)throw Error(`[FormBuilder] At least one slot is required. Use .slot() to add slots.`);if(this.data.steps.length===0)throw Error(`[FormBuilder] At least one step is required. Use .step() to add steps.`)}validateSlotReferences(){let e=new Map(this.data.slots.map(e=>[e.id,e.objectName]));for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(r.type!==`slot`)continue;let n=getSlotFieldTargets(r);for(let r of n)if(!e.has(r))throw Error(`[FormBuilder] Step "${t.id}" references unknown slot "${r}". Declare it with .slot("${r}", ...) first.`);let i=new Set(n.map(t=>e.get(t)));if(i.size>1)throw Error(`[FormBuilder] Step "${t.id}" field on attribute "${r.attribute}" targets slots of different objects (${[...i].join(`, `)}). A multi-slot field must target slots of the same object.`)}}validatePrefillExpressions(){let e=[...I,`join`];for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n))for(let r of n.fields){if(!isFormFreeFieldRef(r)||!r.prefillExpression)continue;let n=r.prefillExpression,i=`prefillExpression on free field "${r.attribute.name}" in step "${t.id}"`;if(!isLabelExpression(n))throw Error(`[FormBuilder] ${i} must contain at least one {{ attribute }} interpolation.`);if(/\{\{\s*\}\}/.test(n))throw Error(`[FormBuilder] ${i} contains empty {{ }} interpolation.`);for(let t of n.matchAll(/(?<!\|)\|(?!\|)\s*(\w+)(?::[^|}]*)?/g)){let n=t[1];if(!e.includes(n))throw Error(`[FormBuilder] ${i} uses invalid pipe "${n}". Valid pipes: ${e.join(`, `)}`)}}}validateFreeFields(){let e=new Set(xr);for(let t of this.data.steps)for(let n of t.rows)if(isFormFieldsRow(n)){for(let r of n.fields)if(isFormFreeFieldRef(r)){let n=r.attribute.type;if(e.has(n))throw Error(`[FormBuilder] Free field in step "${t.id}" uses forbidden attribute type "${n}". Forbidden types: ${xr.join(`, `)}`)}}}};function form(e,t){return new FormBuilder(e,t)}function resolveBuiltInTransform(e){return{text:`toString`,richtext:`toString`,number:`toNumber`,currency:`toNumber`,date:`toDate`,checkbox:`toBoolean`}[e]}var MigrationBuilder=class{constructor(e){this.operations=[],this.touchedAttributes=new Set,this.version=e}assertNotTouched(e,t){if(this.touchedAttributes.has(e))throw new E(`[MigrationBuilder] Conflicting operations on attribute "${e}": it was already modified earlier in this migration (attempted: ${t}).`,[])}renameAttribute(e,t){return this.assertNotTouched(e,`rename_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`rename_attribute`,from:e,to:t}),this}changeType(e,t,n,r){this.assertNotTouched(e,`change_type`),this.touchedAttributes.add(e);let i=r?.transform?resolveBuiltInTransform(n):void 0;return this.operations.push({type:`change_type`,name:e,from:t,to:n,transform:i}),this}removeAttribute(e){return this.assertNotTouched(e,`remove_attribute`),this.touchedAttributes.add(e),this.operations.push({type:`remove_attribute`,name:e}),this}addAttribute(e){return this.assertNotTouched(e.name,`add_attribute`),this.touchedAttributes.add(e.name),this.operations.push({type:`add_attribute`,attribute:e}),this}updateConfig(e,t){return this.assertNotTouched(e,`update_config`),this.touchedAttributes.add(e),this.operations.push({type:`update_config`,name:e,from:{},to:t}),this}build(){return{version:this.version,operations:[...this.operations]}}};function validateObjectExpressions(e){let{name:t,labelExpression:n,embeddingExpression:r}=e;if(!n)throw new w(`Object "${t}" must have a labelExpression. The labelExpression defines how records are displayed in lists and relations (e.g. "{{ name }}").`,T.VALIDATION_FAILED);let i=L.safeParse(n);if(!i.success){let e=i.error.issues[0]?.message??`Invalid labelExpression`;throw new w(`Invalid labelExpression for "${t}": ${e}`,T.VALIDATION_FAILED)}if(r!==void 0){let e=L.safeParse(r);if(!e.success){let n=e.error.issues[0]?.message??`Invalid embeddingExpression`;throw new w(`Invalid embeddingExpression for "${t}": ${n}`,T.VALIDATION_FAILED)}}}var ObjectBuilder=class{get"~standard"(){return createStandardSchemaProps(fn(this.build()))}constructor(e){this._migrations=[],this._sealed=!1,this._toleratedAttributes=[],this.validateName(e.name),this.obj={name:e.name,label:e.label,attributes:[],system:!0},e.id&&(this.obj.id=e.id)}description(e){return this.obj.description=e,this}pluralLabel(e){return this._pluralLabel=e,this}icon(e){return this.obj.icon=e,this}runtime(){return this.obj.system=!1,this}sealed(){return this._sealed=!0,this}tolerate(e){return this._toleratedAttributes=[...this._toleratedAttributes,...e],this}attribute(e){return this.pushAttributes([e]),this}attributes(e){return this.pushAttributes(e),this}pushAttributes(e){let t=e.map(e=>`build`in e&&typeof e.build==`function`?e.build():e);wt([...this.obj.attributes,...t],e=>e.name,e=>new S(`attribute`,e,`Object "${this.obj.name}": duplicate attribute name "${e}"`)),this.obj.attributes.push(...t)}metadata(e){return this.obj.metadata={...this.obj.metadata,...e},this}order(e){return this.obj.metadata={...this.obj.metadata,order:e},this}hidden(){return this.obj.metadata={...this.obj.metadata,hidden:!0},this}labelExpression(e){return this._labelExpression=e,this}embeddingExpression(e){return this._embeddingExpression=e,this}documentLayout(e){if(e.presets)for(let t of e.presets)validatePresetStructure(t.id,t.structure,1);return this.obj.documentLayout=e,this}migration(e,t){if(e<2)throw Error(`[ObjectBuilder] Migration version must be >= 2 (version 1 is implicit). Got: ${e}`);if(this._migrations.some(t=>t.version===e))throw Error(`[ObjectBuilder] Duplicate migration version: ${e}`);let n=new MigrationBuilder(e);return t(n),this._migrations.push(n.build()),this}build(){if(!this.obj.name)throw new E(`[ObjectBuilder] Missing required field: name`,[{path:[`name`],message:`name is required`}]);if(!this.obj.label)throw new E(`[ObjectBuilder] Missing required field: label`,[{path:[`label`],message:`label is required`}]);validateObjectExpressions({name:this.obj.name,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression});let e=[...this._migrations].sort((e,t)=>e.version-t.version);for(let t=0;t<e.length;t++){let n=t+2;if(e[t].version!==n)throw Error(`[ObjectBuilder] Migration versions must be sequential starting at 2. Expected version ${n}, got ${e[t].version}.`)}let t=e.length>0?e[e.length-1].version:1;return{...this.obj,pluralLabel:this._pluralLabel,labelExpression:this._labelExpression,embeddingExpression:this._embeddingExpression,schema_version:t,migrations:e,sealed:this._sealed,toleratedAttributes:this._toleratedAttributes}}validateName(e){e!==void 0&&Ft(e)}};function object(e){if(A(e.name))throw new Xe(e.name,`builder`);return new ObjectBuilder(e)}function validatePresetStructure(e,t,n){let fail=(t,n)=>{throw new E(t,[{path:[`documentLayout`,`presets`,e],message:n}])};n>5&&fail(`Preset structure exceeds max depth of 5`,`Preset structure too deep`);let r=new Set;for(let i of t){let t=i.title.trim();t.length===0&&fail(`Folder preset node title is required`,`Empty folder title`),t.includes(`/`)&&fail(`Folder preset node title cannot contain /`,`Folder title contains /: "${t}"`),r.has(t)&&fail(`Folder preset sibling titles must be unique`,`Duplicate folder title: "${t}"`),r.add(t),i.children&&i.children.length>0&&validatePresetStructure(e,i.children,n+1)}}function cloneBuilderValue(e,t){try{return structuredClone(e)}catch{let e=`Builder configuration must contain cloneable data`;throw new E(e,[{path:t,message:e}])}}function requireBuilderName(e,t){if(typeof e!=`string`||e.trim().length===0)throw new E(`Name must not be blank`,[{path:t,message:`Name must not be blank`}])}function validateContentConfiguration(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new E(`Invalid content configuration`,[{path:t,message:`Expected content configuration`}]);for(let n of[`name`,`label`,`placement`])if(Object.hasOwn(e,n)){let e=`Independent content configuration cannot define ${n}`;throw new E(e,[{path:[...t,n],message:e}])}let n=x.safeParse({...e,name:`content`,placement:`main`});if(!n.success)throw E.fromZodErrors(n.error.issues.map(e=>({path:[...t,...e.path.map(String)],message:e.message})));n.data.type===`form`&&n.data.groups.forEach((e,n)=>requireBuilderName(e.name,[...t,`groups`,String(n),`name`]));let{name:r,label:i,placement:a,...o}=n.data;return cloneBuilderValue(o,t)}function validateLiteralContent(e,t){return validateContentConfiguration(e,t),cloneBuilderValue(e,t)}function collectionSourceAddress(e){return e.relation===void 0?{kind:`object`,object:e.object}:e.object===void 0?{kind:`related`,relation:e.relation}:{kind:`relatedFrom`,object:e.object,relation:e.relation}}function collectionSourceAddressOf(e){if(!e||typeof e!=`object`)return;let t=`object`in e?e.object:void 0,n=`relation`in e?e.relation:void 0;if(typeof t==`string`&&typeof n==`string`)return{kind:`relatedFrom`,object:t,relation:n};if(typeof t==`string`&&n===void 0)return{kind:`object`,object:t};if(typeof n==`string`&&t===void 0)return{kind:`related`,relation:n}}function requireRecordContentContext(e,t,n){if(t!==`record`){let t=`Content "${e}" requires record context. In a collection view only a collection that lists a whole object, or a custom content that does not require a record, is allowed.`;throw new E(t,[{path:n,message:t}])}}function resolveContentNavigation(e){let t=e.openMode??`page`;return{openMode:t,createMode:e.createMode??t}}function resolveCollectionActions(e,t){return[...new Set(t)].filter(t=>e.actions===void 0||e.actions.includes(t))}var ei=class ViewBuilder{constructor(e,t=[]){this.kind=`view`,this.data=cloneBuilderValue(e,[`views`,`0`]),this.extensions=t.map(e=>e&&{...e})}for(e){return new ViewBuilder({...this.data,object:e},this.extensions)}default(){return new ViewBuilder({...this.data,default:!0},this.extensions)}description(e){return new ViewBuilder({...this.data,description:e},this.extensions)}icon(e){return new ViewBuilder({...this.data,icon:e},this.extensions)}place(e,t,n,r){let i=[`views`,`0`,`contents`,String(this.data.contents.length)],a,o;try{typeof n==`object`&&n&&`build`in n&&typeof n.build==`function`?(a=validateContentConfiguration(n.build(),i),o=n.extension):a=validateContentConfiguration(n,i)}catch(e){throw e instanceof E?new E(e.message,e.errors.map(e=>({...e,path:e.path[0]===`content`?[...i,...e.path.slice(1)]:e.path}))):e}let s={...a,name:e,label:t,placement:r},c=[...this.data.contents,s];return new ViewBuilder({...this.data,contents:c},[...this.extensions,o])}tab(e,t,n){return this.place(e,t,n,`main`)}aside(e,t,n){return this.place(e,t,n,`aside`)}build(){let e=[`views`,`0`];requireBuilderName(this.data.name,[...e,`name`]),requireBuilderName(this.data.object,[...e,`object`]);let t=he.safeParse(this.data);if(!t.success)throw E.fromZodErrors(t.error.issues.map(t=>({path:[...e,...t.path.map(String)],message:t.message})));return this.data.contents.forEach((t,n)=>{let r=[...e,`contents`,String(n)];requireBuilderName(t.name,[...r,`name`]),t.type===`form`&&t.groups.forEach((e,t)=>requireBuilderName(e.name,[...r,`groups`,String(t),`name`])),(t.type===`custom`?this.extensions[n]?.requiresRecord:t.type!==`collection`||collectionSourceAddress(t.source).kind!==`object`)&&requireRecordContentContext(t.name,this.data.context,r)}),{kind:`view`,definition:cloneBuilderValue(this.data,e)}}};function detailView(e,t){return new ei({name:e,label:t,object:void 0,context:`record`,contents:[]})}function listView(e,t){return new ei({name:e,label:t,object:void 0,context:`collection`,contents:[]})}function relationProperty(e){return requireBuilderName(e,[`relationProperty`]),{relationProperty:e}}var z=class ContentBuilder{constructor(e,t){this.data=cloneBuilderValue(e,[`content`]),this.extension=t===void 0?void 0:Object.freeze({name:t.name,requiresRecord:t.requiresRecord,parameters:t.parameters})}set(e){return new ContentBuilder({...this.data,...e},this.extension)}icon(e){return this.set({icon:e})}object(e){return this.data.type===`forms`?this.set({objectName:e}):this.set({source:{object:e}})}related(e){return this.set({source:{relation:e}})}relatedFrom(e,t){return this.set({source:{object:e,relation:t}})}layout(e){let{layout:t,groupByAttribute:n,columnSizing:r,kanbanColumnOrder:i,kanbanColumnVisibility:a,kanbanPinnedColumns:o,...s}={...this.data,layout:void 0,groupByAttribute:void 0,columnSizing:void 0,kanbanColumnOrder:void 0,kanbanColumnVisibility:void 0,kanbanPinnedColumns:void 0};return new ContentBuilder({...s,...e},this.extension)}table(){return this.layout({layout:`table`})}list(){return this.layout({layout:`list`})}kanban(e){return this.layout({layout:`kanban`,groupByAttribute:e})}columns(...e){return this.set({columns:e})}filter(e){return this.set({filters:e})}sort(e,t=`asc`){let n=[...`sorts`in this.data&&Array.isArray(this.data.sorts)?this.data.sorts:[],{attribute:e,direction:t}];return this.set({sorts:n})}actions(...e){return this.set({actions:e})}openMode(e){return this.set({openMode:e})}createMode(e){return this.set({createMode:e})}visibility(e){return this.set({visibility:e})}descriptionAttribute(e){return this.set({descriptionAttribute:e})}displayAttributes(...e){return this.set({displayAttributes:e})}columnSizing(e){return this.set({columnSizing:e})}kanbanColumnOrder(...e){return this.set({kanbanColumnOrder:e})}kanbanColumnVisibility(e){return this.set({kanbanColumnVisibility:e})}kanbanPinnedColumns(...e){return this.set({kanbanPinnedColumns:e})}formColumns(e){return this.set({formColumns:e})}density(e){return this.set({density:e})}titleAttribute(e){return this.set({titleAttribute:e})}allowUpload(e){return this.set({allowUpload:e})}allowRemove(e){return this.set({allowRemove:e})}hideAttachments(e){return this.set({hideAttachments:e})}relations(...e){return this.set({relations:e})}build(){let e=validateLiteralContent(this.data,[`content`]);if(this.extension&&e.type===`custom`){let t=this.extension.parameters.safeParse(cloneBuilderValue(e.parameters??{},[`content`,`parameters`]));if(!t.success)throw E.fromZodErrors(t.error.issues.map(e=>({path:[`content`,`parameters`,...e.path.map(String)],message:e.message})))}return e}},ti=class GroupBuilder{constructor(e,t,n,r={}){this.data=cloneBuilderValue({name:e,label:t,fields:n,...r},[`group`])}field(e,t){let{name:n,label:r,fields:i,...a}=this.data;return new GroupBuilder(n,r,[...i,{attribute:e,...t}],a)}fields(...e){let{name:t,label:n,fields:r,...i}=this.data;return new GroupBuilder(t,n,[...r,...e.map(e=>({attribute:e}))],i)}description(e){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),description:e})}collapsible(e=!1){return new GroupBuilder(this.data.name,this.data.label,this.data.fields,{...this.presentation(),collapsible:!0,collapsed:e})}presentation(){let{name:e,label:t,fields:n,...r}=this.data;return r}build(){requireBuilderName(this.data.name,[`group`,`name`]);try{validateLiteralContent({type:`form`,groups:[this.data]},[`group`])}catch(e){throw e instanceof E?new E(e.message,e.errors.map(e=>({...e,path:e.path[1]===`groups`?[`group`,...e.path.slice(3)]:e.path}))):e}return cloneBuilderValue(this.data,[`group`])}};function group(e,t){return new ti(e,t,[])}function collection(){return new z({type:`collection`})}function form$1(...e){return new z({type:`form`,groups:e.map(e=>`build`in e?e.build():e)})}function activity(){return new z({type:`activity`})}function richtext$1(e){return new z({type:`richtext`,attribute:e})}function documents(){return new z({type:`documents`})}function forms(){return new z({type:`forms`})}function emails(...e){return new z({type:`emails`,emailAttributes:e})}function meetings(...e){return new z({type:`meetings`,emailAttributes:e})}function custom(e,t){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw new E(`Expected registered extension declaration`,[{path:[`content`,`extension`],message:`Expected registered extension declaration`}]);let n=validateContentConfiguration({type:`custom`,extension:e.name,parameters:t},[`content`]);if(n.type!==`custom`)throw new E(`Expected custom content`,[]);let r=new z({...n,extension:e.name},e);return r.build(),r}const B={collection,form:form$1,activity,richtext:richtext$1,documents,forms,emails,meetings,custom};function validateFlagName(e){if(!/^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/.test(e))throw Error(`Invalid flag name "${e}". Flag names must be kebab-case (e.g., "architect-mode", "ai-features").`)}var BaseFlagBuilder=class{constructor(e,t,n){validateFlagName(e),this.flag={name:e,valueType:t,defaultValue:n,allowedLevels:[`global`,`tenant`,`user`]}}label(e){return this.flag.label=e,this}description(e){return this.flag.description=e,this}category(e){return this.flag.category=e,this}system(){return this.flag.system=!0,this}tenantScoped(){return this.flag.allowedLevels=[`global`,`tenant`],this}globalOnly(){return this.flag.allowedLevels=[`global`],this}allowedLevels(e){return this.flag.allowedLevels=[...e],this}build(){if(!this.flag.label?.trim())throw Error(`Flag "${this.flag.name}" must have a label. Use .label("Human-readable label").`);return{...this.flag,allowedLevels:[...this.flag.allowedLevels||[]]}}},BooleanFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`boolean`,!1)}defaultValue(e){return this.flag.defaultValue=e,this}enabledByDefault(){return this.flag.defaultValue=!0,this}},StringFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`string`,``)}defaultValue(e){return this.flag.defaultValue=e,this}},NumberFlagBuilder=class extends BaseFlagBuilder{constructor(e){super(e,`number`,0)}defaultValue(e){return this.flag.defaultValue=e,this}},JsonFlagBuilder=class extends BaseFlagBuilder{constructor(e,t){super(e,`json`,t)}defaultValue(e){return this.flag.defaultValue=e,this}};function booleanFlag(e){return new BooleanFlagBuilder(e)}function stringFlag(e){return new StringFlagBuilder(e)}function numberFlag(e){return new NumberFlagBuilder(e)}function jsonFlag(e,t){return new JsonFlagBuilder(e,t)}function duplicateFlagError(e){return new S(`feature flag`,e,`Flag "${e}" is already registered. Each flag name must be unique.`)}function cloneFlagDefinition(e){return{...e,allowedLevels:[...e.allowedLevels]}}var FlagRegistry=class{constructor(){this.flags=new Map}register(e){if(this.flags.has(e.name))throw duplicateFlagError(e.name);this.flags.set(e.name,cloneFlagDefinition(e))}registerAll(e){let t=new Set;for(let n of e){if(this.flags.has(n.name)||t.has(n.name))throw duplicateFlagError(n.name);t.add(n.name)}for(let t of e)this.register(t)}get(e){let t=this.flags.get(e);return t?cloneFlagDefinition(t):void 0}getOrThrow(e){let t=this.get(e);if(!t)throw new C(`Feature flag`,e,void 0,`Flag "${e}" is not registered. Available flags: ${this.listNames().join(`, `)}`);return t}has(e){return this.flags.has(e)}list(){return Array.from(this.flags.values(),cloneFlagDefinition)}listNames(){return Array.from(this.flags.keys())}unregister(e){return this.flags.delete(e)}clear(){this.flags.clear()}get size(){return this.flags.size}};const ni=new FlagRegistry;function createFlagRegistry(){return new FlagRegistry}function emptyOverrides(){return{global:new Map,tenant:new Map,user:new Map}}function isActiveOverride(e,t){return e.expiresAt===void 0||e.expiresAt.getTime()>t}function indexOverrides(e,t){let n=new Map;for(let r of e){if(!isActiveOverride(r,t))continue;let e=r.flagName;n.has(e)||n.set(e,r)}return n}var FlagService=class{constructor(e){this.repository=e.repository,this.registry=e.registry,this.staticDefaults=new Map(e.staticDefaults?.map(e=>[e.name,e.value])??[])}async resolveAll(e={}){let t=this.collectFlagNames(),n=this.repository&&t.size>0?await this.getAllOverrides(e,[...t]):emptyOverrides();return this.resolveNames(t,n,e)}resolveAllStatic(){return this.resolveNames(this.collectFlagNames(),emptyOverrides(),{})}collectFlagNames(){let e=new Set;for(let t of this.registry.listNames())e.add(t);for(let t of this.staticDefaults.keys())e.add(t);return e}resolveNames(e,t,n){let r=new Map;for(let i of e)r.set(i,this.resolveValue(i,t,n));return r}async resolve(e,t={}){let n=this.repository?await this.getAllOverrides(t,[e]):emptyOverrides();return this.resolveWithSource(e,n,t)}async isEnabled(e,t={}){return(await this.resolve(e,t)).value===!0}async getValue(e,t={}){return(await this.resolve(e,t)).value}async setOverride(e,t,n,r={}){if(!this.repository)throw new w(`Cannot set override: no FeatureFlagsRepository configured. Add featureFlags to your DatabaseAdapter to enable runtime overrides.`,T.CONFIGURATION_REQUIRED);let i=this.registry.get(e);if(i&&!i.allowedLevels.includes(t)){let n=`Flag "${e}" does not allow ${t}-level overrides. Allowed levels: ${i.allowedLevels.join(`, `)}`;throw new E(n,[{path:[`level`],message:n}])}if(i?.system){let t=`Flag "${e}" is a system flag and cannot be overridden via API.`;throw new E(t,[{path:[`flagName`],message:t}])}await this.repository.setOverride({flagName:e,level:t,value:n,targetId:r.targetId,expiresAt:r.expiresAt,createdBy:r.createdBy})}async deleteOverride(e,t,n){if(!this.repository)throw new w(`Cannot delete override: no FeatureFlagsRepository configured.`,T.CONFIGURATION_REQUIRED);await this.repository.deleteOverride(e,t,n)}async getAllOverrides(e,t){if(!this.repository)return emptyOverrides();let[n,r,i]=await Promise.all([this.repository.getOverrides({level:`global`,flagNames:t}),e.tenantId?this.repository.getOverrides({level:`tenant`,targetId:e.tenantId,flagNames:t}):Promise.resolve([]),e.userId?this.repository.getOverrides({level:`user`,targetId:e.userId,flagNames:t}):Promise.resolve([])]),a=Date.now();return{global:indexOverrides(n,a),tenant:indexOverrides(r,a),user:indexOverrides(i,a)}}resolveValue(e,t,n){return this.resolveWithSource(e,t,n).value}resolveWithSource(e,t,n){let r=this.registry.get(e),i=r?.allowedLevels??[`global`,`tenant`,`user`];if(n.userId&&i.includes(`user`)){let r=t.user.get(e);if(r)return{name:e,value:r.value,source:`user`,sourceId:n.userId}}if(n.tenantId&&i.includes(`tenant`)){let r=t.tenant.get(e);if(r)return{name:e,value:r.value,source:`tenant`,sourceId:n.tenantId}}if(i.includes(`global`)){let n=t.global.get(e);if(n)return{name:e,value:n.value,source:`global`}}return this.staticDefaults.has(e)?{name:e,value:this.staticDefaults.get(e),source:`default`}:{name:e,value:r?.defaultValue??void 0,source:`default`}}};function createFlagService(e){return new FlagService(e)}const ri=Symbol(`stndrds.native-object`);function markNativeDefinition(e){return Object.defineProperty(e,ri,{value:!0,enumerable:!1}),e}var NativeObjectBuilder=class extends ObjectBuilder{build(){return markNativeDefinition(super.build())}};function nativeObject(e){return new NativeObjectBuilder(e)}function isNativeDefinition(e){return e[ri]===!0}function cloneObjectDefinition(e){let t=structuredClone(e);return isNativeDefinition(e)?markNativeDefinition(t):t}var NativeObjectRegistryClass=class{constructor(){this.objects=new Map}register(e){let t=(Array.isArray(e)?e:[e]).map(e=>`build`in e&&typeof e.build==`function`?e.build():e),n=new Set;for(let e of t){if(this.validate(e),n.has(e.name))throw new S(`object`,e.name,`[NativeObjectRegistry] Duplicate object name "${e.name}" within a single register() batch.`);n.add(e.name)}for(let e of t)this.objects.set(e.name,cloneObjectDefinition(e));return this}validate(e){if(!e.system){let t=`[NativeObjectRegistry] Cannot register object "${e.name}" (id: ${e.id}): missing system flag.\nNative objects must have system=true. Did you call .runtime() on the builder? Remove that call — objects are system:true by default.`;throw new E(t,[])}if(A(e.name)&&!isNativeDefinition(e))throw new Xe(e.name,`registry`);if(this.objects.has(e.name)){let t=this.objects.get(e.name),n=`[NativeObjectRegistry] Duplicate object name "${e.name}":\n - Existing: "${t?.label}" (id: ${t?.id})\n - New: "${e.label}" (id: ${e.id})\nPlease use unique names for each native object.`;throw new S(`object`,e.name,n)}}getByName(e){let t=this.objects.get(e);return t?cloneObjectDefinition(t):void 0}getByNameOrThrow(e){let t=this.getByName(e);if(!t){let t=`[NativeObjectRegistry] Native object "${e}" not found.\nAvailable objects: ${this.listNames().join(`, `)}`;throw new C(`Native object`,e,T.OBJECT_NOT_FOUND,t)}return t}getAll(){return Array.from(this.objects.values(),cloneObjectDefinition)}listNames(){return Array.from(this.objects.keys())}has(e){return this.objects.has(e)}get size(){return this.objects.size}clear(){this.objects.clear()}summary(){let e=this.getAll();return[`[NativeObjectRegistry] ${this.size} native object(s) registered:`,...e.map(e=>` - ${e.name}: "${e.label}" (${e.attributes.length} attributes)`)].join(`
|
|
3
3
|
`)}debug(e){let t=this.summary();return e?.(t),t}};const ii=new NativeObjectRegistryClass,ai=new WeakSet;function markSystemView(e){return ai.add(e.definition),e}function isSystemViewDefinition(e){return typeof e==`object`&&!!e&&ai.has(e)}const oi=`## Overview
|
|
4
4
|
|
|
5
5
|
Describe in one or two sentences what this skill does and the outcome it produces. The agent reads this page when it uses the skill — write instructions for the agent, not documentation for people.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
const e=require("./exceptions.js"),t=require("./text-A9AJ1wUO.js"),n=require("./phone-
|
|
2
|
+
const e=require("./exceptions.js"),t=require("./text-A9AJ1wUO.js"),n=require("./phone-DVaELsa3.js"),r=require("./core-397tQy5q.js"),i=require("./validation/complex/currency.js"),a=require("./validation/complex/location.js"),o=require("./validation/complex/relation.js"),s=require("./validation/complex/richtext.js"),c=require("./validation/complex/select.js"),l=require("./validation/complex/user.js"),u=require("./validation/computed/formula.js"),d=require("./validation/computed/rollup.js"),f=require("./validation/primitives/checkbox.js"),p=require("./validation/primitives/date.js"),m=require("./validation/primitives/number.js");let h=require("zod");function isNullishOrEmptyString(e){return e==null||e===``}function isValuePresent(e){return e==null?!1:typeof e==`string`?e.trim()!==``:!Array.isArray(e)||e.length>0}const g={phone:[`countryCode`]};function isEmptyValue(e,t=[]){return e==null||typeof e==`string`&&e.trim()===``?!0:e instanceof Date?!1:typeof e==`object`&&!Array.isArray(e)&&Object.entries(e).filter(([e])=>!t.includes(e)).every(([,e])=>e==null||typeof e==`string`&&e.trim()===``)}function withEmptyToNull(e,t){return h.z.preprocess(e=>isEmptyValue(e,t)?null:e,e.nullish())}function createAttributeValidator(e,g=r.n){switch(e.type){case`text`:return t.t(e,g);case`richtext`:return s.createRichtextValidator(e,g);case`number`:return m.createNumberValidator(e,g);case`checkbox`:return f.createCheckboxValidator(e,g);case`date`:return p.createDateValidator(e,g);case`phone`:return n.t(e,g);case`currency`:return i.createCurrencyValidator(e,g);case`status`:return c.createStatusValidator(e,g);case`location`:return a.createLocationValidator(e,g);case`select`:return c.createSelectValidator(e,g);case`multiselect`:return c.createMultiselectValidator(e,g);case`user`:return l.createUserValidator(e,g);case`relation`:return o.createRelationValidator(e,g);case`formula`:return u.createFormulaValidator(e,g);case`rollup`:return d.createRollupValidator(e,g);default:return h.z.unknown()}}function createFormAttributeValidator(e,t=r.n){let n=createAttributeValidator(e,t);return e.required?n:withEmptyToNull(n,g[e.type])}const _=new WeakMap,v=new WeakMap;function createObjectValidator(e){let t=_.get(e);if(t)return t;let n={};for(let t of e.attributes){let e=createAttributeValidator(t);t.required?n[t.name]=e.refine(isValuePresent,{message:r.n.required(t)}):n[t.name]=withEmptyToNull(e,g[t.type])}let i=h.z.object(n).passthrough();return _.set(e,i),i}function createDraftValidator(e){let t=v.get(e);if(t)return t;let n={};for(let t of e.attributes){let e=createAttributeValidator(t);n[t.name]=withEmptyToNull(e,g[t.type])}let r=h.z.object(n).passthrough();return v.set(e,r),r}function validateAttribute(e,t){let n=createAttributeValidator(e);if(!e.required&&t==null)return{success:!0,data:{[e.name]:t}};let i=n.safeParse(t);return i.success?{success:!0,data:{[e.name]:i.data}}:{success:!1,errors:r.t(i.error).map(t=>({path:[e.name,...t.path],message:t.message}))}}function validateObject(e,t){let n=createObjectValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:r.t(n.error)}}function validateObjectOrThrow(t,n){let r=validateObject(t,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
|
|
3
3
|
`)||`Unknown validation error`;throw new e.ValidationError(`Validation failed for ${t.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function validateDraft(e,t){let n=createDraftValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:r.t(n.error)}}function validateDraftOrThrow(t,n){let r=validateDraft(t,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
|
|
4
4
|
`)||`Unknown validation error`;throw new e.ValidationError(`Draft validation failed for ${t.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function rejectUnknownAttributesOrThrow(t,n){let r=new Set(t.attributes.map(e=>e.name)),i=Object.keys(n).filter(e=>!r.has(e));if(i.length>0)throw new e.ValidationError(`Unknown attribute${i.length>1?`s`:``} for ${t.label}: ${i.join(`, `)}`,i.map(e=>({path:[e],message:`Unknown attribute`})))}function getMissingRequiredAttributes(e,t){let n=[];for(let r of e.attributes)r.required&&!isValuePresent(t[r.name])&&n.push(r);return n}function isRecordComplete(e,t){return getMissingRequiredAttributes(e,t).length>0?!1:validateObject(e,t).success}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return validateDraft}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return validateObjectOrThrow}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return createAttributeValidator}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return createFormAttributeValidator}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return validateAttribute}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return createDraftValidator}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return isValuePresent}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return isRecordComplete}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return validateDraftOrThrow}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return isNullishOrEmptyString}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return rejectUnknownAttributesOrThrow}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return validateObject}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return getMissingRequiredAttributes}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return createObjectValidator}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
import{ValidationError as e}from"./exceptions.mjs";import{t}from"./text-C8Lb-NFo.mjs";import{t as n}from"./phone-
|
|
2
|
+
import{ValidationError as e}from"./exceptions.mjs";import{t}from"./text-C8Lb-NFo.mjs";import{t as n}from"./phone-BawtTYVi.mjs";import{n as r,t as i}from"./core-BLHhNykL.mjs";import{createCurrencyValidator as a}from"./validation/complex/currency.mjs";import{createLocationValidator as o}from"./validation/complex/location.mjs";import{createRelationValidator as s}from"./validation/complex/relation.mjs";import{createRichtextValidator as c}from"./validation/complex/richtext.mjs";import{createMultiselectValidator as l,createSelectValidator as u,createStatusValidator as d}from"./validation/complex/select.mjs";import{createUserValidator as f}from"./validation/complex/user.mjs";import{createFormulaValidator as p}from"./validation/computed/formula.mjs";import{createRollupValidator as m}from"./validation/computed/rollup.mjs";import{createCheckboxValidator as h}from"./validation/primitives/checkbox.mjs";import{createDateValidator as g}from"./validation/primitives/date.mjs";import{createNumberValidator as _}from"./validation/primitives/number.mjs";import{z as v}from"zod";function isNullishOrEmptyString(e){return e==null||e===``}function isValuePresent(e){return e==null?!1:typeof e==`string`?e.trim()!==``:!Array.isArray(e)||e.length>0}const y={phone:[`countryCode`]};function isEmptyValue(e,t=[]){return e==null||typeof e==`string`&&e.trim()===``?!0:e instanceof Date?!1:typeof e==`object`&&!Array.isArray(e)&&Object.entries(e).filter(([e])=>!t.includes(e)).every(([,e])=>e==null||typeof e==`string`&&e.trim()===``)}function withEmptyToNull(e,t){return v.preprocess(e=>isEmptyValue(e,t)?null:e,e.nullish())}function createAttributeValidator(e,i=r){switch(e.type){case`text`:return t(e,i);case`richtext`:return c(e,i);case`number`:return _(e,i);case`checkbox`:return h(e,i);case`date`:return g(e,i);case`phone`:return n(e,i);case`currency`:return a(e,i);case`status`:return d(e,i);case`location`:return o(e,i);case`select`:return u(e,i);case`multiselect`:return l(e,i);case`user`:return f(e,i);case`relation`:return s(e,i);case`formula`:return p(e,i);case`rollup`:return m(e,i);default:return v.unknown()}}function createFormAttributeValidator(e,t=r){let n=createAttributeValidator(e,t);return e.required?n:withEmptyToNull(n,y[e.type])}const b=new WeakMap,x=new WeakMap;function createObjectValidator(e){let t=b.get(e);if(t)return t;let n={};for(let t of e.attributes){let e=createAttributeValidator(t);t.required?n[t.name]=e.refine(isValuePresent,{message:r.required(t)}):n[t.name]=withEmptyToNull(e,y[t.type])}let i=v.object(n).passthrough();return b.set(e,i),i}function createDraftValidator(e){let t=x.get(e);if(t)return t;let n={};for(let t of e.attributes){let e=createAttributeValidator(t);n[t.name]=withEmptyToNull(e,y[t.type])}let r=v.object(n).passthrough();return x.set(e,r),r}function validateAttribute(e,t){let n=createAttributeValidator(e);if(!e.required&&t==null)return{success:!0,data:{[e.name]:t}};let r=n.safeParse(t);return r.success?{success:!0,data:{[e.name]:r.data}}:{success:!1,errors:i(r.error).map(t=>({path:[e.name,...t.path],message:t.message}))}}function validateObject(e,t){let n=createObjectValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:i(n.error)}}function validateObjectOrThrow(t,n){let r=validateObject(t,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
|
|
3
3
|
`)||`Unknown validation error`;throw new e(`Validation failed for ${t.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function validateDraft(e,t){let n=createDraftValidator(e).safeParse(t);return n.success?{success:!0,data:n.data}:{success:!1,errors:i(n.error)}}function validateDraftOrThrow(t,n){let r=validateDraft(t,n);if(!r.success){let n=r.errors??[],i=n.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`
|
|
4
4
|
`)||`Unknown validation error`;throw new e(`Draft validation failed for ${t.label}:\n${i}`,n.map(e=>({path:e.path,message:e.message})))}return r.data}function rejectUnknownAttributesOrThrow(t,n){let r=new Set(t.attributes.map(e=>e.name)),i=Object.keys(n).filter(e=>!r.has(e));if(i.length>0)throw new e(`Unknown attribute${i.length>1?`s`:``} for ${t.label}: ${i.join(`, `)}`,i.map(e=>({path:[e],message:`Unknown attribute`})))}function getMissingRequiredAttributes(e,t){let n=[];for(let r of e.attributes)r.required&&!isValuePresent(t[r.name])&&n.push(r);return n}function isRecordComplete(e,t){return getMissingRequiredAttributes(e,t).length>0?!1:validateObject(e,t).success}export{validateDraft as a,validateObjectOrThrow as c,createAttributeValidator as d,createFormAttributeValidator as f,validateAttribute as i,createDraftValidator as l,isValuePresent as m,isRecordComplete as n,validateDraftOrThrow as o,isNullishOrEmptyString as p,rejectUnknownAttributesOrThrow as r,validateObject as s,getMissingRequiredAttributes as t,createObjectValidator as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
import{n as e}from"./core-BLHhNykL.mjs";import{getCountryByIso3 as t,isValidIso3 as n,stripTrunkPrefix as r}from"@stndrds/constants";import{parsePhoneNumberFromString as i}from"libphonenumber-js";import{z as a}from"zod";function digitsOnly(e){return e.replace(/\D/g,``)}function normalizeCountrylessPhoneNumber(e){return digitsOnly(e)}function getIso2(e){return t(e)?.iso2}function normalizePhoneNumber(e,n){if(!e)return``;let a=getIso2(n);if(!a)return digitsOnly(e);let o=i(e,a);if(o)return o.nationalNumber;let s=t(n),c=digitsOnly(e);if(s){let e=s.phoneCode.replace(`+`,``),t=c.startsWith(e)?c.slice(e.length):c;return r(t,s.phoneTrunkPrefix??``)}return c}function formatPhoneForDisplay(e){if(!e.phoneNumber)return``;let n=getIso2(e.countryCode),r=t(e.countryCode)?.phoneCode??``;if(!n)return`${r} ${e.phoneNumber}`.trim();let a=`${r}${digitsOnly(e.phoneNumber)}`,o=i(a);return o?o.formatInternational():`${r} ${e.phoneNumber}`.trim()}function createPhoneValidator(t,r=e){return a.object({countryCode:a.string().length(3),phoneNumber:a.string().min(1)},{message:r.invalidPhone(t)}).refine(e=>n(e.countryCode),{message:`Invalid country code`}).transform(e=>({countryCode:e.countryCode,phoneNumber:normalizePhoneNumber(e.phoneNumber,e.countryCode)}))}export{normalizePhoneNumber as i,formatPhoneForDisplay as n,normalizeCountrylessPhoneNumber as r,createPhoneValidator as t};
|
|
2
|
+
import{n as e}from"./core-BLHhNykL.mjs";import{getCountryByIso3 as t,isValidIso3 as n,stripTrunkPrefix as r}from"@stndrds/constants";import{parsePhoneNumberFromString as i}from"libphonenumber-js";import{z as a}from"zod";function digitsOnly(e){return e.replace(/\D/g,``)}function normalizeCountrylessPhoneNumber(e){return digitsOnly(e)}function getIso2(e){return t(e)?.iso2}function normalizePhoneNumber(e,n){if(!e)return``;let a=getIso2(n);if(!a)return digitsOnly(e);let o=i(e,a);if(o)return o.nationalNumber;let s=t(n),c=digitsOnly(e);if(s){let e=s.phoneCode.replace(`+`,``),t=c.startsWith(e)?c.slice(e.length):c;return r(t,s.phoneTrunkPrefix??``)}return c}function formatPhoneForDisplay(e){if(!e.phoneNumber)return``;let n=getIso2(e.countryCode),r=t(e.countryCode)?.phoneCode??``;if(!n)return`${r} ${e.phoneNumber}`.trim();let a=`${r}${digitsOnly(e.phoneNumber)}`,o=i(a);return o?o.formatInternational():`${r} ${e.phoneNumber}`.trim()}function createPhoneValidator(t,r=e){return a.object({countryCode:a.string().length(3),phoneNumber:a.string().min(1,{message:r.required(t)})},{message:r.invalidPhone(t)}).refine(e=>n(e.countryCode),{message:`Invalid country code`}).transform(e=>({countryCode:e.countryCode,phoneNumber:normalizePhoneNumber(e.phoneNumber,e.countryCode)}))}export{normalizePhoneNumber as i,formatPhoneForDisplay as n,normalizeCountrylessPhoneNumber as r,createPhoneValidator as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
const e=require("./core-397tQy5q.js");let t=require("@stndrds/constants"),n=require("libphonenumber-js"),r=require("zod");function digitsOnly(e){return e.replace(/\D/g,``)}function normalizeCountrylessPhoneNumber(e){return digitsOnly(e)}function getIso2(e){return(0,t.getCountryByIso3)(e)?.iso2}function normalizePhoneNumber(e,r){if(!e)return``;let i=getIso2(r);if(!i)return digitsOnly(e);let a=(0,n.parsePhoneNumberFromString)(e,i);if(a)return a.nationalNumber;let o=(0,t.getCountryByIso3)(r),s=digitsOnly(e);if(o){let e=o.phoneCode.replace(`+`,``),n=s.startsWith(e)?s.slice(e.length):s;return(0,t.stripTrunkPrefix)(n,o.phoneTrunkPrefix??``)}return s}function formatPhoneForDisplay(e){if(!e.phoneNumber)return``;let r=getIso2(e.countryCode),i=(0,t.getCountryByIso3)(e.countryCode)?.phoneCode??``;if(!r)return`${i} ${e.phoneNumber}`.trim();let a=`${i}${digitsOnly(e.phoneNumber)}`,o=(0,n.parsePhoneNumberFromString)(a);return o?o.formatInternational():`${i} ${e.phoneNumber}`.trim()}function createPhoneValidator(n,i=e.n){return r.z.object({countryCode:r.z.string().length(3),phoneNumber:r.z.string().min(1)},{message:i.invalidPhone(n)}).refine(e=>(0,t.isValidIso3)(e.countryCode),{message:`Invalid country code`}).transform(e=>({countryCode:e.countryCode,phoneNumber:normalizePhoneNumber(e.phoneNumber,e.countryCode)}))}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return normalizePhoneNumber}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return formatPhoneForDisplay}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return normalizeCountrylessPhoneNumber}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return createPhoneValidator}});
|
|
2
|
+
const e=require("./core-397tQy5q.js");let t=require("@stndrds/constants"),n=require("libphonenumber-js"),r=require("zod");function digitsOnly(e){return e.replace(/\D/g,``)}function normalizeCountrylessPhoneNumber(e){return digitsOnly(e)}function getIso2(e){return(0,t.getCountryByIso3)(e)?.iso2}function normalizePhoneNumber(e,r){if(!e)return``;let i=getIso2(r);if(!i)return digitsOnly(e);let a=(0,n.parsePhoneNumberFromString)(e,i);if(a)return a.nationalNumber;let o=(0,t.getCountryByIso3)(r),s=digitsOnly(e);if(o){let e=o.phoneCode.replace(`+`,``),n=s.startsWith(e)?s.slice(e.length):s;return(0,t.stripTrunkPrefix)(n,o.phoneTrunkPrefix??``)}return s}function formatPhoneForDisplay(e){if(!e.phoneNumber)return``;let r=getIso2(e.countryCode),i=(0,t.getCountryByIso3)(e.countryCode)?.phoneCode??``;if(!r)return`${i} ${e.phoneNumber}`.trim();let a=`${i}${digitsOnly(e.phoneNumber)}`,o=(0,n.parsePhoneNumberFromString)(a);return o?o.formatInternational():`${i} ${e.phoneNumber}`.trim()}function createPhoneValidator(n,i=e.n){return r.z.object({countryCode:r.z.string().length(3),phoneNumber:r.z.string().min(1,{message:i.required(n)})},{message:i.invalidPhone(n)}).refine(e=>(0,t.isValidIso3)(e.countryCode),{message:`Invalid country code`}).transform(e=>({countryCode:e.countryCode,phoneNumber:normalizePhoneNumber(e.phoneNumber,e.countryCode)}))}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return normalizePhoneNumber}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return formatPhoneForDisplay}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return normalizeCountrylessPhoneNumber}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return createPhoneValidator}});
|
package/dist/validation/all.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../config-BQJJHopR.js"),t=require("../view-config.schema-to6p1m8L.js"),n=require("../object-
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../config-BQJJHopR.js"),t=require("../view-config.schema-to6p1m8L.js"),n=require("../object-DGu0m2Y1.js"),r=require("../core-397tQy5q.js");exports.DEFAULT_VALIDATION_MESSAGES=r.n,exports.SCHEMA_LIMITS=e.S,exports.SIMPLE_PROPERTY_TYPES=e.t,exports.WIRE_OMITTED_CONFIG_KEYS=e.n,exports.attributeConfigSchemas=e.r,exports.collectionContentSourceSchema=t.n,exports.colorIdSchema=e.b,exports.contentViewDefinitionSchema=t.i,exports.createFormAttributeValidator=n.f,exports.draftContentViewDefinitionSchema=t.s,exports.formatZodErrors=r.t,exports.iconNameSchema=e.x,exports.multiselectOptionWriteSchema=e.o,exports.parseAttributeConfig=e.s,exports.parseAttributeConfigForCreate=e.c,exports.parseAttributeConfigForUpdate=e.l,exports.propertyAttributeSchema=e.u,exports.propertyAttributeWireSchema=e.d,exports.propertySchemaSchema=e.f,exports.propertySchemaWireSchema=e.p,exports.publishedViewContentDefinitionSchema=t.u,exports.refuseForeignKeys=e.m,exports.rejectUnknownAttributesOrThrow=n.r,exports.selectOptionWriteSchema=e.h,exports.statusGroupSchema=e.g,exports.statusOptionWriteSchema=e._,exports.validateDraft=n.a,exports.validateDraftOrThrow=n.o,exports.validateObject=n.s,exports.validateObjectOrThrow=n.c;
|
package/dist/validation/all.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
import{i as e,n as t,s as n,u as r}from"../view-config.schema-B4AkqLKQ.mjs";import{S as i,_ as a,b as o,c as s,d as c,f as l,g as u,h as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,x}from"../config-_sOeudpS.mjs";import{a as S,c as C,f as w,o as T,r as E,s as D}from"../object-
|
|
2
|
+
import{i as e,n as t,s as n,u as r}from"../view-config.schema-B4AkqLKQ.mjs";import{S as i,_ as a,b as o,c as s,d as c,f as l,g as u,h as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,x}from"../config-_sOeudpS.mjs";import{a as S,c as C,f as w,o as T,r as E,s as D}from"../object-DSRy1coV.mjs";import{n as O,t as k}from"../core-BLHhNykL.mjs";export{O as DEFAULT_VALIDATION_MESSAGES,i as SCHEMA_LIMITS,y as SIMPLE_PROPERTY_TYPES,m as WIRE_OMITTED_CONFIG_KEYS,_ as attributeConfigSchemas,t as collectionContentSourceSchema,o as colorIdSchema,e as contentViewDefinitionSchema,w as createFormAttributeValidator,n as draftContentViewDefinitionSchema,k as formatZodErrors,x as iconNameSchema,h as multiselectOptionWriteSchema,v as parseAttributeConfig,s as parseAttributeConfigForCreate,f as parseAttributeConfigForUpdate,b as propertyAttributeSchema,c as propertyAttributeWireSchema,l as propertySchemaSchema,g as propertySchemaWireSchema,r as publishedViewContentDefinitionSchema,p as refuseForeignKeys,E as rejectUnknownAttributesOrThrow,d as selectOptionWriteSchema,u as statusGroupSchema,a as statusOptionWriteSchema,S as validateDraft,T as validateDraftOrThrow,D as validateObject,C as validateObjectOrThrow};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../phone-
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../phone-DVaELsa3.js");exports.createPhoneValidator=e.t;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
import{t as e}from"../../phone-
|
|
2
|
+
import{t as e}from"../../phone-BawtTYVi.mjs";export{e as createPhoneValidator};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../object-
|
|
2
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../object-DGu0m2Y1.js");exports.createAttributeValidator=e.d,exports.createDraftValidator=e.l,exports.createFormAttributeValidator=e.f,exports.createObjectValidator=e.u,exports.getMissingRequiredAttributes=e.t,exports.isRecordComplete=e.n,exports.rejectUnknownAttributesOrThrow=e.r,exports.validateAttribute=e.i,exports.validateDraft=e.a,exports.validateDraftOrThrow=e.o,exports.validateObject=e.s,exports.validateObjectOrThrow=e.c;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"../../object-
|
|
2
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"../../object-DSRy1coV.mjs";export{n as createAttributeValidator,a as createDraftValidator,r as createFormAttributeValidator,d as createObjectValidator,u as getMissingRequiredAttributes,o as isRecordComplete,c as rejectUnknownAttributesOrThrow,i as validateAttribute,e as validateDraft,s as validateDraftOrThrow,l as validateObject,t as validateObjectOrThrow};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stndrds/schema",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.332",
|
|
4
4
|
"description": "Standard schema definitions and utilities",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"@standard-schema/spec": "^1.1.0",
|
|
128
128
|
"libphonenumber-js": "^1.12.31",
|
|
129
129
|
"zod": "^4.2.1",
|
|
130
|
-
"@stndrds/constants": "1.0.0-alpha.
|
|
130
|
+
"@stndrds/constants": "1.0.0-alpha.332"
|
|
131
131
|
},
|
|
132
132
|
"devDependencies": {
|
|
133
133
|
"@types/node": "^25.0.3",
|