@notionhq/custom-blocks-host 0.7.0 → 0.8.0
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/compatibility/normalizeSandboxToHostMessage.d.ts +3 -2
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts.map +1 -1
- package/dist/compatibility/protocol3To4/addMetadataReadSchemasForProtocol3To4.d.ts +2 -2
- package/dist/context/initialState.d.ts +6 -6
- package/dist/manifest/types.d.ts +2 -2
- package/dist/protocol/dataSources/bridgeArchiveStatus.d.ts +3 -0
- package/dist/protocol/dataSources/bridgeArchiveStatus.js +6 -0
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +3 -2
- package/dist/protocol/dataSources/messages/queryDataSource.js +2 -0
- package/dist/protocol/handshake/connect.d.ts +2 -2
- package/dist/protocol/handshake/init.d.ts +2 -2
- package/dist/protocol/index.d.ts +6 -4
- package/dist/protocol/index.js +3 -2
- package/dist/protocol/manifest/{capabilities.d.ts → grants.d.ts} +12 -12
- package/dist/protocol/manifest/{capabilities.js → grants.js} +6 -6
- package/dist/protocol/manifest/manifest.d.ts +6 -6
- package/dist/protocol/manifest/manifest.js +5 -5
- package/dist/protocol/messages/hostToSandbox.d.ts +4 -4
- package/dist/protocol/messages/sandboxToHost.d.ts +3 -2
- package/dist/protocol/pages/messages/createPage.d.ts +2 -2
- package/dist/protocol/pages/messages/getPage.d.ts +2 -2
- package/dist/protocol/pages/messages/openPage.d.ts +2 -2
- package/dist/protocol/pages/messages/updatePage.d.ts +2 -2
- package/dist/protocol/users/messages/getUser.d.ts +2 -2
- package/dist/protocol/users/messages/listUsers.d.ts +2 -2
- package/dist/protocol/utils/errors.d.ts +4 -4
- package/dist/protocol/utils/errors.js +3 -3
- package/docs/bridge/protocol.md +11 -10
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ve,fn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function ut(e){return!e&&!Ve?fn:{lang:e?.lang??Ve?.lang,message:e?.message,abortEarly:e?.abortEarly??Ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Ve?.abortPipeEarly}}var yn;function dn(e){return yn?.get(e)}var vn;function hn(e){return vn?.get(e)}var gn;function bn(e,t){return gn?.get(e)?.get(t)}function _e(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function M(e,t,o,s,c){let l=c&&"input"in c?c.input:o.value,p=c?.expected??e.expects??null,h=c?.received??_e(l),y={kind:e.kind,type:e.type,input:l,expected:p,received:h,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${h}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},x=e.kind==="schema",k=c?.message??e.message??bn(e.reference,y.lang)??(x?hn(y.lang):null)??s.message??dn(y.lang);k!==void 0&&(y.message=typeof k=="function"?k(y):k),x&&(o.typed=!1),o.issues?o.issues.push(y):o.issues=[y]}function Sn(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Ft(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function ct(e,t){let o=[...new Set(e)];return o.length>1?`(${o.join(` ${t} `)})`:o[0]??"never"}function $(e){return e["~standard"]={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},ut())},e}var kn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function me(e){return{kind:"transformation",type:"brand",reference:me,async:!1,name:e,"~run"(t){return t}}}function Te(e){return{kind:"validation",type:"finite",reference:Te,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,o){return t.typed&&!this.requirement(t.value)&&M(this,"finite",t,o),t}}}function lt(e,t){let o=_e(e);return{kind:"validation",type:"includes",reference:lt,async:!1,expects:o,requirement:e,message:t,"~run"(s,c){return s.typed&&!s.value.includes(this.requirement)&&M(this,"content",s,c,{received:`!${o}`}),s}}}function qe(e,t){return{kind:"validation",type:"max_length",reference:qe,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length>this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function fe(e,t){return{kind:"validation",type:"min_length",reference:fe,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length<this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function Ne(e,t){return{kind:"validation",type:"min_value",reference:Ne,async:!1,expects:`>=${e instanceof Date?e.toJSON():_e(e)}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!(o.value>=this.requirement)&&M(this,"value",o,s,{received:o.value instanceof Date?o.value.toJSON():_e(o.value)}),o}}}function pt(e,t){return{kind:"validation",type:"regex",reference:pt,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!this.requirement.test(o.value)&&M(this,"format",o,s),o}}}function mt(e){return{kind:"transformation",type:"transform",reference:mt,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var zt={abortEarly:!0};function ft(e,t,o){return typeof e.fallback=="function"?e.fallback(t,o):e.fallback}function Ae(e,t,o){return typeof e.default=="function"?e.default(t,o):e.default}function Ht(e,t){return!e["~run"]({value:t},zt).issues}function P(e,t){return $({kind:"schema",type:"array",reference:P,expects:"Array",async:!1,item:e,message:t,"~run"(o,s){let c=o.value;if(Array.isArray(c)){o.typed=!0,o.value=[];for(let l=0;l<c.length;l++){let p=c[l],h=this.item["~run"]({value:p},s);if(h.issues){let y={type:"array",origin:"value",input:c,key:l,value:p};for(let x of h.issues)x.path?x.path.unshift(y):x.path=[y],o.issues?.push(x);if(o.issues||(o.issues=h.issues),s.abortEarly){o.typed=!1;break}}h.typed||(o.typed=!1),o.value.push(h.value)}}else M(this,"type",o,s);return o}})}function g(e){return $({kind:"schema",type:"boolean",reference:g,expects:"boolean",async:!1,message:e,"~run"(t,o){return typeof t.value=="boolean"?t.typed=!0:M(this,"type",t,o),t}})}function i(e,t){return $({kind:"schema",type:"literal",reference:i,expects:_e(e),async:!1,literal:e,message:t,"~run"(o,s){return Sn(o.value,this.literal)?o.typed=!0:M(this,"type",o,s),o}})}function Ge(e,t){return $({kind:"schema",type:"loose_object",reference:Ge,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ae(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly)for(let l in c)Ft(c,l)&&!Object.prototype.hasOwnProperty.call(this.entries,l)&&(o.value[l]=c[l])}else M(this,"type",o,s);return o}})}function yt(e){return $({kind:"schema",type:"nan",reference:yt,expects:"NaN",async:!1,message:e,"~run"(t,o){return Number.isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function dt(e){return $({kind:"schema",type:"never",reference:dt,expects:"never",async:!1,message:e,"~run"(t,o){return M(this,"type",t,o),t}})}function q(e,t){return $({kind:"schema",type:"nullable",reference:q,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===null&&(this.default!==void 0&&(o.value=Ae(this,o,s)),o.value===null)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function R(e){return $({kind:"schema",type:"number",reference:R,expects:"number",async:!1,message:e,"~run"(t,o){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function n(e,t){return $({kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ae(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",o,s);return o}})}function a(e,t){return $({kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===void 0&&(this.default!==void 0&&(o.value=Ae(this,o,s)),o.value===void 0)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function B(e,t){return $({kind:"schema",type:"picklist",reference:B,expects:ct(e.map(_e),"|"),async:!1,options:e,message:t,"~run"(o,s){return this.options.includes(o.value)?o.typed=!0:M(this,"type",o,s),o}})}function L(e,t,o){return $({kind:"schema",type:"record",reference:L,expects:"Object",async:!1,key:e,value:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let p in l)if(Ft(l,p)){let h=l[p],y=this.key["~run"]({value:p},c);if(y.issues){let k={type:"object",origin:"key",input:l,key:p,value:h};for(let D of y.issues)D.path=[k],s.issues?.push(D);if(s.issues||(s.issues=y.issues),c.abortEarly){s.typed=!1;break}}let x=this.value["~run"]({value:h},c);if(x.issues){let k={type:"object",origin:"value",input:l,key:p,value:h};for(let D of x.issues)D.path?D.path.unshift(k):D.path=[k],s.issues?.push(D);if(s.issues||(s.issues=x.issues),c.abortEarly){s.typed=!1;break}}(!y.typed||!x.typed)&&(s.typed=!1),y.typed&&(s.value[y.value]=x.value)}}else M(this,"type",s,c);return s}})}function m(e,t){return $({kind:"schema",type:"strict_object",reference:m,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ae(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly){for(let l in c)if(!Object.prototype.hasOwnProperty.call(this.entries,l)){M(this,"key",o,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",o,s);return o}})}function r(e){return $({kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,"~run"(t,o){return typeof t.value=="string"?t.typed=!0:M(this,"type",t,o),t}})}function Ut(e){let t;if(e)for(let o of e)if(t)for(let s of o.issues)t.push(s);else t=o.issues;return t}function d(e,t){return $({kind:"schema",type:"union",reference:d,expects:ct(e.map(o=>o.expects),"|"),async:!1,options:e,message:t,"~run"(o,s){let c,l,p;for(let h of this.options){let y=h["~run"]({value:o.value},s);if(y.typed)if(y.issues)l?l.push(y):l=[y];else{c=y;break}else p?p.push(y):p=[y]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",o,s,{issues:Ut(l)}),o.typed=!0}else{if(p?.length===1)return p[0];M(this,"type",o,s,{issues:Ut(p)})}return o}})}function Se(){return $({kind:"schema",type:"unknown",reference:Se,expects:"unknown",async:!1,"~run"(e){return e.typed=!0,e}})}function v(e,t,o){return $({kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let p,h=0,y=this.key,x=[],k=(D,W)=>{for(let V of D.options){if(V.type==="variant")k(V,new Set(W).add(V.key));else{let b=!0,A=0;for(let j of W){let H=V.entries[j];if(j in l?H["~run"]({typed:!1,value:l[j]},zt).issues:H.type!=="exact_optional"&&H.type!=="optional"&&H.type!=="nullish"){b=!1,y!==j&&(h<A||h===A&&j in l&&!(y in l))&&(h=A,y=j,x=[]),y===j&&x.push(V.entries[j].expects);break}A++}if(b){let j=V["~run"]({value:l},c);(!p||!p.typed&&j.typed)&&(p=j)}}if(p&&!p.issues)break}};if(k(this,new Set([this.key])),p)return p;M(this,"type",s,c,{input:l[y],expected:ct(x,"|"),path:[{type:"object",origin:"value",input:l,key:y,value:l[y]}]})}else M(this,"type",s,c);return s}})}function Lt(e,t){let o={...e.entries};for(let s of t)delete o[s];return $({...e,entries:o})}function ue(e,t,o){let s=e["~run"]({value:t},ut(o));if(s.issues)throw new kn(s.issues);return s.value}function N(...e){return $({...e[0],pipe:e,"~run"(t,o){for(let s of e)if(s.kind!=="metadata"){if(t.issues&&(s.kind==="schema"||s.kind==="transformation")){t.typed=!1;break}(!t.issues||!o.abortEarly&&!o.abortPipeEarly)&&(t=s["~run"](t,o))}return t}})}function ie(e,t,o){let s=e["~run"]({value:t},ut(o));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var ye=N(r(),me("NotionBlockId")),K=N(r(),me("NotionDataSourceId")),z=N(r(),me("NotionPageId")),Vt=N(r(),me("NotionAgentId")),Gt=N(r(),me("NotionSpaceId"));var $t=n({id:K,table:r(),spaceId:a(Gt)});var Qt=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"]),vt=n({id:r(),name:r(),color:a(Qt),description:a(r())}),In=n({id:r(),name:r(),color:a(Qt),option_ids:P(r())}),_n=n({synced_property_id:r(),synced_property_name:r()}),w=n({name:r(),description:a(r())}),xn=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","location","created_time","last_edited_time","created_by","last_edited_by"],Wt=B(xn),Xt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Kt=v("type",[n({...w.entries,type:i("title")}),n({...w.entries,type:i("rich_text")}),n({...w.entries,type:i("number")}),n({...w.entries,type:i("checkbox")}),n({...w.entries,type:i("url")}),n({...w.entries,type:i("email")}),n({...w.entries,type:i("phone_number")}),n({...w.entries,type:i("select"),options:P(vt)}),n({...w.entries,type:i("multi_select"),options:P(vt)}),n({...w.entries,type:i("status"),options:P(vt),groups:P(In)}),n({...w.entries,type:i("date")}),n({...w.entries,type:i("people")}),n({...w.entries,type:i("files")}),n({...w.entries,type:i("unique_id")}),n({...w.entries,type:i("relation"),data_source_id:a(r()),dual_property:a(_n)}),n({...w.entries,type:i("place")}),n({...w.entries,type:i("formula")}),n({...w.entries,type:i("rollup")}),n({...w.entries,type:i("button")}),n({...w.entries,type:i("verification")}),n({...w.entries,type:i("location")}),n({...w.entries,type:i("created_time")}),n({...w.entries,type:i("last_edited_time")}),n({...w.entries,type:i("created_by")}),n({...w.entries,type:i("last_edited_by")})]);var Zt={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 Jt=n({id:a(K),propertiesById:L(r(),Kt)});var Yt=n({collectionPointer:a($t),collectionSchema:a(Jt),propertyIdsByKey:a(L(r(),a(r()))),inaccessible:a(i(!0))});var he=L(r(),Yt);function er(e){let t=Object.entries(e.manifestDataSource.properties??{}).map(([o,s])=>{let c=e.propertyIdsByKey?.[o],l=c===void 0?void 0:e.collectionSchema?.propertiesById[c];return Cn(o,c,l?.type,s.type)});return e.collectionSchema===void 0?{status:"missing_schema",properties:t}:t.every(o=>o.status==="mapped")?{status:"complete",properties:t}:{status:"incomplete",properties:t}}function Cn(e,t,o,s){return t===void 0?{status:"missing",propertyKey:e,propertyId:t}:o===void 0?{status:"invalid",propertyKey:e,propertyId:t}:{status:o===s?"mapped":"incompatible",propertyKey:e,propertyId:t}}var $e=n({type:i("page_id"),page_id:z}),Qe=n({type:i("data_source_id"),data_source_id:K}),Pn=n({type:i("workspace"),workspace:i(!0)}),En=n({type:i("block_id"),block_id:ye}),On=n({type:i("agent_id"),agent_id:Vt}),Rn=n({type:i("unavailable")}),re=v("type",[$e,Qe,Pn,En,On,Rn]);var xe=v("type",[n({type:i("unavailable")}),n({type:i("page"),id:z,parent:re})]);var Ce=B(["standard","high"]),tr="standard";var Pe=B(["light","dark"]);var rr=n({capability:r(),resource:d([r(),N(P(r()),fe(1))])});var or=v("type",[n({type:i("emoji"),emoji:r()}),n({type:i("external"),url:r()})]),Bn=n({name:r(),description:a(r()),type:Wt}),jn=n({name:r(),description:a(r()),icon:a(or)}),Mn=n({name:r(),description:a(r()),icon:a(or),properties:a(L(r(),Bn),{})}),ge=n({version:i(1),name:a(r()),description:a(r()),slashCommand:a(r()),icon:a(n({type:i("emoji"),emoji:r()})),dataSources:a(L(r(),Mn),{}),pages:a(L(r(),jn)),capabilities:a(P(rr))});var We=N(r(),me("NotionUserId"));var ce=n({object:i("user"),id:We,name:a(r()),avatar_url:q(r()),type:i("person"),person:n({email:r()})});var Dn=r(),Fe=n({code:Dn,message:r(),isRetryable:g()}),Ue=class extends Error{constructor(t){super(t.message),this.name="CustomBlockInitializationError",this.code=t.code,this.isRetryable=t.isRetryable}code;isRetryable},Xe=v("status",[n({type:i("init"),initializationId:r(),status:i("success"),theme:Pe,contrastMode:Ce,blockId:ye,parent:re,page:xe,manifest:ge,dataSources:n({bindings:he}),currentUser:ce}),n({type:i("init"),initializationId:r(),status:i("error"),error:Fe})]);var nr=n({type:i("contrastModeChanged"),contrastMode:Ce});var ir=n({type:i("pageChanged"),page:xe});var sr=n({type:i("parentChanged"),parent:re});var ar=n({type:i("themeChanged"),theme:Pe});var ur=n({type:i("dataSourcesChanged"),dataSources:n({bindings:he})});var Ke=n({unit:B(["year","month","week","day"]),value:R(),time:r(),defaultTimeZone:a(r())}),wn=n({unit:B(["hour","minute"]),value:R()}),ze=n({unit:i("none")}),ht=d([Ke,wn]),cr=a(d([Ke,ze])),lr=a(d([ht,ze])),Tn=n({type:i("date"),start_date:r(),reminder:cr}),qn=n({type:i("daterange"),start_date:r(),end_date:r(),reminder:cr}),Nn=n({type:i("datetime"),start_date:r(),start_time:r(),time_zone:a(r()),reminder:lr}),An=n({type:i("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:a(r()),reminder:lr}),pr=v("type",[Tn,qn,Nn,An]);var Ze=n({id:r(),table:r()});var mr=d([r(),R(),g(),pr,P(r()),P(Ze)]);var fr=n({id:z,is_archived:g(),in_trash:g(),propertiesById:L(r(),a(mr))});var Un=r(),Fn=B(["gray","lightgray","brown","yellow","orange","green","blue","purple","pink","red"]),gt=d([Fn,r()]),bt=Ge({type:i("icon"),icon:Ge({name:Un,color:a(gt)})});var yr=n({type:i("emoji"),emoji:r()}),dr=n({type:i("custom_emoji"),custom_emoji:n({id:r(),name:a(r()),url:a(r())})}),St=n({type:i("external"),external:n({url:r()})}),kt=n({type:i("file"),file:n({url:r(),expiry_time:a(r())})}),Ee=v("type",[bt,yr,dr,St,kt]),be=v("type",[St,kt]),vr=v("type",[bt,yr,dr,St,kt]);var Q=q(r());var It={start:r(),end:a(Q),time_zone:a(Q),reminder:a(d([ht,ze]))},hr=d([n({...It,start:N(r(),lt("T"))}),n({...It,time_zone:r()}),n({...It,reminder:a(d([Ke,ze]))})]);var gr=d([n({type:i("external"),name:r(),external:n({url:r()})}),n({type:i("file"),name:r(),file:n({url:r(),expiry_time:a(r())})})]);var Oe=q(n({...Ze.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:a(r())}));var br=n({lat:R(),lon:R(),name:a(Q),address:a(Q),aws_place_id:a(Q),google_place_id:a(Q)});var Sr=n({id:r()});var _t=L(r(),Se());var Je=d([n({id:r(),name:a(r()),color:a(r()),description:a(Q)}),n({name:r(),id:a(r()),color:a(r()),description:a(Q)})]);var kr=d([n({object:a(i("user")),id:r()}),n({object:i("group"),id:r(),name:a(Q)})]);var T={id:r()},xt=v("type",[n({...T,type:i("title"),title:P(_t)}),n({...T,type:i("rich_text"),rich_text:P(_t)}),n({...T,type:i("number"),number:q(R())}),n({...T,type:i("url"),url:Q}),n({...T,type:i("email"),email:Q}),n({...T,type:i("phone_number"),phone_number:Q}),n({...T,type:i("checkbox"),checkbox:g()}),n({...T,type:i("select"),select:q(Je)}),n({...T,type:i("status"),status:q(Je)}),n({...T,type:i("multi_select"),multi_select:P(Je)}),n({...T,type:i("date"),date:q(hr)}),n({...T,type:i("people"),people:P(kr)}),n({...T,type:i("relation"),has_more:a(g()),relation:P(Sr)}),n({...T,type:i("files"),files:P(gr)}),n({...T,type:i("place"),place:q(br)}),n({...T,type:i("created_time"),created_time:Q}),n({...T,type:i("last_edited_time"),last_edited_time:Q}),n({...T,type:i("created_by"),created_by:Oe}),n({...T,type:i("last_edited_by"),last_edited_by:Oe}),n({...T,type:i("unique_id"),unique_id:r()}),n({...T,type:i("button"),button:r()}),n({...T,type:i("formula"),formula:r()}),n({...T,type:i("location"),location:r()}),n({...T,type:i("rollup"),rollup:r()}),n({...T,type:i("verification"),verification:r()})]);var Re=L(r(),xt),Ir=L(r(),q(xt));var oe=n({object:i("page"),id:z,parent:re,properties:Ir,created_by:a(Oe,null),last_edited_by:a(Oe,null),created_time:a(q(r()),null),last_edited_time:a(q(r()),null),icon:a(q(Ee),null),cover:a(q(be),null),url:a(q(r()),null),public_url:a(q(r()),null),is_archived:g(),in_trash:g()});var _r=d([m({equals:g()}),m({does_not_equal:g()})]);var le=d([m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var ke=d([r(),P(r())]);var xr=d([m({contains:ke}),m({contains_all:ke}),m({does_not_contain:ke}),le]);var Cr=m({object:i("user"),id:N(r(),fe(1),qe(2e3))}),Pr=d([m({contains:Cr}),m({does_not_contain:Cr}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var Z=B(["start_date","end_date"]),zn=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),He=d([zn,r()]),Er=d([m({target:a(Z),equals:He}),m({target:a(Z),before:He}),m({target:a(Z),after:He}),m({target:a(Z),on_or_before:He}),m({target:a(Z),on_or_after:He}),m({target:a(Z),this_week:m({})}),m({target:a(Z),past_week:m({})}),m({target:a(Z),past_month:m({})}),m({target:a(Z),past_year:m({})}),m({target:a(Z),next_week:m({})}),m({target:a(Z),next_month:m({})}),m({target:a(Z),next_year:m({})}),m({target:a(Z),is_empty:i(!0)}),m({target:a(Z),is_not_empty:i(!0)})]);var Or=d([m({equals:R()}),m({does_not_equal:R()}),m({greater_than:R()}),m({less_than:R()}),m({greater_than_or_equal_to:R()}),m({less_than_or_equal_to:R()}),le]);var Ye=d([m({equals:ke}),m({does_not_equal:ke}),le]);var Rr=m({object:B(["user","group"]),id:N(r(),fe(1))}),Br=d([m({contains:Rr}),m({does_not_contain:Rr}),le]);var jr=N(z,pt(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),mt(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),et=d([m({contains:jr}),m({does_not_contain:jr}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var Mr=B(["To-do","In progress","Complete","Current","Future"]),Dr=d([Mr,N(P(Mr),fe(1),qe(5))]),wr=d([m({group_equals:Dr}),m({group_does_not_equal:Dr})]);var Tr=d([Ye,wr]);var Be=d([m({equals:r()}),m({does_not_equal:r()}),m({contains:r()}),m({does_not_contain:r()}),m({starts_with:r()}),m({ends_with:r()}),le]);var Ct=d([m({propertyId:r(),relation:et}),m({propertyId:r(),created_by:Pr}),m({propertyId:r(),title:Be}),m({propertyId:r(),rich_text:Be}),m({propertyId:r(),url:Be}),m({propertyId:r(),email:Be}),m({propertyId:r(),phone_number:Be}),m({propertyId:r(),number:Or}),m({propertyId:r(),checkbox:_r}),m({propertyId:r(),select:Ye}),m({propertyId:r(),multi_select:xr}),m({propertyId:r(),status:Tr}),m({propertyId:r(),date:Er}),m({propertyId:r(),people:Br})]);var qr=d([Ct,m({and:P(Ct)})]);var Nr=B(["ascending","descending"]);var Pt=10,Ar=m({propertyId:r(),direction:Nr});var Ur=n({type:i("queryDataSource"),subscriptionId:r(),dataSourceId:K,limit:R(),filter:a(qr),sorts:a(P(Ar))}),Hn=r(),Fr=n({code:Hn,message:r(),isRetryable:g()}),zr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:P(oe),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:Fr})]),Hr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:P(d([oe,fr])),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:Fr})]);var Ln=r(),Vn=n({code:Ln,message:r(),isRetryable:g()}),Lr=n({type:i("openExternalUrl"),requestId:r(),url:r()}),Vr=v("status",[n({type:i("openExternalUrlResult"),requestId:r(),status:i("success")}),n({type:i("openExternalUrlResult"),requestId:r(),status:i("error"),error:Vn})]);var je=n({object:i("page"),id:z,parent:re,properties:Re,created_time:a(r()),last_edited_time:a(r()),icon:a(Ee),cover:a(be),url:a(r()),public_url:a(r()),is_archived:g(),in_trash:g()});var Gn=r(),$r=n({code:Gn,message:r(),isRetryable:g()}),Qr=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:$r})]),Wr=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:$r})]),$n=v("type",[n({type:i("start")}),n({type:i("end")}),n({type:i("before"),blockId:ye}),n({type:i("after"),blockId:ye})]),yu=v("type",[$e,Qe]),Gr={type:i("createPage"),requestId:r(),properties:Re,icon:a(vr),cover:a(be)},Xr=v("type",[n({...Gr,parent:$e,position:a($n)}),n({...Gr,parent:Qe,position:a(dt())})]);var Qn=r(),Kr=n({code:Qn,message:r(),isRetryable:g()}),Zr=n({type:i("getPage"),requestId:r(),pageId:z,dataSourceId:a(K)}),Jr=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Kr})]),Yr=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Kr})]);var Wn=B(["side_peek","center_peek"]),Xn=r(),Kn=n({code:Xn,message:r(),isRetryable:g()}),eo=n({type:i("openPage"),requestId:r(),pageId:z,mode:Wn}),to=v("status",[n({type:i("openPageResult"),requestId:r(),status:i("success"),pageId:z}),n({type:i("openPageResult"),requestId:r(),status:i("error"),error:Kn})]);var Zn=r(),ro=n({code:Zn,message:r(),isRetryable:g()}),oo=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:ro})]),no=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:ro})]),io=n({type:i("updatePage"),requestId:r(),pageId:z,dataSourceId:a(K),properties:a(Re),icon:a(Ee),cover:a(be),archived:a(g())});var so=n({type:i("currentUserChanged"),currentUser:ce});var Jn=r(),Yn=n({code:Jn,message:r(),isRetryable:g()}),ao=n({type:i("getUser"),requestId:r(),userId:We}),uo=v("status",[n({type:i("getUserResult"),requestId:r(),status:i("success"),user:ce}),n({type:i("getUserResult"),requestId:r(),status:i("error"),error:Yn})]);var co=n({object:i("list"),results:P(ce),next_cursor:q(r()),has_more:g(),type:i("user"),user:L(r(),Se())});var ei=r(),ti=n({code:ei,message:r(),isRetryable:g()}),lo=n({type:i("listUsers"),requestId:r(),startCursor:a(r()),pageSize:a(R())}),po=v("status",[n({type:i("listUsersResult"),requestId:r(),status:i("success"),list:co}),n({type:i("listUsersResult"),requestId:r(),status:i("error"),error:ti})]);var mo=n({type:i("invalidSandboxMessage"),requestId:a(r()),reason:r()});var fo=v("type",[Xe,ar,nr,sr,ir,so,ur,uo,po,to,Vr,mo]),yo=v("type",[...fo.options,zr,Jr,Qr,oo]),ec=v("type",[...fo.options,Hr,Yr,Wr,no]);function vo(e){return{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([t,o])=>[t,{...o,collectionSchema:{...o.collectionSchema,propertiesById:{...o.collectionSchema?.propertiesById,...Zt}}}]))}}}function Y(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function tt(e){return{...e,properties:Object.fromEntries(Object.entries(e.properties).map(([t,o])=>{switch(o?.type){case"unique_id":case"button":case"formula":case"location":case"rollup":case"verification":return[t,null];case"title":case"rich_text":case"number":case"url":case"email":case"phone_number":case"checkbox":case"select":case"status":case"multi_select":case"date":case"people":case"relation":case"files":case"place":case"created_time":case"last_edited_time":case"created_by":case"last_edited_by":case void 0:return[t,o];default:return Y(o)}}))}}function Me(e){if(e?.type!=="icon")return e;let{name:t,color:o}=e.icon;return{type:"external",external:{url:`https://www.notion.so/icons/${t}_${o??"gray"}.svg`}}}function ho(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:Me(e.icon)??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function De(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}var Ie=class extends Error{};function Et(e){try{return ri(e)}catch(t){throw t instanceof RangeError?new Ie(t.message):t}}function ri(e){let{start:t,end:o,time_zone:s,reminder:c}=e;if(!t.split("T")[0])throw new Ie("Date values must include a date.");let l=t.includes("T")||s!=null,p=t.match(/([+-])(\d{2}):(\d{2})$/),h=p?(Number(p[2])*60+Number(p[3]))*(p[1]==="-"?-1:1):0,y=s?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=y?(Number(y[2]??0)*60+Number(y[3]??0))*(y[1]==="-"?-1:1):h,k=b=>{if(!b.split("T")[0])throw new Ie("Date values must include a date.");if(!b.includes("T"))return{date:b,time:"00:00"};let A=b.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(A)return{date:A[1],time:A[2]};if(!s||y){let U=new Date(new Date(b).getTime()+x*6e4).toISOString();return{date:U.slice(0,10),time:U.slice(11,16)}}let j=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(b)),H=U=>j.find(ee=>ee.type===U)?.value;return{date:`${H("year")}-${H("month")}-${H("day")}`,time:`${H("hour")}:${H("minute")}`}},D=k(t),W=o?k(o):void 0;if(!l){if(c&&!("time"in c)&&c.unit!=="none")throw new Ie("Hour and minute reminders require a date with a time.");return W?{type:"daterange",start_date:D.date,end_date:W.date,reminder:c}:{type:"date",start_date:D.date,reminder:c}}let V=s??(h===0?"UTC":`UTC${h<0?"-":"+"}${Math.floor(Math.abs(h)/60)}${Math.abs(h)%60===0?"":`:${String(Math.abs(h)%60).padStart(2,"0")}`}`);return W?{type:"datetimerange",start_date:D.date,start_time:D.time,end_date:W.date,end_time:W.time,time_zone:V,reminder:c}:{type:"datetime",start_date:D.date,start_time:D.time,time_zone:V,reminder:c}}function bo(e){switch(e.type){case"title":return go(e.title);case"rich_text":return go(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?Et(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return De(e.created_time);case"last_edited_time":return De(e.last_edited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return Y(e)}}function go(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let o=t.text;return o&&typeof o=="object"&&"content"in o&&typeof o.content=="string"?o.content:""}).join("")}function So(e){let t={};for(let o of Object.values(e.properties))o&&(t[o.id]=bo(o));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:{...t,created_time:De(e.created_time),last_edited_time:De(e.last_edited_time),created_by:e.created_by?[e.created_by]:void 0,last_edited_by:e.last_edited_by?[e.last_edited_by]:void 0}}}function ko(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(So)}:{...e,page:ho(tt(e.page))}}function _o(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(Io)}:{...e,page:Io(e.page)}}function Io(e){return{...tt(e),icon:Me(e.icon)}}function Co(e){if(e.type==="queryDataSourceResult")return e.items.some(o=>o.icon?.type==="icon")?{...e,items:e.items.map(xo)}:e;let t=xo(e.page);return t===e.page?e:{...e,page:t}}function xo(e){let t=Me(e.icon);return t===e.icon?e:{...e,icon:t}}function Po(e,t){return e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged"?t<5?vo(e):e:e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"||e.status==="error"?e:t<6?ko(e):t<7?_o(e):t<9?Co(e):e}var Ot=n({theme:Pe,contrastMode:a(Ce),blockId:ye,parent:re,page:xe,manifest:ge,dataSources:n({bindings:he}),currentUser:ce}),Eo=v("status",[n({status:i("success"),initialState:Lt(Ot,["manifest"])}),n({status:i("error"),error:Fe})]);var rt=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let o={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:o,isRefreshing:!0,shouldRefreshAgain:!1}),o}isCurrent(t,o){return this.bySubscriptionId.get(t)?.token===o}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let o=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,o.push({message:c.message,token:c.token})}return s?o:void 0}finish(t,o){let s=this.bySubscriptionId.get(t);if(s?.token===o&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function Oo(e,t){if(e===void 0)return;let o="and"in e?e.and:[e];for(let s of o){let c=si(s,t);if(c!==void 0)return c}}function si(e,t){if(!Object.hasOwn(t.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 o=t.propertiesById[e.propertyId],s=Object.keys(e).find(h=>h!=="propertyId");if(s!==o.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${o.type}".`,isRetryable:!1};if("status"in e&&o.type==="status"){let h=e.status;if("group_equals"in h||"group_does_not_equal"in h){let y="group_equals"in h?h.group_equals:h.group_does_not_equal,k=(Array.isArray(y)?y:[y]).find(D=>!o.groups.some(W=>W.name===D));return k===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${k}".`,isRetryable:!1}}}if("relation"in e&&!Ht(et,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=ai(e);if(c===void 0||o.type!==c.propertyType)return;let l=new Set(o.options.map(h=>h.name)),p=ui(c.operator).find(h=>!l.has(h));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function ai(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 t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function ui(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:Y(e);return Array.isArray(t)?t:[t]}var ci=new Set(Xt);function Ro(e,t){if(e===void 0)return;if(e.length>Pt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Pt} entries.`,isRetryable:!1};let o=new Set;for(let s of e){if(o.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(o.add(s.propertyId),!Object.hasOwn(t.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=t.propertiesById[s.propertyId];if(!ci.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}}}function Bo(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Rt(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function jo(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Mo(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function ot(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function Bt(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:o}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${o}.`,isRetryable:!1}}function jt(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var li=5e3,pi=5e3,mi=5e3;function Do(e){let{manifestSource:t,prepareInit:o,sendInitMessage:s,warn:c,flushPendingHostStateChanges:l,minBridgeProtocolVersion:p,noConnectTimeoutMs:h=li,initialStateTimeoutMs:y=pi,noInitResultTimeoutMs:x=mi,stopHostWithFailure:k,onInitResult:D,onInitSent:W,onConnectionFailure:V}=e,b="waitingForConnect",A,j,H,U,ee=!1,de=!1;function te(){A!==void 0&&(window.clearTimeout(A),A=void 0)}function F(){j!==void 0&&(window.clearTimeout(j),j=void 0)}function G(){H!==void 0&&(window.clearTimeout(H),H=void 0)}function X(I){let{initializationId:E,error:_,phase:ae,source:it}=I;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"failed":case"stopped":return;default:return Y(b)}b="failed",U=E,te(),F(),s({type:"init",initializationId:E,status:"error",error:_}),V({..._,phase:ae,source:it})}async function se(I){if(b==="waitingForConnect"){b="preparingInit",U=I.initializationId,te(),j=window.setTimeout(()=>{if(b!=="preparingInit")return;let E=Bo();c({...E,initializationId:I.initializationId}),X({initializationId:I.initializationId,error:E,phase:"init",source:"host"})},y);try{let E=await o(I);if(b!=="preparingInit")return;if(F(),E.status==="error"){X({initializationId:I.initializationId,error:E.error,phase:"init",source:"host"});return}b="waitingForInitResult";let _={type:"init",initializationId:I.initializationId,status:"success",theme:E.initialState.theme,contrastMode:E.initialState.contrastMode??tr,blockId:E.initialState.blockId,parent:E.initialState.parent,page:E.initialState.page,currentUser:E.initialState.currentUser,manifest:E.initialState.manifest,dataSources:E.initialState.dataSources};if(s(_),b!=="waitingForInitResult"||(W(),b!=="waitingForInitResult"))return;H=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="failed";let ae=Mo();V({...ae,phase:"initResult",source:"host"}),c({...ae,initializationId:I.initializationId})},x)}catch(E){if(b!=="preparingInit")return;c({message:"Failed to prepare custom block initialization",error:E}),X({initializationId:I.initializationId,error:ot(),phase:"init",source:"host"})}}}function J(I){if(b!=="stopped"&&b==="waitingForConnect"){if(!jt(I.bridgeProtocolVersion)){let E=Rt({currentBridgeProtocolVersion:I.bridgeProtocolVersion});X({initializationId:I.initializationId,error:E,phase:"connect",source:"host"});return}if(I.bridgeProtocolVersion<p){let E=Bt({currentBridgeProtocolVersion:I.bridgeProtocolVersion,minBridgeProtocolVersion:p});X({initializationId:I.initializationId,error:E,phase:"connect",source:"host"});return}if(I.status==="error"&&(t==="sandbox"||I.error.code!=="manifest_invalid")){X({initializationId:I.initializationId,error:I.error,phase:"connect",source:"sandbox"});return}de=!0,se(I)}}function C(I){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:E,bridgeProtocolVersion:_}=I;if(E===void 0)return"nack";let ae=I.error;return _!==void 0&&(jt(_)?_<p&&(ae=Bt({currentBridgeProtocolVersion:_,minBridgeProtocolVersion:p})):ae=Rt({currentBridgeProtocolVersion:_})),X({initializationId:E,error:ae,phase:"connect",source:"host"}),"handled"}function ne(I){let{initializationId:E,error:_}=I;b!=="waitingForInitResult"||E===void 0||E!==U||(te(),G(),b="failed",c(_),V({..._,phase:"initResult",source:"host"}))}function Le(){if(b!=="stopped"){if(ee){k({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}ee=!0,te(),b==="waitingForConnect"&&(A=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="failed";let I=jo();c(I),V({...I,phase:"connect",source:"host"})},h))}}function we(I){if(b!=="waitingForInitResult"||I.initializationId!==U){c({message:"Ignored stale or unexpected initResult",payload:I});return}G(),b=I.status==="success"?"initialized":"failed",I.status==="success"?l():V({...I.error,phase:"initResult",source:"sandbox"}),D(I)}function ve(){b="stopped",te(),F(),G()}return{get status(){return b},get hasConnectedSandbox(){return de},handleConnect:J,handleInitResult:we,handleInvalidConnect:C,handleInvalidInitResult:ne,onIframeLoad:Le,stop:ve}}function Mt(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Dt(){return{code:"invalid_local_preview_url",message:"Local custom blocks require an HTTP(S) URL on localhost, a .localhost subdomain, or 127.0.0.1, without credentials and on a different origin from the host.",isRetryable:!1}}function wo(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function To(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function qo(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function No(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===""}function nt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&No(e)}async function Ao(e){return e.manifestSource==="host"?e.hostManifest:e.connectManifest!==void 0?{status:"success",manifest:e.connectManifest}:{status:"error",error:{code:"manifest_unavailable",message:"The sandbox did not provide a manifest in connect.",isRetryable:!1}}}var Uo=v("status",[n({status:i("success"),manifest:ge}),n({status:i("error"),error:Fe})]);function Fo(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var zo=n({type:i("resize"),height:N(R(),Te(),Ne(0))});var Ho=n({type:i("unsubscribeDataSourceQuery"),subscriptionId:r()});var Lo=n({code:r(),message:r(),isRetryable:g()});var Vo={type:i("connect"),initializationId:r(),bridgeProtocolVersion:R(),sdkVersion:r()},Go=v("status",[n({status:i("success"),manifest:a(ge),...Vo}),n({status:i("error"),error:Lo,...Vo})]);var fi=r(),yi=n({code:fi,message:r(),isRetryable:g()}),$o=v("status",[n({type:i("initResult"),initializationId:r(),status:i("success"),initialHeight:a(N(R(),Te(),Ne(0)))}),n({type:i("initResult"),initializationId:r(),status:i("error"),error:yi})]);var Qo=n({type:i("invalidHostMessage"),requestId:a(r()),reason:r()});var Wo=v("type",[Go,$o,Ur,Ho,Xr,Zr,ao,lo,eo,Lr,io,zo,Qo]);function Xo(e){return ie(Wo,e)}function Ko(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Zo(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Jo(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}var di=n({requestId:r()});function Yo(e){let t=ie(di,e);return t.success?t.output.requestId:void 0}function en(e){let t=Jo(e);if(t==="invalidHostMessage"||t==="invalidSandboxMessage")return{incomingType:t};let o=Yo(e);return{incomingType:t,nack:{type:"invalidSandboxMessage",...o!==void 0?{requestId:o}:{},reason:vi(t)}}}function vi(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var hi=n({type:B(["updatePage","createPage"]),requestId:r(),icon:n({type:i("icon"),icon:n({color:Se()})})});function tn(e){let t=ie(hi,e);if(!t.success)return;let o=t.output.icon.icon.color;if(!(o===void 0||ie(gt,o).success))return{type:t.output.type==="createPage"?"createPageResult":"updatePageResult",requestId:t.output.requestId,status:"error",error:{code:"invalid_icon_color",message:"Use a supported Notion icon color.",isRetryable:!1}}}var rn=n({initializationId:r()}),gi=n({bridgeProtocolVersion:d([R(),yt()])});function on(e){let{iframe:t,sandboxOrigin:o,getInitStatus:s,emit:c,sendNack:l,sendPageMutationError:p,onInvalidConnect:h,onInvalidInitResult:y,onConnect:x,onInitResult:k,onQueryDataSource:D,onUnsubscribeDataSourceQuery:W,onCreatePage:V,onGetPage:b,onOpenPage:A,onOpenExternalUrl:j,onGetUser:H,onListUsers:U,onUpdatePage:ee,onResize:de}=e;function te(F,G){let X=tn(F);if(X!==void 0&&s()==="initialized"){p(X);return}c("warn",{message:"Ignored unsupported sandbox message",payload:wt(F),issues:G});let se=en(F);if(se.incomingType==="connect"){let J=ie(rn,F),C=ie(gi,F);if(h({initializationId:J.success?J.output.initializationId:void 0,error:Ko(),bridgeProtocolVersion:C.success?C.output.bridgeProtocolVersion:void 0})==="handled")return}if(se.incomingType==="initResult"){let J=ie(rn,F);y({initializationId:J.success?J.output.initializationId:void 0,error:Zo()})}se.nack!==void 0&&s()!=="stopped"&&l(se.nack)}return function(G){let X=G.source===t.contentWindow,se=G.origin===o;if(!X||!se)return;let J=Xo(G.data);if(!J.success){te(G.data,J.issues);return}let C=J.output;if(!Fo(C)&&s()!=="initialized"){c("warn",{message:`Ignored ${C.type} before initialization completed`,payload:wt(C)});return}switch(c("in",wt(C)),C.type){case"connect":x(C);return;case"initResult":k(C);return;case"queryDataSource":D(C);return;case"unsubscribeDataSourceQuery":W(C);return;case"createPage":V(C);return;case"openPage":A(C);return;case"openExternalUrl":j(C);return;case"getPage":b(C);return;case"getUser":H(C);return;case"listUsers":U(C);return;case"updatePage":ee(C);return;case"resize":de(C);return;case"invalidHostMessage":return;default:Y(C)}}}function wt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}function nn(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}var an=5;function Si(e){let{iframe:t,prepareInitialState:o,handlers:s,onStatusChange:c,onLog:l,onQueryUnsubscribed:p,minBridgeProtocolVersion:h,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k}=e,D=ki(e.sandboxUrl,e.manifestSource),W=D.origin,V=Math.max(h??3,3),b=new AbortController,A,j={},H=!1,U=new AbortController,ee,de,te=10,F=new rt(u=>{p?.(u)});function G(u,S){l?.(u,S)}function X(u){let S=_.status;switch(S){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"failed":break;case"stopped":return;default:return Y(S)}let O=Po(u,te);G("out",O),t.contentWindow?.postMessage(O,W)}function se(u){X(ue(Xe,u))}function J(u){X(u)}function C(u){let S=_.status;switch(S){case"initialized":X(ue(yo,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"failed":case"stopped":return;default:Y(S)}}async function ne(u,S){try{let O=S===void 0?_i(u.type):await S(u);C({...O,type:`${u.type}Result`,requestId:u.requestId})}catch(O){if(_.status!=="initialized")return;G("warn",O),C({type:`${u.type}Result`,requestId:u.requestId,status:"error",error:{code:"unknown_error",message:`The host could not complete ${u.type}.`,isRetryable:!1}})}}function Le(u){let S=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};C(S)}async function we(u,S=F.subscribe(u)){try{let O=Ii(de,u.dataSourceId),pe=xi(u,O);if(pe!==void 0){F.isCurrent(u.subscriptionId,S)&&(F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:{status:"error",error:pe}}));return}let at=await s.queryDataSource(u);if(!F.isCurrent(u.subscriptionId,S))return;at.status==="error"&&!at.error.isRetryable&&F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:at})}finally{let O=F.finish(u.subscriptionId,S);O!==void 0&&we(O.message,O.token)}}function ve(u){_.status==="stopped"||_.status==="failed"||(Object.assign(j,u),E())}async function I(u){if(b.signal.aborted)return;let S=s.openExternalUrl;if(S===void 0){await ne(u,void 0);return}if(A===u.requestId)return;if(A!==void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};C(pe);return}let O=nn(u.url);if(O===void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};C(pe);return}A=u.requestId;try{await ne(u,()=>S({...u,url:O},{signal:b.signal}))}finally{A===u.requestId&&(A=void 0)}}function E(){if(_.status!=="initialized")return;let u=j;j={},u.theme!==void 0&&C({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&C({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&C({type:"parentChanged",parent:u.parent}),u.page!==void 0&&C({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&C({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&C({type:"currentUserChanged",currentUser:u.currentUser})}let _=Do({manifestSource:e.manifestSource,async prepareInit(u){let S=u.status==="success"?u.manifest:void 0;te=u.bridgeProtocolVersion,c({status:"preparingInit",localManifest:nt({url:D,hostOrigin:window.location.origin})?S:void 0,bridgeProtocolVersion:u.bridgeProtocolVersion,sdkVersion:u.sdkVersion});let O=await(ln??qt(S));return _.status!=="preparingInit"?O:ae(O)},sendInitMessage:se,onInitSent:()=>c({status:"waitingForInitResult"}),warn:u=>G("warn",u),flushPendingHostStateChanges:E,minBridgeProtocolVersion:V,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k,stopHostWithFailure:At,onInitResult(u){u.status==="success"&&ee!==void 0&&c({status:"initialized",resolvedManifest:ee,initialHeight:u.initialHeight})},onConnectionFailure:u=>{U.abort(),c({status:"failed",error:u})}});function ae(u){if(u.status==="error")return u;let S=ue(Ot,{...u.initialState,...j});if(ee=S.manifest,j={},te<an&&S.page.type==="unavailable")return{status:"error",error:Mt()};let O=un(S.manifest,S.dataSources);return O!==void 0?{status:"error",error:O}:(de=S.dataSources,H=!0,{status:"success",initialState:S})}let it=pn().catch(Tt),ln=e.manifestSource==="host"?qt(void 0).catch(Tt):void 0;async function pn(){U.signal.throwIfAborted();let u=await e.getPersistedManifest({signal:U.signal});return U.signal.throwIfAborted(),ue(Uo,u)}function Tt(u){return U.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:u}),{status:"error",error:ot()}}async function qt(u){U.signal.throwIfAborted();let S=await Ao({manifestSource:e.manifestSource,hostManifest:it,connectManifest:u});if(U.signal.throwIfAborted(),S.status==="error")return S;let O=ue(Eo,await o({manifest:S.manifest,signal:U.signal}));return O.status==="error"?O:{status:"success",initialState:{...O.initialState,manifest:S.manifest}}}let Nt=on({iframe:t,sandboxOrigin:W,getInitStatus:()=>_.status,emit:G,sendNack:J,sendPageMutationError:X,onInvalidConnect:_.handleInvalidConnect,onInvalidInitResult:_.handleInvalidInitResult,onConnect:_.handleConnect,onInitResult:_.handleInitResult,onQueryDataSource:we,onUnsubscribeDataSourceQuery:u=>F.unsubscribe(u.subscriptionId),onOpenExternalUrl:I,onCreatePage:u=>ne(u,s.createPage),onGetPage:u=>ne(u,s.getPage),onOpenPage:u=>ne(u,s.openPage),onGetUser:u=>ne(u,s.getUser),onListUsers:u=>ne(u,s.listUsers),onUpdatePage:u=>ne(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",Nt),t.addEventListener("load",_.onIframeLoad);function st(){b.abort(),U.abort(),window.removeEventListener("message",Nt),t.removeEventListener("load",_.onIframeLoad),_.stop(),F.unsubscribeAll()}function mn(){let u=_.status;st(),u!=="stopped"&&u!=="failed"&&c({status:"stopped"})}function At(u){if(_.status!=="stopped"){if(_.status==="failed"){st();return}st(),G("warn",u),c({status:"failed",error:u})}}return c({status:"waitingForConnect"}),{stop:mn,setTheme(u){ve({theme:u})},setContrastMode(u){ve({contrastMode:u})},setParent(u){ve({parent:u})},setPage(u){if(u.type==="unavailable"&&te<an&&(_.status==="preparingInit"&&H||_.status==="waitingForInitResult"||_.status==="initialized")){At({...Mt(),phase:"runtime",source:"host"});return}ve({page:u})},setCurrentUser(u){ve({currentUser:u})},setDataSources(u){let S={bindings:ue(he,u.bindings)},O=_.hasConnectedSandbox&&ee!==void 0?un(ee,S):void 0;return O!==void 0?(G("warn",{message:"Ignored invalid data source bindings update",payload:S}),{status:"error",error:O}):(de=S,ve({dataSources:S}),{status:"success"})},refreshQuery({dataSourceId:u}){if(_.status!=="initialized")return;let S=ue(K,u),O=F.refresh(S);if(O===void 0){G("warn",`No active query exists for data source "${u}"`);return}for(let pe of O)we(pe.message,pe.token)}}}function ki(e,t){let o;try{o=new URL(e)}catch(s){throw t==="host"?s:new Ue(Dt())}if(t==="sandbox"&&!nt({url:o,hostOrigin:window.location.origin}))throw new Ue(Dt());return o}function Ii(e,t){return Object.values(e?.bindings??{}).find(o=>o.collectionPointer?.id===t)?.collectionSchema}function un(e,t){for(let[o,s]of Object.entries(e.dataSources)){let c=t.bindings[o];if(c?.inaccessible===!0)continue;let l=er({manifestDataSource:s,collectionSchema:c?.collectionSchema,propertyIdsByKey:c?.propertyIdsByKey});if(c?.collectionPointer===void 0||l.status==="missing_schema")return To();for(let p of l.properties){if(p.status==="missing")return qo();if(p.status!=="mapped")return wo()}}}function _i(e){return{status:"error",error:{code:"unsupported_operation",message:`The host does not support ${e}.`,isRetryable:!1}}}function xi(e,t){return t===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}:Oo(e.filter,t)??Ro(e.sorts,t)}function Ci(e){let{manifestProperties:t,propertySchemasById:o}=e,s=[];for(let[c,l]of Object.entries(t)){let p=Pi({propertyKey:c,manifestProperty:l,propertySchemasById:o});p!==void 0&&s.push([c,p])}return Object.fromEntries(s)}function Pi(e){let{propertyKey:t,manifestProperty:o,propertySchemasById:s}=e,c=cn(o.name),l=Object.entries(s).filter(([p,h])=>h.type===o.type&&(p===t||cn(h.name)===c));return l.length===1?l[0][0]:void 0}function cn(e){return e.trim().toLowerCase()}function Ei(e){return ue(z,e)}export{Ie as InvalidNotionDateError,Si as createCustomBlockHost,Ci as getAutoBoundPropertyIdsByKey,nt as isAllowedLocalPreviewUrl,Et as toNotionDateValue,Ei as toNotionPageId};
|
|
1
|
+
var Ve,yn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function ut(e){return!e&&!Ve?yn:{lang:e?.lang??Ve?.lang,message:e?.message,abortEarly:e?.abortEarly??Ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Ve?.abortPipeEarly}}var dn;function vn(e){return dn?.get(e)}var hn;function gn(e){return hn?.get(e)}var bn;function Sn(e,t){return bn?.get(e)?.get(t)}function _e(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function M(e,t,o,s,c){let l=c&&"input"in c?c.input:o.value,p=c?.expected??e.expects??null,h=c?.received??_e(l),y={kind:e.kind,type:e.type,input:l,expected:p,received:h,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${h}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},x=e.kind==="schema",k=c?.message??e.message??Sn(e.reference,y.lang)??(x?gn(y.lang):null)??s.message??vn(y.lang);k!==void 0&&(y.message=typeof k=="function"?k(y):k),x&&(o.typed=!1),o.issues?o.issues.push(y):o.issues=[y]}function kn(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Ft(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function ct(e,t){let o=[...new Set(e)];return o.length>1?`(${o.join(` ${t} `)})`:o[0]??"never"}function $(e){return e["~standard"]={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},ut())},e}var In=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function me(e){return{kind:"transformation",type:"brand",reference:me,async:!1,name:e,"~run"(t){return t}}}function Te(e){return{kind:"validation",type:"finite",reference:Te,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,o){return t.typed&&!this.requirement(t.value)&&M(this,"finite",t,o),t}}}function lt(e,t){let o=_e(e);return{kind:"validation",type:"includes",reference:lt,async:!1,expects:o,requirement:e,message:t,"~run"(s,c){return s.typed&&!s.value.includes(this.requirement)&&M(this,"content",s,c,{received:`!${o}`}),s}}}function qe(e,t){return{kind:"validation",type:"max_length",reference:qe,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length>this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function fe(e,t){return{kind:"validation",type:"min_length",reference:fe,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length<this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function Ae(e,t){return{kind:"validation",type:"min_value",reference:Ae,async:!1,expects:`>=${e instanceof Date?e.toJSON():_e(e)}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!(o.value>=this.requirement)&&M(this,"value",o,s,{received:o.value instanceof Date?o.value.toJSON():_e(o.value)}),o}}}function pt(e,t){return{kind:"validation",type:"regex",reference:pt,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!this.requirement.test(o.value)&&M(this,"format",o,s),o}}}function mt(e){return{kind:"transformation",type:"transform",reference:mt,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var zt={abortEarly:!0};function ft(e,t,o){return typeof e.fallback=="function"?e.fallback(t,o):e.fallback}function Ne(e,t,o){return typeof e.default=="function"?e.default(t,o):e.default}function Ht(e,t){return!e["~run"]({value:t},zt).issues}function P(e,t){return $({kind:"schema",type:"array",reference:P,expects:"Array",async:!1,item:e,message:t,"~run"(o,s){let c=o.value;if(Array.isArray(c)){o.typed=!0,o.value=[];for(let l=0;l<c.length;l++){let p=c[l],h=this.item["~run"]({value:p},s);if(h.issues){let y={type:"array",origin:"value",input:c,key:l,value:p};for(let x of h.issues)x.path?x.path.unshift(y):x.path=[y],o.issues?.push(x);if(o.issues||(o.issues=h.issues),s.abortEarly){o.typed=!1;break}}h.typed||(o.typed=!1),o.value.push(h.value)}}else M(this,"type",o,s);return o}})}function g(e){return $({kind:"schema",type:"boolean",reference:g,expects:"boolean",async:!1,message:e,"~run"(t,o){return typeof t.value=="boolean"?t.typed=!0:M(this,"type",t,o),t}})}function i(e,t){return $({kind:"schema",type:"literal",reference:i,expects:_e(e),async:!1,literal:e,message:t,"~run"(o,s){return kn(o.value,this.literal)?o.typed=!0:M(this,"type",o,s),o}})}function Ge(e,t){return $({kind:"schema",type:"loose_object",reference:Ge,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ne(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly)for(let l in c)Ft(c,l)&&!Object.prototype.hasOwnProperty.call(this.entries,l)&&(o.value[l]=c[l])}else M(this,"type",o,s);return o}})}function yt(e){return $({kind:"schema",type:"nan",reference:yt,expects:"NaN",async:!1,message:e,"~run"(t,o){return Number.isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function dt(e){return $({kind:"schema",type:"never",reference:dt,expects:"never",async:!1,message:e,"~run"(t,o){return M(this,"type",t,o),t}})}function q(e,t){return $({kind:"schema",type:"nullable",reference:q,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===null&&(this.default!==void 0&&(o.value=Ne(this,o,s)),o.value===null)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function R(e){return $({kind:"schema",type:"number",reference:R,expects:"number",async:!1,message:e,"~run"(t,o){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function n(e,t){return $({kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ne(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",o,s);return o}})}function a(e,t){return $({kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===void 0&&(this.default!==void 0&&(o.value=Ne(this,o,s)),o.value===void 0)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function B(e,t){return $({kind:"schema",type:"picklist",reference:B,expects:ct(e.map(_e),"|"),async:!1,options:e,message:t,"~run"(o,s){return this.options.includes(o.value)?o.typed=!0:M(this,"type",o,s),o}})}function L(e,t,o){return $({kind:"schema",type:"record",reference:L,expects:"Object",async:!1,key:e,value:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let p in l)if(Ft(l,p)){let h=l[p],y=this.key["~run"]({value:p},c);if(y.issues){let k={type:"object",origin:"key",input:l,key:p,value:h};for(let D of y.issues)D.path=[k],s.issues?.push(D);if(s.issues||(s.issues=y.issues),c.abortEarly){s.typed=!1;break}}let x=this.value["~run"]({value:h},c);if(x.issues){let k={type:"object",origin:"value",input:l,key:p,value:h};for(let D of x.issues)D.path?D.path.unshift(k):D.path=[k],s.issues?.push(D);if(s.issues||(s.issues=x.issues),c.abortEarly){s.typed=!1;break}}(!y.typed||!x.typed)&&(s.typed=!1),y.typed&&(s.value[y.value]=x.value)}}else M(this,"type",s,c);return s}})}function m(e,t){return $({kind:"schema",type:"strict_object",reference:m,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ne(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly){for(let l in c)if(!Object.prototype.hasOwnProperty.call(this.entries,l)){M(this,"key",o,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",o,s);return o}})}function r(e){return $({kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,"~run"(t,o){return typeof t.value=="string"?t.typed=!0:M(this,"type",t,o),t}})}function Ut(e){let t;if(e)for(let o of e)if(t)for(let s of o.issues)t.push(s);else t=o.issues;return t}function d(e,t){return $({kind:"schema",type:"union",reference:d,expects:ct(e.map(o=>o.expects),"|"),async:!1,options:e,message:t,"~run"(o,s){let c,l,p;for(let h of this.options){let y=h["~run"]({value:o.value},s);if(y.typed)if(y.issues)l?l.push(y):l=[y];else{c=y;break}else p?p.push(y):p=[y]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",o,s,{issues:Ut(l)}),o.typed=!0}else{if(p?.length===1)return p[0];M(this,"type",o,s,{issues:Ut(p)})}return o}})}function Se(){return $({kind:"schema",type:"unknown",reference:Se,expects:"unknown",async:!1,"~run"(e){return e.typed=!0,e}})}function v(e,t,o){return $({kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let p,h=0,y=this.key,x=[],k=(D,W)=>{for(let V of D.options){if(V.type==="variant")k(V,new Set(W).add(V.key));else{let b=!0,N=0;for(let j of W){let H=V.entries[j];if(j in l?H["~run"]({typed:!1,value:l[j]},zt).issues:H.type!=="exact_optional"&&H.type!=="optional"&&H.type!=="nullish"){b=!1,y!==j&&(h<N||h===N&&j in l&&!(y in l))&&(h=N,y=j,x=[]),y===j&&x.push(V.entries[j].expects);break}N++}if(b){let j=V["~run"]({value:l},c);(!p||!p.typed&&j.typed)&&(p=j)}}if(p&&!p.issues)break}};if(k(this,new Set([this.key])),p)return p;M(this,"type",s,c,{input:l[y],expected:ct(x,"|"),path:[{type:"object",origin:"value",input:l,key:y,value:l[y]}]})}else M(this,"type",s,c);return s}})}function Lt(e,t){let o={...e.entries};for(let s of t)delete o[s];return $({...e,entries:o})}function ue(e,t,o){let s=e["~run"]({value:t},ut(o));if(s.issues)throw new In(s.issues);return s.value}function A(...e){return $({...e[0],pipe:e,"~run"(t,o){for(let s of e)if(s.kind!=="metadata"){if(t.issues&&(s.kind==="schema"||s.kind==="transformation")){t.typed=!1;break}(!t.issues||!o.abortEarly&&!o.abortPipeEarly)&&(t=s["~run"](t,o))}return t}})}function ie(e,t,o){let s=e["~run"]({value:t},ut(o));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var ye=A(r(),me("NotionBlockId")),K=A(r(),me("NotionDataSourceId")),z=A(r(),me("NotionPageId")),Vt=A(r(),me("NotionAgentId")),Gt=A(r(),me("NotionSpaceId"));var $t=n({id:K,table:r(),spaceId:a(Gt)});var Qt=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"]),vt=n({id:r(),name:r(),color:a(Qt),description:a(r())}),_n=n({id:r(),name:r(),color:a(Qt),option_ids:P(r())}),xn=n({synced_property_id:r(),synced_property_name:r()}),w=n({name:r(),description:a(r())}),Cn=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","location","created_time","last_edited_time","created_by","last_edited_by"],Wt=B(Cn),Xt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Kt=v("type",[n({...w.entries,type:i("title")}),n({...w.entries,type:i("rich_text")}),n({...w.entries,type:i("number")}),n({...w.entries,type:i("checkbox")}),n({...w.entries,type:i("url")}),n({...w.entries,type:i("email")}),n({...w.entries,type:i("phone_number")}),n({...w.entries,type:i("select"),options:P(vt)}),n({...w.entries,type:i("multi_select"),options:P(vt)}),n({...w.entries,type:i("status"),options:P(vt),groups:P(_n)}),n({...w.entries,type:i("date")}),n({...w.entries,type:i("people")}),n({...w.entries,type:i("files")}),n({...w.entries,type:i("unique_id")}),n({...w.entries,type:i("relation"),data_source_id:a(r()),dual_property:a(xn)}),n({...w.entries,type:i("place")}),n({...w.entries,type:i("formula")}),n({...w.entries,type:i("rollup")}),n({...w.entries,type:i("button")}),n({...w.entries,type:i("verification")}),n({...w.entries,type:i("location")}),n({...w.entries,type:i("created_time")}),n({...w.entries,type:i("last_edited_time")}),n({...w.entries,type:i("created_by")}),n({...w.entries,type:i("last_edited_by")})]);var Zt={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 Jt=n({id:a(K),propertiesById:L(r(),Kt)});var Yt=n({collectionPointer:a($t),collectionSchema:a(Jt),propertyIdsByKey:a(L(r(),a(r()))),inaccessible:a(i(!0))});var he=L(r(),Yt);function er(e){let t=Object.entries(e.manifestDataSource.properties??{}).map(([o,s])=>{let c=e.propertyIdsByKey?.[o],l=c===void 0?void 0:e.collectionSchema?.propertiesById[c];return Pn(o,c,l?.type,s.type)});return e.collectionSchema===void 0?{status:"missing_schema",properties:t}:t.every(o=>o.status==="mapped")?{status:"complete",properties:t}:{status:"incomplete",properties:t}}function Pn(e,t,o,s){return t===void 0?{status:"missing",propertyKey:e,propertyId:t}:o===void 0?{status:"invalid",propertyKey:e,propertyId:t}:{status:o===s?"mapped":"incompatible",propertyKey:e,propertyId:t}}var $e=n({type:i("page_id"),page_id:z}),Qe=n({type:i("data_source_id"),data_source_id:K}),En=n({type:i("workspace"),workspace:i(!0)}),On=n({type:i("block_id"),block_id:ye}),Rn=n({type:i("agent_id"),agent_id:Vt}),Bn=n({type:i("unavailable")}),re=v("type",[$e,Qe,En,On,Rn,Bn]);var xe=v("type",[n({type:i("unavailable")}),n({type:i("page"),id:z,parent:re})]);var Ce=B(["standard","high"]),tr="standard";var Pe=B(["light","dark"]);var rr=n({action:r(),resource:d([r(),A(P(r()),fe(1))])});var or=v("type",[n({type:i("emoji"),emoji:r()}),n({type:i("external"),url:r()})]),jn=n({name:r(),description:a(r()),type:Wt}),Mn=n({name:r(),description:a(r()),icon:a(or)}),Dn=n({name:r(),description:a(r()),icon:a(or),properties:a(L(r(),jn),{})}),ge=n({version:i(1),name:a(r()),description:a(r()),slashCommand:a(r()),icon:a(n({type:i("emoji"),emoji:r()})),dataSources:a(L(r(),Dn),{}),pages:a(L(r(),Mn)),grants:a(P(rr))});var We=A(r(),me("NotionUserId"));var ce=n({object:i("user"),id:We,name:a(r()),avatar_url:q(r()),type:i("person"),person:n({email:r()})});var wn=r(),Fe=n({code:wn,message:r(),isRetryable:g()}),Ue=class extends Error{constructor(t){super(t.message),this.name="CustomBlockInitializationError",this.code=t.code,this.isRetryable=t.isRetryable}code;isRetryable},Xe=v("status",[n({type:i("init"),initializationId:r(),status:i("success"),theme:Pe,contrastMode:Ce,blockId:ye,parent:re,page:xe,manifest:ge,dataSources:n({bindings:he}),currentUser:ce}),n({type:i("init"),initializationId:r(),status:i("error"),error:Fe})]);var nr=n({type:i("contrastModeChanged"),contrastMode:Ce});var ir=n({type:i("pageChanged"),page:xe});var sr=n({type:i("parentChanged"),parent:re});var ar=n({type:i("themeChanged"),theme:Pe});var ur=n({type:i("dataSourcesChanged"),dataSources:n({bindings:he})});var Ke=n({unit:B(["year","month","week","day"]),value:R(),time:r(),defaultTimeZone:a(r())}),Tn=n({unit:B(["hour","minute"]),value:R()}),ze=n({unit:i("none")}),ht=d([Ke,Tn]),cr=a(d([Ke,ze])),lr=a(d([ht,ze])),qn=n({type:i("date"),start_date:r(),reminder:cr}),An=n({type:i("daterange"),start_date:r(),end_date:r(),reminder:cr}),Nn=n({type:i("datetime"),start_date:r(),start_time:r(),time_zone:a(r()),reminder:lr}),Un=n({type:i("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:a(r()),reminder:lr}),pr=v("type",[qn,An,Nn,Un]);var Ze=n({id:r(),table:r()});var mr=d([r(),R(),g(),pr,P(r()),P(Ze)]);var fr=n({id:z,is_archived:g(),in_trash:g(),propertiesById:L(r(),a(mr))});var Fn=r(),zn=B(["gray","lightgray","brown","yellow","orange","green","blue","purple","pink","red"]),gt=d([zn,r()]),bt=Ge({type:i("icon"),icon:Ge({name:Fn,color:a(gt)})});var yr=n({type:i("emoji"),emoji:r()}),dr=n({type:i("custom_emoji"),custom_emoji:n({id:r(),name:a(r()),url:a(r())})}),St=n({type:i("external"),external:n({url:r()})}),kt=n({type:i("file"),file:n({url:r(),expiry_time:a(r())})}),Ee=v("type",[bt,yr,dr,St,kt]),be=v("type",[St,kt]),vr=v("type",[bt,yr,dr,St,kt]);var Q=q(r());var It={start:r(),end:a(Q),time_zone:a(Q),reminder:a(d([ht,ze]))},hr=d([n({...It,start:A(r(),lt("T"))}),n({...It,time_zone:r()}),n({...It,reminder:a(d([Ke,ze]))})]);var gr=d([n({type:i("external"),name:r(),external:n({url:r()})}),n({type:i("file"),name:r(),file:n({url:r(),expiry_time:a(r())})})]);var Oe=q(n({...Ze.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:a(r())}));var br=n({lat:R(),lon:R(),name:a(Q),address:a(Q),aws_place_id:a(Q),google_place_id:a(Q)});var Sr=n({id:r()});var _t=L(r(),Se());var Je=d([n({id:r(),name:a(r()),color:a(r()),description:a(Q)}),n({name:r(),id:a(r()),color:a(r()),description:a(Q)})]);var kr=d([n({object:a(i("user")),id:r()}),n({object:i("group"),id:r(),name:a(Q)})]);var T={id:r()},xt=v("type",[n({...T,type:i("title"),title:P(_t)}),n({...T,type:i("rich_text"),rich_text:P(_t)}),n({...T,type:i("number"),number:q(R())}),n({...T,type:i("url"),url:Q}),n({...T,type:i("email"),email:Q}),n({...T,type:i("phone_number"),phone_number:Q}),n({...T,type:i("checkbox"),checkbox:g()}),n({...T,type:i("select"),select:q(Je)}),n({...T,type:i("status"),status:q(Je)}),n({...T,type:i("multi_select"),multi_select:P(Je)}),n({...T,type:i("date"),date:q(hr)}),n({...T,type:i("people"),people:P(kr)}),n({...T,type:i("relation"),has_more:a(g()),relation:P(Sr)}),n({...T,type:i("files"),files:P(gr)}),n({...T,type:i("place"),place:q(br)}),n({...T,type:i("created_time"),created_time:Q}),n({...T,type:i("last_edited_time"),last_edited_time:Q}),n({...T,type:i("created_by"),created_by:Oe}),n({...T,type:i("last_edited_by"),last_edited_by:Oe}),n({...T,type:i("unique_id"),unique_id:r()}),n({...T,type:i("button"),button:r()}),n({...T,type:i("formula"),formula:r()}),n({...T,type:i("location"),location:r()}),n({...T,type:i("rollup"),rollup:r()}),n({...T,type:i("verification"),verification:r()})]);var Re=L(r(),xt),Ir=L(r(),q(xt));var oe=n({object:i("page"),id:z,parent:re,properties:Ir,created_by:a(Oe,null),last_edited_by:a(Oe,null),created_time:a(q(r()),null),last_edited_time:a(q(r()),null),icon:a(q(Ee),null),cover:a(q(be),null),url:a(q(r()),null),public_url:a(q(r()),null),is_archived:g(),in_trash:g()});var _r=B(["active","archived","all"]);var xr=d([m({equals:g()}),m({does_not_equal:g()})]);var le=d([m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var ke=d([r(),P(r())]);var Cr=d([m({contains:ke}),m({contains_all:ke}),m({does_not_contain:ke}),le]);var Pr=m({object:i("user"),id:A(r(),fe(1),qe(2e3))}),Er=d([m({contains:Pr}),m({does_not_contain:Pr}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var Z=B(["start_date","end_date"]),Hn=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),He=d([Hn,r()]),Or=d([m({target:a(Z),equals:He}),m({target:a(Z),before:He}),m({target:a(Z),after:He}),m({target:a(Z),on_or_before:He}),m({target:a(Z),on_or_after:He}),m({target:a(Z),this_week:m({})}),m({target:a(Z),past_week:m({})}),m({target:a(Z),past_month:m({})}),m({target:a(Z),past_year:m({})}),m({target:a(Z),next_week:m({})}),m({target:a(Z),next_month:m({})}),m({target:a(Z),next_year:m({})}),m({target:a(Z),is_empty:i(!0)}),m({target:a(Z),is_not_empty:i(!0)})]);var Rr=d([m({equals:R()}),m({does_not_equal:R()}),m({greater_than:R()}),m({less_than:R()}),m({greater_than_or_equal_to:R()}),m({less_than_or_equal_to:R()}),le]);var Ye=d([m({equals:ke}),m({does_not_equal:ke}),le]);var Br=m({object:B(["user","group"]),id:A(r(),fe(1))}),jr=d([m({contains:Br}),m({does_not_contain:Br}),le]);var Mr=A(z,pt(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),mt(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),et=d([m({contains:Mr}),m({does_not_contain:Mr}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var Dr=B(["To-do","In progress","Complete","Current","Future"]),wr=d([Dr,A(P(Dr),fe(1),qe(5))]),Tr=d([m({group_equals:wr}),m({group_does_not_equal:wr})]);var qr=d([Ye,Tr]);var Be=d([m({equals:r()}),m({does_not_equal:r()}),m({contains:r()}),m({does_not_contain:r()}),m({starts_with:r()}),m({ends_with:r()}),le]);var Ct=d([m({propertyId:r(),relation:et}),m({propertyId:r(),created_by:Er}),m({propertyId:r(),title:Be}),m({propertyId:r(),rich_text:Be}),m({propertyId:r(),url:Be}),m({propertyId:r(),email:Be}),m({propertyId:r(),phone_number:Be}),m({propertyId:r(),number:Rr}),m({propertyId:r(),checkbox:xr}),m({propertyId:r(),select:Ye}),m({propertyId:r(),multi_select:Cr}),m({propertyId:r(),status:qr}),m({propertyId:r(),date:Or}),m({propertyId:r(),people:jr})]);var Ar=d([Ct,m({and:P(Ct)})]);var Nr=B(["ascending","descending"]);var Pt=10,Ur=m({propertyId:r(),direction:Nr});var Fr=n({type:i("queryDataSource"),subscriptionId:r(),dataSourceId:K,limit:R(),filter:a(Ar),sorts:a(P(Ur)),archive_status:a(_r)}),Ln=r(),zr=n({code:Ln,message:r(),isRetryable:g()}),Hr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:P(oe),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:zr})]),Lr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:P(d([oe,fr])),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:zr})]);var Vn=r(),Gn=n({code:Vn,message:r(),isRetryable:g()}),Vr=n({type:i("openExternalUrl"),requestId:r(),url:r()}),Gr=v("status",[n({type:i("openExternalUrlResult"),requestId:r(),status:i("success")}),n({type:i("openExternalUrlResult"),requestId:r(),status:i("error"),error:Gn})]);var je=n({object:i("page"),id:z,parent:re,properties:Re,created_time:a(r()),last_edited_time:a(r()),icon:a(Ee),cover:a(be),url:a(r()),public_url:a(r()),is_archived:g(),in_trash:g()});var $n=r(),Qr=n({code:$n,message:r(),isRetryable:g()}),Wr=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:Qr})]),Xr=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:Qr})]),Qn=v("type",[n({type:i("start")}),n({type:i("end")}),n({type:i("before"),blockId:ye}),n({type:i("after"),blockId:ye})]),hu=v("type",[$e,Qe]),$r={type:i("createPage"),requestId:r(),properties:Re,icon:a(vr),cover:a(be)},Kr=v("type",[n({...$r,parent:$e,position:a(Qn)}),n({...$r,parent:Qe,position:a(dt())})]);var Wn=r(),Zr=n({code:Wn,message:r(),isRetryable:g()}),Jr=n({type:i("getPage"),requestId:r(),pageId:z,dataSourceId:a(K)}),Yr=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Zr})]),eo=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Zr})]);var Xn=B(["side_peek","center_peek"]),Kn=r(),Zn=n({code:Kn,message:r(),isRetryable:g()}),to=n({type:i("openPage"),requestId:r(),pageId:z,mode:Xn}),ro=v("status",[n({type:i("openPageResult"),requestId:r(),status:i("success"),pageId:z}),n({type:i("openPageResult"),requestId:r(),status:i("error"),error:Zn})]);var Jn=r(),oo=n({code:Jn,message:r(),isRetryable:g()}),no=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:oo})]),io=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:d([oe,je])}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:oo})]),so=n({type:i("updatePage"),requestId:r(),pageId:z,dataSourceId:a(K),properties:a(Re),icon:a(Ee),cover:a(be),archived:a(g())});var ao=n({type:i("currentUserChanged"),currentUser:ce});var Yn=r(),ei=n({code:Yn,message:r(),isRetryable:g()}),uo=n({type:i("getUser"),requestId:r(),userId:We}),co=v("status",[n({type:i("getUserResult"),requestId:r(),status:i("success"),user:ce}),n({type:i("getUserResult"),requestId:r(),status:i("error"),error:ei})]);var lo=n({object:i("list"),results:P(ce),next_cursor:q(r()),has_more:g(),type:i("user"),user:L(r(),Se())});var ti=r(),ri=n({code:ti,message:r(),isRetryable:g()}),po=n({type:i("listUsers"),requestId:r(),startCursor:a(r()),pageSize:a(R())}),mo=v("status",[n({type:i("listUsersResult"),requestId:r(),status:i("success"),list:lo}),n({type:i("listUsersResult"),requestId:r(),status:i("error"),error:ri})]);var fo=n({type:i("invalidSandboxMessage"),requestId:a(r()),reason:r()});var yo=v("type",[Xe,ar,nr,sr,ir,ao,ur,co,mo,ro,Gr,fo]),vo=v("type",[...yo.options,Hr,Yr,Wr,no]),oc=v("type",[...yo.options,Lr,eo,Xr,io]);function ho(e){return{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([t,o])=>[t,{...o,collectionSchema:{...o.collectionSchema,propertiesById:{...o.collectionSchema?.propertiesById,...Zt}}}]))}}}function Y(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function tt(e){return{...e,properties:Object.fromEntries(Object.entries(e.properties).map(([t,o])=>{switch(o?.type){case"unique_id":case"button":case"formula":case"location":case"rollup":case"verification":return[t,null];case"title":case"rich_text":case"number":case"url":case"email":case"phone_number":case"checkbox":case"select":case"status":case"multi_select":case"date":case"people":case"relation":case"files":case"place":case"created_time":case"last_edited_time":case"created_by":case"last_edited_by":case void 0:return[t,o];default:return Y(o)}}))}}function Me(e){if(e?.type!=="icon")return e;let{name:t,color:o}=e.icon;return{type:"external",external:{url:`https://www.notion.so/icons/${t}_${o??"gray"}.svg`}}}function go(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:Me(e.icon)??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function De(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}var Ie=class extends Error{};function Et(e){try{return oi(e)}catch(t){throw t instanceof RangeError?new Ie(t.message):t}}function oi(e){let{start:t,end:o,time_zone:s,reminder:c}=e;if(!t.split("T")[0])throw new Ie("Date values must include a date.");let l=t.includes("T")||s!=null,p=t.match(/([+-])(\d{2}):(\d{2})$/),h=p?(Number(p[2])*60+Number(p[3]))*(p[1]==="-"?-1:1):0,y=s?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=y?(Number(y[2]??0)*60+Number(y[3]??0))*(y[1]==="-"?-1:1):h,k=b=>{if(!b.split("T")[0])throw new Ie("Date values must include a date.");if(!b.includes("T"))return{date:b,time:"00:00"};let N=b.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(N)return{date:N[1],time:N[2]};if(!s||y){let U=new Date(new Date(b).getTime()+x*6e4).toISOString();return{date:U.slice(0,10),time:U.slice(11,16)}}let j=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(b)),H=U=>j.find(ee=>ee.type===U)?.value;return{date:`${H("year")}-${H("month")}-${H("day")}`,time:`${H("hour")}:${H("minute")}`}},D=k(t),W=o?k(o):void 0;if(!l){if(c&&!("time"in c)&&c.unit!=="none")throw new Ie("Hour and minute reminders require a date with a time.");return W?{type:"daterange",start_date:D.date,end_date:W.date,reminder:c}:{type:"date",start_date:D.date,reminder:c}}let V=s??(h===0?"UTC":`UTC${h<0?"-":"+"}${Math.floor(Math.abs(h)/60)}${Math.abs(h)%60===0?"":`:${String(Math.abs(h)%60).padStart(2,"0")}`}`);return W?{type:"datetimerange",start_date:D.date,start_time:D.time,end_date:W.date,end_time:W.time,time_zone:V,reminder:c}:{type:"datetime",start_date:D.date,start_time:D.time,time_zone:V,reminder:c}}function So(e){switch(e.type){case"title":return bo(e.title);case"rich_text":return bo(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?Et(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return De(e.created_time);case"last_edited_time":return De(e.last_edited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return Y(e)}}function bo(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let o=t.text;return o&&typeof o=="object"&&"content"in o&&typeof o.content=="string"?o.content:""}).join("")}function ko(e){let t={};for(let o of Object.values(e.properties))o&&(t[o.id]=So(o));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:{...t,created_time:De(e.created_time),last_edited_time:De(e.last_edited_time),created_by:e.created_by?[e.created_by]:void 0,last_edited_by:e.last_edited_by?[e.last_edited_by]:void 0}}}function Io(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(ko)}:{...e,page:go(tt(e.page))}}function xo(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(_o)}:{...e,page:_o(e.page)}}function _o(e){return{...tt(e),icon:Me(e.icon)}}function Po(e){if(e.type==="queryDataSourceResult")return e.items.some(o=>o.icon?.type==="icon")?{...e,items:e.items.map(Co)}:e;let t=Co(e.page);return t===e.page?e:{...e,page:t}}function Co(e){let t=Me(e.icon);return t===e.icon?e:{...e,icon:t}}function Eo(e,t){return e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged"?t<5?ho(e):e:e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"||e.status==="error"?e:t<6?Io(e):t<7?xo(e):t<9?Po(e):e}var Ot=n({theme:Pe,contrastMode:a(Ce),blockId:ye,parent:re,page:xe,manifest:ge,dataSources:n({bindings:he}),currentUser:ce}),Oo=v("status",[n({status:i("success"),initialState:Lt(Ot,["manifest"])}),n({status:i("error"),error:Fe})]);var rt=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let o={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:o,isRefreshing:!0,shouldRefreshAgain:!1}),o}isCurrent(t,o){return this.bySubscriptionId.get(t)?.token===o}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let o=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,o.push({message:c.message,token:c.token})}return s?o:void 0}finish(t,o){let s=this.bySubscriptionId.get(t);if(s?.token===o&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function Ro(e,t){if(e===void 0)return;let o="and"in e?e.and:[e];for(let s of o){let c=ai(s,t);if(c!==void 0)return c}}function ai(e,t){if(!Object.hasOwn(t.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 o=t.propertiesById[e.propertyId],s=Object.keys(e).find(h=>h!=="propertyId");if(s!==o.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${o.type}".`,isRetryable:!1};if("status"in e&&o.type==="status"){let h=e.status;if("group_equals"in h||"group_does_not_equal"in h){let y="group_equals"in h?h.group_equals:h.group_does_not_equal,k=(Array.isArray(y)?y:[y]).find(D=>!o.groups.some(W=>W.name===D));return k===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${k}".`,isRetryable:!1}}}if("relation"in e&&!Ht(et,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=ui(e);if(c===void 0||o.type!==c.propertyType)return;let l=new Set(o.options.map(h=>h.name)),p=ci(c.operator).find(h=>!l.has(h));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function ui(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 t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function ci(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:Y(e);return Array.isArray(t)?t:[t]}var li=new Set(Xt);function Bo(e,t){if(e===void 0)return;if(e.length>Pt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Pt} entries.`,isRetryable:!1};let o=new Set;for(let s of e){if(o.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(o.add(s.propertyId),!Object.hasOwn(t.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=t.propertiesById[s.propertyId];if(!li.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}}}function jo(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Rt(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function Mo(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function Do(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function ot(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function Bt(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:o}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${o}.`,isRetryable:!1}}function jt(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var pi=5e3,mi=5e3,fi=5e3;function wo(e){let{manifestSource:t,prepareInit:o,sendInitMessage:s,warn:c,flushPendingHostStateChanges:l,minBridgeProtocolVersion:p,noConnectTimeoutMs:h=pi,initialStateTimeoutMs:y=mi,noInitResultTimeoutMs:x=fi,stopHostWithFailure:k,onInitResult:D,onInitSent:W,onConnectionFailure:V}=e,b="waitingForConnect",N,j,H,U,ee=!1,de=!1;function te(){N!==void 0&&(window.clearTimeout(N),N=void 0)}function F(){j!==void 0&&(window.clearTimeout(j),j=void 0)}function G(){H!==void 0&&(window.clearTimeout(H),H=void 0)}function X(I){let{initializationId:E,error:_,phase:ae,source:it}=I;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"failed":case"stopped":return;default:return Y(b)}b="failed",U=E,te(),F(),s({type:"init",initializationId:E,status:"error",error:_}),V({..._,phase:ae,source:it})}async function se(I){if(b==="waitingForConnect"){b="preparingInit",U=I.initializationId,te(),j=window.setTimeout(()=>{if(b!=="preparingInit")return;let E=jo();c({...E,initializationId:I.initializationId}),X({initializationId:I.initializationId,error:E,phase:"init",source:"host"})},y);try{let E=await o(I);if(b!=="preparingInit")return;if(F(),E.status==="error"){X({initializationId:I.initializationId,error:E.error,phase:"init",source:"host"});return}b="waitingForInitResult";let _={type:"init",initializationId:I.initializationId,status:"success",theme:E.initialState.theme,contrastMode:E.initialState.contrastMode??tr,blockId:E.initialState.blockId,parent:E.initialState.parent,page:E.initialState.page,currentUser:E.initialState.currentUser,manifest:E.initialState.manifest,dataSources:E.initialState.dataSources};if(s(_),b!=="waitingForInitResult"||(W(),b!=="waitingForInitResult"))return;H=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="failed";let ae=Do();V({...ae,phase:"initResult",source:"host"}),c({...ae,initializationId:I.initializationId})},x)}catch(E){if(b!=="preparingInit")return;c({message:"Failed to prepare custom block initialization",error:E}),X({initializationId:I.initializationId,error:ot(),phase:"init",source:"host"})}}}function J(I){if(b!=="stopped"&&b==="waitingForConnect"){if(!jt(I.bridgeProtocolVersion)){let E=Rt({currentBridgeProtocolVersion:I.bridgeProtocolVersion});X({initializationId:I.initializationId,error:E,phase:"connect",source:"host"});return}if(I.bridgeProtocolVersion<p){let E=Bt({currentBridgeProtocolVersion:I.bridgeProtocolVersion,minBridgeProtocolVersion:p});X({initializationId:I.initializationId,error:E,phase:"connect",source:"host"});return}if(I.status==="error"&&(t==="sandbox"||I.error.code!=="manifest_invalid")){X({initializationId:I.initializationId,error:I.error,phase:"connect",source:"sandbox"});return}de=!0,se(I)}}function C(I){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:E,bridgeProtocolVersion:_}=I;if(E===void 0)return"nack";let ae=I.error;return _!==void 0&&(jt(_)?_<p&&(ae=Bt({currentBridgeProtocolVersion:_,minBridgeProtocolVersion:p})):ae=Rt({currentBridgeProtocolVersion:_})),X({initializationId:E,error:ae,phase:"connect",source:"host"}),"handled"}function ne(I){let{initializationId:E,error:_}=I;b!=="waitingForInitResult"||E===void 0||E!==U||(te(),G(),b="failed",c(_),V({..._,phase:"initResult",source:"host"}))}function Le(){if(b!=="stopped"){if(ee){k({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}ee=!0,te(),b==="waitingForConnect"&&(N=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="failed";let I=Mo();c(I),V({...I,phase:"connect",source:"host"})},h))}}function we(I){if(b!=="waitingForInitResult"||I.initializationId!==U){c({message:"Ignored stale or unexpected initResult",payload:I});return}G(),b=I.status==="success"?"initialized":"failed",I.status==="success"?l():V({...I.error,phase:"initResult",source:"sandbox"}),D(I)}function ve(){b="stopped",te(),F(),G()}return{get status(){return b},get hasConnectedSandbox(){return de},handleConnect:J,handleInitResult:we,handleInvalidConnect:C,handleInvalidInitResult:ne,onIframeLoad:Le,stop:ve}}function Mt(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Dt(){return{code:"invalid_local_preview_url",message:"Local custom blocks require an HTTP(S) URL on localhost, a .localhost subdomain, or 127.0.0.1, without credentials and on a different origin from the host.",isRetryable:!1}}function To(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function qo(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function Ao(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function No(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===""}function nt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&No(e)}async function Uo(e){return e.manifestSource==="host"?e.hostManifest:e.connectManifest!==void 0?{status:"success",manifest:e.connectManifest}:{status:"error",error:{code:"manifest_unavailable",message:"The sandbox did not provide a manifest in connect.",isRetryable:!1}}}var Fo=v("status",[n({status:i("success"),manifest:ge}),n({status:i("error"),error:Fe})]);function zo(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Ho=n({type:i("resize"),height:A(R(),Te(),Ae(0))});var Lo=n({type:i("unsubscribeDataSourceQuery"),subscriptionId:r()});var Vo=n({code:r(),message:r(),isRetryable:g()});var Go={type:i("connect"),initializationId:r(),bridgeProtocolVersion:R(),sdkVersion:r()},$o=v("status",[n({status:i("success"),manifest:a(ge),...Go}),n({status:i("error"),error:Vo,...Go})]);var yi=r(),di=n({code:yi,message:r(),isRetryable:g()}),Qo=v("status",[n({type:i("initResult"),initializationId:r(),status:i("success"),initialHeight:a(A(R(),Te(),Ae(0)))}),n({type:i("initResult"),initializationId:r(),status:i("error"),error:di})]);var Wo=n({type:i("invalidHostMessage"),requestId:a(r()),reason:r()});var Xo=v("type",[$o,Qo,Fr,Lo,Kr,Jr,uo,po,to,Vr,so,Ho,Wo]);function Ko(e){return ie(Xo,e)}function Zo(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Jo(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Yo(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}var vi=n({requestId:r()});function en(e){let t=ie(vi,e);return t.success?t.output.requestId:void 0}function tn(e){let t=Yo(e);if(t==="invalidHostMessage"||t==="invalidSandboxMessage")return{incomingType:t};let o=en(e);return{incomingType:t,nack:{type:"invalidSandboxMessage",...o!==void 0?{requestId:o}:{},reason:hi(t)}}}function hi(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var gi=n({type:B(["updatePage","createPage"]),requestId:r(),icon:n({type:i("icon"),icon:n({color:Se()})})});function rn(e){let t=ie(gi,e);if(!t.success)return;let o=t.output.icon.icon.color;if(!(o===void 0||ie(gt,o).success))return{type:t.output.type==="createPage"?"createPageResult":"updatePageResult",requestId:t.output.requestId,status:"error",error:{code:"invalid_icon_color",message:"Use a supported Notion icon color.",isRetryable:!1}}}var on=n({initializationId:r()}),bi=n({bridgeProtocolVersion:d([R(),yt()])});function nn(e){let{iframe:t,sandboxOrigin:o,getInitStatus:s,emit:c,sendNack:l,sendPageMutationError:p,onInvalidConnect:h,onInvalidInitResult:y,onConnect:x,onInitResult:k,onQueryDataSource:D,onUnsubscribeDataSourceQuery:W,onCreatePage:V,onGetPage:b,onOpenPage:N,onOpenExternalUrl:j,onGetUser:H,onListUsers:U,onUpdatePage:ee,onResize:de}=e;function te(F,G){let X=rn(F);if(X!==void 0&&s()==="initialized"){p(X);return}c("warn",{message:"Ignored unsupported sandbox message",payload:wt(F),issues:G});let se=tn(F);if(se.incomingType==="connect"){let J=ie(on,F),C=ie(bi,F);if(h({initializationId:J.success?J.output.initializationId:void 0,error:Zo(),bridgeProtocolVersion:C.success?C.output.bridgeProtocolVersion:void 0})==="handled")return}if(se.incomingType==="initResult"){let J=ie(on,F);y({initializationId:J.success?J.output.initializationId:void 0,error:Jo()})}se.nack!==void 0&&s()!=="stopped"&&l(se.nack)}return function(G){let X=G.source===t.contentWindow,se=G.origin===o;if(!X||!se)return;let J=Ko(G.data);if(!J.success){te(G.data,J.issues);return}let C=J.output;if(!zo(C)&&s()!=="initialized"){c("warn",{message:`Ignored ${C.type} before initialization completed`,payload:wt(C)});return}switch(c("in",wt(C)),C.type){case"connect":x(C);return;case"initResult":k(C);return;case"queryDataSource":D(C);return;case"unsubscribeDataSourceQuery":W(C);return;case"createPage":V(C);return;case"openPage":N(C);return;case"openExternalUrl":j(C);return;case"getPage":b(C);return;case"getUser":H(C);return;case"listUsers":U(C);return;case"updatePage":ee(C);return;case"resize":de(C);return;case"invalidHostMessage":return;default:Y(C)}}}function wt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}function sn(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}var un=5;function ki(e){let{iframe:t,prepareInitialState:o,handlers:s,onStatusChange:c,onLog:l,onQueryUnsubscribed:p,minBridgeProtocolVersion:h,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k}=e,D=Ii(e.sandboxUrl,e.manifestSource),W=D.origin,V=Math.max(h??3,3),b=new AbortController,N,j={},H=!1,U=new AbortController,ee,de,te=10,F=new rt(u=>{p?.(u)});function G(u,S){l?.(u,S)}function X(u){let S=_.status;switch(S){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"failed":break;case"stopped":return;default:return Y(S)}let O=Eo(u,te);G("out",O),t.contentWindow?.postMessage(O,W)}function se(u){X(ue(Xe,u))}function J(u){X(u)}function C(u){let S=_.status;switch(S){case"initialized":X(ue(vo,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"failed":case"stopped":return;default:Y(S)}}async function ne(u,S){try{let O=S===void 0?xi(u.type):await S(u);C({...O,type:`${u.type}Result`,requestId:u.requestId})}catch(O){if(_.status!=="initialized")return;G("warn",O),C({type:`${u.type}Result`,requestId:u.requestId,status:"error",error:{code:"unknown_error",message:`The host could not complete ${u.type}.`,isRetryable:!1}})}}function Le(u){let S=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};C(S)}async function we(u,S=F.subscribe(u)){try{let O=_i(de,u.dataSourceId),pe=Ci(u,O);if(pe!==void 0){F.isCurrent(u.subscriptionId,S)&&(F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:{status:"error",error:pe}}));return}let at=await s.queryDataSource(u);if(!F.isCurrent(u.subscriptionId,S))return;at.status==="error"&&!at.error.isRetryable&&F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:at})}finally{let O=F.finish(u.subscriptionId,S);O!==void 0&&we(O.message,O.token)}}function ve(u){_.status==="stopped"||_.status==="failed"||(Object.assign(j,u),E())}async function I(u){if(b.signal.aborted)return;let S=s.openExternalUrl;if(S===void 0){await ne(u,void 0);return}if(N===u.requestId)return;if(N!==void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};C(pe);return}let O=sn(u.url);if(O===void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};C(pe);return}N=u.requestId;try{await ne(u,()=>S({...u,url:O},{signal:b.signal}))}finally{N===u.requestId&&(N=void 0)}}function E(){if(_.status!=="initialized")return;let u=j;j={},u.theme!==void 0&&C({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&C({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&C({type:"parentChanged",parent:u.parent}),u.page!==void 0&&C({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&C({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&C({type:"currentUserChanged",currentUser:u.currentUser})}let _=wo({manifestSource:e.manifestSource,async prepareInit(u){let S=u.status==="success"?u.manifest:void 0;te=u.bridgeProtocolVersion,c({status:"preparingInit",localManifest:nt({url:D,hostOrigin:window.location.origin})?S:void 0,bridgeProtocolVersion:u.bridgeProtocolVersion,sdkVersion:u.sdkVersion});let O=await(pn??qt(S));return _.status!=="preparingInit"?O:ae(O)},sendInitMessage:se,onInitSent:()=>c({status:"waitingForInitResult"}),warn:u=>G("warn",u),flushPendingHostStateChanges:E,minBridgeProtocolVersion:V,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k,stopHostWithFailure:Nt,onInitResult(u){u.status==="success"&&ee!==void 0&&c({status:"initialized",resolvedManifest:ee,initialHeight:u.initialHeight})},onConnectionFailure:u=>{U.abort(),c({status:"failed",error:u})}});function ae(u){if(u.status==="error")return u;let S=ue(Ot,{...u.initialState,...j});if(ee=S.manifest,j={},te<un&&S.page.type==="unavailable")return{status:"error",error:Mt()};let O=cn(S.manifest,S.dataSources);return O!==void 0?{status:"error",error:O}:(de=S.dataSources,H=!0,{status:"success",initialState:S})}let it=mn().catch(Tt),pn=e.manifestSource==="host"?qt(void 0).catch(Tt):void 0;async function mn(){U.signal.throwIfAborted();let u=await e.getPersistedManifest({signal:U.signal});return U.signal.throwIfAborted(),ue(Fo,u)}function Tt(u){return U.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:u}),{status:"error",error:ot()}}async function qt(u){U.signal.throwIfAborted();let S=await Uo({manifestSource:e.manifestSource,hostManifest:it,connectManifest:u});if(U.signal.throwIfAborted(),S.status==="error")return S;let O=ue(Oo,await o({manifest:S.manifest,signal:U.signal}));return O.status==="error"?O:{status:"success",initialState:{...O.initialState,manifest:S.manifest}}}let At=nn({iframe:t,sandboxOrigin:W,getInitStatus:()=>_.status,emit:G,sendNack:J,sendPageMutationError:X,onInvalidConnect:_.handleInvalidConnect,onInvalidInitResult:_.handleInvalidInitResult,onConnect:_.handleConnect,onInitResult:_.handleInitResult,onQueryDataSource:we,onUnsubscribeDataSourceQuery:u=>F.unsubscribe(u.subscriptionId),onOpenExternalUrl:I,onCreatePage:u=>ne(u,s.createPage),onGetPage:u=>ne(u,s.getPage),onOpenPage:u=>ne(u,s.openPage),onGetUser:u=>ne(u,s.getUser),onListUsers:u=>ne(u,s.listUsers),onUpdatePage:u=>ne(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",At),t.addEventListener("load",_.onIframeLoad);function st(){b.abort(),U.abort(),window.removeEventListener("message",At),t.removeEventListener("load",_.onIframeLoad),_.stop(),F.unsubscribeAll()}function fn(){let u=_.status;st(),u!=="stopped"&&u!=="failed"&&c({status:"stopped"})}function Nt(u){if(_.status!=="stopped"){if(_.status==="failed"){st();return}st(),G("warn",u),c({status:"failed",error:u})}}return c({status:"waitingForConnect"}),{stop:fn,setTheme(u){ve({theme:u})},setContrastMode(u){ve({contrastMode:u})},setParent(u){ve({parent:u})},setPage(u){if(u.type==="unavailable"&&te<un&&(_.status==="preparingInit"&&H||_.status==="waitingForInitResult"||_.status==="initialized")){Nt({...Mt(),phase:"runtime",source:"host"});return}ve({page:u})},setCurrentUser(u){ve({currentUser:u})},setDataSources(u){let S={bindings:ue(he,u.bindings)},O=_.hasConnectedSandbox&&ee!==void 0?cn(ee,S):void 0;return O!==void 0?(G("warn",{message:"Ignored invalid data source bindings update",payload:S}),{status:"error",error:O}):(de=S,ve({dataSources:S}),{status:"success"})},refreshQuery({dataSourceId:u}){if(_.status!=="initialized")return;let S=ue(K,u),O=F.refresh(S);if(O===void 0){G("warn",`No active query exists for data source "${u}"`);return}for(let pe of O)we(pe.message,pe.token)}}}function Ii(e,t){let o;try{o=new URL(e)}catch(s){throw t==="host"?s:new Ue(Dt())}if(t==="sandbox"&&!nt({url:o,hostOrigin:window.location.origin}))throw new Ue(Dt());return o}function _i(e,t){return Object.values(e?.bindings??{}).find(o=>o.collectionPointer?.id===t)?.collectionSchema}function cn(e,t){for(let[o,s]of Object.entries(e.dataSources)){let c=t.bindings[o];if(c?.inaccessible===!0)continue;let l=er({manifestDataSource:s,collectionSchema:c?.collectionSchema,propertyIdsByKey:c?.propertyIdsByKey});if(c?.collectionPointer===void 0||l.status==="missing_schema")return qo();for(let p of l.properties){if(p.status==="missing")return Ao();if(p.status!=="mapped")return To()}}}function xi(e){return{status:"error",error:{code:"unsupported_operation",message:`The host does not support ${e}.`,isRetryable:!1}}}function Ci(e,t){return t===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}:Ro(e.filter,t)??Bo(e.sorts,t)}function Pi(e){let{manifestProperties:t,propertySchemasById:o}=e,s=[];for(let[c,l]of Object.entries(t)){let p=Ei({propertyKey:c,manifestProperty:l,propertySchemasById:o});p!==void 0&&s.push([c,p])}return Object.fromEntries(s)}function Ei(e){let{propertyKey:t,manifestProperty:o,propertySchemasById:s}=e,c=ln(o.name),l=Object.entries(s).filter(([p,h])=>h.type===o.type&&(p===t||ln(h.name)===c));return l.length===1?l[0][0]:void 0}function ln(e){return e.trim().toLowerCase()}function Oi(e){return ue(z,e)}export{Ie as InvalidNotionDateError,ki as createCustomBlockHost,Pi as getAutoBoundPropertyIdsByKey,nt as isAllowedLocalPreviewUrl,Et as toNotionDateValue,Oi as toNotionPageId};
|
|
@@ -45,8 +45,8 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
|
|
|
45
45
|
readonly url: v.StringSchema<undefined>;
|
|
46
46
|
}, undefined>], undefined>, undefined>;
|
|
47
47
|
}, undefined>, undefined>, undefined>;
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
48
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
49
|
+
readonly action: v.StringSchema<undefined>;
|
|
50
50
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
51
51
|
}, undefined>, undefined>, undefined>;
|
|
52
52
|
}, undefined>, undefined>;
|
|
@@ -587,6 +587,7 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
|
|
|
587
587
|
readonly propertyId: v.StringSchema<undefined>;
|
|
588
588
|
readonly direction: v.PicklistSchema<["ascending", "descending"], undefined>;
|
|
589
589
|
}, undefined>, undefined>, undefined>;
|
|
590
|
+
readonly archive_status: v.OptionalSchema<v.PicklistSchema<["active", "archived", "all"], undefined>, undefined>;
|
|
590
591
|
}, undefined>, v.ObjectSchema<{
|
|
591
592
|
readonly type: v.LiteralSchema<"unsubscribeDataSourceQuery", undefined>;
|
|
592
593
|
readonly subscriptionId: v.StringSchema<undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeSandboxToHostMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeSandboxToHostMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"normalizeSandboxToHostMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeSandboxToHostMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAE7D"}
|
|
@@ -101,8 +101,8 @@ export declare function addMetadataReadSchemasForProtocol3To4(message: Extract<H
|
|
|
101
101
|
} | undefined;
|
|
102
102
|
};
|
|
103
103
|
} | undefined;
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
grants?: {
|
|
105
|
+
action: string;
|
|
106
106
|
resource: string | string[];
|
|
107
107
|
}[] | undefined;
|
|
108
108
|
};
|
|
@@ -87,8 +87,8 @@ export declare const customBlockHostInitialStateSchema: v.ObjectSchema<{
|
|
|
87
87
|
readonly url: v.StringSchema<undefined>;
|
|
88
88
|
}, undefined>], undefined>, undefined>;
|
|
89
89
|
}, undefined>, undefined>, undefined>;
|
|
90
|
-
readonly
|
|
91
|
-
readonly
|
|
90
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
91
|
+
readonly action: v.StringSchema<undefined>;
|
|
92
92
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
93
93
|
}, undefined>, undefined>, undefined>;
|
|
94
94
|
}, undefined>;
|
|
@@ -339,8 +339,8 @@ export declare const customBlockHostPreparedStateResultSchema: v.VariantSchema<"
|
|
|
339
339
|
readonly url: v.StringSchema<undefined>;
|
|
340
340
|
}, undefined>], undefined>, undefined>;
|
|
341
341
|
}, undefined>, undefined>, undefined>;
|
|
342
|
-
readonly
|
|
343
|
-
readonly
|
|
342
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
343
|
+
readonly action: v.StringSchema<undefined>;
|
|
344
344
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
345
345
|
}, undefined>, undefined>, undefined>;
|
|
346
346
|
}, undefined>;
|
|
@@ -585,8 +585,8 @@ export declare const customBlockHostPreparedStateResultSchema: v.VariantSchema<"
|
|
|
585
585
|
readonly url: v.StringSchema<undefined>;
|
|
586
586
|
}, undefined>], undefined>, undefined>;
|
|
587
587
|
}, undefined>, undefined>, undefined>;
|
|
588
|
-
readonly
|
|
589
|
-
readonly
|
|
588
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
589
|
+
readonly action: v.StringSchema<undefined>;
|
|
590
590
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
591
591
|
}, undefined>, undefined>, undefined>;
|
|
592
592
|
}, undefined>;
|
package/dist/manifest/types.d.ts
CHANGED
|
@@ -45,8 +45,8 @@ export declare const customBlockHostManifestResultSchema: v.VariantSchema<"statu
|
|
|
45
45
|
readonly url: v.StringSchema<undefined>;
|
|
46
46
|
}, undefined>], undefined>, undefined>;
|
|
47
47
|
}, undefined>, undefined>, undefined>;
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
48
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
49
|
+
readonly action: v.StringSchema<undefined>;
|
|
50
50
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
51
51
|
}, undefined>, undefined>, undefined>;
|
|
52
52
|
}, undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode } from "../../utils/errors.js";
|
|
3
3
|
/**
|
|
4
4
|
* Message sent by the sandbox to ask the host for the current rows in a resolved
|
|
5
5
|
* Notion data source.
|
|
@@ -521,10 +521,11 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
|
521
521
|
readonly propertyId: v.StringSchema<undefined>;
|
|
522
522
|
readonly direction: v.PicklistSchema<["ascending", "descending"], undefined>;
|
|
523
523
|
}, undefined>, undefined>, undefined>;
|
|
524
|
+
readonly archive_status: v.OptionalSchema<v.PicklistSchema<["active", "archived", "all"], undefined>, undefined>;
|
|
524
525
|
}, undefined>;
|
|
525
526
|
export type QueryDataSourceMessage = v.InferOutput<typeof queryDataSourceMessageSchema>;
|
|
526
527
|
export declare const customBlockQueryDataSourceErrorCodeSchema: v.StringSchema<undefined>;
|
|
527
|
-
export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "data_source_query_invalid_limit" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_inaccessible" | "data_source_schema_unavailable" |
|
|
528
|
+
export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "data_source_query_invalid_limit" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_inaccessible" | "data_source_schema_unavailable" | CustomBlockGrantErrorCode>;
|
|
528
529
|
export type CustomBlockQueryDataSourceErrorInfo = CustomBlockErrorInfo<CustomBlockQueryDataSourceErrorCode>;
|
|
529
530
|
export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
|
|
530
531
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -2,6 +2,7 @@ import * as v from "valibot";
|
|
|
2
2
|
import { notionDataSourcePageForProtocol3To5Schema } from "../../compatibility/protocol3To5/dataSourcePage.js";
|
|
3
3
|
import { bridgePageSchema } from "../../pages/bridgePage.js";
|
|
4
4
|
import { notionDataSourceIdSchema } from "../../utils/ids.js";
|
|
5
|
+
import { bridgeArchiveStatusSchema } from "../bridgeArchiveStatus.js";
|
|
5
6
|
import { bridgeDataSourceFilterSchema } from "../filters/bridgeDataSourceFilter.js";
|
|
6
7
|
import { bridgeDataSourceSortSchema } from "../filters/bridgeDataSourceSort.js";
|
|
7
8
|
/**
|
|
@@ -20,6 +21,7 @@ export const queryDataSourceMessageSchema = v.object({
|
|
|
20
21
|
filter: v.optional(bridgeDataSourceFilterSchema),
|
|
21
22
|
/** Sandbox-resolved property sorts, in priority order. */
|
|
22
23
|
sorts: v.optional(v.array(bridgeDataSourceSortSchema)),
|
|
24
|
+
archive_status: v.optional(bridgeArchiveStatusSchema),
|
|
23
25
|
});
|
|
24
26
|
// The schema accepts any string code. The type lists known codes for
|
|
25
27
|
// autocomplete, with an open string fallback for newer senders.
|
|
@@ -49,8 +49,8 @@ export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSc
|
|
|
49
49
|
readonly url: v.StringSchema<undefined>;
|
|
50
50
|
}, undefined>], undefined>, undefined>;
|
|
51
51
|
}, undefined>, undefined>, undefined>;
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
52
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
53
|
+
readonly action: v.StringSchema<undefined>;
|
|
54
54
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
55
55
|
}, undefined>, undefined>, undefined>;
|
|
56
56
|
}, undefined>, undefined>;
|
|
@@ -113,8 +113,8 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
|
|
|
113
113
|
readonly url: v.StringSchema<undefined>;
|
|
114
114
|
}, undefined>], undefined>, undefined>;
|
|
115
115
|
}, undefined>, undefined>, undefined>;
|
|
116
|
-
readonly
|
|
117
|
-
readonly
|
|
116
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
117
|
+
readonly action: v.StringSchema<undefined>;
|
|
118
118
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
119
119
|
}, undefined>, undefined>, undefined>;
|
|
120
120
|
}, undefined>;
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export type { BridgeParent, DataSourceParent, NotionParent, PageParent, } from "
|
|
|
23
23
|
export { dataSourceParentSchema, notionParentSchema, pageParentSchema, } from "./context/parent.js";
|
|
24
24
|
export type { NotionTheme } from "./context/theme.js";
|
|
25
25
|
export { notionThemeSchema } from "./context/theme.js";
|
|
26
|
+
export type { BridgeArchiveStatus } from "./dataSources/bridgeArchiveStatus.js";
|
|
27
|
+
export { bridgeArchiveStatusSchema } from "./dataSources/bridgeArchiveStatus.js";
|
|
26
28
|
export type { BridgeDataSourceBinding } from "./dataSources/bridgeDataSourceBinding.js";
|
|
27
29
|
export { bridgeDataSourceBindingSchema } from "./dataSources/bridgeDataSourceBinding.js";
|
|
28
30
|
export type { BridgeDataSourceBindings } from "./dataSources/bridgeDataSourceBindings.js";
|
|
@@ -86,8 +88,8 @@ export type { CustomBlockInitResultErrorCode, CustomBlockInitResultErrorInfo, In
|
|
|
86
88
|
export { customBlockInitResultErrorCodeSchema, customBlockInitResultErrorInfoSchema, initResultMessageSchema, } from "./handshake/initResult.js";
|
|
87
89
|
export { isInitHandshakeMessage } from "./handshake/isInitHandshakeMessage.js";
|
|
88
90
|
export * from "./icons.js";
|
|
89
|
-
export type {
|
|
90
|
-
export {
|
|
91
|
+
export type { CustomBlockDataSourceResourceName, CustomBlockGrant, CustomBlockGrantAction, CustomBlockGrantResourceName, CustomBlockOriginResourceName, } from "./manifest/grants.js";
|
|
92
|
+
export { customBlockGrantSchema } from "./manifest/grants.js";
|
|
91
93
|
export type { BridgeCustomBlockManifest, ManifestDataSource, ManifestIcon, ManifestPage, ManifestProperty, } from "./manifest/manifest.js";
|
|
92
94
|
export { manifestDataSourceSchema, manifestIconSchema, manifestPageSchema, manifestPropertySchema, manifestSchema, } from "./manifest/manifest.js";
|
|
93
95
|
export type { HostToSandboxMessage, HostToSandboxMessageWithProtocol3To5Compatibility, } from "./messages/hostToSandbox.js";
|
|
@@ -141,8 +143,8 @@ export type { CustomBlockListUsersErrorCode, CustomBlockListUsersErrorInfo, List
|
|
|
141
143
|
export { customBlockListUsersErrorCodeSchema, customBlockListUsersErrorInfoSchema, listUsersMessageSchema, listUsersResultMessageSchema, } from "./users/messages/listUsers.js";
|
|
142
144
|
export type { NotionUserId } from "./users/userId.js";
|
|
143
145
|
export { notionUserIdSchema } from "./users/userId.js";
|
|
144
|
-
export type {
|
|
145
|
-
export {
|
|
146
|
+
export type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode, } from "./utils/errors.js";
|
|
147
|
+
export { customBlockErrorInfoSchema, NOT_GRANTED_ERROR_CODE, } from "./utils/errors.js";
|
|
146
148
|
export type { NotionAgentId, NotionBlockId, NotionDataSourceId, NotionPageId, NotionSpaceId, } from "./utils/ids.js";
|
|
147
149
|
export { notionAgentIdSchema, notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, notionSpaceIdSchema, } from "./utils/ids.js";
|
|
148
150
|
export { isLocalBlockServerUrl } from "./utils/isLocalBlockServerUrl.js";
|
package/dist/protocol/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { resizeMessageSchema } from "./context/messages/resize.js";
|
|
|
11
11
|
export { themeChangedMessageSchema } from "./context/messages/themeChanged.js";
|
|
12
12
|
export { dataSourceParentSchema, notionParentSchema, pageParentSchema, } from "./context/parent.js";
|
|
13
13
|
export { notionThemeSchema } from "./context/theme.js";
|
|
14
|
+
export { bridgeArchiveStatusSchema } from "./dataSources/bridgeArchiveStatus.js";
|
|
14
15
|
export { bridgeDataSourceBindingSchema } from "./dataSources/bridgeDataSourceBinding.js";
|
|
15
16
|
export { bridgeDataSourceBindingsSchema } from "./dataSources/bridgeDataSourceBindings.js";
|
|
16
17
|
export { notionCollectionSchemaValidator } from "./dataSources/collectionSchema.js";
|
|
@@ -43,7 +44,7 @@ export { CustomBlockInitializationError, customBlockInitErrorCodeSchema, customB
|
|
|
43
44
|
export { customBlockInitResultErrorCodeSchema, customBlockInitResultErrorInfoSchema, initResultMessageSchema, } from "./handshake/initResult.js";
|
|
44
45
|
export { isInitHandshakeMessage } from "./handshake/isInitHandshakeMessage.js";
|
|
45
46
|
export * from "./icons.js";
|
|
46
|
-
export {
|
|
47
|
+
export { customBlockGrantSchema } from "./manifest/grants.js";
|
|
47
48
|
export { manifestDataSourceSchema, manifestIconSchema, manifestPageSchema, manifestPropertySchema, manifestSchema, } from "./manifest/manifest.js";
|
|
48
49
|
export { hostToSandboxMessageSchema, hostToSandboxMessageWithProtocol3To5CompatibilitySchema, } from "./messages/hostToSandbox.js";
|
|
49
50
|
export { readIncomingType } from "./messages/incomingType.js";
|
|
@@ -67,7 +68,7 @@ export { currentUserChangedMessageSchema } from "./users/messages/currentUserCha
|
|
|
67
68
|
export { customBlockGetUserErrorCodeSchema, customBlockGetUserErrorInfoSchema, getUserMessageSchema, getUserResultMessageSchema, } from "./users/messages/getUser.js";
|
|
68
69
|
export { customBlockListUsersErrorCodeSchema, customBlockListUsersErrorInfoSchema, listUsersMessageSchema, listUsersResultMessageSchema, } from "./users/messages/listUsers.js";
|
|
69
70
|
export { notionUserIdSchema } from "./users/userId.js";
|
|
70
|
-
export {
|
|
71
|
+
export { customBlockErrorInfoSchema, NOT_GRANTED_ERROR_CODE, } from "./utils/errors.js";
|
|
71
72
|
export { notionAgentIdSchema, notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, notionSpaceIdSchema, } from "./utils/ids.js";
|
|
72
73
|
export { isLocalBlockServerUrl } from "./utils/isLocalBlockServerUrl.js";
|
|
73
74
|
export { LATEST_BRIDGE_PROTOCOL_VERSION, NATIVE_ICON_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "./utils/protocolVersion.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
|
-
* One entry in the block manifest's `
|
|
4
|
-
* (`
|
|
3
|
+
* One entry in the block manifest's `grants`: what the block needs to do
|
|
4
|
+
* (`action`) and what it acts on (`resource`). Viewers approve declared
|
|
5
5
|
* entries before the block loads.
|
|
6
6
|
*
|
|
7
|
-
* `resource` is one resource or a non-empty array of them. An array
|
|
8
|
-
* the
|
|
7
|
+
* `resource` is one resource or a non-empty array of them. An array applies
|
|
8
|
+
* the action to each element. A resource string is never split, so
|
|
9
9
|
* `"data_source:tasks,projects"` names one key.
|
|
10
10
|
*
|
|
11
11
|
* Names are open strings so a newer vocabulary never makes an older host or SDK
|
|
@@ -13,28 +13,28 @@ import * as v from "valibot";
|
|
|
13
13
|
* deploy, so the manifest a deployed block receives in `init` has string
|
|
14
14
|
* resources only.
|
|
15
15
|
*/
|
|
16
|
-
export declare const
|
|
17
|
-
readonly
|
|
16
|
+
export declare const customBlockGrantSchema: v.ObjectSchema<{
|
|
17
|
+
readonly action: v.StringSchema<undefined>;
|
|
18
18
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
19
19
|
}, undefined>;
|
|
20
|
-
export type
|
|
20
|
+
export type CustomBlockGrant = v.InferOutput<typeof customBlockGrantSchema>;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Grant actions that hosts recognize. `user` is shorthand for `user.read`
|
|
23
23
|
* and `user.read_email` on the same resource. `page` is shorthand for
|
|
24
24
|
* `page.read`, `page.insert`, `page.update`, and `page.archive` on the same
|
|
25
25
|
* resource. `page.trash` is reserved for a future Trash call and is not
|
|
26
26
|
* accepted yet.
|
|
27
27
|
*/
|
|
28
|
-
export type
|
|
28
|
+
export type CustomBlockGrantAction = "user" | "user.read" | "user.read_email" | "page" | "page.read" | "page.insert" | "page.update" | "page.archive" | "network.fetch";
|
|
29
29
|
/**
|
|
30
|
-
* Resource names that hosts recognize. User
|
|
31
|
-
* or `workspace` (every member of the workspace). Page
|
|
30
|
+
* Resource names that hosts recognize. User actions take `current_user`
|
|
31
|
+
* or `workspace` (every member of the workspace). Page actions take
|
|
32
32
|
* `workspace` (every page the viewer can access), `containing_page`,
|
|
33
33
|
* `data_source:<key>`, or `data_source` (every declared data source).
|
|
34
34
|
* `private` is reserved for a future `page.insert` into the viewer's Private
|
|
35
35
|
* section and is not accepted yet. `network.fetch` takes a bare HTTPS origin.
|
|
36
36
|
*/
|
|
37
|
-
export type
|
|
37
|
+
export type CustomBlockGrantResourceName = "current_user" | "workspace" | "containing_page" | "data_source" | CustomBlockDataSourceResourceName | CustomBlockOriginResourceName;
|
|
38
38
|
/**
|
|
39
39
|
* The data source bound to one key of the manifest's `dataSources`, such as
|
|
40
40
|
* `data_source:tasks`. The key must match a declared data source exactly.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
|
-
* One entry in the block manifest's `
|
|
4
|
-
* (`
|
|
3
|
+
* One entry in the block manifest's `grants`: what the block needs to do
|
|
4
|
+
* (`action`) and what it acts on (`resource`). Viewers approve declared
|
|
5
5
|
* entries before the block loads.
|
|
6
6
|
*
|
|
7
|
-
* `resource` is one resource or a non-empty array of them. An array
|
|
8
|
-
* the
|
|
7
|
+
* `resource` is one resource or a non-empty array of them. An array applies
|
|
8
|
+
* the action to each element. A resource string is never split, so
|
|
9
9
|
* `"data_source:tasks,projects"` names one key.
|
|
10
10
|
*
|
|
11
11
|
* Names are open strings so a newer vocabulary never makes an older host or SDK
|
|
@@ -13,7 +13,7 @@ import * as v from "valibot";
|
|
|
13
13
|
* deploy, so the manifest a deployed block receives in `init` has string
|
|
14
14
|
* resources only.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
17
|
-
|
|
16
|
+
export const customBlockGrantSchema = v.object({
|
|
17
|
+
action: v.string(),
|
|
18
18
|
resource: v.union([v.string(), v.pipe(v.array(v.string()), v.minLength(1))]),
|
|
19
19
|
});
|
|
@@ -84,17 +84,17 @@ export declare const manifestSchema: v.ObjectSchema<{
|
|
|
84
84
|
}, undefined>], undefined>, undefined>;
|
|
85
85
|
}, undefined>, undefined>, undefined>;
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
88
|
-
* approval, so hosts do not ask the viewer. An empty array declares
|
|
89
|
-
*
|
|
87
|
+
* Grants the block needs. Omitted means the block predates viewer
|
|
88
|
+
* approval, so hosts do not ask the viewer. An empty array declares
|
|
89
|
+
* nothing.
|
|
90
90
|
*/
|
|
91
|
-
readonly
|
|
92
|
-
readonly
|
|
91
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
92
|
+
readonly action: v.StringSchema<undefined>;
|
|
93
93
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
94
94
|
}, undefined>, undefined>, undefined>;
|
|
95
95
|
}, undefined>;
|
|
96
96
|
/**
|
|
97
97
|
* Manifest describing a custom block, its required data sources, and its
|
|
98
|
-
*
|
|
98
|
+
* grants.
|
|
99
99
|
*/
|
|
100
100
|
export type BridgeCustomBlockManifest = v.InferOutput<typeof manifestSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { notionPropertyTypeSchema } from "../dataSources/properties/propertySchema.js";
|
|
3
|
-
import {
|
|
3
|
+
import { customBlockGrantSchema } from "./grants.js";
|
|
4
4
|
/**
|
|
5
5
|
* Decorative icon attached to a manifest data source. Mirrors the
|
|
6
6
|
* `emoji` / `external` icon variants the public Notion API uses, so the host
|
|
@@ -41,9 +41,9 @@ export const manifestSchema = v.object({
|
|
|
41
41
|
dataSources: v.optional(v.record(v.string(), manifestDataSourceSchema), {}),
|
|
42
42
|
pages: v.optional(v.record(v.string(), manifestPageSchema)),
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* approval, so hosts do not ask the viewer. An empty array declares
|
|
46
|
-
*
|
|
44
|
+
* Grants the block needs. Omitted means the block predates viewer
|
|
45
|
+
* approval, so hosts do not ask the viewer. An empty array declares
|
|
46
|
+
* nothing.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
grants: v.optional(v.array(customBlockGrantSchema)),
|
|
49
49
|
});
|
|
@@ -84,8 +84,8 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
84
84
|
readonly url: v.StringSchema<undefined>;
|
|
85
85
|
}, undefined>], undefined>, undefined>;
|
|
86
86
|
}, undefined>, undefined>, undefined>;
|
|
87
|
-
readonly
|
|
88
|
-
readonly
|
|
87
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
88
|
+
readonly action: v.StringSchema<undefined>;
|
|
89
89
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
90
90
|
}, undefined>, undefined>, undefined>;
|
|
91
91
|
}, undefined>;
|
|
@@ -1844,8 +1844,8 @@ export declare const hostToSandboxMessageWithProtocol3To5CompatibilitySchema: v.
|
|
|
1844
1844
|
readonly url: v.StringSchema<undefined>;
|
|
1845
1845
|
}, undefined>], undefined>, undefined>;
|
|
1846
1846
|
}, undefined>, undefined>, undefined>;
|
|
1847
|
-
readonly
|
|
1848
|
-
readonly
|
|
1847
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
1848
|
+
readonly action: v.StringSchema<undefined>;
|
|
1849
1849
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
1850
1850
|
}, undefined>, undefined>, undefined>;
|
|
1851
1851
|
}, undefined>;
|
|
@@ -45,8 +45,8 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
45
45
|
readonly url: v.StringSchema<undefined>;
|
|
46
46
|
}, undefined>], undefined>, undefined>;
|
|
47
47
|
}, undefined>, undefined>, undefined>;
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
48
|
+
readonly grants: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
49
|
+
readonly action: v.StringSchema<undefined>;
|
|
50
50
|
readonly resource: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>], undefined>;
|
|
51
51
|
}, undefined>, undefined>, undefined>;
|
|
52
52
|
}, undefined>, undefined>;
|
|
@@ -587,6 +587,7 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
587
587
|
readonly propertyId: v.StringSchema<undefined>;
|
|
588
588
|
readonly direction: v.PicklistSchema<["ascending", "descending"], undefined>;
|
|
589
589
|
}, undefined>, undefined>, undefined>;
|
|
590
|
+
readonly archive_status: v.OptionalSchema<v.PicklistSchema<["active", "archived", "all"], undefined>, undefined>;
|
|
590
591
|
}, undefined>, v.ObjectSchema<{
|
|
591
592
|
readonly type: v.LiteralSchema<"unsubscribeDataSourceQuery", undefined>;
|
|
592
593
|
readonly subscriptionId: v.StringSchema<undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockCreatePageErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockCreatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "create_page_failed" | "invalid_icon_name" | "invalid_icon_color" | "invalid_page_parent" | "page_unavailable" | "data_source_access_failed" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_inaccessible" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" |
|
|
4
|
+
export type CustomBlockCreatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "create_page_failed" | "invalid_icon_name" | "invalid_icon_color" | "invalid_page_parent" | "page_unavailable" | "data_source_access_failed" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_inaccessible" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" | CustomBlockGrantErrorCode>;
|
|
5
5
|
export type CustomBlockCreatePageErrorInfo = CustomBlockErrorInfo<CustomBlockCreatePageErrorCode>;
|
|
6
6
|
export declare const customBlockCreatePageErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockGetPageErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockGetPageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "get_page_failed" | "page_unavailable" |
|
|
4
|
+
export type CustomBlockGetPageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "get_page_failed" | "page_unavailable" | CustomBlockGrantErrorCode>;
|
|
5
5
|
export type CustomBlockGetPageErrorInfo = CustomBlockErrorInfo<CustomBlockGetPageErrorCode>;
|
|
6
6
|
export declare const customBlockGetPageErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const openPageModeSchema: v.PicklistSchema<["side_peek", "center_peek"], undefined>;
|
|
4
4
|
export type OpenPageMode = v.InferOutput<typeof openPageModeSchema>;
|
|
5
5
|
export declare const customBlockOpenPageErrorCodeSchema: v.StringSchema<undefined>;
|
|
6
|
-
export type CustomBlockOpenPageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "open_page_failed" | "page_unavailable" | "navigation_unavailable" |
|
|
6
|
+
export type CustomBlockOpenPageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "open_page_failed" | "page_unavailable" | "navigation_unavailable" | CustomBlockGrantErrorCode>;
|
|
7
7
|
export type CustomBlockOpenPageErrorInfo = CustomBlockErrorInfo<CustomBlockOpenPageErrorCode>;
|
|
8
8
|
export declare const customBlockOpenPageErrorInfoSchema: v.ObjectSchema<{
|
|
9
9
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockUpdatePageErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "update_page_failed" | "previous_write_incomplete" | "invalid_page_update" | "invalid_icon_name" | "invalid_icon_color" | "page_unavailable" | "data_source_access_failed" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" |
|
|
4
|
+
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "update_page_failed" | "previous_write_incomplete" | "invalid_page_update" | "invalid_icon_name" | "invalid_icon_color" | "page_unavailable" | "data_source_access_failed" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" | CustomBlockGrantErrorCode>;
|
|
5
5
|
export type CustomBlockUpdatePageErrorInfo = CustomBlockErrorInfo<CustomBlockUpdatePageErrorCode>;
|
|
6
6
|
export declare const customBlockUpdatePageErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockGetUserErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockGetUserErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "get_user_failed" |
|
|
4
|
+
export type CustomBlockGetUserErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "get_user_failed" | CustomBlockGrantErrorCode>;
|
|
5
5
|
export type CustomBlockGetUserErrorInfo = CustomBlockErrorInfo<CustomBlockGetUserErrorCode>;
|
|
6
6
|
export declare const customBlockGetUserErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockListUsersErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockListUsersErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "list_users_failed" |
|
|
4
|
+
export type CustomBlockListUsersErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "list_users_failed" | CustomBlockGrantErrorCode>;
|
|
5
5
|
export type CustomBlockListUsersErrorInfo = CustomBlockErrorInfo<CustomBlockListUsersErrorCode>;
|
|
6
6
|
export declare const customBlockListUsersErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
export type CustomBlockErrorCode<KnownCode extends string> = KnownCode | "unknown_error" | (string & {});
|
|
3
3
|
/**
|
|
4
|
-
* Reserved for a request that needs a
|
|
5
|
-
*
|
|
4
|
+
* Reserved for a request that needs a grant the block did not declare or the
|
|
5
|
+
* viewer did not approve. No host sends it yet.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
8
|
-
export type
|
|
7
|
+
export declare const NOT_GRANTED_ERROR_CODE = "not_granted";
|
|
8
|
+
export type CustomBlockGrantErrorCode = typeof NOT_GRANTED_ERROR_CODE;
|
|
9
9
|
export type CustomBlockErrorInfo<TCode extends string = string> = {
|
|
10
10
|
code: TCode;
|
|
11
11
|
message: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
/**
|
|
3
|
-
* Reserved for a request that needs a
|
|
4
|
-
*
|
|
3
|
+
* Reserved for a request that needs a grant the block did not declare or the
|
|
4
|
+
* viewer did not approve. No host sends it yet.
|
|
5
5
|
*/
|
|
6
|
-
export const
|
|
6
|
+
export const NOT_GRANTED_ERROR_CODE = "not_granted";
|
|
7
7
|
export const customBlockErrorInfoSchema = v.object({
|
|
8
8
|
code: v.string(),
|
|
9
9
|
message: v.string(),
|
package/docs/bridge/protocol.md
CHANGED
|
@@ -139,6 +139,8 @@ without sending a message.
|
|
|
139
139
|
|
|
140
140
|
### Query requests
|
|
141
141
|
|
|
142
|
+
`queryDataSource.archive_status` accepts `active`, `archived`, or `all`. It defaults to `active`.
|
|
143
|
+
|
|
142
144
|
`queryDataSource` may include a resolved `filter` and an ordered `sorts` list. Each sort contains a
|
|
143
145
|
raw `propertyId` and an `ascending` or `descending` direction. Hosts apply sorts in array order. The
|
|
144
146
|
SDK and host validate that the list contains at most ten unique properties. The host rejects
|
|
@@ -183,21 +185,20 @@ filter: {
|
|
|
183
185
|
}
|
|
184
186
|
```
|
|
185
187
|
|
|
186
|
-
##
|
|
188
|
+
## Grants
|
|
187
189
|
|
|
188
|
-
`manifest.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
predates approval.
|
|
190
|
+
`manifest.grants` lists `{ action, resource }` declarations. `action` is an open string and
|
|
191
|
+
`resource` is an open string or a non-empty array of them, so a newer vocabulary never makes an
|
|
192
|
+
older receiver reject a manifest. An array applies the action to each element. Receivers never split
|
|
193
|
+
a resource string on commas. An omitted `grants` marks a block that predates approval.
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
Resources for page actions can name one manifest data source as `data_source:<key>`. The key is the
|
|
195
196
|
semantic key from `manifest.dataSources`; hosts resolve it to the bound data source when they record
|
|
196
197
|
and check grants. Bare `data_source` covers every declared key.
|
|
197
198
|
|
|
198
|
-
The `
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
The `not_granted` error code is reserved for a request that the viewer's grants do not cover, with
|
|
200
|
+
`isRetryable: false`. No adapter sends it yet, and no receiver restricts requests by grant. The
|
|
201
|
+
SDK's grants guide documents the vocabulary.
|
|
201
202
|
|
|
202
203
|
## Page context
|
|
203
204
|
|