@notionhq/custom-blocks-host 0.2.18 → 0.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -1 +1 @@
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 Te(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 qr;function Tr(e,i){return qr?.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??Tr(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},Te())}},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,q=0;for(let B of k){let T=G.entries[B];if(B in l?T["~run"]({typed:!1,value:l[B]},Ur).issues:T.type!=="exact_optional"&&T.type!=="optional"&&T.type!=="nullish"){W=!1,m!==B&&(y<q||y===q&&B in l&&!(m in l))&&(y=q,m=B,S=[]),m===B&&S.push(G.entries[B].expects);break}q++}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},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"(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},Te(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)}),uo=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)}),V={id:t()},tn=h("type",[r({...V,type:o("title"),title:O(mt)}),r({...V,type:o("rich_text"),rich_text:O(mt)}),r({...V,type:o("number"),number:Z(E())}),r({...V,type:o("url"),url:X}),r({...V,type:o("email"),email:X}),r({...V,type:o("phone_number"),phone_number:X}),r({...V,type:o("checkbox"),checkbox:b()}),r({...V,type:o("select"),select:Z(He)}),r({...V,type:o("status"),status:Z(He)}),r({...V,type:o("multi_select"),multi_select:O(He)}),r({...V,type:o("date"),date:Z(Jr)}),r({...V,type:o("people"),people:O(Kr)}),r({...V,type:o("relation"),has_more:a(b()),relation:O(Zr)}),r({...V,type:o("files"),files:O(Yr)}),r({...V,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 qt=r({id:t(),table:t()});var Tt=x([t(),E(),b(),At,O(t()),O(qt)]);var Nt=r({id:H,is_archived:b(),in_trash:b(),propertiesById:U(t(),a(Tt))});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}`,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,q,B,T=!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(){q!==void 0&&(window.clearTimeout(q),q=void 0)}function A(g){let{initializationId:v,error:L,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:L}),j?.({...L,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 L={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(L),q=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:L}=g;if(v===void 0)return"nack";let K=g.error;return L!==void 0&&(We(L)?L<l&&(K=$e({currentBridgeProtocolVersion:L,minBridgeProtocolVersion:l})):K=Qe({currentBridgeProtocolVersion:L})),A({initializationId:v,error:K,phase:"connect",source:"host"}),"handled"}function ue(g){let{initializationId:v,error:L}=g;k!=="waitingForInitResult"||v===void 0||v!==B||($(),N(),k="error",s(L),j?.({...L,phase:"initResult",source:"host"}))}function je(){if(k!=="stopped"){if(T){S({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}T=!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]),qn=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))]),Tn=x([p({group_equals:fr}),p({group_does_not_equal:fr})]),Nn=x([yr,Tn]),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:qn}),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:q,onListUsers:B,onUpdatePage:T,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":q(_);return;case"listUsers":B(_);return;case"updatePage":T(_);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),q={},B=!1,T,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 qe=await s.queryDataSource(u);if(!R.isCurrent(u.subscriptionId,C))return;qe.status==="error"&&!qe.error.isRetryable&&R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:qe})}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(q,u),g())}function g(){if(v.status!=="initialized")return;let u=q;q={},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:L(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"&&T!==void 0&&l?.({manifest:T,initialHeight:u.initialHeight})},onConnectionFailure:f});function L(u){if(u.status==="error")return u;T=fe(pe,u.initialState.manifest),c?.(T);let C={...u.initialState,...q};q={};let w={...fe(rt(er,["manifest"]),C),manifest:T};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&&T!==void 0&&Pr(T,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)}function eo(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}export{Kn as createCustomBlockHost,jr as getAutoBoundPropertyIdsByKey,eo as isLocalCustomBlockUrl};
1
+ function qr(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=Tr({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function Tr(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=rt(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||rt(y.name)===c));return l.length===1?l[0][0]:void 0}function rt(e){return e.trim().toLowerCase()}var Re,Nr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Ne(e){return!e&&!Re?Nr:{lang:e?.lang??Re?.lang,message:e?.message,abortEarly:e?.abortEarly??Re?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Re?.abortPipeEarly}}var Fr;function Ur(e){return Fr?.get(e)}var zr;function Hr(e){return zr?.get(e)}var Lr;function Gr(e,o){return Lr?.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 j(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??Gr(e.reference,m.lang)??(S?Hr(m.lang):null)??s.message??Ur(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 nt=new WeakMap;function z(e){let o=nt.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Ne())}},nt.set(e,o)),o}function Vr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function Fe(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var $r=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)&&j(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&&j(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&&j(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)&&j(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}function Ue(e,o){return{kind:"validation",type:"regex",reference:Ue,async:!1,expects:`${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!this.requirement.test(n.value)&&j(this,"format",n,s),n}}}function ze(e){return{kind:"transformation",type:"transform",reference:ze,async:!1,operation:e,"~run"(o){return o.value=this.operation(o.value),o}}}var it={abortEarly:!0};function st(e,o,n){return typeof e.fallback=="function"?e.fallback(o,n):e.fallback}function De(e,o,n){return typeof e.default=="function"?e.default(o,n):e.default}function ut(e,o){return!e["~run"]({value:o},it).issues}function O(e,o){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return z(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 j(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 z(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:j(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 z(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:j(this,"type",n,s),n}}}function He(e){return{kind:"schema",type:"nan",reference:He,expects:"NaN",async:!1,message:e,get"~standard"(){return z(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function W(e,o){return{kind:"schema",type:"nullable",reference:W,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return z(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 z(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:j(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 z(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]=st(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(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 j(this,"type",n,s);return n}}}function u(e,o){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return z(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 B(e,o){return{kind:"schema",type:"picklist",reference:B,expects:Fe(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return z(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:j(this,"type",n,s),n}}}function H(e,o,n){return{kind:"schema",type:"record",reference:H,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return z(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Vr(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 R of m.issues)R.path=[I],s.issues?.push(R);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 R of S.issues)R.path?R.path.unshift(I):R.path=[I],s.issues?.push(R);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 j(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 z(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]=st(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(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)){j(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else j(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 z(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:j(this,"type",o,n),o}}}function ot(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 _(e,o){return{kind:"schema",type:"union",reference:_,expects:Fe(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return z(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];j(this,"type",n,s,{issues:ot(l)}),n.typed=!0}else{if(f?.length===1)return f[0];j(this,"type",n,s,{issues:ot(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return z(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 z(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(R,k)=>{for(let G of R.options){if(G.type==="variant")I(G,new Set(k).add(G.key));else{let J=!0,N=0;for(let M of k){let F=G.entries[M];if(M in l?F["~run"]({typed:!1,value:l[M]},it).issues:F.type!=="exact_optional"&&F.type!=="optional"&&F.type!=="nullish"){J=!1,m!==M&&(y<N||y===N&&M in l&&!(m in l))&&(y=N,m=M,S=[]),m===M&&S.push(G.entries[M].expects);break}N++}if(J){let M=G["~run"]({value:l},c);(!f||!f.typed&&M.typed)&&(f=M)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;j(this,"type",s,c,{input:l[m],expected:Fe(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else j(this,"type",s,c);return s}}}function at(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return z(this)}}}function fe(e,o,n){let s=e["~run"]({value:o},Ne(n));if(s.issues)throw new $r(s.issues);return s.value}function L(...e){return{...e[0],pipe:e,get"~standard"(){return z(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 _e(e,o,n){let s=e["~run"]({value:o},Ne(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var re=L(t(),te("NotionBlockId")),Y=L(t(),te("NotionDataSourceId")),T=L(t(),te("NotionPageId")),ct=L(t(),te("NotionAgentId")),lt=L(t(),te("NotionSpaceId"));var pt=B(["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"]),Le=r({id:t(),name:t(),color:u(pt),description:u(t())}),Qr=r({id:t(),name:t(),color:u(pt),option_ids:O(t())}),Xr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:u(t())}),Wr=["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"],ft=B(Wr),mt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Ge=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(Le)}),r({...P.entries,type:i("multi_select"),options:O(Le)}),r({...P.entries,type:i("status"),options:O(Le),groups:O(Qr)}),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:u(t()),dual_property:u(Xr)}),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 yt={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 vt=r({id:Y,table:t(),spaceId:u(lt)}),dt=r({id:u(Y),propertiesById:H(t(),Ge)}),mo=r({key:t(),collectionPointer:u(vt),collectionSchema:u(dt),propertyIdsByKey:H(t(),u(t())),propertySchemasById:H(t(),Ge)}),Jr=r({collectionPointer:u(vt),collectionSchema:u(dt),propertyIdsByKey:u(H(t(),u(t())))}),le=H(t(),Jr);var Kr=h("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),Zr=r({name:t(),description:u(t()),type:ft}),Yr=r({name:t(),description:u(t()),icon:u(Kr),properties:u(H(t(),Zr),{})}),pe=r({version:i(1),name:u(t()),description:u(t()),slashCommand:u(t()),icon:u(r({type:i("emoji"),emoji:t()})),dataSources:u(H(t(),Yr),{})});var me=B(["standard","high"]),ht="standard";var gt=r({type:i("contrastModeChanged"),contrastMode:me});var we=r({id:t(),table:t()});var ne=h("type",[r({type:i("page_id"),page_id:T}),r({type:i("data_source_id"),data_source_id:Y}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:re}),r({type:i("agent_id"),agent_id:ct}),r({type:i("unavailable")})]);var ye=h("type",[r({type:i("unavailable")}),r({type:i("page"),id:T,parent:ne})]),en=r({type:i("emoji"),emoji:t()}),tn=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:u(t()),url:u(t())})}),St=r({type:i("external"),external:r({url:t()})}),It=r({type:i("file"),file:r({url:t(),expiry_time:u(t())})}),$e=h("type",[en,tn,St,It]),Qe=h("type",[St,It]),$=W(t()),bt=H(t(),Ie()),Ve=_([r({id:t(),name:u(t()),color:u(t()),description:u($)}),r({name:t(),id:u(t()),color:u(t()),description:u($)})]),rn=r({start:t(),end:u($),time_zone:u($)}),nn=_([r({object:u(i("user")),id:t()}),r({object:i("group"),id:t(),name:u($)})]),on=r({id:t()}),sn=_([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:u(t())})})]),un=r({lat:E(),lon:E(),name:u($),address:u($),aws_place_id:u($),google_place_id:u($)}),w={id:t()},kt=W(r({...we.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:u(t())})),an=h("type",[r({...w,type:i("title"),title:O(bt)}),r({...w,type:i("rich_text"),rich_text:O(bt)}),r({...w,type:i("number"),number:W(E())}),r({...w,type:i("url"),url:$}),r({...w,type:i("email"),email:$}),r({...w,type:i("phone_number"),phone_number:$}),r({...w,type:i("checkbox"),checkbox:b()}),r({...w,type:i("select"),select:W(Ve)}),r({...w,type:i("status"),status:W(Ve)}),r({...w,type:i("multi_select"),multi_select:O(Ve)}),r({...w,type:i("date"),date:W(rn)}),r({...w,type:i("people"),people:O(nn)}),r({...w,type:i("relation"),has_more:u(b()),relation:O(on)}),r({...w,type:i("files"),files:O(sn)}),r({...w,type:i("place"),place:W(un)}),r({...w,type:i("created_time"),created_time:$}),r({...w,type:i("last_edited_time"),last_edited_time:$}),r({...w,type:i("created_by"),created_by:kt}),r({...w,type:i("last_edited_by"),last_edited_by:kt}),r({...w,type:i("last_visited_time"),last_visited_time:$})]),xe=H(t(),an),ve=r({object:i("page"),id:T,parent:ne,properties:xe,created_time:u(t()),last_edited_time:u(t()),icon:u($e),cover:u(Qe),url:u(t()),public_url:u(t()),is_archived:b(),in_trash:b()});var cn=t(),ln=r({code:cn,message:t(),isRetryable:b()}),_t=h("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:ln})]);var Xe=L(t(),te("NotionUserId")),oe=r({object:i("user"),id:Xe,name:u(t()),avatar_url:W(t()),type:i("person"),person:r({email:t()})}),xt=r({object:i("list"),results:O(oe),next_cursor:W(t()),has_more:b(),type:i("user"),user:H(t(),Ie())});var Ct=r({type:i("currentUserChanged"),currentUser:oe});var Et=r({type:i("dataSourcesChanged"),dataSources:r({bindings:le})});var pn=t(),fn=r({code:pn,message:t(),isRetryable:b()}),Ot=r({type:i("getPage"),requestId:t(),pageId:T}),Pt=h("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:fn})]);var mn=t(),yn=r({code:mn,message:t(),isRetryable:b()}),jt=r({type:i("getUser"),requestId:t(),userId:Xe}),Bt=h("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:oe}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:yn})]);var de=B(["light","dark"]);var vn=t(),dn=r({code:vn,message:t(),isRetryable:b()});var Ae=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:dn})]);var Rt=r({type:i("invalidSandboxMessage"),reason:t()});var hn=t(),gn=r({code:hn,message:t(),isRetryable:b()}),Mt=r({type:i("listUsers"),requestId:t(),startCursor:u(t()),pageSize:u(E())}),Dt=h("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:xt}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:gn})]);var bn=B(["side_peek","center_peek"]),kn=t(),Sn=r({code:kn,message:t(),isRetryable:b()}),wt=r({type:i("openPage"),requestId:t(),pageId:T,mode:bn}),At=h("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:T}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:Sn})]);var qt=r({type:i("pageChanged"),page:ye});var Tt=r({type:i("parentChanged"),parent:ne});var Nt=r({unit:B(["year","month","week","day"]),value:E(),time:t(),defaultTimeZone:u(t())}),In=r({unit:B(["hour","minute"]),value:E()}),Ft=r({unit:i("none")}),_n=_([Nt,In]),Ut=u(_([Nt,Ft])),zt=u(_([_n,Ft])),xn=r({type:i("date"),start_date:t(),reminder:Ut}),Cn=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:Ut}),En=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:u(t()),reminder:zt}),On=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:u(t()),reminder:zt}),Ht=h("type",[xn,Cn,En,On]);var Lt=_([t(),E(),b(),Ht,O(t()),O(we)]);var Gt=r({id:T,is_archived:b(),in_trash:b(),propertiesById:H(t(),u(Lt))});var Pn=t(),jn=r({code:Pn,message:t(),isRetryable:b()}),Vt=h("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:O(Gt),hasMore:b()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:jn})]);var $t=r({type:i("themeChanged"),theme:de});var Bn=t(),Rn=r({code:Bn,message:t(),isRetryable:b()}),Qt=h("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:Rn})]);var Xt=h("type",[Ae,$t,gt,Tt,qt,Ct,Et,Vt,_t,Pt,Bt,Dt,At,Qt,Rt]);function Wt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Jt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function We(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${o}`,isRetryable:!1}}function Je(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 Ke(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Kt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Zt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function Yt(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function er(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function tr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function rr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function nr(){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 Ze(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var Mn=5e3,Dn=5e3,wn=5e3;function or(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=Mn,initialStateTimeoutMs:y=Dn,noInitResultTimeoutMs:m=wn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:R}=e,k="waitingForConnect",G,J,N,M,F=!1,se=!1;function X(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function D(){J!==void 0&&(window.clearTimeout(J),J=void 0)}function U(){N!==void 0&&(window.clearTimeout(N),N=void 0)}function q(g){let{initializationId:v,error:V,phase:Z,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",M=v,X(),D(),n({type:"init",initializationId:v,status:"error",error:V}),R?.({...V,phase:Z,source:Be})}async function K(g){if(k==="waitingForConnect"){k="preparingInit",M=g.initializationId,X(),J=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Kt();s({...v,initializationId:g.initializationId}),q({initializationId:g.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await o(g);if(k!=="preparingInit")return;if(D(),v.status==="error"){q({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??ht,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),N=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let Z=tr();R?.({...Z,phase:"initResult",source:"host"}),s({...Z,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),q({initializationId:g.initializationId,error:nr(),phase:"init",source:"host"})}}}function ee(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!Ze(g.bridgeProtocolVersion)){let v=We({currentBridgeProtocolVersion:g.bridgeProtocolVersion});q({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.bridgeProtocolVersion<l){let v=Je({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});q({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.status==="error"){q({initializationId:g.initializationId,error:g.error,phase:"connect",source:"sandbox"});return}se=!0,K(g)}}function x(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=g;if(v===void 0)return"nack";let Z=g.error;return V!==void 0&&(Ze(V)?V<l&&(Z=Je({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):Z=We({currentBridgeProtocolVersion:V})),q({initializationId:v,error:Z,phase:"connect",source:"host"}),"handled"}function ue(g){let{initializationId:v,error:V}=g;k!=="waitingForInitResult"||v===void 0||v!==M||(X(),U(),k="error",s(V),R?.({...V,phase:"initResult",source:"host"}))}function je(){if(k!=="stopped"){if(F){S({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}F=!0,X(),k==="waitingForConnect"&&(G=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Wt();s(g),R?.({...g,phase:"connect",source:"host"})},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==M){s({message:"Ignored stale or unexpected initResult",payload:g});return}U(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():R?.({...g.error,phase:"initResult",source:"sandbox"}),I?.(g)}function ae(){k="stopped",X(),D(),U()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:ee,handleInitResult:he,handleInvalidConnect:x,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function ir(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,...yt}}}]))}}}var sr=r({theme:de,contrastMode:u(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function ur(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var ar=r({code:t(),message:t(),isRetryable:b()});var cr={type:i("connect"),initializationId:t(),bridgeProtocolVersion:E(),sdkVersion:t()},lr=h("status",[r({status:i("success"),manifest:u(pe),...cr}),r({status:i("error"),error:ar,...cr})]);var An=h("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:re}),r({type:i("after"),blockId:re})]),qn=h("type",[r({type:i("page_id"),page_id:T}),r({type:i("data_source_id"),data_source_id:Y})]),pr=r({type:i("createPage"),requestId:t(),parent:qn,properties:xe,position:u(An)});var Tn=t(),Nn=r({code:Tn,message:t(),isRetryable:b()}),fr=h("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:u(L(E(),be(),Se(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Nn})]);var mr=r({type:i("invalidHostMessage"),reason:t()});var yr=B(["ascending","descending"]);var vr=L(T,Ue(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),ze(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),Ye=_([p({contains:vr}),p({does_not_contain:vr})]),Pe=_([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Oe=_([t(),O(t())]),dr=p({object:B(["user","group"]),id:L(t(),ke(1))}),Fn=_([p({contains:dr}),p({does_not_contain:dr}),Pe]),hr=p({object:i("user"),id:L(t(),ke(1),Me(2e3))}),Un=_([p({contains:hr}),p({does_not_contain:hr}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ce=_([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]),zn=_([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]),Hn=_([p({equals:b()}),p({does_not_equal:b()})]),Sr=_([p({equals:Oe}),p({does_not_equal:Oe}),Pe]),gr=B(["To-do","In progress","Complete","Current","Future"]),br=_([gr,L(O(gr),ke(1),Me(5))]),Ln=_([p({group_equals:br}),p({group_does_not_equal:br})]),Gn=_([Sr,Ln]),Vn=_([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Pe]),Q=B(["start_date","end_date"]),$n=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Ee=_([$n,t()]),Qn=_([p({target:u(Q),equals:Ee}),p({target:u(Q),before:Ee}),p({target:u(Q),after:Ee}),p({target:u(Q),on_or_before:Ee}),p({target:u(Q),on_or_after:Ee}),p({target:u(Q),this_week:p({})}),p({target:u(Q),past_week:p({})}),p({target:u(Q),past_month:p({})}),p({target:u(Q),past_year:p({})}),p({target:u(Q),next_week:p({})}),p({target:u(Q),next_month:p({})}),p({target:u(Q),next_year:p({})}),p({target:u(Q),is_empty:i(!0)}),p({target:u(Q),is_not_empty:i(!0)})]),kr=_([p({propertyId:t(),relation:Ye}),p({propertyId:t(),created_by:Un}),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:zn}),p({propertyId:t(),checkbox:Hn}),p({propertyId:t(),select:Sr}),p({propertyId:t(),multi_select:Vn}),p({propertyId:t(),status:Gn}),p({propertyId:t(),date:Qn}),p({propertyId:t(),people:Fn})]),Xn=_([kr,p({and:O(kr)})]),et=10,Wn=p({propertyId:t(),direction:yr}),Ir=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Y,limit:E(),filter:u(Xn),sorts:u(O(Wn))});var _r=r({type:i("resize"),height:L(E(),be(),Se(0))});var xr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var Cr=r({type:i("updatePage"),requestId:t(),pageId:T,properties:u(xe),icon:u($e),cover:u(Qe),archived:u(b())});var Er=h("type",[lr,fr,Ir,xr,pr,Ot,jt,Mt,wt,Cr,_r,mr]);function Or(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Pr(e){let o=Or(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Jn(o)}}}function Jn(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var jr=r({initializationId:t()}),Kn=r({bridgeProtocolVersion:_([E(),He()])});function Br(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:R,onCreatePage:k,onGetPage:G,onOpenPage:J,onGetUser:N,onListUsers:M,onUpdatePage:F,onResize:se}=e;function X(D,U){c("warn",{message:"Ignored unsupported sandbox message",payload:D,issues:U});let q=Pr(D);if(q.incomingType==="connect"){let K=_e(jr,D),ee=_e(Kn,D);if(f({initializationId:K.success?K.output.initializationId:void 0,error:Jt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(q.incomingType==="initResult"){let K=_e(jr,D);y({initializationId:K.success?K.output.initializationId:void 0,error:rr()})}q.nack!==void 0&&s()!=="stopped"&&l(q.nack)}return function(U){let q=U.source===o.contentWindow,K=U.origin===n;if(!q||!K)return;let ee=_e(Er,U.data);if(!ee.success){X(U.data,ee.issues);return}let x=ee.output;if(!ur(x)&&s()!=="initialized"){c("warn",{message:`Ignored ${x.type} before initialization completed`,payload:x});return}switch(c("in",x),x.type){case"connect":m(x);return;case"initResult":S(x);return;case"queryDataSource":I(x);return;case"unsubscribeDataSourceQuery":R(x);return;case"createPage":k(x);return;case"openPage":J(x);return;case"getPage":G(x);return;case"getUser":N(x);return;case"listUsers":M(x);return;case"updatePage":F(x);return;case"resize":se(x);return;case"invalidHostMessage":return;default:ie(x)}}}var qe=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 Rr(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Zn(s,o);if(c!==void 0)return c}}function Zn(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(R=>!n.groups.some(k=>k.name===R));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}if("relation"in e&&!ut(Ye,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Yn(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=eo(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 Yn(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 eo(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 to=new Set(mt);function Mr(e,o){if(e===void 0)return;if(e.length>et)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${et} 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(!to.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 wr=5;function no(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:R,initialStateTimeoutMs:k,noInitResultTimeoutMs:G}=e,J=Math.max(I??3,3),N={},M=!1,F,se,X=5,D=new qe(a=>{m?.(a)});function U(a,C){y?.(a,C)}function q(a){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 A=ir(a,X);U("out",A),o.contentWindow?.postMessage(A,S)}function K(a){q(fe(Ae,a))}function ee(a){q(a)}function x(a){let C=v.status;switch(C){case"initialized":q(fe(Xt,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(a,C){if(C===void 0)return;let A=await C(a);x({type:`${a.type}Result`,requestId:a.requestId,...A})}function je(a){let C=a.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"error",error:a.response.error}:{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"success",items:a.response.items,hasMore:a.response.hasMore};x(C)}async function he(a,C=D.subscribe(a)){try{let A=oo(se,a.dataSourceId),ce=io(a,A);if(ce!==void 0){D.isCurrent(a.subscriptionId,C)&&(D.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:{status:"error",error:ce}}));return}let Te=await s.queryDataSource(a);if(!D.isCurrent(a.subscriptionId,C))return;Te.status==="error"&&!Te.error.isRetryable&&D.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:Te})}finally{let A=D.finish(a.subscriptionId,C);A!==void 0&&he(A.message,A.token)}}function ae(a){v.status==="stopped"||v.status==="error"||(Object.assign(N,a),g())}function g(){if(v.status!=="initialized")return;let a=N;N={},a.theme!==void 0&&x({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&x({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&x({type:"parentChanged",parent:a.parent}),a.page!==void 0&&x({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&x({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&x({type:"currentUserChanged",currentUser:a.currentUser})}let v=or({async prepareInit(a){X=a.bridgeProtocolVersion;let C=await n(a);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:K,warn:a=>U("warn",a),flushPendingHostStateChanges:g,minBridgeProtocolVersion:J,noConnectTimeoutMs:R,initialStateTimeoutMs:k,noInitResultTimeoutMs:G,stopHostWithFailure:tt,onInitResult(a){a.status==="success"&&F!==void 0&&l?.({manifest:F,initialHeight:a.initialHeight})},onConnectionFailure:f});function V(a){if(a.status==="error")return a;F=fe(pe,a.initialState.manifest),c?.(F);let C={...a.initialState,...N};N={};let A={...fe(at(sr,["manifest"]),C),manifest:F};if(X<wr&&A.page.type==="unavailable")return{status:"error",error:Ke()};let ce=Ar(A.manifest,A.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=A.dataSources,M=!0,{status:"success",initialState:A})}let Z=Br({iframe:o,sandboxOrigin:S,getInitStatus:()=>v.status,emit:U,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:a=>D.unsubscribe(a.subscriptionId),onCreatePage:a=>ue(a,s.createPage),onGetPage:a=>ue(a,s.getPage),onOpenPage:a=>ue(a,s.openPage),onGetUser:a=>ue(a,s.getUser),onListUsers:a=>ue(a,s.listUsers),onUpdatePage:a=>ue(a,s.updatePage),onResize:a=>s.resize?.(a)});window.addEventListener("message",Z),o.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",Z),o.removeEventListener("load",v.onIframeLoad),v.stop(),D.unsubscribeAll()}function tt(a){Be(),U("warn",a),f?.(a)}return{stop:Be,setTheme(a){ae({theme:a})},setContrastMode(a){ae({contrastMode:a})},setParent(a){ae({parent:a})},setPage(a){if(a.type==="unavailable"&&X<wr&&(v.status==="preparingInit"&&M||v.status==="waitingForInitResult"||v.status==="initialized")){tt({...Ke(),phase:"runtime",source:"host"});return}ae({page:a})},setCurrentUser(a){ae({currentUser:a})},setDataSources(a){let C={bindings:fe(le,a.bindings)};if(v.hasConnectedSandbox&&F!==void 0&&Ar(F,C)!==void 0){U("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:a}){if(v.status!=="initialized")return;let C=fe(Y,a),A=D.refresh(C);if(A===void 0){U("warn",`No active query exists for data source "${a}"`);return}for(let ce of A)he(ce.message,ce.token)}}}function oo(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function Ar(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 Zt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return Yt();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return er()}}}function io(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}:Rr(e.filter,o)??Mr(e.sorts,o)}function so(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}export{no as createCustomBlockHost,qr as getAutoBoundPropertyIdsByKey,so as isLocalCustomBlockUrl};
package/dist/index.d.ts CHANGED
@@ -4,10 +4,10 @@ export type { GetPageMessage } from "./protocol/messages/getPage.js";
4
4
  export type { GetUserMessage } from "./protocol/messages/getUser.js";
5
5
  export type { ListUsersMessage } from "./protocol/messages/listUsers.js";
6
6
  export type { OpenPageMessage } from "./protocol/messages/openPage.js";
7
- export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockStatusFilterOperator, CustomBlockStatusGroupFilterOperator, CustomBlockStatusGroupName, CustomBlockTextFilterOperator, QueryDataSourceMessage, ResolvedCustomBlockDataSourceFilter, ResolvedCustomBlockDataSourcePropertyFilter, ResolvedCustomBlockDataSourceSort, } from "./protocol/messages/queryDataSource.js";
7
+ export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockRelationFilterOperator, CustomBlockStatusFilterOperator, CustomBlockStatusGroupFilterOperator, CustomBlockStatusGroupName, CustomBlockTextFilterOperator, QueryDataSourceMessage, ResolvedCustomBlockDataSourceFilter, ResolvedCustomBlockDataSourcePropertyFilter, ResolvedCustomBlockDataSourceSort, } from "./protocol/messages/queryDataSource.js";
8
8
  export type { ResizeMessage } from "./protocol/messages/resize.js";
9
9
  export type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
10
- export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageIcon, NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, NotionSelectOptionInput, } from "./protocol/pages/page.js";
10
+ export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageIcon, NotionPagePropertyReadMap, NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, NotionSelectOptionInput, } from "./protocol/pages/page.js";
11
11
  export { type AutoBindableProperty, getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
12
12
  export { type CustomBlockHostHandle, type CustomBlockHostOptions, createCustomBlockHost, } from "./createCustomBlockHost.js";
13
13
  export type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostGetInitialState, CustomBlockHostInitialState, CustomBlockHostInitialStateResult, } from "./lifecycle/types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
@@ -181,6 +181,34 @@ export declare const createPageMessageSchema: v.ObjectSchema<{
181
181
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
182
182
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
183
183
  }, undefined>, undefined>;
184
+ }, undefined>, v.ObjectSchema<{
185
+ readonly id: v.StringSchema<undefined>;
186
+ readonly type: v.LiteralSchema<"created_time", undefined>;
187
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
188
+ }, undefined>, v.ObjectSchema<{
189
+ readonly id: v.StringSchema<undefined>;
190
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
191
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
192
+ }, undefined>, v.ObjectSchema<{
193
+ readonly id: v.StringSchema<undefined>;
194
+ readonly type: v.LiteralSchema<"created_by", undefined>;
195
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
196
+ readonly id: v.StringSchema<undefined>;
197
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
198
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
199
+ }, undefined>, undefined>;
200
+ }, undefined>, v.ObjectSchema<{
201
+ readonly id: v.StringSchema<undefined>;
202
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
203
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
204
+ readonly id: v.StringSchema<undefined>;
205
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
206
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
207
+ }, undefined>, undefined>;
208
+ }, undefined>, v.ObjectSchema<{
209
+ readonly id: v.StringSchema<undefined>;
210
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
211
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
184
212
  }, undefined>], undefined>, undefined>;
185
213
  readonly position: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
186
214
  readonly type: v.LiteralSchema<"start", undefined>;
@@ -1,6 +1,6 @@
1
1
  import * as v from "valibot";
2
2
  import { notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, } from "../ids.js";
3
- import { notionPagePropertyWriteMapSchema } from "../pages/page.js";
3
+ import { notionPagePropertyReadMapSchema } from "../pages/page.js";
4
4
  /**
5
5
  * Describes where the newly created page should be inserted.
6
6
  * - `start` / `end` (default): prepend / append to the request's `parent`
@@ -46,6 +46,6 @@ export const createPageMessageSchema = v.object({
46
46
  * To create a page with manifest-defined property keys, call `pages.create`. The SDK resolves
47
47
  * those keys before it sends this message.
48
48
  */
49
- properties: notionPagePropertyWriteMapSchema,
49
+ properties: notionPagePropertyReadMapSchema,
50
50
  position: v.optional(notionCreatePagePositionSchema),
51
51
  });
@@ -161,6 +161,34 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
161
161
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
162
162
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
163
163
  }, undefined>, undefined>;
164
+ }, undefined>, v.ObjectSchema<{
165
+ readonly id: v.StringSchema<undefined>;
166
+ readonly type: v.LiteralSchema<"created_time", undefined>;
167
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
168
+ }, undefined>, v.ObjectSchema<{
169
+ readonly id: v.StringSchema<undefined>;
170
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
171
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
172
+ }, undefined>, v.ObjectSchema<{
173
+ readonly id: v.StringSchema<undefined>;
174
+ readonly type: v.LiteralSchema<"created_by", undefined>;
175
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
176
+ readonly id: v.StringSchema<undefined>;
177
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
178
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
179
+ }, undefined>, undefined>;
180
+ }, undefined>, v.ObjectSchema<{
181
+ readonly id: v.StringSchema<undefined>;
182
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
183
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
184
+ readonly id: v.StringSchema<undefined>;
185
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
186
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
187
+ }, undefined>, undefined>;
188
+ }, undefined>, v.ObjectSchema<{
189
+ readonly id: v.StringSchema<undefined>;
190
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
191
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
164
192
  }, undefined>], undefined>, undefined>;
165
193
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
166
194
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -166,6 +166,34 @@ export declare const getPageResultMessageSchema: v.VariantSchema<"status", [v.Ob
166
166
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
167
167
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
168
168
  }, undefined>, undefined>;
169
+ }, undefined>, v.ObjectSchema<{
170
+ readonly id: v.StringSchema<undefined>;
171
+ readonly type: v.LiteralSchema<"created_time", undefined>;
172
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
173
+ }, undefined>, v.ObjectSchema<{
174
+ readonly id: v.StringSchema<undefined>;
175
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
176
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
177
+ }, undefined>, v.ObjectSchema<{
178
+ readonly id: v.StringSchema<undefined>;
179
+ readonly type: v.LiteralSchema<"created_by", undefined>;
180
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
181
+ readonly id: v.StringSchema<undefined>;
182
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
183
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
184
+ }, undefined>, undefined>;
185
+ }, undefined>, v.ObjectSchema<{
186
+ readonly id: v.StringSchema<undefined>;
187
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
188
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
189
+ readonly id: v.StringSchema<undefined>;
190
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
191
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
192
+ }, undefined>, undefined>;
193
+ }, undefined>, v.ObjectSchema<{
194
+ readonly id: v.StringSchema<undefined>;
195
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
196
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
169
197
  }, undefined>], undefined>, undefined>;
170
198
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
171
199
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -685,6 +685,34 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
685
685
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
686
686
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
687
687
  }, undefined>, undefined>;
688
+ }, undefined>, v.ObjectSchema<{
689
+ readonly id: v.StringSchema<undefined>;
690
+ readonly type: v.LiteralSchema<"created_time", undefined>;
691
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
692
+ }, undefined>, v.ObjectSchema<{
693
+ readonly id: v.StringSchema<undefined>;
694
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
695
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
696
+ }, undefined>, v.ObjectSchema<{
697
+ readonly id: v.StringSchema<undefined>;
698
+ readonly type: v.LiteralSchema<"created_by", undefined>;
699
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
700
+ readonly id: v.StringSchema<undefined>;
701
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
702
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
703
+ }, undefined>, undefined>;
704
+ }, undefined>, v.ObjectSchema<{
705
+ readonly id: v.StringSchema<undefined>;
706
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
707
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
708
+ readonly id: v.StringSchema<undefined>;
709
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
710
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
711
+ }, undefined>, undefined>;
712
+ }, undefined>, v.ObjectSchema<{
713
+ readonly id: v.StringSchema<undefined>;
714
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
715
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
688
716
  }, undefined>], undefined>, undefined>;
689
717
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
690
718
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -885,6 +913,34 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
885
913
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
886
914
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
887
915
  }, undefined>, undefined>;
916
+ }, undefined>, v.ObjectSchema<{
917
+ readonly id: v.StringSchema<undefined>;
918
+ readonly type: v.LiteralSchema<"created_time", undefined>;
919
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
920
+ }, undefined>, v.ObjectSchema<{
921
+ readonly id: v.StringSchema<undefined>;
922
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
923
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
924
+ }, undefined>, v.ObjectSchema<{
925
+ readonly id: v.StringSchema<undefined>;
926
+ readonly type: v.LiteralSchema<"created_by", undefined>;
927
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
928
+ readonly id: v.StringSchema<undefined>;
929
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
930
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
931
+ }, undefined>, undefined>;
932
+ }, undefined>, v.ObjectSchema<{
933
+ readonly id: v.StringSchema<undefined>;
934
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
935
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
936
+ readonly id: v.StringSchema<undefined>;
937
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
938
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
939
+ }, undefined>, undefined>;
940
+ }, undefined>, v.ObjectSchema<{
941
+ readonly id: v.StringSchema<undefined>;
942
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
943
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
888
944
  }, undefined>], undefined>, undefined>;
889
945
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
890
946
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -1152,6 +1208,34 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
1152
1208
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
1153
1209
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
1154
1210
  }, undefined>, undefined>;
1211
+ }, undefined>, v.ObjectSchema<{
1212
+ readonly id: v.StringSchema<undefined>;
1213
+ readonly type: v.LiteralSchema<"created_time", undefined>;
1214
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1215
+ }, undefined>, v.ObjectSchema<{
1216
+ readonly id: v.StringSchema<undefined>;
1217
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
1218
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1219
+ }, undefined>, v.ObjectSchema<{
1220
+ readonly id: v.StringSchema<undefined>;
1221
+ readonly type: v.LiteralSchema<"created_by", undefined>;
1222
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
1223
+ readonly id: v.StringSchema<undefined>;
1224
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
1225
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1226
+ }, undefined>, undefined>;
1227
+ }, undefined>, v.ObjectSchema<{
1228
+ readonly id: v.StringSchema<undefined>;
1229
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
1230
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
1231
+ readonly id: v.StringSchema<undefined>;
1232
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
1233
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1234
+ }, undefined>, undefined>;
1235
+ }, undefined>, v.ObjectSchema<{
1236
+ readonly id: v.StringSchema<undefined>;
1237
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
1238
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1155
1239
  }, undefined>], undefined>, undefined>;
1156
1240
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1157
1241
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -1,4 +1,10 @@
1
1
  import * as v from "valibot";
2
+ export declare const customBlockRelationFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
3
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
4
+ }, undefined>, v.StrictObjectSchema<{
5
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
6
+ }, undefined>], undefined>;
7
+ export type CustomBlockRelationFilterOperator = v.InferOutput<typeof customBlockRelationFilterOperatorSchema>;
2
8
  declare const customBlockPersonFilterValueSchema: v.StrictObjectSchema<{
3
9
  readonly object: v.PicklistSchema<["user", "group"], undefined>;
4
10
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
@@ -169,6 +175,13 @@ export declare const customBlockDateFilterOperatorSchema: v.UnionSchema<[v.Stric
169
175
  }, undefined>], undefined>;
170
176
  export type CustomBlockDateFilterOperator = v.InferOutput<typeof customBlockDateFilterOperatorSchema>;
171
177
  export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionSchema<[v.StrictObjectSchema<{
178
+ readonly propertyId: v.StringSchema<undefined>;
179
+ readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
180
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
181
+ }, undefined>, v.StrictObjectSchema<{
182
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
183
+ }, undefined>], undefined>;
184
+ }, undefined>, v.StrictObjectSchema<{
172
185
  readonly propertyId: v.StringSchema<undefined>;
173
186
  readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
174
187
  readonly contains: v.StrictObjectSchema<{
@@ -410,6 +423,13 @@ export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionS
410
423
  }, undefined>], undefined>;
411
424
  export type ResolvedCustomBlockDataSourcePropertyFilter = v.InferOutput<typeof resolvedCustomBlockDataSourcePropertyFilterSchema>;
412
425
  export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
426
+ readonly propertyId: v.StringSchema<undefined>;
427
+ readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
428
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
429
+ }, undefined>, v.StrictObjectSchema<{
430
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
431
+ }, undefined>], undefined>;
432
+ }, undefined>, v.StrictObjectSchema<{
413
433
  readonly propertyId: v.StringSchema<undefined>;
414
434
  readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
415
435
  readonly contains: v.StrictObjectSchema<{
@@ -650,6 +670,13 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
650
670
  }, undefined>], undefined>], undefined>;
651
671
  }, undefined>], undefined>, v.StrictObjectSchema<{
652
672
  readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
673
+ readonly propertyId: v.StringSchema<undefined>;
674
+ readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
675
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
676
+ }, undefined>, v.StrictObjectSchema<{
677
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
678
+ }, undefined>], undefined>;
679
+ }, undefined>, v.StrictObjectSchema<{
653
680
  readonly propertyId: v.StringSchema<undefined>;
654
681
  readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
655
682
  readonly contains: v.StrictObjectSchema<{
@@ -915,6 +942,13 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
915
942
  readonly limit: v.NumberSchema<undefined>;
916
943
  /** A sandbox-resolved property filter. */
917
944
  readonly filter: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
945
+ readonly propertyId: v.StringSchema<undefined>;
946
+ readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
947
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
948
+ }, undefined>, v.StrictObjectSchema<{
949
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
950
+ }, undefined>], undefined>;
951
+ }, undefined>, v.StrictObjectSchema<{
918
952
  readonly propertyId: v.StringSchema<undefined>;
919
953
  readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
920
954
  readonly contains: v.StrictObjectSchema<{
@@ -1155,6 +1189,13 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
1155
1189
  }, undefined>], undefined>], undefined>;
1156
1190
  }, undefined>], undefined>, v.StrictObjectSchema<{
1157
1191
  readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
1192
+ readonly propertyId: v.StringSchema<undefined>;
1193
+ readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
1194
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
1195
+ }, undefined>, v.StrictObjectSchema<{
1196
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
1197
+ }, undefined>], undefined>;
1198
+ }, undefined>, v.StrictObjectSchema<{
1158
1199
  readonly propertyId: v.StringSchema<undefined>;
1159
1200
  readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
1160
1201
  readonly contains: v.StrictObjectSchema<{
@@ -1,6 +1,14 @@
1
1
  import * as v from "valibot";
2
2
  import { notionSortDirectionSchema } from "../dataSources/sortDirection.js";
3
- import { notionDataSourceIdSchema } from "../ids.js";
3
+ import { notionDataSourceIdSchema, notionPageIdSchema } from "../ids.js";
4
+ const relationPageIdSchema = v.pipe(notionPageIdSchema, v.regex(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i), v.transform(id => id
5
+ .replaceAll("-", "")
6
+ .toLowerCase()
7
+ .replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5")));
8
+ export const customBlockRelationFilterOperatorSchema = v.union([
9
+ v.strictObject({ contains: relationPageIdSchema }),
10
+ v.strictObject({ does_not_contain: relationPageIdSchema }),
11
+ ]);
4
12
  const emptyOperatorSchema = v.union([
5
13
  v.strictObject({ is_empty: v.literal(true) }),
6
14
  v.strictObject({ is_not_empty: v.literal(true) }),
@@ -156,6 +164,10 @@ export const customBlockDateFilterOperatorSchema = v.union([
156
164
  }),
157
165
  ]);
158
166
  export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
167
+ v.strictObject({
168
+ propertyId: v.string(),
169
+ relation: customBlockRelationFilterOperatorSchema,
170
+ }),
159
171
  v.strictObject({
160
172
  propertyId: v.string(),
161
173
  created_by: customBlockCreatedByFilterOperatorSchema,
@@ -66,6 +66,13 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
66
66
  readonly dataSourceId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
67
67
  readonly limit: v.NumberSchema<undefined>;
68
68
  readonly filter: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
69
+ readonly propertyId: v.StringSchema<undefined>;
70
+ readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
71
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
72
+ }, undefined>, v.StrictObjectSchema<{
73
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
74
+ }, undefined>], undefined>;
75
+ }, undefined>, v.StrictObjectSchema<{
69
76
  readonly propertyId: v.StringSchema<undefined>;
70
77
  readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
71
78
  readonly contains: v.StrictObjectSchema<{
@@ -306,6 +313,13 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
306
313
  }, undefined>], undefined>], undefined>;
307
314
  }, undefined>], undefined>, v.StrictObjectSchema<{
308
315
  readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
316
+ readonly propertyId: v.StringSchema<undefined>;
317
+ readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
318
+ readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
319
+ }, undefined>, v.StrictObjectSchema<{
320
+ readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
321
+ }, undefined>], undefined>;
322
+ }, undefined>, v.StrictObjectSchema<{
309
323
  readonly propertyId: v.StringSchema<undefined>;
310
324
  readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
311
325
  readonly contains: v.StrictObjectSchema<{
@@ -687,6 +701,34 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
687
701
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
688
702
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
689
703
  }, undefined>, undefined>;
704
+ }, undefined>, v.ObjectSchema<{
705
+ readonly id: v.StringSchema<undefined>;
706
+ readonly type: v.LiteralSchema<"created_time", undefined>;
707
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
708
+ }, undefined>, v.ObjectSchema<{
709
+ readonly id: v.StringSchema<undefined>;
710
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
711
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
712
+ }, undefined>, v.ObjectSchema<{
713
+ readonly id: v.StringSchema<undefined>;
714
+ readonly type: v.LiteralSchema<"created_by", undefined>;
715
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
716
+ readonly id: v.StringSchema<undefined>;
717
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
718
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
719
+ }, undefined>, undefined>;
720
+ }, undefined>, v.ObjectSchema<{
721
+ readonly id: v.StringSchema<undefined>;
722
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
723
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
724
+ readonly id: v.StringSchema<undefined>;
725
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
726
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
727
+ }, undefined>, undefined>;
728
+ }, undefined>, v.ObjectSchema<{
729
+ readonly id: v.StringSchema<undefined>;
730
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
731
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
690
732
  }, undefined>], undefined>, undefined>;
691
733
  readonly position: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
692
734
  readonly type: v.LiteralSchema<"start", undefined>;
@@ -845,6 +887,34 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
845
887
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
846
888
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
847
889
  }, undefined>, undefined>;
890
+ }, undefined>, v.ObjectSchema<{
891
+ readonly id: v.StringSchema<undefined>;
892
+ readonly type: v.LiteralSchema<"created_time", undefined>;
893
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
894
+ }, undefined>, v.ObjectSchema<{
895
+ readonly id: v.StringSchema<undefined>;
896
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
897
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
898
+ }, undefined>, v.ObjectSchema<{
899
+ readonly id: v.StringSchema<undefined>;
900
+ readonly type: v.LiteralSchema<"created_by", undefined>;
901
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
902
+ readonly id: v.StringSchema<undefined>;
903
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
904
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
905
+ }, undefined>, undefined>;
906
+ }, undefined>, v.ObjectSchema<{
907
+ readonly id: v.StringSchema<undefined>;
908
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
909
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
910
+ readonly id: v.StringSchema<undefined>;
911
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
912
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
913
+ }, undefined>, undefined>;
914
+ }, undefined>, v.ObjectSchema<{
915
+ readonly id: v.StringSchema<undefined>;
916
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
917
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
848
918
  }, undefined>], undefined>, undefined>, undefined>;
849
919
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
850
920
  readonly type: v.LiteralSchema<"emoji", undefined>;
@@ -137,6 +137,34 @@ export declare const updatePageMessageSchema: v.ObjectSchema<{
137
137
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
138
138
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
139
139
  }, undefined>, undefined>;
140
+ }, undefined>, v.ObjectSchema<{
141
+ readonly id: v.StringSchema<undefined>;
142
+ readonly type: v.LiteralSchema<"created_time", undefined>;
143
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
144
+ }, undefined>, v.ObjectSchema<{
145
+ readonly id: v.StringSchema<undefined>;
146
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
147
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
148
+ }, undefined>, v.ObjectSchema<{
149
+ readonly id: v.StringSchema<undefined>;
150
+ readonly type: v.LiteralSchema<"created_by", undefined>;
151
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
152
+ readonly id: v.StringSchema<undefined>;
153
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
154
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
155
+ }, undefined>, undefined>;
156
+ }, undefined>, v.ObjectSchema<{
157
+ readonly id: v.StringSchema<undefined>;
158
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
159
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
160
+ readonly id: v.StringSchema<undefined>;
161
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
162
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
163
+ }, undefined>, undefined>;
164
+ }, undefined>, v.ObjectSchema<{
165
+ readonly id: v.StringSchema<undefined>;
166
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
167
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
140
168
  }, undefined>], undefined>, undefined>, undefined>;
141
169
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
142
170
  readonly type: v.LiteralSchema<"emoji", undefined>;
@@ -1,6 +1,6 @@
1
1
  import * as v from "valibot";
2
2
  import { notionPageIdSchema } from "../ids.js";
3
- import { notionPageCoverSchema, notionPageIconSchema, notionPagePropertyWriteMapSchema, } from "../pages/page.js";
3
+ import { notionPageCoverSchema, notionPageIconSchema, notionPagePropertyReadMapSchema, } from "../pages/page.js";
4
4
  /**
5
5
  * The sandbox sends this message to patch a page.
6
6
  */
@@ -15,7 +15,7 @@ export const updatePageMessageSchema = v.object({
15
15
  * To update a page with manifest-defined property keys, call `row.update()` on a row returned
16
16
  * by `useDataSource()`. The SDK resolves those keys before it sends this message.
17
17
  */
18
- properties: v.optional(notionPagePropertyWriteMapSchema),
18
+ properties: v.optional(notionPagePropertyReadMapSchema),
19
19
  icon: v.optional(notionPageIconSchema),
20
20
  cover: v.optional(notionPageCoverSchema),
21
21
  archived: v.optional(v.boolean()),
@@ -160,6 +160,34 @@ export declare const updatePageResultMessageSchema: v.VariantSchema<"status", [v
160
160
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
161
161
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
162
162
  }, undefined>, undefined>;
163
+ }, undefined>, v.ObjectSchema<{
164
+ readonly id: v.StringSchema<undefined>;
165
+ readonly type: v.LiteralSchema<"created_time", undefined>;
166
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
167
+ }, undefined>, v.ObjectSchema<{
168
+ readonly id: v.StringSchema<undefined>;
169
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
170
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
171
+ }, undefined>, v.ObjectSchema<{
172
+ readonly id: v.StringSchema<undefined>;
173
+ readonly type: v.LiteralSchema<"created_by", undefined>;
174
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
175
+ readonly id: v.StringSchema<undefined>;
176
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
177
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
178
+ }, undefined>, undefined>;
179
+ }, undefined>, v.ObjectSchema<{
180
+ readonly id: v.StringSchema<undefined>;
181
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
182
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
183
+ readonly id: v.StringSchema<undefined>;
184
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
185
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
186
+ }, undefined>, undefined>;
187
+ }, undefined>, v.ObjectSchema<{
188
+ readonly id: v.StringSchema<undefined>;
189
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
190
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
163
191
  }, undefined>], undefined>, undefined>;
164
192
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
165
193
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -283,9 +283,37 @@ export declare const notionPagePropertyValueSchema: v.VariantSchema<"type", [v.O
283
283
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
284
284
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
285
285
  }, undefined>, undefined>;
286
+ }, undefined>, v.ObjectSchema<{
287
+ readonly id: v.StringSchema<undefined>;
288
+ readonly type: v.LiteralSchema<"created_time", undefined>;
289
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
290
+ }, undefined>, v.ObjectSchema<{
291
+ readonly id: v.StringSchema<undefined>;
292
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
293
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
294
+ }, undefined>, v.ObjectSchema<{
295
+ readonly id: v.StringSchema<undefined>;
296
+ readonly type: v.LiteralSchema<"created_by", undefined>;
297
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
298
+ readonly id: v.StringSchema<undefined>;
299
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
300
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
301
+ }, undefined>, undefined>;
302
+ }, undefined>, v.ObjectSchema<{
303
+ readonly id: v.StringSchema<undefined>;
304
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
305
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
306
+ readonly id: v.StringSchema<undefined>;
307
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
308
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
309
+ }, undefined>, undefined>;
310
+ }, undefined>, v.ObjectSchema<{
311
+ readonly id: v.StringSchema<undefined>;
312
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
313
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
286
314
  }, undefined>], undefined>;
287
315
  export type NotionPagePropertyValue = v.InferOutput<typeof notionPagePropertyValueSchema>;
288
- export declare const notionPagePropertyWriteMapSchema: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
316
+ export declare const notionPagePropertyReadMapSchema: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
289
317
  readonly id: v.StringSchema<undefined>;
290
318
  readonly type: v.LiteralSchema<"title", undefined>;
291
319
  readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
@@ -409,8 +437,39 @@ export declare const notionPagePropertyWriteMapSchema: v.RecordSchema<v.StringSc
409
437
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
410
438
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
411
439
  }, undefined>, undefined>;
440
+ }, undefined>, v.ObjectSchema<{
441
+ readonly id: v.StringSchema<undefined>;
442
+ readonly type: v.LiteralSchema<"created_time", undefined>;
443
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
444
+ }, undefined>, v.ObjectSchema<{
445
+ readonly id: v.StringSchema<undefined>;
446
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
447
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
448
+ }, undefined>, v.ObjectSchema<{
449
+ readonly id: v.StringSchema<undefined>;
450
+ readonly type: v.LiteralSchema<"created_by", undefined>;
451
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
452
+ readonly id: v.StringSchema<undefined>;
453
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
454
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
455
+ }, undefined>, undefined>;
456
+ }, undefined>, v.ObjectSchema<{
457
+ readonly id: v.StringSchema<undefined>;
458
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
459
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
460
+ readonly id: v.StringSchema<undefined>;
461
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
462
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
463
+ }, undefined>, undefined>;
464
+ }, undefined>, v.ObjectSchema<{
465
+ readonly id: v.StringSchema<undefined>;
466
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
467
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
412
468
  }, undefined>], undefined>, undefined>;
413
- export type NotionPagePropertyWriteMap = v.InferOutput<typeof notionPagePropertyWriteMapSchema>;
469
+ export type NotionPagePropertyReadMap = v.InferOutput<typeof notionPagePropertyReadMapSchema>;
470
+ export type NotionPagePropertyWriteMap = Record<string, Exclude<NotionPagePropertyValue, {
471
+ type: "created_time" | "last_edited_time" | "created_by" | "last_edited_by" | "last_visited_time";
472
+ }>>;
414
473
  /**
415
474
  * The `Page` object returned in `createPageResult` messages.
416
475
  */
@@ -559,6 +618,34 @@ export declare const notionPageSchema: v.ObjectSchema<{
559
618
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
560
619
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
561
620
  }, undefined>, undefined>;
621
+ }, undefined>, v.ObjectSchema<{
622
+ readonly id: v.StringSchema<undefined>;
623
+ readonly type: v.LiteralSchema<"created_time", undefined>;
624
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
625
+ }, undefined>, v.ObjectSchema<{
626
+ readonly id: v.StringSchema<undefined>;
627
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
628
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
629
+ }, undefined>, v.ObjectSchema<{
630
+ readonly id: v.StringSchema<undefined>;
631
+ readonly type: v.LiteralSchema<"created_by", undefined>;
632
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
633
+ readonly id: v.StringSchema<undefined>;
634
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
635
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
636
+ }, undefined>, undefined>;
637
+ }, undefined>, v.ObjectSchema<{
638
+ readonly id: v.StringSchema<undefined>;
639
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
640
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
641
+ readonly id: v.StringSchema<undefined>;
642
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
643
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
644
+ }, undefined>, undefined>;
645
+ }, undefined>, v.ObjectSchema<{
646
+ readonly id: v.StringSchema<undefined>;
647
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
648
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
562
649
  }, undefined>], undefined>, undefined>;
563
650
  readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
564
651
  readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -5,6 +5,7 @@
5
5
  * shape the host delivers for messages like `createPageResult`.
6
6
  */
7
7
  import * as v from "valibot";
8
+ import { notionRecordPointerSchema } from "../dataSources/recordPointer.js";
8
9
  import { notionPageIdSchema } from "../ids.js";
9
10
  import { notionParentSchema } from "../parent.js";
10
11
  /**
@@ -117,6 +118,11 @@ const notionPlaceInputSchema = v.object({
117
118
  const pagePropertyBaseSchema = {
118
119
  id: v.string(),
119
120
  };
121
+ const metadataActorSchema = v.nullable(v.object({
122
+ ...notionRecordPointerSchema.entries,
123
+ table: v.picklist(["notion_user", "bot", "organization_bot"]),
124
+ spaceId: v.optional(v.string()),
125
+ }));
120
126
  /**
121
127
  * A page property value.
122
128
  */
@@ -197,8 +203,33 @@ export const notionPagePropertyValueSchema = v.variant("type", [
197
203
  type: v.literal("place"),
198
204
  place: v.nullable(notionPlaceInputSchema),
199
205
  }),
206
+ v.object({
207
+ ...pagePropertyBaseSchema,
208
+ type: v.literal("created_time"),
209
+ created_time: nullableStringSchema,
210
+ }),
211
+ v.object({
212
+ ...pagePropertyBaseSchema,
213
+ type: v.literal("last_edited_time"),
214
+ last_edited_time: nullableStringSchema,
215
+ }),
216
+ v.object({
217
+ ...pagePropertyBaseSchema,
218
+ type: v.literal("created_by"),
219
+ created_by: metadataActorSchema,
220
+ }),
221
+ v.object({
222
+ ...pagePropertyBaseSchema,
223
+ type: v.literal("last_edited_by"),
224
+ last_edited_by: metadataActorSchema,
225
+ }),
226
+ v.object({
227
+ ...pagePropertyBaseSchema,
228
+ type: v.literal("last_visited_time"),
229
+ last_visited_time: nullableStringSchema,
230
+ }),
200
231
  ]);
201
- export const notionPagePropertyWriteMapSchema = v.record(v.string(), notionPagePropertyValueSchema);
232
+ export const notionPagePropertyReadMapSchema = v.record(v.string(), notionPagePropertyValueSchema);
202
233
  /**
203
234
  * The `Page` object returned in `createPageResult` messages.
204
235
  */
@@ -206,7 +237,7 @@ export const notionPageSchema = v.object({
206
237
  object: v.literal("page"),
207
238
  id: notionPageIdSchema,
208
239
  parent: notionParentSchema,
209
- properties: notionPagePropertyWriteMapSchema,
240
+ properties: notionPagePropertyReadMapSchema,
210
241
  created_time: v.optional(v.string()),
211
242
  last_edited_time: v.optional(v.string()),
212
243
  icon: v.optional(notionPageIconSchema),
@@ -1 +1 @@
1
- {"version":3,"file":"validateQueryDataSourceFilter.d.ts","sourceRoot":"","sources":["../../src/queries/validateQueryDataSourceFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAGX,mCAAmC,EAEnC,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAO7H,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,mCAAmC,GAAG,SAAS,EACvD,gBAAgB,EAAE,sBAAsB,GACtC,mCAAmC,GAAG,SAAS,CAajD"}
1
+ {"version":3,"file":"validateQueryDataSourceFilter.d.ts","sourceRoot":"","sources":["../../src/queries/validateQueryDataSourceFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAGX,mCAAmC,EAEnC,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAQ7H,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,mCAAmC,GAAG,SAAS,EACvD,gBAAgB,EAAE,sBAAsB,GACtC,mCAAmC,GAAG,SAAS,CAajD"}
@@ -1,3 +1,5 @@
1
+ import { customBlockRelationFilterOperatorSchema } from "../protocol/messages/queryDataSource.js";
2
+ import { is } from "valibot";
1
3
  import { unreachable } from "../utils.js";
2
4
  export function validateQueryDataSourceFilter(filter, collectionSchema) {
3
5
  if (filter === undefined) {
@@ -46,6 +48,14 @@ function validatePropertyFilter(filter, collectionSchema) {
46
48
  };
47
49
  }
48
50
  }
51
+ if ("relation" in filter &&
52
+ !is(customBlockRelationFilterOperatorSchema, filter.relation)) {
53
+ return {
54
+ code: "invalid_data_source_query_filter",
55
+ message: "Relation filters require a page ID.",
56
+ isRetryable: false,
57
+ };
58
+ }
49
59
  const optionFilter = getOptionFilter(filter);
50
60
  if (optionFilter === undefined ||
51
61
  propertySchema.type !== optionFilter.propertyType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-host",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Reusable host runtime for Notion custom blocks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ export type {
13
13
  CustomBlockOptionFilterOperator,
14
14
  CustomBlockPeopleFilterOperator,
15
15
  CustomBlockPersonFilterValue,
16
+ CustomBlockRelationFilterOperator,
16
17
  CustomBlockStatusFilterOperator,
17
18
  CustomBlockStatusGroupFilterOperator,
18
19
  CustomBlockStatusGroupName,
@@ -29,6 +30,7 @@ export type {
29
30
  NotionFileInput,
30
31
  NotionPageCover,
31
32
  NotionPageIcon,
33
+ NotionPagePropertyReadMap,
32
34
  NotionPagePropertyValue,
33
35
  NotionPagePropertyWriteMap,
34
36
  NotionRichTextItem,
@@ -5,7 +5,9 @@ import type {
5
5
  ResolvedCustomBlockDataSourceFilter,
6
6
  ResolvedCustomBlockDataSourcePropertyFilter,
7
7
  } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
8
+ import { customBlockRelationFilterOperatorSchema } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
8
9
  import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
10
+ import { is } from "valibot"
9
11
  import { unreachable } from "../utils.js"
10
12
 
11
13
  type OptionFilterOperator =
@@ -73,6 +75,17 @@ function validatePropertyFilter(
73
75
  }
74
76
  }
75
77
 
78
+ if (
79
+ "relation" in filter &&
80
+ !is(customBlockRelationFilterOperatorSchema, filter.relation)
81
+ ) {
82
+ return {
83
+ code: "invalid_data_source_query_filter",
84
+ message: "Relation filters require a page ID.",
85
+ isRetryable: false,
86
+ }
87
+ }
88
+
76
89
  const optionFilter = getOptionFilter(filter)
77
90
  if (
78
91
  optionFilter === undefined ||