@notionhq/custom-blocks-host 0.2.14 → 0.2.16

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/README.md CHANGED
@@ -150,7 +150,9 @@ iframe reload.
150
150
  - `onInitialized` reports success after the sandbox accepts initialization. It provides the selected
151
151
  `manifest` and the sandbox's optional `initialHeight`.
152
152
  - `onConnectionFailure` reports a handshake failure, timeout, unavailable page context, or iframe
153
- reload. It can run after initialization succeeds.
153
+ reload. It receives `{ phase, source, code, message, isRetryable }`. The phase identifies
154
+ `connect`, `init`, `initResult`, or `runtime`; the source identifies whether the host detected the
155
+ failure or the sandbox reported it. It can run after initialization succeeds.
154
156
 
155
157
  - `onQueryUnsubscribed` reports when a query subscription ends. Use it to release per-query
156
158
  resources, such as listeners or timers. The host removes the subscription itself. A query failure
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- function jr(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=Br({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function Br(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=Ze(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||Ze(y.name)===c));return l.length===1?l[0][0]:void 0}function Ze(e){return e.trim().toLowerCase()}var Be,Mr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Te(e){return!e&&!Be?Mr:{lang:e?.lang??Be?.lang,message:e?.message,abortEarly:e?.abortEarly??Be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Be?.abortPipeEarly}}var Rr;function Dr(e){return Rr?.get(e)}var wr;function Ar(e){return wr?.get(e)}var Tr;function qr(e,o){return Tr?.get(e)?.get(o)}function ge(e){let o=typeof e;return o==="string"?`"${e}"`:o==="number"||o==="bigint"||o==="boolean"?`${e}`:o==="object"||o==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":o}function M(e,o,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${o}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},S=e.kind==="schema",I=c?.message??e.message??qr(e.reference,m.lang)??(S?Ar(m.lang):null)??s.message??Dr(m.lang);I!==void 0&&(m.message=typeof I=="function"?I(m):I),S&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var Ye=new WeakMap;function F(e){let o=Ye.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Te())}},Ye.set(e,o)),o}function Nr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function qe(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var Fr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(o){return o}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(o,n){return o.typed&&!this.requirement(o.value)&&M(this,"finite",o,n),o}}}function Me(e,o){return{kind:"validation",type:"max_length",reference:Me,async:!1,expects:`<=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,o){return{kind:"validation",type:"min_length",reference:ke,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,o){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&M(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}var Ur={abortEarly:!0};function tt(e,o,n){return typeof e.fallback=="function"?e.fallback(o,n):e.fallback}function Re(e,o,n){return typeof e.default=="function"?e.default(o,n):e.default}function O(e,o){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else M(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:M(this,"type",o,n),o}}}function i(e,o){return{kind:"schema",type:"literal",reference:i,expects:ge(e),async:!1,literal:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:M(this,"type",n,s),n}}}function Ne(e){return{kind:"schema",type:"nan",reference:Ne,expects:"NaN",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:M(this,"type",o,n),o}}}function K(e,o){return{kind:"schema",type:"nullable",reference:K,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=Re(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function E(e){return{kind:"schema",type:"number",reference:E,expects:"number",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:M(this,"type",o,n),o}}}function r(e,o){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:Re(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",n,s);return n}}}function a(e,o){return{kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=Re(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function D(e,o){return{kind:"schema",type:"picklist",reference:D,expects:qe(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:M(this,"type",n,s),n}}}function U(e,o,n){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Nr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let I={type:"object",origin:"key",input:l,key:f,value:y};for(let j of m.issues)j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let S=this.value["~run"]({value:y},c);if(S.issues){let I={type:"object",origin:"value",input:l,key:f,value:y};for(let j of S.issues)j.path?j.path.unshift(I):j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=S.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!S.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=S.value)}}else M(this,"type",s,c);return s}}}function p(e,o){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:Re(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){M(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:M(this,"type",o,n),o}}}function et(e){let o;if(e)for(let n of e)if(o)for(let s of n.issues)o.push(s);else o=n.issues;return o}function x(e,o){return{kind:"schema",type:"union",reference:x,expects:qe(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",n,s,{issues:et(l)}),n.typed=!0}else{if(f?.length===1)return f[0];M(this,"type",n,s,{issues:et(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return F(this)},"~run"(e){return e.typed=!0,e}}}function h(e,o,n){return{kind:"schema",type:"variant",reference:h,expects:"Object",async:!1,key:e,options:o,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(j,k)=>{for(let G of j.options){if(G.type==="variant")I(G,new Set(k).add(G.key));else{let W=!0,T=0;for(let B of k){let q=G.entries[B];if(B in l?q["~run"]({typed:!1,value:l[B]},Ur).issues:q.type!=="exact_optional"&&q.type!=="optional"&&q.type!=="nullish"){W=!1,m!==B&&(y<T||y===T&&B in l&&!(m in l))&&(y=T,m=B,S=[]),m===B&&S.push(G.entries[B].expects);break}T++}if(W){let B=G["~run"]({value:l},c);(!f||!f.typed&&B.typed)&&(f=B)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;M(this,"type",s,c,{input:l[m],expected:qe(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else M(this,"type",s,c);return s}}}function rt(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return F(this)}}}function fe(e,o,n){let s=e["~run"]({value:o},Te(n));if(s.issues)throw new Fr(s.issues);return s.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return F(this)},"~run"(o,n){for(let s of e)if(s.kind!=="metadata"){if(o.issues&&(s.kind==="schema"||s.kind==="transformation")){o.typed=!1;break}(!o.issues||!n.abortEarly&&!n.abortPipeEarly)&&(o=s["~run"](o,n))}return o}}}function xe(e,o,n){let s=e["~run"]({value:o},Te(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var re=z(t(),te("NotionBlockId")),Z=z(t(),te("NotionDataSourceId")),H=z(t(),te("NotionPageId")),nt=z(t(),te("NotionAgentId")),ot=z(t(),te("NotionSpaceId"));var it=D(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),Fe=r({id:t(),name:t(),color:a(it),description:a(t())}),zr=r({id:t(),name:t(),color:a(it),option_ids:O(t())}),Hr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:a(t())}),Gr=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],st=D(Gr),ut=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Ue=h("type",[r({...P.entries,type:i("title")}),r({...P.entries,type:i("rich_text")}),r({...P.entries,type:i("number")}),r({...P.entries,type:i("checkbox")}),r({...P.entries,type:i("url")}),r({...P.entries,type:i("email")}),r({...P.entries,type:i("phone_number")}),r({...P.entries,type:i("select"),options:O(Fe)}),r({...P.entries,type:i("multi_select"),options:O(Fe)}),r({...P.entries,type:i("status"),options:O(Fe),groups:O(zr)}),r({...P.entries,type:i("date")}),r({...P.entries,type:i("people")}),r({...P.entries,type:i("files")}),r({...P.entries,type:i("unique_id")}),r({...P.entries,type:i("relation"),data_source_id:a(t()),dual_property:a(Hr)}),r({...P.entries,type:i("place")}),r({...P.entries,type:i("formula")}),r({...P.entries,type:i("rollup")}),r({...P.entries,type:i("button")}),r({...P.entries,type:i("verification")}),r({...P.entries,type:i("last_visited_time")}),r({...P.entries,type:i("location")}),r({...P.entries,type:i("created_time")}),r({...P.entries,type:i("last_edited_time")}),r({...P.entries,type:i("created_by")}),r({...P.entries,type:i("last_edited_by")})]);var at={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var ct=r({id:Z,table:t(),spaceId:a(ot)}),lt=r({id:a(Z),propertiesById:U(t(),Ue)}),so=r({key:t(),collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:U(t(),a(t())),propertySchemasById:U(t(),Ue)}),Lr=r({collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:a(U(t(),a(t())))}),le=U(t(),Lr);var Vr=h("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),Qr=r({name:t(),description:a(t()),type:st}),$r=r({name:t(),description:a(t()),icon:a(Vr),properties:a(U(t(),Qr),{})}),pe=r({version:i(1),dataSources:U(t(),$r)});var me=D(["standard","high"]),pt="standard";var ft=r({type:i("contrastModeChanged"),contrastMode:me});var ne=h("type",[r({type:i("page_id"),page_id:H}),r({type:i("data_source_id"),data_source_id:Z}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:re}),r({type:i("agent_id"),agent_id:nt}),r({type:i("unavailable")})]);var ye=h("type",[r({type:i("unavailable")}),r({type:i("page"),id:H,parent:ne})]),Xr=r({type:i("emoji"),emoji:t()}),Wr=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:a(t()),url:a(t())})}),yt=r({type:i("external"),external:r({url:t()})}),vt=r({type:i("file"),file:r({url:t(),expiry_time:a(t())})}),He=h("type",[Xr,Wr,yt,vt]),Ge=h("type",[yt,vt]),X=K(t()),mt=U(t(),Ie()),ze=x([r({id:t(),name:a(t()),color:a(t()),description:a(X)}),r({name:t(),id:a(t()),color:a(t()),description:a(X)})]),Jr=r({start:t(),end:a(X),time_zone:a(X)}),Kr=x([r({object:a(i("user")),id:t()}),r({object:i("group"),id:t(),name:a(X)})]),Zr=r({id:t()}),Yr=x([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:a(t())})})]),en=r({lat:E(),lon:E(),name:a(X),address:a(X),aws_place_id:a(X),google_place_id:a(X)}),L={id:t()},tn=h("type",[r({...L,type:i("title"),title:O(mt)}),r({...L,type:i("rich_text"),rich_text:O(mt)}),r({...L,type:i("number"),number:K(E())}),r({...L,type:i("url"),url:X}),r({...L,type:i("email"),email:X}),r({...L,type:i("phone_number"),phone_number:X}),r({...L,type:i("checkbox"),checkbox:b()}),r({...L,type:i("select"),select:K(ze)}),r({...L,type:i("status"),status:K(ze)}),r({...L,type:i("multi_select"),multi_select:O(ze)}),r({...L,type:i("date"),date:K(Jr)}),r({...L,type:i("people"),people:O(Kr)}),r({...L,type:i("relation"),has_more:a(b()),relation:O(Zr)}),r({...L,type:i("files"),files:O(Yr)}),r({...L,type:i("place"),place:K(en)})]),_e=U(t(),tn),ve=r({object:i("page"),id:H,parent:ne,properties:_e,created_time:a(t()),last_edited_time:a(t()),icon:a(He),cover:a(Ge),url:a(t()),public_url:a(t()),is_archived:b(),in_trash:b()});var rn=t(),nn=r({code:rn,message:t(),isRetryable:b()}),dt=h("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:nn})]);var Le=z(t(),te("NotionUserId")),oe=r({object:i("user"),id:Le,name:a(t()),avatar_url:K(t()),type:i("person"),person:r({email:t()})}),ht=r({object:i("list"),results:O(oe),next_cursor:K(t()),has_more:b(),type:i("user"),user:U(t(),Ie())});var gt=r({type:i("currentUserChanged"),currentUser:oe});var bt=r({type:i("dataSourcesChanged"),dataSources:r({bindings:le})});var on=t(),sn=r({code:on,message:t(),isRetryable:b()}),kt=r({type:i("getPage"),requestId:t(),pageId:H}),St=h("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:sn})]);var un=t(),an=r({code:un,message:t(),isRetryable:b()}),It=r({type:i("getUser"),requestId:t(),userId:Le}),xt=h("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:oe}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:an})]);var de=D(["light","dark"]);var cn=t(),ln=r({code:cn,message:t(),isRetryable:b()});var De=h("status",[r({type:i("init"),initializationId:t(),status:i("success"),theme:de,contrastMode:me,blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe}),r({type:i("init"),initializationId:t(),status:i("error"),error:ln})]);var _t=r({type:i("invalidSandboxMessage"),reason:t()});var pn=t(),fn=r({code:pn,message:t(),isRetryable:b()}),Ct=r({type:i("listUsers"),requestId:t(),startCursor:a(t()),pageSize:a(E())}),Et=h("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:ht}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:fn})]);var mn=D(["side_peek","center_peek"]),yn=t(),vn=r({code:yn,message:t(),isRetryable:b()}),Ot=r({type:i("openPage"),requestId:t(),pageId:H,mode:mn}),Pt=h("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:H}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:vn})]);var jt=r({type:i("pageChanged"),page:ye});var Bt=r({type:i("parentChanged"),parent:ne});var Mt=r({unit:D(["year","month","week","day"]),value:E(),time:t(),defaultTimeZone:a(t())}),dn=r({unit:D(["hour","minute"]),value:E()}),Rt=r({unit:i("none")}),hn=x([Mt,dn]),Dt=a(x([Mt,Rt])),wt=a(x([hn,Rt])),gn=r({type:i("date"),start_date:t(),reminder:Dt}),bn=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:Dt}),kn=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:a(t()),reminder:wt}),Sn=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:a(t()),reminder:wt}),At=h("type",[gn,bn,kn,Sn]);var Tt=r({id:t(),table:t()});var qt=x([t(),E(),b(),At,O(t()),O(Tt)]);var Nt=r({id:H,is_archived:b(),in_trash:b(),propertiesById:U(t(),a(qt))});var In=t(),xn=r({code:In,message:t(),isRetryable:b()}),Ft=h("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:O(Nt),hasMore:b()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:xn})]);var Ut=r({type:i("themeChanged"),theme:de});var _n=t(),Cn=r({code:_n,message:t(),isRetryable:b()}),zt=h("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:Cn})]);var Ht=h("type",[De,Ut,ft,Bt,jt,gt,bt,Ft,dt,St,xt,Et,Pt,zt,_t]);function Gt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Lt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Ve(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version ${o?`: ${o}`:"."}`,isRetryable:!1}}function Qe(e){let{currentBridgeProtocolVersion:o,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${o} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function $e(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Vt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Qt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function $t(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function Xt(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Wt(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function Jt(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Kt(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function ie(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function Xe(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var En=5e3,On=5e3,Pn=5e3;function Zt(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=En,initialStateTimeoutMs:y=On,noInitResultTimeoutMs:m=Pn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:j}=e,k="waitingForConnect",G,W,T,B,q=!1,se=!1;function $(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function R(){W!==void 0&&(window.clearTimeout(W),W=void 0)}function N(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function A(g){let{initializationId:v,error:V}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ie(k)}k="error",B=v,$(),R(),n({type:"init",initializationId:v,status:"error",error:V}),j?.(V)}async function J(g){if(k==="waitingForConnect"){k="preparingInit",B=g.initializationId,$(),W=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Vt();s({...v,initializationId:g.initializationId}),A({initializationId:g.initializationId,error:v})},y);try{let v=await o(g);if(k!=="preparingInit")return;if(R(),v.status==="error"){A({initializationId:g.initializationId,error:v.error});return}k="waitingForInitResult";let V={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??pt,blockId:v.initialState.blockId,parent:v.initialState.parent,page:v.initialState.page,currentUser:v.initialState.currentUser,manifest:v.initialState.manifest,dataSources:v.initialState.dataSources};n(V),T=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let ee=Wt();j?.(ee),s({...ee,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),A({initializationId:g.initializationId,error:Kt()})}}}function Y(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!Xe(g.bridgeProtocolVersion)){let v=Ve({currentBridgeProtocolVersion:g.bridgeProtocolVersion});A({initializationId:g.initializationId,error:v});return}if(g.bridgeProtocolVersion<l){let v=Qe({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});A({initializationId:g.initializationId,error:v});return}if(g.status==="error"){A({initializationId:g.initializationId,error:g.error});return}se=!0,J(g)}}function _(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=g;if(v===void 0)return"nack";let ee=g.error;return V!==void 0&&(Xe(V)?V<l&&(ee=Qe({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):ee=Ve({currentBridgeProtocolVersion:void 0})),A({initializationId:v,error:ee}),"handled"}function ue(g){let{initializationId:v,error:V}=g;k!=="waitingForInitResult"||v===void 0||v!==B||($(),N(),k="error",s(V),j?.(V))}function je(){if(k!=="stopped"){if(q){S({code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}q=!0,$(),k==="waitingForConnect"&&(G=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Gt();s(g),j?.(g)},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==B){s({message:"Ignored stale or unexpected initResult",payload:g});return}N(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():j?.(g.error),I?.(g)}function ae(){k="stopped",$(),R(),N()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:Y,handleInitResult:he,handleInvalidConnect:_,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function Yt(e,o){return o>=5||!(e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged")?e:{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([s,c])=>[s,{...c,collectionSchema:{...c.collectionSchema,propertiesById:{...c.collectionSchema?.propertiesById,...at}}}]))}}}var er=r({theme:de,contrastMode:a(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function tr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var rr=r({code:t(),message:t(),isRetryable:b()});var nr={type:i("connect"),initializationId:t(),bridgeProtocolVersion:E(),sdkVersion:t()},or=h("status",[r({status:i("success"),manifest:a(pe),...nr}),r({status:i("error"),error:rr,...nr})]);var jn=h("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:re}),r({type:i("after"),blockId:re})]),Bn=h("type",[r({type:i("page_id"),page_id:H}),r({type:i("data_source_id"),data_source_id:Z})]),ir=r({type:i("createPage"),requestId:t(),parent:Bn,properties:_e,position:a(jn)});var Mn=t(),Rn=r({code:Mn,message:t(),isRetryable:b()}),sr=h("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:a(z(E(),be(),Se(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Rn})]);var ur=r({type:i("invalidHostMessage"),reason:t()});var ar=D(["ascending","descending"]);var Pe=x([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Oe=x([t(),O(t())]),cr=p({object:D(["user","group"]),id:z(t(),ke(1))}),Dn=x([p({contains:cr}),p({does_not_contain:cr}),Pe]),lr=p({object:i("user"),id:z(t(),ke(1),Me(2e3))}),wn=x([p({contains:lr}),p({does_not_contain:lr}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ce=x([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Pe]),An=x([p({equals:E()}),p({does_not_equal:E()}),p({greater_than:E()}),p({less_than:E()}),p({greater_than_or_equal_to:E()}),p({less_than_or_equal_to:E()}),Pe]),Tn=x([p({equals:b()}),p({does_not_equal:b()})]),yr=x([p({equals:Oe}),p({does_not_equal:Oe}),Pe]),pr=D(["To-do","In progress","Complete","Current","Future"]),fr=x([pr,z(O(pr),ke(1),Me(5))]),qn=x([p({group_equals:fr}),p({group_does_not_equal:fr})]),Nn=x([yr,qn]),Fn=x([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Pe]),Q=D(["start_date","end_date"]),Un=D(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Ee=x([Un,t()]),zn=x([p({target:a(Q),equals:Ee}),p({target:a(Q),before:Ee}),p({target:a(Q),after:Ee}),p({target:a(Q),on_or_before:Ee}),p({target:a(Q),on_or_after:Ee}),p({target:a(Q),this_week:p({})}),p({target:a(Q),past_week:p({})}),p({target:a(Q),past_month:p({})}),p({target:a(Q),past_year:p({})}),p({target:a(Q),next_week:p({})}),p({target:a(Q),next_month:p({})}),p({target:a(Q),next_year:p({})}),p({target:a(Q),is_empty:i(!0)}),p({target:a(Q),is_not_empty:i(!0)})]),mr=x([p({propertyId:t(),created_by:wn}),p({propertyId:t(),title:Ce}),p({propertyId:t(),rich_text:Ce}),p({propertyId:t(),url:Ce}),p({propertyId:t(),email:Ce}),p({propertyId:t(),phone_number:Ce}),p({propertyId:t(),number:An}),p({propertyId:t(),checkbox:Tn}),p({propertyId:t(),select:yr}),p({propertyId:t(),multi_select:Fn}),p({propertyId:t(),status:Nn}),p({propertyId:t(),date:zn}),p({propertyId:t(),people:Dn})]),Hn=x([mr,p({and:O(mr)})]),We=10,Gn=p({propertyId:t(),direction:ar}),vr=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Z,limit:E(),filter:a(Hn),sorts:a(O(Gn))});var dr=r({type:i("resize"),height:z(E(),be(),Se(0))});var hr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var gr=r({type:i("updatePage"),requestId:t(),pageId:H,properties:a(_e),icon:a(He),cover:a(Ge),archived:a(b())});var br=h("type",[or,sr,vr,hr,ir,kt,It,Ct,Ot,gr,dr,ur]);function kr(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Sr(e){let o=kr(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Ln(o)}}}function Ln(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Ir=r({initializationId:t()}),Vn=r({bridgeProtocolVersion:x([E(),Ne()])});function xr(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:j,onCreatePage:k,onGetPage:G,onOpenPage:W,onGetUser:T,onListUsers:B,onUpdatePage:q,onResize:se}=e;function $(R,N){c("warn",{message:"Ignored unsupported sandbox message",payload:R,issues:N});let A=Sr(R);if(A.incomingType==="connect"){let J=xe(Ir,R),Y=xe(Vn,R);if(f({initializationId:J.success?J.output.initializationId:void 0,error:Lt(),bridgeProtocolVersion:Y.success?Y.output.bridgeProtocolVersion:void 0})==="handled")return}if(A.incomingType==="initResult"){let J=xe(Ir,R);y({initializationId:J.success?J.output.initializationId:void 0,error:Jt()})}A.nack!==void 0&&s()!=="stopped"&&l(A.nack)}return function(N){let A=N.source===o.contentWindow,J=N.origin===n;if(!A||!J)return;let Y=xe(br,N.data);if(!Y.success){$(N.data,Y.issues);return}let _=Y.output;if(!tr(_)&&s()!=="initialized"){c("warn",{message:`Ignored ${_.type} before initialization completed`,payload:_});return}switch(c("in",_),_.type){case"connect":m(_);return;case"initResult":S(_);return;case"queryDataSource":I(_);return;case"unsubscribeDataSourceQuery":j(_);return;case"createPage":k(_);return;case"openPage":W(_);return;case"getPage":G(_);return;case"getUser":T(_);return;case"listUsers":B(_);return;case"updatePage":q(_);return;case"resize":se(_);return;case"invalidHostMessage":return;default:ie(_)}}}var we=class{constructor(o){this.onUnsubscribe=o}onUnsubscribe;bySubscriptionId=new Map;subscribe(o){this.unsubscribe(o.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(o.subscriptionId,{message:o,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(o,n){return this.bySubscriptionId.get(o)?.token===n}unsubscribe(o){this.bySubscriptionId.delete(o)&&this.onUnsubscribe(o)}refresh(o){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===o){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(o,n){let s=this.bySubscriptionId.get(o);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let o of this.bySubscriptionId.keys())this.unsubscribe(o)}};function _r(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Qn(s,o);if(c!==void 0)return c}}function Qn(e,o){if(!Object.hasOwn(o.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let n=o.propertiesById[e.propertyId],s=Object.keys(e).find(y=>y!=="propertyId");if(s!==n.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${n.type}".`,isRetryable:!1};if("status"in e&&n.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,I=(Array.isArray(m)?m:[m]).find(j=>!n.groups.some(k=>k.name===j));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}let c=$n(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=Xn(c.operator).find(y=>!l.has(y));if(f!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${f}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function $n(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let o=e.status;return"group_equals"in o||"group_does_not_equal"in o?void 0:{propertyType:"status",operator:o}}}function Xn(e){let o;if("equals"in e)o=e.equals;else if("does_not_equal"in e)o=e.does_not_equal;else if("contains"in e)o=e.contains;else if("contains_all"in e)o=e.contains_all;else if("does_not_contain"in e)o=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ie(e);return Array.isArray(o)?o:[o]}var Wn=new Set(ut);function Cr(e,o){if(e===void 0)return;if(e.length>We)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${We} entries.`,isRetryable:!1};let n=new Set;for(let s of e){if(n.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(n.add(s.propertyId),!Object.hasOwn(o.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=o.propertiesById[s.propertyId];if(!Wn.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}var Or=5;function Kn(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G}=e,W=Math.max(I??3,3),T={},B=!1,q,se,$=5,R=new we(u=>{m?.(u)});function N(u,C){y?.(u,C)}function A(u){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ie(C)}let w=Yt(u,$);N("out",w),o.contentWindow?.postMessage(w,S)}function J(u){A(fe(De,u))}function Y(u){A(u)}function _(u){let C=v.status;switch(C){case"initialized":A(fe(Ht,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(u,C){if(C===void 0)return;let w=await C(u);_({type:`${u.type}Result`,requestId:u.requestId,...w})}function je(u){let C=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};_(C)}async function he(u,C=R.subscribe(u)){try{let w=Zn(se,u.dataSourceId),ce=Yn(u,w);if(ce!==void 0){R.isCurrent(u.subscriptionId,C)&&(R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:{status:"error",error:ce}}));return}let Ae=await s.queryDataSource(u);if(!R.isCurrent(u.subscriptionId,C))return;Ae.status==="error"&&!Ae.error.isRetryable&&R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:Ae})}finally{let w=R.finish(u.subscriptionId,C);w!==void 0&&he(w.message,w.token)}}function ae(u){v.status==="stopped"||v.status==="error"||(Object.assign(T,u),g())}function g(){if(v.status!=="initialized")return;let u=T;T={},u.theme!==void 0&&_({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&_({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&_({type:"parentChanged",parent:u.parent}),u.page!==void 0&&_({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&_({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&_({type:"currentUserChanged",currentUser:u.currentUser})}let v=Zt({async prepareInit(u){$=u.bridgeProtocolVersion;let C=await n(u);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:J,warn:u=>N("warn",u),flushPendingHostStateChanges:g,minBridgeProtocolVersion:W,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G,stopHostWithFailure:Ke,onInitResult(u){u.status==="success"&&q!==void 0&&l?.({manifest:q,initialHeight:u.initialHeight})},onConnectionFailure:f});function V(u){if(u.status==="error")return u;q=fe(pe,u.initialState.manifest),c?.(q);let C={...u.initialState,...T};T={};let w={...fe(rt(er,["manifest"]),C),manifest:q};if($<Or&&w.page.type==="unavailable")return{status:"error",error:$e()};let ce=Pr(w.manifest,w.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=w.dataSources,B=!0,{status:"success",initialState:w})}let ee=xr({iframe:o,sandboxOrigin:S,getInitStatus:()=>v.status,emit:N,sendNack:Y,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:u=>R.unsubscribe(u.subscriptionId),onCreatePage:u=>ue(u,s.createPage),onGetPage:u=>ue(u,s.getPage),onOpenPage:u=>ue(u,s.openPage),onGetUser:u=>ue(u,s.getUser),onListUsers:u=>ue(u,s.listUsers),onUpdatePage:u=>ue(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",ee),o.addEventListener("load",v.onIframeLoad);function Je(){window.removeEventListener("message",ee),o.removeEventListener("load",v.onIframeLoad),v.stop(),R.unsubscribeAll()}function Ke(u){Je(),N("warn",u),f?.(u)}return{stop:Je,setTheme(u){ae({theme:u})},setContrastMode(u){ae({contrastMode:u})},setParent(u){ae({parent:u})},setPage(u){if(u.type==="unavailable"&&$<Or&&(v.status==="preparingInit"&&B||v.status==="waitingForInitResult"||v.status==="initialized")){Ke($e());return}ae({page:u})},setCurrentUser(u){ae({currentUser:u})},setDataSources(u){let C={bindings:fe(le,u.bindings)};if(v.hasConnectedSandbox&&q!==void 0&&Pr(q,C)!==void 0){N("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:u}){if(v.status!=="initialized")return;let C=fe(Z,u),w=R.refresh(C);if(w===void 0){N("warn",`No active query exists for data source "${u}"`);return}for(let ce of w)he(ce.message,ce.token)}}}function Zn(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function Pr(e,o){for(let[n,s]of Object.entries(e.dataSources)){let c=o.bindings[n];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Qt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return $t();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return Xt()}}}function Yn(e,o){return o===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:_r(e.filter,o)??Cr(e.sorts,o)}export{Kn as createCustomBlockHost,jr as getAutoBoundPropertyIdsByKey};
1
+ function jr(e){let{manifestProperties:i,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(i)){let f=Br({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function Br(e){let{propertyKey:i,manifestProperty:n,propertySchemasById:s}=e,c=Ze(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===i||Ze(y.name)===c));return l.length===1?l[0][0]:void 0}function Ze(e){return e.trim().toLowerCase()}var Me,Mr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function qe(e){return!e&&!Me?Mr:{lang:e?.lang??Me?.lang,message:e?.message,abortEarly:e?.abortEarly??Me?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Me?.abortPipeEarly}}var Rr;function Dr(e){return Rr?.get(e)}var wr;function Ar(e){return wr?.get(e)}var Tr;function qr(e,i){return Tr?.get(e)?.get(i)}function ge(e){let i=typeof e;return i==="string"?`"${e}"`:i==="number"||i==="bigint"||i==="boolean"?`${e}`:i==="object"||i==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":i}function M(e,i,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${i}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},S=e.kind==="schema",I=c?.message??e.message??qr(e.reference,m.lang)??(S?Ar(m.lang):null)??s.message??Dr(m.lang);I!==void 0&&(m.message=typeof I=="function"?I(m):I),S&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var Ye=new WeakMap;function F(e){let i=Ye.get(e);return i||(i={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},qe())}},Ye.set(e,i)),i}function Nr(e,i){return Object.prototype.hasOwnProperty.call(e,i)&&i!=="__proto__"&&i!=="prototype"&&i!=="constructor"}function Ne(e,i){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${i} `)})`:n[0]??"never"}var Fr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(i){return i}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(i,n){return i.typed&&!this.requirement(i.value)&&M(this,"finite",i,n),i}}}function Re(e,i){return{kind:"validation",type:"max_length",reference:Re,async:!1,expects:`<=${e}`,requirement:e,message:i,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,i){return{kind:"validation",type:"min_length",reference:ke,async:!1,expects:`>=${e}`,requirement:e,message:i,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,i){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:i,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&M(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}var Ur={abortEarly:!0};function tt(e,i,n){return typeof e.fallback=="function"?e.fallback(i,n):e.fallback}function De(e,i,n){return typeof e.default=="function"?e.default(i,n):e.default}function O(e,i){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else M(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return typeof i.value=="boolean"?i.typed=!0:M(this,"type",i,n),i}}}function o(e,i){return{kind:"schema",type:"literal",reference:o,expects:ge(e),async:!1,literal:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:M(this,"type",n,s),n}}}function Fe(e){return{kind:"schema",type:"nan",reference:Fe,expects:"NaN",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return Number.isNaN(i.value)?i.typed=!0:M(this,"type",i,n),i}}}function Z(e,i){return{kind:"schema",type:"nullable",reference:Z,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:i,get"~standard"(){return F(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function E(e){return{kind:"schema",type:"number",reference:E,expects:"number",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return typeof i.value=="number"&&!isNaN(i.value)?i.typed=!0:M(this,"type",i,n),i}}}function r(e,i){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",n,s);return n}}}function a(e,i){return{kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:i,get"~standard"(){return F(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function D(e,i){return{kind:"schema",type:"picklist",reference:D,expects:Ne(e.map(ge),"|"),async:!1,options:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:M(this,"type",n,s),n}}}function U(e,i,n){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:i,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Nr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let I={type:"object",origin:"key",input:l,key:f,value:y};for(let j of m.issues)j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let S=this.value["~run"]({value:y},c);if(S.issues){let I={type:"object",origin:"value",input:l,key:f,value:y};for(let j of S.issues)j.path?j.path.unshift(I):j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=S.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!S.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=S.value)}}else M(this,"type",s,c);return s}}}function p(e,i){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){M(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return typeof i.value=="string"?i.typed=!0:M(this,"type",i,n),i}}}function et(e){let i;if(e)for(let n of e)if(i)for(let s of n.issues)i.push(s);else i=n.issues;return i}function x(e,i){return{kind:"schema",type:"union",reference:x,expects:Ne(e.map(n=>n.expects),"|"),async:!1,options:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",n,s,{issues:et(l)}),n.typed=!0}else{if(f?.length===1)return f[0];M(this,"type",n,s,{issues:et(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return F(this)},"~run"(e){return e.typed=!0,e}}}function h(e,i,n){return{kind:"schema",type:"variant",reference:h,expects:"Object",async:!1,key:e,options:i,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(j,k)=>{for(let G of j.options){if(G.type==="variant")I(G,new Set(k).add(G.key));else{let W=!0,T=0;for(let B of k){let q=G.entries[B];if(B in l?q["~run"]({typed:!1,value:l[B]},Ur).issues:q.type!=="exact_optional"&&q.type!=="optional"&&q.type!=="nullish"){W=!1,m!==B&&(y<T||y===T&&B in l&&!(m in l))&&(y=T,m=B,S=[]),m===B&&S.push(G.entries[B].expects);break}T++}if(W){let B=G["~run"]({value:l},c);(!f||!f.typed&&B.typed)&&(f=B)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;M(this,"type",s,c,{input:l[m],expected:Ne(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else M(this,"type",s,c);return s}}}function rt(e,i){let n={...e.entries};for(let s of i)delete n[s];return{...e,entries:n,get"~standard"(){return F(this)}}}function fe(e,i,n){let s=e["~run"]({value:i},qe(n));if(s.issues)throw new Fr(s.issues);return s.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return F(this)},"~run"(i,n){for(let s of e)if(s.kind!=="metadata"){if(i.issues&&(s.kind==="schema"||s.kind==="transformation")){i.typed=!1;break}(!i.issues||!n.abortEarly&&!n.abortPipeEarly)&&(i=s["~run"](i,n))}return i}}}function xe(e,i,n){let s=e["~run"]({value:i},qe(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var re=z(t(),te("NotionBlockId")),Y=z(t(),te("NotionDataSourceId")),H=z(t(),te("NotionPageId")),nt=z(t(),te("NotionAgentId")),ot=z(t(),te("NotionSpaceId"));var it=D(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),Ue=r({id:t(),name:t(),color:a(it),description:a(t())}),zr=r({id:t(),name:t(),color:a(it),option_ids:O(t())}),Hr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:a(t())}),Gr=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],st=D(Gr),ut=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],ze=h("type",[r({...P.entries,type:o("title")}),r({...P.entries,type:o("rich_text")}),r({...P.entries,type:o("number")}),r({...P.entries,type:o("checkbox")}),r({...P.entries,type:o("url")}),r({...P.entries,type:o("email")}),r({...P.entries,type:o("phone_number")}),r({...P.entries,type:o("select"),options:O(Ue)}),r({...P.entries,type:o("multi_select"),options:O(Ue)}),r({...P.entries,type:o("status"),options:O(Ue),groups:O(zr)}),r({...P.entries,type:o("date")}),r({...P.entries,type:o("people")}),r({...P.entries,type:o("files")}),r({...P.entries,type:o("unique_id")}),r({...P.entries,type:o("relation"),data_source_id:a(t()),dual_property:a(Hr)}),r({...P.entries,type:o("place")}),r({...P.entries,type:o("formula")}),r({...P.entries,type:o("rollup")}),r({...P.entries,type:o("button")}),r({...P.entries,type:o("verification")}),r({...P.entries,type:o("last_visited_time")}),r({...P.entries,type:o("location")}),r({...P.entries,type:o("created_time")}),r({...P.entries,type:o("last_edited_time")}),r({...P.entries,type:o("created_by")}),r({...P.entries,type:o("last_edited_by")})]);var at={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var ct=r({id:Y,table:t(),spaceId:a(ot)}),lt=r({id:a(Y),propertiesById:U(t(),ze)}),so=r({key:t(),collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:U(t(),a(t())),propertySchemasById:U(t(),ze)}),Lr=r({collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:a(U(t(),a(t())))}),le=U(t(),Lr);var Vr=h("type",[r({type:o("emoji"),emoji:t()}),r({type:o("external"),url:t()})]),Qr=r({name:t(),description:a(t()),type:st}),$r=r({name:t(),description:a(t()),icon:a(Vr),properties:a(U(t(),Qr),{})}),pe=r({version:o(1),name:a(t()),description:a(t()),slashCommand:a(t()),icon:a(r({type:o("emoji"),emoji:t()})),dataSources:a(U(t(),$r),{})});var me=D(["standard","high"]),pt="standard";var ft=r({type:o("contrastModeChanged"),contrastMode:me});var ne=h("type",[r({type:o("page_id"),page_id:H}),r({type:o("data_source_id"),data_source_id:Y}),r({type:o("workspace"),workspace:o(!0)}),r({type:o("block_id"),block_id:re}),r({type:o("agent_id"),agent_id:nt}),r({type:o("unavailable")})]);var ye=h("type",[r({type:o("unavailable")}),r({type:o("page"),id:H,parent:ne})]),Xr=r({type:o("emoji"),emoji:t()}),Wr=r({type:o("custom_emoji"),custom_emoji:r({id:t(),name:a(t()),url:a(t())})}),yt=r({type:o("external"),external:r({url:t()})}),vt=r({type:o("file"),file:r({url:t(),expiry_time:a(t())})}),Ge=h("type",[Xr,Wr,yt,vt]),Le=h("type",[yt,vt]),X=Z(t()),mt=U(t(),Ie()),He=x([r({id:t(),name:a(t()),color:a(t()),description:a(X)}),r({name:t(),id:a(t()),color:a(t()),description:a(X)})]),Jr=r({start:t(),end:a(X),time_zone:a(X)}),Kr=x([r({object:a(o("user")),id:t()}),r({object:o("group"),id:t(),name:a(X)})]),Zr=r({id:t()}),Yr=x([r({type:o("external"),name:t(),external:r({url:t()})}),r({type:o("file"),name:t(),file:r({url:t(),expiry_time:a(t())})})]),en=r({lat:E(),lon:E(),name:a(X),address:a(X),aws_place_id:a(X),google_place_id:a(X)}),L={id:t()},tn=h("type",[r({...L,type:o("title"),title:O(mt)}),r({...L,type:o("rich_text"),rich_text:O(mt)}),r({...L,type:o("number"),number:Z(E())}),r({...L,type:o("url"),url:X}),r({...L,type:o("email"),email:X}),r({...L,type:o("phone_number"),phone_number:X}),r({...L,type:o("checkbox"),checkbox:b()}),r({...L,type:o("select"),select:Z(He)}),r({...L,type:o("status"),status:Z(He)}),r({...L,type:o("multi_select"),multi_select:O(He)}),r({...L,type:o("date"),date:Z(Jr)}),r({...L,type:o("people"),people:O(Kr)}),r({...L,type:o("relation"),has_more:a(b()),relation:O(Zr)}),r({...L,type:o("files"),files:O(Yr)}),r({...L,type:o("place"),place:Z(en)})]),_e=U(t(),tn),ve=r({object:o("page"),id:H,parent:ne,properties:_e,created_time:a(t()),last_edited_time:a(t()),icon:a(Ge),cover:a(Le),url:a(t()),public_url:a(t()),is_archived:b(),in_trash:b()});var rn=t(),nn=r({code:rn,message:t(),isRetryable:b()}),dt=h("status",[r({type:o("createPageResult"),requestId:t(),status:o("success"),page:ve}),r({type:o("createPageResult"),requestId:t(),status:o("error"),error:nn})]);var Ve=z(t(),te("NotionUserId")),oe=r({object:o("user"),id:Ve,name:a(t()),avatar_url:Z(t()),type:o("person"),person:r({email:t()})}),ht=r({object:o("list"),results:O(oe),next_cursor:Z(t()),has_more:b(),type:o("user"),user:U(t(),Ie())});var gt=r({type:o("currentUserChanged"),currentUser:oe});var bt=r({type:o("dataSourcesChanged"),dataSources:r({bindings:le})});var on=t(),sn=r({code:on,message:t(),isRetryable:b()}),kt=r({type:o("getPage"),requestId:t(),pageId:H}),St=h("status",[r({type:o("getPageResult"),requestId:t(),status:o("success"),page:ve}),r({type:o("getPageResult"),requestId:t(),status:o("error"),error:sn})]);var un=t(),an=r({code:un,message:t(),isRetryable:b()}),It=r({type:o("getUser"),requestId:t(),userId:Ve}),xt=h("status",[r({type:o("getUserResult"),requestId:t(),status:o("success"),user:oe}),r({type:o("getUserResult"),requestId:t(),status:o("error"),error:an})]);var de=D(["light","dark"]);var cn=t(),ln=r({code:cn,message:t(),isRetryable:b()});var we=h("status",[r({type:o("init"),initializationId:t(),status:o("success"),theme:de,contrastMode:me,blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe}),r({type:o("init"),initializationId:t(),status:o("error"),error:ln})]);var _t=r({type:o("invalidSandboxMessage"),reason:t()});var pn=t(),fn=r({code:pn,message:t(),isRetryable:b()}),Ct=r({type:o("listUsers"),requestId:t(),startCursor:a(t()),pageSize:a(E())}),Et=h("status",[r({type:o("listUsersResult"),requestId:t(),status:o("success"),list:ht}),r({type:o("listUsersResult"),requestId:t(),status:o("error"),error:fn})]);var mn=D(["side_peek","center_peek"]),yn=t(),vn=r({code:yn,message:t(),isRetryable:b()}),Ot=r({type:o("openPage"),requestId:t(),pageId:H,mode:mn}),Pt=h("status",[r({type:o("openPageResult"),requestId:t(),status:o("success"),pageId:H}),r({type:o("openPageResult"),requestId:t(),status:o("error"),error:vn})]);var jt=r({type:o("pageChanged"),page:ye});var Bt=r({type:o("parentChanged"),parent:ne});var Mt=r({unit:D(["year","month","week","day"]),value:E(),time:t(),defaultTimeZone:a(t())}),dn=r({unit:D(["hour","minute"]),value:E()}),Rt=r({unit:o("none")}),hn=x([Mt,dn]),Dt=a(x([Mt,Rt])),wt=a(x([hn,Rt])),gn=r({type:o("date"),start_date:t(),reminder:Dt}),bn=r({type:o("daterange"),start_date:t(),end_date:t(),reminder:Dt}),kn=r({type:o("datetime"),start_date:t(),start_time:t(),time_zone:a(t()),reminder:wt}),Sn=r({type:o("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:a(t()),reminder:wt}),At=h("type",[gn,bn,kn,Sn]);var Tt=r({id:t(),table:t()});var qt=x([t(),E(),b(),At,O(t()),O(Tt)]);var Nt=r({id:H,is_archived:b(),in_trash:b(),propertiesById:U(t(),a(qt))});var In=t(),xn=r({code:In,message:t(),isRetryable:b()}),Ft=h("status",[r({type:o("queryDataSourceResult"),subscriptionId:t(),status:o("success"),items:O(Nt),hasMore:b()}),r({type:o("queryDataSourceResult"),subscriptionId:t(),status:o("error"),error:xn})]);var Ut=r({type:o("themeChanged"),theme:de});var _n=t(),Cn=r({code:_n,message:t(),isRetryable:b()}),zt=h("status",[r({type:o("updatePageResult"),requestId:t(),status:o("success"),page:ve}),r({type:o("updatePageResult"),requestId:t(),status:o("error"),error:Cn})]);var Ht=h("type",[we,Ut,ft,Bt,jt,gt,bt,Ft,dt,St,xt,Et,Pt,zt,_t]);function Gt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Lt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Qe(e){let{currentBridgeProtocolVersion:i}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version ${i?`: ${i}`:"."}`,isRetryable:!1}}function $e(e){let{currentBridgeProtocolVersion:i,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${i} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function Xe(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Vt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Qt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function $t(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function Xt(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Wt(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function Jt(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Kt(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function ie(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function We(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var En=5e3,On=5e3,Pn=5e3;function Zt(e){let{prepareInit:i,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=En,initialStateTimeoutMs:y=On,noInitResultTimeoutMs:m=Pn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:j}=e,k="waitingForConnect",G,W,T,B,q=!1,se=!1;function $(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function R(){W!==void 0&&(window.clearTimeout(W),W=void 0)}function N(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function A(g){let{initializationId:v,error:V,phase:K,source:Be}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ie(k)}k="error",B=v,$(),R(),n({type:"init",initializationId:v,status:"error",error:V}),j?.({...V,phase:K,source:Be})}async function J(g){if(k==="waitingForConnect"){k="preparingInit",B=g.initializationId,$(),W=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Vt();s({...v,initializationId:g.initializationId}),A({initializationId:g.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await i(g);if(k!=="preparingInit")return;if(R(),v.status==="error"){A({initializationId:g.initializationId,error:v.error,phase:"init",source:"host"});return}k="waitingForInitResult";let V={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??pt,blockId:v.initialState.blockId,parent:v.initialState.parent,page:v.initialState.page,currentUser:v.initialState.currentUser,manifest:v.initialState.manifest,dataSources:v.initialState.dataSources};n(V),T=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let K=Wt();j?.({...K,phase:"initResult",source:"host"}),s({...K,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),A({initializationId:g.initializationId,error:Kt(),phase:"init",source:"host"})}}}function ee(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!We(g.bridgeProtocolVersion)){let v=Qe({currentBridgeProtocolVersion:g.bridgeProtocolVersion});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.bridgeProtocolVersion<l){let v=$e({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.status==="error"){A({initializationId:g.initializationId,error:g.error,phase:"connect",source:"sandbox"});return}se=!0,J(g)}}function _(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=g;if(v===void 0)return"nack";let K=g.error;return V!==void 0&&(We(V)?V<l&&(K=$e({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):K=Qe({currentBridgeProtocolVersion:void 0})),A({initializationId:v,error:K,phase:"connect",source:"host"}),"handled"}function ue(g){let{initializationId:v,error:V}=g;k!=="waitingForInitResult"||v===void 0||v!==B||($(),N(),k="error",s(V),j?.({...V,phase:"initResult",source:"host"}))}function je(){if(k!=="stopped"){if(q){S({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}q=!0,$(),k==="waitingForConnect"&&(G=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Gt();s(g),j?.({...g,phase:"connect",source:"host"})},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==B){s({message:"Ignored stale or unexpected initResult",payload:g});return}N(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():j?.({...g.error,phase:"initResult",source:"sandbox"}),I?.(g)}function ae(){k="stopped",$(),R(),N()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:ee,handleInitResult:he,handleInvalidConnect:_,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function Yt(e,i){return i>=5||!(e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged")?e:{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([s,c])=>[s,{...c,collectionSchema:{...c.collectionSchema,propertiesById:{...c.collectionSchema?.propertiesById,...at}}}]))}}}var er=r({theme:de,contrastMode:a(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function tr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var rr=r({code:t(),message:t(),isRetryable:b()});var nr={type:o("connect"),initializationId:t(),bridgeProtocolVersion:E(),sdkVersion:t()},or=h("status",[r({status:o("success"),manifest:a(pe),...nr}),r({status:o("error"),error:rr,...nr})]);var jn=h("type",[r({type:o("start")}),r({type:o("end")}),r({type:o("before"),blockId:re}),r({type:o("after"),blockId:re})]),Bn=h("type",[r({type:o("page_id"),page_id:H}),r({type:o("data_source_id"),data_source_id:Y})]),ir=r({type:o("createPage"),requestId:t(),parent:Bn,properties:_e,position:a(jn)});var Mn=t(),Rn=r({code:Mn,message:t(),isRetryable:b()}),sr=h("status",[r({type:o("initResult"),initializationId:t(),status:o("success"),initialHeight:a(z(E(),be(),Se(0)))}),r({type:o("initResult"),initializationId:t(),status:o("error"),error:Rn})]);var ur=r({type:o("invalidHostMessage"),reason:t()});var ar=D(["ascending","descending"]);var Pe=x([p({is_empty:o(!0)}),p({is_not_empty:o(!0)})]),Oe=x([t(),O(t())]),cr=p({object:D(["user","group"]),id:z(t(),ke(1))}),Dn=x([p({contains:cr}),p({does_not_contain:cr}),Pe]),lr=p({object:o("user"),id:z(t(),ke(1),Re(2e3))}),wn=x([p({contains:lr}),p({does_not_contain:lr}),p({is_empty:o(!0)}),p({is_not_empty:o(!0)})]),Ce=x([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Pe]),An=x([p({equals:E()}),p({does_not_equal:E()}),p({greater_than:E()}),p({less_than:E()}),p({greater_than_or_equal_to:E()}),p({less_than_or_equal_to:E()}),Pe]),Tn=x([p({equals:b()}),p({does_not_equal:b()})]),yr=x([p({equals:Oe}),p({does_not_equal:Oe}),Pe]),pr=D(["To-do","In progress","Complete","Current","Future"]),fr=x([pr,z(O(pr),ke(1),Re(5))]),qn=x([p({group_equals:fr}),p({group_does_not_equal:fr})]),Nn=x([yr,qn]),Fn=x([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Pe]),Q=D(["start_date","end_date"]),Un=D(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Ee=x([Un,t()]),zn=x([p({target:a(Q),equals:Ee}),p({target:a(Q),before:Ee}),p({target:a(Q),after:Ee}),p({target:a(Q),on_or_before:Ee}),p({target:a(Q),on_or_after:Ee}),p({target:a(Q),this_week:p({})}),p({target:a(Q),past_week:p({})}),p({target:a(Q),past_month:p({})}),p({target:a(Q),past_year:p({})}),p({target:a(Q),next_week:p({})}),p({target:a(Q),next_month:p({})}),p({target:a(Q),next_year:p({})}),p({target:a(Q),is_empty:o(!0)}),p({target:a(Q),is_not_empty:o(!0)})]),mr=x([p({propertyId:t(),created_by:wn}),p({propertyId:t(),title:Ce}),p({propertyId:t(),rich_text:Ce}),p({propertyId:t(),url:Ce}),p({propertyId:t(),email:Ce}),p({propertyId:t(),phone_number:Ce}),p({propertyId:t(),number:An}),p({propertyId:t(),checkbox:Tn}),p({propertyId:t(),select:yr}),p({propertyId:t(),multi_select:Fn}),p({propertyId:t(),status:Nn}),p({propertyId:t(),date:zn}),p({propertyId:t(),people:Dn})]),Hn=x([mr,p({and:O(mr)})]),Je=10,Gn=p({propertyId:t(),direction:ar}),vr=r({type:o("queryDataSource"),subscriptionId:t(),dataSourceId:Y,limit:E(),filter:a(Hn),sorts:a(O(Gn))});var dr=r({type:o("resize"),height:z(E(),be(),Se(0))});var hr=r({type:o("unsubscribeDataSourceQuery"),subscriptionId:t()});var gr=r({type:o("updatePage"),requestId:t(),pageId:H,properties:a(_e),icon:a(Ge),cover:a(Le),archived:a(b())});var br=h("type",[or,sr,vr,hr,ir,kt,It,Ct,Ot,gr,dr,ur]);function kr(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Sr(e){let i=kr(e);return i==="invalidHostMessage"||i==="invalidSandboxMessage"?{incomingType:i}:{incomingType:i,nack:{type:"invalidSandboxMessage",reason:Ln(i)}}}function Ln(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Ir=r({initializationId:t()}),Vn=r({bridgeProtocolVersion:x([E(),Fe()])});function xr(e){let{iframe:i,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:j,onCreatePage:k,onGetPage:G,onOpenPage:W,onGetUser:T,onListUsers:B,onUpdatePage:q,onResize:se}=e;function $(R,N){c("warn",{message:"Ignored unsupported sandbox message",payload:R,issues:N});let A=Sr(R);if(A.incomingType==="connect"){let J=xe(Ir,R),ee=xe(Vn,R);if(f({initializationId:J.success?J.output.initializationId:void 0,error:Lt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(A.incomingType==="initResult"){let J=xe(Ir,R);y({initializationId:J.success?J.output.initializationId:void 0,error:Jt()})}A.nack!==void 0&&s()!=="stopped"&&l(A.nack)}return function(N){let A=N.source===i.contentWindow,J=N.origin===n;if(!A||!J)return;let ee=xe(br,N.data);if(!ee.success){$(N.data,ee.issues);return}let _=ee.output;if(!tr(_)&&s()!=="initialized"){c("warn",{message:`Ignored ${_.type} before initialization completed`,payload:_});return}switch(c("in",_),_.type){case"connect":m(_);return;case"initResult":S(_);return;case"queryDataSource":I(_);return;case"unsubscribeDataSourceQuery":j(_);return;case"createPage":k(_);return;case"openPage":W(_);return;case"getPage":G(_);return;case"getUser":T(_);return;case"listUsers":B(_);return;case"updatePage":q(_);return;case"resize":se(_);return;case"invalidHostMessage":return;default:ie(_)}}}var Ae=class{constructor(i){this.onUnsubscribe=i}onUnsubscribe;bySubscriptionId=new Map;subscribe(i){this.unsubscribe(i.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(i.subscriptionId,{message:i,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(i,n){return this.bySubscriptionId.get(i)?.token===n}unsubscribe(i){this.bySubscriptionId.delete(i)&&this.onUnsubscribe(i)}refresh(i){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===i){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(i,n){let s=this.bySubscriptionId.get(i);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let i of this.bySubscriptionId.keys())this.unsubscribe(i)}};function _r(e,i){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Qn(s,i);if(c!==void 0)return c}}function Qn(e,i){if(!Object.hasOwn(i.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let n=i.propertiesById[e.propertyId],s=Object.keys(e).find(y=>y!=="propertyId");if(s!==n.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${n.type}".`,isRetryable:!1};if("status"in e&&n.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,I=(Array.isArray(m)?m:[m]).find(j=>!n.groups.some(k=>k.name===j));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}let c=$n(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=Xn(c.operator).find(y=>!l.has(y));if(f!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${f}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function $n(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let i=e.status;return"group_equals"in i||"group_does_not_equal"in i?void 0:{propertyType:"status",operator:i}}}function Xn(e){let i;if("equals"in e)i=e.equals;else if("does_not_equal"in e)i=e.does_not_equal;else if("contains"in e)i=e.contains;else if("contains_all"in e)i=e.contains_all;else if("does_not_contain"in e)i=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ie(e);return Array.isArray(i)?i:[i]}var Wn=new Set(ut);function Cr(e,i){if(e===void 0)return;if(e.length>Je)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Je} entries.`,isRetryable:!1};let n=new Set;for(let s of e){if(n.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(n.add(s.propertyId),!Object.hasOwn(i.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=i.propertiesById[s.propertyId];if(!Wn.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}var Or=5;function Kn(e){let{iframe:i,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G}=e,W=Math.max(I??3,3),T={},B=!1,q,se,$=5,R=new Ae(u=>{m?.(u)});function N(u,C){y?.(u,C)}function A(u){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ie(C)}let w=Yt(u,$);N("out",w),i.contentWindow?.postMessage(w,S)}function J(u){A(fe(we,u))}function ee(u){A(u)}function _(u){let C=v.status;switch(C){case"initialized":A(fe(Ht,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(u,C){if(C===void 0)return;let w=await C(u);_({type:`${u.type}Result`,requestId:u.requestId,...w})}function je(u){let C=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};_(C)}async function he(u,C=R.subscribe(u)){try{let w=Zn(se,u.dataSourceId),ce=Yn(u,w);if(ce!==void 0){R.isCurrent(u.subscriptionId,C)&&(R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:{status:"error",error:ce}}));return}let Te=await s.queryDataSource(u);if(!R.isCurrent(u.subscriptionId,C))return;Te.status==="error"&&!Te.error.isRetryable&&R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:Te})}finally{let w=R.finish(u.subscriptionId,C);w!==void 0&&he(w.message,w.token)}}function ae(u){v.status==="stopped"||v.status==="error"||(Object.assign(T,u),g())}function g(){if(v.status!=="initialized")return;let u=T;T={},u.theme!==void 0&&_({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&_({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&_({type:"parentChanged",parent:u.parent}),u.page!==void 0&&_({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&_({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&_({type:"currentUserChanged",currentUser:u.currentUser})}let v=Zt({async prepareInit(u){$=u.bridgeProtocolVersion;let C=await n(u);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:J,warn:u=>N("warn",u),flushPendingHostStateChanges:g,minBridgeProtocolVersion:W,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G,stopHostWithFailure:Ke,onInitResult(u){u.status==="success"&&q!==void 0&&l?.({manifest:q,initialHeight:u.initialHeight})},onConnectionFailure:f});function V(u){if(u.status==="error")return u;q=fe(pe,u.initialState.manifest),c?.(q);let C={...u.initialState,...T};T={};let w={...fe(rt(er,["manifest"]),C),manifest:q};if($<Or&&w.page.type==="unavailable")return{status:"error",error:Xe()};let ce=Pr(w.manifest,w.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=w.dataSources,B=!0,{status:"success",initialState:w})}let K=xr({iframe:i,sandboxOrigin:S,getInitStatus:()=>v.status,emit:N,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:u=>R.unsubscribe(u.subscriptionId),onCreatePage:u=>ue(u,s.createPage),onGetPage:u=>ue(u,s.getPage),onOpenPage:u=>ue(u,s.openPage),onGetUser:u=>ue(u,s.getUser),onListUsers:u=>ue(u,s.listUsers),onUpdatePage:u=>ue(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",K),i.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",K),i.removeEventListener("load",v.onIframeLoad),v.stop(),R.unsubscribeAll()}function Ke(u){Be(),N("warn",u),f?.(u)}return{stop:Be,setTheme(u){ae({theme:u})},setContrastMode(u){ae({contrastMode:u})},setParent(u){ae({parent:u})},setPage(u){if(u.type==="unavailable"&&$<Or&&(v.status==="preparingInit"&&B||v.status==="waitingForInitResult"||v.status==="initialized")){Ke({...Xe(),phase:"runtime",source:"host"});return}ae({page:u})},setCurrentUser(u){ae({currentUser:u})},setDataSources(u){let C={bindings:fe(le,u.bindings)};if(v.hasConnectedSandbox&&q!==void 0&&Pr(q,C)!==void 0){N("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:u}){if(v.status!=="initialized")return;let C=fe(Y,u),w=R.refresh(C);if(w===void 0){N("warn",`No active query exists for data source "${u}"`);return}for(let ce of w)he(ce.message,ce.token)}}}function Zn(e,i){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===i)?.collectionSchema}function Pr(e,i){for(let[n,s]of Object.entries(e.dataSources)){let c=i.bindings[n];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Qt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return $t();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return Xt()}}}function Yn(e,i){return i===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:_r(e.filter,i)??Cr(e.sorts,i)}export{Kn as createCustomBlockHost,jr as getAutoBoundPropertyIdsByKey};
@@ -1 +1 @@
1
- {"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AAI5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AAiBvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAA;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAUzC,OAAO,KAAK,EACX,iCAAiC,EACjC,8BAA8B,EAI9B,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,MAAM,qBAAqB,CAAA;AAe5B,MAAM,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,iBAAiB,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B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wBAAwB,CAAC,CAAA;KACzD,KAAK,IAAI,CAAA;CACV,CAAA;AAQD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CAkZvB"}
@@ -297,7 +297,11 @@ export function createCustomBlockHost(options) {
297
297
  hasPreparedInitialState) ||
298
298
  initializationController.status === "waitingForInitResult" ||
299
299
  initializationController.status === "initialized")) {
300
- stopWithFailure(contextUnavailableError());
300
+ stopWithFailure({
301
+ ...contextUnavailableError(),
302
+ phase: "runtime",
303
+ source: "host",
304
+ });
301
305
  return;
302
306
  }
303
307
  updateHostState({ page });
@@ -1 +1 @@
1
- {"version":3,"file":"initializationController.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initializationController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EACX,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAWlE,OAAO,KAAK,EACX,qBAAqB,EACrB,iCAAiC,EACjC,UAAU,EACV,MAAM,YAAY,CAAA;AAMnB,MAAM,MAAM,+BAA+B,GAAG;IAC7C,WAAW,EAAE,CACZ,OAAO,EAAE,qBAAqB,KAC1B,OAAO,CAAC,iCAAiC,CAAC,CAAA;IAC/C,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,KAAK,IAAI,CAAA;IACxE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAChC,4BAA4B,EAAE,MAAM,IAAI,CAAA;IACxC,wBAAwB,EAAE,MAAM,CAAA;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAC5D,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACnD,mBAAmB,EAAE,CAAC,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;CAC1E,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;IACrC,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAA;IAChD,gBAAgB,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACtD,oBAAoB,EAAE,CAAC,IAAI,EAAE;QAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;QAC/B,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAA;KACzC,KAAK,SAAS,GAAG,MAAM,CAAA;IACxB,uBAAuB,EAAE,CAAC,IAAI,EAAE;QAC/B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;KAC/B,KAAK,IAAI,CAAA;IACV,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,+BAA+B,GACtC,wBAAwB,CAgU1B"}
1
+ {"version":3,"file":"initializationController.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initializationController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EACX,wBAAwB,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AAA;IACtD,oBAAoB,EAAE,CAAC,IAAI,EAAE;QAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;QAC/B,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAA;KACzC,KAAK,SAAS,GAAG,MAAM,CAAA;IACxB,uBAAuB,EAAE,CAAC,IAAI,EAAE;QAC/B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;KAC/B,KAAK,IAAI,CAAA;IACV,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,+BAA+B,GACtC,wBAAwB,CAuV1B"}
@@ -33,7 +33,7 @@ export function createInitializationController(options) {
33
33
  }
34
34
  }
35
35
  function sendInitError(args) {
36
- const { initializationId, error } = args;
36
+ const { initializationId, error, phase, source } = args;
37
37
  switch (initStatus) {
38
38
  case "waitingForConnect":
39
39
  case "preparingInit":
@@ -56,7 +56,7 @@ export function createInitializationController(options) {
56
56
  status: "error",
57
57
  error,
58
58
  });
59
- onConnectionFailure?.(error);
59
+ onConnectionFailure?.({ ...error, phase, source });
60
60
  }
61
61
  async function prepareAndSendInit(connect) {
62
62
  if (initStatus !== "waitingForConnect") {
@@ -74,7 +74,12 @@ export function createInitializationController(options) {
74
74
  ...error,
75
75
  initializationId: connect.initializationId,
76
76
  });
77
- sendInitError({ initializationId: connect.initializationId, error });
77
+ sendInitError({
78
+ initializationId: connect.initializationId,
79
+ error,
80
+ phase: "init",
81
+ source: "host",
82
+ });
78
83
  }, initialStateTimeoutMs);
79
84
  try {
80
85
  const preparation = await prepareInit(connect);
@@ -86,6 +91,8 @@ export function createInitializationController(options) {
86
91
  sendInitError({
87
92
  initializationId: connect.initializationId,
88
93
  error: preparation.error,
94
+ phase: "init",
95
+ source: "host",
89
96
  });
90
97
  return;
91
98
  }
@@ -110,7 +117,7 @@ export function createInitializationController(options) {
110
117
  }
111
118
  initStatus = "error";
112
119
  const error = noInitResultError();
113
- onConnectionFailure?.(error);
120
+ onConnectionFailure?.({ ...error, phase: "initResult", source: "host" });
114
121
  warn({
115
122
  ...error,
116
123
  initializationId: connect.initializationId,
@@ -128,6 +135,8 @@ export function createInitializationController(options) {
128
135
  sendInitError({
129
136
  initializationId: connect.initializationId,
130
137
  error: unknownInitializationError(),
138
+ phase: "init",
139
+ source: "host",
131
140
  });
132
141
  }
133
142
  }
@@ -146,6 +155,8 @@ export function createInitializationController(options) {
146
155
  sendInitError({
147
156
  initializationId: message.initializationId,
148
157
  error: initError,
158
+ phase: "connect",
159
+ source: "host",
149
160
  });
150
161
  return;
151
162
  }
@@ -157,6 +168,8 @@ export function createInitializationController(options) {
157
168
  sendInitError({
158
169
  initializationId: message.initializationId,
159
170
  error: initError,
171
+ phase: "connect",
172
+ source: "host",
160
173
  });
161
174
  return;
162
175
  }
@@ -165,6 +178,8 @@ export function createInitializationController(options) {
165
178
  sendInitError({
166
179
  initializationId: message.initializationId,
167
180
  error: message.error,
181
+ phase: "connect",
182
+ source: "sandbox",
168
183
  });
169
184
  return;
170
185
  }
@@ -198,7 +213,7 @@ export function createInitializationController(options) {
198
213
  });
199
214
  }
200
215
  }
201
- sendInitError({ initializationId, error });
216
+ sendInitError({ initializationId, error, phase: "connect", source: "host" });
202
217
  return "handled";
203
218
  }
204
219
  function handleInvalidInitResult(args) {
@@ -212,7 +227,7 @@ export function createInitializationController(options) {
212
227
  clearNoInitResultTimeout();
213
228
  initStatus = "error";
214
229
  warn(error);
215
- onConnectionFailure?.(error);
230
+ onConnectionFailure?.({ ...error, phase: "initResult", source: "host" });
216
231
  }
217
232
  function onIframeLoad() {
218
233
  if (initStatus === "stopped") {
@@ -220,6 +235,8 @@ export function createInitializationController(options) {
220
235
  }
221
236
  if (hasObservedIframeLoad) {
222
237
  stopHostWithFailure({
238
+ phase: "runtime",
239
+ source: "host",
223
240
  code: "iframe_reloaded",
224
241
  message: "The iframe reloaded. Create a new host and iframe to reconnect.",
225
242
  isRetryable: true,
@@ -240,7 +257,7 @@ export function createInitializationController(options) {
240
257
  initStatus = "error";
241
258
  const error = noConnectError();
242
259
  warn(error);
243
- onConnectionFailure?.(error);
260
+ onConnectionFailure?.({ ...error, phase: "connect", source: "host" });
244
261
  }, noConnectTimeoutMs);
245
262
  }
246
263
  function handleInitResult(message) {
@@ -258,7 +275,11 @@ export function createInitializationController(options) {
258
275
  flushPendingHostStateChanges();
259
276
  }
260
277
  else {
261
- onConnectionFailure?.(message.error);
278
+ onConnectionFailure?.({
279
+ ...message.error,
280
+ phase: "initResult",
281
+ source: "sandbox",
282
+ });
262
283
  }
263
284
  onInitResult?.(message);
264
285
  }
@@ -77,7 +77,14 @@ export declare const customBlockHostInitialStateSchema: v.ObjectSchema<{
77
77
  }, undefined>], undefined>;
78
78
  readonly manifest: v.ObjectSchema<{
79
79
  readonly version: v.LiteralSchema<1, undefined>;
80
- readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
80
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
81
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
82
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
83
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
84
+ readonly type: v.LiteralSchema<"emoji", undefined>;
85
+ readonly emoji: v.StringSchema<undefined>;
86
+ }, undefined>, undefined>;
87
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
81
88
  readonly name: v.StringSchema<undefined>;
82
89
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
83
90
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
@@ -92,7 +99,7 @@ export declare const customBlockHostInitialStateSchema: v.ObjectSchema<{
92
99
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
93
100
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
94
101
  }, undefined>, undefined>, {}>;
95
- }, undefined>, undefined>;
102
+ }, undefined>, undefined>, {}>;
96
103
  }, undefined>;
97
104
  readonly dataSources: v.ObjectSchema<{
98
105
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lifecycle/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,4DAA4D,CAAA;AAG3G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAA;AAKjG,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAC1C,cAAc,EACd;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CACrB,CAAA;AAED,gEAAgE;AAChE,MAAM,MAAM,UAAU;AACrB,qEAAqE;AACnE,mBAAmB;AACrB,mEAAmE;GACjE,eAAe;AACjB,6EAA6E;GAC3E,sBAAsB;AACxB,yDAAyD;GACvD,aAAa;AACf,gFAAgF;GAC9E,OAAO;AACT,2EAA2E;GACzE,SAAS,CAAA;AAEZ,MAAM,MAAM,iCAAiC,GAAG;IAC/C,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAA;CAC7D,CAAA;AAED,MAAM,MAAM,2CAA2C,GAAG;IACzD,QAAQ,EAAE,CAAC,CAAC,WAAW,CAAC,OAAO,8BAA8B,CAAC,CAAA;CAC9D,CAAA;AAED,eAAO,MAA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AAO;AACT,2EAA2E;GACzE,SAAS,CAAA;AAEZ,MAAM,MAAM,iCAAiC,GAAG;IAC/C,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAA;CAC7D,CAAA;AAED,MAAM,MAAM,2CAA2C,GAAG;IACzD,QAAQ,EAAE,CAAC,CAAC,WAAW,CAAC,OAAO,8BAA8B,CAAC,CAAA;CAC9D,CAAA;AAED,eAAO,MAAM,iCAAiC;;IAE7C;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAQF,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,UAAU,CACrD,OAAO,iCAAiC,CACxC,CAAA;AAED,MAAM,MAAM,iCAAiC,GAC1C;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,YAAY,EAAE,2BAA2B,CAAA;CACxC,GACD;IACA,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,wBAAwB,CAAA;CAC9B,CAAA;AAEJ,MAAM,MAAM,8BAA8B,GAAG,CAC5C,OAAO,EAAE,qBAAqB,KAC1B,OAAO,CAAC,iCAAiC,CAAC,CAAA"}
@@ -1,9 +1,8 @@
1
+ import type { CustomBlockErrorInfo } from "../protocol/errors.js";
1
2
  import type { CreatePageMessage, createPageMessageSchema } from "../protocol/messages/createPage.js";
2
3
  import type { CustomBlockCreatePageErrorInfo, createPageResultMessageSchema } from "../protocol/messages/createPageResult.js";
3
4
  import type { CustomBlockGetPageErrorInfo, GetPageMessage, getPageMessageSchema, getPageResultMessageSchema } from "../protocol/messages/getPage.js";
4
5
  import type { CustomBlockGetUserErrorInfo, GetUserMessage, getUserMessageSchema, getUserResultMessageSchema } from "../protocol/messages/getUser.js";
5
- import type { CustomBlockInitErrorInfo } from "../protocol/messages/init.js";
6
- import type { CustomBlockInitResultErrorInfo } from "../protocol/messages/initResult.js";
7
6
  import type { CustomBlockListUsersErrorInfo, ListUsersMessage, listUsersMessageSchema, listUsersResultMessageSchema } from "../protocol/messages/listUsers.js";
8
7
  import type { BridgeMessagePayload } from "../protocol/messages/messagePayload.js";
9
8
  import type { CustomBlockOpenPageErrorInfo, OpenPageMessage, openPageMessageSchema, openPageResultMessageSchema } from "../protocol/messages/openPage.js";
@@ -35,7 +34,18 @@ export type CustomBlockHostHandlers = {
35
34
  updatePage?: (message: UpdatePageMessage) => MaybePromise<CustomBlockHostUpdatePageResult>;
36
35
  resize?: (message: ResizeMessage) => void;
37
36
  };
38
- export type CustomBlockHostFailure = CustomBlockInitErrorInfo | CustomBlockInitResultErrorInfo;
37
+ export type CustomBlockHostFailure = CustomBlockErrorInfo & {
38
+ /** The handshake step or host lifecycle event that failed. */
39
+ phase: "connect"
40
+ /** The host cannot prepare or validate initial state, or preparation times out. */
41
+ | "init"
42
+ /** The sandbox's initialization acknowledgment is missing, invalid, or reports an error. */
43
+ | "initResult"
44
+ /** An iframe reload or unavailable page context stops the host, before or after initialization succeeds. */
45
+ | "runtime";
46
+ /** Who reported or detected the failure, regardless of who caused it. */
47
+ source: "host" | "sandbox";
48
+ };
39
49
  export type CustomBlockHostLogDirection = "in" | "out" | "warn";
40
50
  export type CreatePageMessageInput = InferInput<typeof createPageMessageSchema>;
41
51
  export type GetPageMessageInput = InferInput<typeof getPageMessageSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/messages/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,yDAAyD,CAAA;AAChE,OAAO,KAAK,EACX,8BAA8B,EAC9B,6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,CAAC,CAAA;AAE/E,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE7E,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAE3E,MAAM,MAAM,2BAA2B,GAAG,UAAU,CACnD,OAAO,4BAA4B,CACnC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAEvE,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
@@ -37,7 +37,14 @@ export declare const manifestDataSourceSchema: v.ObjectSchema<{
37
37
  export type ManifestDataSource = v.InferOutput<typeof manifestDataSourceSchema>;
38
38
  export declare const manifestSchema: v.ObjectSchema<{
39
39
  readonly version: v.LiteralSchema<1, undefined>;
40
- readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
40
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
41
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
42
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
43
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
44
+ readonly type: v.LiteralSchema<"emoji", undefined>;
45
+ readonly emoji: v.StringSchema<undefined>;
46
+ }, undefined>, undefined>;
47
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
41
48
  readonly name: v.StringSchema<undefined>;
42
49
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
43
50
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
@@ -52,9 +59,9 @@ export declare const manifestSchema: v.ObjectSchema<{
52
59
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
53
60
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
54
61
  }, undefined>, undefined>, {}>;
55
- }, undefined>, undefined>;
62
+ }, undefined>, undefined>, {}>;
56
63
  }, undefined>;
57
64
  /**
58
- * Manifest declaring the data sources required by a custom block.
65
+ * Manifest describing a custom block and its required data sources.
59
66
  */
60
67
  export type CustomBlockManifest = v.InferOutput<typeof manifestSchema>;
@@ -28,5 +28,9 @@ export const manifestDataSourceSchema = v.object({
28
28
  });
29
29
  export const manifestSchema = v.object({
30
30
  version: v.literal(1),
31
- dataSources: v.record(v.string(), manifestDataSourceSchema),
31
+ name: v.optional(v.string()),
32
+ description: v.optional(v.string()),
33
+ slashCommand: v.optional(v.string()),
34
+ icon: v.optional(v.object({ type: v.literal("emoji"), emoji: v.string() })),
35
+ dataSources: v.optional(v.record(v.string(), manifestDataSourceSchema), {}),
32
36
  });
@@ -15,7 +15,14 @@ export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSc
15
15
  */
16
16
  readonly manifest: v.OptionalSchema<v.ObjectSchema<{
17
17
  readonly version: v.LiteralSchema<1, undefined>;
18
- readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
18
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
19
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
20
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
21
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
22
+ readonly type: v.LiteralSchema<"emoji", undefined>;
23
+ readonly emoji: v.StringSchema<undefined>;
24
+ }, undefined>, undefined>;
25
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
19
26
  readonly name: v.StringSchema<undefined>;
20
27
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
21
28
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
@@ -30,7 +37,7 @@ export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSc
30
37
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
31
38
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
32
39
  }, undefined>, undefined>, {}>;
33
- }, undefined>, undefined>;
40
+ }, undefined>, undefined>, {}>;
34
41
  }, undefined>, undefined>;
35
42
  }, undefined>, v.ObjectSchema<{
36
43
  readonly type: v.LiteralSchema<"connect", undefined>;
@@ -53,7 +53,14 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
53
53
  }, undefined>], undefined>;
54
54
  readonly manifest: v.ObjectSchema<{
55
55
  readonly version: v.LiteralSchema<1, undefined>;
56
- readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
56
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
57
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
58
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
59
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
60
+ readonly type: v.LiteralSchema<"emoji", undefined>;
61
+ readonly emoji: v.StringSchema<undefined>;
62
+ }, undefined>, undefined>;
63
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
57
64
  readonly name: v.StringSchema<undefined>;
58
65
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
59
66
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
@@ -68,7 +75,7 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
68
75
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
69
76
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
70
77
  }, undefined>, undefined>, {}>;
71
- }, undefined>, undefined>;
78
+ }, undefined>, undefined>, {}>;
72
79
  }, undefined>;
73
80
  readonly dataSources: v.ObjectSchema<{
74
81
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
@@ -79,7 +79,14 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
79
79
  }, undefined>], undefined>;
80
80
  readonly manifest: v.ObjectSchema<{
81
81
  readonly version: v.LiteralSchema<1, undefined>;
82
- readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
82
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
83
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
84
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
85
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
86
+ readonly type: v.LiteralSchema<"emoji", undefined>;
87
+ readonly emoji: v.StringSchema<undefined>;
88
+ }, undefined>, undefined>;
89
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
83
90
  readonly name: v.StringSchema<undefined>;
84
91
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
85
92
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
@@ -94,7 +101,7 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
94
101
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
95
102
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
96
103
  }, undefined>, undefined>, {}>;
97
- }, undefined>, undefined>;
104
+ }, undefined>, undefined>, {}>;
98
105
  }, undefined>;
99
106
  readonly dataSources: v.ObjectSchema<{
100
107
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
@@ -11,7 +11,14 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
11
11
  readonly status: v.LiteralSchema<"success", undefined>;
12
12
  readonly manifest: v.OptionalSchema<v.ObjectSchema<{
13
13
  readonly version: v.LiteralSchema<1, undefined>;
14
- readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
14
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
15
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
16
+ readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
17
+ readonly icon: v.OptionalSchema<v.ObjectSchema<{
18
+ readonly type: v.LiteralSchema<"emoji", undefined>;
19
+ readonly emoji: v.StringSchema<undefined>;
20
+ }, undefined>, undefined>;
21
+ readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
15
22
  readonly name: v.StringSchema<undefined>;
16
23
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
17
24
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
@@ -26,7 +33,7 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
26
33
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
27
34
  readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
28
35
  }, undefined>, undefined>, {}>;
29
- }, undefined>, undefined>;
36
+ }, undefined>, undefined>, {}>;
30
37
  }, undefined>, undefined>;
31
38
  }, undefined>, v.ObjectSchema<{
32
39
  readonly type: v.LiteralSchema<"connect", undefined>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-host",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Reusable host runtime for Notion custom blocks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -469,7 +469,11 @@ export function createCustomBlockHost(
469
469
  initializationController.status === "waitingForInitResult" ||
470
470
  initializationController.status === "initialized")
471
471
  ) {
472
- stopWithFailure(contextUnavailableError())
472
+ stopWithFailure({
473
+ ...contextUnavailableError(),
474
+ phase: "runtime",
475
+ source: "host",
476
+ })
473
477
  return
474
478
  }
475
479
  updateHostState({ page })
@@ -529,7 +533,7 @@ function getCollectionSchema(
529
533
  }
530
534
 
531
535
  function getBindingError(
532
- manifest: InferInput<typeof manifestSchema>,
536
+ manifest: CustomBlockManifest,
533
537
  dataSources: CustomBlockHostDataSourcesPayload,
534
538
  ): CustomBlockInitErrorInfo | undefined {
535
539
  for (const [dataSourceKey, manifestDataSource] of Object.entries(
@@ -110,8 +110,10 @@ export function createInitializationController(
110
110
  function sendInitError(args: {
111
111
  initializationId: string
112
112
  error: CustomBlockInitErrorInfo
113
+ phase: "connect" | "init"
114
+ source: "host" | "sandbox"
113
115
  }) {
114
- const { initializationId, error } = args
116
+ const { initializationId, error, phase, source } = args
115
117
  switch (initStatus) {
116
118
  case "waitingForConnect":
117
119
  case "preparingInit":
@@ -134,7 +136,7 @@ export function createInitializationController(
134
136
  status: "error",
135
137
  error,
136
138
  })
137
- onConnectionFailure?.(error)
139
+ onConnectionFailure?.({ ...error, phase, source })
138
140
  }
139
141
 
140
142
  async function prepareAndSendInit(connect: ConnectSuccessMessage) {
@@ -153,7 +155,12 @@ export function createInitializationController(
153
155
  ...error,
154
156
  initializationId: connect.initializationId,
155
157
  })
156
- sendInitError({ initializationId: connect.initializationId, error })
158
+ sendInitError({
159
+ initializationId: connect.initializationId,
160
+ error,
161
+ phase: "init",
162
+ source: "host",
163
+ })
157
164
  }, initialStateTimeoutMs)
158
165
 
159
166
  try {
@@ -166,6 +173,8 @@ export function createInitializationController(
166
173
  sendInitError({
167
174
  initializationId: connect.initializationId,
168
175
  error: preparation.error,
176
+ phase: "init",
177
+ source: "host",
169
178
  })
170
179
  return
171
180
  }
@@ -191,7 +200,7 @@ export function createInitializationController(
191
200
  }
192
201
  initStatus = "error"
193
202
  const error = noInitResultError()
194
- onConnectionFailure?.(error)
203
+ onConnectionFailure?.({ ...error, phase: "initResult", source: "host" })
195
204
  warn({
196
205
  ...error,
197
206
  initializationId: connect.initializationId,
@@ -208,6 +217,8 @@ export function createInitializationController(
208
217
  sendInitError({
209
218
  initializationId: connect.initializationId,
210
219
  error: unknownInitializationError(),
220
+ phase: "init",
221
+ source: "host",
211
222
  })
212
223
  }
213
224
  }
@@ -228,6 +239,8 @@ export function createInitializationController(
228
239
  sendInitError({
229
240
  initializationId: message.initializationId,
230
241
  error: initError,
242
+ phase: "connect",
243
+ source: "host",
231
244
  })
232
245
  return
233
246
  }
@@ -239,6 +252,8 @@ export function createInitializationController(
239
252
  sendInitError({
240
253
  initializationId: message.initializationId,
241
254
  error: initError,
255
+ phase: "connect",
256
+ source: "host",
242
257
  })
243
258
  return
244
259
  }
@@ -248,6 +263,8 @@ export function createInitializationController(
248
263
  sendInitError({
249
264
  initializationId: message.initializationId,
250
265
  error: message.error,
266
+ phase: "connect",
267
+ source: "sandbox",
251
268
  })
252
269
  return
253
270
  }
@@ -287,7 +304,7 @@ export function createInitializationController(
287
304
  })
288
305
  }
289
306
  }
290
- sendInitError({ initializationId, error })
307
+ sendInitError({ initializationId, error, phase: "connect", source: "host" })
291
308
  return "handled"
292
309
  }
293
310
 
@@ -307,7 +324,7 @@ export function createInitializationController(
307
324
  clearNoInitResultTimeout()
308
325
  initStatus = "error"
309
326
  warn(error)
310
- onConnectionFailure?.(error)
327
+ onConnectionFailure?.({ ...error, phase: "initResult", source: "host" })
311
328
  }
312
329
 
313
330
  function onIframeLoad() {
@@ -316,6 +333,8 @@ export function createInitializationController(
316
333
  }
317
334
  if (hasObservedIframeLoad) {
318
335
  stopHostWithFailure({
336
+ phase: "runtime",
337
+ source: "host",
319
338
  code: "iframe_reloaded",
320
339
  message:
321
340
  "The iframe reloaded. Create a new host and iframe to reconnect.",
@@ -337,7 +356,7 @@ export function createInitializationController(
337
356
  initStatus = "error"
338
357
  const error = noConnectError()
339
358
  warn(error)
340
- onConnectionFailure?.(error)
359
+ onConnectionFailure?.({ ...error, phase: "connect", source: "host" })
341
360
  }, noConnectTimeoutMs)
342
361
  }
343
362
 
@@ -357,7 +376,11 @@ export function createInitializationController(
357
376
  if (message.status === "success") {
358
377
  flushPendingHostStateChanges()
359
378
  } else {
360
- onConnectionFailure?.(message.error)
379
+ onConnectionFailure?.({
380
+ ...message.error,
381
+ phase: "initResult",
382
+ source: "sandbox",
383
+ })
361
384
  }
362
385
  onInitResult?.(message)
363
386
  }
@@ -1,3 +1,4 @@
1
+ import type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
1
2
  import type {
2
3
  CreatePageMessage,
3
4
  createPageMessageSchema,
@@ -18,8 +19,6 @@ import type {
18
19
  getUserMessageSchema,
19
20
  getUserResultMessageSchema,
20
21
  } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
21
- import type { CustomBlockInitErrorInfo } from "@notionhq/custom-blocks-protocol/messages/init.js"
22
- import type { CustomBlockInitResultErrorInfo } from "@notionhq/custom-blocks-protocol/messages/initResult.js"
23
22
  import type {
24
23
  CustomBlockListUsersErrorInfo,
25
24
  ListUsersMessage,
@@ -114,9 +113,19 @@ export type CustomBlockHostHandlers = {
114
113
  resize?: (message: ResizeMessage) => void
115
114
  }
116
115
 
117
- export type CustomBlockHostFailure =
118
- | CustomBlockInitErrorInfo
119
- | CustomBlockInitResultErrorInfo
116
+ export type CustomBlockHostFailure = CustomBlockErrorInfo & {
117
+ /** The handshake step or host lifecycle event that failed. */
118
+ phase: /** The sandbox's connect message is missing, invalid, unsupported, or reports a startup error. */
119
+ | "connect"
120
+ /** The host cannot prepare or validate initial state, or preparation times out. */
121
+ | "init"
122
+ /** The sandbox's initialization acknowledgment is missing, invalid, or reports an error. */
123
+ | "initResult"
124
+ /** An iframe reload or unavailable page context stops the host, before or after initialization succeeds. */
125
+ | "runtime"
126
+ /** Who reported or detected the failure, regardless of who caused it. */
127
+ source: "host" | "sandbox"
128
+ }
120
129
 
121
130
  export type CustomBlockHostLogDirection = "in" | "out" | "warn"
122
131