@notionhq/custom-blocks-host 0.2.20 → 0.2.21
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/ids.d.ts +3 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/protocol/dataSources/dataSourcePage.d.ts +160 -1
- package/dist/protocol/dataSources/dataSourcePage.js +8 -1
- package/dist/protocol/dataSources/propertySchema.d.ts +1 -0
- package/dist/protocol/messages/hostToSandbox.d.ts +159 -2
- package/dist/protocol/messages/queryDataSourceResult.d.ts +159 -2
- package/dist/protocol/messages/queryDataSourceResult.js +5 -2
- package/dist/protocol/protocolVersion.d.ts +2 -1
- package/dist/protocol/protocolVersion.js +4 -1
- package/package.json +1 -1
- package/src/ids.ts +9 -0
- package/src/index.ts +8 -0
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function qr(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=Tr({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function Tr(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=rt(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||rt(y.name)===c));return l.length===1?l[0][0]:void 0}function rt(e){return e.trim().toLowerCase()}var Re,Nr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Ne(e){return!e&&!Re?Nr:{lang:e?.lang??Re?.lang,message:e?.message,abortEarly:e?.abortEarly??Re?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Re?.abortPipeEarly}}var Fr;function Ur(e){return Fr?.get(e)}var zr;function Hr(e){return zr?.get(e)}var Lr;function Gr(e,o){return Lr?.get(e)?.get(o)}function ge(e){let o=typeof e;return o==="string"?`"${e}"`:o==="number"||o==="bigint"||o==="boolean"?`${e}`:o==="object"||o==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":o}function j(e,o,n,s,c){let l=c&&"input"in c?c.input:n.value,f=c?.expected??e.expects??null,y=c?.received??ge(l),m={kind:e.kind,type:e.type,input:l,expected:f,received:y,message:`Invalid ${o}: ${f?`Expected ${f} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},S=e.kind==="schema",I=c?.message??e.message??Gr(e.reference,m.lang)??(S?Hr(m.lang):null)??s.message??Ur(m.lang);I!==void 0&&(m.message=typeof I=="function"?I(m):I),S&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var nt=new WeakMap;function z(e){let o=nt.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Ne())}},nt.set(e,o)),o}function Vr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function Fe(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var $r=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function te(e){return{kind:"transformation",type:"brand",reference:te,async:!1,name:e,"~run"(o){return o}}}function be(e){return{kind:"validation",type:"finite",reference:be,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(o,n){return o.typed&&!this.requirement(o.value)&&j(this,"finite",o,n),o}}}function Me(e,o){return{kind:"validation",type:"max_length",reference:Me,async:!1,expects:`<=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length>this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,o){return{kind:"validation",type:"min_length",reference:ke,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function Se(e,o){return{kind:"validation",type:"min_value",reference:Se,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&j(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}function Ue(e,o){return{kind:"validation",type:"regex",reference:Ue,async:!1,expects:`${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!this.requirement.test(n.value)&&j(this,"format",n,s),n}}}function ze(e){return{kind:"transformation",type:"transform",reference:ze,async:!1,operation:e,"~run"(o){return o.value=this.operation(o.value),o}}}var it={abortEarly:!0};function st(e,o,n){return typeof e.fallback=="function"?e.fallback(o,n):e.fallback}function De(e,o,n){return typeof e.default=="function"?e.default(o,n):e.default}function ut(e,o){return!e["~run"]({value:o},it).issues}function O(e,o){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return z(this)},"~run"(n,s){let c=n.value;if(Array.isArray(c)){n.typed=!0,n.value=[];for(let l=0;l<c.length;l++){let f=c[l],y=this.item["~run"]({value:f},s);if(y.issues){let m={type:"array",origin:"value",input:c,key:l,value:f};for(let S of y.issues)S.path?S.path.unshift(m):S.path=[m],n.issues?.push(S);if(n.issues||(n.issues=y.issues),s.abortEarly){n.typed=!1;break}}y.typed||(n.typed=!1),n.value.push(y.value)}}else j(this,"type",n,s);return n}}}function b(e){return{kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,get"~standard"(){return z(this)},"~run"(o,n){return typeof o.value=="boolean"?o.typed=!0:j(this,"type",o,n),o}}}function i(e,o){return{kind:"schema",type:"literal",reference:i,expects:ge(e),async:!1,literal:e,message:o,get"~standard"(){return z(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:j(this,"type",n,s),n}}}function He(e){return{kind:"schema",type:"nan",reference:He,expects:"NaN",async:!1,message:e,get"~standard"(){return z(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function W(e,o){return{kind:"schema",type:"nullable",reference:W,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return z(this)},"~run"(n,s){return n.value===null&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function E(e){return{kind:"schema",type:"number",reference:E,expects:"number",async:!1,message:e,get"~standard"(){return z(this)},"~run"(o,n){return typeof o.value=="number"&&!isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function r(e,o){return{kind:"schema",type:"object",reference:r,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return z(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=st(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else j(this,"type",n,s);return n}}}function u(e,o){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return z(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function B(e,o){return{kind:"schema",type:"picklist",reference:B,expects:Fe(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return z(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:j(this,"type",n,s),n}}}function H(e,o,n){return{kind:"schema",type:"record",reference:H,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return z(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Vr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let I={type:"object",origin:"key",input:l,key:f,value:y};for(let R of m.issues)R.path=[I],s.issues?.push(R);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let S=this.value["~run"]({value:y},c);if(S.issues){let I={type:"object",origin:"value",input:l,key:f,value:y};for(let R of S.issues)R.path?R.path.unshift(I):R.path=[I],s.issues?.push(R);if(s.issues||(s.issues=S.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!S.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=S.value)}}else j(this,"type",s,c);return s}}}function p(e,o){return{kind:"schema",type:"strict_object",reference:p,expects:"Object",async:!1,entries:e,message:o,get"~standard"(){return z(this)},"~run"(n,s){let c=n.value;if(c&&typeof c=="object"){n.typed=!0,n.value={};for(let l in this.entries){let f=this.entries[l];if(l in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let y=l in c?c[l]:De(f),m=f["~run"]({value:y},s);if(m.issues){let S={type:"object",origin:"value",input:c,key:l,value:y};for(let I of m.issues)I.path?I.path.unshift(S):I.path=[S],n.issues?.push(I);if(n.issues||(n.issues=m.issues),s.abortEarly){n.typed=!1;break}}m.typed||(n.typed=!1),n.value[l]=m.value}else if(f.fallback!==void 0)n.value[l]=st(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!n.issues||!s.abortEarly){for(let l in c)if(!(l in this.entries)){j(this,"key",n,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else j(this,"type",n,s);return n}}}function t(e){return{kind:"schema",type:"string",reference:t,expects:"string",async:!1,message:e,get"~standard"(){return z(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:j(this,"type",o,n),o}}}function ot(e){let o;if(e)for(let n of e)if(o)for(let s of n.issues)o.push(s);else o=n.issues;return o}function _(e,o){return{kind:"schema",type:"union",reference:_,expects:Fe(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return z(this)},"~run"(n,s){let c,l,f;for(let y of this.options){let m=y["~run"]({value:n.value},s);if(m.typed)if(m.issues)l?l.push(m):l=[m];else{c=m;break}else f?f.push(m):f=[m]}if(c)return c;if(l){if(l.length===1)return l[0];j(this,"type",n,s,{issues:ot(l)}),n.typed=!0}else{if(f?.length===1)return f[0];j(this,"type",n,s,{issues:ot(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return z(this)},"~run"(e){return e.typed=!0,e}}}function h(e,o,n){return{kind:"schema",type:"variant",reference:h,expects:"Object",async:!1,key:e,options:o,message:n,get"~standard"(){return z(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,S=[],I=(R,k)=>{for(let G of R.options){if(G.type==="variant")I(G,new Set(k).add(G.key));else{let J=!0,N=0;for(let M of k){let F=G.entries[M];if(M in l?F["~run"]({typed:!1,value:l[M]},it).issues:F.type!=="exact_optional"&&F.type!=="optional"&&F.type!=="nullish"){J=!1,m!==M&&(y<N||y===N&&M in l&&!(m in l))&&(y=N,m=M,S=[]),m===M&&S.push(G.entries[M].expects);break}N++}if(J){let M=G["~run"]({value:l},c);(!f||!f.typed&&M.typed)&&(f=M)}}if(f&&!f.issues)break}};if(I(this,new Set([this.key])),f)return f;j(this,"type",s,c,{input:l[m],expected:Fe(S,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else j(this,"type",s,c);return s}}}function at(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return z(this)}}}function fe(e,o,n){let s=e["~run"]({value:o},Ne(n));if(s.issues)throw new $r(s.issues);return s.value}function L(...e){return{...e[0],pipe:e,get"~standard"(){return z(this)},"~run"(o,n){for(let s of e)if(s.kind!=="metadata"){if(o.issues&&(s.kind==="schema"||s.kind==="transformation")){o.typed=!1;break}(!o.issues||!n.abortEarly&&!n.abortPipeEarly)&&(o=s["~run"](o,n))}return o}}}function _e(e,o,n){let s=e["~run"]({value:o},Ne(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var re=L(t(),te("NotionBlockId")),Y=L(t(),te("NotionDataSourceId")),T=L(t(),te("NotionPageId")),ct=L(t(),te("NotionAgentId")),lt=L(t(),te("NotionSpaceId"));var pt=B(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),Le=r({id:t(),name:t(),color:u(pt),description:u(t())}),Qr=r({id:t(),name:t(),color:u(pt),option_ids:O(t())}),Xr=r({synced_property_id:t(),synced_property_name:t()}),P=r({name:t(),description:u(t())}),Wr=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],ft=B(Wr),mt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Ge=h("type",[r({...P.entries,type:i("title")}),r({...P.entries,type:i("rich_text")}),r({...P.entries,type:i("number")}),r({...P.entries,type:i("checkbox")}),r({...P.entries,type:i("url")}),r({...P.entries,type:i("email")}),r({...P.entries,type:i("phone_number")}),r({...P.entries,type:i("select"),options:O(Le)}),r({...P.entries,type:i("multi_select"),options:O(Le)}),r({...P.entries,type:i("status"),options:O(Le),groups:O(Qr)}),r({...P.entries,type:i("date")}),r({...P.entries,type:i("people")}),r({...P.entries,type:i("files")}),r({...P.entries,type:i("unique_id")}),r({...P.entries,type:i("relation"),data_source_id:u(t()),dual_property:u(Xr)}),r({...P.entries,type:i("place")}),r({...P.entries,type:i("formula")}),r({...P.entries,type:i("rollup")}),r({...P.entries,type:i("button")}),r({...P.entries,type:i("verification")}),r({...P.entries,type:i("last_visited_time")}),r({...P.entries,type:i("location")}),r({...P.entries,type:i("created_time")}),r({...P.entries,type:i("last_edited_time")}),r({...P.entries,type:i("created_by")}),r({...P.entries,type:i("last_edited_by")})]);var yt={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var vt=r({id:Y,table:t(),spaceId:u(lt)}),dt=r({id:u(Y),propertiesById:H(t(),Ge)}),mo=r({key:t(),collectionPointer:u(vt),collectionSchema:u(dt),propertyIdsByKey:H(t(),u(t())),propertySchemasById:H(t(),Ge)}),Jr=r({collectionPointer:u(vt),collectionSchema:u(dt),propertyIdsByKey:u(H(t(),u(t())))}),le=H(t(),Jr);var Kr=h("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),Zr=r({name:t(),description:u(t()),type:ft}),Yr=r({name:t(),description:u(t()),icon:u(Kr),properties:u(H(t(),Zr),{})}),pe=r({version:i(1),name:u(t()),description:u(t()),slashCommand:u(t()),icon:u(r({type:i("emoji"),emoji:t()})),dataSources:u(H(t(),Yr),{})});var me=B(["standard","high"]),ht="standard";var gt=r({type:i("contrastModeChanged"),contrastMode:me});var we=r({id:t(),table:t()});var ne=h("type",[r({type:i("page_id"),page_id:T}),r({type:i("data_source_id"),data_source_id:Y}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:re}),r({type:i("agent_id"),agent_id:ct}),r({type:i("unavailable")})]);var ye=h("type",[r({type:i("unavailable")}),r({type:i("page"),id:T,parent:ne})]),en=r({type:i("emoji"),emoji:t()}),tn=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:u(t()),url:u(t())})}),St=r({type:i("external"),external:r({url:t()})}),It=r({type:i("file"),file:r({url:t(),expiry_time:u(t())})}),$e=h("type",[en,tn,St,It]),Qe=h("type",[St,It]),$=W(t()),bt=H(t(),Ie()),Ve=_([r({id:t(),name:u(t()),color:u(t()),description:u($)}),r({name:t(),id:u(t()),color:u(t()),description:u($)})]),rn=r({start:t(),end:u($),time_zone:u($)}),nn=_([r({object:u(i("user")),id:t()}),r({object:i("group"),id:t(),name:u($)})]),on=r({id:t()}),sn=_([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:u(t())})})]),un=r({lat:E(),lon:E(),name:u($),address:u($),aws_place_id:u($),google_place_id:u($)}),w={id:t()},kt=W(r({...we.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:u(t())})),an=h("type",[r({...w,type:i("title"),title:O(bt)}),r({...w,type:i("rich_text"),rich_text:O(bt)}),r({...w,type:i("number"),number:W(E())}),r({...w,type:i("url"),url:$}),r({...w,type:i("email"),email:$}),r({...w,type:i("phone_number"),phone_number:$}),r({...w,type:i("checkbox"),checkbox:b()}),r({...w,type:i("select"),select:W(Ve)}),r({...w,type:i("status"),status:W(Ve)}),r({...w,type:i("multi_select"),multi_select:O(Ve)}),r({...w,type:i("date"),date:W(rn)}),r({...w,type:i("people"),people:O(nn)}),r({...w,type:i("relation"),has_more:u(b()),relation:O(on)}),r({...w,type:i("files"),files:O(sn)}),r({...w,type:i("place"),place:W(un)}),r({...w,type:i("created_time"),created_time:$}),r({...w,type:i("last_edited_time"),last_edited_time:$}),r({...w,type:i("created_by"),created_by:kt}),r({...w,type:i("last_edited_by"),last_edited_by:kt}),r({...w,type:i("last_visited_time"),last_visited_time:$})]),xe=H(t(),an),ve=r({object:i("page"),id:T,parent:ne,properties:xe,created_time:u(t()),last_edited_time:u(t()),icon:u($e),cover:u(Qe),url:u(t()),public_url:u(t()),is_archived:b(),in_trash:b()});var cn=t(),ln=r({code:cn,message:t(),isRetryable:b()}),_t=h("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:ln})]);var Xe=L(t(),te("NotionUserId")),oe=r({object:i("user"),id:Xe,name:u(t()),avatar_url:W(t()),type:i("person"),person:r({email:t()})}),xt=r({object:i("list"),results:O(oe),next_cursor:W(t()),has_more:b(),type:i("user"),user:H(t(),Ie())});var Ct=r({type:i("currentUserChanged"),currentUser:oe});var Et=r({type:i("dataSourcesChanged"),dataSources:r({bindings:le})});var pn=t(),fn=r({code:pn,message:t(),isRetryable:b()}),Ot=r({type:i("getPage"),requestId:t(),pageId:T}),Pt=h("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:fn})]);var mn=t(),yn=r({code:mn,message:t(),isRetryable:b()}),jt=r({type:i("getUser"),requestId:t(),userId:Xe}),Bt=h("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:oe}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:yn})]);var de=B(["light","dark"]);var vn=t(),dn=r({code:vn,message:t(),isRetryable:b()});var Ae=h("status",[r({type:i("init"),initializationId:t(),status:i("success"),theme:de,contrastMode:me,blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe}),r({type:i("init"),initializationId:t(),status:i("error"),error:dn})]);var Rt=r({type:i("invalidSandboxMessage"),reason:t()});var hn=t(),gn=r({code:hn,message:t(),isRetryable:b()}),Mt=r({type:i("listUsers"),requestId:t(),startCursor:u(t()),pageSize:u(E())}),Dt=h("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:xt}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:gn})]);var bn=B(["side_peek","center_peek"]),kn=t(),Sn=r({code:kn,message:t(),isRetryable:b()}),wt=r({type:i("openPage"),requestId:t(),pageId:T,mode:bn}),At=h("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:T}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:Sn})]);var qt=r({type:i("pageChanged"),page:ye});var Tt=r({type:i("parentChanged"),parent:ne});var Nt=r({unit:B(["year","month","week","day"]),value:E(),time:t(),defaultTimeZone:u(t())}),In=r({unit:B(["hour","minute"]),value:E()}),Ft=r({unit:i("none")}),_n=_([Nt,In]),Ut=u(_([Nt,Ft])),zt=u(_([_n,Ft])),xn=r({type:i("date"),start_date:t(),reminder:Ut}),Cn=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:Ut}),En=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:u(t()),reminder:zt}),On=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:u(t()),reminder:zt}),Ht=h("type",[xn,Cn,En,On]);var Lt=_([t(),E(),b(),Ht,O(t()),O(we)]);var Gt=r({id:T,is_archived:b(),in_trash:b(),propertiesById:H(t(),u(Lt))});var Pn=t(),jn=r({code:Pn,message:t(),isRetryable:b()}),Vt=h("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:O(Gt),hasMore:b()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:jn})]);var $t=r({type:i("themeChanged"),theme:de});var Bn=t(),Rn=r({code:Bn,message:t(),isRetryable:b()}),Qt=h("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:Rn})]);var Xt=h("type",[Ae,$t,gt,Tt,qt,Ct,Et,Vt,_t,Pt,Bt,Dt,At,Qt,Rt]);function Wt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Jt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function We(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${o}`,isRetryable:!1}}function Je(e){let{currentBridgeProtocolVersion:o,minBridgeProtocolVersion:n}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${o} is not supported. Minimum supported version is ${n}.`,isRetryable:!1}}function Ke(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Kt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Zt(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function Yt(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function er(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function tr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function rr(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function nr(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function ie(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function Ze(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var Mn=5e3,Dn=5e3,wn=5e3;function or(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=Mn,initialStateTimeoutMs:y=Dn,noInitResultTimeoutMs:m=wn,stopHostWithFailure:S,onInitResult:I,onConnectionFailure:R}=e,k="waitingForConnect",G,J,N,M,F=!1,se=!1;function X(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function D(){J!==void 0&&(window.clearTimeout(J),J=void 0)}function U(){N!==void 0&&(window.clearTimeout(N),N=void 0)}function q(g){let{initializationId:v,error:V,phase:Z,source:Be}=g;switch(k){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return ie(k)}k="error",M=v,X(),D(),n({type:"init",initializationId:v,status:"error",error:V}),R?.({...V,phase:Z,source:Be})}async function K(g){if(k==="waitingForConnect"){k="preparingInit",M=g.initializationId,X(),J=window.setTimeout(()=>{if(k!=="preparingInit")return;let v=Kt();s({...v,initializationId:g.initializationId}),q({initializationId:g.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await o(g);if(k!=="preparingInit")return;if(D(),v.status==="error"){q({initializationId:g.initializationId,error:v.error,phase:"init",source:"host"});return}k="waitingForInitResult";let V={type:"init",initializationId:g.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??ht,blockId:v.initialState.blockId,parent:v.initialState.parent,page:v.initialState.page,currentUser:v.initialState.currentUser,manifest:v.initialState.manifest,dataSources:v.initialState.dataSources};n(V),N=window.setTimeout(()=>{if(k!=="waitingForInitResult")return;k="error";let Z=tr();R?.({...Z,phase:"initResult",source:"host"}),s({...Z,initializationId:g.initializationId})},m)}catch(v){if(k!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),q({initializationId:g.initializationId,error:nr(),phase:"init",source:"host"})}}}function ee(g){if(k!=="stopped"&&k==="waitingForConnect"){if(!Ze(g.bridgeProtocolVersion)){let v=We({currentBridgeProtocolVersion:g.bridgeProtocolVersion});q({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.bridgeProtocolVersion<l){let v=Je({currentBridgeProtocolVersion:g.bridgeProtocolVersion,minBridgeProtocolVersion:l});q({initializationId:g.initializationId,error:v,phase:"connect",source:"host"});return}if(g.status==="error"){q({initializationId:g.initializationId,error:g.error,phase:"connect",source:"sandbox"});return}se=!0,K(g)}}function x(g){if(k==="stopped"||k!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=g;if(v===void 0)return"nack";let Z=g.error;return V!==void 0&&(Ze(V)?V<l&&(Z=Je({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):Z=We({currentBridgeProtocolVersion:V})),q({initializationId:v,error:Z,phase:"connect",source:"host"}),"handled"}function ue(g){let{initializationId:v,error:V}=g;k!=="waitingForInitResult"||v===void 0||v!==M||(X(),U(),k="error",s(V),R?.({...V,phase:"initResult",source:"host"}))}function je(){if(k!=="stopped"){if(F){S({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}F=!0,X(),k==="waitingForConnect"&&(G=window.setTimeout(()=>{if(k!=="waitingForConnect")return;k="error";let g=Wt();s(g),R?.({...g,phase:"connect",source:"host"})},f))}}function he(g){if(k!=="waitingForInitResult"||g.initializationId!==M){s({message:"Ignored stale or unexpected initResult",payload:g});return}U(),k=g.status==="success"?"initialized":"error",g.status==="success"?c():R?.({...g.error,phase:"initResult",source:"sandbox"}),I?.(g)}function ae(){k="stopped",X(),D(),U()}return{get status(){return k},get hasConnectedSandbox(){return se},handleConnect:ee,handleInitResult:he,handleInvalidConnect:x,handleInvalidInitResult:ue,onIframeLoad:je,stop:ae}}function ir(e,o){return o>=5||!(e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged")?e:{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([s,c])=>[s,{...c,collectionSchema:{...c.collectionSchema,propertiesById:{...c.collectionSchema?.propertiesById,...yt}}}]))}}}var sr=r({theme:de,contrastMode:u(me),blockId:re,parent:ne,page:ye,manifest:pe,dataSources:r({bindings:le}),currentUser:oe});function ur(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var ar=r({code:t(),message:t(),isRetryable:b()});var cr={type:i("connect"),initializationId:t(),bridgeProtocolVersion:E(),sdkVersion:t()},lr=h("status",[r({status:i("success"),manifest:u(pe),...cr}),r({status:i("error"),error:ar,...cr})]);var An=h("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:re}),r({type:i("after"),blockId:re})]),qn=h("type",[r({type:i("page_id"),page_id:T}),r({type:i("data_source_id"),data_source_id:Y})]),pr=r({type:i("createPage"),requestId:t(),parent:qn,properties:xe,position:u(An)});var Tn=t(),Nn=r({code:Tn,message:t(),isRetryable:b()}),fr=h("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:u(L(E(),be(),Se(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Nn})]);var mr=r({type:i("invalidHostMessage"),reason:t()});var yr=B(["ascending","descending"]);var vr=L(T,Ue(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),ze(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),Ye=_([p({contains:vr}),p({does_not_contain:vr})]),Pe=_([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Oe=_([t(),O(t())]),dr=p({object:B(["user","group"]),id:L(t(),ke(1))}),Fn=_([p({contains:dr}),p({does_not_contain:dr}),Pe]),hr=p({object:i("user"),id:L(t(),ke(1),Me(2e3))}),Un=_([p({contains:hr}),p({does_not_contain:hr}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ce=_([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Pe]),zn=_([p({equals:E()}),p({does_not_equal:E()}),p({greater_than:E()}),p({less_than:E()}),p({greater_than_or_equal_to:E()}),p({less_than_or_equal_to:E()}),Pe]),Hn=_([p({equals:b()}),p({does_not_equal:b()})]),Sr=_([p({equals:Oe}),p({does_not_equal:Oe}),Pe]),gr=B(["To-do","In progress","Complete","Current","Future"]),br=_([gr,L(O(gr),ke(1),Me(5))]),Ln=_([p({group_equals:br}),p({group_does_not_equal:br})]),Gn=_([Sr,Ln]),Vn=_([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Pe]),Q=B(["start_date","end_date"]),$n=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Ee=_([$n,t()]),Qn=_([p({target:u(Q),equals:Ee}),p({target:u(Q),before:Ee}),p({target:u(Q),after:Ee}),p({target:u(Q),on_or_before:Ee}),p({target:u(Q),on_or_after:Ee}),p({target:u(Q),this_week:p({})}),p({target:u(Q),past_week:p({})}),p({target:u(Q),past_month:p({})}),p({target:u(Q),past_year:p({})}),p({target:u(Q),next_week:p({})}),p({target:u(Q),next_month:p({})}),p({target:u(Q),next_year:p({})}),p({target:u(Q),is_empty:i(!0)}),p({target:u(Q),is_not_empty:i(!0)})]),kr=_([p({propertyId:t(),relation:Ye}),p({propertyId:t(),created_by:Un}),p({propertyId:t(),title:Ce}),p({propertyId:t(),rich_text:Ce}),p({propertyId:t(),url:Ce}),p({propertyId:t(),email:Ce}),p({propertyId:t(),phone_number:Ce}),p({propertyId:t(),number:zn}),p({propertyId:t(),checkbox:Hn}),p({propertyId:t(),select:Sr}),p({propertyId:t(),multi_select:Vn}),p({propertyId:t(),status:Gn}),p({propertyId:t(),date:Qn}),p({propertyId:t(),people:Fn})]),Xn=_([kr,p({and:O(kr)})]),et=10,Wn=p({propertyId:t(),direction:yr}),Ir=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Y,limit:E(),filter:u(Xn),sorts:u(O(Wn))});var _r=r({type:i("resize"),height:L(E(),be(),Se(0))});var xr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var Cr=r({type:i("updatePage"),requestId:t(),pageId:T,properties:u(xe),icon:u($e),cover:u(Qe),archived:u(b())});var Er=h("type",[lr,fr,Ir,xr,pr,Ot,jt,Mt,wt,Cr,_r,mr]);function Or(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Pr(e){let o=Or(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Jn(o)}}}function Jn(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var jr=r({initializationId:t()}),Kn=r({bridgeProtocolVersion:_([E(),He()])});function Br(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:S,onQueryDataSource:I,onUnsubscribeDataSourceQuery:R,onCreatePage:k,onGetPage:G,onOpenPage:J,onGetUser:N,onListUsers:M,onUpdatePage:F,onResize:se}=e;function X(D,U){c("warn",{message:"Ignored unsupported sandbox message",payload:D,issues:U});let q=Pr(D);if(q.incomingType==="connect"){let K=_e(jr,D),ee=_e(Kn,D);if(f({initializationId:K.success?K.output.initializationId:void 0,error:Jt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(q.incomingType==="initResult"){let K=_e(jr,D);y({initializationId:K.success?K.output.initializationId:void 0,error:rr()})}q.nack!==void 0&&s()!=="stopped"&&l(q.nack)}return function(U){let q=U.source===o.contentWindow,K=U.origin===n;if(!q||!K)return;let ee=_e(Er,U.data);if(!ee.success){X(U.data,ee.issues);return}let x=ee.output;if(!ur(x)&&s()!=="initialized"){c("warn",{message:`Ignored ${x.type} before initialization completed`,payload:x});return}switch(c("in",x),x.type){case"connect":m(x);return;case"initResult":S(x);return;case"queryDataSource":I(x);return;case"unsubscribeDataSourceQuery":R(x);return;case"createPage":k(x);return;case"openPage":J(x);return;case"getPage":G(x);return;case"getUser":N(x);return;case"listUsers":M(x);return;case"updatePage":F(x);return;case"resize":se(x);return;case"invalidHostMessage":return;default:ie(x)}}}var qe=class{constructor(o){this.onUnsubscribe=o}onUnsubscribe;bySubscriptionId=new Map;subscribe(o){this.unsubscribe(o.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(o.subscriptionId,{message:o,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(o,n){return this.bySubscriptionId.get(o)?.token===n}unsubscribe(o){this.bySubscriptionId.delete(o)&&this.onUnsubscribe(o)}refresh(o){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===o){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(o,n){let s=this.bySubscriptionId.get(o);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let o of this.bySubscriptionId.keys())this.unsubscribe(o)}};function Rr(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=Zn(s,o);if(c!==void 0)return c}}function Zn(e,o){if(!Object.hasOwn(o.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let n=o.propertiesById[e.propertyId],s=Object.keys(e).find(y=>y!=="propertyId");if(s!==n.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${n.type}".`,isRetryable:!1};if("status"in e&&n.type==="status"){let y=e.status;if("group_equals"in y||"group_does_not_equal"in y){let m="group_equals"in y?y.group_equals:y.group_does_not_equal,I=(Array.isArray(m)?m:[m]).find(R=>!n.groups.some(k=>k.name===R));return I===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${I}".`,isRetryable:!1}}}if("relation"in e&&!ut(Ye,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Yn(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=eo(c.operator).find(y=>!l.has(y));if(f!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${f}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function Yn(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let o=e.status;return"group_equals"in o||"group_does_not_equal"in o?void 0:{propertyType:"status",operator:o}}}function eo(e){let o;if("equals"in e)o=e.equals;else if("does_not_equal"in e)o=e.does_not_equal;else if("contains"in e)o=e.contains;else if("contains_all"in e)o=e.contains_all;else if("does_not_contain"in e)o=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ie(e);return Array.isArray(o)?o:[o]}var to=new Set(mt);function Mr(e,o){if(e===void 0)return;if(e.length>et)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${et} entries.`,isRetryable:!1};let n=new Set;for(let s of e){if(n.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(n.add(s.propertyId),!Object.hasOwn(o.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=o.propertiesById[s.propertyId];if(!to.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}var wr=5;function no(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:S,minBridgeProtocolVersion:I,noConnectTimeoutMs:R,initialStateTimeoutMs:k,noInitResultTimeoutMs:G}=e,J=Math.max(I??3,3),N={},M=!1,F,se,X=5,D=new qe(a=>{m?.(a)});function U(a,C){y?.(a,C)}function q(a){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return ie(C)}let A=ir(a,X);U("out",A),o.contentWindow?.postMessage(A,S)}function K(a){q(fe(Ae,a))}function ee(a){q(a)}function x(a){let C=v.status;switch(C){case"initialized":q(fe(Xt,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:ie(C)}}async function ue(a,C){if(C===void 0)return;let A=await C(a);x({type:`${a.type}Result`,requestId:a.requestId,...A})}function je(a){let C=a.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"error",error:a.response.error}:{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"success",items:a.response.items,hasMore:a.response.hasMore};x(C)}async function he(a,C=D.subscribe(a)){try{let A=oo(se,a.dataSourceId),ce=io(a,A);if(ce!==void 0){D.isCurrent(a.subscriptionId,C)&&(D.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:{status:"error",error:ce}}));return}let Te=await s.queryDataSource(a);if(!D.isCurrent(a.subscriptionId,C))return;Te.status==="error"&&!Te.error.isRetryable&&D.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:Te})}finally{let A=D.finish(a.subscriptionId,C);A!==void 0&&he(A.message,A.token)}}function ae(a){v.status==="stopped"||v.status==="error"||(Object.assign(N,a),g())}function g(){if(v.status!=="initialized")return;let a=N;N={},a.theme!==void 0&&x({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&x({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&x({type:"parentChanged",parent:a.parent}),a.page!==void 0&&x({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&x({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&x({type:"currentUserChanged",currentUser:a.currentUser})}let v=or({async prepareInit(a){X=a.bridgeProtocolVersion;let C=await n(a);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:K,warn:a=>U("warn",a),flushPendingHostStateChanges:g,minBridgeProtocolVersion:J,noConnectTimeoutMs:R,initialStateTimeoutMs:k,noInitResultTimeoutMs:G,stopHostWithFailure:tt,onInitResult(a){a.status==="success"&&F!==void 0&&l?.({manifest:F,initialHeight:a.initialHeight})},onConnectionFailure:f});function V(a){if(a.status==="error")return a;F=fe(pe,a.initialState.manifest),c?.(F);let C={...a.initialState,...N};N={};let A={...fe(at(sr,["manifest"]),C),manifest:F};if(X<wr&&A.page.type==="unavailable")return{status:"error",error:Ke()};let ce=Ar(A.manifest,A.dataSources);return ce!==void 0?{status:"error",error:ce}:(se=A.dataSources,M=!0,{status:"success",initialState:A})}let Z=Br({iframe:o,sandboxOrigin:S,getInitStatus:()=>v.status,emit:U,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:a=>D.unsubscribe(a.subscriptionId),onCreatePage:a=>ue(a,s.createPage),onGetPage:a=>ue(a,s.getPage),onOpenPage:a=>ue(a,s.openPage),onGetUser:a=>ue(a,s.getUser),onListUsers:a=>ue(a,s.listUsers),onUpdatePage:a=>ue(a,s.updatePage),onResize:a=>s.resize?.(a)});window.addEventListener("message",Z),o.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",Z),o.removeEventListener("load",v.onIframeLoad),v.stop(),D.unsubscribeAll()}function tt(a){Be(),U("warn",a),f?.(a)}return{stop:Be,setTheme(a){ae({theme:a})},setContrastMode(a){ae({contrastMode:a})},setParent(a){ae({parent:a})},setPage(a){if(a.type==="unavailable"&&X<wr&&(v.status==="preparingInit"&&M||v.status==="waitingForInitResult"||v.status==="initialized")){tt({...Ke(),phase:"runtime",source:"host"});return}ae({page:a})},setCurrentUser(a){ae({currentUser:a})},setDataSources(a){let C={bindings:fe(le,a.bindings)};if(v.hasConnectedSandbox&&F!==void 0&&Ar(F,C)!==void 0){U("warn",{message:"Ignored invalid data source bindings update",payload:C});return}se=C,ae({dataSources:C})},refreshQuery({dataSourceId:a}){if(v.status!=="initialized")return;let C=fe(Y,a),A=D.refresh(C);if(A===void 0){U("warn",`No active query exists for data source "${a}"`);return}for(let ce of A)he(ce.message,ce.token)}}}function oo(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function Ar(e,o){for(let[n,s]of Object.entries(e.dataSources)){let c=o.bindings[n];if(c?.collectionPointer===void 0||c.collectionSchema===void 0)return Zt();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return Yt();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return er()}}}function io(e,o){return o===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:Rr(e.filter,o)??Mr(e.sorts,o)}function so(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}export{no as createCustomBlockHost,qr as getAutoBoundPropertyIdsByKey,so as isLocalCustomBlockUrl};
|
|
1
|
+
var Nr=6;function Fr(e){let{manifestProperties:o,propertySchemasById:n}=e,s=[];for(let[c,l]of Object.entries(o)){let f=Ur({propertyKey:c,manifestProperty:l,propertySchemasById:n});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function Ur(e){let{propertyKey:o,manifestProperty:n,propertySchemasById:s}=e,c=nt(n.name),l=Object.entries(s).filter(([f,y])=>y.type===n.type&&(f===o||nt(y.name)===c));return l.length===1?l[0][0]:void 0}function nt(e){return e.trim().toLowerCase()}var Re,zr={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Ne(e){return!e&&!Re?zr:{lang:e?.lang??Re?.lang,message:e?.message,abortEarly:e?.abortEarly??Re?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Re?.abortPipeEarly}}var Hr;function Lr(e){return Hr?.get(e)}var Gr;function Vr(e){return Gr?.get(e)}var $r;function Qr(e,o){return $r?.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},I=e.kind==="schema",_=c?.message??e.message??Qr(e.reference,m.lang)??(I?Vr(m.lang):null)??s.message??Lr(m.lang);_!==void 0&&(m.message=typeof _=="function"?_(m):_),I&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}var ot=new WeakMap;function H(e){let o=ot.get(e);return o||(o={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Ne())}},ot.set(e,o)),o}function Xr(e,o){return Object.prototype.hasOwnProperty.call(e,o)&&o!=="__proto__"&&o!=="prototype"&&o!=="constructor"}function Fe(e,o){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${o} `)})`:n[0]??"never"}var Wr=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 Se(e,o){return{kind:"validation",type:"min_length",reference:Se,async:!1,expects:`>=${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&n.value.length<this.requirement&&j(this,"length",n,s,{received:`${n.value.length}`}),n}}}function ke(e,o){return{kind:"validation",type:"min_value",reference:ke,async:!1,expects:`>=${e instanceof Date?e.toJSON():ge(e)}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!(n.value>=this.requirement)&&j(this,"value",n,s,{received:n.value instanceof Date?n.value.toJSON():ge(n.value)}),n}}}function Ue(e,o){return{kind:"validation",type:"regex",reference:Ue,async:!1,expects:`${e}`,requirement:e,message:o,"~run"(n,s){return n.typed&&!this.requirement.test(n.value)&&j(this,"format",n,s),n}}}function ze(e){return{kind:"transformation",type:"transform",reference:ze,async:!1,operation:e,"~run"(o){return o.value=this.operation(o.value),o}}}var st={abortEarly:!0};function ut(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 at(e,o){return!e["~run"]({value:o},st).issues}function O(e,o){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:o,get"~standard"(){return H(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 I of y.issues)I.path?I.path.unshift(m):I.path=[m],n.issues?.push(I);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 h(e){return{kind:"schema",type:"boolean",reference:h,expects:"boolean",async:!1,message:e,get"~standard"(){return H(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 H(this)},"~run"(n,s){return n.value===this.literal?n.typed=!0:j(this,"type",n,s),n}}}function He(e){return{kind:"schema",type:"nan",reference:He,expects:"NaN",async:!1,message:e,get"~standard"(){return H(this)},"~run"(o,n){return Number.isNaN(o.value)?o.typed=!0:j(this,"type",o,n),o}}}function W(e,o){return{kind:"schema",type:"nullable",reference:W,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:o,get"~standard"(){return H(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 P(e){return{kind:"schema",type:"number",reference:P,expects:"number",async:!1,message:e,get"~standard"(){return H(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 H(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 I={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(I):_.path=[I],n.issues?.push(_);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]=ut(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(j(this,"key",n,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else j(this,"type",n,s);return n}}}function u(e,o){return{kind:"schema",type:"optional",reference:u,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:o,get"~standard"(){return H(this)},"~run"(n,s){return n.value===void 0&&(this.default!==void 0&&(n.value=De(this,n,s)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,s)}}}function B(e,o){return{kind:"schema",type:"picklist",reference:B,expects:Fe(e.map(ge),"|"),async:!1,options:e,message:o,get"~standard"(){return H(this)},"~run"(n,s){return this.options.includes(n.value)?n.typed=!0:j(this,"type",n,s),n}}}function N(e,o,n){return{kind:"schema",type:"record",reference:N,expects:"Object",async:!1,key:e,value:o,message:n,get"~standard"(){return H(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let f in l)if(Xr(l,f)){let y=l[f],m=this.key["~run"]({value:f},c);if(m.issues){let _={type:"object",origin:"key",input:l,key:f,value:y};for(let R of m.issues)R.path=[_],s.issues?.push(R);if(s.issues||(s.issues=m.issues),c.abortEarly){s.typed=!1;break}}let I=this.value["~run"]({value:y},c);if(I.issues){let _={type:"object",origin:"value",input:l,key:f,value:y};for(let R of I.issues)R.path?R.path.unshift(_):R.path=[_],s.issues?.push(R);if(s.issues||(s.issues=I.issues),c.abortEarly){s.typed=!1;break}}(!m.typed||!I.typed)&&(s.typed=!1),m.typed&&(s.value[m.value]=I.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 H(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 I={type:"object",origin:"value",input:c,key:l,value:y};for(let _ of m.issues)_.path?_.path.unshift(I):_.path=[I],n.issues?.push(_);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]=ut(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 H(this)},"~run"(o,n){return typeof o.value=="string"?o.typed=!0:j(this,"type",o,n),o}}}function it(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 k(e,o){return{kind:"schema",type:"union",reference:k,expects:Fe(e.map(n=>n.expects),"|"),async:!1,options:e,message:o,get"~standard"(){return H(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:it(l)}),n.typed=!0}else{if(f?.length===1)return f[0];j(this,"type",n,s,{issues:it(f)})}return n}}}function Ie(){return{kind:"schema",type:"unknown",reference:Ie,expects:"unknown",async:!1,get"~standard"(){return H(this)},"~run"(e){return e.typed=!0,e}}}function g(e,o,n){return{kind:"schema",type:"variant",reference:g,expects:"Object",async:!1,key:e,options:o,message:n,get"~standard"(){return H(this)},"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let f,y=0,m=this.key,I=[],_=(R,S)=>{for(let G of R.options){if(G.type==="variant")_(G,new Set(S).add(G.key));else{let J=!0,F=0;for(let M of S){let U=G.entries[M];if(M in l?U["~run"]({typed:!1,value:l[M]},st).issues:U.type!=="exact_optional"&&U.type!=="optional"&&U.type!=="nullish"){J=!1,m!==M&&(y<F||y===F&&M in l&&!(m in l))&&(y=F,m=M,I=[]),m===M&&I.push(G.entries[M].expects);break}F++}if(J){let M=G["~run"]({value:l},c);(!f||!f.typed&&M.typed)&&(f=M)}}if(f&&!f.issues)break}};if(_(this,new Set([this.key])),f)return f;j(this,"type",s,c,{input:l[m],expected:Fe(I,"|"),path:[{type:"object",origin:"value",input:l,key:m,value:l[m]}]})}else j(this,"type",s,c);return s}}}function ct(e,o){let n={...e.entries};for(let s of o)delete n[s];return{...e,entries:n,get"~standard"(){return H(this)}}}function re(e,o,n){let s=e["~run"]({value:o},Ne(n));if(s.issues)throw new Wr(s.issues);return s.value}function L(...e){return{...e[0],pipe:e,get"~standard"(){return H(this)},"~run"(o,n){for(let s of e)if(s.kind!=="metadata"){if(o.issues&&(s.kind==="schema"||s.kind==="transformation")){o.typed=!1;break}(!o.issues||!n.abortEarly&&!n.abortPipeEarly)&&(o=s["~run"](o,n))}return o}}}function _e(e,o,n){let s=e["~run"]({value:o},Ne(n));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var ne=L(t(),te("NotionBlockId")),Z=L(t(),te("NotionDataSourceId")),D=L(t(),te("NotionPageId")),lt=L(t(),te("NotionAgentId")),pt=L(t(),te("NotionSpaceId"));var ft=B(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),Le=r({id:t(),name:t(),color:u(ft),description:u(t())}),Jr=r({id:t(),name:t(),color:u(ft),option_ids:O(t())}),Kr=r({synced_property_id:t(),synced_property_name:t()}),E=r({name:t(),description:u(t())}),Yr=["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"],mt=B(Yr),yt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Ge=g("type",[r({...E.entries,type:i("title")}),r({...E.entries,type:i("rich_text")}),r({...E.entries,type:i("number")}),r({...E.entries,type:i("checkbox")}),r({...E.entries,type:i("url")}),r({...E.entries,type:i("email")}),r({...E.entries,type:i("phone_number")}),r({...E.entries,type:i("select"),options:O(Le)}),r({...E.entries,type:i("multi_select"),options:O(Le)}),r({...E.entries,type:i("status"),options:O(Le),groups:O(Jr)}),r({...E.entries,type:i("date")}),r({...E.entries,type:i("people")}),r({...E.entries,type:i("files")}),r({...E.entries,type:i("unique_id")}),r({...E.entries,type:i("relation"),data_source_id:u(t()),dual_property:u(Kr)}),r({...E.entries,type:i("place")}),r({...E.entries,type:i("formula")}),r({...E.entries,type:i("rollup")}),r({...E.entries,type:i("button")}),r({...E.entries,type:i("verification")}),r({...E.entries,type:i("last_visited_time")}),r({...E.entries,type:i("location")}),r({...E.entries,type:i("created_time")}),r({...E.entries,type:i("last_edited_time")}),r({...E.entries,type:i("created_by")}),r({...E.entries,type:i("last_edited_by")})]);var vt={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 dt=r({id:Z,table:t(),spaceId:u(pt)}),ht=r({id:u(Z),propertiesById:N(t(),Ge)}),go=r({key:t(),collectionPointer:u(dt),collectionSchema:u(ht),propertyIdsByKey:N(t(),u(t())),propertySchemasById:N(t(),Ge)}),Zr=r({collectionPointer:u(dt),collectionSchema:u(ht),propertyIdsByKey:u(N(t(),u(t())))}),pe=N(t(),Zr);var en=g("type",[r({type:i("emoji"),emoji:t()}),r({type:i("external"),url:t()})]),tn=r({name:t(),description:u(t()),type:mt}),rn=r({name:t(),description:u(t()),icon:u(en),properties:u(N(t(),tn),{})}),fe=r({version:i(1),name:u(t()),description:u(t()),slashCommand:u(t()),icon:u(r({type:i("emoji"),emoji:t()})),dataSources:u(N(t(),rn),{})});var me=B(["standard","high"]),gt="standard";var bt=r({type:i("contrastModeChanged"),contrastMode:me});var we=r({id:t(),table:t()});var oe=g("type",[r({type:i("page_id"),page_id:D}),r({type:i("data_source_id"),data_source_id:Z}),r({type:i("workspace"),workspace:i(!0)}),r({type:i("block_id"),block_id:ne}),r({type:i("agent_id"),agent_id:lt}),r({type:i("unavailable")})]);var ye=g("type",[r({type:i("unavailable")}),r({type:i("page"),id:D,parent:oe})]),nn=r({type:i("emoji"),emoji:t()}),on=r({type:i("custom_emoji"),custom_emoji:r({id:t(),name:u(t()),url:u(t())})}),It=r({type:i("external"),external:r({url:t()})}),_t=r({type:i("file"),file:r({url:t(),expiry_time:u(t())})}),$e=g("type",[nn,on,It,_t]),Qe=g("type",[It,_t]),$=W(t()),St=N(t(),Ie()),Ve=k([r({id:t(),name:u(t()),color:u(t()),description:u($)}),r({name:t(),id:u(t()),color:u(t()),description:u($)})]),sn=r({start:t(),end:u($),time_zone:u($)}),un=k([r({object:u(i("user")),id:t()}),r({object:i("group"),id:t(),name:u($)})]),an=r({id:t()}),cn=k([r({type:i("external"),name:t(),external:r({url:t()})}),r({type:i("file"),name:t(),file:r({url:t(),expiry_time:u(t())})})]),ln=r({lat:P(),lon:P(),name:u($),address:u($),aws_place_id:u($),google_place_id:u($)}),A={id:t()},kt=W(r({...we.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:u(t())})),Xe=g("type",[r({...A,type:i("title"),title:O(St)}),r({...A,type:i("rich_text"),rich_text:O(St)}),r({...A,type:i("number"),number:W(P())}),r({...A,type:i("url"),url:$}),r({...A,type:i("email"),email:$}),r({...A,type:i("phone_number"),phone_number:$}),r({...A,type:i("checkbox"),checkbox:h()}),r({...A,type:i("select"),select:W(Ve)}),r({...A,type:i("status"),status:W(Ve)}),r({...A,type:i("multi_select"),multi_select:O(Ve)}),r({...A,type:i("date"),date:W(sn)}),r({...A,type:i("people"),people:O(un)}),r({...A,type:i("relation"),has_more:u(h()),relation:O(an)}),r({...A,type:i("files"),files:O(cn)}),r({...A,type:i("place"),place:W(ln)}),r({...A,type:i("created_time"),created_time:$}),r({...A,type:i("last_edited_time"),last_edited_time:$}),r({...A,type:i("created_by"),created_by:kt}),r({...A,type:i("last_edited_by"),last_edited_by:kt}),r({...A,type:i("last_visited_time"),last_visited_time:$})]),xe=N(t(),Xe),ve=r({object:i("page"),id:D,parent:oe,properties:xe,created_time:u(t()),last_edited_time:u(t()),icon:u($e),cover:u(Qe),url:u(t()),public_url:u(t()),is_archived:h(),in_trash:h()});var pn=t(),fn=r({code:pn,message:t(),isRetryable:h()}),xt=g("status",[r({type:i("createPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("createPageResult"),requestId:t(),status:i("error"),error:fn})]);var We=L(t(),te("NotionUserId")),ie=r({object:i("user"),id:We,name:u(t()),avatar_url:W(t()),type:i("person"),person:r({email:t()})}),Ct=r({object:i("list"),results:O(ie),next_cursor:W(t()),has_more:h(),type:i("user"),user:N(t(),Ie())});var Pt=r({type:i("currentUserChanged"),currentUser:ie});var Ot=r({type:i("dataSourcesChanged"),dataSources:r({bindings:pe})});var mn=t(),yn=r({code:mn,message:t(),isRetryable:h()}),Et=r({type:i("getPage"),requestId:t(),pageId:D}),jt=g("status",[r({type:i("getPageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("getPageResult"),requestId:t(),status:i("error"),error:yn})]);var vn=t(),dn=r({code:vn,message:t(),isRetryable:h()}),Bt=r({type:i("getUser"),requestId:t(),userId:We}),Rt=g("status",[r({type:i("getUserResult"),requestId:t(),status:i("success"),user:ie}),r({type:i("getUserResult"),requestId:t(),status:i("error"),error:dn})]);var de=B(["light","dark"]);var hn=t(),gn=r({code:hn,message:t(),isRetryable:h()});var Ae=g("status",[r({type:i("init"),initializationId:t(),status:i("success"),theme:de,contrastMode:me,blockId:ne,parent:oe,page:ye,manifest:fe,dataSources:r({bindings:pe}),currentUser:ie}),r({type:i("init"),initializationId:t(),status:i("error"),error:gn})]);var Mt=r({type:i("invalidSandboxMessage"),reason:t()});var bn=t(),Sn=r({code:bn,message:t(),isRetryable:h()}),Dt=r({type:i("listUsers"),requestId:t(),startCursor:u(t()),pageSize:u(P())}),wt=g("status",[r({type:i("listUsersResult"),requestId:t(),status:i("success"),list:Ct}),r({type:i("listUsersResult"),requestId:t(),status:i("error"),error:Sn})]);var kn=B(["side_peek","center_peek"]),In=t(),_n=r({code:In,message:t(),isRetryable:h()}),At=r({type:i("openPage"),requestId:t(),pageId:D,mode:kn}),qt=g("status",[r({type:i("openPageResult"),requestId:t(),status:i("success"),pageId:D}),r({type:i("openPageResult"),requestId:t(),status:i("error"),error:_n})]);var Tt=r({type:i("pageChanged"),page:ye});var Nt=r({type:i("parentChanged"),parent:oe});var Ft=r({unit:B(["year","month","week","day"]),value:P(),time:t(),defaultTimeZone:u(t())}),xn=r({unit:B(["hour","minute"]),value:P()}),Ut=r({unit:i("none")}),Cn=k([Ft,xn]),zt=u(k([Ft,Ut])),Ht=u(k([Cn,Ut])),Pn=r({type:i("date"),start_date:t(),reminder:zt}),On=r({type:i("daterange"),start_date:t(),end_date:t(),reminder:zt}),En=r({type:i("datetime"),start_date:t(),start_time:t(),time_zone:u(t()),reminder:Ht}),jn=r({type:i("datetimerange"),start_date:t(),start_time:t(),end_date:t(),end_time:t(),time_zone:u(t()),reminder:Ht}),Lt=g("type",[Pn,On,En,jn]);var Gt=k([t(),P(),h(),Lt,O(t()),O(we)]);var Vt=r({id:D,is_archived:h(),in_trash:h(),propertiesById:N(t(),u(Gt))}),$t=r({id:D,is_archived:h(),in_trash:h(),properties:N(t(),u(Xe))});var Bn=t(),Rn=r({code:Bn,message:t(),isRetryable:h()}),Qt=g("status",[r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("success"),items:O(k([$t,Vt])),hasMore:h()}),r({type:i("queryDataSourceResult"),subscriptionId:t(),status:i("error"),error:Rn})]);var Xt=r({type:i("themeChanged"),theme:de});var Mn=t(),Dn=r({code:Mn,message:t(),isRetryable:h()}),Wt=g("status",[r({type:i("updatePageResult"),requestId:t(),status:i("success"),page:ve}),r({type:i("updatePageResult"),requestId:t(),status:i("error"),error:Dn})]);var Jt=g("type",[Ae,Xt,bt,Nt,Tt,Pt,Ot,Qt,xt,jt,Rt,wt,qt,Wt,Mt]);function Kt(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Yt(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Je(e){let{currentBridgeProtocolVersion:o}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${o}`,isRetryable:!1}}function Ke(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 Ye(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Zt(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function er(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function tr(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function rr(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function nr(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function or(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function ir(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function se(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function Ze(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var wn=5e3,An=5e3,qn=5e3;function sr(e){let{prepareInit:o,sendInitMessage:n,warn:s,flushPendingHostStateChanges:c,minBridgeProtocolVersion:l,noConnectTimeoutMs:f=wn,initialStateTimeoutMs:y=An,noInitResultTimeoutMs:m=qn,stopHostWithFailure:I,onInitResult:_,onConnectionFailure:R}=e,S="waitingForConnect",G,J,F,M,U=!1,ue=!1;function X(){G!==void 0&&(window.clearTimeout(G),G=void 0)}function w(){J!==void 0&&(window.clearTimeout(J),J=void 0)}function z(){F!==void 0&&(window.clearTimeout(F),F=void 0)}function T(b){let{initializationId:v,error:V,phase:Y,source:Be}=b;switch(S){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"error":case"stopped":return;default:return se(S)}S="error",M=v,X(),w(),n({type:"init",initializationId:v,status:"error",error:V}),R?.({...V,phase:Y,source:Be})}async function K(b){if(S==="waitingForConnect"){S="preparingInit",M=b.initializationId,X(),J=window.setTimeout(()=>{if(S!=="preparingInit")return;let v=Zt();s({...v,initializationId:b.initializationId}),T({initializationId:b.initializationId,error:v,phase:"init",source:"host"})},y);try{let v=await o(b);if(S!=="preparingInit")return;if(w(),v.status==="error"){T({initializationId:b.initializationId,error:v.error,phase:"init",source:"host"});return}S="waitingForInitResult";let V={type:"init",initializationId:b.initializationId,status:"success",theme:v.initialState.theme,contrastMode:v.initialState.contrastMode??gt,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),F=window.setTimeout(()=>{if(S!=="waitingForInitResult")return;S="error";let Y=nr();R?.({...Y,phase:"initResult",source:"host"}),s({...Y,initializationId:b.initializationId})},m)}catch(v){if(S!=="preparingInit")return;s({message:"Failed to prepare custom block initialization",error:v}),T({initializationId:b.initializationId,error:ir(),phase:"init",source:"host"})}}}function ee(b){if(S!=="stopped"&&S==="waitingForConnect"){if(!Ze(b.bridgeProtocolVersion)){let v=Je({currentBridgeProtocolVersion:b.bridgeProtocolVersion});T({initializationId:b.initializationId,error:v,phase:"connect",source:"host"});return}if(b.bridgeProtocolVersion<l){let v=Ke({currentBridgeProtocolVersion:b.bridgeProtocolVersion,minBridgeProtocolVersion:l});T({initializationId:b.initializationId,error:v,phase:"connect",source:"host"});return}if(b.status==="error"){T({initializationId:b.initializationId,error:b.error,phase:"connect",source:"sandbox"});return}ue=!0,K(b)}}function x(b){if(S==="stopped"||S!=="waitingForConnect")return"handled";let{initializationId:v,bridgeProtocolVersion:V}=b;if(v===void 0)return"nack";let Y=b.error;return V!==void 0&&(Ze(V)?V<l&&(Y=Ke({currentBridgeProtocolVersion:V,minBridgeProtocolVersion:l})):Y=Je({currentBridgeProtocolVersion:V})),T({initializationId:v,error:Y,phase:"connect",source:"host"}),"handled"}function ae(b){let{initializationId:v,error:V}=b;S!=="waitingForInitResult"||v===void 0||v!==M||(X(),z(),S="error",s(V),R?.({...V,phase:"initResult",source:"host"}))}function je(){if(S!=="stopped"){if(U){I({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}U=!0,X(),S==="waitingForConnect"&&(G=window.setTimeout(()=>{if(S!=="waitingForConnect")return;S="error";let b=Kt();s(b),R?.({...b,phase:"connect",source:"host"})},f))}}function he(b){if(S!=="waitingForInitResult"||b.initializationId!==M){s({message:"Ignored stale or unexpected initResult",payload:b});return}z(),S=b.status==="success"?"initialized":"error",b.status==="success"?c():R?.({...b.error,phase:"initResult",source:"sandbox"}),_?.(b)}function ce(){S="stopped",X(),w(),z()}return{get status(){return S},get hasConnectedSandbox(){return ue},handleConnect:ee,handleInitResult:he,handleInvalidConnect:x,handleInvalidInitResult:ae,onIframeLoad:je,stop:ce}}function ur(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,...vt}}}]))}}}var ar=r({theme:de,contrastMode:u(me),blockId:ne,parent:oe,page:ye,manifest:fe,dataSources:r({bindings:pe}),currentUser:ie});function cr(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var lr=r({code:t(),message:t(),isRetryable:h()});var pr={type:i("connect"),initializationId:t(),bridgeProtocolVersion:P(),sdkVersion:t()},fr=g("status",[r({status:i("success"),manifest:u(fe),...pr}),r({status:i("error"),error:lr,...pr})]);var Tn=g("type",[r({type:i("start")}),r({type:i("end")}),r({type:i("before"),blockId:ne}),r({type:i("after"),blockId:ne})]),Nn=g("type",[r({type:i("page_id"),page_id:D}),r({type:i("data_source_id"),data_source_id:Z})]),mr=r({type:i("createPage"),requestId:t(),parent:Nn,properties:xe,position:u(Tn)});var Fn=t(),Un=r({code:Fn,message:t(),isRetryable:h()}),yr=g("status",[r({type:i("initResult"),initializationId:t(),status:i("success"),initialHeight:u(L(P(),be(),ke(0)))}),r({type:i("initResult"),initializationId:t(),status:i("error"),error:Un})]);var vr=r({type:i("invalidHostMessage"),reason:t()});var dr=B(["ascending","descending"]);var hr=L(D,Ue(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),ze(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),et=k([p({contains:hr}),p({does_not_contain:hr})]),Ee=k([p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Oe=k([t(),O(t())]),gr=p({object:B(["user","group"]),id:L(t(),Se(1))}),zn=k([p({contains:gr}),p({does_not_contain:gr}),Ee]),br=p({object:i("user"),id:L(t(),Se(1),Me(2e3))}),Hn=k([p({contains:br}),p({does_not_contain:br}),p({is_empty:i(!0)}),p({is_not_empty:i(!0)})]),Ce=k([p({equals:t()}),p({does_not_equal:t()}),p({contains:t()}),p({does_not_contain:t()}),p({starts_with:t()}),p({ends_with:t()}),Ee]),Ln=k([p({equals:P()}),p({does_not_equal:P()}),p({greater_than:P()}),p({less_than:P()}),p({greater_than_or_equal_to:P()}),p({less_than_or_equal_to:P()}),Ee]),Gn=k([p({equals:h()}),p({does_not_equal:h()})]),_r=k([p({equals:Oe}),p({does_not_equal:Oe}),Ee]),Sr=B(["To-do","In progress","Complete","Current","Future"]),kr=k([Sr,L(O(Sr),Se(1),Me(5))]),Vn=k([p({group_equals:kr}),p({group_does_not_equal:kr})]),$n=k([_r,Vn]),Qn=k([p({contains:Oe}),p({contains_all:Oe}),p({does_not_contain:Oe}),Ee]),Q=B(["start_date","end_date"]),Xn=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Pe=k([Xn,t()]),Wn=k([p({target:u(Q),equals:Pe}),p({target:u(Q),before:Pe}),p({target:u(Q),after:Pe}),p({target:u(Q),on_or_before:Pe}),p({target:u(Q),on_or_after:Pe}),p({target:u(Q),this_week:p({})}),p({target:u(Q),past_week:p({})}),p({target:u(Q),past_month:p({})}),p({target:u(Q),past_year:p({})}),p({target:u(Q),next_week:p({})}),p({target:u(Q),next_month:p({})}),p({target:u(Q),next_year:p({})}),p({target:u(Q),is_empty:i(!0)}),p({target:u(Q),is_not_empty:i(!0)})]),Ir=k([p({propertyId:t(),relation:et}),p({propertyId:t(),created_by:Hn}),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:Ln}),p({propertyId:t(),checkbox:Gn}),p({propertyId:t(),select:_r}),p({propertyId:t(),multi_select:Qn}),p({propertyId:t(),status:$n}),p({propertyId:t(),date:Wn}),p({propertyId:t(),people:zn})]),Jn=k([Ir,p({and:O(Ir)})]),tt=10,Kn=p({propertyId:t(),direction:dr}),xr=r({type:i("queryDataSource"),subscriptionId:t(),dataSourceId:Z,limit:P(),filter:u(Jn),sorts:u(O(Kn))});var Cr=r({type:i("resize"),height:L(P(),be(),ke(0))});var Pr=r({type:i("unsubscribeDataSourceQuery"),subscriptionId:t()});var Or=r({type:i("updatePage"),requestId:t(),pageId:D,properties:u(xe),icon:u($e),cover:u(Qe),archived:u(h())});var Er=g("type",[fr,yr,xr,Pr,mr,Et,Bt,Dt,At,Or,Cr,vr]);function jr(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function Br(e){let o=jr(e);return o==="invalidHostMessage"||o==="invalidSandboxMessage"?{incomingType:o}:{incomingType:o,nack:{type:"invalidSandboxMessage",reason:Yn(o)}}}function Yn(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Rr=r({initializationId:t()}),Zn=r({bridgeProtocolVersion:k([P(),He()])});function Mr(e){let{iframe:o,sandboxOrigin:n,getInitStatus:s,emit:c,sendNack:l,onInvalidConnect:f,onInvalidInitResult:y,onConnect:m,onInitResult:I,onQueryDataSource:_,onUnsubscribeDataSourceQuery:R,onCreatePage:S,onGetPage:G,onOpenPage:J,onGetUser:F,onListUsers:M,onUpdatePage:U,onResize:ue}=e;function X(w,z){c("warn",{message:"Ignored unsupported sandbox message",payload:w,issues:z});let T=Br(w);if(T.incomingType==="connect"){let K=_e(Rr,w),ee=_e(Zn,w);if(f({initializationId:K.success?K.output.initializationId:void 0,error:Yt(),bridgeProtocolVersion:ee.success?ee.output.bridgeProtocolVersion:void 0})==="handled")return}if(T.incomingType==="initResult"){let K=_e(Rr,w);y({initializationId:K.success?K.output.initializationId:void 0,error:or()})}T.nack!==void 0&&s()!=="stopped"&&l(T.nack)}return function(z){let T=z.source===o.contentWindow,K=z.origin===n;if(!T||!K)return;let ee=_e(Er,z.data);if(!ee.success){X(z.data,ee.issues);return}let x=ee.output;if(!cr(x)&&s()!=="initialized"){c("warn",{message:`Ignored ${x.type} before initialization completed`,payload:x});return}switch(c("in",x),x.type){case"connect":m(x);return;case"initResult":I(x);return;case"queryDataSource":_(x);return;case"unsubscribeDataSourceQuery":R(x);return;case"createPage":S(x);return;case"openPage":J(x);return;case"getPage":G(x);return;case"getUser":F(x);return;case"listUsers":M(x);return;case"updatePage":U(x);return;case"resize":ue(x);return;case"invalidHostMessage":return;default:se(x)}}}var qe=class{constructor(o){this.onUnsubscribe=o}onUnsubscribe;bySubscriptionId=new Map;subscribe(o){this.unsubscribe(o.subscriptionId);let n={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(o.subscriptionId,{message:o,token:n,isRefreshing:!0,shouldRefreshAgain:!1}),n}isCurrent(o,n){return this.bySubscriptionId.get(o)?.token===n}unsubscribe(o){this.bySubscriptionId.delete(o)&&this.onUnsubscribe(o)}refresh(o){let n=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===o){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,n.push({message:c.message,token:c.token})}return s?n:void 0}finish(o,n){let s=this.bySubscriptionId.get(o);if(s?.token===n&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let o of this.bySubscriptionId.keys())this.unsubscribe(o)}};function Dr(e,o){if(e===void 0)return;let n="and"in e?e.and:[e];for(let s of n){let c=eo(s,o);if(c!==void 0)return c}}function eo(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,_=(Array.isArray(m)?m:[m]).find(R=>!n.groups.some(S=>S.name===R));return _===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${_}".`,isRetryable:!1}}}if("relation"in e&&!at(et,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=to(e);if(c===void 0||n.type!==c.propertyType)return;let l=new Set(n.options.map(y=>y.name)),f=ro(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 to(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 ro(e){let o;if("equals"in e)o=e.equals;else if("does_not_equal"in e)o=e.does_not_equal;else if("contains"in e)o=e.contains;else if("contains_all"in e)o=e.contains_all;else if("does_not_contain"in e)o=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:se(e);return Array.isArray(o)?o:[o]}var no=new Set(yt);function wr(e,o){if(e===void 0)return;if(e.length>tt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${tt} 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(!no.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 qr=5;function io(e){let{iframe:o,getInitialState:n,handlers:s,onManifest:c,onInitialized:l,onConnectionFailure:f,onLog:y,onQueryUnsubscribed:m,sandboxOrigin:I,minBridgeProtocolVersion:_,noConnectTimeoutMs:R,initialStateTimeoutMs:S,noInitResultTimeoutMs:G}=e,J=Math.max(_??3,3),F={},M=!1,U,ue,X=6,w=new qe(a=>{m?.(a)});function z(a,C){y?.(a,C)}function T(a){let C=v.status;switch(C){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"error":break;case"stopped":return;default:return se(C)}let q=ur(a,X);z("out",q),o.contentWindow?.postMessage(q,I)}function K(a){T(re(Ae,a))}function ee(a){T(a)}function x(a){let C=v.status;switch(C){case"initialized":T(re(Jt,a));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"error":case"stopped":return;default:se(C)}}async function ae(a,C){if(C===void 0)return;let q=await C(a);x({type:`${a.type}Result`,requestId:a.requestId,...q})}function je(a){let C=a.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"error",error:a.response.error}:{type:"queryDataSourceResult",subscriptionId:a.subscriptionId,status:"success",items:a.response.items,hasMore:a.response.hasMore};x(C)}async function he(a,C=w.subscribe(a)){try{let q=so(ue,a.dataSourceId),le=uo(a,q);if(le!==void 0){w.isCurrent(a.subscriptionId,C)&&(w.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:{status:"error",error:le}}));return}let Te=await s.queryDataSource(a);if(!w.isCurrent(a.subscriptionId,C))return;Te.status==="error"&&!Te.error.isRetryable&&w.unsubscribe(a.subscriptionId),je({subscriptionId:a.subscriptionId,response:Te})}finally{let q=w.finish(a.subscriptionId,C);q!==void 0&&he(q.message,q.token)}}function ce(a){v.status==="stopped"||v.status==="error"||(Object.assign(F,a),b())}function b(){if(v.status!=="initialized")return;let a=F;F={},a.theme!==void 0&&x({type:"themeChanged",theme:a.theme}),a.contrastMode!==void 0&&x({type:"contrastModeChanged",contrastMode:a.contrastMode}),a.parent!==void 0&&x({type:"parentChanged",parent:a.parent}),a.page!==void 0&&x({type:"pageChanged",page:a.page}),a.dataSources!==void 0&&x({type:"dataSourcesChanged",dataSources:a.dataSources}),a.currentUser!==void 0&&x({type:"currentUserChanged",currentUser:a.currentUser})}let v=sr({async prepareInit(a){X=a.bridgeProtocolVersion;let C=await n(a);return v.status!=="preparingInit"?C:V(C)},sendInitMessage:K,warn:a=>z("warn",a),flushPendingHostStateChanges:b,minBridgeProtocolVersion:J,noConnectTimeoutMs:R,initialStateTimeoutMs:S,noInitResultTimeoutMs:G,stopHostWithFailure:rt,onInitResult(a){a.status==="success"&&U!==void 0&&l?.({manifest:U,initialHeight:a.initialHeight})},onConnectionFailure:f});function V(a){if(a.status==="error")return a;U=re(fe,a.initialState.manifest),c?.(U);let C={...a.initialState,...F};F={};let q={...re(ct(ar,["manifest"]),C),manifest:U};if(X<qr&&q.page.type==="unavailable")return{status:"error",error:Ye()};let le=Tr(q.manifest,q.dataSources);return le!==void 0?{status:"error",error:le}:(ue=q.dataSources,M=!0,{status:"success",initialState:q})}let Y=Mr({iframe:o,sandboxOrigin:I,getInitStatus:()=>v.status,emit:z,sendNack:ee,onInvalidConnect:v.handleInvalidConnect,onInvalidInitResult:v.handleInvalidInitResult,onConnect:v.handleConnect,onInitResult:v.handleInitResult,onQueryDataSource:he,onUnsubscribeDataSourceQuery:a=>w.unsubscribe(a.subscriptionId),onCreatePage:a=>ae(a,s.createPage),onGetPage:a=>ae(a,s.getPage),onOpenPage:a=>ae(a,s.openPage),onGetUser:a=>ae(a,s.getUser),onListUsers:a=>ae(a,s.listUsers),onUpdatePage:a=>ae(a,s.updatePage),onResize:a=>s.resize?.(a)});window.addEventListener("message",Y),o.addEventListener("load",v.onIframeLoad);function Be(){window.removeEventListener("message",Y),o.removeEventListener("load",v.onIframeLoad),v.stop(),w.unsubscribeAll()}function rt(a){Be(),z("warn",a),f?.(a)}return{stop:Be,setTheme(a){ce({theme:a})},setContrastMode(a){ce({contrastMode:a})},setParent(a){ce({parent:a})},setPage(a){if(a.type==="unavailable"&&X<qr&&(v.status==="preparingInit"&&M||v.status==="waitingForInitResult"||v.status==="initialized")){rt({...Ye(),phase:"runtime",source:"host"});return}ce({page:a})},setCurrentUser(a){ce({currentUser:a})},setDataSources(a){let C={bindings:re(pe,a.bindings)};if(v.hasConnectedSandbox&&U!==void 0&&Tr(U,C)!==void 0){z("warn",{message:"Ignored invalid data source bindings update",payload:C});return}ue=C,ce({dataSources:C})},refreshQuery({dataSourceId:a}){if(v.status!=="initialized")return;let C=re(Z,a),q=w.refresh(C);if(q===void 0){z("warn",`No active query exists for data source "${a}"`);return}for(let le of q)he(le.message,le.token)}}}function so(e,o){return Object.values(e?.bindings??{}).find(n=>n.collectionPointer?.id===o)?.collectionSchema}function Tr(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 er();for(let[l,f]of Object.entries(s.properties??{})){let y=c.propertyIdsByKey?.[l];if(y===void 0)return tr();if(c.collectionSchema.propertiesById[y]?.type!==f.type)return rr()}}}function uo(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}:Dr(e.filter,o)??wr(e.sorts,o)}function ao(e){return re(D,e)}function co(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{Nr as LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION,io as createCustomBlockHost,Fr as getAutoBoundPropertyIdsByKey,co as isLocalCustomBlockUrl,ao as toNotionPageId};
|
package/dist/ids.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAEjB,MAAM,yCAAyC,CAAA;AAGhD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAEvD"}
|
package/dist/ids.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export type { LegacyNotionDataSourcePageBridge, NotionDataSourcePageBridge, } from "./protocol/dataSources/dataSourcePage.js";
|
|
2
|
+
export type { NotionPropertySchemasById } from "./protocol/dataSources/propertySchema.js";
|
|
1
3
|
export type { CustomBlockErrorInfo } from "./protocol/errors.js";
|
|
4
|
+
export type { NotionPageId } from "./protocol/ids.js";
|
|
2
5
|
export type { CreatePageMessage } from "./protocol/messages/createPage.js";
|
|
3
6
|
export type { GetPageMessage } from "./protocol/messages/getPage.js";
|
|
4
7
|
export type { GetUserMessage } from "./protocol/messages/getUser.js";
|
|
@@ -8,8 +11,10 @@ export type { CustomBlockCheckboxFilterOperator, CustomBlockContainsFilterOperat
|
|
|
8
11
|
export type { ResizeMessage } from "./protocol/messages/resize.js";
|
|
9
12
|
export type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
|
|
10
13
|
export type { NotionDateInput, NotionFileInput, NotionPageCover, NotionPageIcon, NotionPagePropertyReadMap, NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, NotionSelectOptionInput, } from "./protocol/pages/page.js";
|
|
14
|
+
export { LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION } from "./protocol/protocolVersion.js";
|
|
11
15
|
export { type AutoBindableProperty, getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
|
|
12
16
|
export { type CustomBlockHostHandle, type CustomBlockHostOptions, createCustomBlockHost, } from "./createCustomBlockHost.js";
|
|
17
|
+
export { toNotionPageId } from "./ids.js";
|
|
13
18
|
export type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostGetInitialState, CustomBlockHostInitialState, CustomBlockHostInitialStateResult, } from "./lifecycle/types.js";
|
|
14
19
|
export { isLocalCustomBlockUrl } from "./localBlockUrl.js";
|
|
15
20
|
export type { CreatePageMessageInput, CustomBlockHostCreatePageResult, CustomBlockHostFailure, CustomBlockHostGetPageResult, CustomBlockHostGetUserResult, CustomBlockHostHandlers, CustomBlockHostListUsersResult, CustomBlockHostLogDirection, CustomBlockHostOpenPageResult, CustomBlockHostUpdatePageResult, GetPageMessageInput, GetUserMessageInput, ListUsersMessageInput, OpenPageMessageInput, QueryDataSourceMessageInput, ResizeMessageInput, UpdatePageMessageInput, } from "./messages/types.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,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,8BAA8B,EAC9B,2BAA2B,EAC3B,iCAAiC,GACjC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,gCAAgC,EAChC,0BAA0B,GAC1B,MAAM,gEAAgE,CAAA;AACvE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAA;AAC/G,YAAY,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAA;AACtF,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAC3E,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,YAAY,EACX,iCAAiC,EACjC,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,+BAA+B,EAC/B,4BAA4B,EAC5B,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,0BAA0B,EAC1B,6BAA6B,EAC7B,sBAAsB,EACtB,mCAAmC,EACnC,2CAA2C,EAC3C,iCAAiC,GACjC,MAAM,8DAA8D,CAAA;AACrE,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAAE,sCAAsC,EAAE,MAAM,qDAAqD,CAAA;AAC5G,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,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,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"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION } from "./protocol/protocolVersion.js";
|
|
1
2
|
export { getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
|
|
2
3
|
export { createCustomBlockHost, } from "./createCustomBlockHost.js";
|
|
4
|
+
export { toNotionPageId } from "./ids.js";
|
|
3
5
|
export { isLocalCustomBlockUrl } from "./localBlockUrl.js";
|
|
@@ -4,7 +4,7 @@ import * as v from "valibot";
|
|
|
4
4
|
* properties by raw property ID. The four built-ins (`created_time`, `last_edited_time`,
|
|
5
5
|
* `created_by`, `last_edited_by`) are normally present, possibly with `undefined` values.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const legacyNotionDataSourcePageBridgeSchema: v.ObjectSchema<{
|
|
8
8
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
9
9
|
/** Whether the page or an ancestor is archived. */
|
|
10
10
|
readonly is_archived: v.BooleanSchema<undefined>;
|
|
@@ -72,5 +72,164 @@ export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
|
|
|
72
72
|
readonly table: v.StringSchema<undefined>;
|
|
73
73
|
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
74
74
|
}, undefined>;
|
|
75
|
+
export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
|
|
76
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
77
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
78
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
79
|
+
readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
80
|
+
readonly id: v.StringSchema<undefined>;
|
|
81
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
82
|
+
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
83
|
+
}, undefined>, v.ObjectSchema<{
|
|
84
|
+
readonly id: v.StringSchema<undefined>;
|
|
85
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
86
|
+
readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
87
|
+
}, undefined>, v.ObjectSchema<{
|
|
88
|
+
readonly id: v.StringSchema<undefined>;
|
|
89
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
90
|
+
readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
91
|
+
}, undefined>, v.ObjectSchema<{
|
|
92
|
+
readonly id: v.StringSchema<undefined>;
|
|
93
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
94
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
95
|
+
}, undefined>, v.ObjectSchema<{
|
|
96
|
+
readonly id: v.StringSchema<undefined>;
|
|
97
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
98
|
+
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
99
|
+
}, undefined>, v.ObjectSchema<{
|
|
100
|
+
readonly id: v.StringSchema<undefined>;
|
|
101
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
102
|
+
readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
103
|
+
}, undefined>, v.ObjectSchema<{
|
|
104
|
+
readonly id: v.StringSchema<undefined>;
|
|
105
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
106
|
+
readonly checkbox: v.BooleanSchema<undefined>;
|
|
107
|
+
}, undefined>, v.ObjectSchema<{
|
|
108
|
+
readonly id: v.StringSchema<undefined>;
|
|
109
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
110
|
+
readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
111
|
+
readonly id: v.StringSchema<undefined>;
|
|
112
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
113
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
114
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
115
|
+
}, undefined>, v.ObjectSchema<{
|
|
116
|
+
readonly name: v.StringSchema<undefined>;
|
|
117
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
118
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
119
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
120
|
+
}, undefined>], undefined>, undefined>;
|
|
121
|
+
}, undefined>, v.ObjectSchema<{
|
|
122
|
+
readonly id: v.StringSchema<undefined>;
|
|
123
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
124
|
+
readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
125
|
+
readonly id: v.StringSchema<undefined>;
|
|
126
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
127
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
128
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
129
|
+
}, undefined>, v.ObjectSchema<{
|
|
130
|
+
readonly name: v.StringSchema<undefined>;
|
|
131
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
132
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
133
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
134
|
+
}, undefined>], undefined>, undefined>;
|
|
135
|
+
}, undefined>, v.ObjectSchema<{
|
|
136
|
+
readonly id: v.StringSchema<undefined>;
|
|
137
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
138
|
+
readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
139
|
+
readonly id: v.StringSchema<undefined>;
|
|
140
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
141
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
142
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
143
|
+
}, undefined>, v.ObjectSchema<{
|
|
144
|
+
readonly name: v.StringSchema<undefined>;
|
|
145
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
146
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
147
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
148
|
+
}, undefined>], undefined>, undefined>;
|
|
149
|
+
}, undefined>, v.ObjectSchema<{
|
|
150
|
+
readonly id: v.StringSchema<undefined>;
|
|
151
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
152
|
+
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
153
|
+
readonly start: v.StringSchema<undefined>;
|
|
154
|
+
readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
155
|
+
readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
156
|
+
}, undefined>, undefined>;
|
|
157
|
+
}, undefined>, v.ObjectSchema<{
|
|
158
|
+
readonly id: v.StringSchema<undefined>;
|
|
159
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
160
|
+
readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
161
|
+
readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
|
|
162
|
+
readonly id: v.StringSchema<undefined>;
|
|
163
|
+
}, undefined>, v.ObjectSchema<{
|
|
164
|
+
readonly object: v.LiteralSchema<"group", undefined>;
|
|
165
|
+
readonly id: v.StringSchema<undefined>;
|
|
166
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
167
|
+
}, undefined>], undefined>, undefined>;
|
|
168
|
+
}, undefined>, v.ObjectSchema<{
|
|
169
|
+
readonly id: v.StringSchema<undefined>;
|
|
170
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
171
|
+
readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
172
|
+
readonly relation: v.ArraySchema<v.ObjectSchema<{
|
|
173
|
+
readonly id: v.StringSchema<undefined>;
|
|
174
|
+
}, undefined>, undefined>;
|
|
175
|
+
}, undefined>, v.ObjectSchema<{
|
|
176
|
+
readonly id: v.StringSchema<undefined>;
|
|
177
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
178
|
+
readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
179
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
180
|
+
readonly name: v.StringSchema<undefined>;
|
|
181
|
+
readonly external: v.ObjectSchema<{
|
|
182
|
+
readonly url: v.StringSchema<undefined>;
|
|
183
|
+
}, undefined>;
|
|
184
|
+
}, undefined>, v.ObjectSchema<{
|
|
185
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
186
|
+
readonly name: v.StringSchema<undefined>;
|
|
187
|
+
readonly file: v.ObjectSchema<{
|
|
188
|
+
readonly url: v.StringSchema<undefined>;
|
|
189
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
190
|
+
}, undefined>;
|
|
191
|
+
}, undefined>], undefined>, undefined>;
|
|
192
|
+
}, undefined>, v.ObjectSchema<{
|
|
193
|
+
readonly id: v.StringSchema<undefined>;
|
|
194
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
195
|
+
readonly place: v.NullableSchema<v.ObjectSchema<{
|
|
196
|
+
readonly lat: v.NumberSchema<undefined>;
|
|
197
|
+
readonly lon: v.NumberSchema<undefined>;
|
|
198
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
199
|
+
readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
200
|
+
readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
201
|
+
readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
202
|
+
}, undefined>, undefined>;
|
|
203
|
+
}, undefined>, v.ObjectSchema<{
|
|
204
|
+
readonly id: v.StringSchema<undefined>;
|
|
205
|
+
readonly type: v.LiteralSchema<"created_time", undefined>;
|
|
206
|
+
readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
207
|
+
}, undefined>, v.ObjectSchema<{
|
|
208
|
+
readonly id: v.StringSchema<undefined>;
|
|
209
|
+
readonly type: v.LiteralSchema<"last_edited_time", undefined>;
|
|
210
|
+
readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
211
|
+
}, undefined>, v.ObjectSchema<{
|
|
212
|
+
readonly id: v.StringSchema<undefined>;
|
|
213
|
+
readonly type: v.LiteralSchema<"created_by", undefined>;
|
|
214
|
+
readonly created_by: v.NullableSchema<v.ObjectSchema<{
|
|
215
|
+
readonly id: v.StringSchema<undefined>;
|
|
216
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
217
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
218
|
+
}, undefined>, undefined>;
|
|
219
|
+
}, undefined>, v.ObjectSchema<{
|
|
220
|
+
readonly id: v.StringSchema<undefined>;
|
|
221
|
+
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
222
|
+
readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
|
|
223
|
+
readonly id: v.StringSchema<undefined>;
|
|
224
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
225
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
226
|
+
}, undefined>, undefined>;
|
|
227
|
+
}, undefined>, v.ObjectSchema<{
|
|
228
|
+
readonly id: v.StringSchema<undefined>;
|
|
229
|
+
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
230
|
+
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
231
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
232
|
+
}, undefined>;
|
|
233
|
+
export type LegacyNotionDataSourcePageBridge = v.InferOutput<typeof legacyNotionDataSourcePageBridgeSchema>;
|
|
75
234
|
/** Internal SDK type for a parsed bridge page. */
|
|
76
235
|
export type NotionDataSourcePageBridge = v.InferOutput<typeof notionDataSourcePageBridgeSchema>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { notionPageIdSchema } from "../ids.js";
|
|
3
|
+
import { notionPagePropertyValueSchema } from "../pages/page.js";
|
|
3
4
|
import { notionDataSourceValueSchema } from "./dataSourceValue.js";
|
|
4
5
|
/**
|
|
5
6
|
* Bridge shape for a data source page, as parsed from inbound host messages. The host keys
|
|
6
7
|
* properties by raw property ID. The four built-ins (`created_time`, `last_edited_time`,
|
|
7
8
|
* `created_by`, `last_edited_by`) are normally present, possibly with `undefined` values.
|
|
8
9
|
*/
|
|
9
|
-
export const
|
|
10
|
+
export const legacyNotionDataSourcePageBridgeSchema = v.object({
|
|
10
11
|
id: notionPageIdSchema,
|
|
11
12
|
/** Whether the page or an ancestor is archived. */
|
|
12
13
|
is_archived: v.boolean(),
|
|
@@ -14,3 +15,9 @@ export const notionDataSourcePageBridgeSchema = v.object({
|
|
|
14
15
|
in_trash: v.boolean(),
|
|
15
16
|
propertiesById: v.record(v.string(), v.optional(notionDataSourceValueSchema)),
|
|
16
17
|
});
|
|
18
|
+
export const notionDataSourcePageBridgeSchema = v.object({
|
|
19
|
+
id: notionPageIdSchema,
|
|
20
|
+
is_archived: v.boolean(),
|
|
21
|
+
in_trash: v.boolean(),
|
|
22
|
+
properties: v.record(v.string(), v.optional(notionPagePropertyValueSchema)),
|
|
23
|
+
});
|
|
@@ -189,6 +189,7 @@ export declare const notionPropertySchemaSchema: v.VariantSchema<"type", [v.Obje
|
|
|
189
189
|
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
190
190
|
}, undefined>], undefined>;
|
|
191
191
|
export type NotionPropertySchema = v.InferOutput<typeof notionPropertySchemaSchema>;
|
|
192
|
+
export type NotionPropertySchemasById = Record<string, NotionPropertySchema>;
|
|
192
193
|
/**
|
|
193
194
|
* The four synthetic built-in property IDs the host always includes in every
|
|
194
195
|
* data source's `propertySchemasById` and every row's `propertiesById`.
|
|
@@ -460,7 +460,164 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
460
460
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
461
461
|
readonly subscriptionId: v.StringSchema<undefined>;
|
|
462
462
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
463
|
-
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
463
|
+
readonly items: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
464
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
465
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
466
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
467
|
+
readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
468
|
+
readonly id: v.StringSchema<undefined>;
|
|
469
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
470
|
+
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
471
|
+
}, undefined>, v.ObjectSchema<{
|
|
472
|
+
readonly id: v.StringSchema<undefined>;
|
|
473
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
474
|
+
readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
475
|
+
}, undefined>, v.ObjectSchema<{
|
|
476
|
+
readonly id: v.StringSchema<undefined>;
|
|
477
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
478
|
+
readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
479
|
+
}, undefined>, v.ObjectSchema<{
|
|
480
|
+
readonly id: v.StringSchema<undefined>;
|
|
481
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
482
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
483
|
+
}, undefined>, v.ObjectSchema<{
|
|
484
|
+
readonly id: v.StringSchema<undefined>;
|
|
485
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
486
|
+
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
487
|
+
}, undefined>, v.ObjectSchema<{
|
|
488
|
+
readonly id: v.StringSchema<undefined>;
|
|
489
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
490
|
+
readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
491
|
+
}, undefined>, v.ObjectSchema<{
|
|
492
|
+
readonly id: v.StringSchema<undefined>;
|
|
493
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
494
|
+
readonly checkbox: v.BooleanSchema<undefined>;
|
|
495
|
+
}, undefined>, v.ObjectSchema<{
|
|
496
|
+
readonly id: v.StringSchema<undefined>;
|
|
497
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
498
|
+
readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
499
|
+
readonly id: v.StringSchema<undefined>;
|
|
500
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
501
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
502
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
503
|
+
}, undefined>, v.ObjectSchema<{
|
|
504
|
+
readonly name: v.StringSchema<undefined>;
|
|
505
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
506
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
507
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
508
|
+
}, undefined>], undefined>, undefined>;
|
|
509
|
+
}, undefined>, v.ObjectSchema<{
|
|
510
|
+
readonly id: v.StringSchema<undefined>;
|
|
511
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
512
|
+
readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
513
|
+
readonly id: v.StringSchema<undefined>;
|
|
514
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
515
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
516
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
517
|
+
}, undefined>, v.ObjectSchema<{
|
|
518
|
+
readonly name: v.StringSchema<undefined>;
|
|
519
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
520
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
521
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
522
|
+
}, undefined>], undefined>, undefined>;
|
|
523
|
+
}, undefined>, v.ObjectSchema<{
|
|
524
|
+
readonly id: v.StringSchema<undefined>;
|
|
525
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
526
|
+
readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
527
|
+
readonly id: v.StringSchema<undefined>;
|
|
528
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
529
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
530
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
531
|
+
}, undefined>, v.ObjectSchema<{
|
|
532
|
+
readonly name: v.StringSchema<undefined>;
|
|
533
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
534
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
535
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
536
|
+
}, undefined>], undefined>, undefined>;
|
|
537
|
+
}, undefined>, v.ObjectSchema<{
|
|
538
|
+
readonly id: v.StringSchema<undefined>;
|
|
539
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
540
|
+
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
541
|
+
readonly start: v.StringSchema<undefined>;
|
|
542
|
+
readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
543
|
+
readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
544
|
+
}, undefined>, undefined>;
|
|
545
|
+
}, undefined>, v.ObjectSchema<{
|
|
546
|
+
readonly id: v.StringSchema<undefined>;
|
|
547
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
548
|
+
readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
549
|
+
readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
|
|
550
|
+
readonly id: v.StringSchema<undefined>;
|
|
551
|
+
}, undefined>, v.ObjectSchema<{
|
|
552
|
+
readonly object: v.LiteralSchema<"group", undefined>;
|
|
553
|
+
readonly id: v.StringSchema<undefined>;
|
|
554
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
555
|
+
}, undefined>], undefined>, undefined>;
|
|
556
|
+
}, undefined>, v.ObjectSchema<{
|
|
557
|
+
readonly id: v.StringSchema<undefined>;
|
|
558
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
559
|
+
readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
560
|
+
readonly relation: v.ArraySchema<v.ObjectSchema<{
|
|
561
|
+
readonly id: v.StringSchema<undefined>;
|
|
562
|
+
}, undefined>, undefined>;
|
|
563
|
+
}, undefined>, v.ObjectSchema<{
|
|
564
|
+
readonly id: v.StringSchema<undefined>;
|
|
565
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
566
|
+
readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
567
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
568
|
+
readonly name: v.StringSchema<undefined>;
|
|
569
|
+
readonly external: v.ObjectSchema<{
|
|
570
|
+
readonly url: v.StringSchema<undefined>;
|
|
571
|
+
}, undefined>;
|
|
572
|
+
}, undefined>, v.ObjectSchema<{
|
|
573
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
574
|
+
readonly name: v.StringSchema<undefined>;
|
|
575
|
+
readonly file: v.ObjectSchema<{
|
|
576
|
+
readonly url: v.StringSchema<undefined>;
|
|
577
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
578
|
+
}, undefined>;
|
|
579
|
+
}, undefined>], undefined>, undefined>;
|
|
580
|
+
}, undefined>, v.ObjectSchema<{
|
|
581
|
+
readonly id: v.StringSchema<undefined>;
|
|
582
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
583
|
+
readonly place: v.NullableSchema<v.ObjectSchema<{
|
|
584
|
+
readonly lat: v.NumberSchema<undefined>;
|
|
585
|
+
readonly lon: v.NumberSchema<undefined>;
|
|
586
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
587
|
+
readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
588
|
+
readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
589
|
+
readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
590
|
+
}, undefined>, undefined>;
|
|
591
|
+
}, undefined>, v.ObjectSchema<{
|
|
592
|
+
readonly id: v.StringSchema<undefined>;
|
|
593
|
+
readonly type: v.LiteralSchema<"created_time", undefined>;
|
|
594
|
+
readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
595
|
+
}, undefined>, v.ObjectSchema<{
|
|
596
|
+
readonly id: v.StringSchema<undefined>;
|
|
597
|
+
readonly type: v.LiteralSchema<"last_edited_time", undefined>;
|
|
598
|
+
readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
599
|
+
}, undefined>, v.ObjectSchema<{
|
|
600
|
+
readonly id: v.StringSchema<undefined>;
|
|
601
|
+
readonly type: v.LiteralSchema<"created_by", undefined>;
|
|
602
|
+
readonly created_by: v.NullableSchema<v.ObjectSchema<{
|
|
603
|
+
readonly id: v.StringSchema<undefined>;
|
|
604
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
605
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
606
|
+
}, undefined>, undefined>;
|
|
607
|
+
}, undefined>, v.ObjectSchema<{
|
|
608
|
+
readonly id: v.StringSchema<undefined>;
|
|
609
|
+
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
610
|
+
readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
|
|
611
|
+
readonly id: v.StringSchema<undefined>;
|
|
612
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
613
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
614
|
+
}, undefined>, undefined>;
|
|
615
|
+
}, undefined>, v.ObjectSchema<{
|
|
616
|
+
readonly id: v.StringSchema<undefined>;
|
|
617
|
+
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
618
|
+
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
619
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
620
|
+
}, undefined>, v.ObjectSchema<{
|
|
464
621
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
465
622
|
readonly is_archived: v.BooleanSchema<undefined>;
|
|
466
623
|
readonly in_trash: v.BooleanSchema<undefined>;
|
|
@@ -525,7 +682,7 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
525
682
|
readonly id: v.StringSchema<undefined>;
|
|
526
683
|
readonly table: v.StringSchema<undefined>;
|
|
527
684
|
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
528
|
-
}, undefined>, undefined>;
|
|
685
|
+
}, undefined>], undefined>, undefined>;
|
|
529
686
|
readonly hasMore: v.BooleanSchema<undefined>;
|
|
530
687
|
}, undefined>, v.ObjectSchema<{
|
|
531
688
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
@@ -15,7 +15,164 @@ export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status
|
|
|
15
15
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
16
16
|
readonly subscriptionId: v.StringSchema<undefined>;
|
|
17
17
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
18
|
-
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
18
|
+
readonly items: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
19
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
20
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
21
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
22
|
+
readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
23
|
+
readonly id: v.StringSchema<undefined>;
|
|
24
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
25
|
+
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
26
|
+
}, undefined>, v.ObjectSchema<{
|
|
27
|
+
readonly id: v.StringSchema<undefined>;
|
|
28
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
29
|
+
readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
30
|
+
}, undefined>, v.ObjectSchema<{
|
|
31
|
+
readonly id: v.StringSchema<undefined>;
|
|
32
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
33
|
+
readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
34
|
+
}, undefined>, v.ObjectSchema<{
|
|
35
|
+
readonly id: v.StringSchema<undefined>;
|
|
36
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
37
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
38
|
+
}, undefined>, v.ObjectSchema<{
|
|
39
|
+
readonly id: v.StringSchema<undefined>;
|
|
40
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
41
|
+
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
42
|
+
}, undefined>, v.ObjectSchema<{
|
|
43
|
+
readonly id: v.StringSchema<undefined>;
|
|
44
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
45
|
+
readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
46
|
+
}, undefined>, v.ObjectSchema<{
|
|
47
|
+
readonly id: v.StringSchema<undefined>;
|
|
48
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
49
|
+
readonly checkbox: v.BooleanSchema<undefined>;
|
|
50
|
+
}, undefined>, v.ObjectSchema<{
|
|
51
|
+
readonly id: v.StringSchema<undefined>;
|
|
52
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
53
|
+
readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
54
|
+
readonly id: v.StringSchema<undefined>;
|
|
55
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
56
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
57
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
58
|
+
}, undefined>, v.ObjectSchema<{
|
|
59
|
+
readonly name: v.StringSchema<undefined>;
|
|
60
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
62
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
63
|
+
}, undefined>], undefined>, undefined>;
|
|
64
|
+
}, undefined>, v.ObjectSchema<{
|
|
65
|
+
readonly id: v.StringSchema<undefined>;
|
|
66
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
67
|
+
readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
68
|
+
readonly id: v.StringSchema<undefined>;
|
|
69
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
70
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
72
|
+
}, undefined>, v.ObjectSchema<{
|
|
73
|
+
readonly name: v.StringSchema<undefined>;
|
|
74
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
75
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
76
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
77
|
+
}, undefined>], undefined>, undefined>;
|
|
78
|
+
}, undefined>, v.ObjectSchema<{
|
|
79
|
+
readonly id: v.StringSchema<undefined>;
|
|
80
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
81
|
+
readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
82
|
+
readonly id: v.StringSchema<undefined>;
|
|
83
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
84
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
86
|
+
}, undefined>, v.ObjectSchema<{
|
|
87
|
+
readonly name: v.StringSchema<undefined>;
|
|
88
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
89
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
90
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
91
|
+
}, undefined>], undefined>, undefined>;
|
|
92
|
+
}, undefined>, v.ObjectSchema<{
|
|
93
|
+
readonly id: v.StringSchema<undefined>;
|
|
94
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
95
|
+
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
96
|
+
readonly start: v.StringSchema<undefined>;
|
|
97
|
+
readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
98
|
+
readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
99
|
+
}, undefined>, undefined>;
|
|
100
|
+
}, undefined>, v.ObjectSchema<{
|
|
101
|
+
readonly id: v.StringSchema<undefined>;
|
|
102
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
103
|
+
readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
104
|
+
readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
|
|
105
|
+
readonly id: v.StringSchema<undefined>;
|
|
106
|
+
}, undefined>, v.ObjectSchema<{
|
|
107
|
+
readonly object: v.LiteralSchema<"group", undefined>;
|
|
108
|
+
readonly id: v.StringSchema<undefined>;
|
|
109
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
110
|
+
}, undefined>], undefined>, undefined>;
|
|
111
|
+
}, undefined>, v.ObjectSchema<{
|
|
112
|
+
readonly id: v.StringSchema<undefined>;
|
|
113
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
114
|
+
readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
115
|
+
readonly relation: v.ArraySchema<v.ObjectSchema<{
|
|
116
|
+
readonly id: v.StringSchema<undefined>;
|
|
117
|
+
}, undefined>, undefined>;
|
|
118
|
+
}, undefined>, v.ObjectSchema<{
|
|
119
|
+
readonly id: v.StringSchema<undefined>;
|
|
120
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
121
|
+
readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
122
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
123
|
+
readonly name: v.StringSchema<undefined>;
|
|
124
|
+
readonly external: v.ObjectSchema<{
|
|
125
|
+
readonly url: v.StringSchema<undefined>;
|
|
126
|
+
}, undefined>;
|
|
127
|
+
}, undefined>, v.ObjectSchema<{
|
|
128
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
129
|
+
readonly name: v.StringSchema<undefined>;
|
|
130
|
+
readonly file: v.ObjectSchema<{
|
|
131
|
+
readonly url: v.StringSchema<undefined>;
|
|
132
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
133
|
+
}, undefined>;
|
|
134
|
+
}, undefined>], undefined>, undefined>;
|
|
135
|
+
}, undefined>, v.ObjectSchema<{
|
|
136
|
+
readonly id: v.StringSchema<undefined>;
|
|
137
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
138
|
+
readonly place: v.NullableSchema<v.ObjectSchema<{
|
|
139
|
+
readonly lat: v.NumberSchema<undefined>;
|
|
140
|
+
readonly lon: v.NumberSchema<undefined>;
|
|
141
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
142
|
+
readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
143
|
+
readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
144
|
+
readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
145
|
+
}, undefined>, undefined>;
|
|
146
|
+
}, undefined>, v.ObjectSchema<{
|
|
147
|
+
readonly id: v.StringSchema<undefined>;
|
|
148
|
+
readonly type: v.LiteralSchema<"created_time", undefined>;
|
|
149
|
+
readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
150
|
+
}, undefined>, v.ObjectSchema<{
|
|
151
|
+
readonly id: v.StringSchema<undefined>;
|
|
152
|
+
readonly type: v.LiteralSchema<"last_edited_time", undefined>;
|
|
153
|
+
readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
154
|
+
}, undefined>, v.ObjectSchema<{
|
|
155
|
+
readonly id: v.StringSchema<undefined>;
|
|
156
|
+
readonly type: v.LiteralSchema<"created_by", undefined>;
|
|
157
|
+
readonly created_by: v.NullableSchema<v.ObjectSchema<{
|
|
158
|
+
readonly id: v.StringSchema<undefined>;
|
|
159
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
160
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
161
|
+
}, undefined>, undefined>;
|
|
162
|
+
}, undefined>, v.ObjectSchema<{
|
|
163
|
+
readonly id: v.StringSchema<undefined>;
|
|
164
|
+
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
165
|
+
readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
|
|
166
|
+
readonly id: v.StringSchema<undefined>;
|
|
167
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
168
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
169
|
+
}, undefined>, undefined>;
|
|
170
|
+
}, undefined>, v.ObjectSchema<{
|
|
171
|
+
readonly id: v.StringSchema<undefined>;
|
|
172
|
+
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
173
|
+
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
174
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
175
|
+
}, undefined>, v.ObjectSchema<{
|
|
19
176
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
20
177
|
readonly is_archived: v.BooleanSchema<undefined>;
|
|
21
178
|
readonly in_trash: v.BooleanSchema<undefined>;
|
|
@@ -80,7 +237,7 @@ export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status
|
|
|
80
237
|
readonly id: v.StringSchema<undefined>;
|
|
81
238
|
readonly table: v.StringSchema<undefined>;
|
|
82
239
|
}, undefined>, undefined>], undefined>, undefined>, undefined>;
|
|
83
|
-
}, undefined>, undefined>;
|
|
240
|
+
}, undefined>], undefined>, undefined>;
|
|
84
241
|
readonly hasMore: v.BooleanSchema<undefined>;
|
|
85
242
|
}, undefined>, v.ObjectSchema<{
|
|
86
243
|
readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { notionDataSourcePageBridgeSchema } from "../dataSources/dataSourcePage.js";
|
|
2
|
+
import { legacyNotionDataSourcePageBridgeSchema, notionDataSourcePageBridgeSchema, } from "../dataSources/dataSourcePage.js";
|
|
3
3
|
// The schema accepts any string code. The type lists known codes for
|
|
4
4
|
// autocomplete, with an open string fallback for newer senders.
|
|
5
5
|
export const customBlockQueryDataSourceErrorCodeSchema = v.string();
|
|
@@ -16,7 +16,10 @@ export const queryDataSourceResultMessageSchema = v.variant("status", [
|
|
|
16
16
|
type: v.literal("queryDataSourceResult"),
|
|
17
17
|
subscriptionId: v.string(),
|
|
18
18
|
status: v.literal("success"),
|
|
19
|
-
items: v.array(
|
|
19
|
+
items: v.array(v.union([
|
|
20
|
+
notionDataSourcePageBridgeSchema,
|
|
21
|
+
legacyNotionDataSourcePageBridgeSchema,
|
|
22
|
+
])),
|
|
20
23
|
hasMore: v.boolean(),
|
|
21
24
|
}),
|
|
22
25
|
v.object({
|
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
4
|
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export declare const LATEST_BRIDGE_PROTOCOL_VERSION =
|
|
6
|
+
export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 6;
|
|
7
|
+
export declare const LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION = 6;
|
|
@@ -3,4 +3,7 @@
|
|
|
3
3
|
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
4
|
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export const LATEST_BRIDGE_PROTOCOL_VERSION =
|
|
6
|
+
export const LATEST_BRIDGE_PROTOCOL_VERSION = 6;
|
|
7
|
+
// Protocol 6 introduces name-keyed property objects for data source queries.
|
|
8
|
+
// Keep this cutoff fixed when the latest protocol version increases.
|
|
9
|
+
export const LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION = 6;
|
package/package.json
CHANGED
package/src/ids.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
LegacyNotionDataSourcePageBridge,
|
|
3
|
+
NotionDataSourcePageBridge,
|
|
4
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
5
|
+
export type { NotionPropertySchemasById } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
1
6
|
export type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
|
|
7
|
+
export type { NotionPageId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
2
8
|
export type { CreatePageMessage } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
|
|
3
9
|
export type { GetPageMessage } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
4
10
|
export type { GetUserMessage } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
@@ -36,6 +42,7 @@ export type {
|
|
|
36
42
|
NotionRichTextItem,
|
|
37
43
|
NotionSelectOptionInput,
|
|
38
44
|
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
45
|
+
export { LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/protocolVersion.js"
|
|
39
46
|
export {
|
|
40
47
|
type AutoBindableProperty,
|
|
41
48
|
getAutoBoundPropertyIdsByKey,
|
|
@@ -45,6 +52,7 @@ export {
|
|
|
45
52
|
type CustomBlockHostOptions,
|
|
46
53
|
createCustomBlockHost,
|
|
47
54
|
} from "./createCustomBlockHost.js"
|
|
55
|
+
export { toNotionPageId } from "./ids.js"
|
|
48
56
|
export type {
|
|
49
57
|
ConnectSuccessMessage,
|
|
50
58
|
CustomBlockHostDataSourcesPayload,
|