@powerhousedao/connect 4.1.0-dev.3 → 4.1.0-dev.4

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.
Files changed (72) hide show
  1. package/dist/assets/{AddDriveModal.B9l0uX0V.js → AddDriveModal.Da3jKsZ_.js} +2 -2
  2. package/dist/assets/{AddDriveModal.B9l0uX0V.js.map → AddDriveModal.Da3jKsZ_.js.map} +1 -1
  3. package/dist/assets/{AddRemoteDriveModal.yNhuaN--.js → AddRemoteDriveModal.B-JiA2ZF.js} +2 -2
  4. package/dist/assets/{AddRemoteDriveModal.yNhuaN--.js.map → AddRemoteDriveModal.B-JiA2ZF.js.map} +1 -1
  5. package/dist/assets/{CookiesPolicyModal.D4hQ48Ir.js → CookiesPolicyModal.CFBKbAr-.js} +2 -2
  6. package/dist/assets/{CookiesPolicyModal.D4hQ48Ir.js.map → CookiesPolicyModal.CFBKbAr-.js.map} +1 -1
  7. package/dist/assets/{CreateDocumentModal.CD66Cg3r.js → CreateDocumentModal.CdeyybtM.js} +2 -2
  8. package/dist/assets/{CreateDocumentModal.CD66Cg3r.js.map → CreateDocumentModal.CdeyybtM.js.map} +1 -1
  9. package/dist/assets/{DebugSettingsModal.BILReZxs.js → DebugSettingsModal.DJ_1rUc-.js} +2 -2
  10. package/dist/assets/{DebugSettingsModal.BILReZxs.js.map → DebugSettingsModal.DJ_1rUc-.js.map} +1 -1
  11. package/dist/assets/{DeleteDriveModal.BBoBe82W.js → DeleteDriveModal.SZ6yK21-.js} +2 -2
  12. package/dist/assets/{DeleteDriveModal.BBoBe82W.js.map → DeleteDriveModal.SZ6yK21-.js.map} +1 -1
  13. package/dist/assets/{DeleteItemModal.DIkemmAE.js → DeleteItemModal.C6agp6HV.js} +2 -2
  14. package/dist/assets/{DeleteItemModal.DIkemmAE.js.map → DeleteItemModal.C6agp6HV.js.map} +1 -1
  15. package/dist/assets/{DisclaimerModal.DL8j9bHv.js → DisclaimerModal.j5fyTY3r.js} +2 -2
  16. package/dist/assets/{DisclaimerModal.DL8j9bHv.js.map → DisclaimerModal.j5fyTY3r.js.map} +1 -1
  17. package/dist/assets/{DriveSettingsModal.DKRG5FTh.js → DriveSettingsModal.B28aUSHx.js} +2 -2
  18. package/dist/assets/{DriveSettingsModal.DKRG5FTh.js.map → DriveSettingsModal.B28aUSHx.js.map} +1 -1
  19. package/dist/assets/{SettingsModal.C20l5YzD.js → SettingsModal.DuVB1zyr.js} +2 -2
  20. package/dist/assets/{SettingsModal.C20l5YzD.js.map → SettingsModal.DuVB1zyr.js.map} +1 -1
  21. package/dist/assets/{Trans.C-XxAJQI.js → Trans.CSO_Gnh0.js} +2 -2
  22. package/dist/assets/{Trans.C-XxAJQI.js.map → Trans.CSO_Gnh0.js.map} +1 -1
  23. package/dist/assets/{UpgradeDriveModal.DCqSX06A.js → UpgradeDriveModal.uMSN_PXp.js} +2 -2
  24. package/dist/assets/{UpgradeDriveModal.DCqSX06A.js.map → UpgradeDriveModal.uMSN_PXp.js.map} +1 -1
  25. package/dist/assets/{atlas-import.ocOrNrns.js → atlas-import.BTK5TpJM.js} +2 -2
  26. package/dist/assets/{atlas-import.ocOrNrns.js.map → atlas-import.BTK5TpJM.js.map} +1 -1
  27. package/dist/assets/{content.B5WVCHY5.js → content.DKjIWCna.js} +3 -3
  28. package/dist/assets/{content.B5WVCHY5.js.map → content.DKjIWCna.js.map} +1 -1
  29. package/dist/assets/{cookie-banner.Bg2v0svK.js → cookie-banner.DsPVe6SD.js} +2 -2
  30. package/dist/assets/{cookie-banner.Bg2v0svK.js.map → cookie-banner.DsPVe6SD.js.map} +1 -1
  31. package/dist/assets/{index.mOGwt8eT.js → index.BcAgmgN1.js} +2 -2
  32. package/dist/assets/{index.mOGwt8eT.js.map → index.BcAgmgN1.js.map} +1 -1
  33. package/dist/assets/{index.C-HG-Gwi.js → index.BdsBV3Yf.js} +2 -2
  34. package/dist/assets/{index.C-HG-Gwi.js.map → index.BdsBV3Yf.js.map} +1 -1
  35. package/dist/assets/{index.7FqhOECI.js → index.BuRlIuLR.js} +2 -2
  36. package/dist/assets/{index.7FqhOECI.js.map → index.BuRlIuLR.js.map} +1 -1
  37. package/dist/assets/{index.CLzXE8sZ.js → index.Byl5M-El.js} +2 -2
  38. package/dist/assets/{index.CLzXE8sZ.js.map → index.Byl5M-El.js.map} +1 -1
  39. package/dist/assets/{index.DGVoDyf9.js → index.DbGcj8XM.js} +2 -2
  40. package/dist/assets/{index.DGVoDyf9.js.map → index.DbGcj8XM.js.map} +1 -1
  41. package/dist/assets/{index.DlkM_dKy.js → index.Dng4bmoE.js} +2 -2
  42. package/dist/assets/{index.DlkM_dKy.js.map → index.Dng4bmoE.js.map} +1 -1
  43. package/dist/assets/{index.DpBTsU0F.js → index.DyeFAl0a.js} +5 -5
  44. package/dist/assets/{index.DpBTsU0F.js.map → index.DyeFAl0a.js.map} +1 -1
  45. package/dist/assets/{index.DuUVYKhB.js → index.IQLcrTKf.js} +2 -2
  46. package/dist/assets/{index.DuUVYKhB.js.map → index.IQLcrTKf.js.map} +1 -1
  47. package/dist/assets/{main.Ck6VRIF6.js → main.DStONwBq.js} +3 -3
  48. package/dist/assets/{main.Ck6VRIF6.js.map → main.DStONwBq.js.map} +1 -1
  49. package/dist/assets/{modal.B3z6DV2z.js → modal.DPaGlp1P.js} +3 -3
  50. package/dist/assets/{modal.B3z6DV2z.js.map → modal.DPaGlp1P.js.map} +1 -1
  51. package/dist/assets/{modals.PJC1keaq.js → modals.BWp55IQR.js} +2 -2
  52. package/dist/assets/{modals.PJC1keaq.js.map → modals.BWp55IQR.js.map} +1 -1
  53. package/dist/assets/{nodefs.Bo88sObU.js → nodefs.DNNJauAN.js} +2 -2
  54. package/dist/assets/{nodefs.Bo88sObU.js.map → nodefs.DNNJauAN.js.map} +1 -1
  55. package/dist/assets/{nodes.l1IJVPjz.js → nodes.B_eVbI_2.js} +2 -2
  56. package/dist/assets/{nodes.l1IJVPjz.js.map → nodes.B_eVbI_2.js.map} +1 -1
  57. package/dist/assets/{opfs-ahp.CtT90Lnv.js → opfs-ahp.DvJEZ6bR.js} +2 -2
  58. package/dist/assets/{opfs-ahp.CtT90Lnv.js.map → opfs-ahp.DvJEZ6bR.js.map} +1 -1
  59. package/dist/assets/{registerServiceWorker.BAEIkXhW.js → registerServiceWorker.CZCqqDT3.js} +2 -2
  60. package/dist/assets/{registerServiceWorker.BAEIkXhW.js.map → registerServiceWorker.CZCqqDT3.js.map} +1 -1
  61. package/dist/assets/{root.Vt3ZBtf_.js → root.B1DGwRFc.js} +2 -2
  62. package/dist/assets/{root.Vt3ZBtf_.js.map → root.B1DGwRFc.js.map} +1 -1
  63. package/dist/assets/{useAcceptedCookies.sbf3QW74.js → useAcceptedCookies.JSKTOL1v.js} +2 -2
  64. package/dist/assets/{useAcceptedCookies.sbf3QW74.js.map → useAcceptedCookies.JSKTOL1v.js.map} +1 -1
  65. package/dist/assets/useDefaultDocumentModelEditor.Ce_obvOa.js +2 -0
  66. package/dist/assets/{useDefaultDocumentModelEditor.BtCpUHqb.js.map → useDefaultDocumentModelEditor.Ce_obvOa.js.map} +1 -1
  67. package/dist/assets/{useInitSentry.hI4c9V57.js → useInitSentry._tswbI1T.js} +6 -6
  68. package/dist/assets/{useInitSentry.hI4c9V57.js.map → useInitSentry._tswbI1T.js.map} +1 -1
  69. package/dist/index.html +1 -1
  70. package/dist/vite-envs.sh +1 -1
  71. package/package.json +10 -10
  72. package/dist/assets/useDefaultDocumentModelEditor.BtCpUHqb.js +0 -2
@@ -1,2 +1,2 @@
1
- var v=Object.defineProperty;var _=(r,e,t)=>e in r?v(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var S=(r,e,t)=>_(r,typeof e!="symbol"?e+"":e,t);import{c as O}from"./index.DpBTsU0F.js";import{A as n,D as I}from"./useInitSentry.hI4c9V57.js";import"react-dom/client";import"./index.VxUYZjTL.js";import"react";import"react/jsx-runtime";import"react-dom";import"./browser.BkwNmV2Z.js";import"./app-skeleton.js";import"./useAcceptedCookies.sbf3QW74.js";import"./registerServiceWorker.BAEIkXhW.js";class w{constructor(e,t=O(["processor","document-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/doc/${t.driveId}/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{driveId:s,documentId:f,branch:E,scope:a}=t,p=s===f?"DRIVE":"NODE",l=50;for(let o=0;o<t.operations.length;o+=l){const i=t.operations.slice(o,o+l),c=[];for(const d of i){const g=d.index,h={source:u,metric:"DocumentOperations",start:I.fromISO(d.timestamp),value:1,dimensions:{drive:n.fromString(`ph/doc/drive/${s}/${E}/${a}/${g}`),operation:n.fromString(`ph/doc/operation/${d.type}/${d.index}`),target:n.fromString(`ph/doc/target/${s}/${p}/${f}`)}};for(c.push(h);c.length>=l;){const y=c.splice(0,l);await this.analyticsStore.addSeriesValues(y)}}c.length>0&&await this.analyticsStore.addSeriesValues(c)}}}async onDisconnect(){}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const $=["ADD_FILE","ADD_FOLDER"],T=["COPY_NODE"],C=["UPDATE_FILE","UPDATE_NODE"],A=["MOVE_NODE"],N=["DELETE_NODE"],V=[...$,...T,...C,...A,...N];class b{constructor(e,t=O(["processor","drive-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/drive/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{documentId:s,branch:f,scope:E}=t,a=50;for(let p=0;p<t.operations.length;p+=a){const l=t.operations.slice(p,p+a),o=[];for(const i of l){const c=i.index,d=this.getActionType(i.type),g=V.includes(i.type)?"NODE":"DRIVE";let h=s;if(g==="NODE"){const m=i.input;h=m.id||m.targetId||m.srcFolder||s}const y={source:u,metric:"DriveOperations",start:I.fromISO(i.timestamp),value:1,dimensions:{drive:n.fromString(`ph/drive/${s}/${f}/${E}/${c}`),operation:n.fromString(`ph/drive/operation/${i.type}/${i.index}`),target:n.fromString(`ph/drive/target/${g}/${h}`),actionType:n.fromString(`ph/drive/actionType/${d}/${h}`)}};for(o.push(y);o.length>=a;){const m=o.splice(0,a);await this.analyticsStore.addSeriesValues(m)}}o.length>0&&await this.analyticsStore.addSeriesValues(o)}}}async onDisconnect(){}getActionType(e){return $.includes(e)?"CREATED":T.includes(e)?"DUPLICATED":N.includes(e)?"REMOVED":A.includes(e)?"MOVED":"UPDATED"}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const Y=r=>e=>[{processor:new b(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["powerhouse/document-drive"]}},{processor:new w(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{w as DocumentAnalyticsProcessor,b as DriveAnalyticsProcessor,Y as processorFactory};
2
- //# sourceMappingURL=index.7FqhOECI.js.map
1
+ var v=Object.defineProperty;var _=(r,e,t)=>e in r?v(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var S=(r,e,t)=>_(r,typeof e!="symbol"?e+"":e,t);import{c as O}from"./index.DyeFAl0a.js";import{A as n,D as I}from"./useInitSentry._tswbI1T.js";import"react-dom/client";import"./index.VxUYZjTL.js";import"react";import"react/jsx-runtime";import"react-dom";import"./browser.BkwNmV2Z.js";import"./app-skeleton.js";import"./useAcceptedCookies.JSKTOL1v.js";import"./registerServiceWorker.CZCqqDT3.js";class w{constructor(e,t=O(["processor","document-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/doc/${t.driveId}/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{driveId:s,documentId:f,branch:E,scope:a}=t,p=s===f?"DRIVE":"NODE",l=50;for(let o=0;o<t.operations.length;o+=l){const i=t.operations.slice(o,o+l),c=[];for(const d of i){const g=d.index,h={source:u,metric:"DocumentOperations",start:I.fromISO(d.timestamp),value:1,dimensions:{drive:n.fromString(`ph/doc/drive/${s}/${E}/${a}/${g}`),operation:n.fromString(`ph/doc/operation/${d.type}/${d.index}`),target:n.fromString(`ph/doc/target/${s}/${p}/${f}`)}};for(c.push(h);c.length>=l;){const y=c.splice(0,l);await this.analyticsStore.addSeriesValues(y)}}c.length>0&&await this.analyticsStore.addSeriesValues(c)}}}async onDisconnect(){}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const $=["ADD_FILE","ADD_FOLDER"],T=["COPY_NODE"],C=["UPDATE_FILE","UPDATE_NODE"],A=["MOVE_NODE"],N=["DELETE_NODE"],V=[...$,...T,...C,...A,...N];class b{constructor(e,t=O(["processor","drive-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/drive/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{documentId:s,branch:f,scope:E}=t,a=50;for(let p=0;p<t.operations.length;p+=a){const l=t.operations.slice(p,p+a),o=[];for(const i of l){const c=i.index,d=this.getActionType(i.type),g=V.includes(i.type)?"NODE":"DRIVE";let h=s;if(g==="NODE"){const m=i.input;h=m.id||m.targetId||m.srcFolder||s}const y={source:u,metric:"DriveOperations",start:I.fromISO(i.timestamp),value:1,dimensions:{drive:n.fromString(`ph/drive/${s}/${f}/${E}/${c}`),operation:n.fromString(`ph/drive/operation/${i.type}/${i.index}`),target:n.fromString(`ph/drive/target/${g}/${h}`),actionType:n.fromString(`ph/drive/actionType/${d}/${h}`)}};for(o.push(y);o.length>=a;){const m=o.splice(0,a);await this.analyticsStore.addSeriesValues(m)}}o.length>0&&await this.analyticsStore.addSeriesValues(o)}}}async onDisconnect(){}getActionType(e){return $.includes(e)?"CREATED":T.includes(e)?"DUPLICATED":N.includes(e)?"REMOVED":A.includes(e)?"MOVED":"UPDATED"}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const Y=r=>e=>[{processor:new b(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["powerhouse/document-drive"]}},{processor:new w(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{w as DocumentAnalyticsProcessor,b as DriveAnalyticsProcessor,Y as processorFactory};
2
+ //# sourceMappingURL=index.BuRlIuLR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.7FqhOECI.js","sources":["../../../../packages/common/dist/drive-analytics/processor/document-processor.js","../../../../packages/common/dist/drive-analytics/processor/drive-processor.js","../../../../packages/common/dist/drive-analytics/processor/index.js"],"sourcesContent":["import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nexport class DocumentAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"document-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/doc/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { driveId, documentId, branch, scope } = strand;\n const target = driveId === documentId ? \"DRIVE\" : \"NODE\";\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const seriesInput = {\n source,\n metric: \"DocumentOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/doc/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/doc/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/doc/target/${driveId}/${target}/${documentId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=document-processor.js.map","import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nconst CREATE_NODE_ACTIONS = [\"ADD_FILE\", \"ADD_FOLDER\"];\nconst DUPLICATE_NODE_ACTIONS = [\"COPY_NODE\"];\nconst UPDATE_NODE_ACTIONS = [\"UPDATE_FILE\", \"UPDATE_NODE\"];\nconst MOVE_NODE_ACTIONS = [\"MOVE_NODE\"];\nconst REMOVE_NODE_ACTIONS = [\"DELETE_NODE\"];\nconst NODE_ACTIONS = [\n ...CREATE_NODE_ACTIONS,\n ...DUPLICATE_NODE_ACTIONS,\n ...UPDATE_NODE_ACTIONS,\n ...MOVE_NODE_ACTIONS,\n ...REMOVE_NODE_ACTIONS,\n];\nexport class DriveAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"drive-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/drive/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { documentId: driveId, branch, scope } = strand;\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const actionType = this.getActionType(operation.type);\n const target = NODE_ACTIONS.includes(operation.type)\n ? \"NODE\"\n : \"DRIVE\";\n let targetId = driveId;\n if (target === \"NODE\") {\n const operationInput = operation.input;\n targetId =\n operationInput.id ||\n operationInput.targetId ||\n operationInput.srcFolder ||\n driveId;\n }\n const seriesInput = {\n source,\n metric: \"DriveOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/drive/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/drive/target/${target}/${targetId}`),\n actionType: AnalyticsPath.fromString(`ph/drive/actionType/${actionType}/${targetId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n getActionType(action) {\n if (CREATE_NODE_ACTIONS.includes(action)) {\n return \"CREATED\";\n }\n if (DUPLICATE_NODE_ACTIONS.includes(action)) {\n return \"DUPLICATED\";\n }\n if (REMOVE_NODE_ACTIONS.includes(action)) {\n return \"REMOVED\";\n }\n if (MOVE_NODE_ACTIONS.includes(action)) {\n return \"MOVED\";\n }\n return \"UPDATED\";\n }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=drive-processor.js.map","import { DocumentAnalyticsProcessor } from \"./document-processor.js\";\nimport { DriveAnalyticsProcessor } from \"./drive-processor.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DriveAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"powerhouse/document-drive\"],\n },\n },\n {\n processor: new DocumentAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\nexport * from \"./document-processor.js\";\nexport * from \"./drive-processor.js\";\n//# sourceMappingURL=index.js.map"],"names":["DocumentAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","driveId","documentId","branch","scope","target","CHUNK_SIZE","i","chunk","buffer","operation","revision","seriesInput","DateTime","batch","e","CREATE_NODE_ACTIONS","DUPLICATE_NODE_ACTIONS","UPDATE_NODE_ACTIONS","MOVE_NODE_ACTIONS","REMOVE_NODE_ACTIONS","NODE_ACTIONS","DriveAnalyticsProcessor","actionType","targetId","operationInput","action","processorFactory","module"],"mappings":"+fAEO,MAAMA,CAA2B,CAGpC,YAAYC,EAAgBC,EAASC,EAAY,CAAC,YAAa,oBAAoB,CAAC,EAAG,CAFvFC,EAAA,uBACAA,EAAA,eAEI,KAAK,eAAiBH,EACtB,KAAK,OAASC,CAEtB,CACI,MAAM,UAAUG,EAAS,CACrB,GAAIA,EAAQ,SAAW,EAGvB,UAAWC,KAAUD,EAAS,CAE1B,GAAIC,EAAO,WAAW,SAAW,EAC7B,SAEJ,MAAMC,EAA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C/D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CAClC,CACA,CACA"}
1
+ {"version":3,"file":"index.BuRlIuLR.js","sources":["../../../../packages/common/dist/drive-analytics/processor/document-processor.js","../../../../packages/common/dist/drive-analytics/processor/drive-processor.js","../../../../packages/common/dist/drive-analytics/processor/index.js"],"sourcesContent":["import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nexport class DocumentAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"document-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/doc/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { driveId, documentId, branch, scope } = strand;\n const target = driveId === documentId ? \"DRIVE\" : \"NODE\";\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const seriesInput = {\n source,\n metric: \"DocumentOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/doc/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/doc/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/doc/target/${driveId}/${target}/${documentId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=document-processor.js.map","import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nconst CREATE_NODE_ACTIONS = [\"ADD_FILE\", \"ADD_FOLDER\"];\nconst DUPLICATE_NODE_ACTIONS = [\"COPY_NODE\"];\nconst UPDATE_NODE_ACTIONS = [\"UPDATE_FILE\", \"UPDATE_NODE\"];\nconst MOVE_NODE_ACTIONS = [\"MOVE_NODE\"];\nconst REMOVE_NODE_ACTIONS = [\"DELETE_NODE\"];\nconst NODE_ACTIONS = [\n ...CREATE_NODE_ACTIONS,\n ...DUPLICATE_NODE_ACTIONS,\n ...UPDATE_NODE_ACTIONS,\n ...MOVE_NODE_ACTIONS,\n ...REMOVE_NODE_ACTIONS,\n];\nexport class DriveAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"drive-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/drive/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { documentId: driveId, branch, scope } = strand;\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const actionType = this.getActionType(operation.type);\n const target = NODE_ACTIONS.includes(operation.type)\n ? \"NODE\"\n : \"DRIVE\";\n let targetId = driveId;\n if (target === \"NODE\") {\n const operationInput = operation.input;\n targetId =\n operationInput.id ||\n operationInput.targetId ||\n operationInput.srcFolder ||\n driveId;\n }\n const seriesInput = {\n source,\n metric: \"DriveOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/drive/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/drive/target/${target}/${targetId}`),\n actionType: AnalyticsPath.fromString(`ph/drive/actionType/${actionType}/${targetId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n getActionType(action) {\n if (CREATE_NODE_ACTIONS.includes(action)) {\n return \"CREATED\";\n }\n if (DUPLICATE_NODE_ACTIONS.includes(action)) {\n return \"DUPLICATED\";\n }\n if (REMOVE_NODE_ACTIONS.includes(action)) {\n return \"REMOVED\";\n }\n if (MOVE_NODE_ACTIONS.includes(action)) {\n return \"MOVED\";\n }\n return \"UPDATED\";\n }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=drive-processor.js.map","import { DocumentAnalyticsProcessor } from \"./document-processor.js\";\nimport { DriveAnalyticsProcessor } from \"./drive-processor.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DriveAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"powerhouse/document-drive\"],\n },\n },\n {\n processor: new DocumentAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\nexport * from \"./document-processor.js\";\nexport * from \"./drive-processor.js\";\n//# sourceMappingURL=index.js.map"],"names":["DocumentAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","driveId","documentId","branch","scope","target","CHUNK_SIZE","i","chunk","buffer","operation","revision","seriesInput","DateTime","batch","e","CREATE_NODE_ACTIONS","DUPLICATE_NODE_ACTIONS","UPDATE_NODE_ACTIONS","MOVE_NODE_ACTIONS","REMOVE_NODE_ACTIONS","NODE_ACTIONS","DriveAnalyticsProcessor","actionType","targetId","operationInput","action","processorFactory","module"],"mappings":"+fAEO,MAAMA,CAA2B,CAGpC,YAAYC,EAAgBC,EAASC,EAAY,CAAC,YAAa,oBAAoB,CAAC,EAAG,CAFvFC,EAAA,uBACAA,EAAA,eAEI,KAAK,eAAiBH,EACtB,KAAK,OAASC,CAEtB,CACI,MAAM,UAAUG,EAAS,CACrB,GAAIA,EAAQ,SAAW,EAGvB,UAAWC,KAAUD,EAAS,CAE1B,GAAIC,EAAO,WAAW,SAAW,EAC7B,SAEJ,MAAMC,EAAUD,EAAO,WAAW,CAAC,EAC7BE,EAASC,EAAc,WAAW,UAAUH,EAAO,OAAO,IAAIA,EAAO,UAAU,IAAIA,EAAO,MAAM,IAAIA,EAAO,KAAK,EAAE,EACpHC,EAAQ,QAAU,GAClB,MAAM,KAAK,YAAYC,CAAM,EAEjC,KAAM,CAAE,QAAAE,EAAS,WAAAC,EAAY,OAAAC,EAAQ,MAAAC,CAAK,EAAKP,EACzCQ,EAASJ,IAAYC,EAAa,QAAU,OAC5CI,EAAa,GACnB,QAASC,EAAI,EAAGA,EAAIV,EAAO,WAAW,OAAQU,GAAKD,EAAY,CAC3D,MAAME,EAAQX,EAAO,WAAW,MAAMU,EAAGA,EAAID,CAAU,EACjDG,EA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AAY,CAChC,MAAMQ,EAAQL,EAAO,OAAO,EAAGH,CAAU,EACzC,MAAM,KAAK,eAAe,gBAAgBQ,CAAK,CACvE,CACA,CACoBL,EAAO,OAAS,GAChB,MAAM,KAAK,eAAe,gBAAgBA,CAAM,CAEpE,CACA,CACA,CACI,MAAM,cAAe,CAAA,CACrB,cAAciB,EAAQ,CAClB,OAAIV,EAAoB,SAASU,CAAM,EAC5B,UAEPT,EAAuB,SAASS,CAAM,EAC/B,aAEPN,EAAoB,SAASM,CAAM,EAC5B,UAEPP,EAAkB,SAASO,CAAM,EAC1B,QAEJ,SACf,CACI,MAAM,YAAY3B,EAAQ,CACtB,GAAI,CACA,MAAM,KAAK,eAAe,oBAAoBA,EAAQ,EAAI,CACtE,OACegB,EAAG,CACN,KAAK,OAAO,MAAM,yBAA0BA,CAAC,CACzD,CACA,CACA,CCtGY,MAACY,EAAoBC,GAAY3B,GAClC,CACH,CACI,UAAW,IAAIqB,EAAwBM,EAAO,cAAc,EAC5D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,2BAA2B,CAC1D,CACA,EACQ,CACI,UAAW,IAAIrC,EAA2BqC,EAAO,cAAc,EAC/D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CAClC,CACA,CACA"}
@@ -1,4 +1,4 @@
1
- import{jsx as Y,jsxs as Me}from"react/jsx-runtime";import*as Gt from"react";import Pu,{useState as Ms,useEffect as en,createContext as WN,useContext as ZN,forwardRef as fh,useRef as _t,useCallback as ve,useImperativeHandle as wb,useId as dh,memo as xb,useMemo as to}from"react";import{ar as YN,a_ as zN,o as Ci,a$ as ii,s as Ie,b0 as KN,b1 as kb,b as Ib,b2 as XN,d as JN,b3 as e_,w as Ln,b4 as Vf,b5 as jc,b6 as Rb,g as t_,b7 as n_,b8 as i_,l as r_,b9 as s_,ba as o_,bb as a_,bc as l_,bd as u_,be as c_,bf as f_,p as d_,bg as h_,bh as p_,bi as Db,bj as Cb,bk as Pb,bl as Ep,bm as m_,bn as g_,bo as v_,bp as y_,bq as b_,br as Ap,bs as O_,q as Gc,bt as S_,bu as T_,bv as E_,bw as A_,bx as N_,by as __,bz as w_,bA as x_,bB as k_,bC as I_,bD as R_}from"./index.VxUYZjTL.js";import{c2 as Mb,c3 as re,c4 as On,c5 as Su,c6 as En,c7 as bc,c8 as Ht,c9 as tn,ca as Oc,cb as Lr,cc as Ls,cd as D_,ce as z,cf as C_,cg as P_,ch as Lb,ci as $b,cj as M_,ck as Qb,cl as Np,cm as Oi,cn as _p,co as wp,cp as xp,cq as L_,cr as ui,cs as Cn,ct as $_,cu as $r,cv as $s,cw as ht,cx as Qs,cy as hh,cz as Fb,cA as Vb,cB as Bb,cC as Ub,cD as Bf,cE as Q_,cF as Mu,cG as F_,cH as ph,cI as mh,cJ as qb,cK as jb,cL as V_,cM as Uf,cN as qf,cO as jf,cP as gs,cQ as B_,cR as Gb,cS as U_,cT as q_,cU as it,cV as j_,cW as G_,cX as H_}from"./index.DpBTsU0F.js";import"react-dom";import"react-dom/client";import"./browser.BkwNmV2Z.js";import"./app-skeleton.js";const W_=Object.freeze({major:16,minor:11,patch:0,preReleaseTag:null});function Z_(n){return n instanceof Error?n:new Y_(n)}class Y_ extends Error{constructor(e){super("Unexpected error value: "+Mb(e)),this.name="NonErrorThrown",this.thrownValue=e}}function z_(n,e,t){var i;const r=Z_(n);return K_(r)?r:new re(r.message,{nodes:(i=r.nodes)!==null&&i!==void 0?i:e,source:r.source,positions:r.positions,path:t,originalError:r})}function K_(n){return Array.isArray(n.path)}function X_(n){return{Field(e){const t=n.getFieldDef(),i=t==null?void 0:t.deprecationReason;if(t&&i!=null){const r=n.getParentType();r!=null||Su(!1),n.reportError(new re(`The field ${r.name}.${t.name} is deprecated. ${i}`,{nodes:e}))}},Argument(e){const t=n.getArgument(),i=t==null?void 0:t.deprecationReason;if(t&&i!=null){const r=n.getDirective();if(r!=null)n.reportError(new re(`Directive "@${r.name}" argument "${t.name}" is deprecated. ${i}`,{nodes:e}));else{const s=n.getParentType(),o=n.getFieldDef();s!=null&&o!=null||Su(!1),n.reportError(new re(`Field "${s.name}.${o.name}" argument "${t.name}" is deprecated. ${i}`,{nodes:e}))}}},ObjectField(e){const t=On(n.getParentInputType());if(En(t)){const i=t.getFields()[e.name.value],r=i==null?void 0:i.deprecationReason;r!=null&&n.reportError(new re(`The input field ${t.name}.${i.name} is deprecated. ${r}`,{nodes:e}))}},EnumValue(e){const t=n.getEnumValue(),i=t==null?void 0:t.deprecationReason;if(t&&i!=null){const r=On(n.getInputType());r!=null||Su(!1),n.reportError(new re(`The enum value "${r.name}.${t.name}" is deprecated. ${i}`,{nodes:e}))}}}}function gh(n){return ew(n,e=>!Lb(e),J_)}function J_(n){return!$b(n)&&!M_(n)}function ew(n,e,t){const i=n.getDirectives().filter(e),r=Object.values(n.getTypeMap()).filter(t);return[tw(n),...i.map(s=>cw(s)),...r.map(s=>iw(s))].filter(Boolean).join(`
1
+ import{jsx as Y,jsxs as Me}from"react/jsx-runtime";import*as Gt from"react";import Pu,{useState as Ms,useEffect as en,createContext as WN,useContext as ZN,forwardRef as fh,useRef as _t,useCallback as ve,useImperativeHandle as wb,useId as dh,memo as xb,useMemo as to}from"react";import{ar as YN,a_ as zN,o as Ci,a$ as ii,s as Ie,b0 as KN,b1 as kb,b as Ib,b2 as XN,d as JN,b3 as e_,w as Ln,b4 as Vf,b5 as jc,b6 as Rb,g as t_,b7 as n_,b8 as i_,l as r_,b9 as s_,ba as o_,bb as a_,bc as l_,bd as u_,be as c_,bf as f_,p as d_,bg as h_,bh as p_,bi as Db,bj as Cb,bk as Pb,bl as Ep,bm as m_,bn as g_,bo as v_,bp as y_,bq as b_,br as Ap,bs as O_,q as Gc,bt as S_,bu as T_,bv as E_,bw as A_,bx as N_,by as __,bz as w_,bA as x_,bB as k_,bC as I_,bD as R_}from"./index.VxUYZjTL.js";import{c2 as Mb,c3 as re,c4 as On,c5 as Su,c6 as En,c7 as bc,c8 as Ht,c9 as tn,ca as Oc,cb as Lr,cc as Ls,cd as D_,ce as z,cf as C_,cg as P_,ch as Lb,ci as $b,cj as M_,ck as Qb,cl as Np,cm as Oi,cn as _p,co as wp,cp as xp,cq as L_,cr as ui,cs as Cn,ct as $_,cu as $r,cv as $s,cw as ht,cx as Qs,cy as hh,cz as Fb,cA as Vb,cB as Bb,cC as Ub,cD as Bf,cE as Q_,cF as Mu,cG as F_,cH as ph,cI as mh,cJ as qb,cK as jb,cL as V_,cM as Uf,cN as qf,cO as jf,cP as gs,cQ as B_,cR as Gb,cS as U_,cT as q_,cU as it,cV as j_,cW as G_,cX as H_}from"./index.DyeFAl0a.js";import"react-dom";import"react-dom/client";import"./browser.BkwNmV2Z.js";import"./app-skeleton.js";const W_=Object.freeze({major:16,minor:11,patch:0,preReleaseTag:null});function Z_(n){return n instanceof Error?n:new Y_(n)}class Y_ extends Error{constructor(e){super("Unexpected error value: "+Mb(e)),this.name="NonErrorThrown",this.thrownValue=e}}function z_(n,e,t){var i;const r=Z_(n);return K_(r)?r:new re(r.message,{nodes:(i=r.nodes)!==null&&i!==void 0?i:e,source:r.source,positions:r.positions,path:t,originalError:r})}function K_(n){return Array.isArray(n.path)}function X_(n){return{Field(e){const t=n.getFieldDef(),i=t==null?void 0:t.deprecationReason;if(t&&i!=null){const r=n.getParentType();r!=null||Su(!1),n.reportError(new re(`The field ${r.name}.${t.name} is deprecated. ${i}`,{nodes:e}))}},Argument(e){const t=n.getArgument(),i=t==null?void 0:t.deprecationReason;if(t&&i!=null){const r=n.getDirective();if(r!=null)n.reportError(new re(`Directive "@${r.name}" argument "${t.name}" is deprecated. ${i}`,{nodes:e}));else{const s=n.getParentType(),o=n.getFieldDef();s!=null&&o!=null||Su(!1),n.reportError(new re(`Field "${s.name}.${o.name}" argument "${t.name}" is deprecated. ${i}`,{nodes:e}))}}},ObjectField(e){const t=On(n.getParentInputType());if(En(t)){const i=t.getFields()[e.name.value],r=i==null?void 0:i.deprecationReason;r!=null&&n.reportError(new re(`The input field ${t.name}.${i.name} is deprecated. ${r}`,{nodes:e}))}},EnumValue(e){const t=n.getEnumValue(),i=t==null?void 0:t.deprecationReason;if(t&&i!=null){const r=On(n.getInputType());r!=null||Su(!1),n.reportError(new re(`The enum value "${r.name}.${t.name}" is deprecated. ${i}`,{nodes:e}))}}}}function gh(n){return ew(n,e=>!Lb(e),J_)}function J_(n){return!$b(n)&&!M_(n)}function ew(n,e,t){const i=n.getDirectives().filter(e),r=Object.values(n.getTypeMap()).filter(t);return[tw(n),...i.map(s=>cw(s)),...r.map(s=>iw(s))].filter(Boolean).join(`
2
2
 
3
3
  `)}function tw(n){if(n.description==null&&nw(n))return;const e=[],t=n.getQueryType();t&&e.push(` query: ${t.name}`);const i=n.getMutationType();i&&e.push(` mutation: ${i.name}`);const r=n.getSubscriptionType();return r&&e.push(` subscription: ${r.name}`),Wt(n)+`schema {
4
4
  ${e.join(`
@@ -111,4 +111,4 @@ In some cases, you need to provide options to alter GraphQL's execution behavior
111
111
  "errors editor"
112
112
  `,gridTemplateRows:"auto 1fr"},children:[Me("div",{className:"flex flex-col gap-2",style:{gridArea:"left"},children:[Y(GS,{operation:e,onAddOperationAndInitialSchema:s,updateOperationName:o,deleteOperation:a,module:t,allOperationNames:i}),Y(wQ,{operation:e,focusOnMount:e.id===r,setOperationDescription:u})]}),Y("div",{className:"relative top-8",style:{gridArea:"editor"},children:Y(ah,{doc:e.schema??"",updateDocumentInModel:h,customLinter:p})}),Me("div",{style:{gridArea:"errors"},children:[Y("h3",{className:"my-2 text-sm font-medium text-gray-700",children:"Reducer Exceptions"}),Y(xQ,{operation:e,addOperationError:f,deleteOperationError:c,setOperationErrorName:d})]})]})}function DQ({module:n,allOperations:e,shouldFocusNewOperation:t,updateOperationName:i,deleteOperation:r,addOperationAndInitialSchema:s,addOperationError:o,deleteOperationError:a,setOperationErrorName:l,updateOperationSchema:u,setOperationDescription:f}){const[c,d]=Ms(null),h=dh(),p=e.map(g=>g.name).filter(g=>g!==null),m=ve(async(g,v)=>{const y=await s(g,v);return y&&d(y),y},[s,d]);return Me("div",{children:[n.operations.map(g=>Y("div",{children:Y(RQ,{operation:g,module:n,lastCreatedOperationId:c,allOperationNames:p,addOperationError:o,deleteOperationError:a,setOperationErrorName:l,onAddOperationAndInitialSchema:m,updateOperationName:i,deleteOperation:r,updateOperationSchema:u,setOperationDescription:f})},g.id)),Y("div",{className:"mt-6 w-1/2 pr-6",children:Y(GS,{onAddOperationAndInitialSchema:m,updateOperationName:i,deleteOperation:r,module:n,allOperationNames:p,focusOnMount:t},h)})]})}function Eb(n){const{module:e,modules:t,allOperations:i,lastCreatedModuleId:r,onAddModule:s,updateModuleName:o,deleteModule:a,updateOperationName:l,deleteOperation:u,addOperationAndInitialSchema:f,updateOperationSchema:c,setOperationDescription:d,addOperationError:h,deleteOperationError:p,setOperationErrorName:m}=n;return Me("div",{className:"relative rounded-3xl bg-gray-100 p-6",children:[Me("div",{className:"mb-2 w-1/2 pr-6",children:[Y(TR,{modules:t,module:e,onAddModule:s,updateModuleName:o}),!!e&&Y("button",{"aria-label":"Delete module",tabIndex:-1,className:"absolute right-1 top-1 p-2 text-gray-800 transition-colors hover:text-gray-500",onClick:()=>{a(e.id)},children:Y("svg",{className:"size-6",viewBox:"0 0 24 24",fill:"currentcolor",children:Y("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.9993 8.51506L15.4844 7L11.9994 10.4852L8.51497 7.00057L7 8.51562L10.4844 12.0003L7.00056 15.4843L8.51552 16.9994L11.9994 13.5153L15.4838 17L16.9988 15.4849L13.5144 12.0003L16.9993 8.51506Z"})})})]}),!!e&&Y(DQ,{module:e,allOperations:i,shouldFocusNewOperation:e.id===r,updateOperationName:l,deleteOperation:u,addOperationAndInitialSchema:f,updateOperationSchema:c,setOperationDescription:d,addOperationError:h,deleteOperationError:p,setOperationErrorName:m})]})}function CQ({modules:n,allOperations:e,addModule:t,updateModuleName:i,deleteModule:r,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d}){const[h,p]=Ms(null),m=_t(null),g=ve(async v=>{var O;const y=await t(v);return y&&(p(y),(O=m.current)==null||O.focus()),y},[t,p]);return Me("div",{className:"flex flex-col gap-2",children:[n.map(v=>Y(Eb,{module:v,modules:n,allOperations:e,lastCreatedModuleId:h,onAddModule:g,updateModuleName:i,deleteModule:r,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d},v.id)),Y(Eb,{modules:n,allOperations:e,lastCreatedModuleId:h,onAddModule:g,updateModuleName:i,deleteModule:r,updateOperationName:s,deleteOperation:o,addOperationAndInitialSchema:a,updateOperationSchema:l,setOperationDescription:u,addOperationError:f,deleteOperationError:c,setOperationErrorName:d},"add-module"),Y("div",{ref:m,tabIndex:0,className:"size-0 overflow-hidden","aria-hidden":"true"})]})}const lh=fh((n,e)=>{const{className:t,...i}=n;return Y("button",{ref:e,...i,className:Yt("h-10 whitespace-nowrap rounded-md border border-gray-200 bg-gray-50 px-4 py-2 text-sm font-medium text-gray-800 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t)})}),PQ=Yh({String:Q.string,Number:Q.number,"True False":Q.bool,PropertyName:Q.propertyName,Null:Q.null,", :":Q.separator,"[ ]":Q.squareBracket,"{ }":Q.brace}),MQ=ks.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[PQ],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),LQ=()=>n=>{try{JSON.parse(n.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=$Q(e,n.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function $Q(n,e){let t;return(t=n.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=n.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const ON=Is.define({name:"json",parser:MQ.configure({props:[Xh.add({Object:my({except:/^\s*\}/}),Array:my({except:/^\s*\]/})}),ep.add({"Object Array":jE})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function QQ(){return new BE(ON)}const FQ=xb(function(e){const{doc:t,readonly:i=!1,updateDocumentInModel:r}=e,{editorRef:s,viewRef:o,updateListenerCompartment:a,focusHandlerCompartment:l,pasteHandlerCompartment:u,timeoutRef:f}=dN();return en(()=>{o.current||(o.current=new ne({state:Ee.create({doc:t,extensions:[...gN,wc.of(vN),sA,ON,QQ(),Uh(LQ()),a.current.of(yp(i,f,r)),l.current.of(bp(i,f,r)),u.current.of(Op(i,f,r)),Ee.readOnly.of(i)]}),parent:s.current}),kr(o.current))},[]),hN(o),pN(o.current,i,f,r,{updateListener:a.current,focusHandler:l.current,pasteHandler:u.current}),mN(o.current,t),Y("div",{ref:s})}),VQ=p_,SN=Gt.forwardRef(({className:n,...e},t)=>Y(Db,{ref:t,className:Yt("flex items-center justify-center rounded-xl bg-slate-50 p-1 shadow-[inset_0px_0px_2px_rgba(255,255,255,0.50)]",n),...e}));SN.displayName=Db.displayName;const uh=Gt.forwardRef(({className:n,...e},t)=>Y(Cb,{ref:t,className:Yt("flex w-full items-center justify-center whitespace-nowrap rounded-lg p-1 text-sm text-gray-500 transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-gray-50 data-[state=active]:text-gray-800 data-[state=active]:shadow-[0px_16px_16px_-4px_rgba(0,0,0,0.10)]",n),...e}));uh.displayName=Cb.displayName;const ch=Gt.forwardRef(({className:n,...e},t)=>Y(Pb,{ref:t,className:Yt("",n),...e}));ch.displayName=Pb.displayName;function Ab({modelName:n,stateSchema:e,initialValue:t,setStateSchema:i,setInitialState:r,scope:s}){const o=tS(),[a,l]=Ms(!1),u=ve(p=>kQ(p,n,s),[n,s]),f=ve(()=>{l(p=>!p)},[]),c=ve(p=>i(p,s),[i,s]),d=ve(p=>r(p,s),[r,s]),h=ve(()=>{const p=t||"{}",m=nn(o);if(!m)return;const g=nn(e);if(!g)return;const v=nS(n,s);if(!v)return;const y=g.definitions.find(S=>S.kind===z.OBJECT_TYPE_DEFINITION&&S.name.value===v);if(!y||y.kind!==z.OBJECT_TYPE_DEFINITION)return;const O=ek({sharedSchemaDocumentNode:m,stateTypeDefinitionNode:y,existingValue:p});r(O,s)},[o,t,r,s]);return Me("div",{className:"grid grid-cols-2 gap-4",children:[Me("div",{children:[Me("h3",{className:"mb-2 text-lg capitalize",children:[s," state schema"]}),Me(lh,{onClick:f,className:"mb-2 flex w-fit items-center gap-2",children:[a?"Hide":"Show"," standard library",Y("svg",{className:Yt("inline-block transition-transform",a?"rotate-180":"rotate-0"),xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:Y("path",{d:"M11.9883 6.01172C11.4363 6.01172 10.9883 6.45972 10.9883 7.01172V13.0117H6.98828L11.9883 18.0117L16.9883 13.0117H12.9883V7.01172C12.9883 6.45972 12.5403 6.01172 11.9883 6.01172Z",fill:"black"})})]}),a&&Y(ah,{doc:bh,readonly:!0}),Y(ah,{doc:e,updateDocumentInModel:c,customLinter:u})]}),Me("div",{children:[Me("div",{className:"flex flex-col items-end",children:[Me("h3",{className:"mb-2 text-right text-lg capitalize",children:[s," state initial value"]}),Me(lh,{onClick:h,className:"mb-2 flex w-fit items-center gap-2",children:["Sync with schema"," ",Y("svg",{className:"inline-block",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Y("path",{d:"M8.00521 1.99219C6.63588 1.99219 5.32788 2.45152 4.27588 3.28419C3.98721 3.51219 3.94321 3.93285 4.17188 4.22151C4.40054 4.51018 4.82055 4.55418 5.10921 4.32552C5.92721 3.67819 6.93921 3.32552 8.00521 3.32552C10.5825 3.32552 12.6719 5.41485 12.6719 7.99218H11.3385L13.3385 10.6588L15.3385 7.99218H14.0052C14.0052 4.67818 11.3192 1.99219 8.00521 1.99219ZM2.67188 5.32552L0.671875 7.99218H2.00521C2.00521 11.3062 4.69121 13.9922 8.00521 13.9922C9.37521 13.9922 10.6825 13.5335 11.7345 12.7002C12.0232 12.4722 12.0672 12.0515 11.8385 11.7628C11.6099 11.4742 11.1899 11.4302 10.9012 11.6588C10.0825 12.3068 9.07188 12.6588 8.00521 12.6588C5.42788 12.6588 3.33854 10.5695 3.33854 7.99218H4.67188L2.67188 5.32552Z",fill:"#343839"})})]})]}),Y(FQ,{doc:t,updateDocumentInModel:d})]})]})}function BQ({modelName:n,globalStateSchema:e,localStateSchema:t,globalStateInitialValue:i,localStateInitialValue:r,setStateSchema:s,setInitialState:o}){const a=ve(()=>{const l=Oh(n,"local");s(l,"local"),o("","local")},[n,s,o]);return Me(VQ,{className:"pb-8",activationMode:"manual",defaultValue:"global",children:[Y("div",{className:"my-6",children:Me(SN,{className:"mx-auto flex max-w-sm",children:[Y(uh,{value:"global",children:"Global"}),Y(uh,{value:"local",children:"Local"})]})}),Y(ch,{value:"global",tabIndex:-1,children:Y(Ab,{modelName:n,stateSchema:e,initialValue:i,setStateSchema:s,setInitialState:o,scope:"global"})}),Y(ch,{value:"local",tabIndex:-1,children:t?Y(Ab,{modelName:n,stateSchema:t,initialValue:r,setStateSchema:s,setInitialState:o,scope:"local"}):Me("div",{className:"",children:[Y("h3",{className:"mb-2 text-lg capitalize",children:"local state schema"}),Y(lh,{onClick:a,children:"Add local state"})]})})]})}function UQ(n){const{document:e,documentNodeName:t,dispatch:i}=n,{name:r,id:s,extension:o,description:a,author:{name:l,website:u}}=to(()=>e.state.global,[e.state.global]),{state:{global:{schema:f,initialValue:c},local:{schema:d,initialValue:h}},modules:p}=to(()=>e.state.global.specifications[0],[e.state.global.specifications[0]]),m=to(()=>p.flatMap(B=>B.operations),[p]),g=_t(!r&&!!t&&m.length===0);en(()=>{!g.current||!t||(i(Ep({name:t})),aS({modelName:t,setStateSchema:(B,ee)=>{i(Ap({schema:B,scope:ee}))}}),g.current=!1)},[t]);const v=to(()=>m.flatMap(B=>B.schema??[]).join(`
113
113
  `),[m]),y=ve(B=>{ut(B,s)||i(m_({id:B}))},[s]),O=ve(B=>{ut(B,a)||i(g_({description:B}))},[a]),S=ve(B=>{ut(B,o)||i(v_({extension:B}))},[o]),b=ve(B=>{ut(B,r)||i(Ep({name:B}))},[r]),T=ve(B=>{ut(B,l)||i(y_({authorName:B}))},[l]),w=ve(B=>{ut(B,u??"")||i(b_({authorWebsite:B}))},[u]),C=ve((B,ee)=>{ut(B,ee==="global"?f:d)||i(Ap({schema:B,scope:ee}))},[f,d]),D=ve((B,ee)=>{ut(B,ee==="global"?c:h)||i(O_({initialValue:B,scope:ee}))},[c,h]),k=ve(B=>new Promise(ee=>{try{if(p.some(pe=>ut(pe.name,B))){ee(void 0);return}const ie=Gc();i(S_({id:ie,name:B})),ee(ie)}catch(ie){console.error("Failed to add module:",ie),ee(void 0)}}),[p]),$=ve((B,ee)=>{p.some(ie=>ut(ie.name,ee))||i(T_({id:B,name:ee}))},[p]),A=ve(B=>i(E_({id:B})),[]),N=ve((B,ee)=>new Promise(ie=>{var pe;try{if((((pe=p.find(Ue=>Ue.id===B))==null?void 0:pe.operations.map(Ue=>Ue.name).filter(Boolean))??[]).some(Ue=>ut(Ue,ee))){ie(void 0);return}const Le=Gc();i(A_({id:Le,moduleId:B,name:ee})),ie(Le)}catch(xe){console.error("Failed to add operation:",xe),ie(void 0)}}),[p]),I=ve((B,ee)=>{const ie=p.find(xe=>xe.operations.some(Le=>Le.id===B));((ie==null?void 0:ie.operations.map(xe=>xe.name).filter(Boolean))??[]).some(xe=>ut(xe,ee))||i(N_({id:B,name:ee}))},[p]),R=ve((B,ee)=>{const ie=m.find(pe=>pe.id===B);ie!=null&&ie.schema&&ut(ee,ie.schema)||i(__({id:B,schema:ee}))},[m]),F=ve((B,ee)=>{var pe;const ie=((pe=m.find(xe=>xe.id===B))==null?void 0:pe.description)??"";ut(ie,ee)||i(w_({id:B,description:ee}))},[m]),U=ve(B=>i(x_({id:B})),[]),X=ve((B,ee)=>new Promise(ie=>{try{const pe=m.find(Ue=>Ue.id===B);if(((pe==null?void 0:pe.errors.map(Ue=>Ue.name).filter(Boolean))??[]).some(Ue=>ut(Ue,ee))){ie(void 0);return}const Le=Gc();i(k_({id:Le,operationId:B,errorName:ee})),ie(Le)}catch(pe){console.error("Failed to add operation error:",pe),ie(void 0)}}),[m]),te=ve(B=>i(I_({id:B})),[]),ue=ve((B,ee,ie)=>{const pe=m.find(Le=>Le.id===B);((pe==null?void 0:pe.errors.map(Le=>Le.name).filter(Boolean))??[]).some(Le=>ut(Le,ie))||i(R_({id:ee,errorName:ie}))},[m]),fe=ve(async(B,ee)=>{try{const ie=await N(B,ee);if(!ie)return;try{return R(ie,Xx(ee)),ie}catch(pe){console.error("Failed to update operation schema:",pe);return}}catch(ie){console.error("Failed to add operation and schema:",ie);return}},[N,R]);return Y("main",{className:"min-h-dvh bg-gray-50",children:Y(Kx,{globalStateSchemaSdl:f,localStateSchemaSdl:d,operationSchemasSdl:v,children:Me("div",{className:"mx-auto max-w-6xl px-4 pt-8",children:[Y(mR,{name:r,documentType:s,extension:o,description:a,authorName:l,authorWebsite:u??"",globalStateSchema:f,localStateSchema:d,setModelId:y,setModelDescription:O,setModelExtension:S,setModelName:b,setAuthorName:T,setAuthorWebsite:w,setStateSchema:C}),Y(kp,{}),Me("div",{children:[Y(BQ,{modelName:r,globalStateSchema:f,globalStateInitialValue:c,localStateSchema:d,localStateInitialValue:h,setStateSchema:C,setInitialState:D}),Y(kp,{}),Y("h3",{className:"mb-6 text-lg",children:"Global Operations"}),Y(CQ,{modules:p,allOperations:m,addModule:k,updateModuleName:$,deleteModule:A,updateOperationName:I,updateOperationSchema:R,setOperationDescription:F,deleteOperation:U,addOperationError:X,deleteOperationError:te,setOperationErrorName:ue,addOperationAndInitialSchema:fe})]})]})})})}const rF={Component:UQ,documentTypes:["powerhouse/document-model"],config:{id:"document-model-editor-v2",disableExternalControls:!0,documentToolbarEnabled:!0,timelineEnabled:!0}};export{UQ as DocumentModelEditor,rF as documentModelEditorModule};
114
- //# sourceMappingURL=index.CLzXE8sZ.js.map
114
+ //# sourceMappingURL=index.Byl5M-El.js.map