document-model 1.0.34 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/document-model.cjs +1 -1
- package/dist/browser/document-model.js +12 -7
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/internal/index-CsKglrKe.js +22 -0
- package/dist/browser/internal/{index-CDGYwLIP.js → index-DJYIO2I4.js} +572 -405
- package/dist/browser/src/document-model/custom/utils.d.ts +7 -1
- package/dist/browser/src/document-model/index.d.ts +5 -0
- package/dist/browser/test/document-model/validation.test.d.ts +1 -0
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +11 -6
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/internal/index-BLZ2ydMH.js +22 -0
- package/dist/node/internal/{index-CEkeEja8.js → index-DfxrIKIl.js} +572 -405
- package/dist/node/src/document-model/custom/utils.d.ts +7 -1
- package/dist/node/src/document-model/index.d.ts +5 -0
- package/dist/node/test/document-model/validation.test.d.ts +1 -0
- package/package.json +2 -1
- package/dist/browser/internal/index-368Qgjhp.js +0 -22
- package/dist/node/internal/index-qa67kbhM.js +0 -22
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { ValidationError } from '../../document';
|
|
2
|
+
import { Module, Operation } from '../gen/schema';
|
|
3
|
+
export declare function validateInitialState(initialState: string, allowEmptyState?: boolean): ValidationError[];
|
|
4
|
+
export declare function validateStateSchemaName(schema: string, documentName: string, scope?: string, allowEmptySchema?: boolean): ValidationError[];
|
|
5
|
+
export declare function validateModules(modules: Array<Module>): ValidationError[];
|
|
6
|
+
export declare function validateModule(mod: Module): ValidationError[];
|
|
7
|
+
export declare function validateModuleOperation(operation: Operation): ValidationError[];
|
|
@@ -9,6 +9,11 @@ import { reducer } from './gen/reducer';
|
|
|
9
9
|
import { DocumentModelAction, DocumentModelLocalState, DocumentModelState } from './gen/types';
|
|
10
10
|
declare const Document: typeof DocumentModel;
|
|
11
11
|
declare const utils: {
|
|
12
|
+
validateInitialState(initialState: string, allowEmptyState?: boolean): import("../document").ValidationError[];
|
|
13
|
+
validateStateSchemaName(schema: string, documentName: string, scope?: string, allowEmptySchema?: boolean): import("../document").ValidationError[];
|
|
14
|
+
validateModules(modules: import("./gen").Module[]): import("../document").ValidationError[];
|
|
15
|
+
validateModule(mod: import("./gen").Module): import("../document").ValidationError[];
|
|
16
|
+
validateModuleOperation(operation: import("./gen").Operation): import("../document").ValidationError[];
|
|
12
17
|
fileExtension: string;
|
|
13
18
|
createState: import("../document").CreateState<DocumentModelState, DocumentModelLocalState>;
|
|
14
19
|
createExtendedState: (extendedState?: Partial<import("../document").ExtendedState<import("../document").PartialState<DocumentModelState>, import("../document").PartialState<DocumentModelLocalState>>> | undefined, createState?: import("../document").CreateState<DocumentModelState, DocumentModelLocalState> | undefined) => import("../document").ExtendedState<DocumentModelState, DocumentModelLocalState>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-model",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": false,
|
|
6
6
|
"files": [
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"vitest": "^1.2.1"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
+
"change-case": "^5.4.3",
|
|
84
85
|
"immer": "^10.0.3",
|
|
85
86
|
"json-stringify-deterministic": "1.0.12",
|
|
86
87
|
"jszip": "^3.10.1",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";var mt=Object.defineProperty;var Et=(t,e,r)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var me=(t,e,r)=>(Et(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-C8B-mq5Y.js");require("immer");require("json-stringify-deterministic");require("jszip");const o=require("zod"),ht=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={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:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
|
|
2
|
-
"id": "",
|
|
3
|
-
"name": "",
|
|
4
|
-
"extension": "",
|
|
5
|
-
"description": "",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "",
|
|
8
|
-
"website": ""
|
|
9
|
-
},
|
|
10
|
-
"specifications": [
|
|
11
|
-
{
|
|
12
|
-
"version": 1,
|
|
13
|
-
"changeLog": [],
|
|
14
|
-
"state": {
|
|
15
|
-
"schema": "",
|
|
16
|
-
"initialValue": "",
|
|
17
|
-
"examples": []
|
|
18
|
-
},
|
|
19
|
-
"modules": []
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}`,examples:[]},local:{schema:"",initialValue:"{}",examples:[]}}}]},Ee=t=>t!=null,Ot=o.z.any().refine(t=>Ee(t));function z(){return o.z.object({__typename:o.z.literal("AddChangeLogItemInput").optional(),content:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullable()})}function A(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),name:o.z.string()})}function I(){return o.z.object({errorCode:o.z.string().nullish(),errorDescription:o.z.string().nullish(),errorName:o.z.string().nullish(),errorTemplate:o.z.string().nullish(),id:o.z.string(),operationId:o.z.string()})}function T(){return o.z.object({example:o.z.string(),id:o.z.string(),operationId:o.z.string()})}function R(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),moduleId:o.z.string(),name:o.z.string(),reducer:o.z.string().nullish(),schema:o.z.string().nullish(),template:o.z.string().nullish(),scope:S().nullish()})}function D(){return o.z.object({scope:o.z.string(),example:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullish()})}function he(){return o.z.object({__typename:o.z.literal("Author").optional(),name:o.z.string(),website:o.z.string().nullable()})}function M(){return o.z.object({__typename:o.z.literal("CodeExample").optional(),id:o.z.string(),value:o.z.string()})}function x(){return o.z.object({__typename:o.z.literal("DeleteChangeLogItemInput").optional(),id:o.z.string()})}function N(){return o.z.object({id:o.z.string()})}function L(){return o.z.object({id:o.z.string()})}function j(){return o.z.object({id:o.z.string()})}function P(){return o.z.object({id:o.z.string()})}function C(){return o.z.object({scope:o.z.string(),id:o.z.string()})}function S(){return o.z.literal("global").or(o.z.literal("local"))}function gt(){return o.z.union([z(),A(),I(),T(),R(),D(),x(),N(),L(),j(),P(),C(),k(),y(),w(),v(),U(),V(),F(),H(),$(),X(),G(),B(),W(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae(),pe(),le()])}function St(){return o.z.object({__typename:o.z.literal("DocumentModelState").optional(),author:he(),description:o.z.string(),extension:o.z.string(),id:o.z.string(),name:o.z.string(),specifications:o.z.array(Oe())})}function Oe(){return o.z.object({__typename:o.z.literal("DocumentSpecification").optional(),changeLog:o.z.array(o.z.string()),modules:o.z.array(ge()),state:_e(),version:o.z.number()})}function ge(){return o.z.object({__typename:o.z.literal("Module").optional(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string(),operations:o.z.array(Se())})}function k(){return o.z.object({newModuleId:o.z.string(),operationId:o.z.string()})}function Se(){return o.z.object({__typename:o.z.literal("Operation").optional(),description:o.z.string().nullable(),errors:o.z.array(be()),examples:o.z.array(M()),id:o.z.string(),name:o.z.string().nullable(),reducer:o.z.string().nullable(),schema:o.z.string().nullable(),template:o.z.string().nullable(),scope:S()})}function be(){return o.z.object({__typename:o.z.literal("OperationError").optional(),code:o.z.string().nullable(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string().nullable(),template:o.z.string().nullable()})}function y(){return o.z.object({__typename:o.z.literal("ReorderChangeLogItemsInput").optional(),order:o.z.array(o.z.string())})}function w(){return o.z.object({moduleId:o.z.string(),order:o.z.array(o.z.string())})}function v(){return o.z.object({order:o.z.array(o.z.string())})}function U(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function V(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function F(){return o.z.object({scope:o.z.string(),order:o.z.array(o.z.string())})}function H(){return o.z.object({authorName:o.z.string()})}function $(){return o.z.object({authorWebsite:o.z.string()})}function X(){return o.z.object({scope:o.z.string(),initialValue:o.z.string()})}function G(){return o.z.object({description:o.z.string()})}function B(){return o.z.object({extension:o.z.string()})}function W(){return o.z.object({id:o.z.string()})}function q(){return o.z.object({name:o.z.string()})}function J(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function K(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function Q(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function Y(){return o.z.object({errorCode:o.z.string().nullish(),id:o.z.string()})}function Z(){return o.z.object({errorDescription:o.z.string().nullish(),id:o.z.string()})}function ee(){return o.z.object({errorName:o.z.string().nullish(),id:o.z.string()})}function te(){return o.z.object({errorTemplate:o.z.string().nullish(),id:o.z.string()})}function re(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function fe(){return o.z.object({id:o.z.string(),scope:S()})}function oe(){return o.z.object({id:o.z.string(),reducer:o.z.string().nullish()})}function ne(){return o.z.object({id:o.z.string(),schema:o.z.string().nullish()})}function ie(){return o.z.object({id:o.z.string(),template:o.z.string().nullish()})}function se(){return o.z.object({scope:o.z.string(),schema:o.z.string()})}function f(){return o.z.object({__typename:o.z.literal("State").optional(),examples:o.z.array(M()),initialValue:o.z.string(),schema:o.z.string()})}function _e(){return o.z.object({global:f(),local:f()})}function ae(){return o.z.object({__typename:o.z.literal("UpdateChangeLogItemInput").optional(),id:o.z.string(),newContent:o.z.string()})}function pe(){return o.z.object({example:o.z.string(),id:o.z.string()})}function le(){return o.z.object({scope:o.z.string(),id:o.z.string(),newExample:o.z.string()})}const ze=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:z,AddModuleInputSchema:A,AddOperationErrorInputSchema:I,AddOperationExampleInputSchema:T,AddOperationInputSchema:R,AddStateExampleInputSchema:D,AuthorSchema:he,CodeExampleSchema:M,DeleteChangeLogItemInputSchema:x,DeleteModuleInputSchema:N,DeleteOperationErrorInputSchema:L,DeleteOperationExampleInputSchema:j,DeleteOperationInputSchema:P,DeleteStateExampleInputSchema:C,DocumentModelInputSchema:gt,DocumentModelStateSchema:St,DocumentSpecificationSchema:Oe,ModuleSchema:ge,MoveOperationInputSchema:k,OperationErrorSchema:be,OperationSchema:Se,OperationScopeSchema:S,ReorderChangeLogItemsInputSchema:y,ReorderModuleOperationsInputSchema:w,ReorderModulesInputSchema:v,ReorderOperationErrorsInputSchema:U,ReorderOperationExamplesInputSchema:V,ReorderStateExamplesInputSchema:F,ScopeStateSchema:_e,SetAuthorNameInputSchema:H,SetAuthorWebsiteInputSchema:$,SetInitialStateInputSchema:X,SetModelDescriptionInputSchema:G,SetModelExtensionInputSchema:B,SetModelIdInputSchema:W,SetModelNameInputSchema:q,SetModuleDescriptionInputSchema:J,SetModuleNameInputSchema:K,SetOperationDescriptionInputSchema:Q,SetOperationErrorCodeInputSchema:Y,SetOperationErrorDescriptionInputSchema:Z,SetOperationErrorNameInputSchema:ee,SetOperationErrorTemplateInputSchema:te,SetOperationNameInputSchema:re,SetOperationReducerInputSchema:oe,SetOperationSchemaInputSchema:ne,SetOperationScopeInputSchema:fe,SetOperationTemplateInputSchema:ie,SetStateSchemaInputSchema:se,StateSchema:f,UpdateChangeLogItemInputSchema:ae,UpdateOperationExampleInputSchema:pe,UpdateStateExampleInputSchema:le,definedNonNullAnySchema:Ot,isDefinedNonNullAny:Ee},Symbol.toStringTag,{value:"Module"})),c={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}},E={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')}},bt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},h={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 n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].description=e.input.description||"")},deleteModuleOperation(t,e){const r=t.specifications[t.specifications.length-1];r.modules=r.modules.filter(n=>n.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(bt(e.input.order))}},ft=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},l={addOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].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 n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].errors=r.modules[n].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].errors.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},g={addOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].examples.length;a++)r.modules[n].operations[i].examples[a].id==e.input.id&&(r.modules[n].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].examples=r.modules[n].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.sort(_t(e.input.order))}},zt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},p={addOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].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 n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const r=[],n=t.specifications[t.specifications.length-1];for(let i=0;i<n.modules.length;i++)n.modules[i].operations=n.modules[i].operations.filter(a=>a.id==e.input.operationId?(r.push(a),!1):!0);for(let i=0;i<n.modules.length;i++)n.modules[i].id==e.input.newModuleId&&n.modules[i].operations.push(...r)},deleteOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].operations=r.modules[n].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].operations.sort(zt(e.input.order))}},At=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.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 n=r.state[e.input.scope].examples;for(let i=0;i<n.length;i++)n[i].id==e.input.id&&(n[i].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(n=>n.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(At(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},It=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":q().parse(e.input),c.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":W().parse(e.input),c.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":B().parse(e.input),c.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":G().parse(e.input),c.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":H().parse(e.input),c.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":$().parse(e.input),c.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":z().parse(e.input),E.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":ae().parse(e.input),E.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":x().parse(e.input),E.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":y().parse(e.input),E.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");E.releaseNewVersionOperation(t.global,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":K().parse(e.input),h.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":J().parse(e.input),h.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":N().parse(e.input),h.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":v().parse(e.input),h.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":I().parse(e.input),l.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":Y().parse(e.input),l.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":ee().parse(e.input),l.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Z().parse(e.input),l.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":te().parse(e.input),l.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":L().parse(e.input),l.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":U().parse(e.input),l.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":T().parse(e.input),g.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":pe().parse(e.input),g.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":j().parse(e.input),g.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":V().parse(e.input),g.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":R().parse(e.input),p.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":re().parse(e.input),p.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":fe().parse(e.input),p.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":ne().parse(e.input),p.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":Q().parse(e.input),p.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":ie().parse(e.input),p.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":oe().parse(e.input),p.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":k().parse(e.input),p.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":P().parse(e.input),p.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":w().parse(e.input),p.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":se().parse(e.input),d.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":X().parse(e.input),d.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":D().parse(e.input),d.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":le().parse(e.input),d.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":C().parse(e.input),d.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":F().parse(e.input),d.reorderStateExamplesOperation(t.global,e);break;default:return t}},m=s.createReducer(It),Tt={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},Rt={},O={fileExtension:"phdm",createState(t){return{global:{...Tt,...t==null?void 0:t.global},local:{...Rt,...t==null?void 0:t.local}}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},O.createState)},createDocument(t){return s.createDocument(O.createExtendedState(t),O.createState)},saveToFile(t,e,r){return s.saveToFile(t,e,"phdm",r)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},Ae=t=>s.createAction("SET_MODEL_NAME",{...t}),Ie=t=>s.createAction("SET_MODEL_ID",{...t}),Te=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Re=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),De=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Me=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Dt extends s.BaseDocument{setModelName(e,r){return this.dispatch(Ae(e),r)}setModelId(e,r){return this.dispatch(Ie(e),r)}setModelExtension(e,r){return this.dispatch(Te(e),r)}setModelDescription(e,r){return this.dispatch(Re(e),r)}setAuthorName(e,r){return this.dispatch(De(e),r)}setAuthorWebsite(e,r){return this.dispatch(Me(e),r)}}const xe=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),Le=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),je=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Pe=()=>s.createAction("RELEASE_NEW_VERSION");class Mt extends s.BaseDocument{addChangeLogItem(e,r){return this.dispatch(xe(e),r)}updateChangeLogItem(e,r){return this.dispatch(Ne(e),r)}deleteChangeLogItem(e,r){return this.dispatch(Le(e),r)}reorderChangeLogItems(e,r){return this.dispatch(je(e),r)}releaseNewVersion(e){return this.dispatch(Pe(),e)}}const Ce=t=>s.createAction("ADD_MODULE",{...t}),ke=t=>s.createAction("SET_MODULE_NAME",{...t}),ye=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),we=t=>s.createAction("DELETE_MODULE",{...t}),ve=t=>s.createAction("REORDER_MODULES",{...t});class xt extends s.BaseDocument{addModule(e,r){return this.dispatch(Ce(e),r)}setModuleName(e,r){return this.dispatch(ke(e),r)}setModuleDescription(e,r){return this.dispatch(ye(e),r)}deleteModule(e,r){return this.dispatch(we(e),r)}reorderModules(e,r){return this.dispatch(ve(e),r)}}const Ue=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Ve=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),He=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),$e=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),Xe=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Ge=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Nt extends s.BaseDocument{addOperationError(e,r){return this.dispatch(Ue(e),r)}setOperationErrorCode(e,r){return this.dispatch(Ve(e),r)}setOperationErrorName(e,r){return this.dispatch(Fe(e),r)}setOperationErrorDescription(e,r){return this.dispatch(He(e),r)}setOperationErrorTemplate(e,r){return this.dispatch($e(e),r)}deleteOperationError(e,r){return this.dispatch(Xe(e),r)}reorderOperationErrors(e,r){return this.dispatch(Ge(e),r)}}const Be=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),qe=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),Je=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Lt extends s.BaseDocument{addOperationExample(e,r){return this.dispatch(Be(e),r)}updateOperationExample(e,r){return this.dispatch(We(e),r)}deleteOperationExample(e,r){return this.dispatch(qe(e),r)}reorderOperationExamples(e,r){return this.dispatch(Je(e),r)}}const Ke=t=>s.createAction("ADD_OPERATION",{...t}),Qe=t=>s.createAction("SET_OPERATION_NAME",{...t}),Ye=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Ze=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),et=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),tt=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),rt=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),ot=t=>s.createAction("MOVE_OPERATION",{...t}),nt=t=>s.createAction("DELETE_OPERATION",{...t}),it=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class jt extends s.BaseDocument{addOperation(e,r){return this.dispatch(Ke(e),r)}setOperationName(e,r){return this.dispatch(Qe(e),r)}setOperationScope(e,r){return this.dispatch(Ye(e),r)}setOperationSchema(e,r){return this.dispatch(Ze(e),r)}setOperationDescription(e,r){return this.dispatch(et(e),r)}setOperationTemplate(e,r){return this.dispatch(tt(e),r)}setOperationReducer(e,r){return this.dispatch(rt(e),r)}moveOperation(e,r){return this.dispatch(ot(e),r)}deleteOperation(e,r){return this.dispatch(nt(e),r)}reorderModuleOperations(e,r){return this.dispatch(it(e),r)}}const st=t=>s.createAction("SET_STATE_SCHEMA",{...t}),at=t=>s.createAction("SET_INITIAL_STATE",{...t}),pt=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),ct=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),dt=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Pt extends s.BaseDocument{setStateSchema(e,r){return this.dispatch(st(e),r)}setInitialState(e,r){return this.dispatch(at(e),r)}addStateExample(e,r){return this.dispatch(pt(e),r)}updateStateExample(e,r){return this.dispatch(lt(e),r)}deleteStateExample(e,r){return this.dispatch(ct(e),r)}reorderStateExamples(e,r){return this.dispatch(dt(e),r)}}var u;let b=(u=class extends s.BaseDocument{constructor(e,r){super(m,O.createDocument(e),r)}saveToFile(e,r){return super.saveToFile(e,u.fileExtension,r)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const r=new this;return await r.loadFromFile(e),r}},me(u,"fileExtension","phdm"),u);s.applyMixins(b,[Dt,Mt,xt,Nt,Lt,jt,Pt]);const Ct=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:xe,addModule:Ce,addOperation:Ke,addOperationError:Ue,addOperationExample:Be,addStateExample:pt,deleteChangeLogItem:Le,deleteModule:we,deleteOperation:nt,deleteOperationError:Xe,deleteOperationExample:qe,deleteStateExample:ct,moveOperation:ot,releaseNewVersion:Pe,reorderChangeLogItems:je,reorderModuleOperations:it,reorderModules:ve,reorderOperationErrors:Ge,reorderOperationExamples:Je,reorderStateExamples:dt,setAuthorName:De,setAuthorWebsite:Me,setInitialState:at,setModelDescription:Re,setModelExtension:Te,setModelId:Ie,setModelName:Ae,setModuleDescription:ye,setModuleName:ke,setOperationDescription:et,setOperationErrorCode:Ve,setOperationErrorDescription:He,setOperationErrorName:Fe,setOperationErrorTemplate:$e,setOperationName:Qe,setOperationReducer:rt,setOperationSchema:Ze,setOperationScope:Ye,setOperationTemplate:tt,setStateSchema:st,updateChangeLogItem:Ne,updateOperationExample:We,updateStateExample:lt},Symbol.toStringTag,{value:"Module"})),ce=b,de={...O,...ht},ue={...s.BaseActions,...Ct},ut={Document:ce,reducer:m,actions:ue,utils:de,documentModel:_},kt=Object.freeze(Object.defineProperty({__proto__:null,Document:ce,DocumentModel:b,actions:ue,documentModel:_,module:ut,reducer:m,utils:de,z:ze},Symbol.toStringTag,{value:"Module"}));exports.Document=ce;exports.DocumentModel=kt;exports.DocumentModel$1=b;exports.actions=ue;exports.documentModel=_;exports.module=ut;exports.reducer=m;exports.utils=de;exports.zod=ze;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";var mt=Object.defineProperty;var Et=(t,e,r)=>e in t?mt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var me=(t,e,r)=>(Et(t,typeof e!="symbol"?e+"":e,r),r);const s=require("./object-B5Lf9AWl.js");require("immer");require("json-stringify-deterministic");require("crypto");require("fs");require("https");require("path");require("jszip");const o=require("zod"),ht=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),_={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:[],modules:[{name:"header",operations:[{name:"SetModelName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelId",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelExtension",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModelDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetAuthorWebsite",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"versioning",operations:[{name:"AddChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteChangeLogItem",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderChangeLogItems",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReleaseNewVersion",schema:null,id:"",description:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"module",operations:[{name:"AddModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetModuleDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteModule",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModules",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-error",operations:[{name:"AddOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorCode",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationErrorTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationError",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationErrors",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation-example",operations:[{name:"AddOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperationExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderOperationExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"operation",operations:[{name:"AddOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationName",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationDescription",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationTemplate",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetOperationReducer",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"MoveOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteOperation",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderModuleOperations",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""},{name:"state",operations:[{name:"SetStateSchema",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"SetInitialState",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"AddStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"UpdateStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"DeleteStateExample",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"},{name:"ReorderStateExamples",id:"",description:"",schema:"",template:"",reducer:"",examples:[],errors:[],scope:"global"}],id:"",description:""}],state:{global:{schema:"",initialValue:`{
|
|
2
|
-
"id": "",
|
|
3
|
-
"name": "",
|
|
4
|
-
"extension": "",
|
|
5
|
-
"description": "",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "",
|
|
8
|
-
"website": ""
|
|
9
|
-
},
|
|
10
|
-
"specifications": [
|
|
11
|
-
{
|
|
12
|
-
"version": 1,
|
|
13
|
-
"changeLog": [],
|
|
14
|
-
"state": {
|
|
15
|
-
"schema": "",
|
|
16
|
-
"initialValue": "",
|
|
17
|
-
"examples": []
|
|
18
|
-
},
|
|
19
|
-
"modules": []
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}`,examples:[]},local:{schema:"",initialValue:"{}",examples:[]}}}]},Ee=t=>t!=null,Ot=o.z.any().refine(t=>Ee(t));function z(){return o.z.object({__typename:o.z.literal("AddChangeLogItemInput").optional(),content:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullable()})}function A(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),name:o.z.string()})}function I(){return o.z.object({errorCode:o.z.string().nullish(),errorDescription:o.z.string().nullish(),errorName:o.z.string().nullish(),errorTemplate:o.z.string().nullish(),id:o.z.string(),operationId:o.z.string()})}function T(){return o.z.object({example:o.z.string(),id:o.z.string(),operationId:o.z.string()})}function R(){return o.z.object({description:o.z.string().nullish(),id:o.z.string(),moduleId:o.z.string(),name:o.z.string(),reducer:o.z.string().nullish(),schema:o.z.string().nullish(),template:o.z.string().nullish(),scope:S().nullish()})}function D(){return o.z.object({scope:o.z.string(),example:o.z.string(),id:o.z.string(),insertBefore:o.z.string().nullish()})}function he(){return o.z.object({__typename:o.z.literal("Author").optional(),name:o.z.string(),website:o.z.string().nullable()})}function M(){return o.z.object({__typename:o.z.literal("CodeExample").optional(),id:o.z.string(),value:o.z.string()})}function x(){return o.z.object({__typename:o.z.literal("DeleteChangeLogItemInput").optional(),id:o.z.string()})}function N(){return o.z.object({id:o.z.string()})}function L(){return o.z.object({id:o.z.string()})}function j(){return o.z.object({id:o.z.string()})}function P(){return o.z.object({id:o.z.string()})}function C(){return o.z.object({scope:o.z.string(),id:o.z.string()})}function S(){return o.z.literal("global").or(o.z.literal("local"))}function gt(){return o.z.union([z(),A(),I(),T(),R(),D(),x(),N(),L(),j(),P(),C(),k(),y(),w(),v(),U(),V(),F(),H(),$(),X(),G(),B(),W(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae(),pe(),le()])}function St(){return o.z.object({__typename:o.z.literal("DocumentModelState").optional(),author:he(),description:o.z.string(),extension:o.z.string(),id:o.z.string(),name:o.z.string(),specifications:o.z.array(Oe())})}function Oe(){return o.z.object({__typename:o.z.literal("DocumentSpecification").optional(),changeLog:o.z.array(o.z.string()),modules:o.z.array(ge()),state:_e(),version:o.z.number()})}function ge(){return o.z.object({__typename:o.z.literal("Module").optional(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string(),operations:o.z.array(Se())})}function k(){return o.z.object({newModuleId:o.z.string(),operationId:o.z.string()})}function Se(){return o.z.object({__typename:o.z.literal("Operation").optional(),description:o.z.string().nullable(),errors:o.z.array(be()),examples:o.z.array(M()),id:o.z.string(),name:o.z.string().nullable(),reducer:o.z.string().nullable(),schema:o.z.string().nullable(),template:o.z.string().nullable(),scope:S()})}function be(){return o.z.object({__typename:o.z.literal("OperationError").optional(),code:o.z.string().nullable(),description:o.z.string().nullable(),id:o.z.string(),name:o.z.string().nullable(),template:o.z.string().nullable()})}function y(){return o.z.object({__typename:o.z.literal("ReorderChangeLogItemsInput").optional(),order:o.z.array(o.z.string())})}function w(){return o.z.object({moduleId:o.z.string(),order:o.z.array(o.z.string())})}function v(){return o.z.object({order:o.z.array(o.z.string())})}function U(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function V(){return o.z.object({operationId:o.z.string(),order:o.z.array(o.z.string())})}function F(){return o.z.object({scope:o.z.string(),order:o.z.array(o.z.string())})}function H(){return o.z.object({authorName:o.z.string()})}function $(){return o.z.object({authorWebsite:o.z.string()})}function X(){return o.z.object({scope:o.z.string(),initialValue:o.z.string()})}function G(){return o.z.object({description:o.z.string()})}function B(){return o.z.object({extension:o.z.string()})}function W(){return o.z.object({id:o.z.string()})}function q(){return o.z.object({name:o.z.string()})}function J(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function K(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function Q(){return o.z.object({description:o.z.string().nullish(),id:o.z.string()})}function Y(){return o.z.object({errorCode:o.z.string().nullish(),id:o.z.string()})}function Z(){return o.z.object({errorDescription:o.z.string().nullish(),id:o.z.string()})}function ee(){return o.z.object({errorName:o.z.string().nullish(),id:o.z.string()})}function te(){return o.z.object({errorTemplate:o.z.string().nullish(),id:o.z.string()})}function re(){return o.z.object({id:o.z.string(),name:o.z.string().nullish()})}function fe(){return o.z.object({id:o.z.string(),scope:S()})}function oe(){return o.z.object({id:o.z.string(),reducer:o.z.string().nullish()})}function ne(){return o.z.object({id:o.z.string(),schema:o.z.string().nullish()})}function ie(){return o.z.object({id:o.z.string(),template:o.z.string().nullish()})}function se(){return o.z.object({scope:o.z.string(),schema:o.z.string()})}function f(){return o.z.object({__typename:o.z.literal("State").optional(),examples:o.z.array(M()),initialValue:o.z.string(),schema:o.z.string()})}function _e(){return o.z.object({global:f(),local:f()})}function ae(){return o.z.object({__typename:o.z.literal("UpdateChangeLogItemInput").optional(),id:o.z.string(),newContent:o.z.string()})}function pe(){return o.z.object({example:o.z.string(),id:o.z.string()})}function le(){return o.z.object({scope:o.z.string(),id:o.z.string(),newExample:o.z.string()})}const ze=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:z,AddModuleInputSchema:A,AddOperationErrorInputSchema:I,AddOperationExampleInputSchema:T,AddOperationInputSchema:R,AddStateExampleInputSchema:D,AuthorSchema:he,CodeExampleSchema:M,DeleteChangeLogItemInputSchema:x,DeleteModuleInputSchema:N,DeleteOperationErrorInputSchema:L,DeleteOperationExampleInputSchema:j,DeleteOperationInputSchema:P,DeleteStateExampleInputSchema:C,DocumentModelInputSchema:gt,DocumentModelStateSchema:St,DocumentSpecificationSchema:Oe,ModuleSchema:ge,MoveOperationInputSchema:k,OperationErrorSchema:be,OperationSchema:Se,OperationScopeSchema:S,ReorderChangeLogItemsInputSchema:y,ReorderModuleOperationsInputSchema:w,ReorderModulesInputSchema:v,ReorderOperationErrorsInputSchema:U,ReorderOperationExamplesInputSchema:V,ReorderStateExamplesInputSchema:F,ScopeStateSchema:_e,SetAuthorNameInputSchema:H,SetAuthorWebsiteInputSchema:$,SetInitialStateInputSchema:X,SetModelDescriptionInputSchema:G,SetModelExtensionInputSchema:B,SetModelIdInputSchema:W,SetModelNameInputSchema:q,SetModuleDescriptionInputSchema:J,SetModuleNameInputSchema:K,SetOperationDescriptionInputSchema:Q,SetOperationErrorCodeInputSchema:Y,SetOperationErrorDescriptionInputSchema:Z,SetOperationErrorNameInputSchema:ee,SetOperationErrorTemplateInputSchema:te,SetOperationNameInputSchema:re,SetOperationReducerInputSchema:oe,SetOperationSchemaInputSchema:ne,SetOperationScopeInputSchema:fe,SetOperationTemplateInputSchema:ie,SetStateSchemaInputSchema:se,StateSchema:f,UpdateChangeLogItemInputSchema:ae,UpdateOperationExampleInputSchema:pe,UpdateStateExampleInputSchema:le,definedNonNullAnySchema:Ot,isDefinedNonNullAny:Ee},Symbol.toStringTag,{value:"Module"})),c={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}},E={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')}},bt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},h={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 n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id===e.input.id&&(r.modules[n].description=e.input.description||"")},deleteModuleOperation(t,e){const r=t.specifications[t.specifications.length-1];r.modules=r.modules.filter(n=>n.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(bt(e.input.order))}},ft=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},l={addOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].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 n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].errors.length;a++)r.modules[n].operations[i].errors[a].id==e.input.id&&(r.modules[n].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].errors=r.modules[n].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].errors.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},g={addOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)for(let a=0;a<r.modules[n].operations[i].examples.length;a++)r.modules[n].operations[i].examples[a].id==e.input.id&&(r.modules[n].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].examples=r.modules[n].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.operationId&&r.modules[n].operations[i].examples.sort(_t(e.input.order))}},zt=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.id]||999999)-(e[r.id]||999999)},p={addOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].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 n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)for(let i=0;i<r.modules[n].operations.length;i++)r.modules[n].operations[i].id==e.input.id&&(r.modules[n].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const r=[],n=t.specifications[t.specifications.length-1];for(let i=0;i<n.modules.length;i++)n.modules[i].operations=n.modules[i].operations.filter(a=>a.id==e.input.operationId?(r.push(a),!1):!0);for(let i=0;i<n.modules.length;i++)n.modules[i].id==e.input.newModuleId&&n.modules[i].operations.push(...r)},deleteOperationOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].operations=r.modules[n].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const r=t.specifications[t.specifications.length-1];for(let n=0;n<r.modules.length;n++)r.modules[n].id==e.input.moduleId&&r.modules[n].operations.sort(zt(e.input.order))}},At=t=>{const e={};return t.forEach((r,n)=>e[r]=n),(r,n)=>(e[n.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 n=r.state[e.input.scope].examples;for(let i=0;i<n.length;i++)n[i].id==e.input.id&&(n[i].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(n=>n.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(At(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},It=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":q().parse(e.input),c.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":W().parse(e.input),c.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":B().parse(e.input),c.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":G().parse(e.input),c.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":H().parse(e.input),c.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":$().parse(e.input),c.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":z().parse(e.input),E.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":ae().parse(e.input),E.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":x().parse(e.input),E.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":y().parse(e.input),E.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");E.releaseNewVersionOperation(t.global,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":K().parse(e.input),h.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":J().parse(e.input),h.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":N().parse(e.input),h.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":v().parse(e.input),h.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":I().parse(e.input),l.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":Y().parse(e.input),l.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":ee().parse(e.input),l.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Z().parse(e.input),l.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":te().parse(e.input),l.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":L().parse(e.input),l.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":U().parse(e.input),l.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":T().parse(e.input),g.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":pe().parse(e.input),g.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":j().parse(e.input),g.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":V().parse(e.input),g.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":R().parse(e.input),p.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":re().parse(e.input),p.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":fe().parse(e.input),p.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":ne().parse(e.input),p.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":Q().parse(e.input),p.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":ie().parse(e.input),p.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":oe().parse(e.input),p.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":k().parse(e.input),p.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":P().parse(e.input),p.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":w().parse(e.input),p.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":se().parse(e.input),d.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":X().parse(e.input),d.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":D().parse(e.input),d.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":le().parse(e.input),d.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":C().parse(e.input),d.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":F().parse(e.input),d.reorderStateExamplesOperation(t.global,e);break;default:return t}},m=s.createReducer(It),Tt={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},Rt={},O={fileExtension:"phdm",createState(t){return{global:{...Tt,...t==null?void 0:t.global},local:{...Rt,...t==null?void 0:t.local}}},createExtendedState(t){return s.createExtendedState({...t,documentType:"powerhouse/document-model"},O.createState)},createDocument(t){return s.createDocument(O.createExtendedState(t),O.createState)},saveToFile(t,e,r){return s.saveToFile(t,e,"phdm",r)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},Ae=t=>s.createAction("SET_MODEL_NAME",{...t}),Ie=t=>s.createAction("SET_MODEL_ID",{...t}),Te=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Re=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),De=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Me=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Dt extends s.BaseDocument{setModelName(e,r){return this.dispatch(Ae(e),r)}setModelId(e,r){return this.dispatch(Ie(e),r)}setModelExtension(e,r){return this.dispatch(Te(e),r)}setModelDescription(e,r){return this.dispatch(Re(e),r)}setAuthorName(e,r){return this.dispatch(De(e),r)}setAuthorWebsite(e,r){return this.dispatch(Me(e),r)}}const xe=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),Le=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),je=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Pe=()=>s.createAction("RELEASE_NEW_VERSION");class Mt extends s.BaseDocument{addChangeLogItem(e,r){return this.dispatch(xe(e),r)}updateChangeLogItem(e,r){return this.dispatch(Ne(e),r)}deleteChangeLogItem(e,r){return this.dispatch(Le(e),r)}reorderChangeLogItems(e,r){return this.dispatch(je(e),r)}releaseNewVersion(e){return this.dispatch(Pe(),e)}}const Ce=t=>s.createAction("ADD_MODULE",{...t}),ke=t=>s.createAction("SET_MODULE_NAME",{...t}),ye=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),we=t=>s.createAction("DELETE_MODULE",{...t}),ve=t=>s.createAction("REORDER_MODULES",{...t});class xt extends s.BaseDocument{addModule(e,r){return this.dispatch(Ce(e),r)}setModuleName(e,r){return this.dispatch(ke(e),r)}setModuleDescription(e,r){return this.dispatch(ye(e),r)}deleteModule(e,r){return this.dispatch(we(e),r)}reorderModules(e,r){return this.dispatch(ve(e),r)}}const Ue=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Ve=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),He=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),$e=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),Xe=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Ge=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Nt extends s.BaseDocument{addOperationError(e,r){return this.dispatch(Ue(e),r)}setOperationErrorCode(e,r){return this.dispatch(Ve(e),r)}setOperationErrorName(e,r){return this.dispatch(Fe(e),r)}setOperationErrorDescription(e,r){return this.dispatch(He(e),r)}setOperationErrorTemplate(e,r){return this.dispatch($e(e),r)}deleteOperationError(e,r){return this.dispatch(Xe(e),r)}reorderOperationErrors(e,r){return this.dispatch(Ge(e),r)}}const Be=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),qe=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),Je=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Lt extends s.BaseDocument{addOperationExample(e,r){return this.dispatch(Be(e),r)}updateOperationExample(e,r){return this.dispatch(We(e),r)}deleteOperationExample(e,r){return this.dispatch(qe(e),r)}reorderOperationExamples(e,r){return this.dispatch(Je(e),r)}}const Ke=t=>s.createAction("ADD_OPERATION",{...t}),Qe=t=>s.createAction("SET_OPERATION_NAME",{...t}),Ye=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Ze=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),et=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),tt=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),rt=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),ot=t=>s.createAction("MOVE_OPERATION",{...t}),nt=t=>s.createAction("DELETE_OPERATION",{...t}),it=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class jt extends s.BaseDocument{addOperation(e,r){return this.dispatch(Ke(e),r)}setOperationName(e,r){return this.dispatch(Qe(e),r)}setOperationScope(e,r){return this.dispatch(Ye(e),r)}setOperationSchema(e,r){return this.dispatch(Ze(e),r)}setOperationDescription(e,r){return this.dispatch(et(e),r)}setOperationTemplate(e,r){return this.dispatch(tt(e),r)}setOperationReducer(e,r){return this.dispatch(rt(e),r)}moveOperation(e,r){return this.dispatch(ot(e),r)}deleteOperation(e,r){return this.dispatch(nt(e),r)}reorderModuleOperations(e,r){return this.dispatch(it(e),r)}}const st=t=>s.createAction("SET_STATE_SCHEMA",{...t}),at=t=>s.createAction("SET_INITIAL_STATE",{...t}),pt=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),ct=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),dt=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Pt extends s.BaseDocument{setStateSchema(e,r){return this.dispatch(st(e),r)}setInitialState(e,r){return this.dispatch(at(e),r)}addStateExample(e,r){return this.dispatch(pt(e),r)}updateStateExample(e,r){return this.dispatch(lt(e),r)}deleteStateExample(e,r){return this.dispatch(ct(e),r)}reorderStateExamples(e,r){return this.dispatch(dt(e),r)}}var u;let b=(u=class extends s.BaseDocument{constructor(e,r){super(m,O.createDocument(e),r)}saveToFile(e,r){return super.saveToFile(e,u.fileExtension,r)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const r=new this;return await r.loadFromFile(e),r}},me(u,"fileExtension","phdm"),u);s.applyMixins(b,[Dt,Mt,xt,Nt,Lt,jt,Pt]);const Ct=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:xe,addModule:Ce,addOperation:Ke,addOperationError:Ue,addOperationExample:Be,addStateExample:pt,deleteChangeLogItem:Le,deleteModule:we,deleteOperation:nt,deleteOperationError:Xe,deleteOperationExample:qe,deleteStateExample:ct,moveOperation:ot,releaseNewVersion:Pe,reorderChangeLogItems:je,reorderModuleOperations:it,reorderModules:ve,reorderOperationErrors:Ge,reorderOperationExamples:Je,reorderStateExamples:dt,setAuthorName:De,setAuthorWebsite:Me,setInitialState:at,setModelDescription:Re,setModelExtension:Te,setModelId:Ie,setModelName:Ae,setModuleDescription:ye,setModuleName:ke,setOperationDescription:et,setOperationErrorCode:Ve,setOperationErrorDescription:He,setOperationErrorName:Fe,setOperationErrorTemplate:$e,setOperationName:Qe,setOperationReducer:rt,setOperationSchema:Ze,setOperationScope:Ye,setOperationTemplate:tt,setStateSchema:st,updateChangeLogItem:Ne,updateOperationExample:We,updateStateExample:lt},Symbol.toStringTag,{value:"Module"})),ce=b,de={...O,...ht},ue={...s.BaseActions,...Ct},ut={Document:ce,reducer:m,actions:ue,utils:de,documentModel:_},kt=Object.freeze(Object.defineProperty({__proto__:null,Document:ce,DocumentModel:b,actions:ue,documentModel:_,module:ut,reducer:m,utils:de,z:ze},Symbol.toStringTag,{value:"Module"}));exports.Document=ce;exports.DocumentModel=kt;exports.DocumentModel$1=b;exports.actions=ue;exports.documentModel=_;exports.module=ut;exports.reducer=m;exports.utils=de;exports.zod=ze;
|