@stndrds/schema 1.0.0-alpha.333 → 1.0.0-alpha.336
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/{all-BLytyk5I.d.mts → all-Cen87Ixs.d.mts} +12 -11
- package/dist/{all-Cf6oNz9y.d.ts → all-SqlYyhI8.d.ts} +12 -11
- package/dist/{checkbox-DIk051px.d.ts → checkbox-3svoI60z.d.ts} +2 -2
- package/dist/{checkbox-DGuL9Z3k.d.mts → checkbox-B0drQb0k.d.mts} +2 -2
- package/dist/config-BvijG1IN.js +13 -0
- package/dist/{config-CHSqDLhx.mjs → config-aeELOnWd.mjs} +5 -5
- package/dist/{date-D7P9JtGg.d.mts → date-CORVrilQ.d.mts} +2 -2
- package/dist/{date-B4ZumBBO.d.ts → date-u9Xa5EkT.d.ts} +2 -2
- package/dist/{exceptions-DG_iMvYs.d.mts → exceptions-LUovX1Xh.d.mts} +1 -0
- package/dist/{exceptions-DG_iMvYs.d.ts → exceptions-LUovX1Xh.d.ts} +1 -0
- package/dist/exceptions.d.mts +1 -1
- package/dist/exceptions.d.ts +1 -1
- package/dist/exceptions.js +1 -1
- package/dist/exceptions.mjs +1 -1
- package/dist/{index-B6DXIuf2.d.ts → index-BcjEnWLU.d.ts} +2 -2
- package/dist/{index-ZnCTYc93.d.ts → index-Bsfq_aDE.d.ts} +1 -1
- package/dist/{index-gM_g_Y_H.d.mts → index-BxlwF7Mg.d.mts} +1 -1
- package/dist/{index-CePzb28P.d.ts → index-C0VbD25z.d.ts} +1 -1
- package/dist/{index-CK7gaSRm.d.mts → index-CmGHLozK.d.mts} +1 -1
- package/dist/{index--ukNqScY.d.mts → index-CxNwSJ7O.d.mts} +2 -2
- package/dist/index.d.mts +119 -30
- package/dist/index.d.ts +119 -30
- package/dist/index.js +2 -2
- package/dist/index.mjs +9 -9
- package/dist/{number-DYExtkZN.d.mts → number-BhkK5Nuu.d.mts} +2 -2
- package/dist/{number-BMX9OJ46.d.ts → number-dfPBKJ09.d.ts} +2 -2
- package/dist/{object-CUkTFj0u.js → object-BfGtzS7g.js} +2 -2
- package/dist/object-D-aDCAHn.mjs +4 -0
- package/dist/{phone-CLsxU8tv.js → phone-CUgSbH-z.js} +1 -1
- package/dist/{phone-DfXAzPpD.mjs → phone-X_nKo0qe.mjs} +1 -1
- package/dist/{text-BwN_Y1Du.d.mts → text-B8oxuO3F.d.mts} +2 -2
- package/dist/{text-6w5qf9V1.d.ts → text-DF7MUSRq.d.ts} +2 -2
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/validation/all.d.mts +4 -4
- package/dist/validation/all.d.ts +4 -4
- package/dist/validation/all.js +1 -1
- package/dist/validation/all.mjs +1 -1
- package/dist/validation/complex/currency.d.mts +2 -2
- package/dist/validation/complex/currency.d.ts +2 -2
- package/dist/validation/complex/location.d.mts +2 -2
- package/dist/validation/complex/location.d.ts +2 -2
- package/dist/validation/complex/phone.d.mts +2 -2
- package/dist/validation/complex/phone.d.ts +2 -2
- package/dist/validation/complex/phone.js +1 -1
- package/dist/validation/complex/phone.mjs +1 -1
- package/dist/validation/complex/relation.d.mts +2 -2
- package/dist/validation/complex/relation.d.ts +2 -2
- package/dist/validation/complex/richtext.d.mts +2 -2
- package/dist/validation/complex/richtext.d.ts +2 -2
- package/dist/validation/complex/select.d.mts +2 -2
- package/dist/validation/complex/select.d.ts +2 -2
- package/dist/validation/complex/user.d.mts +2 -2
- package/dist/validation/complex/user.d.ts +2 -2
- package/dist/validation/computed/formula.d.mts +2 -2
- package/dist/validation/computed/formula.d.ts +2 -2
- package/dist/validation/computed/rollup.d.mts +2 -2
- package/dist/validation/computed/rollup.d.ts +2 -2
- package/dist/validation/config/index.d.mts +1 -1
- package/dist/validation/config/index.d.ts +1 -1
- package/dist/validation/config/index.js +1 -1
- package/dist/validation/config/index.mjs +1 -1
- package/dist/validation/core/index.d.mts +1 -1
- package/dist/validation/core/index.d.ts +1 -1
- package/dist/validation/object/index.d.mts +1 -1
- package/dist/validation/object/index.d.ts +1 -1
- package/dist/validation/object/index.js +1 -1
- package/dist/validation/object/index.mjs +1 -1
- package/dist/validation/primitives/checkbox.d.mts +1 -1
- package/dist/validation/primitives/checkbox.d.ts +1 -1
- package/dist/validation/primitives/date.d.mts +1 -1
- package/dist/validation/primitives/date.d.ts +1 -1
- package/dist/validation/primitives/number.d.mts +1 -1
- package/dist/validation/primitives/number.d.ts +1 -1
- package/dist/validation/primitives/text.d.mts +1 -1
- package/dist/validation/primitives/text.d.ts +1 -1
- package/dist/{view-config.schema-D-TbyG6j.js → view-config.schema-4QhPV9el.js} +1 -1
- package/dist/{view-config.schema-CcfExWMt.mjs → view-config.schema-CMjVNRCh.mjs} +1 -1
- package/package.json +2 -2
- package/dist/config-CFYxsRcx.js +0 -13
- package/dist/object-B9V5JZzh.mjs +0 -4
|
@@ -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("./config-CFYxsRcx.js"),t=require("./exceptions.js");let n=require("zod");const r={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`};function getSystemAttributeI18nKey(e){return r[e]}const i={createdAt:{id:`system:createdAt`,name:`createdAt`,label:`Created time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was created`},updatedAt:{id:`system:updatedAt`,name:`updatedAt`,label:`Last edited time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was last modified`},createdBy:{id:`system:createdBy`,name:`createdBy`,label:`Created by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who created this record`},lastUpdatedBy:{id:`system:lastUpdatedBy`,name:`lastUpdatedBy`,label:`Last edited by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who last modified this record`},attachments:{id:`system:attachments`,name:`attachments`,label:`Attachments`,type:`document`,required:!1,system:!0,hidden:!0,icon:`paperclip`,description:`Free-form document attachments`}};function getSystemAttributeList(){return Object.values(i)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const a=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],o=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],s=[`is`],c=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],l=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],u=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],d=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],f=[`is_empty`,`is_not_empty`],p=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],m=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return m.includes(e)}function isLocationPartOperator(e){return a.includes(e)}const h={text:a,richtext:[],number:o,checkbox:s,date:c,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:o,status:l,select:l,multiselect:u,location:[],user:d,relation:d,formula:p,document:f},g=new Set([`formula`,`rollup`]),ee=new Set([`user`,`relation`,`document`]),_=new Set([`text`,`richtext`,`number`,`select`,`multiselect`,`status`,`date`,`phone`,`currency`,`location`,`user`,`relation`,`document`]),te=new Set([`text`,`number`,`date`,`phone`,`currency`,`select`,`multiselect`]),ne=new Set([`text`,`phone`,`status`,`select`,`multiselect`]),re=new Set([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`]);function getAttributeCapabilities(e){let t=!!(e.hidden||e.archived),n=!e.archived,r=g.has(e.type),i=e.type===`document`,a=ee.has(e.type),o=getAttributeCardinality(e),s=t?[]:getRawFilterOperators(e),c=s.length>0&&!t,l=!t&&ne.has(e.type),u=!t&&re.has(e.type),d=!t&&isGroupableType(e.type),f=!t&&e.type===`status`,p=isManagedSystemAttribute(e),m=r||i||p,h=!(t||m),_=isRequiredForbidden(e.type)?`forbidden`:`allowed`,v=getDefaultValueCapability(e.type),y=supportsMaxItems(e),b=te.has(e.type),x=!(!e.deprecated||t),S=resolveEditMode(e);return{lifecycle:{active:n,deprecated:!!e.deprecated,visibleInArchitect:!0,visibleInRuntime:!t,warningWhenDeprecated:x},storage:{mode:r?`computed`:a?`edge`:`value`,cardinality:o,edgeBacked:a,preservesExistingValues:!!e.archived,qualifiedProperties:supportsQualifiedProperties(e.type),polymorphic:getPolymorphicCapability(e),maxItems:y},authoring:{editable:h,readOnly:m,directEdit:h&&S===`inline`,required:_,defaultValue:v,placeholder:b,maxItems:y},presentation:{formField:!t&&isFormFieldType(e.type),tableCell:!t&&isTableCellType(e.type),defaultColumn:!t&&isDefaultColumnType(e.type),compactDisplay:!t,popoverEditor:!t&&S===`popover`,placeholder:b,warningWhenDeprecated:x},query:{filterable:c,searchable:l,sortable:u,groupable:d,kanbanGroupable:f,operators:s},agent:{readable:!t,writable:h&&!i,compactReadable:!t,contentReadable:!t&&isContentReadableType(e.type),requiresDedicatedTool:i},exchange:{importable:!t,exportable:!t,schemaExportable:!0,metadataExportable:!1}}}function getAttributeFilterOperators(e){return getAttributeCapabilities(e).query.operators}function isAttributeFilterable(e){return getAttributeCapabilities(e).query.filterable}function isAttributeSearchable(e){return getAttributeCapabilities(e).query.searchable}function isAttributeSortable(e){return getAttributeCapabilities(e).query.sortable}function isAttributeGroupable(e){return getAttributeCapabilities(e).query.groupable}function isAttributeKanbanGroupable(e){return getAttributeCapabilities(e).query.kanbanGroupable}function resolveEffectiveFilterType(e){if(e.type!==`rollup`)return e.type;let t=e;if(t.function===`earliest`||t.function===`latest`)return`date`;if(t.function===`original`){let e=t.targetAttributeType;if(e&&hasFilterOperatorEntry(e))return e}return`number`}function getRollupFilterOperators$1(e){let t=resolveEffectiveFilterType(e);return hasFilterOperatorEntry(t)?h[t]:h.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):h[e.type]??[]}function getAttributeCardinality(e){return e.type===`multiselect`||e.type===`document`||e.type===`user`&&e.multiple===!0||e.type===`relation`&&e.cardinality===`many`?`many`:`one`}function getPolymorphicCapability(e){if(e.type!==`relation`)return`none`;let t=e.targets??[];return t.length===1&&t[0]?.object===`*`?`internal`:t.length>1?`code-only`:`none`}function supportsMaxItems(e){return e.type===`multiselect`||e.type===`relation`&&e.cardinality===`many`}function supportsQualifiedProperties(e){return e===`relation`||e===`document`}function isRequiredForbidden(e){return e===`checkbox`||e===`formula`||e===`rollup`}function getDefaultValueCapability(e){return e===`checkbox`?`automatic`:e===`formula`||e===`rollup`?`forbidden`:_.has(e)?`static`:`forbidden`}function isDefaultColumnType(e){return isTableCellType(e)}function isTableCellType(e){return e!==`richtext`&&e!==`document`}function isFormFieldType(e){return e!==`richtext`}function resolveEditMode(e){switch(e.type){case`checkbox`:return`inline`;case`number`:return e.renderAs===`rating`?`inline`:`default`;case`select`:case`multiselect`:return e.renderAs===`badges`?`inline`:`popover`;case`status`:case`relation`:case`user`:case`date`:return`popover`;default:return`default`}}function isGroupableType(e){return e===`status`||e===`currency`}function isContentReadableType(e){return e===`richtext`||e===`document`}function hasFilterOperatorEntry(e){return Object.prototype.hasOwnProperty.call(h,e)}const v=h,y=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return y.includes(e)}function filterOperatorsByTypeForGeneration(e){return e===`rollup`?y:v[e]??[]}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}function isDynamicValue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`dynamic`in e}function currentActor(){return{dynamic:`actor`,ref:`current`}}function today(){return{dynamic:`date`,anchor:`today`}}function now(){return{dynamic:`date`,anchor:`now`}}function toAmount(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function extractCurrencyFilterValue(e){return typeof e==`object`&&e?`value`in e?toAmount(e.value):null:toAmount(e)}function extractFilterValue(e){return e==null?null:typeof e==`object`&&`value`in e?e.value??null:e}const b=new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),x={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return b.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return x[e]??e}const S={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return S[e]??e}const ie=new Set(Object.values(S).filter(e=>e!==void 0));function isSetMembershipOperator(e){return ie.has(e)}function canonicalizeFilterValue(e,n){let r=e.value;if(isNoValueOperator(e.operator)||r==null||isDynamicValue(r))return;if(isSetMembershipOperator(e.operator)){Array.isArray(r)||(e.value=[r]);return}if(n!==`currency`)return;let i=extractCurrencyFilterValue(r);if(i!==null){e.value=i;return}if(!hasCurrencyAmount(r))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(r)}`;throw new t.ValidationError(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const C={eq:`is`,equals:`is`,equal:`is`,"==":`is`,"=":`is`,neq:`is_not`,notEqual:`is_not`,isNot:`is_not`,"!=":`is_not`,"<>":`is_not`,lt:`less_than`,"<":`less_than`,gt:`greater_than`,">":`greater_than`,lte:`less_or_equal`,"<=":`less_or_equal`,gte:`greater_or_equal`,">=":`greater_or_equal`,in:`any_of`,isAnyOf:`any_of`,anyOf:`any_of`,oneOf:`any_of`,notIn:`none_of`,not_in:`none_of`,isNoneOf:`none_of`,noneOf:`none_of`,notOneOf:`none_of`,startsWith:`starts_with`,beginsWith:`starts_with`,endsWith:`ends_with`,doesNotContain:`not_contains`,notContain:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`};function normalizeOperator(e){return C[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const w=864e5,T=new Set([`days`,`weeks`,`months`,`years`]),E=new Set([`past`,`future`]);function isRelativeDateValue(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.amount==`number`&&Number.isFinite(t.amount)&&t.amount>0&&typeof t.unit==`string`&&T.has(t.unit)&&typeof t.direction==`string`&&E.has(t.direction)}function utcDayStart(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function shiftUtcDay(e,t,n){if(n===`days`)return e+t*w;if(n===`weeks`)return e+t*7*w;let r=new Date(e),i=r.getUTCFullYear()+(n===`years`?t:0),a=r.getUTCMonth()+(n===`months`?t:0),o=new Date(Date.UTC(i,a+1,0)).getUTCDate();return Date.UTC(i,a,Math.min(r.getUTCDate(),o))}function resolveIsWithinBounds(e,t=new Date){if(!isRelativeDateValue(e))return null;let n=utcDayStart(t),r=Math.trunc(e.amount),i=e.direction===`past`?{startMs:shiftUtcDay(n,-r,e.unit),endMs:n+w}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+w};return Number.isFinite(i.startMs)&&Number.isFinite(i.endMs)?i:null}function resolveUtcDayBounds(e){if(!Number.isFinite(e))return null;let t=utcDayStart(new Date(e));return Number.isFinite(t)?{startMs:t,endMs:t+w}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const D=new Set([`relation`,`document`,`user`]),O=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],ae={id:O,objectId:O,tenantId:O,label:v.text,createdAt:v.date,updatedAt:v.date,deletedAt:v.date,createdBy:v.user,lastUpdatedBy:v.user},k={id:`text`,objectId:`text`,objectName:`text`,tenantId:`text`,label:`text`,createdAt:`date`,updatedAt:`date`,deletedAt:`date`,deletedBy:`user`,createdBy:`user`,lastUpdatedBy:`user`,visibility:`select`,ownedBy:`user`},A={before:`"less_than"`,after:`"greater_than"`,on_or_before:`"less_or_equal"`,on_or_after:`"greater_or_equal"`,is_checked:`"is" with value true`,is_not_checked:`"is" with value false`,day_month_eq:`"on_day_month"`},oe=new Set(Object.entries(h).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),se={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(e,n){let r=A[e];if(r){let n=`Unknown filter operator "${e}" — use ${r}`;throw new t.ValidationError(n,[{path:[`operator`],message:n}])}let i=normalizeOperator(e),a=se[i];if(a&&oe.has(n)){let e=`Operator "${i}" is not valid for type "${n}" — use "${a}"`;throw new t.ValidationError(e,[{path:[`operator`],message:e}])}return i}function assertOperatorForType(e,n,r){let i=resolveCanonicalOperator(e,n),a=v[n];if(!a?.includes(i)){let i=`Operator "${e}" is not valid for ${r} type "${n}". Valid operators: ${a?.length?a.join(`, `):`(no operators registered for this type)`}.`;throw new t.ValidationError(i,[{path:[`operator`],message:i}])}return i}function assertRelativeDateValue(e){if(e.operator===`is_within`&&!isRelativeDateValue(e.value)){let e=`Operator "is_within" requires a relative-date value { amount: positive number, unit: days|weeks|months|years, direction: past|future }`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}}function applyCanonicalForm(e,t,n){e.operator=t,canonicalizeFilterValue(e,n),assertRelativeDateValue(e)}function assertDynamicValueForAttribute(e,n){if(!isDynamicValue(e.value))return;let r=e.value;if(r.dynamic===`actor`&&n!==`user`){let e=`actor token (@me) is only valid on user attributes, not "${n}"`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}if(r.dynamic===`date`&&n!==`date`){let e=`date token (@today/@now) is only valid on date attributes, not "${n}"`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}}const j=m.map(e=>`"${e}"`).join(`, `);function locationPartsHint(e){return e===`location`?` A location is filtered on one of its parts: set "property" to one of ${j} and use a text operator (e.g. contains).`:``}function collectQualifiedRuleIssues(e,n){try{return validateQualifiedRule({...e},n),[]}catch(e){if(!(e instanceof t.ValidationError))throw e;return e.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(e,n){let r=n.attributes.find(t=>t.name===e.attribute),i=ae[e.attribute];if(!(r||i)){let[r,...i]=e.attribute.split(`.`),a=(i.length>0?n.attributes.find(e=>e.name===r):void 0)?.type===`location`?` Dotted paths are not supported — set "attribute" to "${r}" and "property" to ${isLocationFilterProperty(i[0]??``)?`"${i[0]}"`:`one of ${j}`}.`:e.attribute.includes(`.`)?` Dotted paths are not supported — filter on the attribute name alone, or use the full-text "query" parameter to match text inside a value.`:``,o=`Unknown attribute: ${e.attribute}${a}`;throw new t.ValidationError(o,[{path:[`attribute`],message:o}])}if(e.quantifier!==void 0&&!e.property){let e=`quantifier is only valid on qualified edge rules (set "property")`;throw new t.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!r){if(e.property)throw new t.ValidationError(`Cannot qualify system attribute "${e.attribute}"`,[{path:[`property`],message:`"${e.attribute}" is a system column, not a reference`}]);let n=k[e.attribute]??`text`,r=resolveCanonicalOperator(e.operator,n);if(!i.includes(r)){let n=`Operator "${e.operator}" is not valid for system attribute "${e.attribute}". Valid operators: ${i.join(`, `)}.`;throw new t.ValidationError(n,[{path:[`operator`],message:n}])}applyCanonicalForm(e,r,n);return}if(!e.property){assertDynamicValueForAttribute(e,r.type);let n=getAttributeFilterOperators(r),i=resolveCanonicalOperator(e.operator,r.type);if(!n.includes(i)){let i=n.length?n.join(`, `):`(not filterable)`,a=`Operator "${e.operator}" is not valid for attribute "${r.name}". Valid operators: ${i}.${locationPartsHint(r.type)}`;throw new t.ValidationError(a,[{path:[`operator`],message:a}])}applyCanonicalForm(e,i,resolveEffectiveFilterType(r));return}if(r.type===`location`){if(e.quantifier!==void 0){let e=`quantifier is not valid on a location part — a location is one value, not a set of edges`;throw new t.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!isLocationFilterProperty(e.property)){let n=`Property "${e.property}" is not a part of location "${e.attribute}". Valid parts: ${j}.`;throw new t.ValidationError(n,[{path:[`property`],message:n}])}assertDynamicValueForAttribute(e,`text`),applyCanonicalForm(e,assertOperatorForType(e.operator,`text`,`property`),`text`);return}if(!D.has(r.type))throw new t.ValidationError(`Cannot qualify ${r.type} attribute "${e.attribute}"`,[{path:[`property`],message:`Attribute "${e.attribute}" is not a reference type`}]);let a=r.properties;if(!a)throw new t.ValidationError(`Attribute "${e.attribute}" has no qualifyWith schema`,[{path:[`property`],message:`"${e.attribute}" has no qualifyWith`}]);let o=a.definitions.find(t=>t.name===e.property);if(!o)throw new t.ValidationError(`Property "${e.property}" not defined on "${e.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${e.property}`}]);applyCanonicalForm(e,assertOperatorForType(e.operator,o.type,`property`),o.type)}const M=1e4;function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null&&t.constructor?.name===`Object`}function addJsonIssue(e,t,n=[]){e.addIssue({code:`custom`,message:t,path:n})}function pushJsonArrayChildren(e,t,n,r){for(let n of Reflect.ownKeys(e))if(n!==`length`){if(n===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]);continue}(typeof n==`symbol`||!/^(0|[1-9]\d*)$/.test(n))&&addJsonIssue(r,`Arrays cannot contain non-index JSON properties`,[...t.path,n])}for(let i=e.length-1;i>=0;i--){let a=Object.getOwnPropertyDescriptor(e,String(i)),o=[...t.path,i];if(!(a&&`value`in a)){addJsonIssue(r,`Sparse arrays are not valid JSON values`,o);continue}n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1})}}function pushJsonObjectChildren(e,t,n,r){let i=Reflect.ownKeys(e);for(let a=i.length-1;a>=0;a--){let o=i[a],s=[...t.path,o];if(o===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,s);continue}if(typeof o==`symbol`){addJsonIssue(r,`Symbol keys are not valid JSON keys`,s);continue}let c=Object.getOwnPropertyDescriptor(e,o);if(!(c?.enumerable&&`value`in c)){addJsonIssue(r,`Custom props must contain enumerable data properties only`,s);continue}n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1})}}function validateJsonProps(e,t){if(typeof e!=`object`||!e){addJsonIssue(t,`Expected a plain JSON object`);return}try{if(Array.isArray(e)||!isPlainJsonObject(e)){addJsonIssue(t,`Expected a plain JSON object`);return}}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`);return}let n=new WeakSet,r=[{kind:`enter`,value:e,path:[],depth:0}],i=0;for(;r.length>0;){let e=r.pop();if(!e)break;if(e.kind===`exit`){n.delete(e.value);continue}if(i++,i>M){addJsonIssue(t,`Custom props cannot exceed ${M.toLocaleString(`en-US`)} total JSON nodes`,e.path);return}if(e.depth>64){addJsonIssue(t,`Custom props cannot exceed depth 64`,e.path);continue}let a=e.value;if(!(a===null||typeof a==`string`||typeof a==`boolean`||typeof a==`number`&&Number.isFinite(a))){if(typeof a!=`object`){addJsonIssue(t,`Expected a JSON value`,e.path);continue}if(n.has(a)){addJsonIssue(t,`Custom props cannot contain circular references`,e.path);continue}try{if(Array.isArray(a)){n.add(a),r.push({kind:`exit`,value:a}),pushJsonArrayChildren(a,e,r,t);continue}if(!isPlainJsonObject(a)){addJsonIssue(t,`Expected an array or plain JSON object`,e.path);continue}n.add(a),r.push({kind:`exit`,value:a}),pushJsonObjectChildren(a,e,r,t)}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`,e.path)}}}}const N=n.z.unknown().superRefine(validateJsonProps).transform(e=>e),P=n.z.array(n.z.string()).max(e.S.columnsPerTab),F=n.z.array(n.z.string().min(1)).max(e.S.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),I=n.z.object({attribute:n.z.string().describe(`Attribute to sort by`),direction:n.z.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),L=n.z.array(I).max(e.S.sortsPerTab),R=n.z.object({amount:n.z.number().describe(`Count`),unit:n.z.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:n.z.enum([`past`,`future`]).describe(`Past or future`)}).strict(),z=n.z.object({value:n.z.number().nullable().describe(`Amount`),code:n.z.array(n.z.string()).optional().describe(`Currency codes`)}).strict(),B=n.z.object({phoneNumber:n.z.string().nullable().describe(`Number`),countryCode:n.z.string().optional().describe(`ISO country code`)}).strict(),V=n.z.discriminatedUnion(`dynamic`,[n.z.object({dynamic:n.z.literal(`actor`).describe(`Resolved at filter time`),ref:n.z.literal(`current`).describe(`The current actor`)}).strict(),n.z.object({dynamic:n.z.literal(`date`).describe(`Resolved at filter time`),anchor:n.z.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),H=n.z.object({month:n.z.number().describe(`1-12`),day:n.z.number().describe(`Day`)}).strict(),U=n.z.union([n.z.string(),n.z.number(),n.z.boolean(),n.z.array(n.z.string()),R,z,B,H,V,n.z.null()]),W=n.z.enum([`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`any_of`,`none_of`],{error:e=>{let t=e.input,n=typeof t==`string`?A[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),G=n.z.object({attribute:n.z.string().describe(`Attribute to filter on`),property:n.z.string().optional().describe(`Qualified edge property`),quantifier:n.z.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:W.describe(`Comparison`),value:U.describe(`Comparison value, by attribute type`)}).strict(),K=n.z.array(G).max(e.S.filterRulesPerTab),q=n.z.object({combinator:n.z.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:K.describe(`The rules`)}).strict(),ce={span:n.z.union([n.z.literal(1),n.z.literal(2),n.z.literal(3),n.z.literal(4),n.z.literal(5),n.z.literal(6),n.z.literal(7),n.z.literal(8),n.z.literal(9),n.z.literal(10),n.z.literal(11),n.z.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:n.z.string().optional().describe(`Overrides the attribute's label`),readOnly:n.z.boolean().optional().describe(`Shows the value, not editable`)},le=n.z.object({attribute:n.z.string().describe(`Attribute API name shown by this field`),...ce}).strict(),ue=n.z.object({name:n.z.string().describe(`Group API name, unique in the form`),label:n.z.string().describe(`Label people see`),description:n.z.string().optional().describe(`Extra context under the label`),collapsible:n.z.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:n.z.boolean().optional().describe(`Whether the group starts collapsed`),fields:n.z.array(le).max(e.S.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(t,n){t.groups.reduce((e,t)=>e+t.fields.length,0)>e.S.fieldsPerFormTab&&n.addIssue({code:`too_big`,origin:`array`,maximum:e.S.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${e.S.fieldsPerFormTab} fields`,path:[`groups`]});let r=new Set,i=new Set;t.groups.forEach((e,t)=>{r.has(e.name)&&n.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,t,`name`]}),r.add(e.name),e.fields.forEach((e,r)=>{i.has(e.attribute)&&n.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,t,`fields`,r,`attribute`]}),i.add(e.attribute)})})}const J={name:n.z.string().describe(`Content API name, unique in the view`),label:n.z.string().optional().describe(`Label people see`),icon:e.x.optional().describe(`Icon name`),placement:n.z.enum([`main`,`aside`]).describe(`main: any tabs. aside: at most one, a form`)},Y=n.z.object({object:n.z.string().optional().describe(`Every record of this object`),relation:n.z.string().optional().describe(`Records linked through this relation`)}).strict().superRefine((e,t)=>{e.object===void 0&&e.relation===void 0&&t.addIssue({code:`custom`,message:`Collection source must define an object, a relation, or both`})}).transform(e=>e.relation===void 0?{object:e.object}:e.object===void 0?{relation:e.relation}:{object:e.object,relation:e.relation}),de={...J,type:n.z.literal(`collection`),source:Y.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:n.z.enum(e.M).optional().describe(`all: no scope; workspace: every member; private: viewer's own`),columns:n.z.array(n.z.union([n.z.string(),n.z.object({relationProperty:n.z.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(e.S.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:n.z.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:F.optional().describe(`Attributes shown on each card`),filters:q.optional().describe(`Restricts which records show`),sorts:L.optional().describe(`Sort order`),actions:n.z.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:n.z.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:n.z.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},fe=n.z.object({...de,layout:n.z.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:n.z.record(n.z.string(),n.z.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:n.z.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:n.z.array(n.z.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:n.z.record(n.z.string(),n.z.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:n.z.array(n.z.string()).optional().describe(`Kanban: columns pinned first`)}).strict().superRefine((e,t)=>{let n=[`groupByAttribute`,`kanbanColumnOrder`,`kanbanColumnVisibility`,`kanbanPinnedColumns`];if(e.layout===`kanban`){e.groupByAttribute===void 0&&t.addIssue({code:`custom`,path:[`groupByAttribute`],message:`A kanban layout requires groupByAttribute`});return}for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),X={...J,type:n.z.literal(`form`),groups:n.z.array(ue).max(e.S.groupsPerFormTab).describe(`Field groups, in order`),formColumns:n.z.union([n.z.literal(1),n.z.literal(2),n.z.literal(3)]).optional().describe(`Grid columns, 1-3`),density:n.z.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},pe=n.z.object(X).strict().superRefine(refineFormContent),me=n.z.object({...X,groups:X.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),Z=[fe,n.z.object({...J,type:n.z.literal(`custom`),extension:n.z.string().describe(`Name of a registered extension`),parameters:n.z.lazy(()=>N).optional().describe(`Extension parameters`)}).strict(),n.z.object({...J,type:n.z.literal(`activity`)}).strict(),n.z.object({...J,type:n.z.literal(`richtext`),attribute:n.z.string().describe(`Richtext attribute edited in place`),titleAttribute:n.z.string().optional().describe(`Text attribute shown as the title`)}).strict(),n.z.object({...J,type:n.z.literal(`documents`),allowUpload:n.z.boolean().optional().describe(`Lets people add files here`),allowRemove:n.z.boolean().optional().describe(`Lets people remove files here`),hideAttachments:n.z.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:n.z.array(n.z.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),n.z.object({...J,type:n.z.literal(`forms`),objectName:n.z.string().optional().describe(`Limits to this object's published forms`)}).strict(),n.z.object({...J,type:n.z.literal(`emails`),emailAttributes:n.z.array(n.z.string()).max(e.S.emailAttributesPerTab).describe(`Addresses`)}).strict(),n.z.object({...J,type:n.z.literal(`meetings`),emailAttributes:n.z.array(n.z.string()).max(e.S.emailAttributesPerTab).describe(`Addresses`)}).strict()],he=n.z.discriminatedUnion(`type`,[pe,...Z]),Q=n.z.discriminatedUnion(`type`,[me,...Z]),$={object:n.z.string(),name:n.z.string(),label:n.z.string(),description:n.z.string().optional(),icon:e.x.optional(),context:n.z.enum([`collection`,`record`]),default:n.z.boolean().optional()},ge=n.z.object({...$,contents:n.z.array(he).max(e.S.tabsPerView)}).strict(),_e=n.z.object({...$,contents:n.z.array(Q).max(e.S.tabsPerView)}).strict();function addDuplicateContentNameIssues(e,t){let n=new Set;e.contents.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate content name "${e.name}"`,path:[`contents`,r,`name`]}),n.add(e.name)})}function asideRuleIssues(e){let t=e.contents.map((e,t)=>({content:e,index:t})).filter(({content:e})=>e.placement===`aside`),n=[],[,r]=t;r&&n.push({contentName:null,path:[`contents`,r.index,`placement`],message:`Aside holds one content for now; put the others in main`});for(let{content:e,index:r}of t)e.type!==`form`&&n.push({contentName:e.name,path:[`contents`,r,`type`],message:`Only a form content can sit in aside for now; put ${e.type} in main`});return n}function addAsideIssues(e,t){for(let n of asideRuleIssues(e))t.addIssue({code:`custom`,path:n.path,message:n.message})}function draftContentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return ge.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),e===`enforce`&&addAsideIssues(t,n)})}function contentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return _e.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),t.contents.some(e=>e.placement===`main`)||n.addIssue({code:`custom`,message:`A published view requires at least one main content`,path:[`contents`]}),e===`enforce`&&addAsideIssues(t,n)})}const ve=draftContentViewDefinitionSchemaFor(),ye=contentViewDefinitionSchemaFor();Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return getSystemAttributeI18nKey}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return currentActor}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return canonicalizeFilterValue}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return toMultiValueOperator}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return normalizeForEdgeRpc}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return isAttributeKanbanGroupable}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return getAttributeFilterOperators}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return filterOperatorsByTypeForGeneration}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return isLocationFilterProperty}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return isAttributeSearchable}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return getRollupFilterOperators}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return now}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return today}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return extractCurrencyFilterValue}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return isNoValueOperator}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return normalizeOperator}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return isSetMembershipOperator}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return isAttributeFilterable}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return getAttributeCapabilities}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return isAttributeGroupable}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return resolveEffectiveFilterType}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return isLocationPartOperator}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return resolveIsWithinBounds}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return contentViewDefinitionSchemaFor}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return draftContentViewDefinitionSchemaFor}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return getSystemAttributeList}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return isRelativeDateValue}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return validateQualifiedRule}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return isDynamicValue}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return extractFilterValue}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return collectQualifiedRuleIssues}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return isAttributeSortable}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return asideRuleIssues}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return isManagedSystemAttribute}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return resolveUtcDayBounds}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return getOperatorPolarity}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return normalizeFilterRule}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return toUtcDayString}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return h}});
|
|
2
|
+
const e=require("./config-BvijG1IN.js"),t=require("./exceptions.js");let n=require("zod");const r={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`};function getSystemAttributeI18nKey(e){return r[e]}const i={createdAt:{id:`system:createdAt`,name:`createdAt`,label:`Created time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was created`},updatedAt:{id:`system:updatedAt`,name:`updatedAt`,label:`Last edited time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was last modified`},createdBy:{id:`system:createdBy`,name:`createdBy`,label:`Created by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who created this record`},lastUpdatedBy:{id:`system:lastUpdatedBy`,name:`lastUpdatedBy`,label:`Last edited by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who last modified this record`},attachments:{id:`system:attachments`,name:`attachments`,label:`Attachments`,type:`document`,required:!1,system:!0,hidden:!0,icon:`paperclip`,description:`Free-form document attachments`}};function getSystemAttributeList(){return Object.values(i)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const a=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],o=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],s=[`is`],c=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],l=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],u=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],d=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],f=[`is_empty`,`is_not_empty`],p=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],m=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return m.includes(e)}function isLocationPartOperator(e){return a.includes(e)}const h={text:a,richtext:[],number:o,checkbox:s,date:c,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:o,status:l,select:l,multiselect:u,location:[],user:d,relation:d,formula:p,document:f},g=new Set([`formula`,`rollup`]),ee=new Set([`user`,`relation`,`document`]),_=new Set([`text`,`richtext`,`number`,`select`,`multiselect`,`status`,`date`,`phone`,`currency`,`location`,`user`,`relation`,`document`]),te=new Set([`text`,`number`,`date`,`phone`,`currency`,`select`,`multiselect`]),ne=new Set([`text`,`phone`,`status`,`select`,`multiselect`]),re=new Set([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`]);function getAttributeCapabilities(e){let t=!!(e.hidden||e.archived),n=!e.archived,r=g.has(e.type),i=e.type===`document`,a=ee.has(e.type),o=getAttributeCardinality(e),s=t?[]:getRawFilterOperators(e),c=s.length>0&&!t,l=!t&&ne.has(e.type),u=!t&&re.has(e.type),d=!t&&isGroupableType(e.type),f=!t&&e.type===`status`,p=isManagedSystemAttribute(e),m=r||i||p,h=!(t||m),_=isRequiredForbidden(e.type)?`forbidden`:`allowed`,v=getDefaultValueCapability(e.type),y=supportsMaxItems(e),b=te.has(e.type),x=!(!e.deprecated||t),S=resolveEditMode(e);return{lifecycle:{active:n,deprecated:!!e.deprecated,visibleInArchitect:!0,visibleInRuntime:!t,warningWhenDeprecated:x},storage:{mode:r?`computed`:a?`edge`:`value`,cardinality:o,edgeBacked:a,preservesExistingValues:!!e.archived,qualifiedProperties:supportsQualifiedProperties(e.type),polymorphic:getPolymorphicCapability(e),maxItems:y},authoring:{editable:h,readOnly:m,directEdit:h&&S===`inline`,required:_,defaultValue:v,placeholder:b,maxItems:y},presentation:{formField:!t&&isFormFieldType(e.type),tableCell:!t&&isTableCellType(e.type),defaultColumn:!t&&isDefaultColumnType(e.type),compactDisplay:!t,popoverEditor:!t&&S===`popover`,placeholder:b,warningWhenDeprecated:x},query:{filterable:c,searchable:l,sortable:u,groupable:d,kanbanGroupable:f,operators:s},agent:{readable:!t,writable:h&&!i,compactReadable:!t,contentReadable:!t&&isContentReadableType(e.type),requiresDedicatedTool:i},exchange:{importable:!t,exportable:!t,schemaExportable:!0,metadataExportable:!1}}}function getAttributeFilterOperators(e){return getAttributeCapabilities(e).query.operators}function isAttributeFilterable(e){return getAttributeCapabilities(e).query.filterable}function isAttributeSearchable(e){return getAttributeCapabilities(e).query.searchable}function isAttributeSortable(e){return getAttributeCapabilities(e).query.sortable}function isAttributeGroupable(e){return getAttributeCapabilities(e).query.groupable}function isAttributeKanbanGroupable(e){return getAttributeCapabilities(e).query.kanbanGroupable}function resolveEffectiveFilterType(e){if(e.type!==`rollup`)return e.type;let t=e;if(t.function===`earliest`||t.function===`latest`)return`date`;if(t.function===`original`){let e=t.targetAttributeType;if(e&&hasFilterOperatorEntry(e))return e}return`number`}function getRollupFilterOperators$1(e){let t=resolveEffectiveFilterType(e);return hasFilterOperatorEntry(t)?h[t]:h.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):h[e.type]??[]}function getAttributeCardinality(e){return e.type===`multiselect`||e.type===`document`||e.type===`user`&&e.multiple===!0||e.type===`relation`&&e.cardinality===`many`?`many`:`one`}function getPolymorphicCapability(e){if(e.type!==`relation`)return`none`;let t=e.targets??[];return t.length===1&&t[0]?.object===`*`?`internal`:t.length>1?`code-only`:`none`}function supportsMaxItems(e){return e.type===`multiselect`||e.type===`relation`&&e.cardinality===`many`}function supportsQualifiedProperties(e){return e===`relation`||e===`document`}function isRequiredForbidden(e){return e===`checkbox`||e===`formula`||e===`rollup`}function getDefaultValueCapability(e){return e===`checkbox`?`automatic`:e===`formula`||e===`rollup`?`forbidden`:_.has(e)?`static`:`forbidden`}function isDefaultColumnType(e){return isTableCellType(e)}function isTableCellType(e){return e!==`richtext`&&e!==`document`}function isFormFieldType(e){return e!==`richtext`}function resolveEditMode(e){switch(e.type){case`checkbox`:return`inline`;case`number`:return e.renderAs===`rating`?`inline`:`default`;case`select`:case`multiselect`:return e.renderAs===`badges`?`inline`:`popover`;case`status`:case`relation`:case`user`:case`date`:return`popover`;default:return`default`}}function isGroupableType(e){return e===`status`||e===`currency`}function isContentReadableType(e){return e===`richtext`||e===`document`}function hasFilterOperatorEntry(e){return Object.prototype.hasOwnProperty.call(h,e)}const v=h,y=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return y.includes(e)}function filterOperatorsByTypeForGeneration(e){return e===`rollup`?y:v[e]??[]}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}function isDynamicValue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`dynamic`in e}function currentActor(){return{dynamic:`actor`,ref:`current`}}function today(){return{dynamic:`date`,anchor:`today`}}function now(){return{dynamic:`date`,anchor:`now`}}function toAmount(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function extractCurrencyFilterValue(e){return typeof e==`object`&&e?`value`in e?toAmount(e.value):null:toAmount(e)}function extractFilterValue(e){return e==null?null:typeof e==`object`&&`value`in e?e.value??null:e}const b=new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),x={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return b.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return x[e]??e}const S={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return S[e]??e}const ie=new Set(Object.values(S).filter(e=>e!==void 0));function isSetMembershipOperator(e){return ie.has(e)}function canonicalizeFilterValue(e,n){let r=e.value;if(isNoValueOperator(e.operator)||r==null||isDynamicValue(r))return;if(isSetMembershipOperator(e.operator)){Array.isArray(r)||(e.value=[r]);return}if(n!==`currency`)return;let i=extractCurrencyFilterValue(r);if(i!==null){e.value=i;return}if(!hasCurrencyAmount(r))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(r)}`;throw new t.ValidationError(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const C={eq:`is`,equals:`is`,equal:`is`,"==":`is`,"=":`is`,neq:`is_not`,notEqual:`is_not`,isNot:`is_not`,"!=":`is_not`,"<>":`is_not`,lt:`less_than`,"<":`less_than`,gt:`greater_than`,">":`greater_than`,lte:`less_or_equal`,"<=":`less_or_equal`,gte:`greater_or_equal`,">=":`greater_or_equal`,in:`any_of`,isAnyOf:`any_of`,anyOf:`any_of`,oneOf:`any_of`,notIn:`none_of`,not_in:`none_of`,isNoneOf:`none_of`,noneOf:`none_of`,notOneOf:`none_of`,startsWith:`starts_with`,beginsWith:`starts_with`,endsWith:`ends_with`,doesNotContain:`not_contains`,notContain:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`};function normalizeOperator(e){return C[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const w=864e5,T=new Set([`days`,`weeks`,`months`,`years`]),E=new Set([`past`,`future`]);function isRelativeDateValue(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.amount==`number`&&Number.isFinite(t.amount)&&t.amount>0&&typeof t.unit==`string`&&T.has(t.unit)&&typeof t.direction==`string`&&E.has(t.direction)}function utcDayStart(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function shiftUtcDay(e,t,n){if(n===`days`)return e+t*w;if(n===`weeks`)return e+t*7*w;let r=new Date(e),i=r.getUTCFullYear()+(n===`years`?t:0),a=r.getUTCMonth()+(n===`months`?t:0),o=new Date(Date.UTC(i,a+1,0)).getUTCDate();return Date.UTC(i,a,Math.min(r.getUTCDate(),o))}function resolveIsWithinBounds(e,t=new Date){if(!isRelativeDateValue(e))return null;let n=utcDayStart(t),r=Math.trunc(e.amount),i=e.direction===`past`?{startMs:shiftUtcDay(n,-r,e.unit),endMs:n+w}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+w};return Number.isFinite(i.startMs)&&Number.isFinite(i.endMs)?i:null}function resolveUtcDayBounds(e){if(!Number.isFinite(e))return null;let t=utcDayStart(new Date(e));return Number.isFinite(t)?{startMs:t,endMs:t+w}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const D=new Set([`relation`,`document`,`user`]),O=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],ae={id:O,objectId:O,tenantId:O,label:v.text,createdAt:v.date,updatedAt:v.date,deletedAt:v.date,createdBy:v.user,lastUpdatedBy:v.user},k={id:`text`,objectId:`text`,objectName:`text`,tenantId:`text`,label:`text`,createdAt:`date`,updatedAt:`date`,deletedAt:`date`,deletedBy:`user`,createdBy:`user`,lastUpdatedBy:`user`,visibility:`select`,ownedBy:`user`},A={before:`"less_than"`,after:`"greater_than"`,on_or_before:`"less_or_equal"`,on_or_after:`"greater_or_equal"`,is_checked:`"is" with value true`,is_not_checked:`"is" with value false`,day_month_eq:`"on_day_month"`},oe=new Set(Object.entries(h).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),se={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(e,n){let r=A[e];if(r){let n=`Unknown filter operator "${e}" — use ${r}`;throw new t.ValidationError(n,[{path:[`operator`],message:n}])}let i=normalizeOperator(e),a=se[i];if(a&&oe.has(n)){let e=`Operator "${i}" is not valid for type "${n}" — use "${a}"`;throw new t.ValidationError(e,[{path:[`operator`],message:e}])}return i}function assertOperatorForType(e,n,r){let i=resolveCanonicalOperator(e,n),a=v[n];if(!a?.includes(i)){let i=`Operator "${e}" is not valid for ${r} type "${n}". Valid operators: ${a?.length?a.join(`, `):`(no operators registered for this type)`}.`;throw new t.ValidationError(i,[{path:[`operator`],message:i}])}return i}function assertRelativeDateValue(e){if(e.operator===`is_within`&&!isRelativeDateValue(e.value)){let e=`Operator "is_within" requires a relative-date value { amount: positive number, unit: days|weeks|months|years, direction: past|future }`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}}function applyCanonicalForm(e,t,n){e.operator=t,canonicalizeFilterValue(e,n),assertRelativeDateValue(e)}function assertDynamicValueForAttribute(e,n){if(!isDynamicValue(e.value))return;let r=e.value;if(r.dynamic===`actor`&&n!==`user`){let e=`actor token (@me) is only valid on user attributes, not "${n}"`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}if(r.dynamic===`date`&&n!==`date`){let e=`date token (@today/@now) is only valid on date attributes, not "${n}"`;throw new t.ValidationError(e,[{path:[`value`],message:e}])}}const j=m.map(e=>`"${e}"`).join(`, `);function locationPartsHint(e){return e===`location`?` A location is filtered on one of its parts: set "property" to one of ${j} and use a text operator (e.g. contains).`:``}function collectQualifiedRuleIssues(e,n){try{return validateQualifiedRule({...e},n),[]}catch(e){if(!(e instanceof t.ValidationError))throw e;return e.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(e,n){let r=n.attributes.find(t=>t.name===e.attribute),i=ae[e.attribute];if(!(r||i)){let[r,...i]=e.attribute.split(`.`),a=(i.length>0?n.attributes.find(e=>e.name===r):void 0)?.type===`location`?` Dotted paths are not supported — set "attribute" to "${r}" and "property" to ${isLocationFilterProperty(i[0]??``)?`"${i[0]}"`:`one of ${j}`}.`:e.attribute.includes(`.`)?` Dotted paths are not supported — filter on the attribute name alone, or use the full-text "query" parameter to match text inside a value.`:``,o=`Unknown attribute: ${e.attribute}${a}`;throw new t.ValidationError(o,[{path:[`attribute`],message:o}])}if(e.quantifier!==void 0&&!e.property){let e=`quantifier is only valid on qualified edge rules (set "property")`;throw new t.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!r){if(e.property)throw new t.ValidationError(`Cannot qualify system attribute "${e.attribute}"`,[{path:[`property`],message:`"${e.attribute}" is a system column, not a reference`}]);let n=k[e.attribute]??`text`,r=resolveCanonicalOperator(e.operator,n);if(!i.includes(r)){let n=`Operator "${e.operator}" is not valid for system attribute "${e.attribute}". Valid operators: ${i.join(`, `)}.`;throw new t.ValidationError(n,[{path:[`operator`],message:n}])}applyCanonicalForm(e,r,n);return}if(!e.property){assertDynamicValueForAttribute(e,r.type);let n=getAttributeFilterOperators(r),i=resolveCanonicalOperator(e.operator,r.type);if(!n.includes(i)){let i=n.length?n.join(`, `):`(not filterable)`,a=`Operator "${e.operator}" is not valid for attribute "${r.name}". Valid operators: ${i}.${locationPartsHint(r.type)}`;throw new t.ValidationError(a,[{path:[`operator`],message:a}])}applyCanonicalForm(e,i,resolveEffectiveFilterType(r));return}if(r.type===`location`){if(e.quantifier!==void 0){let e=`quantifier is not valid on a location part — a location is one value, not a set of edges`;throw new t.ValidationError(e,[{path:[`quantifier`],message:e}])}if(!isLocationFilterProperty(e.property)){let n=`Property "${e.property}" is not a part of location "${e.attribute}". Valid parts: ${j}.`;throw new t.ValidationError(n,[{path:[`property`],message:n}])}assertDynamicValueForAttribute(e,`text`),applyCanonicalForm(e,assertOperatorForType(e.operator,`text`,`property`),`text`);return}if(!D.has(r.type))throw new t.ValidationError(`Cannot qualify ${r.type} attribute "${e.attribute}"`,[{path:[`property`],message:`Attribute "${e.attribute}" is not a reference type`}]);let a=r.properties;if(!a)throw new t.ValidationError(`Attribute "${e.attribute}" has no qualifyWith schema`,[{path:[`property`],message:`"${e.attribute}" has no qualifyWith`}]);let o=a.definitions.find(t=>t.name===e.property);if(!o)throw new t.ValidationError(`Property "${e.property}" not defined on "${e.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${e.property}`}]);applyCanonicalForm(e,assertOperatorForType(e.operator,o.type,`property`),o.type)}const M=1e4;function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null&&t.constructor?.name===`Object`}function addJsonIssue(e,t,n=[]){e.addIssue({code:`custom`,message:t,path:n})}function pushJsonArrayChildren(e,t,n,r){for(let n of Reflect.ownKeys(e))if(n!==`length`){if(n===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]);continue}(typeof n==`symbol`||!/^(0|[1-9]\d*)$/.test(n))&&addJsonIssue(r,`Arrays cannot contain non-index JSON properties`,[...t.path,n])}for(let i=e.length-1;i>=0;i--){let a=Object.getOwnPropertyDescriptor(e,String(i)),o=[...t.path,i];if(!(a&&`value`in a)){addJsonIssue(r,`Sparse arrays are not valid JSON values`,o);continue}n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1})}}function pushJsonObjectChildren(e,t,n,r){let i=Reflect.ownKeys(e);for(let a=i.length-1;a>=0;a--){let o=i[a],s=[...t.path,o];if(o===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,s);continue}if(typeof o==`symbol`){addJsonIssue(r,`Symbol keys are not valid JSON keys`,s);continue}let c=Object.getOwnPropertyDescriptor(e,o);if(!(c?.enumerable&&`value`in c)){addJsonIssue(r,`Custom props must contain enumerable data properties only`,s);continue}n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1})}}function validateJsonProps(e,t){if(typeof e!=`object`||!e){addJsonIssue(t,`Expected a plain JSON object`);return}try{if(Array.isArray(e)||!isPlainJsonObject(e)){addJsonIssue(t,`Expected a plain JSON object`);return}}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`);return}let n=new WeakSet,r=[{kind:`enter`,value:e,path:[],depth:0}],i=0;for(;r.length>0;){let e=r.pop();if(!e)break;if(e.kind===`exit`){n.delete(e.value);continue}if(i++,i>M){addJsonIssue(t,`Custom props cannot exceed ${M.toLocaleString(`en-US`)} total JSON nodes`,e.path);return}if(e.depth>64){addJsonIssue(t,`Custom props cannot exceed depth 64`,e.path);continue}let a=e.value;if(!(a===null||typeof a==`string`||typeof a==`boolean`||typeof a==`number`&&Number.isFinite(a))){if(typeof a!=`object`){addJsonIssue(t,`Expected a JSON value`,e.path);continue}if(n.has(a)){addJsonIssue(t,`Custom props cannot contain circular references`,e.path);continue}try{if(Array.isArray(a)){n.add(a),r.push({kind:`exit`,value:a}),pushJsonArrayChildren(a,e,r,t);continue}if(!isPlainJsonObject(a)){addJsonIssue(t,`Expected an array or plain JSON object`,e.path);continue}n.add(a),r.push({kind:`exit`,value:a}),pushJsonObjectChildren(a,e,r,t)}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`,e.path)}}}}const N=n.z.unknown().superRefine(validateJsonProps).transform(e=>e),P=n.z.array(n.z.string()).max(e.j.columnsPerTab),F=n.z.array(n.z.string().min(1)).max(e.j.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),I=n.z.object({attribute:n.z.string().describe(`Attribute to sort by`),direction:n.z.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),L=n.z.array(I).max(e.j.sortsPerTab),R=n.z.object({amount:n.z.number().describe(`Count`),unit:n.z.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:n.z.enum([`past`,`future`]).describe(`Past or future`)}).strict(),z=n.z.object({value:n.z.number().nullable().describe(`Amount`),code:n.z.array(n.z.string()).optional().describe(`Currency codes`)}).strict(),B=n.z.object({phoneNumber:n.z.string().nullable().describe(`Number`),countryCode:n.z.string().optional().describe(`ISO country code`)}).strict(),V=n.z.discriminatedUnion(`dynamic`,[n.z.object({dynamic:n.z.literal(`actor`).describe(`Resolved at filter time`),ref:n.z.literal(`current`).describe(`The current actor`)}).strict(),n.z.object({dynamic:n.z.literal(`date`).describe(`Resolved at filter time`),anchor:n.z.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),H=n.z.object({month:n.z.number().describe(`1-12`),day:n.z.number().describe(`Day`)}).strict(),U=n.z.union([n.z.string(),n.z.number(),n.z.boolean(),n.z.array(n.z.string()),R,z,B,H,V,n.z.null()]),W=n.z.enum([`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`any_of`,`none_of`],{error:e=>{let t=e.input,n=typeof t==`string`?A[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),G=n.z.object({attribute:n.z.string().describe(`Attribute to filter on`),property:n.z.string().optional().describe(`Qualified edge property`),quantifier:n.z.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:W.describe(`Comparison`),value:U.describe(`Comparison value, by attribute type`)}).strict(),K=n.z.array(G).max(e.j.filterRulesPerTab),q=n.z.object({combinator:n.z.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:K.describe(`The rules`)}).strict(),ce={span:n.z.union([n.z.literal(1),n.z.literal(2),n.z.literal(3),n.z.literal(4),n.z.literal(5),n.z.literal(6),n.z.literal(7),n.z.literal(8),n.z.literal(9),n.z.literal(10),n.z.literal(11),n.z.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:n.z.string().optional().describe(`Overrides the attribute's label`),readOnly:n.z.boolean().optional().describe(`Shows the value, not editable`)},le=n.z.object({attribute:n.z.string().describe(`Attribute API name shown by this field`),...ce}).strict(),ue=n.z.object({name:n.z.string().describe(`Group API name, unique in the form`),label:n.z.string().describe(`Label people see`),description:n.z.string().optional().describe(`Extra context under the label`),collapsible:n.z.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:n.z.boolean().optional().describe(`Whether the group starts collapsed`),fields:n.z.array(le).max(e.j.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(t,n){t.groups.reduce((e,t)=>e+t.fields.length,0)>e.j.fieldsPerFormTab&&n.addIssue({code:`too_big`,origin:`array`,maximum:e.j.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${e.j.fieldsPerFormTab} fields`,path:[`groups`]});let r=new Set,i=new Set;t.groups.forEach((e,t)=>{r.has(e.name)&&n.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,t,`name`]}),r.add(e.name),e.fields.forEach((e,r)=>{i.has(e.attribute)&&n.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,t,`fields`,r,`attribute`]}),i.add(e.attribute)})})}const J={name:n.z.string().describe(`Content API name, unique in the view`),label:n.z.string().optional().describe(`Label people see`),icon:e.A.optional().describe(`Icon name`),placement:n.z.enum([`main`,`aside`]).describe(`main: any tabs. aside: at most one, a form`)},Y=n.z.object({object:n.z.string().optional().describe(`Every record of this object`),relation:n.z.string().optional().describe(`Records linked through this relation`)}).strict().superRefine((e,t)=>{e.object===void 0&&e.relation===void 0&&t.addIssue({code:`custom`,message:`Collection source must define an object, a relation, or both`})}).transform(e=>e.relation===void 0?{object:e.object}:e.object===void 0?{relation:e.relation}:{object:e.object,relation:e.relation}),de={...J,type:n.z.literal(`collection`),source:Y.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:n.z.enum(e.M).optional().describe(`all: no scope; workspace: every member; private: viewer's own`),columns:n.z.array(n.z.union([n.z.string(),n.z.object({relationProperty:n.z.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(e.j.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:n.z.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:F.optional().describe(`Attributes shown on each card`),filters:q.optional().describe(`Restricts which records show`),sorts:L.optional().describe(`Sort order`),actions:n.z.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:n.z.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:n.z.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},fe=n.z.object({...de,layout:n.z.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:n.z.record(n.z.string(),n.z.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:n.z.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:n.z.array(n.z.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:n.z.record(n.z.string(),n.z.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:n.z.array(n.z.string()).optional().describe(`Kanban: columns pinned first`)}).strict().superRefine((e,t)=>{let n=[`groupByAttribute`,`kanbanColumnOrder`,`kanbanColumnVisibility`,`kanbanPinnedColumns`];if(e.layout===`kanban`){e.groupByAttribute===void 0&&t.addIssue({code:`custom`,path:[`groupByAttribute`],message:`A kanban layout requires groupByAttribute`});return}for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),X={...J,type:n.z.literal(`form`),groups:n.z.array(ue).max(e.j.groupsPerFormTab).describe(`Field groups, in order`),formColumns:n.z.union([n.z.literal(1),n.z.literal(2),n.z.literal(3)]).optional().describe(`Grid columns, 1-3`),density:n.z.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},pe=n.z.object(X).strict().superRefine(refineFormContent),me=n.z.object({...X,groups:X.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),Z=[fe,n.z.object({...J,type:n.z.literal(`custom`),extension:n.z.string().describe(`Name of a registered extension`),parameters:n.z.lazy(()=>N).optional().describe(`Extension parameters`)}).strict(),n.z.object({...J,type:n.z.literal(`activity`)}).strict(),n.z.object({...J,type:n.z.literal(`richtext`),attribute:n.z.string().describe(`Richtext attribute edited in place`),titleAttribute:n.z.string().optional().describe(`Text attribute shown as the title`)}).strict(),n.z.object({...J,type:n.z.literal(`documents`),allowUpload:n.z.boolean().optional().describe(`Lets people add files here`),allowRemove:n.z.boolean().optional().describe(`Lets people remove files here`),hideAttachments:n.z.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:n.z.array(n.z.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),n.z.object({...J,type:n.z.literal(`forms`),objectName:n.z.string().optional().describe(`Limits to this object's published forms`)}).strict(),n.z.object({...J,type:n.z.literal(`emails`),emailAttributes:n.z.array(n.z.string()).max(e.j.emailAttributesPerTab).describe(`Addresses`)}).strict(),n.z.object({...J,type:n.z.literal(`meetings`),emailAttributes:n.z.array(n.z.string()).max(e.j.emailAttributesPerTab).describe(`Addresses`)}).strict()],he=n.z.discriminatedUnion(`type`,[pe,...Z]),Q=n.z.discriminatedUnion(`type`,[me,...Z]),$={object:n.z.string(),name:n.z.string(),label:n.z.string(),description:n.z.string().optional(),icon:e.A.optional(),context:n.z.enum([`collection`,`record`]),default:n.z.boolean().optional()},ge=n.z.object({...$,contents:n.z.array(he).max(e.j.tabsPerView)}).strict(),_e=n.z.object({...$,contents:n.z.array(Q).max(e.j.tabsPerView)}).strict();function addDuplicateContentNameIssues(e,t){let n=new Set;e.contents.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate content name "${e.name}"`,path:[`contents`,r,`name`]}),n.add(e.name)})}function asideRuleIssues(e){let t=e.contents.map((e,t)=>({content:e,index:t})).filter(({content:e})=>e.placement===`aside`),n=[],[,r]=t;r&&n.push({contentName:null,path:[`contents`,r.index,`placement`],message:`Aside holds one content for now; put the others in main`});for(let{content:e,index:r}of t)e.type!==`form`&&n.push({contentName:e.name,path:[`contents`,r,`type`],message:`Only a form content can sit in aside for now; put ${e.type} in main`});return n}function addAsideIssues(e,t){for(let n of asideRuleIssues(e))t.addIssue({code:`custom`,path:n.path,message:n.message})}function draftContentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return ge.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),e===`enforce`&&addAsideIssues(t,n)})}function contentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return _e.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),t.contents.some(e=>e.placement===`main`)||n.addIssue({code:`custom`,message:`A published view requires at least one main content`,path:[`contents`]}),e===`enforce`&&addAsideIssues(t,n)})}const ve=draftContentViewDefinitionSchemaFor(),ye=contentViewDefinitionSchemaFor();Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return getSystemAttributeI18nKey}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return currentActor}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return canonicalizeFilterValue}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return toMultiValueOperator}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return normalizeForEdgeRpc}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return isAttributeKanbanGroupable}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return getAttributeFilterOperators}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return filterOperatorsByTypeForGeneration}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return isLocationFilterProperty}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return isAttributeSearchable}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return getRollupFilterOperators}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return now}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return today}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return extractCurrencyFilterValue}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return isNoValueOperator}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return normalizeOperator}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return isSetMembershipOperator}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return isAttributeFilterable}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return getAttributeCapabilities}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return isAttributeGroupable}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return resolveEffectiveFilterType}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return isLocationPartOperator}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return resolveIsWithinBounds}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return contentViewDefinitionSchemaFor}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return draftContentViewDefinitionSchemaFor}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return getSystemAttributeList}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return isRelativeDateValue}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return validateQualifiedRule}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return isDynamicValue}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return extractFilterValue}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return collectQualifiedRuleIssues}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return isAttributeSortable}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return asideRuleIssues}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return isManagedSystemAttribute}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return resolveUtcDayBounds}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return getOperatorPolarity}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return normalizeFilterRule}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return toUtcDayString}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return h}});
|
|
@@ -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{ValidationError as e}from"./exceptions.mjs";import{M as t,S as n,x as r}from"./config-CHSqDLhx.mjs";import{z as i}from"zod";const a={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`};function getSystemAttributeI18nKey(e){return a[e]}const o={createdAt:{id:`system:createdAt`,name:`createdAt`,label:`Created time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was created`},updatedAt:{id:`system:updatedAt`,name:`updatedAt`,label:`Last edited time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was last modified`},createdBy:{id:`system:createdBy`,name:`createdBy`,label:`Created by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who created this record`},lastUpdatedBy:{id:`system:lastUpdatedBy`,name:`lastUpdatedBy`,label:`Last edited by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who last modified this record`},attachments:{id:`system:attachments`,name:`attachments`,label:`Attachments`,type:`document`,required:!1,system:!0,hidden:!0,icon:`paperclip`,description:`Free-form document attachments`}};function getSystemAttributeList(){return Object.values(o)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const s=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],c=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],l=[`is`],u=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],d=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],f=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],p=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],m=[`is_empty`,`is_not_empty`],h=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],g=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return g.includes(e)}function isLocationPartOperator(e){return s.includes(e)}const _={text:s,richtext:[],number:c,checkbox:l,date:u,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:c,status:d,select:d,multiselect:f,location:[],user:p,relation:p,formula:h,document:m},ee=new Set([`formula`,`rollup`]),v=new Set([`user`,`relation`,`document`]),y=new Set([`text`,`richtext`,`number`,`select`,`multiselect`,`status`,`date`,`phone`,`currency`,`location`,`user`,`relation`,`document`]),te=new Set([`text`,`number`,`date`,`phone`,`currency`,`select`,`multiselect`]),b=new Set([`text`,`phone`,`status`,`select`,`multiselect`]),x=new Set([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`]);function getAttributeCapabilities(e){let t=!!(e.hidden||e.archived),n=!e.archived,r=ee.has(e.type),i=e.type===`document`,a=v.has(e.type),o=getAttributeCardinality(e),s=t?[]:getRawFilterOperators(e),c=s.length>0&&!t,l=!t&&b.has(e.type),u=!t&&x.has(e.type),d=!t&&isGroupableType(e.type),f=!t&&e.type===`status`,p=isManagedSystemAttribute(e),m=r||i||p,h=!(t||m),g=isRequiredForbidden(e.type)?`forbidden`:`allowed`,_=getDefaultValueCapability(e.type),y=supportsMaxItems(e),S=te.has(e.type),C=!(!e.deprecated||t),w=resolveEditMode(e);return{lifecycle:{active:n,deprecated:!!e.deprecated,visibleInArchitect:!0,visibleInRuntime:!t,warningWhenDeprecated:C},storage:{mode:r?`computed`:a?`edge`:`value`,cardinality:o,edgeBacked:a,preservesExistingValues:!!e.archived,qualifiedProperties:supportsQualifiedProperties(e.type),polymorphic:getPolymorphicCapability(e),maxItems:y},authoring:{editable:h,readOnly:m,directEdit:h&&w===`inline`,required:g,defaultValue:_,placeholder:S,maxItems:y},presentation:{formField:!t&&isFormFieldType(e.type),tableCell:!t&&isTableCellType(e.type),defaultColumn:!t&&isDefaultColumnType(e.type),compactDisplay:!t,popoverEditor:!t&&w===`popover`,placeholder:S,warningWhenDeprecated:C},query:{filterable:c,searchable:l,sortable:u,groupable:d,kanbanGroupable:f,operators:s},agent:{readable:!t,writable:h&&!i,compactReadable:!t,contentReadable:!t&&isContentReadableType(e.type),requiresDedicatedTool:i},exchange:{importable:!t,exportable:!t,schemaExportable:!0,metadataExportable:!1}}}function getAttributeFilterOperators(e){return getAttributeCapabilities(e).query.operators}function isAttributeFilterable(e){return getAttributeCapabilities(e).query.filterable}function isAttributeSearchable(e){return getAttributeCapabilities(e).query.searchable}function isAttributeSortable(e){return getAttributeCapabilities(e).query.sortable}function isAttributeGroupable(e){return getAttributeCapabilities(e).query.groupable}function isAttributeKanbanGroupable(e){return getAttributeCapabilities(e).query.kanbanGroupable}function resolveEffectiveFilterType(e){if(e.type!==`rollup`)return e.type;let t=e;if(t.function===`earliest`||t.function===`latest`)return`date`;if(t.function===`original`){let e=t.targetAttributeType;if(e&&hasFilterOperatorEntry(e))return e}return`number`}function getRollupFilterOperators$1(e){let t=resolveEffectiveFilterType(e);return hasFilterOperatorEntry(t)?_[t]:_.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):_[e.type]??[]}function getAttributeCardinality(e){return e.type===`multiselect`||e.type===`document`||e.type===`user`&&e.multiple===!0||e.type===`relation`&&e.cardinality===`many`?`many`:`one`}function getPolymorphicCapability(e){if(e.type!==`relation`)return`none`;let t=e.targets??[];return t.length===1&&t[0]?.object===`*`?`internal`:t.length>1?`code-only`:`none`}function supportsMaxItems(e){return e.type===`multiselect`||e.type===`relation`&&e.cardinality===`many`}function supportsQualifiedProperties(e){return e===`relation`||e===`document`}function isRequiredForbidden(e){return e===`checkbox`||e===`formula`||e===`rollup`}function getDefaultValueCapability(e){return e===`checkbox`?`automatic`:e===`formula`||e===`rollup`?`forbidden`:y.has(e)?`static`:`forbidden`}function isDefaultColumnType(e){return isTableCellType(e)}function isTableCellType(e){return e!==`richtext`&&e!==`document`}function isFormFieldType(e){return e!==`richtext`}function resolveEditMode(e){switch(e.type){case`checkbox`:return`inline`;case`number`:return e.renderAs===`rating`?`inline`:`default`;case`select`:case`multiselect`:return e.renderAs===`badges`?`inline`:`popover`;case`status`:case`relation`:case`user`:case`date`:return`popover`;default:return`default`}}function isGroupableType(e){return e===`status`||e===`currency`}function isContentReadableType(e){return e===`richtext`||e===`document`}function hasFilterOperatorEntry(e){return Object.prototype.hasOwnProperty.call(_,e)}const S=_,C=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return C.includes(e)}function filterOperatorsByTypeForGeneration(e){return e===`rollup`?C:S[e]??[]}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}function isDynamicValue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`dynamic`in e}function currentActor(){return{dynamic:`actor`,ref:`current`}}function today(){return{dynamic:`date`,anchor:`today`}}function now(){return{dynamic:`date`,anchor:`now`}}function toAmount(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function extractCurrencyFilterValue(e){return typeof e==`object`&&e?`value`in e?toAmount(e.value):null:toAmount(e)}function extractFilterValue(e){return e==null?null:typeof e==`object`&&`value`in e?e.value??null:e}const w=new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),ne={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return w.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return ne[e]??e}const T={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return T[e]??e}const E=new Set(Object.values(T).filter(e=>e!==void 0));function isSetMembershipOperator(e){return E.has(e)}function canonicalizeFilterValue(t,n){let r=t.value;if(isNoValueOperator(t.operator)||r==null||isDynamicValue(r))return;if(isSetMembershipOperator(t.operator)){Array.isArray(r)||(t.value=[r]);return}if(n!==`currency`)return;let i=extractCurrencyFilterValue(r);if(i!==null){t.value=i;return}if(!hasCurrencyAmount(r))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(r)}`;throw new e(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const D={eq:`is`,equals:`is`,equal:`is`,"==":`is`,"=":`is`,neq:`is_not`,notEqual:`is_not`,isNot:`is_not`,"!=":`is_not`,"<>":`is_not`,lt:`less_than`,"<":`less_than`,gt:`greater_than`,">":`greater_than`,lte:`less_or_equal`,"<=":`less_or_equal`,gte:`greater_or_equal`,">=":`greater_or_equal`,in:`any_of`,isAnyOf:`any_of`,anyOf:`any_of`,oneOf:`any_of`,notIn:`none_of`,not_in:`none_of`,isNoneOf:`none_of`,noneOf:`none_of`,notOneOf:`none_of`,startsWith:`starts_with`,beginsWith:`starts_with`,endsWith:`ends_with`,doesNotContain:`not_contains`,notContain:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`};function normalizeOperator(e){return D[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const O=864e5,re=new Set([`days`,`weeks`,`months`,`years`]),ie=new Set([`past`,`future`]);function isRelativeDateValue(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.amount==`number`&&Number.isFinite(t.amount)&&t.amount>0&&typeof t.unit==`string`&&re.has(t.unit)&&typeof t.direction==`string`&&ie.has(t.direction)}function utcDayStart(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function shiftUtcDay(e,t,n){if(n===`days`)return e+t*O;if(n===`weeks`)return e+t*7*O;let r=new Date(e),i=r.getUTCFullYear()+(n===`years`?t:0),a=r.getUTCMonth()+(n===`months`?t:0),o=new Date(Date.UTC(i,a+1,0)).getUTCDate();return Date.UTC(i,a,Math.min(r.getUTCDate(),o))}function resolveIsWithinBounds(e,t=new Date){if(!isRelativeDateValue(e))return null;let n=utcDayStart(t),r=Math.trunc(e.amount),i=e.direction===`past`?{startMs:shiftUtcDay(n,-r,e.unit),endMs:n+O}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+O};return Number.isFinite(i.startMs)&&Number.isFinite(i.endMs)?i:null}function resolveUtcDayBounds(e){if(!Number.isFinite(e))return null;let t=utcDayStart(new Date(e));return Number.isFinite(t)?{startMs:t,endMs:t+O}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const ae=new Set([`relation`,`document`,`user`]),k=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],oe={id:k,objectId:k,tenantId:k,label:S.text,createdAt:S.date,updatedAt:S.date,deletedAt:S.date,createdBy:S.user,lastUpdatedBy:S.user},A={id:`text`,objectId:`text`,objectName:`text`,tenantId:`text`,label:`text`,createdAt:`date`,updatedAt:`date`,deletedAt:`date`,deletedBy:`user`,createdBy:`user`,lastUpdatedBy:`user`,visibility:`select`,ownedBy:`user`},j={before:`"less_than"`,after:`"greater_than"`,on_or_before:`"less_or_equal"`,on_or_after:`"greater_or_equal"`,is_checked:`"is" with value true`,is_not_checked:`"is" with value false`,day_month_eq:`"on_day_month"`},se=new Set(Object.entries(_).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),ce={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(t,n){let r=j[t];if(r){let n=`Unknown filter operator "${t}" — use ${r}`;throw new e(n,[{path:[`operator`],message:n}])}let i=normalizeOperator(t),a=ce[i];if(a&&se.has(n)){let t=`Operator "${i}" is not valid for type "${n}" — use "${a}"`;throw new e(t,[{path:[`operator`],message:t}])}return i}function assertOperatorForType(t,n,r){let i=resolveCanonicalOperator(t,n),a=S[n];if(!a?.includes(i)){let i=`Operator "${t}" is not valid for ${r} type "${n}". Valid operators: ${a?.length?a.join(`, `):`(no operators registered for this type)`}.`;throw new e(i,[{path:[`operator`],message:i}])}return i}function assertRelativeDateValue(t){if(t.operator===`is_within`&&!isRelativeDateValue(t.value)){let t=`Operator "is_within" requires a relative-date value { amount: positive number, unit: days|weeks|months|years, direction: past|future }`;throw new e(t,[{path:[`value`],message:t}])}}function applyCanonicalForm(e,t,n){e.operator=t,canonicalizeFilterValue(e,n),assertRelativeDateValue(e)}function assertDynamicValueForAttribute(t,n){if(!isDynamicValue(t.value))return;let r=t.value;if(r.dynamic===`actor`&&n!==`user`){let t=`actor token (@me) is only valid on user attributes, not "${n}"`;throw new e(t,[{path:[`value`],message:t}])}if(r.dynamic===`date`&&n!==`date`){let t=`date token (@today/@now) is only valid on date attributes, not "${n}"`;throw new e(t,[{path:[`value`],message:t}])}}const M=g.map(e=>`"${e}"`).join(`, `);function locationPartsHint(e){return e===`location`?` A location is filtered on one of its parts: set "property" to one of ${M} and use a text operator (e.g. contains).`:``}function collectQualifiedRuleIssues(t,n){try{return validateQualifiedRule({...t},n),[]}catch(t){if(!(t instanceof e))throw t;return t.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(t,n){let r=n.attributes.find(e=>e.name===t.attribute),i=oe[t.attribute];if(!(r||i)){let[r,...i]=t.attribute.split(`.`),a=(i.length>0?n.attributes.find(e=>e.name===r):void 0)?.type===`location`?` Dotted paths are not supported — set "attribute" to "${r}" and "property" to ${isLocationFilterProperty(i[0]??``)?`"${i[0]}"`:`one of ${M}`}.`:t.attribute.includes(`.`)?` Dotted paths are not supported — filter on the attribute name alone, or use the full-text "query" parameter to match text inside a value.`:``,o=`Unknown attribute: ${t.attribute}${a}`;throw new e(o,[{path:[`attribute`],message:o}])}if(t.quantifier!==void 0&&!t.property){let t=`quantifier is only valid on qualified edge rules (set "property")`;throw new e(t,[{path:[`quantifier`],message:t}])}if(!r){if(t.property)throw new e(`Cannot qualify system attribute "${t.attribute}"`,[{path:[`property`],message:`"${t.attribute}" is a system column, not a reference`}]);let n=A[t.attribute]??`text`,r=resolveCanonicalOperator(t.operator,n);if(!i.includes(r)){let n=`Operator "${t.operator}" is not valid for system attribute "${t.attribute}". Valid operators: ${i.join(`, `)}.`;throw new e(n,[{path:[`operator`],message:n}])}applyCanonicalForm(t,r,n);return}if(!t.property){assertDynamicValueForAttribute(t,r.type);let n=getAttributeFilterOperators(r),i=resolveCanonicalOperator(t.operator,r.type);if(!n.includes(i)){let i=n.length?n.join(`, `):`(not filterable)`,a=`Operator "${t.operator}" is not valid for attribute "${r.name}". Valid operators: ${i}.${locationPartsHint(r.type)}`;throw new e(a,[{path:[`operator`],message:a}])}applyCanonicalForm(t,i,resolveEffectiveFilterType(r));return}if(r.type===`location`){if(t.quantifier!==void 0){let t=`quantifier is not valid on a location part — a location is one value, not a set of edges`;throw new e(t,[{path:[`quantifier`],message:t}])}if(!isLocationFilterProperty(t.property)){let n=`Property "${t.property}" is not a part of location "${t.attribute}". Valid parts: ${M}.`;throw new e(n,[{path:[`property`],message:n}])}assertDynamicValueForAttribute(t,`text`),applyCanonicalForm(t,assertOperatorForType(t.operator,`text`,`property`),`text`);return}if(!ae.has(r.type))throw new e(`Cannot qualify ${r.type} attribute "${t.attribute}"`,[{path:[`property`],message:`Attribute "${t.attribute}" is not a reference type`}]);let a=r.properties;if(!a)throw new e(`Attribute "${t.attribute}" has no qualifyWith schema`,[{path:[`property`],message:`"${t.attribute}" has no qualifyWith`}]);let o=a.definitions.find(e=>e.name===t.property);if(!o)throw new e(`Property "${t.property}" not defined on "${t.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${t.property}`}]);applyCanonicalForm(t,assertOperatorForType(t.operator,o.type,`property`),o.type)}const N=1e4;function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null&&t.constructor?.name===`Object`}function addJsonIssue(e,t,n=[]){e.addIssue({code:`custom`,message:t,path:n})}function pushJsonArrayChildren(e,t,n,r){for(let n of Reflect.ownKeys(e))if(n!==`length`){if(n===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]);continue}(typeof n==`symbol`||!/^(0|[1-9]\d*)$/.test(n))&&addJsonIssue(r,`Arrays cannot contain non-index JSON properties`,[...t.path,n])}for(let i=e.length-1;i>=0;i--){let a=Object.getOwnPropertyDescriptor(e,String(i)),o=[...t.path,i];if(!(a&&`value`in a)){addJsonIssue(r,`Sparse arrays are not valid JSON values`,o);continue}n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1})}}function pushJsonObjectChildren(e,t,n,r){let i=Reflect.ownKeys(e);for(let a=i.length-1;a>=0;a--){let o=i[a],s=[...t.path,o];if(o===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,s);continue}if(typeof o==`symbol`){addJsonIssue(r,`Symbol keys are not valid JSON keys`,s);continue}let c=Object.getOwnPropertyDescriptor(e,o);if(!(c?.enumerable&&`value`in c)){addJsonIssue(r,`Custom props must contain enumerable data properties only`,s);continue}n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1})}}function validateJsonProps(e,t){if(typeof e!=`object`||!e){addJsonIssue(t,`Expected a plain JSON object`);return}try{if(Array.isArray(e)||!isPlainJsonObject(e)){addJsonIssue(t,`Expected a plain JSON object`);return}}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`);return}let n=new WeakSet,r=[{kind:`enter`,value:e,path:[],depth:0}],i=0;for(;r.length>0;){let e=r.pop();if(!e)break;if(e.kind===`exit`){n.delete(e.value);continue}if(i++,i>N){addJsonIssue(t,`Custom props cannot exceed ${N.toLocaleString(`en-US`)} total JSON nodes`,e.path);return}if(e.depth>64){addJsonIssue(t,`Custom props cannot exceed depth 64`,e.path);continue}let a=e.value;if(!(a===null||typeof a==`string`||typeof a==`boolean`||typeof a==`number`&&Number.isFinite(a))){if(typeof a!=`object`){addJsonIssue(t,`Expected a JSON value`,e.path);continue}if(n.has(a)){addJsonIssue(t,`Custom props cannot contain circular references`,e.path);continue}try{if(Array.isArray(a)){n.add(a),r.push({kind:`exit`,value:a}),pushJsonArrayChildren(a,e,r,t);continue}if(!isPlainJsonObject(a)){addJsonIssue(t,`Expected an array or plain JSON object`,e.path);continue}n.add(a),r.push({kind:`exit`,value:a}),pushJsonObjectChildren(a,e,r,t)}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`,e.path)}}}}const P=i.unknown().superRefine(validateJsonProps).transform(e=>e),F=i.array(i.string()).max(n.columnsPerTab),I=i.array(i.string().min(1)).max(n.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),L=i.object({attribute:i.string().describe(`Attribute to sort by`),direction:i.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),R=i.array(L).max(n.sortsPerTab),z=i.object({amount:i.number().describe(`Count`),unit:i.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:i.enum([`past`,`future`]).describe(`Past or future`)}).strict(),B=i.object({value:i.number().nullable().describe(`Amount`),code:i.array(i.string()).optional().describe(`Currency codes`)}).strict(),V=i.object({phoneNumber:i.string().nullable().describe(`Number`),countryCode:i.string().optional().describe(`ISO country code`)}).strict(),H=i.discriminatedUnion(`dynamic`,[i.object({dynamic:i.literal(`actor`).describe(`Resolved at filter time`),ref:i.literal(`current`).describe(`The current actor`)}).strict(),i.object({dynamic:i.literal(`date`).describe(`Resolved at filter time`),anchor:i.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),U=i.object({month:i.number().describe(`1-12`),day:i.number().describe(`Day`)}).strict(),W=i.union([i.string(),i.number(),i.boolean(),i.array(i.string()),z,B,V,U,H,i.null()]),G=i.enum([`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`any_of`,`none_of`],{error:e=>{let t=e.input,n=typeof t==`string`?j[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),le=i.object({attribute:i.string().describe(`Attribute to filter on`),property:i.string().optional().describe(`Qualified edge property`),quantifier:i.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:G.describe(`Comparison`),value:W.describe(`Comparison value, by attribute type`)}).strict(),ue=i.array(le).max(n.filterRulesPerTab),K=i.object({combinator:i.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:ue.describe(`The rules`)}).strict(),de={span:i.union([i.literal(1),i.literal(2),i.literal(3),i.literal(4),i.literal(5),i.literal(6),i.literal(7),i.literal(8),i.literal(9),i.literal(10),i.literal(11),i.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:i.string().optional().describe(`Overrides the attribute's label`),readOnly:i.boolean().optional().describe(`Shows the value, not editable`)},fe=i.object({attribute:i.string().describe(`Attribute API name shown by this field`),...de}).strict(),pe=i.object({name:i.string().describe(`Group API name, unique in the form`),label:i.string().describe(`Label people see`),description:i.string().optional().describe(`Extra context under the label`),collapsible:i.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:i.boolean().optional().describe(`Whether the group starts collapsed`),fields:i.array(fe).max(n.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(e,t){e.groups.reduce((e,t)=>e+t.fields.length,0)>n.fieldsPerFormTab&&t.addIssue({code:`too_big`,origin:`array`,maximum:n.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${n.fieldsPerFormTab} fields`,path:[`groups`]});let r=new Set,i=new Set;e.groups.forEach((e,n)=>{r.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,n,`name`]}),r.add(e.name),e.fields.forEach((e,r)=>{i.has(e.attribute)&&t.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,n,`fields`,r,`attribute`]}),i.add(e.attribute)})})}const q={name:i.string().describe(`Content API name, unique in the view`),label:i.string().optional().describe(`Label people see`),icon:r.optional().describe(`Icon name`),placement:i.enum([`main`,`aside`]).describe(`main: any tabs. aside: at most one, a form`)},J=i.object({object:i.string().optional().describe(`Every record of this object`),relation:i.string().optional().describe(`Records linked through this relation`)}).strict().superRefine((e,t)=>{e.object===void 0&&e.relation===void 0&&t.addIssue({code:`custom`,message:`Collection source must define an object, a relation, or both`})}).transform(e=>e.relation===void 0?{object:e.object}:e.object===void 0?{relation:e.relation}:{object:e.object,relation:e.relation}),me={...q,type:i.literal(`collection`),source:J.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:i.enum(t).optional().describe(`all: no scope; workspace: every member; private: viewer's own`),columns:i.array(i.union([i.string(),i.object({relationProperty:i.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(n.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:i.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:I.optional().describe(`Attributes shown on each card`),filters:K.optional().describe(`Restricts which records show`),sorts:R.optional().describe(`Sort order`),actions:i.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:i.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:i.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},he=i.object({...me,layout:i.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:i.record(i.string(),i.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:i.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:i.array(i.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:i.record(i.string(),i.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:i.array(i.string()).optional().describe(`Kanban: columns pinned first`)}).strict().superRefine((e,t)=>{let n=[`groupByAttribute`,`kanbanColumnOrder`,`kanbanColumnVisibility`,`kanbanPinnedColumns`];if(e.layout===`kanban`){e.groupByAttribute===void 0&&t.addIssue({code:`custom`,path:[`groupByAttribute`],message:`A kanban layout requires groupByAttribute`});return}for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),Y={...q,type:i.literal(`form`),groups:i.array(pe).max(n.groupsPerFormTab).describe(`Field groups, in order`),formColumns:i.union([i.literal(1),i.literal(2),i.literal(3)]).optional().describe(`Grid columns, 1-3`),density:i.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},ge=i.object(Y).strict().superRefine(refineFormContent),X=i.object({...Y,groups:Y.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),Z=[he,i.object({...q,type:i.literal(`custom`),extension:i.string().describe(`Name of a registered extension`),parameters:i.lazy(()=>P).optional().describe(`Extension parameters`)}).strict(),i.object({...q,type:i.literal(`activity`)}).strict(),i.object({...q,type:i.literal(`richtext`),attribute:i.string().describe(`Richtext attribute edited in place`),titleAttribute:i.string().optional().describe(`Text attribute shown as the title`)}).strict(),i.object({...q,type:i.literal(`documents`),allowUpload:i.boolean().optional().describe(`Lets people add files here`),allowRemove:i.boolean().optional().describe(`Lets people remove files here`),hideAttachments:i.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:i.array(i.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),i.object({...q,type:i.literal(`forms`),objectName:i.string().optional().describe(`Limits to this object's published forms`)}).strict(),i.object({...q,type:i.literal(`emails`),emailAttributes:i.array(i.string()).max(n.emailAttributesPerTab).describe(`Addresses`)}).strict(),i.object({...q,type:i.literal(`meetings`),emailAttributes:i.array(i.string()).max(n.emailAttributesPerTab).describe(`Addresses`)}).strict()],_e=i.discriminatedUnion(`type`,[ge,...Z]),Q=i.discriminatedUnion(`type`,[X,...Z]),$={object:i.string(),name:i.string(),label:i.string(),description:i.string().optional(),icon:r.optional(),context:i.enum([`collection`,`record`]),default:i.boolean().optional()},ve=i.object({...$,contents:i.array(_e).max(n.tabsPerView)}).strict(),ye=i.object({...$,contents:i.array(Q).max(n.tabsPerView)}).strict();function addDuplicateContentNameIssues(e,t){let n=new Set;e.contents.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate content name "${e.name}"`,path:[`contents`,r,`name`]}),n.add(e.name)})}function asideRuleIssues(e){let t=e.contents.map((e,t)=>({content:e,index:t})).filter(({content:e})=>e.placement===`aside`),n=[],[,r]=t;r&&n.push({contentName:null,path:[`contents`,r.index,`placement`],message:`Aside holds one content for now; put the others in main`});for(let{content:e,index:r}of t)e.type!==`form`&&n.push({contentName:e.name,path:[`contents`,r,`type`],message:`Only a form content can sit in aside for now; put ${e.type} in main`});return n}function addAsideIssues(e,t){for(let n of asideRuleIssues(e))t.addIssue({code:`custom`,path:n.path,message:n.message})}function draftContentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return ve.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),e===`enforce`&&addAsideIssues(t,n)})}function contentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return ye.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),t.contents.some(e=>e.placement===`main`)||n.addIssue({code:`custom`,message:`A published view requires at least one main content`,path:[`contents`]}),e===`enforce`&&addAsideIssues(t,n)})}const be=draftContentViewDefinitionSchemaFor(),xe=contentViewDefinitionSchemaFor();export{getSystemAttributeI18nKey as $,currentActor as A,g as B,canonicalizeFilterValue as C,toMultiValueOperator as D,normalizeForEdgeRpc as E,S as F,isAttributeKanbanGroupable as G,getAttributeFilterOperators as H,filterOperatorsByTypeForGeneration as I,isLocationFilterProperty as J,isAttributeSearchable as K,getRollupFilterOperators as L,now as M,today as N,extractCurrencyFilterValue as O,C as P,a as Q,isNoValueOperator as R,normalizeOperator as S,isSetMembershipOperator as T,isAttributeFilterable as U,getAttributeCapabilities as V,isAttributeGroupable as W,resolveEffectiveFilterType as X,isLocationPartOperator as Y,o as Z,resolveIsWithinBounds as _,contentViewDefinitionSchemaFor as a,D as b,draftContentViewDefinitionSchemaFor as c,R as d,getSystemAttributeList as et,j as f,isRelativeDateValue as g,validateQualifiedRule as h,xe as i,isDynamicValue as j,extractFilterValue as k,K as l,collectQualifiedRuleIssues as m,J as n,I as o,A as p,isAttributeSortable as q,F as r,be as s,asideRuleIssues as t,isManagedSystemAttribute as tt,Q as u,resolveUtcDayBounds as v,getOperatorPolarity as w,normalizeFilterRule as x,toUtcDayString as y,_ as z};
|
|
2
|
+
import{ValidationError as e}from"./exceptions.mjs";import{A as t,M as n,j as r}from"./config-aeELOnWd.mjs";import{z as i}from"zod";const a={createdAt:`createdAt`,updatedAt:`updatedAt`,createdBy:`createdBy`,lastUpdatedBy:`lastUpdatedBy`,attachments:`attachments`};function getSystemAttributeI18nKey(e){return a[e]}const o={createdAt:{id:`system:createdAt`,name:`createdAt`,label:`Created time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was created`},updatedAt:{id:`system:updatedAt`,name:`updatedAt`,label:`Last edited time`,type:`date`,required:!1,system:!0,icon:`clock-circle`,description:`When this record was last modified`},createdBy:{id:`system:createdBy`,name:`createdBy`,label:`Created by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who created this record`},lastUpdatedBy:{id:`system:lastUpdatedBy`,name:`lastUpdatedBy`,label:`Last edited by`,type:`user`,required:!1,system:!0,multiple:!1,icon:`user`,description:`Actor who last modified this record`},attachments:{id:`system:attachments`,name:`attachments`,label:`Attachments`,type:`document`,required:!1,system:!0,hidden:!0,icon:`paperclip`,description:`Free-form document attachments`}};function getSystemAttributeList(){return Object.values(o)}function isManagedSystemAttribute(e){return e.id?.startsWith(`system:`)??!1}const s=[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`],c=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_empty`,`is_not_empty`],l=[`is`],u=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`is_empty`,`is_not_empty`],d=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],f=[`any_of`,`none_of`,`is_empty`,`is_not_empty`],p=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],m=[`is_empty`,`is_not_empty`],h=[`is`,`is_not`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`contains`,`not_contains`,`is_empty`,`is_not_empty`],g=[`city`,`postalCode`,`country`];function isLocationFilterProperty(e){return g.includes(e)}function isLocationPartOperator(e){return s.includes(e)}const _={text:s,richtext:[],number:c,checkbox:l,date:u,phone:[`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`is_empty`,`is_not_empty`],currency:c,status:d,select:d,multiselect:f,location:[],user:p,relation:p,formula:h,document:m},ee=new Set([`formula`,`rollup`]),v=new Set([`user`,`relation`,`document`]),y=new Set([`text`,`richtext`,`number`,`select`,`multiselect`,`status`,`date`,`phone`,`currency`,`location`,`user`,`relation`,`document`]),te=new Set([`text`,`number`,`date`,`phone`,`currency`,`select`,`multiselect`]),b=new Set([`text`,`phone`,`status`,`select`,`multiselect`]),x=new Set([`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`status`,`select`]);function getAttributeCapabilities(e){let t=!!(e.hidden||e.archived),n=!e.archived,r=ee.has(e.type),i=e.type===`document`,a=v.has(e.type),o=getAttributeCardinality(e),s=t?[]:getRawFilterOperators(e),c=s.length>0&&!t,l=!t&&b.has(e.type),u=!t&&x.has(e.type),d=!t&&isGroupableType(e.type),f=!t&&e.type===`status`,p=isManagedSystemAttribute(e),m=r||i||p,h=!(t||m),g=isRequiredForbidden(e.type)?`forbidden`:`allowed`,_=getDefaultValueCapability(e.type),y=supportsMaxItems(e),S=te.has(e.type),C=!(!e.deprecated||t),w=resolveEditMode(e);return{lifecycle:{active:n,deprecated:!!e.deprecated,visibleInArchitect:!0,visibleInRuntime:!t,warningWhenDeprecated:C},storage:{mode:r?`computed`:a?`edge`:`value`,cardinality:o,edgeBacked:a,preservesExistingValues:!!e.archived,qualifiedProperties:supportsQualifiedProperties(e.type),polymorphic:getPolymorphicCapability(e),maxItems:y},authoring:{editable:h,readOnly:m,directEdit:h&&w===`inline`,required:g,defaultValue:_,placeholder:S,maxItems:y},presentation:{formField:!t&&isFormFieldType(e.type),tableCell:!t&&isTableCellType(e.type),defaultColumn:!t&&isDefaultColumnType(e.type),compactDisplay:!t,popoverEditor:!t&&w===`popover`,placeholder:S,warningWhenDeprecated:C},query:{filterable:c,searchable:l,sortable:u,groupable:d,kanbanGroupable:f,operators:s},agent:{readable:!t,writable:h&&!i,compactReadable:!t,contentReadable:!t&&isContentReadableType(e.type),requiresDedicatedTool:i},exchange:{importable:!t,exportable:!t,schemaExportable:!0,metadataExportable:!1}}}function getAttributeFilterOperators(e){return getAttributeCapabilities(e).query.operators}function isAttributeFilterable(e){return getAttributeCapabilities(e).query.filterable}function isAttributeSearchable(e){return getAttributeCapabilities(e).query.searchable}function isAttributeSortable(e){return getAttributeCapabilities(e).query.sortable}function isAttributeGroupable(e){return getAttributeCapabilities(e).query.groupable}function isAttributeKanbanGroupable(e){return getAttributeCapabilities(e).query.kanbanGroupable}function resolveEffectiveFilterType(e){if(e.type!==`rollup`)return e.type;let t=e;if(t.function===`earliest`||t.function===`latest`)return`date`;if(t.function===`original`){let e=t.targetAttributeType;if(e&&hasFilterOperatorEntry(e))return e}return`number`}function getRollupFilterOperators$1(e){let t=resolveEffectiveFilterType(e);return hasFilterOperatorEntry(t)?_[t]:_.number}function getRawFilterOperators(e){return e.type===`rollup`?getRollupFilterOperators$1(e):_[e.type]??[]}function getAttributeCardinality(e){return e.type===`multiselect`||e.type===`document`||e.type===`user`&&e.multiple===!0||e.type===`relation`&&e.cardinality===`many`?`many`:`one`}function getPolymorphicCapability(e){if(e.type!==`relation`)return`none`;let t=e.targets??[];return t.length===1&&t[0]?.object===`*`?`internal`:t.length>1?`code-only`:`none`}function supportsMaxItems(e){return e.type===`multiselect`||e.type===`relation`&&e.cardinality===`many`}function supportsQualifiedProperties(e){return e===`relation`||e===`document`}function isRequiredForbidden(e){return e===`checkbox`||e===`formula`||e===`rollup`}function getDefaultValueCapability(e){return e===`checkbox`?`automatic`:e===`formula`||e===`rollup`?`forbidden`:y.has(e)?`static`:`forbidden`}function isDefaultColumnType(e){return isTableCellType(e)}function isTableCellType(e){return e!==`richtext`&&e!==`document`}function isFormFieldType(e){return e!==`richtext`}function resolveEditMode(e){switch(e.type){case`checkbox`:return`inline`;case`number`:return e.renderAs===`rating`?`inline`:`default`;case`select`:case`multiselect`:return e.renderAs===`badges`?`inline`:`popover`;case`status`:case`relation`:case`user`:case`date`:return`popover`;default:return`default`}}function isGroupableType(e){return e===`status`||e===`currency`}function isContentReadableType(e){return e===`richtext`||e===`document`}function hasFilterOperatorEntry(e){return Object.prototype.hasOwnProperty.call(_,e)}const S=_,C=[`is_empty`,`is_not_empty`];function isNoValueOperator(e){return C.includes(e)}function filterOperatorsByTypeForGeneration(e){return e===`rollup`?C:S[e]??[]}function getRollupFilterOperators(e){return getRollupFilterOperators$1(e)}function isDynamicValue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&`dynamic`in e}function currentActor(){return{dynamic:`actor`,ref:`current`}}function today(){return{dynamic:`date`,anchor:`today`}}function now(){return{dynamic:`date`,anchor:`now`}}function toAmount(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function extractCurrencyFilterValue(e){return typeof e==`object`&&e?`value`in e?toAmount(e.value):null:toAmount(e)}function extractFilterValue(e){return e==null?null:typeof e==`object`&&`value`in e?e.value??null:e}const w=new Set([`is_not`,`not_contains`,`none_of`,`is_empty`]),ne={is_not:`is`,not_contains:`contains`,none_of:`any_of`,is_empty:`is_not_empty`};function getOperatorPolarity(e){return w.has(e)?`none`:`any`}function normalizeForEdgeRpc(e){return ne[e]??e}const T={is:`any_of`,is_not:`none_of`};function toMultiValueOperator(e){return T[e]??e}const E=new Set(Object.values(T).filter(e=>e!==void 0));function isSetMembershipOperator(e){return E.has(e)}function canonicalizeFilterValue(t,n){let r=t.value;if(isNoValueOperator(t.operator)||r==null||isDynamicValue(r))return;if(isSetMembershipOperator(t.operator)){Array.isArray(r)||(t.value=[r]);return}if(n!==`currency`)return;let i=extractCurrencyFilterValue(r);if(i!==null){t.value=i;return}if(!hasCurrencyAmount(r))return;let a=`Filter on a currency attribute expected a numeric amount, received ${JSON.stringify(r)}`;throw new e(a,[{path:[`value`],message:a}])}function hasCurrencyAmount(e){return typeof e!=`object`||`value`in e&&e.value!=null}const D={eq:`is`,equals:`is`,equal:`is`,"==":`is`,"=":`is`,neq:`is_not`,notEqual:`is_not`,isNot:`is_not`,"!=":`is_not`,"<>":`is_not`,lt:`less_than`,"<":`less_than`,gt:`greater_than`,">":`greater_than`,lte:`less_or_equal`,"<=":`less_or_equal`,gte:`greater_or_equal`,">=":`greater_or_equal`,in:`any_of`,isAnyOf:`any_of`,anyOf:`any_of`,oneOf:`any_of`,notIn:`none_of`,not_in:`none_of`,isNoneOf:`none_of`,noneOf:`none_of`,notOneOf:`none_of`,startsWith:`starts_with`,beginsWith:`starts_with`,endsWith:`ends_with`,doesNotContain:`not_contains`,notContain:`not_contains`,isEmpty:`is_empty`,isNotEmpty:`is_not_empty`};function normalizeOperator(e){return D[e]??e}function normalizeFilterRule(e){let t=normalizeOperator(e.operator);return t===e.operator?e:{...e,operator:t}}const O=864e5,re=new Set([`days`,`weeks`,`months`,`years`]),ie=new Set([`past`,`future`]);function isRelativeDateValue(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.amount==`number`&&Number.isFinite(t.amount)&&t.amount>0&&typeof t.unit==`string`&&re.has(t.unit)&&typeof t.direction==`string`&&ie.has(t.direction)}function utcDayStart(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function shiftUtcDay(e,t,n){if(n===`days`)return e+t*O;if(n===`weeks`)return e+t*7*O;let r=new Date(e),i=r.getUTCFullYear()+(n===`years`?t:0),a=r.getUTCMonth()+(n===`months`?t:0),o=new Date(Date.UTC(i,a+1,0)).getUTCDate();return Date.UTC(i,a,Math.min(r.getUTCDate(),o))}function resolveIsWithinBounds(e,t=new Date){if(!isRelativeDateValue(e))return null;let n=utcDayStart(t),r=Math.trunc(e.amount),i=e.direction===`past`?{startMs:shiftUtcDay(n,-r,e.unit),endMs:n+O}:{startMs:n,endMs:shiftUtcDay(n,r,e.unit)+O};return Number.isFinite(i.startMs)&&Number.isFinite(i.endMs)?i:null}function resolveUtcDayBounds(e){if(!Number.isFinite(e))return null;let t=utcDayStart(new Date(e));return Number.isFinite(t)?{startMs:t,endMs:t+O}:null}function toUtcDayString(e){return new Date(e).toISOString().slice(0,10)}const ae=new Set([`relation`,`document`,`user`]),k=[`is`,`is_not`,`any_of`,`none_of`,`is_empty`,`is_not_empty`],oe={id:k,objectId:k,tenantId:k,label:S.text,createdAt:S.date,updatedAt:S.date,deletedAt:S.date,createdBy:S.user,lastUpdatedBy:S.user},A={id:`text`,objectId:`text`,objectName:`text`,tenantId:`text`,label:`text`,createdAt:`date`,updatedAt:`date`,deletedAt:`date`,deletedBy:`user`,createdBy:`user`,lastUpdatedBy:`user`,visibility:`select`,ownedBy:`user`},j={before:`"less_than"`,after:`"greater_than"`,on_or_before:`"less_or_equal"`,on_or_after:`"greater_or_equal"`,is_checked:`"is" with value true`,is_not_checked:`"is" with value false`,day_month_eq:`"on_day_month"`},se=new Set(Object.entries(_).filter(([,e])=>e.includes(`any_of`)&&!e.includes(`contains`)).map(([e])=>e)),ce={contains:`any_of`,not_contains:`none_of`};function resolveCanonicalOperator(t,n){let r=j[t];if(r){let n=`Unknown filter operator "${t}" — use ${r}`;throw new e(n,[{path:[`operator`],message:n}])}let i=normalizeOperator(t),a=ce[i];if(a&&se.has(n)){let t=`Operator "${i}" is not valid for type "${n}" — use "${a}"`;throw new e(t,[{path:[`operator`],message:t}])}return i}function assertOperatorForType(t,n,r){let i=resolveCanonicalOperator(t,n),a=S[n];if(!a?.includes(i)){let i=`Operator "${t}" is not valid for ${r} type "${n}". Valid operators: ${a?.length?a.join(`, `):`(no operators registered for this type)`}.`;throw new e(i,[{path:[`operator`],message:i}])}return i}function assertRelativeDateValue(t){if(t.operator===`is_within`&&!isRelativeDateValue(t.value)){let t=`Operator "is_within" requires a relative-date value { amount: positive number, unit: days|weeks|months|years, direction: past|future }`;throw new e(t,[{path:[`value`],message:t}])}}function applyCanonicalForm(e,t,n){e.operator=t,canonicalizeFilterValue(e,n),assertRelativeDateValue(e)}function assertDynamicValueForAttribute(t,n){if(!isDynamicValue(t.value))return;let r=t.value;if(r.dynamic===`actor`&&n!==`user`){let t=`actor token (@me) is only valid on user attributes, not "${n}"`;throw new e(t,[{path:[`value`],message:t}])}if(r.dynamic===`date`&&n!==`date`){let t=`date token (@today/@now) is only valid on date attributes, not "${n}"`;throw new e(t,[{path:[`value`],message:t}])}}const M=g.map(e=>`"${e}"`).join(`, `);function locationPartsHint(e){return e===`location`?` A location is filtered on one of its parts: set "property" to one of ${M} and use a text operator (e.g. contains).`:``}function collectQualifiedRuleIssues(t,n){try{return validateQualifiedRule({...t},n),[]}catch(t){if(!(t instanceof e))throw t;return t.errors.map(e=>({...e,path:[...e.path]}))}}function validateQualifiedRule(t,n){let r=n.attributes.find(e=>e.name===t.attribute),i=oe[t.attribute];if(!(r||i)){let[r,...i]=t.attribute.split(`.`),a=(i.length>0?n.attributes.find(e=>e.name===r):void 0)?.type===`location`?` Dotted paths are not supported — set "attribute" to "${r}" and "property" to ${isLocationFilterProperty(i[0]??``)?`"${i[0]}"`:`one of ${M}`}.`:t.attribute.includes(`.`)?` Dotted paths are not supported — filter on the attribute name alone, or use the full-text "query" parameter to match text inside a value.`:``,o=`Unknown attribute: ${t.attribute}${a}`;throw new e(o,[{path:[`attribute`],message:o}])}if(t.quantifier!==void 0&&!t.property){let t=`quantifier is only valid on qualified edge rules (set "property")`;throw new e(t,[{path:[`quantifier`],message:t}])}if(!r){if(t.property)throw new e(`Cannot qualify system attribute "${t.attribute}"`,[{path:[`property`],message:`"${t.attribute}" is a system column, not a reference`}]);let n=A[t.attribute]??`text`,r=resolveCanonicalOperator(t.operator,n);if(!i.includes(r)){let n=`Operator "${t.operator}" is not valid for system attribute "${t.attribute}". Valid operators: ${i.join(`, `)}.`;throw new e(n,[{path:[`operator`],message:n}])}applyCanonicalForm(t,r,n);return}if(!t.property){assertDynamicValueForAttribute(t,r.type);let n=getAttributeFilterOperators(r),i=resolveCanonicalOperator(t.operator,r.type);if(!n.includes(i)){let i=n.length?n.join(`, `):`(not filterable)`,a=`Operator "${t.operator}" is not valid for attribute "${r.name}". Valid operators: ${i}.${locationPartsHint(r.type)}`;throw new e(a,[{path:[`operator`],message:a}])}applyCanonicalForm(t,i,resolveEffectiveFilterType(r));return}if(r.type===`location`){if(t.quantifier!==void 0){let t=`quantifier is not valid on a location part — a location is one value, not a set of edges`;throw new e(t,[{path:[`quantifier`],message:t}])}if(!isLocationFilterProperty(t.property)){let n=`Property "${t.property}" is not a part of location "${t.attribute}". Valid parts: ${M}.`;throw new e(n,[{path:[`property`],message:n}])}assertDynamicValueForAttribute(t,`text`),applyCanonicalForm(t,assertOperatorForType(t.operator,`text`,`property`),`text`);return}if(!ae.has(r.type))throw new e(`Cannot qualify ${r.type} attribute "${t.attribute}"`,[{path:[`property`],message:`Attribute "${t.attribute}" is not a reference type`}]);let a=r.properties;if(!a)throw new e(`Attribute "${t.attribute}" has no qualifyWith schema`,[{path:[`property`],message:`"${t.attribute}" has no qualifyWith`}]);let o=a.definitions.find(e=>e.name===t.property);if(!o)throw new e(`Property "${t.property}" not defined on "${t.attribute}".qualifyWith()`,[{path:[`property`],message:`Unknown property: ${t.property}`}]);applyCanonicalForm(t,assertOperatorForType(t.operator,o.type,`property`),o.type)}const N=1e4;function isPlainJsonObject(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null&&t.constructor?.name===`Object`}function addJsonIssue(e,t,n=[]){e.addIssue({code:`custom`,message:t,path:n})}function pushJsonArrayChildren(e,t,n,r){for(let n of Reflect.ownKeys(e))if(n!==`length`){if(n===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,[...t.path,n]);continue}(typeof n==`symbol`||!/^(0|[1-9]\d*)$/.test(n))&&addJsonIssue(r,`Arrays cannot contain non-index JSON properties`,[...t.path,n])}for(let i=e.length-1;i>=0;i--){let a=Object.getOwnPropertyDescriptor(e,String(i)),o=[...t.path,i];if(!(a&&`value`in a)){addJsonIssue(r,`Sparse arrays are not valid JSON values`,o);continue}n.push({kind:`enter`,value:a.value,path:o,depth:t.depth+1})}}function pushJsonObjectChildren(e,t,n,r){let i=Reflect.ownKeys(e);for(let a=i.length-1;a>=0;a--){let o=i[a],s=[...t.path,o];if(o===`__proto__`){addJsonIssue(r,`The __proto__ key is not allowed in custom props`,s);continue}if(typeof o==`symbol`){addJsonIssue(r,`Symbol keys are not valid JSON keys`,s);continue}let c=Object.getOwnPropertyDescriptor(e,o);if(!(c?.enumerable&&`value`in c)){addJsonIssue(r,`Custom props must contain enumerable data properties only`,s);continue}n.push({kind:`enter`,value:c.value,path:s,depth:t.depth+1})}}function validateJsonProps(e,t){if(typeof e!=`object`||!e){addJsonIssue(t,`Expected a plain JSON object`);return}try{if(Array.isArray(e)||!isPlainJsonObject(e)){addJsonIssue(t,`Expected a plain JSON object`);return}}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`);return}let n=new WeakSet,r=[{kind:`enter`,value:e,path:[],depth:0}],i=0;for(;r.length>0;){let e=r.pop();if(!e)break;if(e.kind===`exit`){n.delete(e.value);continue}if(i++,i>N){addJsonIssue(t,`Custom props cannot exceed ${N.toLocaleString(`en-US`)} total JSON nodes`,e.path);return}if(e.depth>64){addJsonIssue(t,`Custom props cannot exceed depth 64`,e.path);continue}let a=e.value;if(!(a===null||typeof a==`string`||typeof a==`boolean`||typeof a==`number`&&Number.isFinite(a))){if(typeof a!=`object`){addJsonIssue(t,`Expected a JSON value`,e.path);continue}if(n.has(a)){addJsonIssue(t,`Custom props cannot contain circular references`,e.path);continue}try{if(Array.isArray(a)){n.add(a),r.push({kind:`exit`,value:a}),pushJsonArrayChildren(a,e,r,t);continue}if(!isPlainJsonObject(a)){addJsonIssue(t,`Expected an array or plain JSON object`,e.path);continue}n.add(a),r.push({kind:`exit`,value:a}),pushJsonObjectChildren(a,e,r,t)}catch{addJsonIssue(t,`Custom props contain an object that cannot be safely inspected`,e.path)}}}}const P=i.unknown().superRefine(validateJsonProps).transform(e=>e),F=i.array(i.string()).max(r.columnsPerTab),I=i.array(i.string().min(1)).max(r.columnsPerTab).refine(e=>new Set(e).size===e.length,{message:`Displayed attribute names must be unique`}),L=i.object({attribute:i.string().describe(`Attribute to sort by`),direction:i.enum([`asc`,`desc`]).describe(`asc or desc`)}).strict(),R=i.array(L).max(r.sortsPerTab),z=i.object({amount:i.number().describe(`Count`),unit:i.enum([`days`,`weeks`,`months`,`years`]).describe(`Unit`),direction:i.enum([`past`,`future`]).describe(`Past or future`)}).strict(),B=i.object({value:i.number().nullable().describe(`Amount`),code:i.array(i.string()).optional().describe(`Currency codes`)}).strict(),V=i.object({phoneNumber:i.string().nullable().describe(`Number`),countryCode:i.string().optional().describe(`ISO country code`)}).strict(),H=i.discriminatedUnion(`dynamic`,[i.object({dynamic:i.literal(`actor`).describe(`Resolved at filter time`),ref:i.literal(`current`).describe(`The current actor`)}).strict(),i.object({dynamic:i.literal(`date`).describe(`Resolved at filter time`),anchor:i.enum([`today`,`now`]).describe(`Anchor`)}).strict()]),U=i.object({month:i.number().describe(`1-12`),day:i.number().describe(`Day`)}).strict(),W=i.union([i.string(),i.number(),i.boolean(),i.array(i.string()),z,B,V,U,H,i.null()]),G=i.enum([`is`,`is_not`,`contains`,`not_contains`,`starts_with`,`ends_with`,`is_empty`,`is_not_empty`,`less_than`,`greater_than`,`less_or_equal`,`greater_or_equal`,`is_within`,`on_day_month`,`any_of`,`none_of`],{error:e=>{let t=e.input,n=typeof t==`string`?j[t]:void 0;return n?`Unknown filter operator "${t}" — use ${n}`:void 0}}),le=i.object({attribute:i.string().describe(`Attribute to filter on`),property:i.string().optional().describe(`Qualified edge property`),quantifier:i.enum([`any`,`none`]).optional().describe(`For a multi-value attribute`),operator:G.describe(`Comparison`),value:W.describe(`Comparison value, by attribute type`)}).strict(),ue=i.array(le).max(r.filterRulesPerTab),K=i.object({combinator:i.enum([`and`,`or`]).describe(`Match every rule or any rule`),rules:ue.describe(`The rules`)}).strict(),de={span:i.union([i.literal(1),i.literal(2),i.literal(3),i.literal(4),i.literal(5),i.literal(6),i.literal(7),i.literal(8),i.literal(9),i.literal(10),i.literal(11),i.literal(12)]).optional().describe(`Columns of 12 this field occupies`),label:i.string().optional().describe(`Overrides the attribute's label`),readOnly:i.boolean().optional().describe(`Shows the value, not editable`)},fe=i.object({attribute:i.string().describe(`Attribute API name shown by this field`),...de}).strict(),pe=i.object({name:i.string().describe(`Group API name, unique in the form`),label:i.string().describe(`Label people see`),description:i.string().optional().describe(`Extra context under the label`),collapsible:i.boolean().optional().describe(`Whether the group can be collapsed`),collapsed:i.boolean().optional().describe(`Whether the group starts collapsed`),fields:i.array(fe).max(r.fieldsPerGroup).describe(`Fields in this group, in order`)}).strict();function refineFormContent(e,t){e.groups.reduce((e,t)=>e+t.fields.length,0)>r.fieldsPerFormTab&&t.addIssue({code:`too_big`,origin:`array`,maximum:r.fieldsPerFormTab,inclusive:!0,message:`A form content can contain at most ${r.fieldsPerFormTab} fields`,path:[`groups`]});let n=new Set,i=new Set;e.groups.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate group name "${e.name}"`,path:[`groups`,r,`name`]}),n.add(e.name),e.fields.forEach((e,n)=>{i.has(e.attribute)&&t.addIssue({code:`custom`,message:`Duplicate field attribute "${e.attribute}"`,path:[`groups`,r,`fields`,n,`attribute`]}),i.add(e.attribute)})})}const q={name:i.string().describe(`Content API name, unique in the view`),label:i.string().optional().describe(`Label people see`),icon:t.optional().describe(`Icon name`),placement:i.enum([`main`,`aside`]).describe(`main: any tabs. aside: at most one, a form`)},J=i.object({object:i.string().optional().describe(`Every record of this object`),relation:i.string().optional().describe(`Records linked through this relation`)}).strict().superRefine((e,t)=>{e.object===void 0&&e.relation===void 0&&t.addIssue({code:`custom`,message:`Collection source must define an object, a relation, or both`})}).transform(e=>e.relation===void 0?{object:e.object}:e.object===void 0?{relation:e.relation}:{object:e.object,relation:e.relation}),me={...q,type:i.literal(`collection`),source:J.describe(`object: every record; relation: records linked to this record; both: records of object whose relation points at this record`),visibility:i.enum(n).optional().describe(`all: no scope; workspace: every member; private: viewer's own`),columns:i.array(i.union([i.string(),i.object({relationProperty:i.string().refine(e=>e.trim().length>0).describe(`Qualified edge property shown as a column`)}).strict()])).max(r.columnsPerTab).optional().describe(`Table columns, in order`),descriptionAttribute:i.string().optional().describe(`Secondary line under each row's title (list layout)`),displayAttributes:I.optional().describe(`Attributes shown on each card`),filters:K.optional().describe(`Restricts which records show`),sorts:R.optional().describe(`Sort order`),actions:i.enum([`create`,`update`,`delete`,`attach`,`detach`]).array().optional().describe(`Offered actions; absent = every action, [] = none`),openMode:i.enum([`page`,`peek`]).optional().describe(`page or peek (the record panel)`),createMode:i.enum([`page`,`peek`,`inline`]).optional().describe(`page, peek, or inline (creates without opening)`)},he=i.object({...me,layout:i.enum([`table`,`list`,`kanban`]).describe(`table columns, list cards, kanban board grouped by a select/status attribute`),columnSizing:i.record(i.string(),i.number()).optional().describe(`Column widths in pixels, by attribute name`),groupByAttribute:i.string().optional().describe(`Kanban only: the select or status attribute that names the columns`),kanbanColumnOrder:i.array(i.string()).optional().describe(`Kanban: column order by option value`),kanbanColumnVisibility:i.record(i.string(),i.boolean()).optional().describe(`Kanban: which columns are shown`),kanbanPinnedColumns:i.array(i.string()).optional().describe(`Kanban: columns pinned first`)}).strict().superRefine((e,t)=>{let n=[`groupByAttribute`,`kanbanColumnOrder`,`kanbanColumnVisibility`,`kanbanPinnedColumns`];if(e.layout===`kanban`){e.groupByAttribute===void 0&&t.addIssue({code:`custom`,path:[`groupByAttribute`],message:`A kanban layout requires groupByAttribute`});return}for(let r of n)e[r]!==void 0&&t.addIssue({code:`custom`,path:[r],message:`Only a kanban layout groups by an attribute`})}),Y={...q,type:i.literal(`form`),groups:i.array(pe).max(r.groupsPerFormTab).describe(`Field groups, in order`),formColumns:i.union([i.literal(1),i.literal(2),i.literal(3)]).optional().describe(`Grid columns, 1-3`),density:i.enum([`compact`,`comfortable`,`spacious`]).optional().describe(`Vertical spacing between fields`)},ge=i.object(Y).strict().superRefine(refineFormContent),X=i.object({...Y,groups:Y.groups.min(1,`A published form content requires at least one group`)}).strict().superRefine(refineFormContent),Z=[he,i.object({...q,type:i.literal(`custom`),extension:i.string().describe(`Name of a registered extension`),parameters:i.lazy(()=>P).optional().describe(`Extension parameters`)}).strict(),i.object({...q,type:i.literal(`activity`)}).strict(),i.object({...q,type:i.literal(`richtext`),attribute:i.string().describe(`Richtext attribute edited in place`),titleAttribute:i.string().optional().describe(`Text attribute shown as the title`)}).strict(),i.object({...q,type:i.literal(`documents`),allowUpload:i.boolean().optional().describe(`Lets people add files here`),allowRemove:i.boolean().optional().describe(`Lets people remove files here`),hideAttachments:i.boolean().optional().describe(`Hides files attached elsewhere (e.g. emails)`),relations:i.array(i.string()).optional().describe(`Document relations shown; the record's own files if absent`)}).strict(),i.object({...q,type:i.literal(`forms`),objectName:i.string().optional().describe(`Limits to this object's published forms`)}).strict(),i.object({...q,type:i.literal(`emails`),emailAttributes:i.array(i.string()).max(r.emailAttributesPerTab).describe(`Addresses`)}).strict(),i.object({...q,type:i.literal(`meetings`),emailAttributes:i.array(i.string()).max(r.emailAttributesPerTab).describe(`Addresses`)}).strict()],_e=i.discriminatedUnion(`type`,[ge,...Z]),Q=i.discriminatedUnion(`type`,[X,...Z]),$={object:i.string(),name:i.string(),label:i.string(),description:i.string().optional(),icon:t.optional(),context:i.enum([`collection`,`record`]),default:i.boolean().optional()},ve=i.object({...$,contents:i.array(_e).max(r.tabsPerView)}).strict(),ye=i.object({...$,contents:i.array(Q).max(r.tabsPerView)}).strict();function addDuplicateContentNameIssues(e,t){let n=new Set;e.contents.forEach((e,r)=>{n.has(e.name)&&t.addIssue({code:`custom`,message:`Duplicate content name "${e.name}"`,path:[`contents`,r,`name`]}),n.add(e.name)})}function asideRuleIssues(e){let t=e.contents.map((e,t)=>({content:e,index:t})).filter(({content:e})=>e.placement===`aside`),n=[],[,r]=t;r&&n.push({contentName:null,path:[`contents`,r.index,`placement`],message:`Aside holds one content for now; put the others in main`});for(let{content:e,index:r}of t)e.type!==`form`&&n.push({contentName:e.name,path:[`contents`,r,`type`],message:`Only a form content can sit in aside for now; put ${e.type} in main`});return n}function addAsideIssues(e,t){for(let n of asideRuleIssues(e))t.addIssue({code:`custom`,path:n.path,message:n.message})}function draftContentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return ve.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),e===`enforce`&&addAsideIssues(t,n)})}function contentViewDefinitionSchemaFor({asideRule:e=`enforce`}={}){return ye.superRefine((t,n)=>{addDuplicateContentNameIssues(t,n),t.contents.some(e=>e.placement===`main`)||n.addIssue({code:`custom`,message:`A published view requires at least one main content`,path:[`contents`]}),e===`enforce`&&addAsideIssues(t,n)})}const be=draftContentViewDefinitionSchemaFor(),xe=contentViewDefinitionSchemaFor();export{getSystemAttributeI18nKey as $,currentActor as A,g as B,canonicalizeFilterValue as C,toMultiValueOperator as D,normalizeForEdgeRpc as E,S as F,isAttributeKanbanGroupable as G,getAttributeFilterOperators as H,filterOperatorsByTypeForGeneration as I,isLocationFilterProperty as J,isAttributeSearchable as K,getRollupFilterOperators as L,now as M,today as N,extractCurrencyFilterValue as O,C as P,a as Q,isNoValueOperator as R,normalizeOperator as S,isSetMembershipOperator as T,isAttributeFilterable as U,getAttributeCapabilities as V,isAttributeGroupable as W,resolveEffectiveFilterType as X,isLocationPartOperator as Y,o as Z,resolveIsWithinBounds as _,contentViewDefinitionSchemaFor as a,D as b,draftContentViewDefinitionSchemaFor as c,R as d,getSystemAttributeList as et,j as f,isRelativeDateValue as g,validateQualifiedRule as h,xe as i,isDynamicValue as j,extractFilterValue as k,K as l,collectQualifiedRuleIssues as m,J as n,I as o,A as p,isAttributeSortable as q,F as r,be as s,asideRuleIssues as t,isManagedSystemAttribute as tt,Q as u,resolveUtcDayBounds as v,getOperatorPolarity as w,normalizeFilterRule as x,toUtcDayString as y,_ as z};
|
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.336",
|
|
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.336"
|
|
131
131
|
},
|
|
132
132
|
"devDependencies": {
|
|
133
133
|
"@types/node": "^25.0.3",
|
package/dist/config-CFYxsRcx.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
|
|
2
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__copyProps=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},__toESM=(n,r,o)=>(o=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));const o=require("./exceptions.js");let s=require("@stndrds/constants"),c=require("zod");c=__toESM(c);const l=[`skill`,`memory`,`drives`,`artifact`,`meeting`];function isNativeObjectName(e){return l.includes(e)}const u=[`workspace`,`private`],d=[`all`,...u];function parseResourceVisibility(e){if(typeof e==`string`&&u.includes(e))return e;throw new o.ValidationError(`visibility must be one of: ${u.join(`, `)} (received: ${String(e)})`,[])}const f=[`id`,`createdAt`,`updatedAt`,`createdBy`,`lastUpdatedBy`,`visibility`,`ownedBy`],p=[...f,`objectId`,`label`,`embeddingText`,`values`,`metadata`,`deletedAt`,`deletedBy`,`schemaVersion`,`owned_by`],ee=l,m=new Set(s.ICONS),h=/^[a-zA-Z_][a-zA-Z0-9_]*$/,te=/^[a-z][a-z0-9-]*$/,g=c.default.string().min(1,`Object name cannot be empty`).max(63,`Object name is too long (max 63 characters)`).regex(/^[a-z][a-z0-9-]*$/,{message:`Invalid object name format.
|
|
3
|
-
Name must be in kebab-case (slug format):
|
|
4
|
-
✅ Valid: 'products', 'user-profiles', 'order-items'
|
|
5
|
-
❌ Invalid: 'Products', 'userProfiles', 'user_profiles'`});function validateObjectName(e){try{g.parse(e)}catch(e){throw e instanceof c.default.ZodError?new o.SchemaError(e.issues[0].message,o.SchemaErrorCode.INVALID_OBJECT_NAME):e}}function validateViewName(e){if(!e||e.length===0)throw new o.ValidationError(`View name cannot be empty`,[{path:[`name`],message:`View name cannot be empty`}]);if(e.length>63)throw new o.ValidationError(`View name is too long`,[{path:[`name`],message:`View name is too long (max 63 characters)`}]);if(!te.test(e))throw new o.ValidationError(`Invalid view name format`,[{path:[`name`],message:`View name must be in kebab-case (e.g., 'detail', 'list-view')`}])}function assertUniqueBy(e,t,n){let r=new Set;for(let i of e){let e=t(i);if(r.has(e))throw n(e);r.add(e)}}const _=c.default.string().min(1,`Attribute name cannot be empty`).max(63,`Attribute name is too long (max 63 characters)`).regex(h,{message:`Invalid attribute name format.
|
|
6
|
-
Name must be a valid variable identifier:
|
|
7
|
-
✅ Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
|
|
8
|
-
❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`}).refine(e=>!p.includes(e),{message:`This is a reserved attribute name. Reserved names: ${p.join(`, `)}`});function validateAttributeName(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute name cannot be empty`);if(e.length>63)throw Error(`[AttributeBuilder] Attribute name is too long (max 63 characters)`);if(!h.test(e))throw Error(`[AttributeBuilder] Invalid attribute name format.
|
|
9
|
-
Name must be a valid variable identifier:
|
|
10
|
-
✅ Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'
|
|
11
|
-
❌ Invalid: 'first-name', 'first name', '123name', 'first.name'`);if(p.includes(e))throw Error(`[AttributeBuilder] "${e}" is a reserved name and cannot be used as an attribute name.\nReserved names: ${p.join(`, `)}`)}function validateLabel(e){if(!e||e.length===0)throw Error(`[AttributeBuilder] Attribute label cannot be empty`);if(e.length>128)throw Error(`[AttributeBuilder] Attribute label is too long (max 128 characters)`)}function validateIconName(e,t){if(!m.has(e))throw Error(`[AttributeBuilder] Invalid icon "${e}" in ${t}.\nIcon must be one of the predefined icons from @stndrds/constants.`)}function validateOptions(e,t){let n=new Set;for(let r of t){if(!r.value?.trim())throw Error(`[AttributeBuilder] Option in "${e}" has an empty or missing value.`);if(!r.label?.trim())throw Error(`[AttributeBuilder] Option "${r.value}" in "${e}" has an empty or missing label.`);if(n.has(r.value))throw Error(`[AttributeBuilder] Duplicate option value "${r.value}" in "${e}".`);n.add(r.value)}for(let n of t){if(n.inverse===void 0)continue;let r=t.find(e=>e.value===n.inverse);if(!r)throw Error(`[AttributeBuilder] Option "${n.value}" in "${e}" has inverse "${n.inverse}" which does not match any option value.`);if(r.inverse!==n.value)throw Error(`[AttributeBuilder] Inverse mismatch in "${e}": "${n.value}" points to "${n.inverse}", but "${n.inverse}" points to "${r.inverse??`(none)`}". Inverse pairs must be symmetric.`)}}const v={attributesPerObject:300,tabsPerView:24,groupsPerFormTab:12,fieldsPerGroup:60,fieldsPerFormTab:150,columnsPerTab:50,optionsPerAttribute:200,sidePanelAttributes:100,sidePanelPanes:20,filterRulesPerTab:50,sortsPerTab:20,emailAttributesPerTab:30,objectsPerPlan:20,mutationsPerPlan:500,planBytes:524288,historyDefault:20,historyMax:50,iconQueries:5,iconResults:20},ne=Object.keys(s.COLORS),re=new Set(s.ICONS),y=c.z.enum(ne).describe(`A color id from the palette`),b=c.z.string().superRefine((e,t)=>{re.has(e)||t.addIssue({code:`custom`,message:`Invalid icon name`})}).transform(e=>e);var ComputedFormulaParseError=class extends Error{constructor(e){super(e),this.name=`ComputedFormulaParseError`}};function parseComputedFormula(e){let t=new Parser(tokenize(e)),n=t.parseExpression();return t.expectEnd(),n}function tokenize(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===` `||r===` `||r===`
|
|
12
|
-
`||r===`\r`){n+=1;continue}if(r===`"`||r===`'`){let i=scanString(e,n,r);t.push({kind:`string`,value:i.value,position:n}),n=i.nextIndex;continue}if(isDigit(r)){let r=scanNumber(e,n);t.push({kind:`number`,value:r.value,position:n}),n=r.nextIndex;continue}if(isIdentifierStart(r)){let r=scanIdentifier(e,n),i=r.value.toLowerCase();i===`true`?t.push({kind:`boolean`,value:!0,position:n}):i===`false`?t.push({kind:`boolean`,value:!1,position:n}):i===`null`?t.push({kind:`null`,position:n}):t.push({kind:`identifier`,value:r.value,position:n}),n=r.nextIndex;continue}let i=e.slice(n,n+2);if(i===`>=`||i===`<=`||i===`==`||i===`!=`){t.push({kind:`operator`,value:i,position:n}),n+=2;continue}if(r===`>`||r===`<`||r===`+`||r===`-`||r===`*`||r===`/`){t.push({kind:`operator`,value:r,position:n}),n+=1;continue}if(r===`(`||r===`)`||r===`,`||r===`.`){t.push({kind:`punctuation`,value:r,position:n}),n+=1;continue}throw new ComputedFormulaParseError(`Unexpected character "${r}" at position ${n}`)}return t}function scanString(e,t,n=`"`){let r=``,i=t+1;for(;i<e.length;){let t=e[i];if(t===n)return{value:r,nextIndex:i+1};if(t===`\\`){let t=e[i+1];if(t===void 0)throw new ComputedFormulaParseError(`Unterminated string literal at position ${i}`);r+=decodeEscape(t,i),i+=2;continue}r+=t,i+=1}throw new ComputedFormulaParseError(`Unterminated string literal at position ${t}`)}function decodeEscape(e,t){switch(e){case`"`:case`\\`:return e;case`n`:return`
|
|
13
|
-
`;case`r`:return`\r`;case`t`:return` `;default:throw new ComputedFormulaParseError(`Unknown escape sequence "\\${e}" at position ${t}`)}}function scanNumber(e,t){let n=t;for(;n<e.length&&isDigit(e[n]);)n+=1;if(e[n]===`.`){let t=n;if(n+=1,!isDigit(e[n]))throw new ComputedFormulaParseError(`Invalid number literal at position ${t}`);for(;n<e.length&&isDigit(e[n]);)n+=1}let r=e.slice(t,n),i=Number(r);if(!Number.isFinite(i))throw new ComputedFormulaParseError(`Invalid number literal "${r}"`);return{value:i,nextIndex:n}}function scanIdentifier(e,t){let n=t+1;for(;n<e.length&&isIdentifierPart(e[n]);)n+=1;return{value:e.slice(t,n),nextIndex:n}}function isDigit(e){return e!==void 0&&e>=`0`&&e<=`9`}function isIdentifierStart(e){return e!==void 0&&/[A-Za-z_]/.test(e)}function isIdentifierPart(e){return e!==void 0&&/[A-Za-z0-9_]/.test(e)}var Parser=class{constructor(e){this.tokens=e,this.position=0}parseExpression(){return this.parseBinaryExpression(0)}expectEnd(){let e=this.peek();if(e!==void 0)throw new ComputedFormulaParseError(`Unexpected token ${describeToken(e)} at position ${e.position}`)}parseBinaryExpression(e){let t=this.parsePrimary();for(;;){let n=this.peek();if(n?.kind!==`operator`)return t;let r=getOperatorPrecedence(n.value);if(r<e)return t;let i=n.value;this.consume();let a=this.parseBinaryExpression(r+1);t={kind:`binary`,operator:i,left:t,right:a}}}parsePrimary(){let e=this.consume();if(e===void 0)throw new ComputedFormulaParseError(`Unexpected end of expression`);switch(e.kind){case`string`:case`number`:case`boolean`:return{kind:`literal`,value:e.value};case`null`:return{kind:`literal`,value:null};case`identifier`:return this.parseIdentifier(e.value);case`punctuation`:if(e.value===`(`){let e=this.parseExpression();return this.expectPunctuation(`)`),e}break;case`operator`:if(e.value===`-`){let e=this.consume();if(e?.kind===`number`)return{kind:`literal`,value:-e.value}}}throw new ComputedFormulaParseError(`Expected literal, path, call, or parenthesized expression at position ${e.position}`)}parseIdentifier(e){if(this.matchPunctuation(`(`)){let t=[];if(!this.matchPunctuation(`)`)){do t.push(this.parseExpression());while(this.matchPunctuation(`,`));this.expectPunctuation(`)`)}return{kind:`call`,functionName:e.toLowerCase(),args:t}}let t=[e];for(;this.matchPunctuation(`.`);){let e=this.consume();if(e?.kind!==`identifier`)throw new ComputedFormulaParseError(`Expected attribute name after path separator at position ${e?.position??this.previousPosition()}`);t.push(e.value)}return{kind:`path`,parts:t}}expectPunctuation(e){if(!this.matchPunctuation(e))throw new ComputedFormulaParseError(`Expected "${e}" at position ${this.peek()?.position??this.previousPosition()}`)}matchPunctuation(e){let t=this.peek();return t?.kind===`punctuation`&&t.value===e&&(this.consume(),!0)}peek(){return this.tokens[this.position]}consume(){let e=this.tokens[this.position];return this.position+=1,e}previousPosition(){return this.tokens[this.position-1]?.position??0}};function describeToken(e){switch(e.kind){case`identifier`:case`number`:case`string`:case`boolean`:case`operator`:case`punctuation`:return`"${String(e.value)}"`;case`null`:return`"null"`;default:return e}}function getOperatorPrecedence(e){switch(e){case`*`:case`/`:return 3;case`+`:case`-`:return 2;case`>`:case`<`:case`>=`:case`<=`:case`==`:case`!=`:return 1;default:return e}}const x=c.z.object({placeholder:c.z.string().optional(),description:c.z.string().optional(),defaultValue:c.z.unknown().optional(),icon:c.z.string().optional(),order:c.z.number().int().optional(),hidden:c.z.boolean().optional(),archived:c.z.boolean().optional(),deprecated:c.z.boolean().optional(),metadata:c.z.record(c.z.string(),c.z.unknown()).optional()}),S=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`];function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const C=c.z.object({value:c.z.string().min(1).describe(`Stored value`),label:c.z.string().min(1).describe(`Label people see`),description:c.z.string().describe(`Extra context`).optional(),inverse:c.z.string().describe(`Paired option's value (symmetric)`).optional(),archived:c.z.boolean().describe(`Hides without deleting`).optional()}),w=c.z.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),T=C.extend({color:y}).strict(),E=T,D=C.extend({color:y,group:w}).strict(),O=C.extend({color:c.z.string().optional().describe(`A color id`),group:w.optional()}).strict(),k=c.z.array(O).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(e){return c.z.array(e).min(1).max(v.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const A=writeOptionsArraySchema(T),j=writeOptionsArraySchema(E),M=writeOptionsArraySchema(D),ie=c.z.object({object:c.z.string().min(1).describe(`Target object`),displayTemplate:c.z.string().optional().describe(`Linked record label template`),filter:c.z.record(c.z.string(),c.z.unknown()).optional().describe(`Restricts linkable records`)}),ae=c.z.object({object:c.z.string().min(1).describe(`Other side's object`),attribute:c.z.string().min(1).describe(`Other side's attribute`),cardinality:c.z.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:c.z.string().min(1).optional().describe(`Other side's label`),storageOwner:c.z.boolean().optional().describe(`Owns the join storage`)}),N=c.z.object({objectName:c.z.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:c.z.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:c.z.string().optional().describe(`Id of the source attribute, resolved by the server`)}),P=x.extend({multiline:c.z.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:c.z.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:c.z.number().int().min(1).describe(`Maximum character count`).optional(),pattern:c.z.string().describe(`Regular expression the value must match`).optional(),format:c.z.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),oe=x,F=x.extend({renderAs:c.z.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:c.z.number().describe(`Minimum allowed value`).optional(),max:c.z.number().describe(`Maximum allowed value`).optional(),unit:c.z.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:c.z.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),I=x,L=x.extend({dateFormat:c.z.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),minDate:c.z.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:c.z.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:c.z.boolean().describe(`Also captures a time of day`).optional(),endDate:c.z.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:c.z.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),R=x.extend({defaultCountryCode:c.z.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),z=x.extend({defaultCurrency:c.z.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:c.z.array(c.z.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:c.z.boolean().describe(`Whether a negative amount is accepted`).optional()}),B=x.extend({options:k.describe(`The workflow statuses, in order`)}),V=x.extend({granularity:c.z.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:c.z.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:c.z.array(c.z.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),H=x.extend({options:k.describe(`Options`),renderAs:c.z.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),U=x.extend({options:k.describe(`Options`),renderAs:c.z.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),W=x.extend({types:c.z.array(c.z.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:c.z.boolean().optional().describe(`Whether more than one actor can be picked`)}),G={name:_.describe(`Property API name`),label:c.z.string().min(1).describe(`Label people see`),required:c.z.boolean().describe(`Required on every edge`).optional()},K={id:c.z.string().optional(),objectId:c.z.string().optional(),system:c.z.boolean().optional(),unique:c.z.boolean().optional()},se=Object.fromEntries(S.map(e=>[e,!0])),q=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],J=[...q,`select`,`multiselect`,`status`],Y={text:P,number:F,checkbox:I,date:L,phone:R,currency:z,location:V,select:H,multiselect:U,status:B},ce={...Y,select:H.extend({options:A.describe(`Options`)}),multiselect:U.extend({options:j.describe(`Options`)}),status:B.extend({options:M.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>ce[e].omit(se).shape,storedPropertyMember=e=>c.z.object({...G,...K,type:c.z.literal(e).describe(`Property type`),...Y[e].shape}).strip(),X=c.z.discriminatedUnion(`type`,J.map(storedPropertyMember)),Z=c.z.object({definitions:c.z.array(X).min(1).max(v.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),le=refuseForeignKeys(Object.fromEntries(J.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(G),`type`]);function refuseForeignPropertyKeys(e,t){le(e.type,e,t)}const ue=q.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>c.z.object({...G,type:e.length===1?c.z.literal(e[0]).describe(`Property type`):c.z.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Q=c.z.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),c.z.object({...G,type:c.z.enum(q).describe(`Property type`),...ue}).strict().superRefine(refuseForeignPropertyKeys)]),de=c.z.object({definitions:c.z.array(Q).min(1).max(v.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),fe=x.extend({targets:c.z.array(ie).min(1).describe(`Target object(s)`),cardinality:c.z.enum([`one`,`many`]).describe(`one or many`),maxItems:c.z.number().int().min(1).optional().describe(`Max linked records`),bilateral:ae.optional().describe(`Syncs the other side's attribute`),properties:Z.optional()}),pe=x.extend({expression:c.z.string().min(1).superRefine((e,t)=>{try{parseComputedFormula(e)}catch(e){t.addIssue({code:c.z.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid formula expression`})}}).describe(`The formula expression, compiled against this object's attributes`),returnType:c.z.enum([`text`,`number`,`boolean`,`date`,`select`,`multiselect`]).describe(`The formula's result type`),decimals:c.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),allowRelations:c.z.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:N.optional().describe(`Mirrors an option set`)}),me=x.extend({relationAttribute:c.z.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:c.z.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:c.z.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:c.z.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:c.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:c.z.string().optional().describe(`Server-set`),targetAttributeOptions:c.z.array(O).optional().describe(`Server-set`),targetCurrencyCode:c.z.string().length(3).optional().describe(`Server-set`),optionsSource:N.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}const $={text:P,richtext:oe,number:F,checkbox:I,date:L,phone:R,currency:z,status:B,location:V,select:H,multiselect:U,user:W,relation:fe,formula:pe,rollup:me,document:x.extend({properties:Z.optional(),accepts:c.z.array(c.z.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:c.z.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let t=$[e];if(!t)throw new o.ValidationError(`Unsupported attribute type: ${e}`,[]);return t}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(e){let t=getAttributeConfigSchema(e).extend({icon:b.optional()});switch(e){case`select`:return t.extend({options:A.describe(`Options`)});case`multiselect`:return t.extend({options:j.describe(`Options`)});case`status`:return t.extend({options:M.describe(`Statuses`)});default:return t}}function validationErrorFromIssues(e){return o.ValidationError.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(e){if(!Object.prototype.hasOwnProperty.call(e,`icon`))return;let t=b.optional().safeParse(e.icon);if(!t.success)throw o.ValidationError.fromZodErrors(t.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function isSelectLike(e){return e===`select`||e===`multiselect`||e===`status`}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let a=e.options;isSelectLike(e.type)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data;return isSelectLike(e.type)&&(s.options=a),s}Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return validateOptions}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return validateIconName}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return validateAttributeName}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return parseResourceVisibility}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return validateLabel}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return assertUniqueBy}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return getAttributeConfigWriteSchema}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return parseAttributeConfigForCreate}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return getAttributeConfigSchema}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return validateViewName}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return validateObjectName}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return parseAttributeConfigForUpdate}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return refuseForeignKeys}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return parseAttributeConfig}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return ComputedFormulaParseError}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return parseComputedFormula}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return isNativeObjectName}});
|
package/dist/object-B9V5JZzh.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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-DfXAzPpD.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
|
-
`)||`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
|
-
`)||`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};
|