@powerhousedao/connect 5.0.0-staging.20 → 5.0.0-staging.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{atlas-import.Bj7HUsJ4.js → atlas-import.BKRUFBh0.js} +2 -2
- package/dist/assets/{atlas-import.Bj7HUsJ4.js.map → atlas-import.BKRUFBh0.js.map} +1 -1
- package/dist/assets/{ccip.zxjGI3Ev.js → ccip.DzCJWzQP.js} +2 -2
- package/dist/assets/{ccip.zxjGI3Ev.js.map → ccip.DzCJWzQP.js.map} +1 -1
- package/dist/assets/{content.DaMUdAfE.js → content.DeZaBgk3.js} +2 -2
- package/dist/assets/{content.DaMUdAfE.js.map → content.DeZaBgk3.js.map} +1 -1
- package/dist/assets/{creators.DJrPlwjp.js → creators.eOVV7E7q.js} +2 -2
- package/dist/assets/{creators.DJrPlwjp.js.map → creators.eOVV7E7q.js.map} +1 -1
- package/dist/assets/{drive-icon.N9u4cB72.js → drive-icon.Cp6t7_a-.js} +2 -2
- package/dist/assets/{drive-icon.N9u4cB72.js.map → drive-icon.Cp6t7_a-.js.map} +1 -1
- package/dist/assets/{index.Dzn2Arpa.js → index.B83sp92N.js} +2 -2
- package/dist/assets/{index.Dzn2Arpa.js.map → index.B83sp92N.js.map} +1 -1
- package/dist/assets/{index.D4RioTUr.js → index.BA60GCbl.js} +2 -2
- package/dist/assets/{index.D4RioTUr.js.map → index.BA60GCbl.js.map} +1 -1
- package/dist/assets/{index.HnRmsJtU.js → index.BIpCC4zI.js} +2 -2
- package/dist/assets/{index.HnRmsJtU.js.map → index.BIpCC4zI.js.map} +1 -1
- package/dist/assets/{index.B8X3pCNf.js → index.CT06rHcb.js} +2 -2
- package/dist/assets/{index.B8X3pCNf.js.map → index.CT06rHcb.js.map} +1 -1
- package/dist/assets/{index.gF400SWr.js → index.D0aC1QBy.js} +2 -2
- package/dist/assets/{index.gF400SWr.js.map → index.D0aC1QBy.js.map} +1 -1
- package/dist/assets/{index.Bo6UVlKn.js → index.DqBwIqO4.js} +2 -2
- package/dist/assets/{index.Bo6UVlKn.js.map → index.DqBwIqO4.js.map} +1 -1
- package/dist/assets/{index.I2T5YRSR.js → index.LxvJEgJH.js} +2 -2
- package/dist/assets/{index.I2T5YRSR.js.map → index.LxvJEgJH.js.map} +1 -1
- package/dist/assets/{main.Dqu7gkaw.js → main.BIQyGbmq.js} +7 -7
- package/dist/assets/{main.Dqu7gkaw.js.map → main.BIQyGbmq.js.map} +1 -1
- package/dist/assets/{nodefs.DcDEsLp9.js → nodefs.CH3u3B05.js} +2 -2
- package/dist/assets/{nodefs.DcDEsLp9.js.map → nodefs.CH3u3B05.js.map} +1 -1
- package/dist/assets/{opfs-ahp.Dcael7XS.js → opfs-ahp.C5GpEdm1.js} +2 -2
- package/dist/assets/{opfs-ahp.Dcael7XS.js.map → opfs-ahp.C5GpEdm1.js.map} +1 -1
- package/dist/assets/{root.C1QCTpFH.js → root.CTyLyX0x.js} +2 -2
- package/dist/assets/{root.C1QCTpFH.js.map → root.CTyLyX0x.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/vite-envs.sh +1 -1
- package/package.json +9 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var v=Object.defineProperty;var _=(o,e,t)=>e in o?v(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var f=(o,e,t)=>_(o,typeof e!="symbol"?e+"":e,t);import{k as O,A as i,D as I}from"./main.
|
|
2
|
-
//# sourceMappingURL=index.
|
|
1
|
+
var v=Object.defineProperty;var _=(o,e,t)=>e in o?v(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var f=(o,e,t)=>_(o,typeof e!="symbol"?e+"":e,t);import{k as O,A as i,D as I}from"./main.BIQyGbmq.js";import"react/jsx-runtime";import"react-dom/client";import"react";import"react-dom";class w{constructor(e,t=O(["processor","document-analytics"])){f(this,"analyticsStore");f(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 E=t.operations[0],u=i.fromString(`ph/doc/${t.driveId}/${t.documentId}/${t.branch}/${t.scope}`);E.index===0&&await this.clearSource(u);const{driveId:s,documentId:g,branch:m,scope:a}=t,l=s===g?"DRIVE":"NODE",d=50;for(let r=0;r<t.operations.length;r+=d){const n=t.operations.slice(r,r+d),c=[];for(const p of n){const D=p.index,h={source:u,metric:"DocumentOperations",start:I.fromISO(p.timestampUtcMs),value:1,dimensions:{drive:i.fromString(`ph/doc/drive/${s}/${m}/${a}/${D}`),operation:i.fromString(`ph/doc/operation/${p.action.type}/${p.index}`),target:i.fromString(`ph/doc/target/${s}/${l}/${g}`)}};for(c.push(h);c.length>=d;){const y=c.splice(0,d);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"])){f(this,"analyticsStore");f(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 E=t.operations[0],u=i.fromString(`ph/drive/${t.documentId}/${t.branch}/${t.scope}`);E.index===0&&await this.clearSource(u);const{documentId:s,branch:g,scope:m}=t,a=50;for(let l=0;l<t.operations.length;l+=a){const d=t.operations.slice(l,l+a),r=[];for(const n of d){const c=n.index,p=this.getActionType(n.action.type),D=V.includes(n.action.type)?"NODE":"DRIVE";let h=s;if(D==="NODE"){const S=n.action.input;h=S.id||S.targetId||S.srcFolder||s}const y={source:u,metric:"DriveOperations",start:I.fromISO(n.timestampUtcMs),value:1,dimensions:{drive:i.fromString(`ph/drive/${s}/${g}/${m}/${c}`),operation:i.fromString(`ph/drive/operation/${n.action.type}/${n.index}`),target:i.fromString(`ph/drive/target/${D}/${h}`),actionType:i.fromString(`ph/drive/actionType/${p}/${h}`)}};for(r.push(y);r.length>=a;){const S=r.splice(0,a);await this.analyticsStore.addSeriesValues(S)}}r.length>0&&await this.analyticsStore.addSeriesValues(r)}}}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 R=o=>e=>[{processor:new b(o.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["powerhouse/document-drive"]}},{processor:new w(o.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{w as DocumentAnalyticsProcessor,b as DriveAnalyticsProcessor,R as processorFactory};
|
|
2
|
+
//# sourceMappingURL=index.BIpCC4zI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.HnRmsJtU.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.timestampUtcMs),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/doc/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/doc/operation/${operation.action.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.action.type);\n const target = NODE_ACTIONS.includes(operation.action.type)\n ? \"NODE\"\n : \"DRIVE\";\n let targetId = driveId;\n if (target === \"NODE\") {\n const operationInput = operation.action.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.timestampUtcMs),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/drive/operation/${operation.action.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) => (driveHeader) => {\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","driveHeader"],"mappings":"4SAEO,MAAMA,CAA2B,CAGpC,YAAYC,EAAgBC,EAASC,EAAY,CAAC,YAAa,oBAAoB,CAAC,EAAG,CAFvFC,EAAA,uBACAA,EAAA,eAEI,KAAK,eAAiBH,EACtB,KAAK,OAASC,CAElB,CACA,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,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
|
+
{"version":3,"file":"index.BIpCC4zI.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.timestampUtcMs),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/doc/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/doc/operation/${operation.action.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.action.type);\n const target = NODE_ACTIONS.includes(operation.action.type)\n ? \"NODE\"\n : \"DRIVE\";\n let targetId = driveId;\n if (target === \"NODE\") {\n const operationInput = operation.action.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.timestampUtcMs),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/drive/operation/${operation.action.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) => (driveHeader) => {\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","driveHeader"],"mappings":"4SAEO,MAAMA,CAA2B,CAGpC,YAAYC,EAAgBC,EAASC,EAAY,CAAC,YAAa,oBAAoB,CAAC,EAAG,CAFvFC,EAAA,uBACAA,EAAA,eAEI,KAAK,eAAiBH,EACtB,KAAK,OAASC,CAElB,CACA,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,MAAA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,ak as w,al as k}from"./main.Dqu7gkaw.js";import{aK as Pt,ao as Ct,ap as wt,aq as kt,aF as vt,aG as Ut,aH as yt,at as jt,as as Gt,aI as Ht,aJ as Xt,aL as Vt,aM as $t,ar as Ft,aN as Wt,am as Bt,aO as zt,aA as Qt,aP as qt,aB as Jt,aC as Kt,aQ as Zt,an as Yt,aR as eo,aD as to,aS as oo,aT as ro,aE as no,au as ao,av as io,aw as so,ax as po,ay as lo,az as mo}from"./main.Dqu7gkaw.js";import{A as O,U as S,D as h,R as g,a as I,b as f,c as _,d as D,e as v,f as U,g as y,h as j,i as G,j as H,k as X,l as V,m as $,r as F,n as W,o as B,p as z,s as Q,q,t as J,u as K,v as Z,w as Y,x as ee,y as te,z as oe,B as re,C as ne,E as ae,F as ie,G as se,H as pe,I as le,J as de,K as me,L as ce,M as ue,N as Ee,O as Oe,P as Se,Q as he,S as ge,T as Ie,V as fe,W as _e,X as De,Y as Te,Z as Re,_ as be,$ as Ae,a0 as xe,a1 as Me,a2 as Ne,a3 as Le,a4 as Pe,a5 as Ce,a6 as we,a7 as ke,a8 as ve,a9 as Ue,aa as ye,ab as je,ac as Ge,ad as He,ae as Xe,af as Ve,ag as $e,ah as Fe,ai as We,aj as Be,ak as ze,al as Qe}from"./creators.DJrPlwjp.js";import"react/jsx-runtime";import"react-dom/client";import"react";import"react-dom";const qe=t=>s("ADD_CHANGE_LOG_ITEM",{...t},void 0,O,"global"),Je=t=>s("UPDATE_CHANGE_LOG_ITEM",{...t},void 0,S,"global"),Ke=t=>s("DELETE_CHANGE_LOG_ITEM",{...t},void 0,h,"global"),Ze=t=>s("REORDER_CHANGE_LOG_ITEMS",{...t},void 0,g,"global"),Ye=()=>s("RELEASE_NEW_VERSION",{},void 0,void 0,"global"),et=t=>s("ADD_OPERATION_EXAMPLE",{...t},void 0,I,"global"),tt=t=>s("UPDATE_OPERATION_EXAMPLE",{...t},void 0,f,"global"),ot=t=>s("DELETE_OPERATION_EXAMPLE",{...t},void 0,_,"global"),rt=t=>s("REORDER_OPERATION_EXAMPLES",{...t},void 0,D,"global"),nt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:qe,addModule:v,addOperation:U,addOperationError:y,addOperationExample:et,addStateExample:j,deleteChangeLogItem:Ke,deleteModule:G,deleteOperation:H,deleteOperationError:X,deleteOperationExample:ot,deleteStateExample:V,moveOperation:$,releaseNewVersion:Ye,reorderChangeLogItems:Ze,reorderModuleOperations:F,reorderModules:W,reorderOperationErrors:B,reorderOperationExamples:rt,reorderStateExamples:z,setAuthorName:Q,setAuthorWebsite:q,setInitialState:J,setModelDescription:K,setModelExtension:Z,setModelId:Y,setModelName:ee,setModuleDescription:te,setModuleName:oe,setOperationDescription:re,setOperationErrorCode:ne,setOperationErrorDescription:ae,setOperationErrorName:ie,setOperationErrorTemplate:se,setOperationName:pe,setOperationReducer:le,setOperationSchema:de,setOperationScope:me,setOperationTemplate:ce,setStateSchema:ue,updateChangeLogItem:Je,updateOperationExample:tt,updateStateExample:Ee},Symbol.toStringTag,{value:"Module"})),l={setModelNameOperation(t,e){t.name=e.input.name},setModelIdOperation(t,e){t.id=e.input.id},setModelExtensionOperation(t,e){t.extension=e.input.extension},setModelDescriptionOperation(t,e){t.description=e.input.description},setAuthorNameOperation(t,e){t.author=t.author||{name:"",website:null},t.author.name=e.input.authorName},setAuthorWebsiteOperation(t,e){t.author=t.author||{name:"",website:null},t.author.website=e.input.authorWebsite}},at=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},m={addModuleOperation(t,e){t.specifications[t.specifications.length-1].modules.push({id:e.input.id,name:e.input.name,description:e.input.description||"",operations:[]})},setModuleNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id===e.input.id&&(r.modules[o].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id===e.input.id&&(r.modules[o].description=e.input.description||"")},deleteModuleOperation(t,e){const r=t.specifications[t.specifications.length-1];r.modules=r.modules.filter(o=>o.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(at(e.input.order))}},it=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},p={addOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].errors.push({id:e.input.id,name:e.input.errorName||"",code:e.input.errorCode||"",description:e.input.errorDescription||"",template:e.input.errorTemplate||""})},setOperationErrorCodeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].errors=r.modules[o].operations[n].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].errors.sort(it(e.input.order))}},st=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},u={addOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].examples.length;a++)r.modules[o].operations[n].examples[a].id==e.input.id&&(r.modules[o].operations[n].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].examples=r.modules[o].operations[n].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].examples.sort(st(e.input.order))}},pt=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},i={addOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id==e.input.moduleId&&r.modules[o].operations.push({id:e.input.id,name:e.input.name,description:e.input.description||"",schema:e.input.schema||"",template:e.input.template||e.input.description||"",reducer:e.input.reducer||"",errors:[],examples:[],scope:e.input.scope||"global"})},setOperationNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].name=e.input.name||"")},setOperationScopeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].description=e.input.description||"")},setOperationTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].template=e.input.template||"")},setOperationReducerOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const r=[],o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].operations=o.modules[n].operations.filter(a=>a.id==e.input.operationId?(r.push(a),!1):!0);for(let n=0;n<o.modules.length;n++)o.modules[n].id==e.input.newModuleId&&o.modules[n].operations.push(...r)},deleteOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].operations=r.modules[o].operations.filter(n=>n.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id==e.input.moduleId&&r.modules[o].operations.sort(pt(e.input.order))}},lt=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},d={setStateSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].schema=e.input.schema;else throw new Error(`Invalid scope: ${e.input.scope}`)},setInitialStateOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].initialValue=e.input.initialValue;else throw new Error(`Invalid scope: ${e.input.scope}`)},addStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.push({id:e.input.id,value:e.input.example});else throw new Error(`Invalid scope: ${e.input.scope}`)},updateStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(!Object.keys(r.state).includes(e.input.scope))throw new Error(`Invalid scope: ${e.input.scope}`);const o=r.state[e.input.scope].examples;for(let n=0;n<o.length;n++)o[n].id==e.input.id&&(o[n].value=e.input.newExample)},deleteStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples=r.state[e.input.scope].examples.filter(o=>o.id!=e.input.id);else throw new Error(`Invalid scope: ${e.input.scope}`)},reorderStateExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.sort(lt(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},c={addChangeLogItemOperation(t,e){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(t,e){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(t,e){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(t,e){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(t,e){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},dt=(t,e)=>{if(A(e))return t;switch(e.type){case"SET_MODEL_NAME":Qe().parse(e.input),l.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":ze().parse(e.input),l.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":Be().parse(e.input),l.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":We().parse(e.input),l.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":Fe().parse(e.input),l.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":$e().parse(e.input),l.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":O().parse(e.input),c.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":S().parse(e.input),c.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":h().parse(e.input),c.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":g().parse(e.input),c.reorderChangeLogItemsOperation(t.global,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");c.releaseNewVersionOperation(t.global,e);break;case"ADD_MODULE":Ve().parse(e.input),m.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":Xe().parse(e.input),m.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":He().parse(e.input),m.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":Ge().parse(e.input),m.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":je().parse(e.input),m.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":ye().parse(e.input),p.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":Ue().parse(e.input),p.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":ve().parse(e.input),p.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":ke().parse(e.input),p.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":we().parse(e.input),p.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":Ce().parse(e.input),p.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":Pe().parse(e.input),p.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),u.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":f().parse(e.input),u.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":_().parse(e.input),u.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":D().parse(e.input),u.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":Le().parse(e.input),i.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":Ne().parse(e.input),i.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":Me().parse(e.input),i.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":xe().parse(e.input),i.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":Ae().parse(e.input),i.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":be().parse(e.input),i.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":Re().parse(e.input),i.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":Te().parse(e.input),i.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":De().parse(e.input),i.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":_e().parse(e.input),i.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":fe().parse(e.input),d.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":Ie().parse(e.input),d.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":ge().parse(e.input),d.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":he().parse(e.input),d.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":Se().parse(e.input),d.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":Oe().parse(e.input),d.reorderStateExamplesOperation(t.global,e);break;default:return t}},E=b(dt),mt={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},ct={},T="phdm",ut="powerhouse/document-model",R=t=>({...x(),global:{...mt,...(t==null?void 0:t.global)??{}},local:{...ct,...(t==null?void 0:t.local)??{}}}),Et=t=>{const e=M(R,t);return e.header.documentType=ut,e},Ot=(t,e,r)=>N(t,e,T,r),St=(t,e)=>L(t,e),ht=t=>P(t,E),gt=t=>C(t,E),It=Object.freeze(Object.defineProperty({__proto__:null,createDocument:Et,createState:R,fileExtension:T,loadFromFile:ht,loadFromInput:gt,saveToFile:Ot,saveToFileHandle:St},Symbol.toStringTag,{value:"Module"})),ft={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type CodeExample {
|
|
1
|
+
import{ab as s,ac as b,ad as A,ae as x,af as M,ag as N,ah as L,ai as P,aj as C,ak as w,al as k}from"./main.BIQyGbmq.js";import{aK as Pt,ao as Ct,ap as wt,aq as kt,aF as vt,aG as Ut,aH as yt,at as jt,as as Gt,aI as Ht,aJ as Xt,aL as Vt,aM as $t,ar as Ft,aN as Wt,am as Bt,aO as zt,aA as Qt,aP as qt,aB as Jt,aC as Kt,aQ as Zt,an as Yt,aR as eo,aD as to,aS as oo,aT as ro,aE as no,au as ao,av as io,aw as so,ax as po,ay as lo,az as mo}from"./main.BIQyGbmq.js";import{A as O,U as S,D as h,R as g,a as I,b as f,c as _,d as D,e as v,f as U,g as y,h as j,i as G,j as H,k as X,l as V,m as $,r as F,n as W,o as B,p as z,s as Q,q,t as J,u as K,v as Z,w as Y,x as ee,y as te,z as oe,B as re,C as ne,E as ae,F as ie,G as se,H as pe,I as le,J as de,K as me,L as ce,M as ue,N as Ee,O as Oe,P as Se,Q as he,S as ge,T as Ie,V as fe,W as _e,X as De,Y as Te,Z as Re,_ as be,$ as Ae,a0 as xe,a1 as Me,a2 as Ne,a3 as Le,a4 as Pe,a5 as Ce,a6 as we,a7 as ke,a8 as ve,a9 as Ue,aa as ye,ab as je,ac as Ge,ad as He,ae as Xe,af as Ve,ag as $e,ah as Fe,ai as We,aj as Be,ak as ze,al as Qe}from"./creators.eOVV7E7q.js";import"react/jsx-runtime";import"react-dom/client";import"react";import"react-dom";const qe=t=>s("ADD_CHANGE_LOG_ITEM",{...t},void 0,O,"global"),Je=t=>s("UPDATE_CHANGE_LOG_ITEM",{...t},void 0,S,"global"),Ke=t=>s("DELETE_CHANGE_LOG_ITEM",{...t},void 0,h,"global"),Ze=t=>s("REORDER_CHANGE_LOG_ITEMS",{...t},void 0,g,"global"),Ye=()=>s("RELEASE_NEW_VERSION",{},void 0,void 0,"global"),et=t=>s("ADD_OPERATION_EXAMPLE",{...t},void 0,I,"global"),tt=t=>s("UPDATE_OPERATION_EXAMPLE",{...t},void 0,f,"global"),ot=t=>s("DELETE_OPERATION_EXAMPLE",{...t},void 0,_,"global"),rt=t=>s("REORDER_OPERATION_EXAMPLES",{...t},void 0,D,"global"),nt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:qe,addModule:v,addOperation:U,addOperationError:y,addOperationExample:et,addStateExample:j,deleteChangeLogItem:Ke,deleteModule:G,deleteOperation:H,deleteOperationError:X,deleteOperationExample:ot,deleteStateExample:V,moveOperation:$,releaseNewVersion:Ye,reorderChangeLogItems:Ze,reorderModuleOperations:F,reorderModules:W,reorderOperationErrors:B,reorderOperationExamples:rt,reorderStateExamples:z,setAuthorName:Q,setAuthorWebsite:q,setInitialState:J,setModelDescription:K,setModelExtension:Z,setModelId:Y,setModelName:ee,setModuleDescription:te,setModuleName:oe,setOperationDescription:re,setOperationErrorCode:ne,setOperationErrorDescription:ae,setOperationErrorName:ie,setOperationErrorTemplate:se,setOperationName:pe,setOperationReducer:le,setOperationSchema:de,setOperationScope:me,setOperationTemplate:ce,setStateSchema:ue,updateChangeLogItem:Je,updateOperationExample:tt,updateStateExample:Ee},Symbol.toStringTag,{value:"Module"})),l={setModelNameOperation(t,e){t.name=e.input.name},setModelIdOperation(t,e){t.id=e.input.id},setModelExtensionOperation(t,e){t.extension=e.input.extension},setModelDescriptionOperation(t,e){t.description=e.input.description},setAuthorNameOperation(t,e){t.author=t.author||{name:"",website:null},t.author.name=e.input.authorName},setAuthorWebsiteOperation(t,e){t.author=t.author||{name:"",website:null},t.author.website=e.input.authorWebsite}},at=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},m={addModuleOperation(t,e){t.specifications[t.specifications.length-1].modules.push({id:e.input.id,name:e.input.name,description:e.input.description||"",operations:[]})},setModuleNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id===e.input.id&&(r.modules[o].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id===e.input.id&&(r.modules[o].description=e.input.description||"")},deleteModuleOperation(t,e){const r=t.specifications[t.specifications.length-1];r.modules=r.modules.filter(o=>o.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(at(e.input.order))}},it=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},p={addOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].errors.push({id:e.input.id,name:e.input.errorName||"",code:e.input.errorCode||"",description:e.input.errorDescription||"",template:e.input.errorTemplate||""})},setOperationErrorCodeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].errors.length;a++)r.modules[o].operations[n].errors[a].id==e.input.id&&(r.modules[o].operations[n].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].errors=r.modules[o].operations[n].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].errors.sort(it(e.input.order))}},st=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},u={addOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)for(let a=0;a<r.modules[o].operations[n].examples.length;a++)r.modules[o].operations[n].examples[a].id==e.input.id&&(r.modules[o].operations[n].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].examples=r.modules[o].operations[n].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.operationId&&r.modules[o].operations[n].examples.sort(st(e.input.order))}},pt=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},i={addOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id==e.input.moduleId&&r.modules[o].operations.push({id:e.input.id,name:e.input.name,description:e.input.description||"",schema:e.input.schema||"",template:e.input.template||e.input.description||"",reducer:e.input.reducer||"",errors:[],examples:[],scope:e.input.scope||"global"})},setOperationNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].name=e.input.name||"")},setOperationScopeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].description=e.input.description||"")},setOperationTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].template=e.input.template||"")},setOperationReducerOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)for(let n=0;n<r.modules[o].operations.length;n++)r.modules[o].operations[n].id==e.input.id&&(r.modules[o].operations[n].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const r=[],o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].operations=o.modules[n].operations.filter(a=>a.id==e.input.operationId?(r.push(a),!1):!0);for(let n=0;n<o.modules.length;n++)o.modules[n].id==e.input.newModuleId&&o.modules[n].operations.push(...r)},deleteOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].operations=r.modules[o].operations.filter(n=>n.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let o=0;o<r.modules.length;o++)r.modules[o].id==e.input.moduleId&&r.modules[o].operations.sort(pt(e.input.order))}},lt=t=>{const e={};return t.forEach((r,o)=>e[r]=o),(r,o)=>(e[o.id]||999999)-(e[r.id]||999999)},d={setStateSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].schema=e.input.schema;else throw new Error(`Invalid scope: ${e.input.scope}`)},setInitialStateOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].initialValue=e.input.initialValue;else throw new Error(`Invalid scope: ${e.input.scope}`)},addStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.push({id:e.input.id,value:e.input.example});else throw new Error(`Invalid scope: ${e.input.scope}`)},updateStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(!Object.keys(r.state).includes(e.input.scope))throw new Error(`Invalid scope: ${e.input.scope}`);const o=r.state[e.input.scope].examples;for(let n=0;n<o.length;n++)o[n].id==e.input.id&&(o[n].value=e.input.newExample)},deleteStateExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples=r.state[e.input.scope].examples.filter(o=>o.id!=e.input.id);else throw new Error(`Invalid scope: ${e.input.scope}`)},reorderStateExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];if(Object.keys(r.state).includes(e.input.scope))r.state[e.input.scope].examples.sort(lt(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},c={addChangeLogItemOperation(t,e){throw new Error('Reducer "addChangeLogItemOperation" not yet implemented')},updateChangeLogItemOperation(t,e){throw new Error('Reducer "updateChangeLogItemOperation" not yet implemented')},deleteChangeLogItemOperation(t,e){throw new Error('Reducer "deleteChangeLogItemOperation" not yet implemented')},reorderChangeLogItemsOperation(t,e){throw new Error('Reducer "reorderChangeLogItemsOperation" not yet implemented')},releaseNewVersionOperation(t,e){throw new Error('Reducer "releaseNewVersionOperation" not yet implemented')}},dt=(t,e)=>{if(A(e))return t;switch(e.type){case"SET_MODEL_NAME":Qe().parse(e.input),l.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":ze().parse(e.input),l.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":Be().parse(e.input),l.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":We().parse(e.input),l.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":Fe().parse(e.input),l.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":$e().parse(e.input),l.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":O().parse(e.input),c.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":S().parse(e.input),c.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":h().parse(e.input),c.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":g().parse(e.input),c.reorderChangeLogItemsOperation(t.global,e);break;case"RELEASE_NEW_VERSION":if(Object.keys(e.input).length>0)throw new Error("Expected empty input for action RELEASE_NEW_VERSION");c.releaseNewVersionOperation(t.global,e);break;case"ADD_MODULE":Ve().parse(e.input),m.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":Xe().parse(e.input),m.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":He().parse(e.input),m.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":Ge().parse(e.input),m.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":je().parse(e.input),m.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":ye().parse(e.input),p.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":Ue().parse(e.input),p.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":ve().parse(e.input),p.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":ke().parse(e.input),p.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":we().parse(e.input),p.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":Ce().parse(e.input),p.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":Pe().parse(e.input),p.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),u.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":f().parse(e.input),u.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":_().parse(e.input),u.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":D().parse(e.input),u.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":Le().parse(e.input),i.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":Ne().parse(e.input),i.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":Me().parse(e.input),i.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":xe().parse(e.input),i.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":Ae().parse(e.input),i.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":be().parse(e.input),i.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":Re().parse(e.input),i.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":Te().parse(e.input),i.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":De().parse(e.input),i.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":_e().parse(e.input),i.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":fe().parse(e.input),d.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":Ie().parse(e.input),d.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":ge().parse(e.input),d.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":he().parse(e.input),d.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":Se().parse(e.input),d.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":Oe().parse(e.input),d.reorderStateExamplesOperation(t.global,e);break;default:return t}},E=b(dt),mt={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},ct={},T="phdm",ut="powerhouse/document-model",R=t=>({...x(),global:{...mt,...(t==null?void 0:t.global)??{}},local:{...ct,...(t==null?void 0:t.local)??{}}}),Et=t=>{const e=M(R,t);return e.header.documentType=ut,e},Ot=(t,e,r)=>N(t,e,T,r),St=(t,e)=>L(t,e),ht=t=>P(t,E),gt=t=>C(t,E),It=Object.freeze(Object.defineProperty({__proto__:null,createDocument:Et,createState:R,fileExtension:T,loadFromFile:ht,loadFromInput:gt,saveToFile:Ot,saveToFileHandle:St},Symbol.toStringTag,{value:"Module"})),ft={id:"powerhouse/document-model",name:"DocumentModel",extension:"phdm",description:"The Powerhouse Document Model describes the state and operations of a document type.",author:{name:"Powerhouse",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type CodeExample {
|
|
2
2
|
id: ID!
|
|
3
3
|
value: String!
|
|
4
4
|
}
|
|
@@ -207,4 +207,4 @@ type DocumentModelState {
|
|
|
207
207
|
scope: String!
|
|
208
208
|
order: [ID!]!
|
|
209
209
|
}`,template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}]}]},_t={...k,...nt},Mt={reducer:E,documentModel:ft,actions:_t,utils:{...It,...w}};export{k as actions,v as addModule,U as addOperation,y as addOperationError,Pt as attachBranch,M as baseCreateDocument,P as baseLoadFromFile,C as baseLoadFromInput,N as baseSaveToFile,L as baseSaveToFileHandle,Ct as buildOperationSignature,wt as buildOperationSignatureMessage,kt as buildSignedAction,s as createAction,vt as createAuthState,Ut as createBaseState,Et as createDocument,yt as createDocumentState,jt as createPresignedHeader,b as createReducer,R as createState,Gt as createZip,Ht as defaultAuthState,x as defaultBaseState,Xt as defaultDocumentState,G as deleteModule,H as deleteOperation,X as deleteOperationError,_t as documentModelActions,Mt as documentModelDocumentModelModule,ht as documentModelLoadFromFile,E as documentModelReducer,Vt as garbageCollect,$t as garbageCollectDocumentOperations,Ft as generateId,Wt as groupOperationsByScope,Bt as hashDocumentStateForScope,A as isDocumentAction,zt as merge,Qt as noop,qt as precedes,Jt as prune,Kt as redo,Zt as removeExistingOperations,Yt as replayDocument,eo as reshuffleByTimestamp,Q as setAuthorName,q as setAuthorWebsite,J as setInitialState,K as setModelDescription,Z as setModelExtension,Y as setModelId,ee as setModelName,oe as setModuleName,to as setName,re as setOperationDescription,ie as setOperationErrorName,pe as setOperationName,de as setOperationSchema,ue as setStateSchema,oo as skipHeaderOperations,ro as sortOperations,no as undo,ao as validateHeader,io as validateInitialState,so as validateModule,po as validateModuleOperation,lo as validateModules,mo as validateStateSchemaName};
|
|
210
|
-
//# sourceMappingURL=index.
|
|
210
|
+
//# sourceMappingURL=index.CT06rHcb.js.map
|