@notionhq/custom-blocks-host 0.2.17 → 0.2.19
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lifecycle/initErrors.d.ts.map +1 -1
- package/dist/lifecycle/initErrors.js +1 -4
- package/dist/lifecycle/initializationController.js +1 -1
- package/dist/protocol/messages/queryDataSource.d.ts +41 -0
- package/dist/protocol/messages/queryDataSource.js +13 -1
- package/dist/protocol/messages/sandboxToHost.d.ts +14 -0
- package/dist/queries/validateQueryDataSourceFilter.d.ts.map +1 -1
- package/dist/queries/validateQueryDataSourceFilter.js +10 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/lifecycle/initErrors.ts +1 -4
- package/src/lifecycle/initializationController.ts +1 -1
- package/src/queries/validateQueryDataSourceFilter.ts +13 -0
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function jr(e){let{manifestProperties:i,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(i)){let f=Br({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function Br(e){let{propertyKey:i,manifestProperty:n,propertySchemasById:s}=e,c=Ze(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===i||Ze(y.name)===c));return l.length===1?l[0][0]:void 0}function Ze(e){return e.trim().toLowerCase()}var Me,Mr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function qe(e){return!e&&!Me?Mr:{lang:e?.lang??Me?.lang,message:e?.message,abortEarly:e?.abortEarly??Me?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Me?.abortPipeEarly}}var Rr;function Dr(e){return Rr?.get(e)}var wr;function Ar(e){return wr?.get(e)}var Tr;function qr(e,i){return Tr?.get(e)?.get(i)}function ge(e){let i=typeof e;return i==="string"?`"${e}"`:i==="number"||i==="bigint"||i==="boolean"?`${e}`:i==="object"||i==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":i}function M(e,i,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${i}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},S=e.kind==="schema",I=c?.message??e.message??qr(e.reference,m.lang)??(S?Ar(m.lang):null)??s.message??Dr(m.lang);I!==void 0&&(m.message=typeof I=="function"?I(m):I),S&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var Ye=new WeakMap;function F(e){let i=Ye.get(e);return i||(i={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},qe())}},Ye.set(e,i)),i}function Nr(e,i){return Object.prototype.hasOwnProperty.call(e,i)&&i!=="__proto__"&&i!=="prototype"&&i!=="constructor"}function Ne(e,i){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${i} `)})`:n[0]??"never"}var Fr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(i){return i}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(i,n){return i.typed&&!this.requirement(i.value)&&M(this,"finite",i,n),i}}}function Re(e,i){return{kind:"validation",type:"max_length",reference:Re,async:!1,expects:`<=${e}`,requirement:e,message:i,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,i){return{kind:"validation",type:"min_length",reference:ke,async:!1,expects:`>=${e}`,requirement:e,message:i,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&M(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,i){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:i,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&M(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}var Ur={abortEarly:!0};function tt(e,i,n){return typeof e.fallback=="function"?e.fallback(i,n):e.fallback}function De(e,i,n){return typeof e.default=="function"?e.default(i,n):e.default}function O(e,i){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else M(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return typeof i.value=="boolean"?i.typed=!0:M(this,"type",i,n),i}}}function o(e,i){return{kind:"schema",type:"literal",reference:o,expects:ge(e),async:!1,literal:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:M(this,"type",n,s),n}}}function Fe(e){return{kind:"schema",type:"nan",reference:Fe,expects:"NaN",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return Number.isNaN(i.value)?i.typed=!0:M(this,"type",i,n),i}}}function Z(e,i){return{kind:"schema",type:"nullable",reference:Z,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:i,get"~standard"(){return F(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function E(e){return{kind:"schema",type:"number",reference:E,expects:"number",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return typeof i.value=="number"&&!isNaN(i.value)?i.typed=!0:M(this,"type",i,n),i}}}function r(e,i){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",n,s);return n}}}function a(e,i){return{kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:i,get"~standard"(){return F(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function D(e,i){return{kind:"schema",type:"picklist",reference:D,expects:Ne(e.map(ge),"|"),async:!1,options:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:M(this,"type",n,s),n}}}function U(e,i,n){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:i,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Nr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let I={type:"object",origin:"key",input:l,key:f,value:y};for(let j of m.issues)j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let S=this.value["~run"]({value:y},c);if(S.issues){let I={type:"object",origin:"value",input:l,key:f,value:y};for(let j of S.issues)j.path?j.path.unshift(I):j.path=[I],s.issues?.push(j);if(s.issues||(s.issues=S.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!S.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=S.value)}}else M(this,"type",s,c);return s}}}function p(e,i){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=tt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(M(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){M(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return F(this)},"~run"(i,n){return typeof i.value=="string"?i.typed=!0:M(this,"type",i,n),i}}}function et(e){let i;if(e)for(let n of e)if(i)for(let s of n.issues)i.push(s);else i=n.issues;return i}function x(e,i){return{kind:"schema",type:"union",reference:x,expects:Ne(e.map(n=>n.expects),"|"),async:!1,options:e,message:i,get"~standard"(){return F(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",n,s,{issues:et(l)}),n.typed=!0}else{if(f?.length===1)return f[0];M(this,"type",n,s,{issues:et(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return F(this)},"~run"(e){return e.typed=!0,e}}}function h(e,i,n){return{kind:"schema",type:"variant",reference:h,expects:"Object",async:!1,key:e,options:i,message:n,get"~standard"(){return F(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(j,k)=>{for(let G of j.options){if(G.type==="variant")I(G,new Set(k).add(G.key));else{let W=!0,T=0;for(let B of k){let q=G.entries[B];if(B in l?q["~run"]({typed:!1,value:l[B]},Ur).issues:q.type!=="exact_optional"&&q.type!=="optional"&&q.type!=="nullish"){W=!1,m!==B&&(y<T||y===T&&B in l&&!(m in l))&&(y=T,m=B,S=[]),m===B&&S.push(G.entries[B].expects);break}T++}if(W){let B=G["~run"]({value:l},c);(!f||!f.typed&&B.typed)&&(f=B)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;M(this,"type",s,c,{input:l[m],expected:Ne(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else M(this,"type",s,c);return s}}}function rt(e,i){let n={...e.entries};for(let s of i)delete n[s];return{...e,entries:n,get"~standard"(){return F(this)}}}function fe(e,i,n){let s=e["~run"]({value:i},qe(n));if(s.issues)throw new Fr(s.issues);return s.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return F(this)},"~run"(i,n){for(let s of e)if(s.kind!=="metadata"){if(i.issues&&(s.kind==="schema"||s.kind==="transformation")){i.typed=!1;break}(!i.issues||!n.abortEarly&&!n.abortPipeEarly)&&(i=s["~run"](i,n))}return i}}}function xe(e,i,n){let s=e["~run"]({value:i},qe(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var re=z(t(),te("NotionBlockId")),Y=z(t(),te("NotionDataSourceId")),H=z(t(),te("NotionPageId")),nt=z(t(),te("NotionAgentId")),ot=z(t(),te("NotionSpaceId"));var it=D(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),Ue=r({id:t(),name:t(),color:a(it),description:a(t())}),zr=r({id:t(),name:t(),color:a(it),option_ids:O(t())}),Hr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:a(t())}),Gr=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],st=D(Gr),ut=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],ze=h("type",[r({...P.entries,type:o("title")}),r({...P.entries,type:o("rich_text")}),r({...P.entries,type:o("number")}),r({...P.entries,type:o("checkbox")}),r({...P.entries,type:o("url")}),r({...P.entries,type:o("email")}),r({...P.entries,type:o("phone_number")}),r({...P.entries,type:o("select"),options:O(Ue)}),r({...P.entries,type:o("multi_select"),options:O(Ue)}),r({...P.entries,type:o("status"),options:O(Ue),groups:O(zr)}),r({...P.entries,type:o("date")}),r({...P.entries,type:o("people")}),r({...P.entries,type:o("files")}),r({...P.entries,type:o("unique_id")}),r({...P.entries,type:o("relation"),data_source_id:a(t()),dual_property:a(Hr)}),r({...P.entries,type:o("place")}),r({...P.entries,type:o("formula")}),r({...P.entries,type:o("rollup")}),r({...P.entries,type:o("button")}),r({...P.entries,type:o("verification")}),r({...P.entries,type:o("last_visited_time")}),r({...P.entries,type:o("location")}),r({...P.entries,type:o("created_time")}),r({...P.entries,type:o("last_edited_time")}),r({...P.entries,type:o("created_by")}),r({...P.entries,type:o("last_edited_by")})]);var at={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var ct=r({id:Y,table:t(),spaceId:a(ot)}),lt=r({id:a(Y),propertiesById:U(t(),ze)}),uo=r({key:t(),collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:U(t(),a(t())),propertySchemasById:U(t(),ze)}),Lr=r({collectionPointer:a(ct),collectionSchema:a(lt),propertyIdsByKey:a(U(t(),a(t())))}),le=U(t(),Lr);var Vr=h("type",[r({type:o("emoji"),emoji:t()}),r({type:o("external"),url:t()})]),Qr=r({name:t(),description:a(t()),type:st}),$r=r({name:t(),description:a(t()),icon:a(Vr),properties:a(U(t(),Qr),{})}),pe=r({version:o(1),name:a(t()),description:a(t()),slashCommand:a(t()),icon:a(r({type:o("emoji"),emoji:t()})),dataSources:a(U(t(),$r),{})});var me=D(["standard","high"]),pt="standard";var ft=r({type:o("contrastModeChanged"),contrastMode:me});var ne=h("type",[r({type:o("page_id"),page_id:H}),r({type:o("data_source_id"),data_source_id:Y}),r({type:o("workspace"),workspace:o(!0)}),r({type:o("block_id"),block_id:re}),r({type:o("agent_id"),agent_id:nt}),r({type:o("unavailable")})]);var ye=h("type",[r({type:o("unavailable")}),r({type:o("page"),id:H,parent:ne})]),Xr=r({type:o("emoji"),emoji:t()}),Wr=r({type:o("custom_emoji"),custom_emoji:r({id:t(),name:a(t()),url:a(t())})}),yt=r({type:o("external"),external:r({url:t()})}),vt=r({type:o("file"),file:r({url:t(),expiry_time:a(t())})}),Ge=h("type",[Xr,Wr,yt,vt]),Le=h("type",[yt,vt]),X=Z(t()),mt=U(t(),Ie()),He=x([r({id:t(),name:a(t()),color:a(t()),description:a(X)}),r({name:t(),id:a(t()),color:a(t()),description:a(X)})]),Jr=r({start:t(),end:a(X),time_zone:a(X)}),Kr=x([r({object:a(o("user")),id:t()}),r({object:o("group"),id:t(),name:a(X)})]),Zr=r({id:t()}),Yr=x([r({type:o("external"),name:t(),external:r({url:t()})}),r({type:o("file"),name:t(),file:r({url:t(),expiry_time:a(t())})})]),en=r({lat:E(),lon:E(),name:a(X),address:a(X),aws_place_id:a(X),google_place_id:a(X)}),L={id:t()},tn=h("type",[r({...L,type:o("title"),title:O(mt)}),r({...L,type:o("rich_text"),rich_text:O(mt)}),r({...L,type:o("number"),number:Z(E())}),r({...L,type:o("url"),url:X}),r({...L,type:o("email"),email:X}),r({...L,type:o("phone_number"),phone_number:X}),r({...L,type:o("checkbox"),checkbox:b()}),r({...L,type:o("select"),select:Z(He)}),r({...L,type:o("status"),status:Z(He)}),r({...L,type:o("multi_select"),multi_select:O(He)}),r({...L,type:o("date"),date:Z(Jr)}),r({...L,type:o("people"),people:O(Kr)}),r({...L,type:o("relation"),has_more:a(b()),relation:O(Zr)}),r({...L,type:o("files"),files:O(Yr)}),r({...L,type:o("place"),place:Z(en)})]),_e=U(t(),tn),ve=r({object:o("page"),id:H,parent:ne,properties:_e,created_time:a(t()),last_edited_time:a(t()),icon:a(Ge),cover:a(Le),url:a(t()),public_url:a(t()),is_archived:b(),in_trash:b()});var rn=t(),nn=r({code:rn,message:t(),isRetryable:b()}),dt=h("status",[r({type:o("createPageResult"),requestId:t(),status:o("success"),page:ve}),r({type:o("createPageResult"),requestId:t(),status:o("error"),error:nn})]);var Ve=z(t(),te("NotionUserId")),oe=r({object:o("user"),id:Ve,name:a(t()),avatar_url:Z(t()),type:o("person"),person:r({email:t()})}),ht=r({object:o("list"),results:O(oe),next_cursor:Z(t()),has_more:b(),type:o("user"),user:U(t(),Ie())});var gt=r({type:o("currentUserChanged"),currentUser:oe});var bt=r({type:o("dataSourcesChanged"),dataSources:r({bindings:le})});var on=t(),sn=r({code:on,message:t(),isRetryable:b()}),kt=r({type:o("getPage"),requestId:t(),pageId:H}),St=h("status",[r({type:o("getPageResult"),requestId:t(),status:o("success"),page:ve}),r({type:o("getPageResult"),requestId:t(),status:o("error"),error:sn})]);var un=t(),an=r({code:un,message:t(),isRetryable:b()}),It=r({type:o("getUser"),requestId:t(),userId:Ve}),xt=h("status",[r({type:o("getUserResult"),requestId:t(),status:o("success"),user:oe}),r({type:o("getUserResult"),requestId:t(),status:o("error"),error:an})]);var de=D(["light","dark"]);var cn=t(),ln=r({code:cn,message:t(),isRetryable:b()});var we=h("status",[r({type:o("init"),initializationId:t(),status:o("success"),theme:de,contrastMode:me,blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe}),r({type:o("init"),initializationId:t(),status:o("error"),error:ln})]);var _t=r({type:o("invalidSandboxMessage"),reason:t()});var pn=t(),fn=r({code:pn,message:t(),isRetryable:b()}),Ct=r({type:o("listUsers"),requestId:t(),startCursor:a(t()),pageSize:a(E())}),Et=h("status",[r({type:o("listUsersResult"),requestId:t(),status:o("success"),list:ht}),r({type:o("listUsersResult"),requestId:t(),status:o("error"),error:fn})]);var mn=D(["side_peek","center_peek"]),yn=t(),vn=r({code:yn,message:t(),isRetryable:b()}),Ot=r({type:o("openPage"),requestId:t(),pageId:H,mode:mn}),Pt=h("status",[r({type:o("openPageResult"),requestId:t(),status:o("success"),pageId:H}),r({type:o("openPageResult"),requestId:t(),status:o("error"),error:vn})]);var jt=r({type:o("pageChanged"),page:ye});var Bt=r({type:o("parentChanged"),parent:ne});var Mt=r({unit:D(["year","month","week","day"]),value:E(),time:t(),defaultTimeZone:a(t())}),dn=r({unit:D(["hour","minute"]),value:E()}),Rt=r({unit:o("none")}),hn=x([Mt,dn]),Dt=a(x([Mt,Rt])),wt=a(x([hn,Rt])),gn=r({type:o("date"),start_date:t(),reminder:Dt}),bn=r({type:o("daterange"),start_date:t(),end_date:t(),reminder:Dt}),kn=r({type:o("datetime"),start_date:t(),start_time:t(),time_zone:a(t()),reminder:wt}),Sn=r({type:o("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:a(t()),reminder:wt}),At=h("type",[gn,bn,kn,Sn]);var Tt=r({id:t(),table:t()});var qt=x([t(),E(),b(),At,O(t()),O(Tt)]);var Nt=r({id:H,is_archived:b(),in_trash:b(),propertiesById:U(t(),a(qt))});var In=t(),xn=r({code:In,message:t(),isRetryable:b()}),Ft=h("status",[r({type:o("queryDataSourceResult"),subscriptionId:t(),status:o("success"),items:O(Nt),hasMore:b()}),r({type:o("queryDataSourceResult"),subscriptionId:t(),status:o("error"),error:xn})]);var Ut=r({type:o("themeChanged"),theme:de});var _n=t(),Cn=r({code:_n,message:t(),isRetryable:b()}),zt=h("status",[r({type:o("updatePageResult"),requestId:t(),status:o("success"),page:ve}),r({type:o("updatePageResult"),requestId:t(),status:o("error"),error:Cn})]);var Ht=h("type",[we,Ut,ft,Bt,jt,gt,bt,Ft,dt,St,xt,Et,Pt,zt,_t]);function Gt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Lt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Qe(e){let{currentBridgeProtocolVersion:i}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version ${i?`: ${i}`:"."}`,isRetryable:!1}}function $e(e){let{currentBridgeProtocolVersion:i,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${i} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function Xe(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Vt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Qt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function $t(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function Xt(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function Wt(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function Jt(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Kt(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function ie(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function We(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var En=5e3,On=5e3,Pn=5e3;function Zt(e){let{prepareInit:i,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=En,initialStateTimeoutMs:y=On,noInitResultTimeoutMs:m=Pn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:j}=e,k="waitingForConnect",G,W,T,B,q=!1,se=!1;function $(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function R(){W!==void 0&&(window.clearTimeout(W),W=void 0)}function N(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function A(g){let{initializationId:v,error:V,phase:K,source:Be}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ie(k)}k="error",B=v,$(),R(),n({type:"init",initializationId:v,status:"error",error:V}),j?.({...V,phase:K,source:Be})}async function J(g){if(k==="waitingForConnect"){k="preparingInit",B=g.initializationId,$(),W=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Vt();s({...v,initializationId:g.initializationId}),A({initializationId:g.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await i(g);if(k!=="preparingInit")return;if(R(),v.status==="error"){A({initializationId:g.initializationId,error:v.error,phase:"init",source:"host"});return}k="waitingForInitResult";let V={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??pt,blockId:v.initialState.blockId,parent:v.initialState.parent,page:v.initialState.page,currentUser:v.initialState.currentUser,manifest:v.initialState.manifest,dataSources:v.initialState.dataSources};n(V),T=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let K=Wt();j?.({...K,phase:"initResult",source:"host"}),s({...K,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),A({initializationId:g.initializationId,error:Kt(),phase:"init",source:"host"})}}}function ee(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!We(g.bridgeProtocolVersion)){let v=Qe({currentBridgeProtocolVersion:g.bridgeProtocolVersion});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.bridgeProtocolVersion<l){let v=$e({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.status==="error"){A({initializationId:g.initializationId,error:g.error,phase:"connect",source:"sandbox"});return}se=!0,J(g)}}function _(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=g;if(v===void 0)return"nack";let K=g.error;return V!==void 0&&(We(V)?V<l&&(K=$e({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):K=Qe({currentBridgeProtocolVersion:void 0})),A({initializationId:v,error:K,phase:"connect",source:"host"}),"handled"}function ue(g){let{initializationId:v,error:V}=g;k!=="waitingForInitResult"||v===void 0||v!==B||($(),N(),k="error",s(V),j?.({...V,phase:"initResult",source:"host"}))}function je(){if(k!=="stopped"){if(q){S({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}q=!0,$(),k==="waitingForConnect"&&(G=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Gt();s(g),j?.({...g,phase:"connect",source:"host"})},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==B){s({message:"Ignored stale or unexpected initResult",payload:g});return}N(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():j?.({...g.error,phase:"initResult",source:"sandbox"}),I?.(g)}function ae(){k="stopped",$(),R(),N()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:ee,handleInitResult:he,handleInvalidConnect:_,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function Yt(e,i){return i>=5||!(e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged")?e:{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([s,c])=>[s,{...c,collectionSchema:{...c.collectionSchema,propertiesById:{...c.collectionSchema?.propertiesById,...at}}}]))}}}var er=r({theme:de,contrastMode:a(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function tr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var rr=r({code:t(),message:t(),isRetryable:b()});var nr={type:o("connect"),initializationId:t(),bridgeProtocolVersion:E(),sdkVersion:t()},or=h("status",[r({status:o("success"),manifest:a(pe),...nr}),r({status:o("error"),error:rr,...nr})]);var jn=h("type",[r({type:o("start")}),r({type:o("end")}),r({type:o("before"),blockId:re}),r({type:o("after"),blockId:re})]),Bn=h("type",[r({type:o("page_id"),page_id:H}),r({type:o("data_source_id"),data_source_id:Y})]),ir=r({type:o("createPage"),requestId:t(),parent:Bn,properties:_e,position:a(jn)});var Mn=t(),Rn=r({code:Mn,message:t(),isRetryable:b()}),sr=h("status",[r({type:o("initResult"),initializationId:t(),status:o("success"),initialHeight:a(z(E(),be(),Se(0)))}),r({type:o("initResult"),initializationId:t(),status:o("error"),error:Rn})]);var ur=r({type:o("invalidHostMessage"),reason:t()});var ar=D(["ascending","descending"]);var Pe=x([p({is_empty:o(!0)}),p({is_not_empty:o(!0)})]),Oe=x([t(),O(t())]),cr=p({object:D(["user","group"]),id:z(t(),ke(1))}),Dn=x([p({contains:cr}),p({does_not_contain:cr}),Pe]),lr=p({object:o("user"),id:z(t(),ke(1),Re(2e3))}),wn=x([p({contains:lr}),p({does_not_contain:lr}),p({is_empty:o(!0)}),p({is_not_empty:o(!0)})]),Ce=x([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Pe]),An=x([p({equals:E()}),p({does_not_equal:E()}),p({greater_than:E()}),p({less_than:E()}),p({greater_than_or_equal_to:E()}),p({less_than_or_equal_to:E()}),Pe]),Tn=x([p({equals:b()}),p({does_not_equal:b()})]),yr=x([p({equals:Oe}),p({does_not_equal:Oe}),Pe]),pr=D(["To-do","In progress","Complete","Current","Future"]),fr=x([pr,z(O(pr),ke(1),Re(5))]),qn=x([p({group_equals:fr}),p({group_does_not_equal:fr})]),Nn=x([yr,qn]),Fn=x([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Pe]),Q=D(["start_date","end_date"]),Un=D(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Ee=x([Un,t()]),zn=x([p({target:a(Q),equals:Ee}),p({target:a(Q),before:Ee}),p({target:a(Q),after:Ee}),p({target:a(Q),on_or_before:Ee}),p({target:a(Q),on_or_after:Ee}),p({target:a(Q),this_week:p({})}),p({target:a(Q),past_week:p({})}),p({target:a(Q),past_month:p({})}),p({target:a(Q),past_year:p({})}),p({target:a(Q),next_week:p({})}),p({target:a(Q),next_month:p({})}),p({target:a(Q),next_year:p({})}),p({target:a(Q),is_empty:o(!0)}),p({target:a(Q),is_not_empty:o(!0)})]),mr=x([p({propertyId:t(),created_by:wn}),p({propertyId:t(),title:Ce}),p({propertyId:t(),rich_text:Ce}),p({propertyId:t(),url:Ce}),p({propertyId:t(),email:Ce}),p({propertyId:t(),phone_number:Ce}),p({propertyId:t(),number:An}),p({propertyId:t(),checkbox:Tn}),p({propertyId:t(),select:yr}),p({propertyId:t(),multi_select:Fn}),p({propertyId:t(),status:Nn}),p({propertyId:t(),date:zn}),p({propertyId:t(),people:Dn})]),Hn=x([mr,p({and:O(mr)})]),Je=10,Gn=p({propertyId:t(),direction:ar}),vr=r({type:o("queryDataSource"),subscriptionId:t(),dataSourceId:Y,limit:E(),filter:a(Hn),sorts:a(O(Gn))});var dr=r({type:o("resize"),height:z(E(),be(),Se(0))});var hr=r({type:o("unsubscribeDataSourceQuery"),subscriptionId:t()});var gr=r({type:o("updatePage"),requestId:t(),pageId:H,properties:a(_e),icon:a(Ge),cover:a(Le),archived:a(b())});var br=h("type",[or,sr,vr,hr,ir,kt,It,Ct,Ot,gr,dr,ur]);function kr(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Sr(e){let i=kr(e);return i==="invalidHostMessage"||i==="invalidSandboxMessage"?{incomingType:i}:{incomingType:i,nack:{type:"invalidSandboxMessage",reason:Ln(i)}}}function Ln(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Ir=r({initializationId:t()}),Vn=r({bridgeProtocolVersion:x([E(),Fe()])});function xr(e){let{iframe:i,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:j,onCreatePage:k,onGetPage:G,onOpenPage:W,onGetUser:T,onListUsers:B,onUpdatePage:q,onResize:se}=e;function $(R,N){c("warn",{message:"Ignored unsupported sandbox message",payload:R,issues:N});let A=Sr(R);if(A.incomingType==="connect"){let J=xe(Ir,R),ee=xe(Vn,R);if(f({initializationId:J.success?J.output.initializationId:void 0,error:Lt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(A.incomingType==="initResult"){let J=xe(Ir,R);y({initializationId:J.success?J.output.initializationId:void 0,error:Jt()})}A.nack!==void 0&&s()!=="stopped"&&l(A.nack)}return function(N){let A=N.source===i.contentWindow,J=N.origin===n;if(!A||!J)return;let ee=xe(br,N.data);if(!ee.success){$(N.data,ee.issues);return}let _=ee.output;if(!tr(_)&&s()!=="initialized"){c("warn",{message:`Ignored ${_.type} before initialization completed`,payload:_});return}switch(c("in",_),_.type){case"connect":m(_);return;case"initResult":S(_);return;case"queryDataSource":I(_);return;case"unsubscribeDataSourceQuery":j(_);return;case"createPage":k(_);return;case"openPage":W(_);return;case"getPage":G(_);return;case"getUser":T(_);return;case"listUsers":B(_);return;case"updatePage":q(_);return;case"resize":se(_);return;case"invalidHostMessage":return;default:ie(_)}}}var Ae=class{constructor(i){this.onUnsubscribe=i}onUnsubscribe;bySubscriptionId=new Map;subscribe(i){this.unsubscribe(i.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(i.subscriptionId,{message:i,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(i,n){return this.bySubscriptionId.get(i)?.token===n}unsubscribe(i){this.bySubscriptionId.delete(i)&&this.onUnsubscribe(i)}refresh(i){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===i){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(i,n){let s=this.bySubscriptionId.get(i);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let i of this.bySubscriptionId.keys())this.unsubscribe(i)}};function _r(e,i){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Qn(s,i);if(c!==void 0)return c}}function Qn(e,i){if(!Object.hasOwn(i.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let n=i.propertiesById[e.propertyId],s=Object.keys(e).find(y=>y!=="propertyId");if(s!==n.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${n.type}".`,isRetryable:!1};if("status"in e&&n.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,I=(Array.isArray(m)?m:[m]).find(j=>!n.groups.some(k=>k.name===j));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}let c=$n(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=Xn(c.operator).find(y=>!l.has(y));if(f!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${f}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function $n(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let i=e.status;return"group_equals"in i||"group_does_not_equal"in i?void 0:{propertyType:"status",operator:i}}}function Xn(e){let i;if("equals"in e)i=e.equals;else if("does_not_equal"in e)i=e.does_not_equal;else if("contains"in e)i=e.contains;else if("contains_all"in e)i=e.contains_all;else if("does_not_contain"in e)i=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ie(e);return Array.isArray(i)?i:[i]}var Wn=new Set(ut);function Cr(e,i){if(e===void 0)return;if(e.length>Je)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Je} entries.`,isRetryable:!1};let n=new Set;for(let s of e){if(n.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(n.add(s.propertyId),!Object.hasOwn(i.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=i.propertiesById[s.propertyId];if(!Wn.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}var Or=5;function Kn(e){let{iframe:i,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G}=e,W=Math.max(I??3,3),T={},B=!1,q,se,$=5,R=new Ae(u=>{m?.(u)});function N(u,C){y?.(u,C)}function A(u){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ie(C)}let w=Yt(u,$);N("out",w),i.contentWindow?.postMessage(w,S)}function J(u){A(fe(we,u))}function ee(u){A(u)}function _(u){let C=v.status;switch(C){case"initialized":A(fe(Ht,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(u,C){if(C===void 0)return;let w=await C(u);_({type:`${u.type}Result`,requestId:u.requestId,...w})}function je(u){let C=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};_(C)}async function he(u,C=R.subscribe(u)){try{let w=Zn(se,u.dataSourceId),ce=Yn(u,w);if(ce!==void 0){R.isCurrent(u.subscriptionId,C)&&(R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:{status:"error",error:ce}}));return}let Te=await s.queryDataSource(u);if(!R.isCurrent(u.subscriptionId,C))return;Te.status==="error"&&!Te.error.isRetryable&&R.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:Te})}finally{let w=R.finish(u.subscriptionId,C);w!==void 0&&he(w.message,w.token)}}function ae(u){v.status==="stopped"||v.status==="error"||(Object.assign(T,u),g())}function g(){if(v.status!=="initialized")return;let u=T;T={},u.theme!==void 0&&_({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&_({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&_({type:"parentChanged",parent:u.parent}),u.page!==void 0&&_({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&_({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&_({type:"currentUserChanged",currentUser:u.currentUser})}let v=Zt({async prepareInit(u){$=u.bridgeProtocolVersion;let C=await n(u);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:J,warn:u=>N("warn",u),flushPendingHostStateChanges:g,minBridgeProtocolVersion:W,noConnectTimeoutMs:j,initialStateTimeoutMs:k,noInitResultTimeoutMs:G,stopHostWithFailure:Ke,onInitResult(u){u.status==="success"&&q!==void 0&&l?.({manifest:q,initialHeight:u.initialHeight})},onConnectionFailure:f});function V(u){if(u.status==="error")return u;q=fe(pe,u.initialState.manifest),c?.(q);let C={...u.initialState,...T};T={};let w={...fe(rt(er,["manifest"]),C),manifest:q};if($<Or&&w.page.type==="unavailable")return{status:"error",error:Xe()};let ce=Pr(w.manifest,w.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=w.dataSources,B=!0,{status:"success",initialState:w})}let K=xr({iframe:i,sandboxOrigin:S,getInitStatus:()=>v.status,emit:N,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:u=>R.unsubscribe(u.subscriptionId),onCreatePage:u=>ue(u,s.createPage),onGetPage:u=>ue(u,s.getPage),onOpenPage:u=>ue(u,s.openPage),onGetUser:u=>ue(u,s.getUser),onListUsers:u=>ue(u,s.listUsers),onUpdatePage:u=>ue(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",K),i.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",K),i.removeEventListener("load",v.onIframeLoad),v.stop(),R.unsubscribeAll()}function Ke(u){Be(),N("warn",u),f?.(u)}return{stop:Be,setTheme(u){ae({theme:u})},setContrastMode(u){ae({contrastMode:u})},setParent(u){ae({parent:u})},setPage(u){if(u.type==="unavailable"&&$<Or&&(v.status==="preparingInit"&&B||v.status==="waitingForInitResult"||v.status==="initialized")){Ke({...Xe(),phase:"runtime",source:"host"});return}ae({page:u})},setCurrentUser(u){ae({currentUser:u})},setDataSources(u){let C={bindings:fe(le,u.bindings)};if(v.hasConnectedSandbox&&q!==void 0&&Pr(q,C)!==void 0){N("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:u}){if(v.status!=="initialized")return;let C=fe(Y,u),w=R.refresh(C);if(w===void 0){N("warn",`No active query exists for data source "${u}"`);return}for(let ce of w)he(ce.message,ce.token)}}}function Zn(e,i){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===i)?.collectionSchema}function Pr(e,i){for(let[n,s]of Object.entries(e.dataSources)){let c=i.bindings[n];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Qt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return $t();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return Xt()}}}function Yn(e,i){return i===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:_r(e.filter,i)??Cr(e.sorts,i)}function eo(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}export{Kn as createCustomBlockHost,jr as getAutoBoundPropertyIdsByKey,eo as isLocalCustomBlockUrl};
|
|
1
|
+
function Ar(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=qr({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function qr(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=tt(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||tt(y.name)===c));return l.length===1?l[0][0]:void 0}function tt(e){return e.trim().toLowerCase()}var Re,Tr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Te(e){return!e&&!Re?Tr:{lang:e?.lang??Re?.lang,message:e?.message,abortEarly:e?.abortEarly??Re?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Re?.abortPipeEarly}}var Nr;function Fr(e){return Nr?.get(e)}var Ur;function zr(e){return Ur?.get(e)}var Hr;function Lr(e,o){return Hr?.get(e)?.get(o)}function ge(e){let o=typeof e;return o==="string"?`"${e}"`:o==="number"||o==="bigint"||o==="boolean"?`${e}`:o==="object"||o==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":o}function j(e,o,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${o}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},S=e.kind==="schema",I=c?.message??e.message??Lr(e.reference,m.lang)??(S?zr(m.lang):null)??s.message??Fr(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 rt=new WeakMap;function U(e){let o=rt.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Te())}},rt.set(e,o)),o}function Gr(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 Vr=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(o){return o}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(o,n){return o.typed&&!this.requirement(o.value)&&j(this,"finite",o,n),o}}}function Me(e,o){return{kind:"validation",type:"max_length",reference:Me,async:!1,expects:`<=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,o){return{kind:"validation",type:"min_length",reference:ke,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,o){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&j(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}function Fe(e,o){return{kind:"validation",type:"regex",reference:Fe,async:!1,expects:`${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!this.requirement.test(n.value)&&j(this,"format",n,s),n}}}function Ue(e){return{kind:"transformation",type:"transform",reference:Ue,async:!1,operation:e,"~run"(o){return o.value=this.operation(o.value),o}}}var ot={abortEarly:!0};function it(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 st(e,o){return!e["~run"]({value:o},ot).issues}function E(e,o){return{kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else j(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return U(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:j(this,"type",o,n),o}}}function i(e,o){return{kind:"schema",type:"literal",reference:i,expects:ge(e),async:!1,literal:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:j(this,"type",n,s),n}}}function ze(e){return{kind:"schema",type:"nan",reference:ze,expects:"NaN",async:!1,message:e,get"~standard"(){return U(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:j(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 U(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 U(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function r(e,o){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return U(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]=it(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else j(this,"type",n,s);return n}}}function a(e,o){return{kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return U(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function D(e,o){return{kind:"schema",type:"picklist",reference:D,expects:Ne(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:j(this,"type",n,s),n}}}function z(e,o,n){return{kind:"schema",type:"record",reference:z,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return U(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Gr(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 B of m.issues)B.path=[I],s.issues?.push(B);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 B of S.issues)B.path?B.path.unshift(I):B.path=[I],s.issues?.push(B);if(s.issues||(s.issues=S.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!S.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=S.value)}}else j(this,"type",s,c);return s}}}function p(e,o){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return U(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]=it(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){j(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else j(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return U(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:j(this,"type",o,n),o}}}function nt(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:Ne(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return U(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];j(this,"type",n,s,{issues:nt(l)}),n.typed=!0}else{if(f?.length===1)return f[0];j(this,"type",n,s,{issues:nt(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return U(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 U(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(B,k)=>{for(let L of B.options){if(L.type==="variant")I(L,new Set(k).add(L.key));else{let W=!0,T=0;for(let R of k){let N=L.entries[R];if(R in l?N["~run"]({typed:!1,value:l[R]},ot).issues:N.type!=="exact_optional"&&N.type!=="optional"&&N.type!=="nullish"){W=!1,m!==R&&(y<T||y===T&&R in l&&!(m in l))&&(y=T,m=R,S=[]),m===R&&S.push(L.entries[R].expects);break}T++}if(W){let R=L["~run"]({value:l},c);(!f||!f.typed&&R.typed)&&(f=R)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;j(this,"type",s,c,{input:l[m],expected:Ne(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else j(this,"type",s,c);return s}}}function ut(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return U(this)}}}function fe(e,o,n){let s=e["~run"]({value:o},Te(n));if(s.issues)throw new Vr(s.issues);return s.value}function H(...e){return{...e[0],pipe:e,get"~standard"(){return U(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=H(t(),te("NotionBlockId")),Y=H(t(),te("NotionDataSourceId")),q=H(t(),te("NotionPageId")),at=H(t(),te("NotionAgentId")),ct=H(t(),te("NotionSpaceId"));var lt=D(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),He=r({id:t(),name:t(),color:a(lt),description:a(t())}),$r=r({id:t(),name:t(),color:a(lt),option_ids:E(t())}),Qr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:a(t())}),Xr=["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"],pt=D(Xr),ft=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Le=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:E(He)}),r({...P.entries,type:i("multi_select"),options:E(He)}),r({...P.entries,type:i("status"),options:E(He),groups:E($r)}),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(Qr)}),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 mt={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 yt=r({id:Y,table:t(),spaceId:a(ct)}),vt=r({id:a(Y),propertiesById:z(t(),Le)}),fo=r({key:t(),collectionPointer:a(yt),collectionSchema:a(vt),propertyIdsByKey:z(t(),a(t())),propertySchemasById:z(t(),Le)}),Wr=r({collectionPointer:a(yt),collectionSchema:a(vt),propertyIdsByKey:a(z(t(),a(t())))}),le=z(t(),Wr);var Jr=h("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),Kr=r({name:t(),description:a(t()),type:pt}),Zr=r({name:t(),description:a(t()),icon:a(Jr),properties:a(z(t(),Kr),{})}),pe=r({version:i(1),name:a(t()),description:a(t()),slashCommand:a(t()),icon:a(r({type:i("emoji"),emoji:t()})),dataSources:a(z(t(),Zr),{})});var me=D(["standard","high"]),dt="standard";var ht=r({type:i("contrastModeChanged"),contrastMode:me});var ne=h("type",[r({type:i("page_id"),page_id:q}),r({type:i("data_source_id"),data_source_id:Y}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:re}),r({type:i("agent_id"),agent_id:at}),r({type:i("unavailable")})]);var ye=h("type",[r({type:i("unavailable")}),r({type:i("page"),id:q,parent:ne})]),Yr=r({type:i("emoji"),emoji:t()}),en=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:a(t()),url:a(t())})}),bt=r({type:i("external"),external:r({url:t()})}),kt=r({type:i("file"),file:r({url:t(),expiry_time:a(t())})}),Ve=h("type",[Yr,en,bt,kt]),$e=h("type",[bt,kt]),X=Z(t()),gt=z(t(),Ie()),Ge=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)})]),tn=r({start:t(),end:a(X),time_zone:a(X)}),rn=x([r({object:a(i("user")),id:t()}),r({object:i("group"),id:t(),name:a(X)})]),nn=r({id:t()}),on=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())})})]),sn=r({lat:O(),lon:O(),name:a(X),address:a(X),aws_place_id:a(X),google_place_id:a(X)}),V={id:t()},un=h("type",[r({...V,type:i("title"),title:E(gt)}),r({...V,type:i("rich_text"),rich_text:E(gt)}),r({...V,type:i("number"),number:Z(O())}),r({...V,type:i("url"),url:X}),r({...V,type:i("email"),email:X}),r({...V,type:i("phone_number"),phone_number:X}),r({...V,type:i("checkbox"),checkbox:b()}),r({...V,type:i("select"),select:Z(Ge)}),r({...V,type:i("status"),status:Z(Ge)}),r({...V,type:i("multi_select"),multi_select:E(Ge)}),r({...V,type:i("date"),date:Z(tn)}),r({...V,type:i("people"),people:E(rn)}),r({...V,type:i("relation"),has_more:a(b()),relation:E(nn)}),r({...V,type:i("files"),files:E(on)}),r({...V,type:i("place"),place:Z(sn)})]),_e=z(t(),un),ve=r({object:i("page"),id:q,parent:ne,properties:_e,created_time:a(t()),last_edited_time:a(t()),icon:a(Ve),cover:a($e),url:a(t()),public_url:a(t()),is_archived:b(),in_trash:b()});var an=t(),cn=r({code:an,message:t(),isRetryable:b()}),St=h("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:cn})]);var Qe=H(t(),te("NotionUserId")),oe=r({object:i("user"),id:Qe,name:a(t()),avatar_url:Z(t()),type:i("person"),person:r({email:t()})}),It=r({object:i("list"),results:E(oe),next_cursor:Z(t()),has_more:b(),type:i("user"),user:z(t(),Ie())});var xt=r({type:i("currentUserChanged"),currentUser:oe});var _t=r({type:i("dataSourcesChanged"),dataSources:r({bindings:le})});var ln=t(),pn=r({code:ln,message:t(),isRetryable:b()}),Ct=r({type:i("getPage"),requestId:t(),pageId:q}),Ot=h("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:pn})]);var fn=t(),mn=r({code:fn,message:t(),isRetryable:b()}),Et=r({type:i("getUser"),requestId:t(),userId:Qe}),Pt=h("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:oe}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:mn})]);var de=D(["light","dark"]);var yn=t(),vn=r({code:yn,message:t(),isRetryable:b()});var we=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:vn})]);var jt=r({type:i("invalidSandboxMessage"),reason:t()});var dn=t(),hn=r({code:dn,message:t(),isRetryable:b()}),Bt=r({type:i("listUsers"),requestId:t(),startCursor:a(t()),pageSize:a(O())}),Rt=h("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:It}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:hn})]);var gn=D(["side_peek","center_peek"]),bn=t(),kn=r({code:bn,message:t(),isRetryable:b()}),Mt=r({type:i("openPage"),requestId:t(),pageId:q,mode:gn}),Dt=h("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:q}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:kn})]);var wt=r({type:i("pageChanged"),page:ye});var At=r({type:i("parentChanged"),parent:ne});var qt=r({unit:D(["year","month","week","day"]),value:O(),time:t(),defaultTimeZone:a(t())}),Sn=r({unit:D(["hour","minute"]),value:O()}),Tt=r({unit:i("none")}),In=x([qt,Sn]),Nt=a(x([qt,Tt])),Ft=a(x([In,Tt])),xn=r({type:i("date"),start_date:t(),reminder:Nt}),_n=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:Nt}),Cn=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:a(t()),reminder:Ft}),On=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:a(t()),reminder:Ft}),Ut=h("type",[xn,_n,Cn,On]);var zt=r({id:t(),table:t()});var Ht=x([t(),O(),b(),Ut,E(t()),E(zt)]);var Lt=r({id:q,is_archived:b(),in_trash:b(),propertiesById:z(t(),a(Ht))});var En=t(),Pn=r({code:En,message:t(),isRetryable:b()}),Gt=h("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:E(Lt),hasMore:b()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:Pn})]);var Vt=r({type:i("themeChanged"),theme:de});var jn=t(),Bn=r({code:jn,message:t(),isRetryable:b()}),$t=h("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:Bn})]);var Qt=h("type",[we,Vt,ht,At,wt,xt,_t,Gt,St,Ot,Pt,Rt,Dt,$t,jt]);function Xt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Wt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Xe(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${o}`,isRetryable:!1}}function We(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 Je(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Jt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Kt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function Zt(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function Yt(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function er(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function tr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function rr(){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 Ke(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var Rn=5e3,Mn=5e3,Dn=5e3;function nr(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=Rn,initialStateTimeoutMs:y=Mn,noInitResultTimeoutMs:m=Dn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:B}=e,k="waitingForConnect",L,W,T,R,N=!1,se=!1;function Q(){L!==void 0&&(window.clearTimeout(L),L=void 0)}function M(){W!==void 0&&(window.clearTimeout(W),W=void 0)}function F(){T!==void 0&&(window.clearTimeout(T),T=void 0)}function A(g){let{initializationId:v,error:G,phase:K,source:Be}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ie(k)}k="error",R=v,Q(),M(),n({type:"init",initializationId:v,status:"error",error:G}),B?.({...G,phase:K,source:Be})}async function J(g){if(k==="waitingForConnect"){k="preparingInit",R=g.initializationId,Q(),W=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Jt();s({...v,initializationId:g.initializationId}),A({initializationId:g.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await o(g);if(k!=="preparingInit")return;if(M(),v.status==="error"){A({initializationId:g.initializationId,error:v.error,phase:"init",source:"host"});return}k="waitingForInitResult";let G={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??dt,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(G),T=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let K=er();B?.({...K,phase:"initResult",source:"host"}),s({...K,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),A({initializationId:g.initializationId,error:rr(),phase:"init",source:"host"})}}}function ee(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!Ke(g.bridgeProtocolVersion)){let v=Xe({currentBridgeProtocolVersion:g.bridgeProtocolVersion});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.bridgeProtocolVersion<l){let v=We({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});A({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.status==="error"){A({initializationId:g.initializationId,error:g.error,phase:"connect",source:"sandbox"});return}se=!0,J(g)}}function _(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:G}=g;if(v===void 0)return"nack";let K=g.error;return G!==void 0&&(Ke(G)?G<l&&(K=We({currentBridgeProtocolVersion:G,minBridgeProtocolVersion:l})):K=Xe({currentBridgeProtocolVersion:G})),A({initializationId:v,error:K,phase:"connect",source:"host"}),"handled"}function ue(g){let{initializationId:v,error:G}=g;k!=="waitingForInitResult"||v===void 0||v!==R||(Q(),F(),k="error",s(G),B?.({...G,phase:"initResult",source:"host"}))}function je(){if(k!=="stopped"){if(N){S({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}N=!0,Q(),k==="waitingForConnect"&&(L=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Xt();s(g),B?.({...g,phase:"connect",source:"host"})},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==R){s({message:"Ignored stale or unexpected initResult",payload:g});return}F(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():B?.({...g.error,phase:"initResult",source:"sandbox"}),I?.(g)}function ae(){k="stopped",Q(),M(),F()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:ee,handleInitResult:he,handleInvalidConnect:_,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function or(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,...mt}}}]))}}}var ir=r({theme:de,contrastMode:a(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function sr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var ur=r({code:t(),message:t(),isRetryable:b()});var ar={type:i("connect"),initializationId:t(),bridgeProtocolVersion:O(),sdkVersion:t()},cr=h("status",[r({status:i("success"),manifest:a(pe),...ar}),r({status:i("error"),error:ur,...ar})]);var wn=h("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:re}),r({type:i("after"),blockId:re})]),An=h("type",[r({type:i("page_id"),page_id:q}),r({type:i("data_source_id"),data_source_id:Y})]),lr=r({type:i("createPage"),requestId:t(),parent:An,properties:_e,position:a(wn)});var qn=t(),Tn=r({code:qn,message:t(),isRetryable:b()}),pr=h("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:a(H(O(),be(),Se(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Tn})]);var fr=r({type:i("invalidHostMessage"),reason:t()});var mr=D(["ascending","descending"]);var yr=H(q,Fe(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),Ue(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),Ze=x([p({contains:yr}),p({does_not_contain:yr})]),Pe=x([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ee=x([t(),E(t())]),vr=p({object:D(["user","group"]),id:H(t(),ke(1))}),Nn=x([p({contains:vr}),p({does_not_contain:vr}),Pe]),dr=p({object:i("user"),id:H(t(),ke(1),Me(2e3))}),Fn=x([p({contains:dr}),p({does_not_contain:dr}),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]),Un=x([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]),zn=x([p({equals:b()}),p({does_not_equal:b()})]),kr=x([p({equals:Ee}),p({does_not_equal:Ee}),Pe]),hr=D(["To-do","In progress","Complete","Current","Future"]),gr=x([hr,H(E(hr),ke(1),Me(5))]),Hn=x([p({group_equals:gr}),p({group_does_not_equal:gr})]),Ln=x([kr,Hn]),Gn=x([p({contains:Ee}),p({contains_all:Ee}),p({does_not_contain:Ee}),Pe]),$=D(["start_date","end_date"]),Vn=D(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Oe=x([Vn,t()]),$n=x([p({target:a($),equals:Oe}),p({target:a($),before:Oe}),p({target:a($),after:Oe}),p({target:a($),on_or_before:Oe}),p({target:a($),on_or_after:Oe}),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)})]),br=x([p({propertyId:t(),relation:Ze}),p({propertyId:t(),created_by:Fn}),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:Un}),p({propertyId:t(),checkbox:zn}),p({propertyId:t(),select:kr}),p({propertyId:t(),multi_select:Gn}),p({propertyId:t(),status:Ln}),p({propertyId:t(),date:$n}),p({propertyId:t(),people:Nn})]),Qn=x([br,p({and:E(br)})]),Ye=10,Xn=p({propertyId:t(),direction:mr}),Sr=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Y,limit:O(),filter:a(Qn),sorts:a(E(Xn))});var Ir=r({type:i("resize"),height:H(O(),be(),Se(0))});var xr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var _r=r({type:i("updatePage"),requestId:t(),pageId:q,properties:a(_e),icon:a(Ve),cover:a($e),archived:a(b())});var Cr=h("type",[cr,pr,Sr,xr,lr,Ct,Et,Bt,Mt,_r,Ir,fr]);function Or(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Er(e){let o=Or(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Wn(o)}}}function Wn(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()}),Jn=r({bridgeProtocolVersion:x([O(),ze()])});function jr(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:B,onCreatePage:k,onGetPage:L,onOpenPage:W,onGetUser:T,onListUsers:R,onUpdatePage:N,onResize:se}=e;function Q(M,F){c("warn",{message:"Ignored unsupported sandbox message",payload:M,issues:F});let A=Er(M);if(A.incomingType==="connect"){let J=xe(Pr,M),ee=xe(Jn,M);if(f({initializationId:J.success?J.output.initializationId:void 0,error:Wt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(A.incomingType==="initResult"){let J=xe(Pr,M);y({initializationId:J.success?J.output.initializationId:void 0,error:tr()})}A.nack!==void 0&&s()!=="stopped"&&l(A.nack)}return function(F){let A=F.source===o.contentWindow,J=F.origin===n;if(!A||!J)return;let ee=xe(Cr,F.data);if(!ee.success){Q(F.data,ee.issues);return}let _=ee.output;if(!sr(_)&&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":B(_);return;case"createPage":k(_);return;case"openPage":W(_);return;case"getPage":L(_);return;case"getUser":T(_);return;case"listUsers":R(_);return;case"updatePage":N(_);return;case"resize":se(_);return;case"invalidHostMessage":return;default:ie(_)}}}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 Br(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Kn(s,o);if(c!==void 0)return c}}function Kn(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(B=>!n.groups.some(k=>k.name===B));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}if("relation"in e&&!st(Ze,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Zn(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=Yn(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 Zn(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 Yn(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 eo=new Set(ft);function Rr(e,o){if(e===void 0)return;if(e.length>Ye)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Ye} 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(!eo.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 ro(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:B,initialStateTimeoutMs:k,noInitResultTimeoutMs:L}=e,W=Math.max(I??3,3),T={},R=!1,N,se,Q=5,M=new Ae(u=>{m?.(u)});function F(u,C){y?.(u,C)}function A(u){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ie(C)}let w=or(u,Q);F("out",w),o.contentWindow?.postMessage(w,S)}function J(u){A(fe(we,u))}function ee(u){A(u)}function _(u){let C=v.status;switch(C){case"initialized":A(fe(Qt,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(u,C){if(C===void 0)return;let w=await C(u);_({type:`${u.type}Result`,requestId:u.requestId,...w})}function je(u){let C=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};_(C)}async function he(u,C=M.subscribe(u)){try{let w=no(se,u.dataSourceId),ce=oo(u,w);if(ce!==void 0){M.isCurrent(u.subscriptionId,C)&&(M.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:{status:"error",error:ce}}));return}let qe=await s.queryDataSource(u);if(!M.isCurrent(u.subscriptionId,C))return;qe.status==="error"&&!qe.error.isRetryable&&M.unsubscribe(u.subscriptionId),je({subscriptionId:u.subscriptionId,response:qe})}finally{let w=M.finish(u.subscriptionId,C);w!==void 0&&he(w.message,w.token)}}function ae(u){v.status==="stopped"||v.status==="error"||(Object.assign(T,u),g())}function g(){if(v.status!=="initialized")return;let u=T;T={},u.theme!==void 0&&_({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&_({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&_({type:"parentChanged",parent:u.parent}),u.page!==void 0&&_({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&_({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&_({type:"currentUserChanged",currentUser:u.currentUser})}let v=nr({async prepareInit(u){Q=u.bridgeProtocolVersion;let C=await n(u);return v.status!=="preparingInit"?C:G(C)},sendInitMessage:J,warn:u=>F("warn",u),flushPendingHostStateChanges:g,minBridgeProtocolVersion:W,noConnectTimeoutMs:B,initialStateTimeoutMs:k,noInitResultTimeoutMs:L,stopHostWithFailure:et,onInitResult(u){u.status==="success"&&N!==void 0&&l?.({manifest:N,initialHeight:u.initialHeight})},onConnectionFailure:f});function G(u){if(u.status==="error")return u;N=fe(pe,u.initialState.manifest),c?.(N);let C={...u.initialState,...T};T={};let w={...fe(ut(ir,["manifest"]),C),manifest:N};if(Q<Dr&&w.page.type==="unavailable")return{status:"error",error:Je()};let ce=wr(w.manifest,w.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=w.dataSources,R=!0,{status:"success",initialState:w})}let K=jr({iframe:o,sandboxOrigin:S,getInitStatus:()=>v.status,emit:F,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:u=>M.unsubscribe(u.subscriptionId),onCreatePage:u=>ue(u,s.createPage),onGetPage:u=>ue(u,s.getPage),onOpenPage:u=>ue(u,s.openPage),onGetUser:u=>ue(u,s.getUser),onListUsers:u=>ue(u,s.listUsers),onUpdatePage:u=>ue(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",K),o.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",K),o.removeEventListener("load",v.onIframeLoad),v.stop(),M.unsubscribeAll()}function et(u){Be(),F("warn",u),f?.(u)}return{stop:Be,setTheme(u){ae({theme:u})},setContrastMode(u){ae({contrastMode:u})},setParent(u){ae({parent:u})},setPage(u){if(u.type==="unavailable"&&Q<Dr&&(v.status==="preparingInit"&&R||v.status==="waitingForInitResult"||v.status==="initialized")){et({...Je(),phase:"runtime",source:"host"});return}ae({page:u})},setCurrentUser(u){ae({currentUser:u})},setDataSources(u){let C={bindings:fe(le,u.bindings)};if(v.hasConnectedSandbox&&N!==void 0&&wr(N,C)!==void 0){F("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:u}){if(v.status!=="initialized")return;let C=fe(Y,u),w=M.refresh(C);if(w===void 0){F("warn",`No active query exists for data source "${u}"`);return}for(let ce of w)he(ce.message,ce.token)}}}function no(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function wr(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 Kt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return Zt();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return Yt()}}}function oo(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}:Br(e.filter,o)??Rr(e.sorts,o)}function io(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}export{ro as createCustomBlockHost,Ar as getAutoBoundPropertyIdsByKey,io as isLocalCustomBlockUrl};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type { GetPageMessage } from "./protocol/messages/getPage.js";
|
|
|
4
4
|
export type { GetUserMessage } from "./protocol/messages/getUser.js";
|
|
5
5
|
export type { ListUsersMessage } from "./protocol/messages/listUsers.js";
|
|
6
6
|
export type { OpenPageMessage } from "./protocol/messages/openPage.js";
|
|
7
|
-
export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockStatusFilterOperator, CustomBlockStatusGroupFilterOperator, CustomBlockStatusGroupName, CustomBlockTextFilterOperator, QueryDataSourceMessage, ResolvedCustomBlockDataSourceFilter, ResolvedCustomBlockDataSourcePropertyFilter, ResolvedCustomBlockDataSourceSort, } from "./protocol/messages/queryDataSource.js";
|
|
7
|
+
export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperator, CustomBlockCreatedByFilterOperator, CustomBlockDateFilterOperator, CustomBlockNumberFilterOperator, CustomBlockOptionFilterOperator, CustomBlockPeopleFilterOperator, CustomBlockPersonFilterValue, CustomBlockRelationFilterOperator, CustomBlockStatusFilterOperator, CustomBlockStatusGroupFilterOperator, CustomBlockStatusGroupName, CustomBlockTextFilterOperator, QueryDataSourceMessage, ResolvedCustomBlockDataSourceFilter, ResolvedCustomBlockDataSourcePropertyFilter, ResolvedCustomBlockDataSourceSort, } from "./protocol/messages/queryDataSource.js";
|
|
8
8
|
export type { ResizeMessage } from "./protocol/messages/resize.js";
|
|
9
9
|
export type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
|
|
10
10
|
export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageIcon, NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, NotionSelectOptionInput, } from "./protocol/pages/page.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAQnD;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"}
|
|
@@ -21,12 +21,9 @@ export function invalidConnectPayloadError() {
|
|
|
21
21
|
}
|
|
22
22
|
export function invalidProtocolVersionError(args) {
|
|
23
23
|
const { currentBridgeProtocolVersion } = args;
|
|
24
|
-
const versionText = currentBridgeProtocolVersion
|
|
25
|
-
? `: ${currentBridgeProtocolVersion}`
|
|
26
|
-
: ".";
|
|
27
24
|
return {
|
|
28
25
|
code: "invalid_protocol_version",
|
|
29
|
-
message: `Sandbox reported an invalid bridge protocol version ${
|
|
26
|
+
message: `Sandbox reported an invalid bridge protocol version: ${currentBridgeProtocolVersion}`,
|
|
30
27
|
// The sandbox must be updated to a supported protocol version.
|
|
31
28
|
isRetryable: false,
|
|
32
29
|
};
|
|
@@ -203,7 +203,7 @@ export function createInitializationController(options) {
|
|
|
203
203
|
if (bridgeProtocolVersion !== undefined) {
|
|
204
204
|
if (!isValidBridgeProtocolVersion(bridgeProtocolVersion)) {
|
|
205
205
|
error = invalidProtocolVersionError({
|
|
206
|
-
currentBridgeProtocolVersion:
|
|
206
|
+
currentBridgeProtocolVersion: bridgeProtocolVersion,
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
else if (bridgeProtocolVersion < minBridgeProtocolVersion) {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
+
export declare const customBlockRelationFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
|
|
3
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
4
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
5
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
6
|
+
}, undefined>], undefined>;
|
|
7
|
+
export type CustomBlockRelationFilterOperator = v.InferOutput<typeof customBlockRelationFilterOperatorSchema>;
|
|
2
8
|
declare const customBlockPersonFilterValueSchema: v.StrictObjectSchema<{
|
|
3
9
|
readonly object: v.PicklistSchema<["user", "group"], undefined>;
|
|
4
10
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
@@ -169,6 +175,13 @@ export declare const customBlockDateFilterOperatorSchema: v.UnionSchema<[v.Stric
|
|
|
169
175
|
}, undefined>], undefined>;
|
|
170
176
|
export type CustomBlockDateFilterOperator = v.InferOutput<typeof customBlockDateFilterOperatorSchema>;
|
|
171
177
|
export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionSchema<[v.StrictObjectSchema<{
|
|
178
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
179
|
+
readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
|
|
180
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
181
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
182
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
183
|
+
}, undefined>], undefined>;
|
|
184
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
172
185
|
readonly propertyId: v.StringSchema<undefined>;
|
|
173
186
|
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
174
187
|
readonly contains: v.StrictObjectSchema<{
|
|
@@ -410,6 +423,13 @@ export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionS
|
|
|
410
423
|
}, undefined>], undefined>;
|
|
411
424
|
export type ResolvedCustomBlockDataSourcePropertyFilter = v.InferOutput<typeof resolvedCustomBlockDataSourcePropertyFilterSchema>;
|
|
412
425
|
export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
|
|
426
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
427
|
+
readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
|
|
428
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
429
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
430
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
431
|
+
}, undefined>], undefined>;
|
|
432
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
413
433
|
readonly propertyId: v.StringSchema<undefined>;
|
|
414
434
|
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
415
435
|
readonly contains: v.StrictObjectSchema<{
|
|
@@ -650,6 +670,13 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
|
|
|
650
670
|
}, undefined>], undefined>], undefined>;
|
|
651
671
|
}, undefined>], undefined>, v.StrictObjectSchema<{
|
|
652
672
|
readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
|
|
673
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
674
|
+
readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
|
|
675
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
676
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
677
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
678
|
+
}, undefined>], undefined>;
|
|
679
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
653
680
|
readonly propertyId: v.StringSchema<undefined>;
|
|
654
681
|
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
655
682
|
readonly contains: v.StrictObjectSchema<{
|
|
@@ -915,6 +942,13 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
|
915
942
|
readonly limit: v.NumberSchema<undefined>;
|
|
916
943
|
/** A sandbox-resolved property filter. */
|
|
917
944
|
readonly filter: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
|
|
945
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
946
|
+
readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
|
|
947
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
948
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
949
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
950
|
+
}, undefined>], undefined>;
|
|
951
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
918
952
|
readonly propertyId: v.StringSchema<undefined>;
|
|
919
953
|
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
920
954
|
readonly contains: v.StrictObjectSchema<{
|
|
@@ -1155,6 +1189,13 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
|
1155
1189
|
}, undefined>], undefined>], undefined>;
|
|
1156
1190
|
}, undefined>], undefined>, v.StrictObjectSchema<{
|
|
1157
1191
|
readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
|
|
1192
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
1193
|
+
readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
|
|
1194
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
1195
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
1196
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
1197
|
+
}, undefined>], undefined>;
|
|
1198
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
1158
1199
|
readonly propertyId: v.StringSchema<undefined>;
|
|
1159
1200
|
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
1160
1201
|
readonly contains: v.StrictObjectSchema<{
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { notionSortDirectionSchema } from "../dataSources/sortDirection.js";
|
|
3
|
-
import { notionDataSourceIdSchema } from "../ids.js";
|
|
3
|
+
import { notionDataSourceIdSchema, notionPageIdSchema } from "../ids.js";
|
|
4
|
+
const relationPageIdSchema = v.pipe(notionPageIdSchema, v.regex(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i), v.transform(id => id
|
|
5
|
+
.replaceAll("-", "")
|
|
6
|
+
.toLowerCase()
|
|
7
|
+
.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5")));
|
|
8
|
+
export const customBlockRelationFilterOperatorSchema = v.union([
|
|
9
|
+
v.strictObject({ contains: relationPageIdSchema }),
|
|
10
|
+
v.strictObject({ does_not_contain: relationPageIdSchema }),
|
|
11
|
+
]);
|
|
4
12
|
const emptyOperatorSchema = v.union([
|
|
5
13
|
v.strictObject({ is_empty: v.literal(true) }),
|
|
6
14
|
v.strictObject({ is_not_empty: v.literal(true) }),
|
|
@@ -156,6 +164,10 @@ export const customBlockDateFilterOperatorSchema = v.union([
|
|
|
156
164
|
}),
|
|
157
165
|
]);
|
|
158
166
|
export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
|
|
167
|
+
v.strictObject({
|
|
168
|
+
propertyId: v.string(),
|
|
169
|
+
relation: customBlockRelationFilterOperatorSchema,
|
|
170
|
+
}),
|
|
159
171
|
v.strictObject({
|
|
160
172
|
propertyId: v.string(),
|
|
161
173
|
created_by: customBlockCreatedByFilterOperatorSchema,
|
|
@@ -66,6 +66,13 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
66
66
|
readonly dataSourceId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
67
67
|
readonly limit: v.NumberSchema<undefined>;
|
|
68
68
|
readonly filter: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
|
|
69
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
70
|
+
readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
|
|
71
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
72
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
73
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
74
|
+
}, undefined>], undefined>;
|
|
75
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
69
76
|
readonly propertyId: v.StringSchema<undefined>;
|
|
70
77
|
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
71
78
|
readonly contains: v.StrictObjectSchema<{
|
|
@@ -306,6 +313,13 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
306
313
|
}, undefined>], undefined>], undefined>;
|
|
307
314
|
}, undefined>], undefined>, v.StrictObjectSchema<{
|
|
308
315
|
readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
|
|
316
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
317
|
+
readonly relation: v.UnionSchema<[v.StrictObjectSchema<{
|
|
318
|
+
readonly contains: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
319
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
320
|
+
readonly does_not_contain: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>, v.RegexAction<string & v.Brand<"NotionPageId">, undefined>, v.TransformAction<string & v.Brand<"NotionPageId">, string>]>;
|
|
321
|
+
}, undefined>], undefined>;
|
|
322
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
309
323
|
readonly propertyId: v.StringSchema<undefined>;
|
|
310
324
|
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
311
325
|
readonly contains: v.StrictObjectSchema<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateQueryDataSourceFilter.d.ts","sourceRoot":"","sources":["../../src/queries/validateQueryDataSourceFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAGX,mCAAmC,EAEnC,MAAM,8DAA8D,CAAA;
|
|
1
|
+
{"version":3,"file":"validateQueryDataSourceFilter.d.ts","sourceRoot":"","sources":["../../src/queries/validateQueryDataSourceFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAGX,mCAAmC,EAEnC,MAAM,8DAA8D,CAAA;AAErE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAQ7H,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,mCAAmC,GAAG,SAAS,EACvD,gBAAgB,EAAE,sBAAsB,GACtC,mCAAmC,GAAG,SAAS,CAajD"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { customBlockRelationFilterOperatorSchema } from "../protocol/messages/queryDataSource.js";
|
|
2
|
+
import { is } from "valibot";
|
|
1
3
|
import { unreachable } from "../utils.js";
|
|
2
4
|
export function validateQueryDataSourceFilter(filter, collectionSchema) {
|
|
3
5
|
if (filter === undefined) {
|
|
@@ -46,6 +48,14 @@ function validatePropertyFilter(filter, collectionSchema) {
|
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
}
|
|
51
|
+
if ("relation" in filter &&
|
|
52
|
+
!is(customBlockRelationFilterOperatorSchema, filter.relation)) {
|
|
53
|
+
return {
|
|
54
|
+
code: "invalid_data_source_query_filter",
|
|
55
|
+
message: "Relation filters require a page ID.",
|
|
56
|
+
isRetryable: false,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
49
59
|
const optionFilter = getOptionFilter(filter);
|
|
50
60
|
if (optionFilter === undefined ||
|
|
51
61
|
propertySchema.type !== optionFilter.propertyType) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type {
|
|
|
13
13
|
CustomBlockOptionFilterOperator,
|
|
14
14
|
CustomBlockPeopleFilterOperator,
|
|
15
15
|
CustomBlockPersonFilterValue,
|
|
16
|
+
CustomBlockRelationFilterOperator,
|
|
16
17
|
CustomBlockStatusFilterOperator,
|
|
17
18
|
CustomBlockStatusGroupFilterOperator,
|
|
18
19
|
CustomBlockStatusGroupName,
|
|
@@ -27,12 +27,9 @@ export function invalidProtocolVersionError(args: {
|
|
|
27
27
|
currentBridgeProtocolVersion: number | undefined
|
|
28
28
|
}): CustomBlockErrorInfo<"invalid_protocol_version"> {
|
|
29
29
|
const { currentBridgeProtocolVersion } = args
|
|
30
|
-
const versionText = currentBridgeProtocolVersion
|
|
31
|
-
? `: ${currentBridgeProtocolVersion}`
|
|
32
|
-
: "."
|
|
33
30
|
return {
|
|
34
31
|
code: "invalid_protocol_version",
|
|
35
|
-
message: `Sandbox reported an invalid bridge protocol version ${
|
|
32
|
+
message: `Sandbox reported an invalid bridge protocol version: ${currentBridgeProtocolVersion}`,
|
|
36
33
|
// The sandbox must be updated to a supported protocol version.
|
|
37
34
|
isRetryable: false,
|
|
38
35
|
}
|
|
@@ -295,7 +295,7 @@ export function createInitializationController(
|
|
|
295
295
|
if (bridgeProtocolVersion !== undefined) {
|
|
296
296
|
if (!isValidBridgeProtocolVersion(bridgeProtocolVersion)) {
|
|
297
297
|
error = invalidProtocolVersionError({
|
|
298
|
-
currentBridgeProtocolVersion:
|
|
298
|
+
currentBridgeProtocolVersion: bridgeProtocolVersion,
|
|
299
299
|
})
|
|
300
300
|
} else if (bridgeProtocolVersion < minBridgeProtocolVersion) {
|
|
301
301
|
error = unsupportedProtocolVersionError({
|
|
@@ -5,7 +5,9 @@ import type {
|
|
|
5
5
|
ResolvedCustomBlockDataSourceFilter,
|
|
6
6
|
ResolvedCustomBlockDataSourcePropertyFilter,
|
|
7
7
|
} from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
8
|
+
import { customBlockRelationFilterOperatorSchema } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
8
9
|
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
10
|
+
import { is } from "valibot"
|
|
9
11
|
import { unreachable } from "../utils.js"
|
|
10
12
|
|
|
11
13
|
type OptionFilterOperator =
|
|
@@ -73,6 +75,17 @@ function validatePropertyFilter(
|
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
if (
|
|
79
|
+
"relation" in filter &&
|
|
80
|
+
!is(customBlockRelationFilterOperatorSchema, filter.relation)
|
|
81
|
+
) {
|
|
82
|
+
return {
|
|
83
|
+
code: "invalid_data_source_query_filter",
|
|
84
|
+
message: "Relation filters require a page ID.",
|
|
85
|
+
isRetryable: false,
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
76
89
|
const optionFilter = getOptionFilter(filter)
|
|
77
90
|
if (
|
|
78
91
|
optionFilter === undefined ||
|