document-model 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/browser/document/types.d.ts +8 -0
  2. package/dist/browser/document/utils/base.d.ts +2 -2
  3. package/dist/browser/document-model/gen/operation/actions.d.ts +3 -2
  4. package/dist/browser/document-model/gen/operation/creators.d.ts +3 -2
  5. package/dist/browser/document-model/gen/operation/object.d.ts +2 -1
  6. package/dist/browser/document-model/gen/operation/operations.d.ts +2 -1
  7. package/dist/browser/document-model/gen/schema/types.d.ts +8 -0
  8. package/dist/browser/document-model/gen/schema/zod.d.ts +5 -1
  9. package/dist/browser/document-model/index.d.ts +1 -0
  10. package/dist/browser/document-model.cjs +1 -1
  11. package/dist/browser/document-model.js +2 -2
  12. package/dist/browser/document.cjs +1 -1
  13. package/dist/browser/document.js +2 -2
  14. package/dist/browser/index.cjs +1 -1
  15. package/dist/browser/index.js +3 -3
  16. package/dist/browser/internal/index-05592a17.js +22 -0
  17. package/dist/{node/internal/index-5b0ca13a.js → browser/internal/index-5dee4170.js} +1 -1
  18. package/dist/{node/internal/index-6a7277fe.js → browser/internal/index-a61bcd7c.js} +1 -1
  19. package/dist/browser/internal/{index-48f140bc.js → index-ea1557d4.js} +441 -373
  20. package/dist/browser/internal/{object-98a2cff6.js → object-35506f2f.js} +3 -3
  21. package/dist/browser/internal/{object-ceb8f869.js → object-70e4dae8.js} +1 -1
  22. package/dist/node/document/types.d.ts +8 -0
  23. package/dist/node/document/utils/base.d.ts +2 -2
  24. package/dist/node/document-model/gen/operation/actions.d.ts +3 -2
  25. package/dist/node/document-model/gen/operation/creators.d.ts +3 -2
  26. package/dist/node/document-model/gen/operation/object.d.ts +2 -1
  27. package/dist/node/document-model/gen/operation/operations.d.ts +2 -1
  28. package/dist/node/document-model/gen/schema/types.d.ts +8 -0
  29. package/dist/node/document-model/gen/schema/zod.d.ts +5 -1
  30. package/dist/node/document-model/index.d.ts +1 -0
  31. package/dist/node/document-model.cjs +1 -1
  32. package/dist/node/document-model.js +2 -2
  33. package/dist/node/document.cjs +1 -1
  34. package/dist/node/document.js +2 -2
  35. package/dist/node/index.cjs +1 -1
  36. package/dist/node/index.js +3 -3
  37. package/dist/node/internal/{index-dfaca09a.js → index-0b946b7d.js} +441 -373
  38. package/dist/{browser/internal/index-ff22a5bb.js → node/internal/index-14934709.js} +1 -1
  39. package/dist/{browser/internal/index-9922a4fc.js → node/internal/index-7056a501.js} +1 -1
  40. package/dist/node/internal/index-fbe65e32.js +22 -0
  41. package/dist/node/internal/{object-10abe15d.js → object-8ed23327.js} +1 -1
  42. package/dist/node/internal/{object-6f942fcb.js → object-e24dafec.js} +16 -16
  43. package/package.json +1 -1
  44. package/dist/browser/internal/index-7d7d05c8.js +0 -22
  45. package/dist/node/internal/index-2e487f63.js +0 -22
@@ -20,6 +20,8 @@ export type Action<T extends string = string, I = unknown> = {
20
20
  input: I;
21
21
  /** The attachments included in the action. */
22
22
  attachments?: AttachmentInput[] | undefined;
23
+ /** The scope of the action, can either be 'global' or 'local'. Defaults to 'global' */
24
+ scope?: OperationScope;
23
25
  };
24
26
  export type ActionWithAttachment<T extends string = string, I = unknown> = Action<T, I> & {
25
27
  attachments: AttachmentInput[];
@@ -46,6 +48,12 @@ export type Reducer<State, A extends Action> = (state: Document<State, A>, actio
46
48
  */
47
49
  export type ImmutableReducer<State, A extends Action> = (state: Draft<Document<State, A>>, action: A | BaseAction) => Document<State, A> | void;
48
50
  export type ImmutableStateReducer<State, A extends Action> = (state: Draft<State>, action: A) => State | void;
51
+ /**
52
+ * Scope of an operation.
53
+ * Global: The operation is synchronized everywhere in the network. This is the default document operation.
54
+ * Local: The operation is applied only locally (to a local state). Used for local settings such as a drive's local path
55
+ */
56
+ export type OperationScope = 'global' | 'local';
49
57
  /**
50
58
  * An operation that was applied to a {@link Document}.
51
59
  *
@@ -1,5 +1,5 @@
1
1
  import { baseReducer } from '../reducer';
2
- import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable } from '../types';
2
+ import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope } from '../types';
3
3
  export declare function isBaseAction(action: Action): action is BaseAction;
4
4
  /**
5
5
  * Helper function to be used by action creators.
@@ -19,7 +19,7 @@ export declare function isBaseAction(action: Action): action is BaseAction;
19
19
  */
20
20
  export declare function createAction<A extends Action>(type: A['type'], input?: A['input'], attachments?: Action['attachments'], validator?: () => {
21
21
  parse(v: unknown): A;
22
- }): A;
22
+ }, scope?: OperationScope): A;
23
23
  /**
24
24
  * Helper function to create a document model reducer.
25
25
  *
@@ -1,7 +1,8 @@
1
1
  import { Action } from '../../../document';
2
- import { AddOperationInput, SetOperationNameInput, SetOperationSchemaInput, SetOperationDescriptionInput, SetOperationTemplateInput, SetOperationReducerInput, MoveOperationInput, DeleteOperationInput, ReorderModuleOperationsInput } from '../types';
2
+ import { AddOperationInput, SetOperationNameInput, SetOperationSchemaInput, SetOperationDescriptionInput, SetOperationTemplateInput, SetOperationReducerInput, MoveOperationInput, DeleteOperationInput, ReorderModuleOperationsInput, SetOperationScopeInput } from '../types';
3
3
  export type AddOperationAction = Action<'ADD_OPERATION', AddOperationInput>;
4
4
  export type SetOperationNameAction = Action<'SET_OPERATION_NAME', SetOperationNameInput>;
5
+ export type SetOperationScopeAction = Action<'SET_OPERATION_SCOPE', SetOperationScopeInput>;
5
6
  export type SetOperationSchemaAction = Action<'SET_OPERATION_SCHEMA', SetOperationSchemaInput>;
6
7
  export type SetOperationDescriptionAction = Action<'SET_OPERATION_DESCRIPTION', SetOperationDescriptionInput>;
7
8
  export type SetOperationTemplateAction = Action<'SET_OPERATION_TEMPLATE', SetOperationTemplateInput>;
@@ -9,4 +10,4 @@ export type SetOperationReducerAction = Action<'SET_OPERATION_REDUCER', SetOpera
9
10
  export type MoveOperationAction = Action<'MOVE_OPERATION', MoveOperationInput>;
10
11
  export type DeleteOperationAction = Action<'DELETE_OPERATION', DeleteOperationInput>;
11
12
  export type ReorderModuleOperationsAction = Action<'REORDER_MODULE_OPERATIONS', ReorderModuleOperationsInput>;
12
- export type DocumentModelOperationAction = AddOperationAction | SetOperationNameAction | SetOperationSchemaAction | SetOperationDescriptionAction | SetOperationTemplateAction | SetOperationReducerAction | MoveOperationAction | DeleteOperationAction | ReorderModuleOperationsAction;
13
+ export type DocumentModelOperationAction = AddOperationAction | SetOperationNameAction | SetOperationScopeAction | SetOperationSchemaAction | SetOperationDescriptionAction | SetOperationTemplateAction | SetOperationReducerAction | MoveOperationAction | DeleteOperationAction | ReorderModuleOperationsAction;
@@ -1,7 +1,8 @@
1
- import { AddOperationInput, SetOperationNameInput, SetOperationSchemaInput, SetOperationDescriptionInput, SetOperationTemplateInput, SetOperationReducerInput, MoveOperationInput, DeleteOperationInput, ReorderModuleOperationsInput } from '../types';
2
- import { AddOperationAction, SetOperationNameAction, SetOperationSchemaAction, SetOperationDescriptionAction, SetOperationTemplateAction, SetOperationReducerAction, MoveOperationAction, DeleteOperationAction, ReorderModuleOperationsAction } from './actions';
1
+ import { AddOperationInput, SetOperationNameInput, SetOperationSchemaInput, SetOperationDescriptionInput, SetOperationTemplateInput, SetOperationReducerInput, MoveOperationInput, DeleteOperationInput, ReorderModuleOperationsInput, SetOperationScopeInput } from '../types';
2
+ import { AddOperationAction, SetOperationNameAction, SetOperationSchemaAction, SetOperationDescriptionAction, SetOperationTemplateAction, SetOperationReducerAction, MoveOperationAction, DeleteOperationAction, ReorderModuleOperationsAction, SetOperationScopeAction } from './actions';
3
3
  export declare const addOperation: (input: AddOperationInput) => AddOperationAction;
4
4
  export declare const setOperationName: (input: SetOperationNameInput) => SetOperationNameAction;
5
+ export declare const setOperationScope: (input: SetOperationScopeInput) => SetOperationScopeAction;
5
6
  export declare const setOperationSchema: (input: SetOperationSchemaInput) => SetOperationSchemaAction;
6
7
  export declare const setOperationDescription: (input: SetOperationDescriptionInput) => SetOperationDescriptionAction;
7
8
  export declare const setOperationTemplate: (input: SetOperationTemplateInput) => SetOperationTemplateAction;
@@ -1,9 +1,10 @@
1
1
  import { BaseDocument } from '../../../document/object';
2
- import { AddOperationInput, SetOperationNameInput, SetOperationSchemaInput, SetOperationDescriptionInput, SetOperationTemplateInput, SetOperationReducerInput, MoveOperationInput, DeleteOperationInput, ReorderModuleOperationsInput, DocumentModelState } from '../types';
2
+ import { AddOperationInput, SetOperationNameInput, SetOperationSchemaInput, SetOperationDescriptionInput, SetOperationTemplateInput, SetOperationReducerInput, MoveOperationInput, DeleteOperationInput, ReorderModuleOperationsInput, DocumentModelState, SetOperationScopeInput } from '../types';
3
3
  import { DocumentModelAction } from '../actions';
4
4
  export default class DocumentModel_Operation extends BaseDocument<DocumentModelState, DocumentModelAction> {
5
5
  addOperation(input: AddOperationInput): this;
6
6
  setOperationName(input: SetOperationNameInput): this;
7
+ setOperationScope(input: SetOperationScopeInput): this;
7
8
  setOperationSchema(input: SetOperationSchemaInput): this;
8
9
  setOperationDescription(input: SetOperationDescriptionInput): this;
9
10
  setOperationTemplate(input: SetOperationTemplateInput): this;
@@ -1,8 +1,9 @@
1
- import { AddOperationAction, SetOperationNameAction, SetOperationSchemaAction, SetOperationDescriptionAction, SetOperationTemplateAction, SetOperationReducerAction, MoveOperationAction, DeleteOperationAction, ReorderModuleOperationsAction } from './actions';
1
+ import { AddOperationAction, SetOperationNameAction, SetOperationSchemaAction, SetOperationDescriptionAction, SetOperationTemplateAction, SetOperationReducerAction, MoveOperationAction, DeleteOperationAction, ReorderModuleOperationsAction, SetOperationScopeAction } from './actions';
2
2
  import { DocumentModelState } from '../types';
3
3
  export interface DocumentModelOperationOperations {
4
4
  addOperationOperation: (state: DocumentModelState, action: AddOperationAction) => void;
5
5
  setOperationNameOperation: (state: DocumentModelState, action: SetOperationNameAction) => void;
6
+ setOperationScopeOperation: (state: DocumentModelState, action: SetOperationScopeAction) => void;
6
7
  setOperationSchemaOperation: (state: DocumentModelState, action: SetOperationSchemaAction) => void;
7
8
  setOperationDescriptionOperation: (state: DocumentModelState, action: SetOperationDescriptionAction) => void;
8
9
  setOperationTemplateOperation: (state: DocumentModelState, action: SetOperationTemplateAction) => void;
@@ -1,3 +1,4 @@
1
+ import { OperationScope } from "../../../document";
1
2
  export type Maybe<T> = T | null;
2
3
  export type InputMaybe<T> = T | null | undefined;
3
4
  export type Exact<T extends {
@@ -74,6 +75,7 @@ export type AddOperationInput = {
74
75
  reducer?: InputMaybe<Scalars['String']['input']>;
75
76
  schema?: InputMaybe<Scalars['String']['input']>;
76
77
  template?: InputMaybe<Scalars['String']['input']>;
78
+ scope?: InputMaybe<OperationScope>;
77
79
  };
78
80
  export type AddStateExampleInput = {
79
81
  example: Scalars['String']['input'];
@@ -119,6 +121,7 @@ export type DocumentModelState = {
119
121
  name: Scalars['String']['output'];
120
122
  specifications: Array<DocumentSpecification>;
121
123
  };
124
+ export type DocumentModelMeta = unknown;
122
125
  export type DocumentSpecification = {
123
126
  __typename?: 'DocumentSpecification';
124
127
  changeLog: Array<Scalars['String']['output']>;
@@ -315,6 +318,7 @@ export type Operation = {
315
318
  reducer: Maybe<Scalars['String']['output']>;
316
319
  schema: Maybe<Scalars['String']['output']>;
317
320
  template: Maybe<Scalars['String']['output']>;
321
+ scope: OperationScope;
318
322
  };
319
323
  export type OperationError = {
320
324
  __typename?: 'OperationError';
@@ -399,6 +403,10 @@ export type SetOperationNameInput = {
399
403
  id: Scalars['ID']['input'];
400
404
  name?: InputMaybe<Scalars['String']['input']>;
401
405
  };
406
+ export type SetOperationScopeInput = {
407
+ id: Scalars['ID']['input'];
408
+ scope: InputMaybe<OperationScope>;
409
+ };
402
410
  export type SetOperationReducerInput = {
403
411
  id: Scalars['ID']['input'];
404
412
  reducer?: InputMaybe<Scalars['String']['input']>;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AddChangeLogItemInput, AddModuleInput, AddOperationErrorInput, AddOperationExampleInput, AddOperationInput, AddStateExampleInput, Author, CodeExample, DeleteChangeLogItemInput, DeleteModuleInput, DeleteOperationErrorInput, DeleteOperationExampleInput, DeleteOperationInput, DeleteStateExampleInput, DocumentModelState, DocumentSpecification, Module, MoveOperationInput, Operation, OperationError, ReorderChangeLogItemsInput, ReorderModuleOperationsInput, ReorderModulesInput, ReorderOperationErrorsInput, ReorderOperationExamplesInput, ReorderStateExamplesInput, SetAuthorNameInput, SetAuthorWebsiteInput, SetInitialStateInput, SetModelDescriptionInput, SetModelExtensionInput, SetModelIdInput, SetModelNameInput, SetModuleDescriptionInput, SetModuleNameInput, SetOperationDescriptionInput, SetOperationErrorCodeInput, SetOperationErrorDescriptionInput, SetOperationErrorNameInput, SetOperationErrorTemplateInput, SetOperationNameInput, SetOperationReducerInput, SetOperationSchemaInput, SetOperationTemplateInput, SetStateSchemaInput, State, UpdateChangeLogItemInput, UpdateOperationExampleInput, UpdateStateExampleInput } from '.';
2
+ import { AddChangeLogItemInput, AddModuleInput, AddOperationErrorInput, AddOperationExampleInput, AddOperationInput, AddStateExampleInput, Author, CodeExample, DeleteChangeLogItemInput, DeleteModuleInput, DeleteOperationErrorInput, DeleteOperationExampleInput, DeleteOperationInput, DeleteStateExampleInput, DocumentModelState, DocumentSpecification, Module, MoveOperationInput, Operation, OperationError, ReorderChangeLogItemsInput, ReorderModuleOperationsInput, ReorderModulesInput, ReorderOperationErrorsInput, ReorderOperationExamplesInput, ReorderStateExamplesInput, SetAuthorNameInput, SetAuthorWebsiteInput, SetInitialStateInput, SetModelDescriptionInput, SetModelExtensionInput, SetModelIdInput, SetModelNameInput, SetModuleDescriptionInput, SetModuleNameInput, SetOperationDescriptionInput, SetOperationErrorCodeInput, SetOperationErrorDescriptionInput, SetOperationErrorNameInput, SetOperationErrorTemplateInput, SetOperationNameInput, SetOperationReducerInput, SetOperationSchemaInput, SetOperationScopeInput, SetOperationTemplateInput, SetStateSchemaInput, State, UpdateChangeLogItemInput, UpdateOperationExampleInput, UpdateStateExampleInput } from '.';
3
3
  type Properties<T> = Required<{
4
4
  [K in keyof T]: z.ZodType<T[K], any, T[K]>;
5
5
  }>;
@@ -88,6 +88,7 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
88
88
  reducer?: z.ZodType<import("./types").InputMaybe<string>, any, import("./types").InputMaybe<string>> | undefined;
89
89
  schema?: z.ZodType<import("./types").InputMaybe<string>, any, import("./types").InputMaybe<string>> | undefined;
90
90
  template?: z.ZodType<import("./types").InputMaybe<string>, any, import("./types").InputMaybe<string>> | undefined;
91
+ scope?: z.ZodType<import("./types").InputMaybe<import("../../../document").OperationScope>, any, import("./types").InputMaybe<import("../../../document").OperationScope>> | undefined;
91
92
  }>, z.UnknownKeysParam, z.ZodTypeAny, {
92
93
  id: string;
93
94
  name: string;
@@ -96,6 +97,7 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
96
97
  reducer?: import("./types").InputMaybe<string>;
97
98
  schema?: import("./types").InputMaybe<string>;
98
99
  template?: import("./types").InputMaybe<string>;
100
+ scope?: import("./types").InputMaybe<import("../../../document").OperationScope>;
99
101
  }, {
100
102
  id: string;
101
103
  name: string;
@@ -104,6 +106,7 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
104
106
  reducer?: import("./types").InputMaybe<string>;
105
107
  schema?: import("./types").InputMaybe<string>;
106
108
  template?: import("./types").InputMaybe<string>;
109
+ scope?: import("./types").InputMaybe<import("../../../document").OperationScope>;
107
110
  }>, z.ZodObject<Required<{
108
111
  example: z.ZodType<string, any, string>;
109
112
  id: z.ZodType<string, any, string>;
@@ -417,6 +420,7 @@ export declare function SetOperationErrorDescriptionInputSchema(): z.ZodObject<P
417
420
  export declare function SetOperationErrorNameInputSchema(): z.ZodObject<Properties<SetOperationErrorNameInput>>;
418
421
  export declare function SetOperationErrorTemplateInputSchema(): z.ZodObject<Properties<SetOperationErrorTemplateInput>>;
419
422
  export declare function SetOperationNameInputSchema(): z.ZodObject<Properties<SetOperationNameInput>>;
423
+ export declare function SetOperationScopeInputSchema(): z.ZodObject<Properties<SetOperationScopeInput>>;
420
424
  export declare function SetOperationReducerInputSchema(): z.ZodObject<Properties<SetOperationReducerInput>>;
421
425
  export declare function SetOperationSchemaInputSchema(): z.ZodObject<Properties<SetOperationSchemaInput>>;
422
426
  export declare function SetOperationTemplateInputSchema(): z.ZodObject<Properties<SetOperationTemplateInput>>;
@@ -48,6 +48,7 @@ declare const actions: {
48
48
  reorderOperationExamples: (input: import("./gen").ReorderOperationExamplesInput) => import("./gen").ReorderOperationExamplesAction;
49
49
  addOperation: (input: import("./gen").AddOperationInput) => import("./gen").AddOperationAction;
50
50
  setOperationName: (input: import("./gen").SetOperationNameInput) => import("./gen").SetOperationNameAction;
51
+ setOperationScope: (input: import("./gen").SetOperationScopeInput) => import("./gen").SetOperationScopeAction;
51
52
  setOperationSchema: (input: import("./gen").SetOperationSchemaInput) => import("./gen").SetOperationSchemaAction;
52
53
  setOperationDescription: (input: import("./gen").SetOperationDescriptionInput) => import("./gen").SetOperationDescriptionAction;
53
54
  setOperationTemplate: (input: import("./gen").SetOperationTemplateInput) => import("./gen").SetOperationTemplateAction;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-ceb8f869.js");require("json-stringify-deterministic");require("immer");require("jszip");const e=require("./internal/index-7d7d05c8.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-70e4dae8.js");require("json-stringify-deterministic");require("immer");require("jszip");const e=require("./internal/index-05592a17.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
@@ -1,8 +1,8 @@
1
- import "./internal/object-98a2cff6.js";
1
+ import "./internal/object-35506f2f.js";
2
2
  import "json-stringify-deterministic";
3
3
  import "immer";
4
4
  import "jszip";
5
- import { b as i, a as u, c, d, m as p, r as l, u as n, z as D } from "./internal/index-48f140bc.js";
5
+ import { b as i, a as u, c, d, m as p, r as l, u as n, z as D } from "./internal/index-ea1557d4.js";
6
6
  import "zod";
7
7
  export {
8
8
  i as Document,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-ceb8f869.js"),r=require("./internal/index-ff22a5bb.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-70e4dae8.js"),r=require("./internal/index-a61bcd7c.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
@@ -1,5 +1,5 @@
1
- import { B as t, h as e, g as m, p as c, z as n } from "./internal/object-98a2cff6.js";
2
- import { i as x } from "./internal/index-9922a4fc.js";
1
+ import { B as t, h as e, g as m, p as c, z as n } from "./internal/object-35506f2f.js";
2
+ import { i as x } from "./internal/index-5dee4170.js";
3
3
  import "json-stringify-deterministic";
4
4
  import "immer";
5
5
  import "jszip";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-ff22a5bb.js"),o=require("./internal/index-7d7d05c8.js");require("./internal/object-ceb8f869.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-a61bcd7c.js"),o=require("./internal/index-05592a17.js");require("./internal/object-70e4dae8.js");require("json-stringify-deterministic");require("immer");require("jszip");require("zod");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},t={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=t;
@@ -1,6 +1,6 @@
1
- import { D as o } from "./internal/index-9922a4fc.js";
2
- import { D as t } from "./internal/index-48f140bc.js";
3
- import "./internal/object-98a2cff6.js";
1
+ import { D as o } from "./internal/index-5dee4170.js";
2
+ import { D as t } from "./internal/index-ea1557d4.js";
3
+ import "./internal/object-35506f2f.js";
4
4
  import "json-stringify-deterministic";
5
5
  import "immer";
6
6
  import "jszip";
@@ -0,0 +1,22 @@
1
+ "use strict";var dt=Object.defineProperty;var ut=(t,e,n)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var de=(t,e,n)=>(ut(t,typeof e!="symbol"?e+"":e,n),n);const s=require("./object-70e4dae8.js");require("json-stringify-deterministic");require("immer");require("jszip");const r=require("zod"),mt=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),f={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:{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:[]}}]},ue=t=>t!=null,Et=r.z.any().refine(t=>ue(t));function _(){return r.z.object({__typename:r.z.literal("AddChangeLogItemInput").optional(),content:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullable()})}function A(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function z(){return r.z.object({errorCode:r.z.string().nullish(),errorDescription:r.z.string().nullish(),errorName:r.z.string().nullish(),errorTemplate:r.z.string().nullish(),id:r.z.string(),operationId:r.z.string()})}function I(){return r.z.object({example:r.z.string(),id:r.z.string(),operationId:r.z.string()})}function T(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),moduleId:r.z.string(),name:r.z.string(),reducer:r.z.string().nullish(),schema:r.z.string().nullish(),template:r.z.string().nullish(),scope:r.z.literal("local").or(r.z.literal("global")).nullish()})}function b(){return r.z.object({example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function me(){return r.z.object({__typename:r.z.literal("Author").optional(),name:r.z.string(),website:r.z.string().nullable()})}function R(){return r.z.object({__typename:r.z.literal("CodeExample").optional(),id:r.z.string(),value:r.z.string()})}function D(){return r.z.object({__typename:r.z.literal("DeleteChangeLogItemInput").optional(),id:r.z.string()})}function M(){return r.z.object({id:r.z.string()})}function x(){return r.z.object({id:r.z.string()})}function N(){return r.z.object({id:r.z.string()})}function L(){return r.z.object({id:r.z.string()})}function P(){return r.z.object({id:r.z.string()})}function ht(){return r.z.union([_(),A(),z(),I(),T(),b(),D(),M(),x(),N(),L(),P(),j(),C(),k(),y(),w(),U(),v(),F(),H(),V(),X(),G(),B(),W(),$(),q(),J(),K(),Q(),Y(),Z(),ee(),te(),re(),oe(),ne(),ie(),se(),ae()])}function Ot(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:me(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(Ee())})}function Ee(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(he()),state:fe(),version:r.z.number()})}function he(){return r.z.object({__typename:r.z.literal("Module").optional(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string(),operations:r.z.array(Oe())})}function j(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function Oe(){return r.z.object({__typename:r.z.literal("Operation").optional(),description:r.z.string().nullable(),errors:r.z.array(ge()),examples:r.z.array(R()),id:r.z.string(),name:r.z.string().nullable(),reducer:r.z.string().nullable(),schema:r.z.string().nullable(),template:r.z.string().nullable(),scope:r.z.literal("local").or(r.z.literal("global"))})}function ge(){return r.z.object({__typename:r.z.literal("OperationError").optional(),code:r.z.string().nullable(),description:r.z.string().nullable(),id:r.z.string(),name:r.z.string().nullable(),template:r.z.string().nullable()})}function C(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function k(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function y(){return r.z.object({order:r.z.array(r.z.string())})}function w(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function U(){return r.z.object({operationId:r.z.string(),order:r.z.array(r.z.string())})}function v(){return r.z.object({order:r.z.array(r.z.string())})}function F(){return r.z.object({authorName:r.z.string()})}function H(){return r.z.object({authorWebsite:r.z.string()})}function V(){return r.z.object({initialValue:r.z.string()})}function X(){return r.z.object({description:r.z.string()})}function G(){return r.z.object({extension:r.z.string()})}function B(){return r.z.object({id:r.z.string()})}function W(){return r.z.object({name:r.z.string()})}function $(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function q(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function J(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function K(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function Se(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function te(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function re(){return r.z.object({id:r.z.string(),schema:r.z.string().nullish()})}function oe(){return r.z.object({id:r.z.string(),template:r.z.string().nullish()})}function ne(){return r.z.object({schema:r.z.string()})}function fe(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(R()),initialValue:r.z.string(),schema:r.z.string()})}function ie(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function se(){return r.z.object({example:r.z.string(),id:r.z.string()})}function ae(){return r.z.object({id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:A,AddOperationErrorInputSchema:z,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:b,AuthorSchema:me,CodeExampleSchema:R,DeleteChangeLogItemInputSchema:D,DeleteModuleInputSchema:M,DeleteOperationErrorInputSchema:x,DeleteOperationExampleInputSchema:N,DeleteOperationInputSchema:L,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:ht,DocumentModelStateSchema:Ot,DocumentSpecificationSchema:Ee,ModuleSchema:he,MoveOperationInputSchema:j,OperationErrorSchema:ge,OperationSchema:Oe,ReorderChangeLogItemsInputSchema:C,ReorderModuleOperationsInputSchema:k,ReorderModulesInputSchema:y,ReorderOperationErrorsInputSchema:w,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:v,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:V,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:$,SetModuleNameInputSchema:q,SetOperationDescriptionInputSchema:J,SetOperationErrorCodeInputSchema:K,SetOperationErrorDescriptionInputSchema:Q,SetOperationErrorNameInputSchema:Y,SetOperationErrorTemplateInputSchema:Z,SetOperationNameInputSchema:ee,SetOperationReducerInputSchema:te,SetOperationSchemaInputSchema:re,SetOperationScopeInputSchema:Se,SetOperationTemplateInputSchema:oe,SetStateSchemaInputSchema:ne,StateSchema:fe,UpdateChangeLogItemInputSchema:ie,UpdateOperationExampleInputSchema:se,UpdateStateExampleInputSchema:ae,definedNonNullAnySchema:Et,isDefinedNonNullAny:ue},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')}},gt=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id===e.input.id&&(n.modules[o].description=e.input.description||"")},deleteModuleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.modules=n.modules.filter(o=>o.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(gt(e.input.order))}},St=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},l={addOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].errors.length;a++)n.modules[o].operations[i].errors[a].id==e.input.id&&(n.modules[o].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].errors=n.modules[o].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].errors.sort(St(e.input.order))}},ft=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},g={addOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)for(let a=0;a<n.modules[o].operations[i].examples.length;a++)n.modules[o].operations[i].examples[a].id==e.input.id&&(n.modules[o].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].examples=n.modules[o].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.operationId&&n.modules[o].operations[i].examples.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},p={addOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.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 n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)for(let i=0;i<n.modules[o].operations.length;i++)n.modules[o].operations[i].id==e.input.id&&(n.modules[o].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const n=[],o=t.specifications[t.specifications.length-1];for(let i=0;i<o.modules.length;i++)o.modules[i].operations=o.modules[i].operations.filter(a=>a.id==e.input.operationId?(n.push(a),!1):!0);for(let i=0;i<o.modules.length;i++)o.modules[i].id==e.input.newModuleId&&o.modules[i].operations.push(...n)},deleteOperationOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].operations=n.modules[o].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.modules.length;o++)n.modules[o].id==e.input.moduleId&&n.modules[o].operations.sort(_t(e.input.order))}},At=t=>{const e={};return t.forEach((n,o)=>e[n]=o),(n,o)=>(e[o.id]||999999)-(e[n.id]||999999)},d={setStateSchemaOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.schema=e.input.schema},setInitialStateOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.initialValue=e.input.initialValue},addStateExampleOperation(t,e){t.specifications[t.specifications.length-1].state.examples.push({id:e.input.id,value:e.input.example})},updateStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];for(let o=0;o<n.state.examples.length;o++)n.state.examples[o].id==e.input.id&&(n.state.examples[o].value=e.input.newExample)},deleteStateExampleOperation(t,e){const n=t.specifications[t.specifications.length-1];n.state.examples=n.state.examples.filter(o=>o.id!=e.input.id)},reorderStateExamplesOperation(t,e){t.specifications[t.specifications.length-1].state.examples.sort(At(e.input.order))}},zt=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t,e);break;case"UPDATE_CHANGE_LOG_ITEM":ie().parse(e.input),E.updateChangeLogItemOperation(t,e);break;case"DELETE_CHANGE_LOG_ITEM":D().parse(e.input),E.deleteChangeLogItemOperation(t,e);break;case"REORDER_CHANGE_LOG_ITEMS":C().parse(e.input),E.reorderChangeLogItemsOperation(t,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,e);break;case"ADD_MODULE":A().parse(e.input),h.addModuleOperation(t,e);break;case"SET_MODULE_NAME":q().parse(e.input),h.setModuleNameOperation(t,e);break;case"SET_MODULE_DESCRIPTION":$().parse(e.input),h.setModuleDescriptionOperation(t,e);break;case"DELETE_MODULE":M().parse(e.input),h.deleteModuleOperation(t,e);break;case"REORDER_MODULES":y().parse(e.input),h.reorderModulesOperation(t,e);break;case"ADD_OPERATION_ERROR":z().parse(e.input),l.addOperationErrorOperation(t,e);break;case"SET_OPERATION_ERROR_CODE":K().parse(e.input),l.setOperationErrorCodeOperation(t,e);break;case"SET_OPERATION_ERROR_NAME":Y().parse(e.input),l.setOperationErrorNameOperation(t,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Q().parse(e.input),l.setOperationErrorDescriptionOperation(t,e);break;case"SET_OPERATION_ERROR_TEMPLATE":Z().parse(e.input),l.setOperationErrorTemplateOperation(t,e);break;case"DELETE_OPERATION_ERROR":x().parse(e.input),l.deleteOperationErrorOperation(t,e);break;case"REORDER_OPERATION_ERRORS":w().parse(e.input),l.reorderOperationErrorsOperation(t,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t,e);break;case"UPDATE_OPERATION_EXAMPLE":se().parse(e.input),g.updateOperationExampleOperation(t,e);break;case"DELETE_OPERATION_EXAMPLE":N().parse(e.input),g.deleteOperationExampleOperation(t,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t,e);break;case"SET_OPERATION_NAME":ee().parse(e.input),p.setOperationNameOperation(t,e);break;case"SET_OPERATION_SCOPE":Se().parse(e.input),p.setOperationScopeOperation(t,e);break;case"SET_OPERATION_SCHEMA":re().parse(e.input),p.setOperationSchemaOperation(t,e);break;case"SET_OPERATION_DESCRIPTION":J().parse(e.input),p.setOperationDescriptionOperation(t,e);break;case"SET_OPERATION_TEMPLATE":oe().parse(e.input),p.setOperationTemplateOperation(t,e);break;case"SET_OPERATION_REDUCER":te().parse(e.input),p.setOperationReducerOperation(t,e);break;case"MOVE_OPERATION":j().parse(e.input),p.moveOperationOperation(t,e);break;case"DELETE_OPERATION":L().parse(e.input),p.deleteOperationOperation(t,e);break;case"REORDER_MODULE_OPERATIONS":k().parse(e.input),p.reorderModuleOperationsOperation(t,e);break;case"SET_STATE_SCHEMA":ne().parse(e.input),d.setStateSchemaOperation(t,e);break;case"SET_INITIAL_STATE":V().parse(e.input),d.setInitialStateOperation(t,e);break;case"ADD_STATE_EXAMPLE":b().parse(e.input),d.addStateExampleOperation(t,e);break;case"UPDATE_STATE_EXAMPLE":ae().parse(e.input),d.updateStateExampleOperation(t,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t,e);break;case"REORDER_STATE_EXAMPLES":v().parse(e.input),d.reorderStateExamplesOperation(t,e);break;default:return t}},m=s.createReducer(zt),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{schema:"",initialValue:"",examples:[]},modules:[]}]},O={fileExtension:"phdm",createState(t){return{...It,...t}},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,n){return s.saveToFile(t,e,"phdm",n)},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}),ze=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),be=t=>s.createAction("SET_AUTHOR_NAME",{...t}),Re=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Tt extends s.BaseDocument{setModelName(e){return this.dispatch(Ae(e))}setModelId(e){return this.dispatch(ze(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(be(e))}setAuthorWebsite(e){return this.dispatch(Re(e))}}const De=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),Me=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),Le=()=>s.createAction("RELEASE_NEW_VERSION");class bt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(De(e))}updateChangeLogItem(e){return this.dispatch(Me(e))}deleteChangeLogItem(e){return this.dispatch(xe(e))}reorderChangeLogItems(e){return this.dispatch(Ne(e))}releaseNewVersion(){return this.dispatch(Le())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),je=t=>s.createAction("SET_MODULE_NAME",{...t}),Ce=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ke=t=>s.createAction("DELETE_MODULE",{...t}),ye=t=>s.createAction("REORDER_MODULES",{...t});class Rt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(je(e))}setModuleDescription(e){return this.dispatch(Ce(e))}deleteModule(e){return this.dispatch(ke(e))}reorderModules(e){return this.dispatch(ye(e))}}const we=t=>s.createAction("ADD_OPERATION_ERROR",{...t}),Ue=t=>s.createAction("SET_OPERATION_ERROR_CODE",{...t}),ve=t=>s.createAction("SET_OPERATION_ERROR_NAME",{...t}),Fe=t=>s.createAction("SET_OPERATION_ERROR_DESCRIPTION",{...t}),He=t=>s.createAction("SET_OPERATION_ERROR_TEMPLATE",{...t}),Ve=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Dt extends s.BaseDocument{addOperationError(e){return this.dispatch(we(e))}setOperationErrorCode(e){return this.dispatch(Ue(e))}setOperationErrorName(e){return this.dispatch(ve(e))}setOperationErrorDescription(e){return this.dispatch(Fe(e))}setOperationErrorTemplate(e){return this.dispatch(He(e))}deleteOperationError(e){return this.dispatch(Ve(e))}reorderOperationErrors(e){return this.dispatch(Xe(e))}}const Ge=t=>s.createAction("ADD_OPERATION_EXAMPLE",{...t}),Be=t=>s.createAction("UPDATE_OPERATION_EXAMPLE",{...t}),We=t=>s.createAction("DELETE_OPERATION_EXAMPLE",{...t}),$e=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class Mt extends s.BaseDocument{addOperationExample(e){return this.dispatch(Ge(e))}updateOperationExample(e){return this.dispatch(Be(e))}deleteOperationExample(e){return this.dispatch(We(e))}reorderOperationExamples(e){return this.dispatch($e(e))}}const qe=t=>s.createAction("ADD_OPERATION",{...t}),Je=t=>s.createAction("SET_OPERATION_NAME",{...t}),Ke=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ye=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),Ze=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),et=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),tt=t=>s.createAction("MOVE_OPERATION",{...t}),rt=t=>s.createAction("DELETE_OPERATION",{...t}),ot=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class xt extends s.BaseDocument{addOperation(e){return this.dispatch(qe(e))}setOperationName(e){return this.dispatch(Je(e))}setOperationScope(e){return this.dispatch(Ke(e))}setOperationSchema(e){return this.dispatch(Qe(e))}setOperationDescription(e){return this.dispatch(Ye(e))}setOperationTemplate(e){return this.dispatch(Ze(e))}setOperationReducer(e){return this.dispatch(et(e))}moveOperation(e){return this.dispatch(tt(e))}deleteOperation(e){return this.dispatch(rt(e))}reorderModuleOperations(e){return this.dispatch(ot(e))}}const nt=t=>s.createAction("SET_STATE_SCHEMA",{...t}),it=t=>s.createAction("SET_INITIAL_STATE",{...t}),st=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),at=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Nt extends s.BaseDocument{setStateSchema(e){return this.dispatch(nt(e))}setInitialState(e){return this.dispatch(it(e))}addStateExample(e){return this.dispatch(st(e))}updateStateExample(e){return this.dispatch(at(e))}deleteStateExample(e){return this.dispatch(pt(e))}reorderStateExamples(e){return this.dispatch(lt(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e){super(m,O.createDocument(e))}saveToFile(e,n){return super.saveToFile(e,u.fileExtension,n)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const n=new this;return await n.loadFromFile(e),n}},de(u,"fileExtension","phdm"),u);s.applyMixins(S,[Tt,bt,Rt,Dt,Mt,xt,Nt]);const Lt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:De,addModule:Pe,addOperation:qe,addOperationError:we,addOperationExample:Ge,addStateExample:st,deleteChangeLogItem:xe,deleteModule:ke,deleteOperation:rt,deleteOperationError:Ve,deleteOperationExample:We,deleteStateExample:pt,moveOperation:tt,releaseNewVersion:Le,reorderChangeLogItems:Ne,reorderModuleOperations:ot,reorderModules:ye,reorderOperationErrors:Xe,reorderOperationExamples:$e,reorderStateExamples:lt,setAuthorName:be,setAuthorWebsite:Re,setInitialState:it,setModelDescription:Te,setModelExtension:Ie,setModelId:ze,setModelName:Ae,setModuleDescription:Ce,setModuleName:je,setOperationDescription:Ye,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:ve,setOperationErrorTemplate:He,setOperationName:Je,setOperationReducer:et,setOperationSchema:Qe,setOperationScope:Ke,setOperationTemplate:Ze,setStateSchema:nt,updateChangeLogItem:Me,updateOperationExample:Be,updateStateExample:at},Symbol.toStringTag,{value:"Module"})),pe=S,le={...O,...mt},ce={...s.BaseActions,...Lt},ct={Document:pe,reducer:m,actions:ce,utils:le,documentModel:f},Pt=Object.freeze(Object.defineProperty({__proto__:null,Document:pe,DocumentModel:S,actions:ce,documentModel:f,module:ct,reducer:m,utils:le,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=pe;exports.DocumentModel=Pt;exports.DocumentModel$1=S;exports.actions=ce;exports.documentModel=f;exports.module=ct;exports.reducer=m;exports.utils=le;exports.zod=_e;
@@ -1,4 +1,4 @@
1
- import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-6f942fcb.js";
1
+ import { f as e, b as a, a as s, c as t, j as o, k as r, m as c, n as l, o as n, i, l as d, e as u, r as m, s as p, d as b, B as _, h as g, g as y, p as F, z as f } from "./object-35506f2f.js";
2
2
  const h = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  createAction: e,
@@ -1 +1 @@
1
- "use strict";const e=require("./object-10abe15d.js"),t=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,readOnly:e.readOnly,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;
1
+ "use strict";const e=require("./object-70e4dae8.js"),t=Object.freeze(Object.defineProperty({__proto__:null,createAction:e.createAction,createDocument:e.createDocument,createExtendedState:e.createExtendedState,createReducer:e.createReducer,createZip:e.createZip,getLocalFile:e.getLocalFile,getRemoteFile:e.getRemoteFile,hashDocument:e.hashDocument,hashKey:e.hashKey,isBaseAction:e.isBaseAction,loadFromFile:e.loadFromFile,loadFromInput:e.loadFromInput,readOnly:e.readOnly,saveToFile:e.saveToFile,saveToFileHandle:e.saveToFileHandle},Symbol.toStringTag,{value:"Module"})),o=Object.freeze(Object.defineProperty({__proto__:null,BaseDocument:e.BaseDocument,actions:e.BaseActions,applyMixins:e.applyMixins,baseReducer:e.baseReducer,utils:t,z:e.zod},Symbol.toStringTag,{value:"Module"}));exports.Document=o;exports.index=t;