@notionhq/custom-blocks-host 0.2.10 → 0.2.12
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 +1 -1
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +11 -11
- package/dist/lifecycle/initErrors.d.ts +21 -10
- package/dist/lifecycle/initErrors.d.ts.map +1 -1
- package/dist/lifecycle/initErrors.js +104 -155
- package/dist/lifecycle/initializationController.d.ts.map +1 -1
- package/dist/lifecycle/initializationController.js +11 -9
- package/dist/messages/sandboxMessageRouter.d.ts.map +1 -1
- package/dist/messages/sandboxMessageRouter.js +3 -3
- package/package.json +1 -1
- package/src/createCustomBlockHost.ts +18 -13
- package/src/lifecycle/initErrors.ts +120 -166
- package/src/lifecycle/initializationController.ts +21 -15
- package/src/messages/sandboxMessageRouter.ts +6 -3
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function gr(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=br({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function br(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=Je(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||Je(y.name)===c));return l.length===1?l[0][0]:void 0}function Je(e){return e.trim().toLowerCase()}var Re,kr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function qe(e){return!e&&!Re?kr:{lang:e?.lang??Re?.lang,message:e?.message,abortEarly:e?.abortEarly??Re?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Re?.abortPipeEarly}}var Sr;function Ir(e){return Sr?.get(e)}var _r;function xr(e){return _r?.get(e)}var Cr;function Or(e,o){return Cr?.get(e)?.get(o)}function be(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 R(e,o,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??be(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??Or(e.reference,m.lang)??(S?xr(m.lang):null)??s.message??Ir(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 Ke=new WeakMap;function F(e){let o=Ke.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},qe())}},Ke.set(e,o)),o}function jr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function Ne(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var Er=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function re(e){return{kind:"transformation",type:"brand",reference:re,async:!1,name:e,"~run"(o){return o}}}function ke(e){return{kind:"validation",type:"finite",reference:ke,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(o,n){return o.typed&&!this.requirement(o.value)&&R(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&&R(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,o){return{kind:"validation",type:"min_length",reference:Se,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&R(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Ie(e,o){return{kind:"validation",type:"min_value",reference:Ie,async:!1,expects:`>=${e instanceof Date?e.toJSON():be(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&R(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():be(n.value)}),n}}}var Pr={abortEarly:!0};function Ye(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 j(e,o){return{kind:"schema",type:"array",reference:j,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else R(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:R(this,"type",o,n),o}}}function i(e,o){return{kind:"schema",type:"literal",reference:i,expects:be(e),async:!1,literal:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:R(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"(o,n){return Number.isNaN(o.value)?o.typed=!0:R(this,"type",o,n),o}}}function Z(e,o){return{kind:"schema",type:"nullable",reference:Z,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function O(e){return{kind:"schema",type:"number",reference:O,expects:"number",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:R(this,"type",o,n),o}}}function r(e,o){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]: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]=Ye(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(R(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 R(this,"type",n,s);return n}}}function a(e,o){return{kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function w(e,o){return{kind:"schema",type:"picklist",reference:w,expects:Ne(e.map(be),"|"),async:!1,options:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:R(this,"type",n,s),n}}}function U(e,o,n){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(jr(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 P of m.issues)P.path=[I],s.issues?.push(P);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 P of S.issues)P.path?P.path.unshift(I):P.path=[I],s.issues?.push(P);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 R(this,"type",s,c);return s}}}function p(e,o){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]: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]=Ye(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(R(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)){R(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else R(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:R(this,"type",o,n),o}}}function Ze(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:Ne(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];R(this,"type",n,s,{issues:Ze(l)}),n.typed=!0}else{if(f?.length===1)return f[0];R(this,"type",n,s,{issues:Ze(f)})}return n}}}function _e(){return{kind:"schema",type:"unknown",reference:_e,expects:"unknown",async:!1,get"~standard"(){return F(this)},"~run"(e){return e.typed=!0,e}}}function h(e,o,n){return{kind:"schema",type:"variant",reference:h,expects:"Object",async:!1,key:e,options:o,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(P,k)=>{for(let L of P.options){if(L.type==="variant")I(L,new Set(k).add(L.key));else{let J=!0,T=0;for(let B of k){let q=L.entries[B];if(B in l?q["~run"]({typed:!1,value:l[B]},Pr).issues:q.type!=="exact_optional"&&q.type!=="optional"&&q.type!=="nullish"){J=!1,m!==B&&(y<T||y===T&&B in l&&!(m in l))&&(y=T,m=B,S=[]),m===B&&S.push(L.entries[B].expects);break}T++}if(J){let B=L["~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;R(this,"type",s,c,{input:l[m],expected:Ne(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else R(this,"type",s,c);return s}}}function et(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return F(this)}}}function me(e,o,n){let s=e["~run"]({value:o},qe(n));if(s.issues)throw new Er(s.issues);return s.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return F(this)},"~run"(o,n){for(let s of e)if(s.kind!=="metadata"){if(o.issues&&(s.kind==="schema"||s.kind==="transformation")){o.typed=!1;break}(!o.issues||!n.abortEarly&&!n.abortPipeEarly)&&(o=s["~run"](o,n))}return o}}}function xe(e,o,n){let s=e["~run"]({value:o},qe(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var ne=z(t(),re("NotionBlockId")),Y=z(t(),re("NotionDataSourceId")),H=z(t(),re("NotionPageId")),tt=z(t(),re("NotionAgentId")),rt=z(t(),re("NotionSpaceId"));var nt=w(["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(nt),description:a(t())}),Br=r({id:t(),name:t(),color:a(nt),option_ids:j(t())}),Rr=r({synced_property_id:t(),synced_property_name:t()}),E=r({name:t(),description:a(t())}),Mr=["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"],ot=w(Mr),it=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time"],ze=h("type",[r({...E.entries,type:i("title")}),r({...E.entries,type:i("rich_text")}),r({...E.entries,type:i("number")}),r({...E.entries,type:i("checkbox")}),r({...E.entries,type:i("url")}),r({...E.entries,type:i("email")}),r({...E.entries,type:i("phone_number")}),r({...E.entries,type:i("select"),options:j(Ue)}),r({...E.entries,type:i("multi_select"),options:j(Ue)}),r({...E.entries,type:i("status"),options:j(Ue),groups:j(Br)}),r({...E.entries,type:i("date")}),r({...E.entries,type:i("people")}),r({...E.entries,type:i("files")}),r({...E.entries,type:i("unique_id")}),r({...E.entries,type:i("relation"),data_source_id:a(t()),dual_property:a(Rr)}),r({...E.entries,type:i("place")}),r({...E.entries,type:i("formula")}),r({...E.entries,type:i("rollup")}),r({...E.entries,type:i("button")}),r({...E.entries,type:i("verification")}),r({...E.entries,type:i("last_visited_time")}),r({...E.entries,type:i("location")}),r({...E.entries,type:i("created_time")}),r({...E.entries,type:i("last_edited_time")}),r({...E.entries,type:i("created_by")}),r({...E.entries,type:i("last_edited_by")})]);var st={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 ut=r({id:Y,table:t(),spaceId:a(rt)}),at=r({id:a(Y),propertiesById:U(t(),ze)}),Wn=r({key:t(),collectionPointer:a(ut),collectionSchema:a(at),propertyIdsByKey:U(t(),a(t())),propertySchemasById:U(t(),ze)}),Dr=r({collectionPointer:a(ut),collectionSchema:a(at),propertyIdsByKey:a(U(t(),a(t())))}),pe=U(t(),Dr);var wr=h("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),Ar=r({name:t(),description:a(t()),type:ot}),Tr=r({name:t(),description:a(t()),icon:a(wr),properties:a(U(t(),Ar),{})}),fe=r({version:i(1),dataSources:U(t(),Tr)});var ye=w(["standard","high"]),ct="standard";var lt=r({type:i("contrastModeChanged"),contrastMode:ye});var oe=h("type",[r({type:i("page_id"),page_id:H}),r({type:i("data_source_id"),data_source_id:Y}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:ne}),r({type:i("agent_id"),agent_id:tt}),r({type:i("unavailable")})]);var ve=h("type",[r({type:i("unavailable")}),r({type:i("page"),id:H,parent:oe})]),qr=r({type:i("emoji"),emoji:t()}),Nr=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:a(t()),url:a(t())})}),ft=r({type:i("external"),external:r({url:t()})}),mt=r({type:i("file"),file:r({url:t(),expiry_time:a(t())})}),Ge=h("type",[qr,Nr,ft,mt]),Le=h("type",[ft,mt]),W=Z(t()),pt=U(t(),_e()),He=_([r({id:t(),name:a(t()),color:a(t()),description:a(W)}),r({name:t(),id:a(t()),color:a(t()),description:a(W)})]),Fr=r({start:t(),end:a(W),time_zone:a(W)}),Ur=_([r({object:a(i("user")),id:t()}),r({object:i("group"),id:t(),name:a(W)})]),zr=r({id:t()}),Hr=_([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:a(t())})})]),Gr=r({lat:O(),lon:O(),name:a(W),address:a(W),aws_place_id:a(W),google_place_id:a(W)}),V={id:t()},Lr=h("type",[r({...V,type:i("title"),title:j(pt)}),r({...V,type:i("rich_text"),rich_text:j(pt)}),r({...V,type:i("number"),number:Z(O())}),r({...V,type:i("url"),url:W}),r({...V,type:i("email"),email:W}),r({...V,type:i("phone_number"),phone_number:W}),r({...V,type:i("checkbox"),checkbox:b()}),r({...V,type:i("select"),select:Z(He)}),r({...V,type:i("status"),status:Z(He)}),r({...V,type:i("multi_select"),multi_select:j(He)}),r({...V,type:i("date"),date:Z(Fr)}),r({...V,type:i("people"),people:j(Ur)}),r({...V,type:i("relation"),has_more:a(b()),relation:j(zr)}),r({...V,type:i("files"),files:j(Hr)}),r({...V,type:i("place"),place:Z(Gr)})]),Ce=U(t(),Lr),de=r({object:i("page"),id:H,parent:oe,properties:Ce,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 Vr=t(),Qr=r({code:Vr,message:t(),isRetryable:b()}),yt=h("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:de}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:Qr})]);var Ve=z(t(),re("NotionUserId")),ie=r({object:i("user"),id:Ve,name:a(t()),avatar_url:Z(t()),type:i("person"),person:r({email:t()})}),vt=r({object:i("list"),results:j(ie),next_cursor:Z(t()),has_more:b(),type:i("user"),user:U(t(),_e())});var dt=r({type:i("currentUserChanged"),currentUser:ie});var ht=r({type:i("dataSourcesChanged"),dataSources:r({bindings:pe})});var $r=t(),Xr=r({code:$r,message:t(),isRetryable:b()}),gt=r({type:i("getPage"),requestId:t(),pageId:H}),bt=h("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:de}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:Xr})]);var Wr=t(),Jr=r({code:Wr,message:t(),isRetryable:b()}),kt=r({type:i("getUser"),requestId:t(),userId:Ve}),St=h("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:ie}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:Jr})]);var he=w(["light","dark"]);var Kr=t(),Zr=r({code:Kr,message:t(),isRetryable:b()});var we=h("status",[r({type:i("init"),initializationId:t(),status:i("success"),theme:he,contrastMode:ye,blockId:ne,parent:oe,page:ve,manifest:fe,dataSources:r({bindings:pe}),currentUser:ie}),r({type:i("init"),initializationId:t(),status:i("error"),error:Zr})]);var It=r({type:i("invalidSandboxMessage"),reason:t()});var Yr=t(),en=r({code:Yr,message:t(),isRetryable:b()}),_t=r({type:i("listUsers"),requestId:t(),startCursor:a(t()),pageSize:a(O())}),xt=h("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:vt}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:en})]);var tn=w(["side_peek","center_peek"]),rn=t(),nn=r({code:rn,message:t(),isRetryable:b()}),Ct=r({type:i("openPage"),requestId:t(),pageId:H,mode:tn}),Ot=h("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:H}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:nn})]);var jt=r({type:i("pageChanged"),page:ve});var Et=r({type:i("parentChanged"),parent:oe});var Pt=r({unit:w(["year","month","week","day"]),value:O(),time:t(),defaultTimeZone:a(t())}),on=r({unit:w(["hour","minute"]),value:O()}),Bt=r({unit:i("none")}),sn=_([Pt,on]),Rt=a(_([Pt,Bt])),Mt=a(_([sn,Bt])),un=r({type:i("date"),start_date:t(),reminder:Rt}),an=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:Rt}),cn=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:a(t()),reminder:Mt}),ln=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:a(t()),reminder:Mt}),Dt=h("type",[un,an,cn,ln]);var wt=r({id:t(),table:t()});var At=_([t(),O(),b(),Dt,j(t()),j(wt)]);var Tt=r({id:H,is_archived:b(),in_trash:b(),propertiesById:U(t(),a(At))});var pn=t(),fn=r({code:pn,message:t(),isRetryable:b()}),qt=h("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:j(Tt),hasMore:b()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:fn})]);var Nt=r({type:i("themeChanged"),theme:he});var mn=t(),yn=r({code:mn,message:t(),isRetryable:b()}),Ft=h("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:de}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:yn})]);var Ut=h("type",[we,Nt,lt,Et,jt,dt,ht,qt,yt,bt,St,xt,Ot,Ft,It]);var zt="Unexpected error while initializing custom block.";function G(e,o={}){switch(e){case"no_connect":return{code:e,message:"Sandbox did not send a connect message.",isRetryable:!0};case"invalid_connect_payload":return{code:e,message:"Sandbox sent an invalid connect message.",isRetryable:!1};case"manifest_unavailable":return{code:e,message:"The custom block manifest is unavailable.",isRetryable:!0};case"manifest_invalid":return{code:e,message:"Sandbox sent an invalid manifest.",isRetryable:!1};case"invalid_protocol_version":{let n=o.currentBridgeProtocolVersion?`: ${o.currentBridgeProtocolVersion}`:".";return{code:e,message:`Sandbox reported an invalid bridge protocol version ${n}`,isRetryable:!1}}case"unsupported_protocol_version":{let n=o.currentBridgeProtocolVersion?`${o.currentBridgeProtocolVersion} `:"",s=o.minBridgeProtocolVersion?` Minimum supported version is ${o.minBridgeProtocolVersion}.`:"";return{code:e,message:`Sandbox bridge protocol version ${n}is not supported.${s}`,isRetryable:!1}}case"init_timeout":return{code:e,message:"Host dependencies did not finish loading before the timeout.",isRetryable:!0};case"context_unavailable":return{code:e,message:"Host page context is unavailable.",isRetryable:!0};case"current_user_unavailable":return{code:e,message:"Current user is unavailable.",isRetryable:!0};case"initial_state_timeout":return{code:e,message:"Host did not prepare initial state before the timeout.",isRetryable:!0};case"missing_data_source_binding":return{code:e,message:"A required data source is not mapped.",isRetryable:!1};case"data_source_unavailable":return{code:e,message:"A mapped data source is unavailable.",isRetryable:!0};case"missing_property_binding":return{code:e,message:"A required data source property is not mapped.",isRetryable:!1};case"invalid_property_binding":return{code:e,message:"A mapped data source property is missing or incompatible.",isRetryable:!1};case"no_init_result":return{code:e,message:"Sandbox did not acknowledge initialization.",isRetryable:!0};case"invalid_init_result_payload":return{code:e,message:"Sandbox sent an invalid initialization result.",isRetryable:!1};case"invalid_init_bindings":return{code:e,message:"Sandbox rejected the host-provided data source bindings.",isRetryable:!1};case"not_in_iframe":return{code:e,message:"<NotionCustomBlock> only works inside an iframe.",isRetryable:!1};case"unknown_error":return{code:e,message:zt,isRetryable:!1};default:return console.warn(`Unexpected custom block init error: ${e}`),{code:e,message:zt,isRetryable:!1}}}function se(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function Qe(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var vn=5e3,dn=5e3,hn=5e3;function Ht(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=vn,initialStateTimeoutMs:y=dn,noInitResultTimeoutMs:m=hn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:P}=e,k="waitingForConnect",L,J,T,B,q=!1,ue=!1;function X(){L!==void 0&&(window.clearTimeout(L),L=void 0)}function M(){J!==void 0&&(window.clearTimeout(J),J=void 0)}function N(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function A(g){let{initializationId:v,error:Q}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return se(k)}k="error",B=v,X(),M(),n({type:"init",initializationId:v,status:"error",error:Q}),P?.(Q)}async function K(g){if(k==="waitingForConnect"){k="preparingInit",B=g.initializationId,X(),J=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=G("initial_state_timeout");s({...v,initializationId:g.initializationId}),A({initializationId:g.initializationId,error:v})},y);try{let v=await o(g);if(k!=="preparingInit")return;if(M(),v.status==="error"){A({initializationId:g.initializationId,error:v.error});return}k="waitingForInitResult";let Q={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??ct,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(Q),T=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let te=G("no_init_result");P?.(te),s({...te,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:G("unknown_error")})}}}function ee(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!Qe(g.bridgeProtocolVersion)){let v=G("invalid_protocol_version",{currentBridgeProtocolVersion:g.bridgeProtocolVersion});A({initializationId:g.initializationId,error:v});return}if(g.bridgeProtocolVersion<l){let v=G("unsupported_protocol_version",{currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});A({initializationId:g.initializationId,error:v});return}if(g.status==="error"){A({initializationId:g.initializationId,error:g.error});return}ue=!0,K(g)}}function x(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:Q}=g;if(v===void 0)return"nack";let te=g.error;return Q!==void 0&&(Qe(Q)?Q<l&&(te=G("unsupported_protocol_version",{currentBridgeProtocolVersion:Q,minBridgeProtocolVersion:l})):te=G("invalid_protocol_version")),A({initializationId:v,error:te}),"handled"}function ae(g){let{initializationId:v,error:Q}=g;k!=="waitingForInitResult"||v===void 0||v!==B||(X(),N(),k="error",s(Q),P?.(Q))}function Be(){if(k!=="stopped"){if(q){S({code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}q=!0,X(),k==="waitingForConnect"&&(L=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=G("no_connect");s(g),P?.(g)},f))}}function ge(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():P?.(g.error),I?.(g)}function ce(){k="stopped",X(),M(),N()}return{get status(){return k},get hasConnectedSandbox(){return ue},handleConnect:ee,handleInitResult:ge,handleInvalidConnect:x,handleInvalidInitResult:ae,onIframeLoad:Be,stop:ce}}function Gt(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,...st}}}]))}}}var Lt=r({theme:he,contrastMode:a(ye),blockId:ne,parent:oe,page:ve,manifest:fe,dataSources:r({bindings:pe}),currentUser:ie});function Vt(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Qt=r({code:t(),message:t(),isRetryable:b()});var $t={type:i("connect"),initializationId:t(),bridgeProtocolVersion:O(),sdkVersion:t()},Xt=h("status",[r({status:i("success"),manifest:a(fe),...$t}),r({status:i("error"),error:Qt,...$t})]);var gn=h("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:ne}),r({type:i("after"),blockId:ne})]),bn=h("type",[r({type:i("page_id"),page_id:H}),r({type:i("data_source_id"),data_source_id:Y})]),Wt=r({type:i("createPage"),requestId:t(),parent:bn,properties:Ce,position:a(gn)});var kn=t(),Sn=r({code:kn,message:t(),isRetryable:b()}),Jt=h("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:a(z(O(),ke(),Ie(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Sn})]);var Kt=r({type:i("invalidHostMessage"),reason:t()});var Pe=_([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ee=_([t(),j(t())]),Zt=p({object:w(["user","group"]),id:z(t(),Se(1))}),In=_([p({contains:Zt}),p({does_not_contain:Zt}),Pe]),Yt=p({object:i("user"),id:z(t(),Se(1),Me(2e3))}),_n=_([p({contains:Yt}),p({does_not_contain:Yt}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Oe=_([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]),xn=_([p({equals:O()}),p({does_not_equal:O()}),p({greater_than:O()}),p({less_than:O()}),p({greater_than_or_equal_to:O()}),p({less_than_or_equal_to:O()}),Pe]),Cn=_([p({equals:b()}),p({does_not_equal:b()})]),nr=_([p({equals:Ee}),p({does_not_equal:Ee}),Pe]),er=w(["To-do","In progress","Complete","Current","Future"]),tr=_([er,z(j(er),Se(1),Me(5))]),On=_([p({group_equals:tr}),p({group_does_not_equal:tr})]),jn=_([nr,On]),En=_([p({contains:Ee}),p({contains_all:Ee}),p({does_not_contain:Ee}),Pe]),$=w(["start_date","end_date"]),Pn=w(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),je=_([Pn,t()]),Bn=_([p({target:a($),equals:je}),p({target:a($),before:je}),p({target:a($),after:je}),p({target:a($),on_or_before:je}),p({target:a($),on_or_after:je}),p({target:a($),this_week:p({})}),p({target:a($),past_week:p({})}),p({target:a($),past_month:p({})}),p({target:a($),past_year:p({})}),p({target:a($),next_week:p({})}),p({target:a($),next_month:p({})}),p({target:a($),next_year:p({})}),p({target:a($),is_empty:i(!0)}),p({target:a($),is_not_empty:i(!0)})]),rr=_([p({propertyId:t(),created_by:_n}),p({propertyId:t(),title:Oe}),p({propertyId:t(),rich_text:Oe}),p({propertyId:t(),url:Oe}),p({propertyId:t(),email:Oe}),p({propertyId:t(),phone_number:Oe}),p({propertyId:t(),number:xn}),p({propertyId:t(),checkbox:Cn}),p({propertyId:t(),select:nr}),p({propertyId:t(),multi_select:En}),p({propertyId:t(),status:jn}),p({propertyId:t(),date:Bn}),p({propertyId:t(),people:In})]),Rn=_([rr,p({and:j(rr)})]),$e=10,Mn=p({propertyId:t(),direction:w(["ascending","descending"])}),or=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Y,limit:O(),filter:a(Rn),sorts:a(j(Mn))});var ir=r({type:i("resize"),height:z(O(),ke(),Ie(0))});var sr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var ur=r({type:i("updatePage"),requestId:t(),pageId:H,properties:a(Ce),icon:a(Ge),cover:a(Le),archived:a(b())});var ar=h("type",[Xt,Jt,or,sr,Wt,gt,kt,_t,Ct,ur,ir,Kt]);function cr(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function lr(e){let o=cr(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Dn(o)}}}function Dn(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var pr=r({initializationId:t()}),wn=r({bridgeProtocolVersion:_([O(),Fe()])});function fr(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:P,onCreatePage:k,onGetPage:L,onOpenPage:J,onGetUser:T,onListUsers:B,onUpdatePage:q,onResize:ue}=e;function X(M,N){c("warn",{message:"Ignored unsupported sandbox message",payload:M,issues:N});let A=lr(M);if(A.incomingType==="connect"){let K=xe(pr,M),ee=xe(wn,M);if(f({initializationId:K.success?K.output.initializationId:void 0,error:G("invalid_connect_payload"),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(A.incomingType==="initResult"){let K=xe(pr,M);y({initializationId:K.success?K.output.initializationId:void 0,error:G("invalid_init_result_payload")})}A.nack!==void 0&&s()!=="stopped"&&l(A.nack)}return function(N){let A=N.source===o.contentWindow,K=N.origin===n;if(!A||!K)return;let ee=xe(ar,N.data);if(!ee.success){X(N.data,ee.issues);return}let x=ee.output;if(!Vt(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":P(x);return;case"createPage":k(x);return;case"openPage":J(x);return;case"getPage":L(x);return;case"getUser":T(x);return;case"listUsers":B(x);return;case"updatePage":q(x);return;case"resize":ue(x);return;case"invalidHostMessage":return;default:se(x)}}}var Ae=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 mr(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=An(s,o);if(c!==void 0)return c}}function An(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(P=>!n.groups.some(k=>k.name===P));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}let c=Tn(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=qn(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 Tn(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 qn(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?[]:se(e);return Array.isArray(o)?o:[o]}var Nn=new Set(it);function yr(e,o){if(e===void 0)return;if(e.length>$e)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${$e} 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(!Nn.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 dr=5;function Un(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:P,initialStateTimeoutMs:k,noInitResultTimeoutMs:L}=e,J=Math.max(I??3,3),T={},B=!1,q,ue,X=5,M=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 se(C)}let D=Gt(u,X);N("out",D),o.contentWindow?.postMessage(D,S)}function K(u){A(me(we,u))}function ee(u){A(u)}function x(u){let C=v.status;switch(C){case"initialized":A(me(Ut,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:se(C)}}async function ae(u,C){if(C===void 0)return;let D=await C(u);x({type:`${u.type}Result`,requestId:u.requestId,...D})}function Be(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};x(C)}async function ge(u,C=M.subscribe(u)){try{let D=zn(ue,u.dataSourceId),le=Hn(u,D);if(le!==void 0){M.isCurrent(u.subscriptionId,C)&&(M.unsubscribe(u.subscriptionId),Be({subscriptionId:u.subscriptionId,response:{status:"error",error:le}}));return}let Te=await s.queryDataSource(u);if(!M.isCurrent(u.subscriptionId,C))return;Te.status==="error"&&!Te.error.isRetryable&&M.unsubscribe(u.subscriptionId),Be({subscriptionId:u.subscriptionId,response:Te})}finally{let D=M.finish(u.subscriptionId,C);D!==void 0&&ge(D.message,D.token)}}function ce(u){v.status==="stopped"||v.status==="error"||(Object.assign(T,u),g())}function g(){if(v.status!=="initialized")return;let u=T;T={},u.theme!==void 0&&x({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&x({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&x({type:"parentChanged",parent:u.parent}),u.page!==void 0&&x({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&x({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&x({type:"currentUserChanged",currentUser:u.currentUser})}let v=Ht({async prepareInit(u){X=u.bridgeProtocolVersion;let C=await n(u);return v.status!=="preparingInit"?C:Q(C)},sendInitMessage:K,warn:u=>N("warn",u),flushPendingHostStateChanges:g,minBridgeProtocolVersion:J,noConnectTimeoutMs:P,initialStateTimeoutMs:k,noInitResultTimeoutMs:L,stopHostWithFailure:We,onInitResult(u){u.status==="success"&&q!==void 0&&l?.({manifest:q,initialHeight:u.initialHeight})},onConnectionFailure:f});function Q(u){if(u.status==="error")return u;q=me(fe,u.initialState.manifest),c?.(q);let C={...u.initialState,...T};T={};let D={...me(et(Lt,["manifest"]),C),manifest:q};if(X<dr&&D.page.type==="unavailable")return{status:"error",error:G("context_unavailable")};let le=hr(D.manifest,D.dataSources);return le!==void 0?{status:"error",error:G(le)}:(ue=D.dataSources,B=!0,{status:"success",initialState:D})}let te=fr({iframe:o,sandboxOrigin:S,getInitStatus:()=>v.status,emit:N,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:ge,onUnsubscribeDataSourceQuery:u=>M.unsubscribe(u.subscriptionId),onCreatePage:u=>ae(u,s.createPage),onGetPage:u=>ae(u,s.getPage),onOpenPage:u=>ae(u,s.openPage),onGetUser:u=>ae(u,s.getUser),onListUsers:u=>ae(u,s.listUsers),onUpdatePage:u=>ae(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",te),o.addEventListener("load",v.onIframeLoad);function Xe(){window.removeEventListener("message",te),o.removeEventListener("load",v.onIframeLoad),v.stop(),M.unsubscribeAll()}function We(u){Xe(),N("warn",u),f?.(u)}return{stop:Xe,setTheme(u){ce({theme:u})},setContrastMode(u){ce({contrastMode:u})},setParent(u){ce({parent:u})},setPage(u){if(u.type==="unavailable"&&X<dr&&(v.status==="preparingInit"&&B||v.status==="waitingForInitResult"||v.status==="initialized")){We(G("context_unavailable"));return}ce({page:u})},setCurrentUser(u){ce({currentUser:u})},setDataSources(u){let C={bindings:me(pe,u.bindings)};if(v.hasConnectedSandbox&&q!==void 0&&hr(q,C)!==void 0){N("warn",{message:"Ignored invalid data source bindings update",payload:C});return}ue=C,ce({dataSources:C})},refreshQuery({dataSourceId:u}){if(v.status!=="initialized")return;let C=me(Y,u),D=M.refresh(C);if(D===void 0){N("warn",`No active query exists for data source "${u}"`);return}for(let le of D)ge(le.message,le.token)}}}function zn(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function hr(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"missing_data_source_binding";for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return"missing_property_binding";if(c.collectionSchema.propertiesById[y]?.type!==f.type)return"invalid_property_binding"}}}function Hn(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}:mr(e.filter,o)??yr(e.sorts,o)}export{Un as createCustomBlockHost,gr as getAutoBoundPropertyIdsByKey};
|
|
1
|
+
function Pr(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=jr({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function jr(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=Ze(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||Ze(y.name)===c));return l.length===1?l[0][0]:void 0}function Ze(e){return e.trim().toLowerCase()}var Be,Br={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Te(e){return!e&&!Be?Br:{lang:e?.lang??Be?.lang,message:e?.message,abortEarly:e?.abortEarly??Be?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Be?.abortPipeEarly}}var Mr;function Rr(e){return Mr?.get(e)}var Dr;function wr(e){return Dr?.get(e)}var Ar;function Tr(e,o){return Ar?.get(e)?.get(o)}function ge(e){let o=typeof e;return o==="string"?`"${e}"`:o==="number"||o==="bigint"||o==="boolean"?`${e}`:o==="object"||o==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":o}function M(e,o,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${o}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},S=e.kind==="schema",I=c?.message??e.message??Tr(e.reference,m.lang)??(S?wr(m.lang):null)??s.message??Rr(m.lang);I!==void 0&&(m.message=typeof I=="function"?I(m):I),S&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var Ye=new WeakMap;function F(e){let o=Ye.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Te())}},Ye.set(e,o)),o}function qr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function qe(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var Nr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(o){return o}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(o,n){return o.typed&&!this.requirement(o.value)&&M(this,"finite",o,n),o}}}function Me(e,o){return{kind:"validation",type:"max_length",reference:Me,async:!1,expects:`<=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,o){return{kind:"validation",type:"min_length",reference:ke,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,o){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&M(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}var Fr={abortEarly:!0};function tt(e,o,n){return typeof e.fallback=="function"?e.fallback(o,n):e.fallback}function Re(e,o,n){return typeof e.default=="function"?e.default(o,n):e.default}function O(e,o){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else M(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:M(this,"type",o,n),o}}}function i(e,o){return{kind:"schema",type:"literal",reference:i,expects:ge(e),async:!1,literal:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:M(this,"type",n,s),n}}}function Ne(e){return{kind:"schema",type:"nan",reference:Ne,expects:"NaN",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:M(this,"type",o,n),o}}}function K(e,o){return{kind:"schema",type:"nullable",reference:K,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=Re(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function E(e){return{kind:"schema",type:"number",reference:E,expects:"number",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:M(this,"type",o,n),o}}}function r(e,o){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:Re(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",n,s);return n}}}function a(e,o){return{kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return F(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=Re(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function w(e,o){return{kind:"schema",type:"picklist",reference:w,expects:qe(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:M(this,"type",n,s),n}}}function U(e,o,n){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(qr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let I={type:"object",origin:"key",input:l,key:f,value:y};for(let j of m.issues)j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let S=this.value["~run"]({value:y},c);if(S.issues){let I={type:"object",origin:"value",input:l,key:f,value:y};for(let j of S.issues)j.path?j.path.unshift(I):j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=S.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!S.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=S.value)}}else M(this,"type",s,c);return s}}}function p(e,o){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:Re(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){M(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return F(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:M(this,"type",o,n),o}}}function et(e){let o;if(e)for(let n of e)if(o)for(let s of n.issues)o.push(s);else o=n.issues;return o}function x(e,o){return{kind:"schema",type:"union",reference:x,expects:qe(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return F(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",n,s,{issues:et(l)}),n.typed=!0}else{if(f?.length===1)return f[0];M(this,"type",n,s,{issues:et(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return F(this)},"~run"(e){return e.typed=!0,e}}}function h(e,o,n){return{kind:"schema",type:"variant",reference:h,expects:"Object",async:!1,key:e,options:o,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(j,k)=>{for(let G of j.options){if(G.type==="variant")I(G,new Set(k).add(G.key));else{let W=!0,T=0;for(let B of k){let q=G.entries[B];if(B in l?q["~run"]({typed:!1,value:l[B]},Fr).issues:q.type!=="exact_optional"&&q.type!=="optional"&&q.type!=="nullish"){W=!1,m!==B&&(y<T||y===T&&B in l&&!(m in l))&&(y=T,m=B,S=[]),m===B&&S.push(G.entries[B].expects);break}T++}if(W){let B=G["~run"]({value:l},c);(!f||!f.typed&&B.typed)&&(f=B)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;M(this,"type",s,c,{input:l[m],expected:qe(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else M(this,"type",s,c);return s}}}function rt(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return F(this)}}}function fe(e,o,n){let s=e["~run"]({value:o},Te(n));if(s.issues)throw new Nr(s.issues);return s.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return F(this)},"~run"(o,n){for(let s of e)if(s.kind!=="metadata"){if(o.issues&&(s.kind==="schema"||s.kind==="transformation")){o.typed=!1;break}(!o.issues||!n.abortEarly&&!n.abortPipeEarly)&&(o=s["~run"](o,n))}return o}}}function xe(e,o,n){let s=e["~run"]({value:o},Te(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var re=z(t(),te("NotionBlockId")),Z=z(t(),te("NotionDataSourceId")),H=z(t(),te("NotionPageId")),nt=z(t(),te("NotionAgentId")),ot=z(t(),te("NotionSpaceId"));var it=w(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),Fe=r({id:t(),name:t(),color:a(it),description:a(t())}),Ur=r({id:t(),name:t(),color:a(it),option_ids:O(t())}),zr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:a(t())}),Hr=["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=w(Hr),ut=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time"],Ue=h("type",[r({...P.entries,type:i("title")}),r({...P.entries,type:i("rich_text")}),r({...P.entries,type:i("number")}),r({...P.entries,type:i("checkbox")}),r({...P.entries,type:i("url")}),r({...P.entries,type:i("email")}),r({...P.entries,type:i("phone_number")}),r({...P.entries,type:i("select"),options:O(Fe)}),r({...P.entries,type:i("multi_select"),options:O(Fe)}),r({...P.entries,type:i("status"),options:O(Fe),groups:O(Ur)}),r({...P.entries,type:i("date")}),r({...P.entries,type:i("people")}),r({...P.entries,type:i("files")}),r({...P.entries,type:i("unique_id")}),r({...P.entries,type:i("relation"),data_source_id:a(t()),dual_property:a(zr)}),r({...P.entries,type:i("place")}),r({...P.entries,type:i("formula")}),r({...P.entries,type:i("rollup")}),r({...P.entries,type:i("button")}),r({...P.entries,type:i("verification")}),r({...P.entries,type:i("last_visited_time")}),r({...P.entries,type:i("location")}),r({...P.entries,type:i("created_time")}),r({...P.entries,type:i("last_edited_time")}),r({...P.entries,type:i("created_by")}),r({...P.entries,type:i("last_edited_by")})]);var at={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var ct=r({id:Z,table:t(),spaceId:a(ot)}),lt=r({id:a(Z),propertiesById:U(t(),Ue)}),io=r({key:t(),collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:U(t(),a(t())),propertySchemasById:U(t(),Ue)}),Gr=r({collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:a(U(t(),a(t())))}),le=U(t(),Gr);var Lr=h("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),Vr=r({name:t(),description:a(t()),type:st}),Qr=r({name:t(),description:a(t()),icon:a(Lr),properties:a(U(t(),Vr),{})}),pe=r({version:i(1),dataSources:U(t(),Qr)});var me=w(["standard","high"]),pt="standard";var ft=r({type:i("contrastModeChanged"),contrastMode:me});var ne=h("type",[r({type:i("page_id"),page_id:H}),r({type:i("data_source_id"),data_source_id:Z}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:re}),r({type:i("agent_id"),agent_id:nt}),r({type:i("unavailable")})]);var ye=h("type",[r({type:i("unavailable")}),r({type:i("page"),id:H,parent:ne})]),$r=r({type:i("emoji"),emoji:t()}),Xr=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:a(t()),url:a(t())})}),yt=r({type:i("external"),external:r({url:t()})}),vt=r({type:i("file"),file:r({url:t(),expiry_time:a(t())})}),He=h("type",[$r,Xr,yt,vt]),Ge=h("type",[yt,vt]),X=K(t()),mt=U(t(),Ie()),ze=x([r({id:t(),name:a(t()),color:a(t()),description:a(X)}),r({name:t(),id:a(t()),color:a(t()),description:a(X)})]),Wr=r({start:t(),end:a(X),time_zone:a(X)}),Jr=x([r({object:a(i("user")),id:t()}),r({object:i("group"),id:t(),name:a(X)})]),Kr=r({id:t()}),Zr=x([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:a(t())})})]),Yr=r({lat:E(),lon:E(),name:a(X),address:a(X),aws_place_id:a(X),google_place_id:a(X)}),L={id:t()},en=h("type",[r({...L,type:i("title"),title:O(mt)}),r({...L,type:i("rich_text"),rich_text:O(mt)}),r({...L,type:i("number"),number:K(E())}),r({...L,type:i("url"),url:X}),r({...L,type:i("email"),email:X}),r({...L,type:i("phone_number"),phone_number:X}),r({...L,type:i("checkbox"),checkbox:b()}),r({...L,type:i("select"),select:K(ze)}),r({...L,type:i("status"),status:K(ze)}),r({...L,type:i("multi_select"),multi_select:O(ze)}),r({...L,type:i("date"),date:K(Wr)}),r({...L,type:i("people"),people:O(Jr)}),r({...L,type:i("relation"),has_more:a(b()),relation:O(Kr)}),r({...L,type:i("files"),files:O(Zr)}),r({...L,type:i("place"),place:K(Yr)})]),_e=U(t(),en),ve=r({object:i("page"),id:H,parent:ne,properties:_e,created_time:a(t()),last_edited_time:a(t()),icon:a(He),cover:a(Ge),url:a(t()),public_url:a(t()),is_archived:b(),in_trash:b()});var tn=t(),rn=r({code:tn,message:t(),isRetryable:b()}),dt=h("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:rn})]);var Le=z(t(),te("NotionUserId")),oe=r({object:i("user"),id:Le,name:a(t()),avatar_url:K(t()),type:i("person"),person:r({email:t()})}),ht=r({object:i("list"),results:O(oe),next_cursor:K(t()),has_more:b(),type:i("user"),user:U(t(),Ie())});var gt=r({type:i("currentUserChanged"),currentUser:oe});var bt=r({type:i("dataSourcesChanged"),dataSources:r({bindings:le})});var nn=t(),on=r({code:nn,message:t(),isRetryable:b()}),kt=r({type:i("getPage"),requestId:t(),pageId:H}),St=h("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:on})]);var sn=t(),un=r({code:sn,message:t(),isRetryable:b()}),It=r({type:i("getUser"),requestId:t(),userId:Le}),xt=h("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:oe}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:un})]);var de=w(["light","dark"]);var an=t(),cn=r({code:an,message:t(),isRetryable:b()});var De=h("status",[r({type:i("init"),initializationId:t(),status:i("success"),theme:de,contrastMode:me,blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe}),r({type:i("init"),initializationId:t(),status:i("error"),error:cn})]);var _t=r({type:i("invalidSandboxMessage"),reason:t()});var ln=t(),pn=r({code:ln,message:t(),isRetryable:b()}),Ct=r({type:i("listUsers"),requestId:t(),startCursor:a(t()),pageSize:a(E())}),Et=h("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:ht}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:pn})]);var fn=w(["side_peek","center_peek"]),mn=t(),yn=r({code:mn,message:t(),isRetryable:b()}),Ot=r({type:i("openPage"),requestId:t(),pageId:H,mode:fn}),Pt=h("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:H}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:yn})]);var jt=r({type:i("pageChanged"),page:ye});var Bt=r({type:i("parentChanged"),parent:ne});var Mt=r({unit:w(["year","month","week","day"]),value:E(),time:t(),defaultTimeZone:a(t())}),vn=r({unit:w(["hour","minute"]),value:E()}),Rt=r({unit:i("none")}),dn=x([Mt,vn]),Dt=a(x([Mt,Rt])),wt=a(x([dn,Rt])),hn=r({type:i("date"),start_date:t(),reminder:Dt}),gn=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:Dt}),bn=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:a(t()),reminder:wt}),kn=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:a(t()),reminder:wt}),At=h("type",[hn,gn,bn,kn]);var Tt=r({id:t(),table:t()});var qt=x([t(),E(),b(),At,O(t()),O(Tt)]);var Nt=r({id:H,is_archived:b(),in_trash:b(),propertiesById:U(t(),a(qt))});var Sn=t(),In=r({code:Sn,message:t(),isRetryable:b()}),Ft=h("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:O(Nt),hasMore:b()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:In})]);var Ut=r({type:i("themeChanged"),theme:de});var xn=t(),_n=r({code:xn,message:t(),isRetryable:b()}),zt=h("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:_n})]);var Ht=h("type",[De,Ut,ft,Bt,jt,gt,bt,Ft,dt,St,xt,Et,Pt,zt,_t]);function Gt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Lt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Ve(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version ${o?`: ${o}`:"."}`,isRetryable:!1}}function Qe(e){let{currentBridgeProtocolVersion:o,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${o} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function $e(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Vt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Qt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function $t(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function Xt(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Wt(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function Jt(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Kt(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function ie(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function Xe(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var Cn=5e3,En=5e3,On=5e3;function Zt(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=Cn,initialStateTimeoutMs:y=En,noInitResultTimeoutMs:m=On,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:j}=e,k="waitingForConnect",G,W,T,B,q=!1,se=!1;function $(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function R(){W!==void 0&&(window.clearTimeout(W),W=void 0)}function N(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function A(g){let{initializationId:v,error:V}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ie(k)}k="error",B=v,$(),R(),n({type:"init",initializationId:v,status:"error",error:V}),j?.(V)}async function J(g){if(k==="waitingForConnect"){k="preparingInit",B=g.initializationId,$(),W=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Vt();s({...v,initializationId:g.initializationId}),A({initializationId:g.initializationId,error:v})},y);try{let v=await o(g);if(k!=="preparingInit")return;if(R(),v.status==="error"){A({initializationId:g.initializationId,error:v.error});return}k="waitingForInitResult";let V={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??pt,blockId:v.initialState.blockId,parent:v.initialState.parent,page:v.initialState.page,currentUser:v.initialState.currentUser,manifest:v.initialState.manifest,dataSources:v.initialState.dataSources};n(V),T=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let ee=Wt();j?.(ee),s({...ee,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),A({initializationId:g.initializationId,error:Kt()})}}}function Y(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!Xe(g.bridgeProtocolVersion)){let v=Ve({currentBridgeProtocolVersion:g.bridgeProtocolVersion});A({initializationId:g.initializationId,error:v});return}if(g.bridgeProtocolVersion<l){let v=Qe({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});A({initializationId:g.initializationId,error:v});return}if(g.status==="error"){A({initializationId:g.initializationId,error:g.error});return}se=!0,J(g)}}function _(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=g;if(v===void 0)return"nack";let ee=g.error;return V!==void 0&&(Xe(V)?V<l&&(ee=Qe({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):ee=Ve({currentBridgeProtocolVersion:void 0})),A({initializationId:v,error:ee}),"handled"}function ue(g){let{initializationId:v,error:V}=g;k!=="waitingForInitResult"||v===void 0||v!==B||($(),N(),k="error",s(V),j?.(V))}function je(){if(k!=="stopped"){if(q){S({code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}q=!0,$(),k==="waitingForConnect"&&(G=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Gt();s(g),j?.(g)},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==B){s({message:"Ignored stale or unexpected initResult",payload:g});return}N(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():j?.(g.error),I?.(g)}function ae(){k="stopped",$(),R(),N()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:Y,handleInitResult:he,handleInvalidConnect:_,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function Yt(e,o){return o>=5||!(e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged")?e:{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([s,c])=>[s,{...c,collectionSchema:{...c.collectionSchema,propertiesById:{...c.collectionSchema?.propertiesById,...at}}}]))}}}var er=r({theme:de,contrastMode:a(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function tr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var rr=r({code:t(),message:t(),isRetryable:b()});var nr={type:i("connect"),initializationId:t(),bridgeProtocolVersion:E(),sdkVersion:t()},or=h("status",[r({status:i("success"),manifest:a(pe),...nr}),r({status:i("error"),error:rr,...nr})]);var Pn=h("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:re}),r({type:i("after"),blockId:re})]),jn=h("type",[r({type:i("page_id"),page_id:H}),r({type:i("data_source_id"),data_source_id:Z})]),ir=r({type:i("createPage"),requestId:t(),parent:jn,properties:_e,position:a(Pn)});var Bn=t(),Mn=r({code:Bn,message:t(),isRetryable:b()}),sr=h("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:a(z(E(),be(),Se(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Mn})]);var ur=r({type:i("invalidHostMessage"),reason:t()});var Pe=x([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Oe=x([t(),O(t())]),ar=p({object:w(["user","group"]),id:z(t(),ke(1))}),Rn=x([p({contains:ar}),p({does_not_contain:ar}),Pe]),cr=p({object:i("user"),id:z(t(),ke(1),Me(2e3))}),Dn=x([p({contains:cr}),p({does_not_contain:cr}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ce=x([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Pe]),wn=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]),An=x([p({equals:b()}),p({does_not_equal:b()})]),mr=x([p({equals:Oe}),p({does_not_equal:Oe}),Pe]),lr=w(["To-do","In progress","Complete","Current","Future"]),pr=x([lr,z(O(lr),ke(1),Me(5))]),Tn=x([p({group_equals:pr}),p({group_does_not_equal:pr})]),qn=x([mr,Tn]),Nn=x([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Pe]),Q=w(["start_date","end_date"]),Fn=w(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Ee=x([Fn,t()]),Un=x([p({target:a(Q),equals:Ee}),p({target:a(Q),before:Ee}),p({target:a(Q),after:Ee}),p({target:a(Q),on_or_before:Ee}),p({target:a(Q),on_or_after:Ee}),p({target:a(Q),this_week:p({})}),p({target:a(Q),past_week:p({})}),p({target:a(Q),past_month:p({})}),p({target:a(Q),past_year:p({})}),p({target:a(Q),next_week:p({})}),p({target:a(Q),next_month:p({})}),p({target:a(Q),next_year:p({})}),p({target:a(Q),is_empty:i(!0)}),p({target:a(Q),is_not_empty:i(!0)})]),fr=x([p({propertyId:t(),created_by:Dn}),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:wn}),p({propertyId:t(),checkbox:An}),p({propertyId:t(),select:mr}),p({propertyId:t(),multi_select:Nn}),p({propertyId:t(),status:qn}),p({propertyId:t(),date:Un}),p({propertyId:t(),people:Rn})]),zn=x([fr,p({and:O(fr)})]),We=10,Hn=p({propertyId:t(),direction:w(["ascending","descending"])}),yr=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Z,limit:E(),filter:a(zn),sorts:a(O(Hn))});var vr=r({type:i("resize"),height:z(E(),be(),Se(0))});var dr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var hr=r({type:i("updatePage"),requestId:t(),pageId:H,properties:a(_e),icon:a(He),cover:a(Ge),archived:a(b())});var gr=h("type",[or,sr,yr,dr,ir,kt,It,Ct,Ot,hr,vr,ur]);function br(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function kr(e){let o=br(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Gn(o)}}}function Gn(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Sr=r({initializationId:t()}),Ln=r({bridgeProtocolVersion:x([E(),Ne()])});function Ir(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:j,onCreatePage:k,onGetPage:G,onOpenPage:W,onGetUser:T,onListUsers:B,onUpdatePage:q,onResize:se}=e;function $(R,N){c("warn",{message:"Ignored unsupported sandbox message",payload:R,issues:N});let A=kr(R);if(A.incomingType==="connect"){let J=xe(Sr,R),Y=xe(Ln,R);if(f({initializationId:J.success?J.output.initializationId:void 0,error:Lt(),bridgeProtocolVersion:Y.success?Y.output.bridgeProtocolVersion:void 0})==="handled")return}if(A.incomingType==="initResult"){let J=xe(Sr,R);y({initializationId:J.success?J.output.initializationId:void 0,error:Jt()})}A.nack!==void 0&&s()!=="stopped"&&l(A.nack)}return function(N){let A=N.source===o.contentWindow,J=N.origin===n;if(!A||!J)return;let Y=xe(gr,N.data);if(!Y.success){$(N.data,Y.issues);return}let _=Y.output;if(!tr(_)&&s()!=="initialized"){c("warn",{message:`Ignored ${_.type} before initialization completed`,payload:_});return}switch(c("in",_),_.type){case"connect":m(_);return;case"initResult":S(_);return;case"queryDataSource":I(_);return;case"unsubscribeDataSourceQuery":j(_);return;case"createPage":k(_);return;case"openPage":W(_);return;case"getPage":G(_);return;case"getUser":T(_);return;case"listUsers":B(_);return;case"updatePage":q(_);return;case"resize":se(_);return;case"invalidHostMessage":return;default:ie(_)}}}var we=class{constructor(o){this.onUnsubscribe=o}onUnsubscribe;bySubscriptionId=new Map;subscribe(o){this.unsubscribe(o.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(o.subscriptionId,{message:o,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(o,n){return this.bySubscriptionId.get(o)?.token===n}unsubscribe(o){this.bySubscriptionId.delete(o)&&this.onUnsubscribe(o)}refresh(o){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===o){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(o,n){let s=this.bySubscriptionId.get(o);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let o of this.bySubscriptionId.keys())this.unsubscribe(o)}};function xr(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Vn(s,o);if(c!==void 0)return c}}function Vn(e,o){if(!Object.hasOwn(o.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let n=o.propertiesById[e.propertyId],s=Object.keys(e).find(y=>y!=="propertyId");if(s!==n.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${n.type}".`,isRetryable:!1};if("status"in e&&n.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,I=(Array.isArray(m)?m:[m]).find(j=>!n.groups.some(k=>k.name===j));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}let c=Qn(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=$n(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 Qn(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 $n(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 Xn=new Set(ut);function _r(e,o){if(e===void 0)return;if(e.length>We)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${We} entries.`,isRetryable:!1};let n=new Set;for(let s of e){if(n.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(n.add(s.propertyId),!Object.hasOwn(o.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=o.propertiesById[s.propertyId];if(!Xn.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 Er=5;function Jn(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G}=e,W=Math.max(I??3,3),T={},B=!1,q,se,$=5,R=new we(u=>{m?.(u)});function N(u,C){y?.(u,C)}function A(u){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ie(C)}let D=Yt(u,$);N("out",D),o.contentWindow?.postMessage(D,S)}function J(u){A(fe(De,u))}function Y(u){A(u)}function _(u){let C=v.status;switch(C){case"initialized":A(fe(Ht,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(u,C){if(C===void 0)return;let D=await C(u);_({type:`${u.type}Result`,requestId:u.requestId,...D})}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 D=Kn(se,u.dataSourceId),ce=Zn(u,D);if(ce!==void 0){R.isCurrent(u.subscriptionId,C)&&(R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:{status:"error",error:ce}}));return}let Ae=await s.queryDataSource(u);if(!R.isCurrent(u.subscriptionId,C))return;Ae.status==="error"&&!Ae.error.isRetryable&&R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:Ae})}finally{let D=R.finish(u.subscriptionId,C);D!==void 0&&he(D.message,D.token)}}function ae(u){v.status==="stopped"||v.status==="error"||(Object.assign(T,u),g())}function g(){if(v.status!=="initialized")return;let u=T;T={},u.theme!==void 0&&_({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&_({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&_({type:"parentChanged",parent:u.parent}),u.page!==void 0&&_({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&_({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&_({type:"currentUserChanged",currentUser:u.currentUser})}let v=Zt({async prepareInit(u){$=u.bridgeProtocolVersion;let C=await n(u);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:J,warn:u=>N("warn",u),flushPendingHostStateChanges:g,minBridgeProtocolVersion:W,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G,stopHostWithFailure:Ke,onInitResult(u){u.status==="success"&&q!==void 0&&l?.({manifest:q,initialHeight:u.initialHeight})},onConnectionFailure:f});function V(u){if(u.status==="error")return u;q=fe(pe,u.initialState.manifest),c?.(q);let C={...u.initialState,...T};T={};let D={...fe(rt(er,["manifest"]),C),manifest:q};if($<Er&&D.page.type==="unavailable")return{status:"error",error:$e()};let ce=Or(D.manifest,D.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=D.dataSources,B=!0,{status:"success",initialState:D})}let ee=Ir({iframe:o,sandboxOrigin:S,getInitStatus:()=>v.status,emit:N,sendNack:Y,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:u=>R.unsubscribe(u.subscriptionId),onCreatePage:u=>ue(u,s.createPage),onGetPage:u=>ue(u,s.getPage),onOpenPage:u=>ue(u,s.openPage),onGetUser:u=>ue(u,s.getUser),onListUsers:u=>ue(u,s.listUsers),onUpdatePage:u=>ue(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",ee),o.addEventListener("load",v.onIframeLoad);function Je(){window.removeEventListener("message",ee),o.removeEventListener("load",v.onIframeLoad),v.stop(),R.unsubscribeAll()}function Ke(u){Je(),N("warn",u),f?.(u)}return{stop:Je,setTheme(u){ae({theme:u})},setContrastMode(u){ae({contrastMode:u})},setParent(u){ae({parent:u})},setPage(u){if(u.type==="unavailable"&&$<Er&&(v.status==="preparingInit"&&B||v.status==="waitingForInitResult"||v.status==="initialized")){Ke($e());return}ae({page:u})},setCurrentUser(u){ae({currentUser:u})},setDataSources(u){let C={bindings:fe(le,u.bindings)};if(v.hasConnectedSandbox&&q!==void 0&&Or(q,C)!==void 0){N("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:u}){if(v.status!=="initialized")return;let C=fe(Z,u),D=R.refresh(C);if(D===void 0){N("warn",`No active query exists for data source "${u}"`);return}for(let ce of D)he(ce.message,ce.token)}}}function Kn(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function Or(e,o){for(let[n,s]of Object.entries(e.dataSources)){let c=o.bindings[n];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Qt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return $t();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return Xt()}}}function Zn(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}:xr(e.filter,o)??_r(e.sorts,o)}export{Jn as createCustomBlockHost,Pr as getAutoBoundPropertyIdsByKey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AAI5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AAiBvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAA;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AAI5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AAiBvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAA;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAUzC,OAAO,KAAK,EACX,iCAAiC,EACjC,8BAA8B,EAI9B,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EACX,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,MAAM,qBAAqB,CAAA;AAe5B,MAAM,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE,iBAAiB,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,EAAE,uBAAuB,CAAA;IACjC,oHAAoH;IACpH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAA;IACpD,gGAAgG;IAChG,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QACvB,QAAQ,EAAE,mBAAmB,CAAA;QAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;KACtB,KAAK,IAAI,CAAA;IACV;;;;;OAKG;IACH,mBAAmB,EAAE,CAAC,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IAC1E,+FAA+F;IAC/F,mBAAmB,EAAE,CAAC,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IACnE,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC1E,eAAe,EAAE,8BAA8B,CAAA;IAC/C,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,KAAK,IAAI,CAAA;IAC/D,eAAe,EAAE,CAChB,YAAY,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,KACrD,IAAI,CAAA;IACT,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,KAAK,IAAI,CAAA;IAClE,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,KAAK,IAAI,CAAA;IACjE,cAAc,EAAE,CAAC,WAAW,EAAE,iCAAiC,KAAK,IAAI,CAAA;IACxE,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC1E,YAAY,EAAE,CAAC,IAAI,EAAE;QACpB,YAAY,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;KACzD,KAAK,IAAI,CAAA;CACV,CAAA;AAQD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CA8YvB"}
|
|
@@ -5,7 +5,7 @@ import { hostToSandboxMessageSchema, } from "./protocol/messages/hostToSandbox.j
|
|
|
5
5
|
import { initMessageSchema, } from "./protocol/messages/init.js";
|
|
6
6
|
import { LATEST_BRIDGE_PROTOCOL_VERSION } from "./protocol/protocolVersion.js";
|
|
7
7
|
import * as v from "valibot";
|
|
8
|
-
import {
|
|
8
|
+
import { contextUnavailableError, invalidPropertyBindingError, missingDataSourceBindingError, missingPropertyBindingError, } from "./lifecycle/initErrors.js";
|
|
9
9
|
import { createInitializationController } from "./lifecycle/initializationController.js";
|
|
10
10
|
import { normalizeHostToSandboxMessage } from "./lifecycle/normalizeHostToSandboxMessage.js";
|
|
11
11
|
import { customBlockHostInitialStateSchema } from "./lifecycle/types.js";
|
|
@@ -231,14 +231,14 @@ export function createCustomBlockHost(options) {
|
|
|
231
231
|
initialState.page.type === "unavailable") {
|
|
232
232
|
return {
|
|
233
233
|
status: "error",
|
|
234
|
-
error:
|
|
234
|
+
error: contextUnavailableError(),
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
if (
|
|
237
|
+
const bindingError = getBindingError(initialState.manifest, initialState.dataSources);
|
|
238
|
+
if (bindingError !== undefined) {
|
|
239
239
|
return {
|
|
240
240
|
status: "error",
|
|
241
|
-
error:
|
|
241
|
+
error: bindingError,
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
244
|
activeDataSources = initialState.dataSources;
|
|
@@ -297,7 +297,7 @@ export function createCustomBlockHost(options) {
|
|
|
297
297
|
hasPreparedInitialState) ||
|
|
298
298
|
initializationController.status === "waitingForInitResult" ||
|
|
299
299
|
initializationController.status === "initialized")) {
|
|
300
|
-
stopWithFailure(
|
|
300
|
+
stopWithFailure(contextUnavailableError());
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
303
|
updateHostState({ page });
|
|
@@ -311,7 +311,7 @@ export function createCustomBlockHost(options) {
|
|
|
311
311
|
};
|
|
312
312
|
if (initializationController.hasConnectedSandbox &&
|
|
313
313
|
manifest !== undefined &&
|
|
314
|
-
|
|
314
|
+
getBindingError(manifest, normalizedDataSources) !== undefined) {
|
|
315
315
|
emit("warn", {
|
|
316
316
|
message: "Ignored invalid data source bindings update",
|
|
317
317
|
payload: normalizedDataSources,
|
|
@@ -340,21 +340,21 @@ export function createCustomBlockHost(options) {
|
|
|
340
340
|
function getCollectionSchema(dataSources, dataSourceId) {
|
|
341
341
|
return Object.values(dataSources?.bindings ?? {}).find(binding => binding.collectionPointer?.id === dataSourceId)?.collectionSchema;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function getBindingError(manifest, dataSources) {
|
|
344
344
|
for (const [dataSourceKey, manifestDataSource] of Object.entries(manifest.dataSources)) {
|
|
345
345
|
const binding = dataSources.bindings[dataSourceKey];
|
|
346
346
|
if (binding?.collectionPointer === undefined ||
|
|
347
347
|
binding.collectionSchema === undefined) {
|
|
348
|
-
return
|
|
348
|
+
return missingDataSourceBindingError();
|
|
349
349
|
}
|
|
350
350
|
for (const [propertyKey, manifestProperty] of Object.entries(manifestDataSource.properties ?? {})) {
|
|
351
351
|
const propertyId = binding.propertyIdsByKey?.[propertyKey];
|
|
352
352
|
if (propertyId === undefined) {
|
|
353
|
-
return
|
|
353
|
+
return missingPropertyBindingError();
|
|
354
354
|
}
|
|
355
355
|
if (binding.collectionSchema.propertiesById[propertyId]?.type !==
|
|
356
356
|
manifestProperty.type) {
|
|
357
|
-
return
|
|
357
|
+
return invalidPropertyBindingError();
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CustomBlockErrorInfo } from "../protocol/errors.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `connect` message. `isRetryable` means a fresh iframe / `init` attempt could plausibly succeed
|
|
7
|
-
* without changing block code or host configuration.
|
|
3
|
+
* Initialization handshakes are one-shot: after an error, this host instance will not answer
|
|
4
|
+
* another `connect` message. `isRetryable` means a fresh host and iframe could plausibly
|
|
5
|
+
* initialize without changing block code or host configuration.
|
|
8
6
|
*/
|
|
9
|
-
export declare function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export declare function noConnectError(): CustomBlockErrorInfo<"no_connect">;
|
|
8
|
+
export declare function invalidConnectPayloadError(): CustomBlockErrorInfo<"invalid_connect_payload">;
|
|
9
|
+
export declare function invalidProtocolVersionError(args: {
|
|
10
|
+
currentBridgeProtocolVersion: number | undefined;
|
|
11
|
+
}): CustomBlockErrorInfo<"invalid_protocol_version">;
|
|
12
|
+
export declare function unsupportedProtocolVersionError(args: {
|
|
13
|
+
currentBridgeProtocolVersion: number;
|
|
14
|
+
minBridgeProtocolVersion: number;
|
|
15
|
+
}): CustomBlockErrorInfo<"unsupported_protocol_version">;
|
|
16
|
+
export declare function contextUnavailableError(): CustomBlockErrorInfo<"context_unavailable">;
|
|
17
|
+
export declare function initialStateTimeoutError(): CustomBlockErrorInfo<"initial_state_timeout">;
|
|
18
|
+
export declare function missingDataSourceBindingError(): CustomBlockErrorInfo<"missing_data_source_binding">;
|
|
19
|
+
export declare function missingPropertyBindingError(): CustomBlockErrorInfo<"missing_property_binding">;
|
|
20
|
+
export declare function invalidPropertyBindingError(): CustomBlockErrorInfo<"invalid_property_binding">;
|
|
21
|
+
export declare function noInitResultError(): CustomBlockErrorInfo<"no_init_result">;
|
|
22
|
+
export declare function invalidInitResultPayloadError(): CustomBlockErrorInfo<"invalid_init_result_payload">;
|
|
23
|
+
export declare function unknownInitializationError(): CustomBlockErrorInfo<"unknown_error">;
|
|
13
24
|
//# sourceMappingURL=initErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initErrors.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"initErrors.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AAEtF;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAOnE;AAED,wBAAgB,0BAA0B,IAAI,oBAAoB,CAAC,yBAAyB,CAAC,CAO5F;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE;IACjD,4BAA4B,EAAE,MAAM,GAAG,SAAS,CAAA;CAChD,GAAG,oBAAoB,CAAC,0BAA0B,CAAC,CAWnD;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE;IACrD,4BAA4B,EAAE,MAAM,CAAA;IACpC,wBAAwB,EAAE,MAAM,CAAA;CAChC,GAAG,oBAAoB,CAAC,8BAA8B,CAAC,CAQvD;AAED,wBAAgB,uBAAuB,IAAI,oBAAoB,CAAC,qBAAqB,CAAC,CAOrF;AAED,wBAAgB,wBAAwB,IAAI,oBAAoB,CAAC,uBAAuB,CAAC,CAOxF;AAED,wBAAgB,6BAA6B,IAAI,oBAAoB,CAAC,6BAA6B,CAAC,CAOnG;AAED,wBAAgB,2BAA2B,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAO9F;AAED,wBAAgB,2BAA2B,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAQ9F;AAED,wBAAgB,iBAAiB,IAAI,oBAAoB,CAAC,gBAAgB,CAAC,CAO1E;AAED,wBAAgB,6BAA6B,IAAI,oBAAoB,CAAC,6BAA6B,CAAC,CAOnG;AAED,wBAAgB,0BAA0B,IAAI,oBAAoB,CAAC,eAAe,CAAC,CAOlF"}
|
|
@@ -1,158 +1,107 @@
|
|
|
1
|
-
const UNKNOWN_ERROR_MESSAGE = "Unexpected error while initializing custom block.";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `connect` message. `isRetryable` means a fresh iframe / `init` attempt could plausibly succeed
|
|
7
|
-
* without changing block code or host configuration.
|
|
2
|
+
* Initialization handshakes are one-shot: after an error, this host instance will not answer
|
|
3
|
+
* another `connect` message. `isRetryable` means a fresh host and iframe could plausibly
|
|
4
|
+
* initialize without changing block code or host configuration.
|
|
8
5
|
*/
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
code: reason,
|
|
112
|
-
message: "A mapped data source property is missing or incompatible.",
|
|
113
|
-
// The bound property's schema must be updated or the binding must be updated to
|
|
114
|
-
// a property with a compatible schema.
|
|
115
|
-
isRetryable: false,
|
|
116
|
-
};
|
|
117
|
-
case "no_init_result":
|
|
118
|
-
return {
|
|
119
|
-
code: reason,
|
|
120
|
-
message: "Sandbox did not acknowledge initialization.",
|
|
121
|
-
isRetryable: true,
|
|
122
|
-
};
|
|
123
|
-
case "invalid_init_result_payload":
|
|
124
|
-
return {
|
|
125
|
-
code: reason,
|
|
126
|
-
message: "Sandbox sent an invalid initialization result.",
|
|
127
|
-
isRetryable: false,
|
|
128
|
-
};
|
|
129
|
-
case "invalid_init_bindings":
|
|
130
|
-
return {
|
|
131
|
-
code: reason,
|
|
132
|
-
message: "Sandbox rejected the host-provided data source bindings.",
|
|
133
|
-
isRetryable: false,
|
|
134
|
-
};
|
|
135
|
-
case "not_in_iframe":
|
|
136
|
-
return {
|
|
137
|
-
code: reason,
|
|
138
|
-
message: "<NotionCustomBlock> only works inside an iframe.",
|
|
139
|
-
// The block must be embedded in an iframe.
|
|
140
|
-
isRetryable: false,
|
|
141
|
-
};
|
|
142
|
-
case "unknown_error":
|
|
143
|
-
return {
|
|
144
|
-
code: reason,
|
|
145
|
-
message: UNKNOWN_ERROR_MESSAGE,
|
|
146
|
-
// Treat unknown errors as non-retryable.
|
|
147
|
-
isRetryable: false,
|
|
148
|
-
};
|
|
149
|
-
default:
|
|
150
|
-
console.warn(`Unexpected custom block init error: ${reason}`);
|
|
151
|
-
return {
|
|
152
|
-
code: reason,
|
|
153
|
-
message: UNKNOWN_ERROR_MESSAGE,
|
|
154
|
-
// Treat unknown error codes as non-retryable.
|
|
155
|
-
isRetryable: false,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
6
|
+
export function noConnectError() {
|
|
7
|
+
return {
|
|
8
|
+
code: "no_connect",
|
|
9
|
+
message: "Sandbox did not send a connect message.",
|
|
10
|
+
// A fresh iframe may finish loading and send connect before the timeout.
|
|
11
|
+
isRetryable: true,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function invalidConnectPayloadError() {
|
|
15
|
+
return {
|
|
16
|
+
code: "invalid_connect_payload",
|
|
17
|
+
message: "Sandbox sent an invalid connect message.",
|
|
18
|
+
// The sandbox must be updated to send a valid connect message.
|
|
19
|
+
isRetryable: false,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function invalidProtocolVersionError(args) {
|
|
23
|
+
const { currentBridgeProtocolVersion } = args;
|
|
24
|
+
const versionText = currentBridgeProtocolVersion
|
|
25
|
+
? `: ${currentBridgeProtocolVersion}`
|
|
26
|
+
: ".";
|
|
27
|
+
return {
|
|
28
|
+
code: "invalid_protocol_version",
|
|
29
|
+
message: `Sandbox reported an invalid bridge protocol version ${versionText}`,
|
|
30
|
+
// The sandbox must be updated to a supported protocol version.
|
|
31
|
+
isRetryable: false,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function unsupportedProtocolVersionError(args) {
|
|
35
|
+
const { currentBridgeProtocolVersion, minBridgeProtocolVersion } = args;
|
|
36
|
+
return {
|
|
37
|
+
code: "unsupported_protocol_version",
|
|
38
|
+
message: `Sandbox bridge protocol version ${currentBridgeProtocolVersion} is not supported. Minimum supported version is ${minBridgeProtocolVersion}.`,
|
|
39
|
+
// The sandbox must be updated to a supported protocol version.
|
|
40
|
+
isRetryable: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function contextUnavailableError() {
|
|
44
|
+
return {
|
|
45
|
+
code: "context_unavailable",
|
|
46
|
+
message: "Host page context is unavailable.",
|
|
47
|
+
// Page context may become available before a fresh initialization attempt.
|
|
48
|
+
isRetryable: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function initialStateTimeoutError() {
|
|
52
|
+
return {
|
|
53
|
+
code: "initial_state_timeout",
|
|
54
|
+
message: "Host did not prepare initial state before the timeout.",
|
|
55
|
+
// A fresh attempt may finish loading host dependencies before the timeout.
|
|
56
|
+
isRetryable: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function missingDataSourceBindingError() {
|
|
60
|
+
return {
|
|
61
|
+
code: "missing_data_source_binding",
|
|
62
|
+
message: "A required data source is not mapped.",
|
|
63
|
+
// Host configuration must be changed before this block can initialize.
|
|
64
|
+
isRetryable: false,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function missingPropertyBindingError() {
|
|
68
|
+
return {
|
|
69
|
+
code: "missing_property_binding",
|
|
70
|
+
message: "A required data source property is not mapped.",
|
|
71
|
+
// Host configuration must be changed before this block can initialize.
|
|
72
|
+
isRetryable: false,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export function invalidPropertyBindingError() {
|
|
76
|
+
return {
|
|
77
|
+
code: "invalid_property_binding",
|
|
78
|
+
message: "A mapped data source property is missing or incompatible.",
|
|
79
|
+
// The bound property's schema must be updated or the binding must be updated to
|
|
80
|
+
// a property with a compatible schema.
|
|
81
|
+
isRetryable: false,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function noInitResultError() {
|
|
85
|
+
return {
|
|
86
|
+
code: "no_init_result",
|
|
87
|
+
message: "Sandbox did not acknowledge initialization.",
|
|
88
|
+
// A fresh iframe may process init and acknowledge it before the timeout.
|
|
89
|
+
isRetryable: true,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function invalidInitResultPayloadError() {
|
|
93
|
+
return {
|
|
94
|
+
code: "invalid_init_result_payload",
|
|
95
|
+
message: "Sandbox sent an invalid initialization result.",
|
|
96
|
+
// The sandbox must be updated to send a valid initialization result.
|
|
97
|
+
isRetryable: false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function unknownInitializationError() {
|
|
101
|
+
return {
|
|
102
|
+
code: "unknown_error",
|
|
103
|
+
message: "Unexpected error while initializing custom block.",
|
|
104
|
+
// Without a known transient cause, conservatively treat unknown errors as non-retryable.
|
|
105
|
+
isRetryable: false,
|
|
106
|
+
};
|
|
158
107
|
}
|