react-semaphor 0.1.318 → 0.1.319
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/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +497 -364
- package/dist/chunks/{calendar-preferences-dialog-DySStYHa.js → calendar-preferences-dialog-DLKB05SY.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-DgpoCz1l.js → calendar-preferences-dialog-DPaVsZlk.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-BrUNYrwk.js → dashboard-briefing-launcher-DR_i0anv.js} +3164 -2537
- package/dist/chunks/dashboard-briefing-launcher-F3qKyuGr.js +106 -0
- package/dist/chunks/{dashboard-controls-BJb7QHvl.js → dashboard-controls-8J06Ot-K.js} +3 -3
- package/dist/chunks/{dashboard-controls-CDCpt8iB.js → dashboard-controls-BNAIucBl.js} +1 -1
- package/dist/chunks/{dashboard-json-BYEqzs6b.js → dashboard-json-B_Li7wO5.js} +1 -1
- package/dist/chunks/{dashboard-json-BjFw0Ktj.js → dashboard-json-DIsACFCO.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-IxtXVkBc.js → edit-dashboard-visual-2CBS2I52.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-VHlDJd5A.js → edit-dashboard-visual-BGnC2DH7.js} +3 -3
- package/dist/chunks/{index-CAWSZGCL.js → index-DYycYzpZ.js} +289 -288
- package/dist/chunks/{index-BhrZn1Zk.js → index-cxoegFH9.js} +75 -75
- package/dist/chunks/{resource-management-panel-X4zxZ4wq.js → resource-management-panel-BwNGxqrB.js} +1 -1
- package/dist/chunks/{resource-management-panel-0OlH_Gze.js → resource-management-panel-YtbKp2kW.js} +2 -2
- package/dist/chunks/{use-create-flow-overlay-state-DkZTa6eN.js → use-create-flow-overlay-state-DQZneUXL.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-WYyQFfGQ.js → use-create-flow-overlay-state-Qnd7FF6L.js} +2 -2
- package/dist/chunks/{use-visual-utils-2l8uDXRH.js → use-visual-utils-BdMhr0YR.js} +1 -1
- package/dist/chunks/{use-visual-utils-C8VR6_Cr.js → use-visual-utils-t73RlvjS.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/briefings.d.ts +29 -1
- package/dist/types/main.d.ts +29 -1
- package/dist/types/types.d.ts +29 -1
- package/package.json +1 -1
- package/dist/chunks/dashboard-briefing-launcher-Fh6vC1S2.js +0 -101
package/dist/briefings/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty;var q=(t,n,e)=>n in t?U(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var R=(t,n,e)=>q(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v="BRIEFING",O=["markdown","html"],A=["markdown"],$=20,c={name:500,description:2e3,instruction:5e4,customMessage:5e4,attachmentTitle:500,presentationAudience:1e3,presentationTone:500,presentationFormat:2e3,id:500},x=new Set(O),H=new Set(["EMAIL","WEBHOOK","SLACK","IN_APP","TELEGRAM"]),T={maxToolCalls:{min:1,max:100},maxRows:{min:1,max:1e5},timeoutMs:{min:1e3,max:30*6e4}},K=new Set(["letter","legal","a4","a3","tabloid"]),J=new Set(["portrait","landscape"]),X=new Set([",",";"," "]),W=["pageSize","orientation","includeFilters","includeTimestamp","delimiter","includeHeaders","useFormattedValues","sheetSelection","currentSheetId","currentSheetName","filterValues","inlineFilterValues","sheetFilterValues","filterLine","controlValues","controlDefinitions","cardControlDefinitions","controlBindings","tablePreferences","dashboardInputExecutionSnapshot","selectedSheetId","cardType","theme"];class C extends Error{constructor(e){super(e.map(r=>`${r.field}: ${r.message}`).join("; "));R(this,"issues");this.name="BriefingContractError",this.issues=e}}function D(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function d(t,n,e){t.push({field:n,message:e})}function m(t,n,e){return D(t)?t:(d(e,n,"Expected an object."),{})}function s(t,n,e,r){const o=new Set(e);Object.keys(t).forEach(i=>{o.has(i)||d(r,n?`${n}.${i}`:i,`Unexpected field "${i}".`)})}function f(t,n,e,r){if(typeof t!="string")return d(r,n,"Expected a string."),"";const o=t.trim();return o?(o.length>e&&d(r,n,`Must be ${e} characters or fewer.`),o):(d(r,n,"Required value cannot be empty."),"")}function u(t,n,e,r){if(t==null)return;if(typeof t!="string"){d(r,n,"Expected a string.");return}const o=t.trim();if(o)return o.length>e&&d(r,n,`Must be ${e} characters or fewer.`),o}function _(t,n,e,r){return t==null?n:typeof t!="boolean"?(d(r,e,"Expected a boolean."),n):t}function Y(t,n){return t==null?"ACTIVE":t==="ACTIVE"||t==="PAUSED"||t==="DISABLED"?t:(d(n,"status","Expected ACTIVE, PAUSED, or DISABLED."),"ACTIVE")}function Z(t){return t.includes("@")&&t.includes(".")&&!t.includes(" ")}function N(t,n){if(t==null)return{type:"project"};const e=m(t,"source",n),r=e.type;return r==="project"?(s(e,"source",["type"],n),{type:"project"}):r==="dashboard"?(s(e,"source",["type","dashboardId"],n),{type:"dashboard",dashboardId:f(e.dashboardId,"source.dashboardId",c.id,n)}):(d(n,"source.type","Expected project or dashboard."),{type:"project"})}function V(t,n){const e=m(t,"body",n),r=e.type;return r==="generated_analysis"?(s(e,"body",["type","instruction"],n),{type:"generated_analysis",instruction:f(e.instruction,"body.instruction",c.instruction,n)}):r==="custom_message"?(s(e,"body",["type","message"],n),{type:"custom_message",message:f(e.message,"body.message",c.customMessage,n)}):r==="none"?(s(e,"body",["type"],n),{type:"none"}):(d(n,"body.type","Expected generated_analysis, custom_message, or none."),{type:"none"})}function Q(t,n){if(t==null)return[...A];if(!Array.isArray(t))return d(n,"presentation.artifactFormats","Expected an array."),[...A];if(t.length===0)return d(n,"presentation.artifactFormats","Choose at least one artifact format."),[];const e=[];return t.forEach((r,o)=>{if(typeof r!="string"||!x.has(r)){d(n,`presentation.artifactFormats.${o}`,"Expected markdown or html.");return}e.includes(r)||e.push(r)}),e}function j(t,n){if(t==null)return{artifactFormats:[...A],includeEvidence:!0,includeSql:!0};const e=m(t,"presentation",n);s(e,"presentation",["artifactFormats","includeEvidence","includeSql","audience","tone","format"],n);const r={artifactFormats:Q(e.artifactFormats,n),includeEvidence:_(e.includeEvidence,!0,"presentation.includeEvidence",n),includeSql:_(e.includeSql,!0,"presentation.includeSql",n)},o=u(e.audience,"presentation.audience",c.presentationAudience,n),i=u(e.tone,"presentation.tone",c.presentationTone,n),a=u(e.format,"presentation.format",c.presentationFormat,n);return o&&(r.audience=o),i&&(r.tone=i),a&&(r.format=a),r}function g(t,n,e,r){return typeof t=="string"&&e.includes(t)?t:(d(r,n,`Expected ${e.join(" or ")}.`),e[0])}function I(t,n,e,r,o){if(t!=null){if(typeof t=="string"&&e.has(t))return t;d(o,n,`Expected ${r}.`)}}function ee(t,n,e){if(t!=null){if(!Array.isArray(t)){d(e,n,"Expected an array.");return}return t}}function te(t,n,e){if(t!=null){if(!D(t)){d(e,n,"Expected an object.");return}return t}}function ne(t,n,e){if(t==null)return;const r=m(t,n,e);s(r,n,W,e);const o={},i=I(r.pageSize,`${n}.pageSize`,K,"letter, legal, a4, a3, or tabloid",e),a=I(r.orientation,`${n}.orientation`,J,"portrait or landscape",e),p=I(r.delimiter,`${n}.delimiter`,X,"comma, semicolon, or tab",e),y=I(r.sheetSelection,`${n}.sheetSelection`,new Set(["current","all"]),"current or all",e);i&&(o.pageSize=i),a&&(o.orientation=a),p&&(o.delimiter=p),y&&(o.sheetSelection=y);for(const l of["includeFilters","includeTimestamp","includeHeaders","useFormattedValues"])if(!(r[l]===void 0||r[l]===null)){if(typeof r[l]!="boolean"){d(e,`${n}.${l}`,"Expected a boolean.");continue}o[l]=r[l]}for(const l of["currentSheetId","currentSheetName","filterLine","selectedSheetId","cardType","theme"]){const h=u(r[l],`${n}.${l}`,c.id,e);h&&(o[l]=h)}for(const l of["filterValues","inlineFilterValues","sheetFilterValues","controlDefinitions","cardControlDefinitions","controlBindings"]){const h=ee(r[l],`${n}.${l}`,e);h&&(o[l]=h)}for(const l of["controlValues","tablePreferences","dashboardInputExecutionSnapshot"]){const h=te(r[l],`${n}.${l}`,e);h&&(o[l]=h)}return Object.keys(o).length>0?o:void 0}function b(t,n,e,r){const o=u(n,e,c.attachmentTitle,r);return o&&(t.title=o),t}function E(t,n,e,r){const o=ne(n,e,r);return o&&(t.settings=o),t}function re(t,n,e){const r=`attachments.${n}`,o=m(t,r,e),i=o.type;if(i==="dashboard"){s(o,r,["type","dashboardId","format","title","settings"],e);const a=b({type:"dashboard",dashboardId:f(o.dashboardId,`${r}.dashboardId`,c.id,e),format:g(o.format,`${r}.format`,["pdf"],e)},o.title,`${r}.title`,e);return E(a,o.settings,`${r}.settings`,e)}if(i==="dashboard_sheet"||i==="document_sheet"){s(o,r,["type","dashboardId","sheetId","format","title","settings"],e);const a=b({type:i,dashboardId:f(o.dashboardId,`${r}.dashboardId`,c.id,e),sheetId:f(o.sheetId,`${r}.sheetId`,c.id,e),format:g(o.format,`${r}.format`,["pdf"],e)},o.title,`${r}.title`,e);return E(a,o.settings,`${r}.settings`,e)}if(i==="visual"){s(o,r,["type","dashboardId","visualId","format","title","settings"],e);const a=b({type:"visual",dashboardId:f(o.dashboardId,`${r}.dashboardId`,c.id,e),visualId:f(o.visualId,`${r}.visualId`,c.id,e),format:g(o.format,`${r}.format`,["pdf","png"],e)},o.title,`${r}.title`,e);return E(a,o.settings,`${r}.settings`,e)}if(i==="card"){s(o,r,["type","dashboardId","cardId","format","title","settings"],e);const a=b({type:"card",dashboardId:f(o.dashboardId,`${r}.dashboardId`,c.id,e),cardId:f(o.cardId,`${r}.cardId`,c.id,e),format:g(o.format,`${r}.format`,["csv","pdf","png"],e)},o.title,`${r}.title`,e);return E(a,o.settings,`${r}.settings`,e)}return d(e,`${r}.type`,"Expected dashboard, dashboard_sheet, document_sheet, visual, or card."),{type:"dashboard",dashboardId:"",format:"pdf"}}function oe(t){switch(t.type){case"dashboard":return`${t.type}:${t.dashboardId}:${t.format}`;case"dashboard_sheet":case"document_sheet":return`${t.type}:${t.dashboardId}:${t.sheetId}:${t.format}`;case"visual":return`${t.type}:${t.dashboardId}:${t.visualId}:${t.format}`;case"card":return`${t.type}:${t.dashboardId}:${t.cardId}:${t.format}`}}function w(t,n){if(t==null)return[];if(!Array.isArray(t))return d(n,"attachments","Expected an array."),[];t.length>$&&d(n,"attachments",`Choose ${$} attachments or fewer.`);const e=t.slice(0,$).map((o,i)=>re(o,i,n)),r=new Set;return e.forEach((o,i)=>{const a=oe(o);r.has(a)&&d(n,`attachments.${i}`,"Duplicate attachment."),r.add(a)}),e}function M(t,n){if(t==null)return;const e=m(t,"limits",n);s(e,"limits",Object.keys(T),n);const r={};return Object.keys(T).forEach(o=>{const i=e[o];if(i==null)return;const a=T[o];if(typeof i!="number"||!Number.isInteger(i)||i<a.min||i>a.max){d(n,`limits.${o}`,`Expected an integer between ${a.min} and ${a.max}.`);return}r[o]=i}),Object.keys(r).length>0?r:void 0}function k(t){if(t.length>0)throw new C(t)}function L(t,n,e){t.type==="none"&&n.length===0&&d(e,"body","Add briefing instructions, a custom message, or at least one attachment.")}function B(t){const n=[],e=m(t,"jobConfig",n);s(e,"jobConfig",["kind","source","body","attachments","presentation","limits"],n),e.kind!==v&&d(n,"kind","Expected BRIEFING.");const r=N(e.source,n),o=V(e.body,n),i=w(e.attachments,n),a=j(e.presentation,n),p=M(e.limits,n);return L(o,i,n),k(n),{kind:v,source:r,body:o,attachments:i,presentation:a,...p?{limits:p}:{}}}function ie(t){return B({...t,kind:v})}function ae(t,n,e){const r=`deliveryConfig.recipients.${n}`,o=m(t,r,e),i=o.type;if(i==="email"){s(o,r,["type","address","name"],e);const a=f(o.address,`${r}.address`,c.id,e),p=u(o.name,`${r}.name`,c.attachmentTitle,e);return a&&!Z(a)&&d(e,`${r}.address`,"Email address is invalid."),{type:"email",address:a,...p?{name:p}:{}}}return i==="user"?(s(o,r,["type","userId"],e),{type:"user",userId:f(o.userId,`${r}.userId`,c.id,e)}):i==="tenant_user"?(s(o,r,["type","tenantUserId"],e),{type:"tenant_user",tenantUserId:f(o.tenantUserId,`${r}.tenantUserId`,c.id,e)}):i==="group"?(s(o,r,["type","groupId"],e),{type:"group",groupId:f(o.groupId,`${r}.groupId`,c.id,e)}):(d(e,`${r}.type`,"Expected email, user, tenant_user, or group."),{type:"email",address:""})}function de(t,n){return Array.isArray(t)?t.map((e,r)=>ae(e,r,n)):(d(n,"deliveryConfig.recipients","Expected an array."),[])}function ce(t,n){if(!Array.isArray(t))return d(n,"deliveryConfig.channels","Expected an array."),[];const e=[];return t.forEach((r,o)=>{if(!F(r)){d(n,`deliveryConfig.channels.${o}`,"Expected EMAIL, WEBHOOK, SLACK, IN_APP, or TELEGRAM.");return}e.includes(r)||e.push(r)}),e}function le(t,n,e){if(t==null)return;const r=m(t,n,e),o={};return Object.entries(r).forEach(([i,a])=>{if(typeof a!="string"){d(e,`${n}.${i}`,"Expected a string.");return}o[i]=a.trim()}),Object.keys(o).length>0?o:void 0}function se(t,n,e){if(t==null)return;const r=m(t,n,e);s(r,n,["url","method","headers","secretEncrypted"],e);const o=r.method===void 0||r.method===null?void 0:g(r.method,`${n}.method`,["POST","PUT"],e),i=le(r.headers,`${n}.headers`,e),a=u(r.secretEncrypted,`${n}.secretEncrypted`,2e3,e);return{url:f(r.url,`${n}.url`,2e3,e),...o?{method:o}:{},...i?{headers:i}:{},...a?{secretEncrypted:a}:{}}}function fe(t,n,e){const r=m(t,n,e);s(r,n,["subjectOverride","titleOverride","summaryOverride","actionBlockVisible","webhookConfig"],e);const o=u(r.subjectOverride,`${n}.subjectOverride`,500,e),i=u(r.titleOverride,`${n}.titleOverride`,500,e),a=u(r.summaryOverride,`${n}.summaryOverride`,2e3,e),p=_(r.actionBlockVisible,!0,`${n}.actionBlockVisible`,e),y=se(r.webhookConfig,`${n}.webhookConfig`,e);return{...o?{subjectOverride:o}:{},...i?{titleOverride:i}:{},...a?{summaryOverride:a}:{},...r.actionBlockVisible!==void 0?{actionBlockVisible:p}:{},...y?{webhookConfig:y}:{}}}function me(t,n){if(t==null)return;const e=m(t,"deliveryConfig.channelConfigs",n),r={};return Object.entries(e).forEach(([o,i])=>{if(!F(o)){d(n,`deliveryConfig.channelConfigs.${o}`,"Expected a supported delivery channel.");return}r[o]=fe(i,`deliveryConfig.channelConfigs.${o}`,n)}),Object.keys(r).length>0?r:void 0}function ue(t,n){if(t==null)return null;const e=m(t,"deliveryConfig",n);s(e,"deliveryConfig",["recipients","channels","channelConfigs"],n);const r=me(e.channelConfigs,n),o=de(e.recipients,n),i=ce(e.channels,n);return o.length===0&&d(n,"deliveryConfig.recipients","Add at least one recipient or remove delivery config."),i.length===0&&d(n,"deliveryConfig.channels","Choose at least one delivery channel or remove delivery config."),{recipients:o,channels:i,...r?{channelConfigs:r}:{}}}function S(t){const n=[],e=m(t,"draft",n);s(e,"draft",["name","description","status","scheduleExpr","timezone","source","body","attachments","presentation","limits","deliveryConfig"],n);const r=f(e.name,"name",c.name,n),o=u(e.description,"description",c.description,n)??null,i=u(e.scheduleExpr,"scheduleExpr",500,n)??null,a=u(e.timezone,"timezone",200,n)??"UTC",p=Y(e.status,n),y=N(e.source,n),l=V(e.body,n),h=w(e.attachments,n),P=j(e.presentation,n),z=M(e.limits,n),G=ue(e.deliveryConfig,n);return L(l,h,n),k(n),{name:r,description:o,status:p,scheduleExpr:i,timezone:a,source:y,body:l,attachments:h,presentation:P,...z?{limits:z}:{},deliveryConfig:G}}function pe(t){return S(t)}function he(t){return S(t)}function ye(t){try{return{valid:!0,value:S(t),issues:[]}}catch(n){if(n instanceof C)return{valid:!1,issues:n.issues};throw n}}function ge(t){try{return{valid:!0,value:B(t),issues:[]}}catch(n){if(n instanceof C)return{valid:!1,issues:n.issues};throw n}}function Ie(t){return typeof t=="string"&&x.has(t)}function F(t){return typeof t=="string"&&H.has(t)}exports.BRIEFING_ARTIFACT_FORMATS=O;exports.BRIEFING_KIND=v;exports.BRIEFING_TEXT_LIMITS=c;exports.BriefingContractError=C;exports.DEFAULT_BRIEFING_ARTIFACT_FORMATS=A;exports.MAX_BRIEFING_ATTACHMENTS=$;exports.buildBriefingJobConfig=ie;exports.buildCreateBriefingRequest=pe;exports.buildUpdateBriefingRequest=he;exports.isBriefingArtifactFormat=Ie;exports.isBriefingDeliveryChannel=F;exports.normalizeBriefingDraft=S;exports.normalizeBriefingJobConfig=B;exports.validateBriefingDraft=ye;exports.validateBriefingJobConfig=ge;
|
|
1
|
+
"use strict";var q=Object.defineProperty;var U=(n,t,e)=>t in n?q(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var R=(n,t,e)=>U(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C="BRIEFING",z=["markdown","html"],A=["markdown"],$=20,l={name:500,description:2e3,instruction:5e4,customMessage:5e4,attachmentTitle:500,presentationAudience:1e3,presentationTone:500,presentationFormat:2e3,id:500},O=new Set(z),H=new Set(["EMAIL","WEBHOOK","SLACK","IN_APP","TELEGRAM"]),B={maxToolCalls:{min:1,max:100},maxRows:{min:1,max:1e5},timeoutMs:{min:1e3,max:30*6e4}},J=new Set(["letter","legal","a4","a3","tabloid"]),X=new Set(["portrait","landscape"]),W=new Set([",",";"," "]),Y=new Set(["current","all"]),Z=new Set(["concise","balanced","detailed"]),Q=["pageSize","orientation","includeFilters","includeTimestamp","delimiter","includeHeaders","useFormattedValues","sheetSelection","currentSheetId","currentSheetName","filterValues","inlineFilterValues","sheetFilterValues","filterLine","controlValues","controlDefinitions","cardControlDefinitions","controlBindings","tablePreferences","dashboardInputExecutionSnapshot","selectedSheetId","cardType","theme"];class S extends Error{constructor(e){super(e.map(r=>`${r.field}: ${r.message}`).join("; "));R(this,"issues");this.name="BriefingContractError",this.issues=e}}function x(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function c(n,t,e){n.push({field:t,message:e})}function h(n,t,e){return x(n)?n:(c(e,t,"Expected an object."),{})}function s(n,t,e,r){const o=new Set(e);Object.keys(n).forEach(i=>{o.has(i)||c(r,t?`${t}.${i}`:i,`Unexpected field "${i}".`)})}function u(n,t,e,r){if(typeof n!="string")return c(r,t,"Expected a string."),"";const o=n.trim();return o?(o.length>e&&c(r,t,`Must be ${e} characters or fewer.`),o):(c(r,t,"Required value cannot be empty."),"")}function p(n,t,e,r){if(n==null)return;if(typeof n!="string"){c(r,t,"Expected a string.");return}const o=n.trim();if(o)return o.length>e&&c(r,t,`Must be ${e} characters or fewer.`),o}function g(n,t,e,r){return n==null?t:typeof n!="boolean"?(c(r,e,"Expected a boolean."),t):n}function ee(n,t){return n==null?"ACTIVE":n==="ACTIVE"||n==="PAUSED"||n==="DISABLED"?n:(c(t,"status","Expected ACTIVE, PAUSED, or DISABLED."),"ACTIVE")}function te(n){return n.includes("@")&&n.includes(".")&&!n.includes(" ")}function N(n,t){if(n==null)return{type:"project"};const e=h(n,"source",t),r=e.type;return r==="project"?(s(e,"source",["type"],t),{type:"project"}):r==="dashboard"?(s(e,"source",["type","dashboardId"],t),{type:"dashboard",dashboardId:u(e.dashboardId,"source.dashboardId",l.id,t)}):(c(t,"source.type","Expected project or dashboard."),{type:"project"})}function M(n,t){const e=h(n,"body",t),r=e.type;return r==="generated_analysis"?(s(e,"body",["type","instruction"],t),{type:"generated_analysis",instruction:u(e.instruction,"body.instruction",l.instruction,t)}):r==="custom_message"?(s(e,"body",["type","message"],t),{type:"custom_message",message:u(e.message,"body.message",l.customMessage,t)}):r==="none"?(s(e,"body",["type"],t),{type:"none"}):(c(t,"body.type","Expected generated_analysis, custom_message, or none."),{type:"none"})}function ne(n,t){if(n==null)return[...A];if(!Array.isArray(n))return c(t,"presentation.artifactFormats","Expected an array."),[...A];if(n.length===0)return c(t,"presentation.artifactFormats","Choose at least one artifact format."),[];const e=[];return n.forEach((r,o)=>{if(typeof r!="string"||!O.has(r)){c(t,`presentation.artifactFormats.${o}`,"Expected markdown or html.");return}e.includes(r)||e.push(r)}),e}function V(n,t){if(n==null)return{artifactFormats:[...A],includeEvidence:!0,includeSql:!0};const e=h(n,"presentation",t);s(e,"presentation",["artifactFormats","includeEvidence","includeSql","audience","tone","format"],t);const r={artifactFormats:ne(e.artifactFormats,t),includeEvidence:g(e.includeEvidence,!0,"presentation.includeEvidence",t),includeSql:g(e.includeSql,!0,"presentation.includeSql",t)},o=p(e.audience,"presentation.audience",l.presentationAudience,t),i=p(e.tone,"presentation.tone",l.presentationTone,t),a=p(e.format,"presentation.format",l.presentationFormat,t);return o&&(r.audience=o),i&&(r.tone=i),a&&(r.format=a),r}function I(n,t,e,r){return typeof n=="string"&&e.includes(n)?n:(c(r,t,`Expected ${e.join(" or ")}.`),e[0])}function b(n,t,e,r,o){if(n!=null){if(typeof n=="string"&&e.has(n))return n;c(o,t,`Expected ${r}.`)}}function re(n,t,e){if(n!=null){if(!Array.isArray(n)){c(e,t,"Expected an array.");return}return n}}function oe(n,t,e){if(n!=null){if(!x(n)){c(e,t,"Expected an object.");return}return n}}function ie(n,t,e){if(n==null)return;const r=h(n,t,e);s(r,t,Q,e);const o={},i=b(r.pageSize,`${t}.pageSize`,J,"letter, legal, a4, a3, or tabloid",e),a=b(r.orientation,`${t}.orientation`,X,"portrait or landscape",e),f=b(r.delimiter,`${t}.delimiter`,W,"comma, semicolon, or tab",e),y=b(r.sheetSelection,`${t}.sheetSelection`,Y,"current or all",e);i&&(o.pageSize=i),a&&(o.orientation=a),f&&(o.delimiter=f),y&&(o.sheetSelection=y);for(const d of["includeFilters","includeTimestamp","includeHeaders","useFormattedValues"])if(!(r[d]===void 0||r[d]===null)){if(typeof r[d]!="boolean"){c(e,`${t}.${d}`,"Expected a boolean.");continue}o[d]=r[d]}for(const d of["currentSheetId","currentSheetName","filterLine","selectedSheetId","cardType","theme"]){const m=p(r[d],`${t}.${d}`,l.id,e);m&&(o[d]=m)}for(const d of["filterValues","inlineFilterValues","sheetFilterValues","controlDefinitions","cardControlDefinitions","controlBindings"]){const m=re(r[d],`${t}.${d}`,e);m&&(o[d]=m)}for(const d of["controlValues","tablePreferences","dashboardInputExecutionSnapshot"]){const m=oe(r[d],`${t}.${d}`,e);m&&(o[d]=m)}return Object.keys(o).length>0?o:void 0}function E(n,t,e,r){const o=p(t,e,l.attachmentTitle,r);return o&&(n.title=o),n}function v(n,t,e,r){const o=ie(t,e,r);return o&&(n.settings=o),n}function ae(n,t,e){const r=`attachments.${t}`,o=h(n,r,e),i=o.type;if(i==="dashboard"){s(o,r,["type","dashboardId","format","title","settings"],e);const a=E({type:"dashboard",dashboardId:u(o.dashboardId,`${r}.dashboardId`,l.id,e),format:I(o.format,`${r}.format`,["pdf"],e)},o.title,`${r}.title`,e);return v(a,o.settings,`${r}.settings`,e)}if(i==="dashboard_sheet"||i==="document_sheet"){s(o,r,["type","dashboardId","sheetId","format","title","settings"],e);const a=E({type:i,dashboardId:u(o.dashboardId,`${r}.dashboardId`,l.id,e),sheetId:u(o.sheetId,`${r}.sheetId`,l.id,e),format:I(o.format,`${r}.format`,["pdf"],e)},o.title,`${r}.title`,e);return v(a,o.settings,`${r}.settings`,e)}if(i==="visual"){s(o,r,["type","dashboardId","visualId","format","title","settings"],e);const a=E({type:"visual",dashboardId:u(o.dashboardId,`${r}.dashboardId`,l.id,e),visualId:u(o.visualId,`${r}.visualId`,l.id,e),format:I(o.format,`${r}.format`,["pdf","png"],e)},o.title,`${r}.title`,e);return v(a,o.settings,`${r}.settings`,e)}if(i==="card"){s(o,r,["type","dashboardId","cardId","format","title","settings"],e);const a=E({type:"card",dashboardId:u(o.dashboardId,`${r}.dashboardId`,l.id,e),cardId:u(o.cardId,`${r}.cardId`,l.id,e),format:I(o.format,`${r}.format`,["csv","pdf","png"],e)},o.title,`${r}.title`,e);return v(a,o.settings,`${r}.settings`,e)}return c(e,`${r}.type`,"Expected dashboard, dashboard_sheet, document_sheet, visual, or card."),{type:"dashboard",dashboardId:"",format:"pdf"}}function ce(n){switch(n.type){case"dashboard":return`${n.type}:${n.dashboardId}:${n.format}`;case"dashboard_sheet":case"document_sheet":return`${n.type}:${n.dashboardId}:${n.sheetId}:${n.format}`;case"visual":return`${n.type}:${n.dashboardId}:${n.visualId}:${n.format}`;case"card":return`${n.type}:${n.dashboardId}:${n.cardId}:${n.format}`}}function P(n,t){if(n==null)return[];if(!Array.isArray(n))return c(t,"attachments","Expected an array."),[];n.length>$&&c(t,"attachments",`Choose ${$} attachments or fewer.`);const e=n.slice(0,$).map((o,i)=>ae(o,i,t)),r=new Set;return e.forEach((o,i)=>{const a=ce(o);r.has(a)&&c(t,`attachments.${i}`,"Duplicate attachment."),r.add(a)}),e}function j(n,t){if(n==null)return;const e=h(n,"limits",t);s(e,"limits",Object.keys(B),t);const r={};return Object.keys(B).forEach(o=>{const i=e[o];if(i==null)return;const a=B[o];if(typeof i!="number"||!Number.isInteger(i)||i<a.min||i>a.max){c(t,`limits.${o}`,`Expected an integer between ${a.min} and ${a.max}.`);return}r[o]=i}),Object.keys(r).length>0?r:void 0}function w(n){if(n.length>0)throw new S(n)}function K(n,t,e){n.type==="none"&&t.length===0&&c(e,"body","Add briefing instructions, a custom message, or at least one attachment.")}function L(n){const t=[],e=h(n,"jobConfig",t);s(e,"jobConfig",["kind","source","body","attachments","presentation","limits"],t),e.kind!==C&&c(t,"kind","Expected BRIEFING.");const r=N(e.source,t),o=M(e.body,t),i=P(e.attachments,t),a=V(e.presentation,t),f=j(e.limits,t);return K(o,i,t),w(t),{kind:C,source:r,body:o,attachments:i,presentation:a,...f?{limits:f}:{}}}function de(n){return L({...n,kind:C})}function k(n,t,e,r="deliveryConfig.recipients"){const o=`${r}.${t}`,i=h(n,o,e),a=i.type;if(a==="email"){s(i,o,["type","address","name"],e);const f=u(i.address,`${o}.address`,l.id,e),y=p(i.name,`${o}.name`,l.attachmentTitle,e);return f&&!te(f)&&c(e,`${o}.address`,"Email address is invalid."),{type:"email",address:f,...y?{name:y}:{}}}return a==="user"?(s(i,o,["type","userId"],e),{type:"user",userId:u(i.userId,`${o}.userId`,l.id,e)}):a==="tenant_user"?(s(i,o,["type","tenantUserId"],e),{type:"tenant_user",tenantUserId:u(i.tenantUserId,`${o}.tenantUserId`,l.id,e)}):a==="group"?(s(i,o,["type","groupId"],e),{type:"group",groupId:u(i.groupId,`${o}.groupId`,l.id,e)}):(c(e,`${o}.type`,"Expected email, user, tenant_user, or group."),{type:"email",address:""})}function le(n,t){return n==null?[]:Array.isArray(n)?n.map((e,r)=>k(e,r,t)):(c(t,"deliveryConfig.recipients","Expected an array."),[])}function se(n,t){if(!Array.isArray(n))return c(t,"deliveryConfig.channels","Expected an array."),[];const e=[];return n.forEach((r,o)=>{if(!D(r)){c(t,`deliveryConfig.channels.${o}`,"Expected EMAIL, WEBHOOK, SLACK, IN_APP, or TELEGRAM.");return}e.includes(r)||e.push(r)}),e}function fe(n,t,e){if(n==null)return;const r=h(n,t,e),o={};return Object.entries(r).forEach(([i,a])=>{if(typeof a!="string"){c(e,`${t}.${i}`,"Expected a string.");return}o[i]=a.trim()}),Object.keys(o).length>0?o:void 0}function me(n,t,e){if(n==null)return;const r=h(n,t,e);s(r,t,["url","method","headers","secretEncrypted"],e);const o=r.method===void 0||r.method===null?void 0:I(r.method,`${t}.method`,["POST","PUT"],e),i=fe(r.headers,`${t}.headers`,e),a=p(r.secretEncrypted,`${t}.secretEncrypted`,2e3,e);return{url:u(r.url,`${t}.url`,2e3,e),...o?{method:o}:{},...i?{headers:i}:{},...a?{secretEncrypted:a}:{}}}function ue(n,t,e){const r=h(n,t,e),o=r.type;if(o==="channel"){s(r,t,["type","channelId","channelName","isPrivate"],e);const i=p(r.channelName,`${t}.channelName`,l.attachmentTitle,e),a=r.isPrivate===void 0||r.isPrivate===null?void 0:g(r.isPrivate,!1,`${t}.isPrivate`,e);return{type:"channel",channelId:u(r.channelId,`${t}.channelId`,l.id,e),...i?{channelName:i}:{},...a!==void 0?{isPrivate:a}:{}}}return o==="dm"?(s(r,t,["type","recipient"],e),c(e,`${t}.type`,"Slack DM delivery is not supported in V1."),{type:"dm",recipient:k(r.recipient,0,e,`${t}.recipient`)}):(c(e,`${t}.type`,"Expected channel."),{type:"channel",channelId:""})}function he(n,t,e){if(n==null)return;if(!Array.isArray(n)){c(e,t,"Expected an array.");return}const r=n.map((o,i)=>k(o,i,e,t));return r.length>0?r:void 0}function pe(n,t,e){if(n==null)return;const r=h(n,t,e);s(r,t,["destination","threadMentions","postThreadDetail","includeDashboardLink","includeBriefingLink"],e);const o=he(r.threadMentions,`${t}.threadMentions`,e),i=g(r.postThreadDetail,!0,`${t}.postThreadDetail`,e),a=g(r.includeDashboardLink,!0,`${t}.includeDashboardLink`,e),f=g(r.includeBriefingLink,!0,`${t}.includeBriefingLink`,e);return{destination:ue(r.destination,`${t}.destination`,e),...o?{threadMentions:o}:{},...r.postThreadDetail!==void 0?{postThreadDetail:i}:{},...r.includeDashboardLink!==void 0?{includeDashboardLink:a}:{},...r.includeBriefingLink!==void 0?{includeBriefingLink:f}:{}}}function ye(n,t,e){const r=h(n,t,e);s(r,t,["subjectOverride","titleOverride","summaryOverride","actionBlockVisible","formatProfile","slackConfig","webhookConfig"],e);const o=b(r.formatProfile,`${t}.formatProfile`,Z,"concise, balanced, or detailed",e),i=p(r.subjectOverride,`${t}.subjectOverride`,500,e),a=p(r.titleOverride,`${t}.titleOverride`,500,e),f=p(r.summaryOverride,`${t}.summaryOverride`,2e3,e),y=g(r.actionBlockVisible,!0,`${t}.actionBlockVisible`,e),d=me(r.webhookConfig,`${t}.webhookConfig`,e),m=pe(r.slackConfig,`${t}.slackConfig`,e);return{...o?{formatProfile:o}:{},...i?{subjectOverride:i}:{},...a?{titleOverride:a}:{},...f?{summaryOverride:f}:{},...r.actionBlockVisible!==void 0?{actionBlockVisible:y}:{},...m?{slackConfig:m}:{},...d?{webhookConfig:d}:{}}}function ge(n,t){if(n==null)return;const e=h(n,"deliveryConfig.channelConfigs",t),r={};return Object.entries(e).forEach(([o,i])=>{if(!D(o)){c(t,`deliveryConfig.channelConfigs.${o}`,"Expected a supported delivery channel.");return}r[o]=ye(i,`deliveryConfig.channelConfigs.${o}`,t)}),Object.keys(r).length>0?r:void 0}function Ie(n,t){var y,d,m;if(n==null)return null;const e=h(n,"deliveryConfig",t);s(e,"deliveryConfig",["recipients","channels","channelConfigs"],t);const r=ge(e.channelConfigs,t),o=le(e.recipients,t),i=se(e.channels,t),a=((d=(y=r==null?void 0:r.SLACK)==null?void 0:y.slackConfig)==null?void 0:d.destination.type)==="channel"&&!!r.SLACK.slackConfig.destination.channelId.trim();return i.some(_=>_!=="SLACK")&&o.length===0&&c(t,"deliveryConfig.recipients","Add at least one recipient or remove delivery config."),i.length===0&&c(t,"deliveryConfig.channels","Choose at least one delivery channel or remove delivery config."),i.includes("SLACK")&&!a&&c(t,"deliveryConfig.channelConfigs.SLACK.slackConfig.destination.channelId","Choose a Slack channel destination."),!i.includes("SLACK")&&((m=r==null?void 0:r.SLACK)!=null&&m.slackConfig)&&c(t,"deliveryConfig.channelConfigs.SLACK","Slack config requires SLACK in deliveryConfig.channels."),{recipients:o,channels:i,...r?{channelConfigs:r}:{}}}function T(n){const t=[],e=h(n,"draft",t);s(e,"draft",["name","description","status","scheduleExpr","timezone","source","body","attachments","presentation","limits","deliveryConfig"],t);const r=u(e.name,"name",l.name,t),o=p(e.description,"description",l.description,t)??null,i=p(e.scheduleExpr,"scheduleExpr",500,t)??null,a=p(e.timezone,"timezone",200,t)??"UTC",f=ee(e.status,t),y=N(e.source,t),d=M(e.body,t),m=P(e.attachments,t),_=V(e.presentation,t),F=j(e.limits,t),G=Ie(e.deliveryConfig,t);return K(d,m,t),w(t),{name:r,description:o,status:f,scheduleExpr:i,timezone:a,source:y,body:d,attachments:m,presentation:_,...F?{limits:F}:{},deliveryConfig:G}}function be(n){return T(n)}function Ee(n){return T(n)}function ve(n){try{return{valid:!0,value:T(n),issues:[]}}catch(t){if(t instanceof S)return{valid:!1,issues:t.issues};throw t}}function $e(n){try{return{valid:!0,value:L(n),issues:[]}}catch(t){if(t instanceof S)return{valid:!1,issues:t.issues};throw t}}function Ce(n){return typeof n=="string"&&O.has(n)}function D(n){return typeof n=="string"&&H.has(n)}exports.BRIEFING_ARTIFACT_FORMATS=z;exports.BRIEFING_KIND=C;exports.BRIEFING_TEXT_LIMITS=l;exports.BriefingContractError=S;exports.DEFAULT_BRIEFING_ARTIFACT_FORMATS=A;exports.MAX_BRIEFING_ATTACHMENTS=$;exports.buildBriefingJobConfig=de;exports.buildCreateBriefingRequest=be;exports.buildUpdateBriefingRequest=Ee;exports.isBriefingArtifactFormat=Ce;exports.isBriefingDeliveryChannel=D;exports.normalizeBriefingDraft=T;exports.normalizeBriefingJobConfig=L;exports.validateBriefingDraft=ve;exports.validateBriefingJobConfig=$e;
|