document-model 1.0.15 → 1.0.17

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 (57) hide show
  1. package/dist/browser/document/actions/creators.d.ts +1 -1
  2. package/dist/browser/document/actions/index.d.ts +8 -8
  3. package/dist/browser/document/object.d.ts +123 -99
  4. package/dist/browser/document/reducer.d.ts +1 -1
  5. package/dist/browser/document/schema/types.d.ts +5 -0
  6. package/dist/browser/document/schema/zod.d.ts +39 -0
  7. package/dist/browser/document/types.d.ts +41 -31
  8. package/dist/browser/document/utils/base.d.ts +6 -6
  9. package/dist/browser/document/utils/file.d.ts +2 -2
  10. package/dist/browser/document-model/gen/object.d.ts +1 -1
  11. package/dist/browser/document-model/gen/reducer.d.ts +1 -1
  12. package/dist/browser/document-model/gen/schema/types.d.ts +13 -3
  13. package/dist/browser/document-model/gen/schema/zod.d.ts +20 -1
  14. package/dist/browser/document-model/index.d.ts +9 -9
  15. package/dist/browser/document-model.cjs +1 -1
  16. package/dist/browser/document-model.js +2 -2
  17. package/dist/browser/document.cjs +1 -1
  18. package/dist/browser/document.js +2 -2
  19. package/dist/browser/index.cjs +1 -1
  20. package/dist/browser/index.js +3 -3
  21. package/dist/browser/internal/index-01030c3f.js +22 -0
  22. package/dist/{node/internal/index-c9d178be.js → browser/internal/index-2aee8ea9.js} +1 -1
  23. package/dist/browser/internal/{index-8142b58e.js → index-5f1909ad.js} +513 -435
  24. package/dist/{node/internal/index-0b0cb8c2.js → browser/internal/index-a1282d5c.js} +1 -1
  25. package/dist/browser/internal/object-24df9d92.js +6 -0
  26. package/dist/browser/internal/{object-4ec03a36.js → object-7e8eaff4.js} +777 -731
  27. package/dist/node/document/actions/creators.d.ts +1 -1
  28. package/dist/node/document/actions/index.d.ts +8 -8
  29. package/dist/node/document/object.d.ts +123 -99
  30. package/dist/node/document/reducer.d.ts +1 -1
  31. package/dist/node/document/schema/types.d.ts +5 -0
  32. package/dist/node/document/schema/zod.d.ts +39 -0
  33. package/dist/node/document/types.d.ts +41 -31
  34. package/dist/node/document/utils/base.d.ts +6 -6
  35. package/dist/node/document/utils/file.d.ts +2 -2
  36. package/dist/node/document-model/gen/object.d.ts +1 -1
  37. package/dist/node/document-model/gen/reducer.d.ts +1 -1
  38. package/dist/node/document-model/gen/schema/types.d.ts +13 -3
  39. package/dist/node/document-model/gen/schema/zod.d.ts +20 -1
  40. package/dist/node/document-model/index.d.ts +9 -9
  41. package/dist/node/document-model.cjs +1 -1
  42. package/dist/node/document-model.js +2 -2
  43. package/dist/node/document.cjs +1 -1
  44. package/dist/node/document.js +2 -2
  45. package/dist/node/index.cjs +1 -1
  46. package/dist/node/index.js +3 -3
  47. package/dist/node/internal/{index-0c87fbed.js → index-0db636da.js} +513 -435
  48. package/dist/{browser/internal/index-cb990484.js → node/internal/index-2d4783d9.js} +1 -1
  49. package/dist/{browser/internal/index-9f1cf811.js → node/internal/index-5ef0c6b0.js} +1 -1
  50. package/dist/node/internal/index-cddc9dfd.js +22 -0
  51. package/dist/node/internal/object-21f3d2ee.js +1 -0
  52. package/dist/node/internal/{object-89d9b82f.js → object-c32ea0a0.js} +400 -356
  53. package/package.json +3 -3
  54. package/dist/browser/internal/index-cbe39f72.js +0 -22
  55. package/dist/browser/internal/object-5f03095e.js +0 -6
  56. package/dist/node/internal/index-63db4708.js +0 -22
  57. package/dist/node/internal/object-397a9b23.js +0 -1
@@ -31,8 +31,8 @@ export declare const saveToFileHandle: (document: Document, input: FileSystemFil
31
31
  * @returns A promise that resolves to the document state after applying all the operations.
32
32
  * @throws An error if the initial state or the operations history is not found in the ZIP file.
33
33
  */
34
- export declare const loadFromFile: <S, A extends Action>(path: string, reducer: Reducer<S, A>) => Promise<Document<S, A>>;
35
- export declare const loadFromInput: <S, A extends Action>(input: FileInput, reducer: Reducer<S, A>) => Promise<Document<S, A>>;
34
+ export declare const loadFromFile: <S, A extends Action, L>(path: string, reducer: Reducer<S, A, L>) => Promise<Document<S, A, L>>;
35
+ export declare const loadFromInput: <S, A extends Action, L>(input: FileInput, reducer: Reducer<S, A, L>) => Promise<Document<S, A, L>>;
36
36
  /**
37
37
  * Fetches an attachment from a URL and returns its base64-encoded data and MIME type.
38
38
  * @param url - The URL of the attachment to fetch.
@@ -20,7 +20,7 @@ interface DocumentModel extends DocumentModel_Header, DocumentModel_Versioning,
20
20
  }
21
21
  declare class DocumentModel extends BaseDocument<DocumentModelState, DocumentModelAction> {
22
22
  static fileExtension: string;
23
- constructor(initialState?: Partial<ExtendedState<Partial<DocumentModelState>>>, dispatch?: SignalDispatch);
23
+ constructor(initialState?: Partial<ExtendedState<Partial<DocumentModelState>, unknown>>, dispatch?: SignalDispatch);
24
24
  saveToFile(path: string, name?: string): Promise<string>;
25
25
  loadFromFile(path: string): Promise<void>;
26
26
  static fromFile(path: string): Promise<DocumentModel>;
@@ -1,3 +1,3 @@
1
1
  import { DocumentModelState } from './schema';
2
2
  import { DocumentModelAction } from './actions';
3
- export declare const reducer: import("../../document/types").Reducer<DocumentModelState, DocumentModelAction>;
3
+ export declare const reducer: import("../../document/types").Reducer<DocumentModelState, DocumentModelAction, unknown>;
@@ -1,4 +1,4 @@
1
- import { OperationScope } from "../../../document";
1
+ import { OperationScope } from '../../../document';
2
2
  export type Maybe<T> = T | null;
3
3
  export type InputMaybe<T> = T | null | undefined;
4
4
  export type Exact<T extends {
@@ -78,6 +78,7 @@ export type AddOperationInput = {
78
78
  scope?: InputMaybe<OperationScope>;
79
79
  };
80
80
  export type AddStateExampleInput = {
81
+ scope: Scalars['String']['input'];
81
82
  example: Scalars['String']['input'];
82
83
  id: Scalars['ID']['input'];
83
84
  insertBefore?: InputMaybe<Scalars['ID']['input']>;
@@ -109,6 +110,7 @@ export type DeleteOperationInput = {
109
110
  id: Scalars['ID']['input'];
110
111
  };
111
112
  export type DeleteStateExampleInput = {
113
+ scope: Scalars['String']['input'];
112
114
  id: Scalars['ID']['input'];
113
115
  };
114
116
  export type DocumentModelInput = AddChangeLogItemInput | AddModuleInput | AddOperationErrorInput | AddOperationExampleInput | AddOperationInput | AddStateExampleInput | DeleteChangeLogItemInput | DeleteModuleInput | DeleteOperationErrorInput | DeleteOperationExampleInput | DeleteOperationInput | DeleteStateExampleInput | MoveOperationInput | 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 | UpdateChangeLogItemInput | UpdateOperationExampleInput | UpdateStateExampleInput;
@@ -121,12 +123,16 @@ export type DocumentModelState = {
121
123
  name: Scalars['String']['output'];
122
124
  specifications: Array<DocumentSpecification>;
123
125
  };
124
- export type DocumentModelMeta = unknown;
126
+ export type ScopeState = {
127
+ global: State;
128
+ local: State;
129
+ };
130
+ export type DocumentModelLocalState = Record<string, never>;
125
131
  export type DocumentSpecification = {
126
132
  __typename?: 'DocumentSpecification';
127
133
  changeLog: Array<Scalars['String']['output']>;
128
134
  modules: Array<Module>;
129
- state: State;
135
+ state: ScopeState;
130
136
  version: Scalars['Int']['output'];
131
137
  };
132
138
  export type Module = {
@@ -348,6 +354,7 @@ export type ReorderOperationExamplesInput = {
348
354
  order: Array<Scalars['ID']['input']>;
349
355
  };
350
356
  export type ReorderStateExamplesInput = {
357
+ scope: Scalars['String']['input'];
351
358
  order: Array<Scalars['ID']['input']>;
352
359
  };
353
360
  export type SetAuthorNameInput = {
@@ -357,6 +364,7 @@ export type SetAuthorWebsiteInput = {
357
364
  authorWebsite: Scalars['String']['input'];
358
365
  };
359
366
  export type SetInitialStateInput = {
367
+ scope: Scalars['String']['input'];
360
368
  initialValue: Scalars['String']['input'];
361
369
  };
362
370
  export type SetModelDescriptionInput = {
@@ -420,6 +428,7 @@ export type SetOperationTemplateInput = {
420
428
  template?: InputMaybe<Scalars['String']['input']>;
421
429
  };
422
430
  export type SetStateSchemaInput = {
431
+ scope: Scalars['String']['input'];
423
432
  schema: Scalars['String']['input'];
424
433
  };
425
434
  export type State = {
@@ -438,6 +447,7 @@ export type UpdateOperationExampleInput = {
438
447
  id: Scalars['ID']['input'];
439
448
  };
440
449
  export type UpdateStateExampleInput = {
450
+ scope: Scalars['String']['input'];
441
451
  id: Scalars['ID']['input'];
442
452
  newExample: Scalars['String']['input'];
443
453
  };
@@ -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, SetOperationScopeInput, 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, ScopeState, 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
  }>;
@@ -108,16 +108,19 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
108
108
  template?: import("./types").InputMaybe<string>;
109
109
  scope?: import("./types").InputMaybe<import("../../../document").OperationScope>;
110
110
  }>, z.ZodObject<Required<{
111
+ scope: z.ZodType<string, any, string>;
111
112
  example: z.ZodType<string, any, string>;
112
113
  id: z.ZodType<string, any, string>;
113
114
  insertBefore?: z.ZodType<import("./types").InputMaybe<string>, any, import("./types").InputMaybe<string>> | undefined;
114
115
  }>, z.UnknownKeysParam, z.ZodTypeAny, {
115
116
  id: string;
116
117
  example: string;
118
+ scope: string;
117
119
  insertBefore?: import("./types").InputMaybe<string>;
118
120
  }, {
119
121
  id: string;
120
122
  example: string;
123
+ scope: string;
121
124
  insertBefore?: import("./types").InputMaybe<string>;
122
125
  }>, z.ZodObject<Required<{
123
126
  __typename?: z.ZodType<"DeleteChangeLogItemInput" | undefined, any, "DeleteChangeLogItemInput" | undefined> | undefined;
@@ -153,11 +156,14 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
153
156
  }, {
154
157
  id: string;
155
158
  }>, z.ZodObject<Required<{
159
+ scope: z.ZodType<string, any, string>;
156
160
  id: z.ZodType<string, any, string>;
157
161
  }>, z.UnknownKeysParam, z.ZodTypeAny, {
158
162
  id: string;
163
+ scope: string;
159
164
  }, {
160
165
  id: string;
166
+ scope: string;
161
167
  }>, z.ZodObject<Required<{
162
168
  newModuleId: z.ZodType<string, any, string>;
163
169
  operationId: z.ZodType<string, any, string>;
@@ -210,10 +216,13 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
210
216
  operationId: string;
211
217
  order: string[];
212
218
  }>, z.ZodObject<Required<{
219
+ scope: z.ZodType<string, any, string>;
213
220
  order: z.ZodType<string[], any, string[]>;
214
221
  }>, z.UnknownKeysParam, z.ZodTypeAny, {
222
+ scope: string;
215
223
  order: string[];
216
224
  }, {
225
+ scope: string;
217
226
  order: string[];
218
227
  }>, z.ZodObject<Required<{
219
228
  authorName: z.ZodType<string, any, string>;
@@ -228,10 +237,13 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
228
237
  }, {
229
238
  authorWebsite: string;
230
239
  }>, z.ZodObject<Required<{
240
+ scope: z.ZodType<string, any, string>;
231
241
  initialValue: z.ZodType<string, any, string>;
232
242
  }>, z.UnknownKeysParam, z.ZodTypeAny, {
243
+ scope: string;
233
244
  initialValue: string;
234
245
  }, {
246
+ scope: string;
235
247
  initialValue: string;
236
248
  }>, z.ZodObject<Required<{
237
249
  description: z.ZodType<string, any, string>;
@@ -357,11 +369,14 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
357
369
  id: string;
358
370
  template?: import("./types").InputMaybe<string>;
359
371
  }>, z.ZodObject<Required<{
372
+ scope: z.ZodType<string, any, string>;
360
373
  schema: z.ZodType<string, any, string>;
361
374
  }>, z.UnknownKeysParam, z.ZodTypeAny, {
362
375
  schema: string;
376
+ scope: string;
363
377
  }, {
364
378
  schema: string;
379
+ scope: string;
365
380
  }>, z.ZodObject<Required<{
366
381
  __typename?: z.ZodType<"UpdateChangeLogItemInput" | undefined, any, "UpdateChangeLogItemInput" | undefined> | undefined;
367
382
  id: z.ZodType<string, any, string>;
@@ -384,13 +399,16 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
384
399
  id: string;
385
400
  example: string;
386
401
  }>, z.ZodObject<Required<{
402
+ scope: z.ZodType<string, any, string>;
387
403
  id: z.ZodType<string, any, string>;
388
404
  newExample: z.ZodType<string, any, string>;
389
405
  }>, z.UnknownKeysParam, z.ZodTypeAny, {
390
406
  id: string;
407
+ scope: string;
391
408
  newExample: string;
392
409
  }, {
393
410
  id: string;
411
+ scope: string;
394
412
  newExample: string;
395
413
  }>]>;
396
414
  export declare function DocumentModelStateSchema(): z.ZodObject<Properties<DocumentModelState>>;
@@ -426,6 +444,7 @@ export declare function SetOperationSchemaInputSchema(): z.ZodObject<Properties<
426
444
  export declare function SetOperationTemplateInputSchema(): z.ZodObject<Properties<SetOperationTemplateInput>>;
427
445
  export declare function SetStateSchemaInputSchema(): z.ZodObject<Properties<SetStateSchemaInput>>;
428
446
  export declare function StateSchema(): z.ZodObject<Properties<State>>;
447
+ export declare function ScopeStateSchema(): z.ZodObject<Properties<ScopeState>>;
429
448
  export declare function UpdateChangeLogItemInputSchema(): z.ZodObject<Properties<UpdateChangeLogItemInput>>;
430
449
  export declare function UpdateOperationExampleInputSchema(): z.ZodObject<Properties<UpdateOperationExampleInput>>;
431
450
  export declare function UpdateStateExampleInputSchema(): z.ZodObject<Properties<UpdateStateExampleInput>>;
@@ -10,13 +10,13 @@ import { DocumentModelAction, DocumentModelState } from './gen/types';
10
10
  declare const Document: typeof DocumentModel;
11
11
  declare const utils: {
12
12
  fileExtension: string;
13
- createState: (state?: Partial<DocumentModelState> | undefined) => DocumentModelState;
14
- createExtendedState: (extendedState?: Partial<import("../document").ExtendedState<Partial<DocumentModelState>>> | undefined, createState?: ((state?: Partial<DocumentModelState> | undefined) => DocumentModelState) | undefined) => import("../document").ExtendedState<DocumentModelState>;
15
- createDocument: (document?: Partial<import("../document").ExtendedState<Partial<DocumentModelState>>> | undefined, createState?: ((state?: Partial<DocumentModelState> | undefined) => DocumentModelState) | undefined) => import("../document").Document<DocumentModelState, DocumentModelAction>;
16
- loadFromFile: (path: string) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction>>;
17
- loadFromInput: (input: import("../document").FileInput) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction>>;
18
- saveToFile: (document: import("../document").Document<DocumentModelState, DocumentModelAction>, path: string, name?: string | undefined) => Promise<string>;
19
- saveToFileHandle: (document: import("../document").Document<DocumentModelState, DocumentModelAction>, input: FileSystemFileHandle) => Promise<void>;
13
+ createState: import("../document").CreateState<DocumentModelState, unknown>;
14
+ createExtendedState: (extendedState?: Partial<import("../document").ExtendedState<import("../document").PartialState<DocumentModelState>, unknown>> | undefined, createState?: import("../document").CreateState<DocumentModelState, unknown> | undefined) => import("../document").ExtendedState<DocumentModelState, unknown>;
15
+ createDocument: (document?: Partial<import("../document").ExtendedState<import("../document").PartialState<DocumentModelState>, unknown>> | undefined, createState?: import("../document").CreateState<DocumentModelState, unknown> | undefined) => import("../document").Document<DocumentModelState, DocumentModelAction, unknown>;
16
+ loadFromFile: (path: string) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction, unknown>>;
17
+ loadFromInput: (input: import("../document").FileInput) => Promise<import("../document").Document<DocumentModelState, DocumentModelAction, unknown>>;
18
+ saveToFile: (document: import("../document").Document<DocumentModelState, DocumentModelAction, unknown>, path: string, name?: string | undefined) => Promise<string>;
19
+ saveToFileHandle: (document: import("../document").Document<DocumentModelState, DocumentModelAction, unknown>, input: FileSystemFileHandle) => Promise<void>;
20
20
  };
21
21
  declare const actions: {
22
22
  setModelName: (input: import("./gen").SetModelNameInput) => import("./gen").SetModelNameAction;
@@ -66,9 +66,9 @@ declare const actions: {
66
66
  undo: (count?: number) => import("../document").UndoAction;
67
67
  redo: (count?: number) => import("../document").RedoAction;
68
68
  prune: (start?: number | undefined, end?: number | undefined) => import("../document").PruneAction;
69
- loadState: (state: Pick<import("../document").ExtendedState, "name" | "state">, operations: number) => import("../document").LoadStateAction;
69
+ loadState: <S, T>(state: Pick<import("../document").ExtendedState<S, T>, "name" | "state">, operations: number) => import("../document").LoadStateAction;
70
70
  };
71
- export declare const module: _DocumentModel<DocumentModelState, DocumentModelAction, DocumentModel>;
71
+ export declare const module: _DocumentModel<DocumentModelState, DocumentModelAction, unknown, DocumentModel>;
72
72
  export * from './custom/utils';
73
73
  export * from './gen/types';
74
74
  export { DocumentModel, Document, reducer, actions, utils, documentModel };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-5f03095e.js");require("json-stringify-deterministic");require("immer");require("jszip");const e=require("./internal/index-cbe39f72.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-24df9d92.js");require("json-stringify-deterministic");require("immer");require("jszip");const e=require("./internal/index-01030c3f.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-4ec03a36.js";
1
+ import "./internal/object-7e8eaff4.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-8142b58e.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-5f1909ad.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-5f03095e.js"),r=require("./internal/index-cb990484.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-24df9d92.js"),r=require("./internal/index-2aee8ea9.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-4ec03a36.js";
2
- import { i as x } from "./internal/index-9f1cf811.js";
1
+ import { B as t, h as e, g as m, p as c, z as n } from "./internal/object-7e8eaff4.js";
2
+ import { i as x } from "./internal/index-a1282d5c.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-cb990484.js"),o=require("./internal/index-cbe39f72.js");require("./internal/object-5f03095e.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-2aee8ea9.js"),o=require("./internal/index-01030c3f.js");require("./internal/object-24df9d92.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-9f1cf811.js";
2
- import { D as t } from "./internal/index-8142b58e.js";
3
- import "./internal/object-4ec03a36.js";
1
+ import { D as o } from "./internal/index-a1282d5c.js";
2
+ import { D as t } from "./internal/index-5f1909ad.js";
3
+ import "./internal/object-7e8eaff4.js";
4
4
  import "json-stringify-deterministic";
5
5
  import "immer";
6
6
  import "jszip";
@@ -0,0 +1,22 @@
1
+ "use strict";var ut=Object.defineProperty;var mt=(t,e,o)=>e in t?ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var ue=(t,e,o)=>(mt(t,typeof e!="symbol"?e+"":e,o),o);const s=require("./object-24df9d92.js");require("json-stringify-deterministic");require("immer");require("jszip");const r=require("zod"),Et=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:{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:[]}}}]},me=t=>t!=null,ht=r.z.any().refine(t=>me(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 z(){return r.z.object({description:r.z.string().nullish(),id:r.z.string(),name:r.z.string()})}function A(){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 R(){return r.z.object({scope:r.z.string(),example:r.z.string(),id:r.z.string(),insertBefore:r.z.string().nullish()})}function Ee(){return r.z.object({__typename:r.z.literal("Author").optional(),name:r.z.string(),website:r.z.string().nullable()})}function D(){return r.z.object({__typename:r.z.literal("CodeExample").optional(),id:r.z.string(),value:r.z.string()})}function M(){return r.z.object({__typename:r.z.literal("DeleteChangeLogItemInput").optional(),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 j(){return r.z.object({id:r.z.string()})}function P(){return r.z.object({scope:r.z.string(),id:r.z.string()})}function Ot(){return r.z.union([_(),z(),A(),I(),T(),R(),M(),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()])}function gt(){return r.z.object({__typename:r.z.literal("DocumentModelState").optional(),author:Ee(),description:r.z.string(),extension:r.z.string(),id:r.z.string(),name:r.z.string(),specifications:r.z.array(he())})}function he(){return r.z.object({__typename:r.z.literal("DocumentSpecification").optional(),changeLog:r.z.array(r.z.string()),modules:r.z.array(Oe()),state:fe(),version:r.z.number()})}function Oe(){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(ge())})}function C(){return r.z.object({newModuleId:r.z.string(),operationId:r.z.string()})}function ge(){return r.z.object({__typename:r.z.literal("Operation").optional(),description:r.z.string().nullable(),errors:r.z.array(Se()),examples:r.z.array(D()),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 Se(){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 k(){return r.z.object({__typename:r.z.literal("ReorderChangeLogItemsInput").optional(),order:r.z.array(r.z.string())})}function y(){return r.z.object({moduleId:r.z.string(),order:r.z.array(r.z.string())})}function w(){return r.z.object({order:r.z.array(r.z.string())})}function v(){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({scope:r.z.string(),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 $(){return r.z.object({scope:r.z.string(),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 q(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function J(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function K(){return r.z.object({description:r.z.string().nullish(),id:r.z.string()})}function Q(){return r.z.object({errorCode:r.z.string().nullish(),id:r.z.string()})}function Y(){return r.z.object({errorDescription:r.z.string().nullish(),id:r.z.string()})}function Z(){return r.z.object({errorName:r.z.string().nullish(),id:r.z.string()})}function ee(){return r.z.object({errorTemplate:r.z.string().nullish(),id:r.z.string()})}function te(){return r.z.object({id:r.z.string(),name:r.z.string().nullish()})}function be(){return r.z.object({id:r.z.string(),scope:r.z.literal("global").or(r.z.literal("local"))})}function re(){return r.z.object({id:r.z.string(),reducer:r.z.string().nullish()})}function oe(){return r.z.object({id:r.z.string(),schema:r.z.string().nullish()})}function ne(){return r.z.object({id:r.z.string(),template:r.z.string().nullish()})}function ie(){return r.z.object({scope:r.z.string(),schema:r.z.string()})}function b(){return r.z.object({__typename:r.z.literal("State").optional(),examples:r.z.array(D()),initialValue:r.z.string(),schema:r.z.string()})}function fe(){return r.z.object({global:b(),local:b()})}function se(){return r.z.object({__typename:r.z.literal("UpdateChangeLogItemInput").optional(),id:r.z.string(),newContent:r.z.string()})}function ae(){return r.z.object({example:r.z.string(),id:r.z.string()})}function pe(){return r.z.object({scope:r.z.string(),id:r.z.string(),newExample:r.z.string()})}const _e=Object.freeze(Object.defineProperty({__proto__:null,AddChangeLogItemInputSchema:_,AddModuleInputSchema:z,AddOperationErrorInputSchema:A,AddOperationExampleInputSchema:I,AddOperationInputSchema:T,AddStateExampleInputSchema:R,AuthorSchema:Ee,CodeExampleSchema:D,DeleteChangeLogItemInputSchema:M,DeleteModuleInputSchema:x,DeleteOperationErrorInputSchema:N,DeleteOperationExampleInputSchema:L,DeleteOperationInputSchema:j,DeleteStateExampleInputSchema:P,DocumentModelInputSchema:Ot,DocumentModelStateSchema:gt,DocumentSpecificationSchema:he,ModuleSchema:Oe,MoveOperationInputSchema:C,OperationErrorSchema:Se,OperationSchema:ge,ReorderChangeLogItemsInputSchema:k,ReorderModuleOperationsInputSchema:y,ReorderModulesInputSchema:w,ReorderOperationErrorsInputSchema:v,ReorderOperationExamplesInputSchema:U,ReorderStateExamplesInputSchema:V,ScopeStateSchema:fe,SetAuthorNameInputSchema:F,SetAuthorWebsiteInputSchema:H,SetInitialStateInputSchema:$,SetModelDescriptionInputSchema:X,SetModelExtensionInputSchema:G,SetModelIdInputSchema:B,SetModelNameInputSchema:W,SetModuleDescriptionInputSchema:q,SetModuleNameInputSchema:J,SetOperationDescriptionInputSchema:K,SetOperationErrorCodeInputSchema:Q,SetOperationErrorDescriptionInputSchema:Y,SetOperationErrorNameInputSchema:Z,SetOperationErrorTemplateInputSchema:ee,SetOperationNameInputSchema:te,SetOperationReducerInputSchema:re,SetOperationSchemaInputSchema:oe,SetOperationScopeInputSchema:be,SetOperationTemplateInputSchema:ne,SetStateSchemaInputSchema:ie,StateSchema:b,UpdateChangeLogItemInputSchema:se,UpdateOperationExampleInputSchema:ae,UpdateStateExampleInputSchema:pe,definedNonNullAnySchema:ht,isDefinedNonNullAny:me},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')}},St=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.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 o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id===e.input.id&&(o.modules[n].name=e.input.name||"")},setModuleDescriptionOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id===e.input.id&&(o.modules[n].description=e.input.description||"")},deleteModuleOperation(t,e){const o=t.specifications[t.specifications.length-1];o.modules=o.modules.filter(n=>n.id!=e.input.id)},reorderModulesOperation(t,e){t.specifications[t.specifications.length-1].modules.sort(St(e.input.order))}},bt=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},l={addOperationErrorOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.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 o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].code=e.input.errorCode||"")},setOperationErrorNameOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].name=e.input.errorName||"")},setOperationErrorDescriptionOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].description=e.input.errorDescription||"")},setOperationErrorTemplateOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].errors.length;a++)o.modules[n].operations[i].errors[a].id==e.input.id&&(o.modules[n].operations[i].errors[a].template=e.input.errorTemplate||"")},deleteOperationErrorOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].errors=o.modules[n].operations[i].errors.filter(a=>a.id!=e.input.id)},reorderOperationErrorsOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.modules[n].operations[i].errors.sort(bt(e.input.order))}},ft=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},g={addOperationExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.modules[n].operations[i].examples.push({id:e.input.id,value:e.input.example})},updateOperationExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)for(let a=0;a<o.modules[n].operations[i].examples.length;a++)o.modules[n].operations[i].examples[a].id==e.input.id&&(o.modules[n].operations[i].examples[a].value=e.input.example)},deleteOperationExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].examples=o.modules[n].operations[i].examples.filter(a=>a.id!=e.input.id)},reorderOperationExamplesOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.operationId&&o.modules[n].operations[i].examples.sort(ft(e.input.order))}},_t=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},p={addOperationOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id==e.input.moduleId&&o.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 o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].name=e.input.name||"")},setOperationScopeOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].scope=e.input.scope||"global")},setOperationSchemaOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].schema=e.input.schema||"")},setOperationDescriptionOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].description=e.input.description||"")},setOperationTemplateOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].template=e.input.template||"")},setOperationReducerOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)for(let i=0;i<o.modules[n].operations.length;i++)o.modules[n].operations[i].id==e.input.id&&(o.modules[n].operations[i].reducer=e.input.reducer||"")},moveOperationOperation(t,e){const o=[],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?(o.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(...o)},deleteOperationOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].operations=o.modules[n].operations.filter(i=>i.id!=e.input.id)},reorderModuleOperationsOperation(t,e){const o=t.specifications[t.specifications.length-1];for(let n=0;n<o.modules.length;n++)o.modules[n].id==e.input.moduleId&&o.modules[n].operations.sort(_t(e.input.order))}},zt=t=>{const e={};return t.forEach((o,n)=>e[o]=n),(o,n)=>(e[n.id]||999999)-(e[o.id]||999999)},d={setStateSchemaOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].schema=e.input.schema;else throw new Error(`Invalid scope: ${e.input.scope}`)},setInitialStateOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].initialValue=e.input.initialValue;else throw new Error(`Invalid scope: ${e.input.scope}`)},addStateExampleOperation(t,e){const o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.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 o=t.specifications[t.specifications.length-1];if(!Object.keys(o.state).includes(e.input.scope))throw new Error(`Invalid scope: ${e.input.scope}`);const n=o.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 o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples=o.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 o=t.specifications[t.specifications.length-1];if(Object.keys(o.state).includes(e.input.scope))o.state[e.input.scope].examples.sort(zt(e.input.order));else throw new Error(`Invalid scope: ${e.input.scope}`)}},At=(t,e)=>{if(s.isBaseAction(e))return t;switch(e.type){case"SET_MODEL_NAME":W().parse(e.input),c.setModelNameOperation(t.global,e);break;case"SET_MODEL_ID":B().parse(e.input),c.setModelIdOperation(t.global,e);break;case"SET_MODEL_EXTENSION":G().parse(e.input),c.setModelExtensionOperation(t.global,e);break;case"SET_MODEL_DESCRIPTION":X().parse(e.input),c.setModelDescriptionOperation(t.global,e);break;case"SET_AUTHOR_NAME":F().parse(e.input),c.setAuthorNameOperation(t.global,e);break;case"SET_AUTHOR_WEBSITE":H().parse(e.input),c.setAuthorWebsiteOperation(t.global,e);break;case"ADD_CHANGE_LOG_ITEM":_().parse(e.input),E.addChangeLogItemOperation(t.global,e);break;case"UPDATE_CHANGE_LOG_ITEM":se().parse(e.input),E.updateChangeLogItemOperation(t.global,e);break;case"DELETE_CHANGE_LOG_ITEM":M().parse(e.input),E.deleteChangeLogItemOperation(t.global,e);break;case"REORDER_CHANGE_LOG_ITEMS":k().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":z().parse(e.input),h.addModuleOperation(t.global,e);break;case"SET_MODULE_NAME":J().parse(e.input),h.setModuleNameOperation(t.global,e);break;case"SET_MODULE_DESCRIPTION":q().parse(e.input),h.setModuleDescriptionOperation(t.global,e);break;case"DELETE_MODULE":x().parse(e.input),h.deleteModuleOperation(t.global,e);break;case"REORDER_MODULES":w().parse(e.input),h.reorderModulesOperation(t.global,e);break;case"ADD_OPERATION_ERROR":A().parse(e.input),l.addOperationErrorOperation(t.global,e);break;case"SET_OPERATION_ERROR_CODE":Q().parse(e.input),l.setOperationErrorCodeOperation(t.global,e);break;case"SET_OPERATION_ERROR_NAME":Z().parse(e.input),l.setOperationErrorNameOperation(t.global,e);break;case"SET_OPERATION_ERROR_DESCRIPTION":Y().parse(e.input),l.setOperationErrorDescriptionOperation(t.global,e);break;case"SET_OPERATION_ERROR_TEMPLATE":ee().parse(e.input),l.setOperationErrorTemplateOperation(t.global,e);break;case"DELETE_OPERATION_ERROR":N().parse(e.input),l.deleteOperationErrorOperation(t.global,e);break;case"REORDER_OPERATION_ERRORS":v().parse(e.input),l.reorderOperationErrorsOperation(t.global,e);break;case"ADD_OPERATION_EXAMPLE":I().parse(e.input),g.addOperationExampleOperation(t.global,e);break;case"UPDATE_OPERATION_EXAMPLE":ae().parse(e.input),g.updateOperationExampleOperation(t.global,e);break;case"DELETE_OPERATION_EXAMPLE":L().parse(e.input),g.deleteOperationExampleOperation(t.global,e);break;case"REORDER_OPERATION_EXAMPLES":U().parse(e.input),g.reorderOperationExamplesOperation(t.global,e);break;case"ADD_OPERATION":T().parse(e.input),p.addOperationOperation(t.global,e);break;case"SET_OPERATION_NAME":te().parse(e.input),p.setOperationNameOperation(t.global,e);break;case"SET_OPERATION_SCOPE":be().parse(e.input),p.setOperationScopeOperation(t.global,e);break;case"SET_OPERATION_SCHEMA":oe().parse(e.input),p.setOperationSchemaOperation(t.global,e);break;case"SET_OPERATION_DESCRIPTION":K().parse(e.input),p.setOperationDescriptionOperation(t.global,e);break;case"SET_OPERATION_TEMPLATE":ne().parse(e.input),p.setOperationTemplateOperation(t.global,e);break;case"SET_OPERATION_REDUCER":re().parse(e.input),p.setOperationReducerOperation(t.global,e);break;case"MOVE_OPERATION":C().parse(e.input),p.moveOperationOperation(t.global,e);break;case"DELETE_OPERATION":j().parse(e.input),p.deleteOperationOperation(t.global,e);break;case"REORDER_MODULE_OPERATIONS":y().parse(e.input),p.reorderModuleOperationsOperation(t.global,e);break;case"SET_STATE_SCHEMA":ie().parse(e.input),d.setStateSchemaOperation(t.global,e);break;case"SET_INITIAL_STATE":$().parse(e.input),d.setInitialStateOperation(t.global,e);break;case"ADD_STATE_EXAMPLE":R().parse(e.input),d.addStateExampleOperation(t.global,e);break;case"UPDATE_STATE_EXAMPLE":pe().parse(e.input),d.updateStateExampleOperation(t.global,e);break;case"DELETE_STATE_EXAMPLE":P().parse(e.input),d.deleteStateExampleOperation(t.global,e);break;case"REORDER_STATE_EXAMPLES":V().parse(e.input),d.reorderStateExamplesOperation(t.global,e);break;default:return t}},m=s.createReducer(At),It={id:"",name:"",extension:"",description:"",author:{name:"",website:""},specifications:[{version:1,changeLog:[],state:{global:{schema:"",initialValue:"",examples:[]},local:{schema:"",initialValue:"",examples:[]}},modules:[]}]},O={fileExtension:"phdm",createState(t){return{global:{...It,...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,o){return s.saveToFile(t,e,"phdm",o)},saveToFileHandle(t,e){return s.saveToFileHandle(t,e)},loadFromFile(t){return s.loadFromFile(t,m)},loadFromInput(t){return s.loadFromInput(t,m)}},ze=t=>s.createAction("SET_MODEL_NAME",{...t}),Ae=t=>s.createAction("SET_MODEL_ID",{...t}),Ie=t=>s.createAction("SET_MODEL_EXTENSION",{...t}),Te=t=>s.createAction("SET_MODEL_DESCRIPTION",{...t}),Re=t=>s.createAction("SET_AUTHOR_NAME",{...t}),De=t=>s.createAction("SET_AUTHOR_WEBSITE",{...t});class Tt extends s.BaseDocument{setModelName(e){return this.dispatch(ze(e))}setModelId(e){return this.dispatch(Ae(e))}setModelExtension(e){return this.dispatch(Ie(e))}setModelDescription(e){return this.dispatch(Te(e))}setAuthorName(e){return this.dispatch(Re(e))}setAuthorWebsite(e){return this.dispatch(De(e))}}const Me=t=>s.createAction("ADD_CHANGE_LOG_ITEM",{...t}),xe=t=>s.createAction("UPDATE_CHANGE_LOG_ITEM",{...t}),Ne=t=>s.createAction("DELETE_CHANGE_LOG_ITEM",{...t}),Le=t=>s.createAction("REORDER_CHANGE_LOG_ITEMS",{...t}),je=()=>s.createAction("RELEASE_NEW_VERSION");class Rt extends s.BaseDocument{addChangeLogItem(e){return this.dispatch(Me(e))}updateChangeLogItem(e){return this.dispatch(xe(e))}deleteChangeLogItem(e){return this.dispatch(Ne(e))}reorderChangeLogItems(e){return this.dispatch(Le(e))}releaseNewVersion(){return this.dispatch(je())}}const Pe=t=>s.createAction("ADD_MODULE",{...t}),Ce=t=>s.createAction("SET_MODULE_NAME",{...t}),ke=t=>s.createAction("SET_MODULE_DESCRIPTION",{...t}),ye=t=>s.createAction("DELETE_MODULE",{...t}),we=t=>s.createAction("REORDER_MODULES",{...t});class Dt extends s.BaseDocument{addModule(e){return this.dispatch(Pe(e))}setModuleName(e){return this.dispatch(Ce(e))}setModuleDescription(e){return this.dispatch(ke(e))}deleteModule(e){return this.dispatch(ye(e))}reorderModules(e){return this.dispatch(we(e))}}const ve=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}),$e=t=>s.createAction("DELETE_OPERATION_ERROR",{...t}),Xe=t=>s.createAction("REORDER_OPERATION_ERRORS",{...t});class Mt extends s.BaseDocument{addOperationError(e){return this.dispatch(ve(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($e(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}),qe=t=>s.createAction("REORDER_OPERATION_EXAMPLES",{...t});class xt 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(qe(e))}}const Je=t=>s.createAction("ADD_OPERATION",{...t}),Ke=t=>s.createAction("SET_OPERATION_NAME",{...t}),Qe=t=>s.createAction("SET_OPERATION_SCOPE",{...t}),Ye=t=>s.createAction("SET_OPERATION_SCHEMA",{...t}),Ze=t=>s.createAction("SET_OPERATION_DESCRIPTION",{...t}),et=t=>s.createAction("SET_OPERATION_TEMPLATE",{...t}),tt=t=>s.createAction("SET_OPERATION_REDUCER",{...t}),rt=t=>s.createAction("MOVE_OPERATION",{...t}),ot=t=>s.createAction("DELETE_OPERATION",{...t}),nt=t=>s.createAction("REORDER_MODULE_OPERATIONS",{...t});class Nt extends s.BaseDocument{addOperation(e){return this.dispatch(Je(e))}setOperationName(e){return this.dispatch(Ke(e))}setOperationScope(e){return this.dispatch(Qe(e))}setOperationSchema(e){return this.dispatch(Ye(e))}setOperationDescription(e){return this.dispatch(Ze(e))}setOperationTemplate(e){return this.dispatch(et(e))}setOperationReducer(e){return this.dispatch(tt(e))}moveOperation(e){return this.dispatch(rt(e))}deleteOperation(e){return this.dispatch(ot(e))}reorderModuleOperations(e){return this.dispatch(nt(e))}}const it=t=>s.createAction("SET_STATE_SCHEMA",{...t}),st=t=>s.createAction("SET_INITIAL_STATE",{...t}),at=t=>s.createAction("ADD_STATE_EXAMPLE",{...t}),pt=t=>s.createAction("UPDATE_STATE_EXAMPLE",{...t}),lt=t=>s.createAction("DELETE_STATE_EXAMPLE",{...t}),ct=t=>s.createAction("REORDER_STATE_EXAMPLES",{...t});class Lt extends s.BaseDocument{setStateSchema(e){return this.dispatch(it(e))}setInitialState(e){return this.dispatch(st(e))}addStateExample(e){return this.dispatch(at(e))}updateStateExample(e){return this.dispatch(pt(e))}deleteStateExample(e){return this.dispatch(lt(e))}reorderStateExamples(e){return this.dispatch(ct(e))}}var u;let S=(u=class extends s.BaseDocument{constructor(e,o){super(m,O.createDocument(e),o)}saveToFile(e,o){return super.saveToFile(e,u.fileExtension,o)}loadFromFile(e){return super.loadFromFile(e)}static async fromFile(e){const o=new this;return await o.loadFromFile(e),o}},ue(u,"fileExtension","phdm"),u);s.applyMixins(S,[Tt,Rt,Dt,Mt,xt,Nt,Lt]);const jt=Object.freeze(Object.defineProperty({__proto__:null,addChangeLogItem:Me,addModule:Pe,addOperation:Je,addOperationError:ve,addOperationExample:Ge,addStateExample:at,deleteChangeLogItem:Ne,deleteModule:ye,deleteOperation:ot,deleteOperationError:$e,deleteOperationExample:We,deleteStateExample:lt,moveOperation:rt,releaseNewVersion:je,reorderChangeLogItems:Le,reorderModuleOperations:nt,reorderModules:we,reorderOperationErrors:Xe,reorderOperationExamples:qe,reorderStateExamples:ct,setAuthorName:Re,setAuthorWebsite:De,setInitialState:st,setModelDescription:Te,setModelExtension:Ie,setModelId:Ae,setModelName:ze,setModuleDescription:ke,setModuleName:Ce,setOperationDescription:Ze,setOperationErrorCode:Ue,setOperationErrorDescription:Fe,setOperationErrorName:Ve,setOperationErrorTemplate:He,setOperationName:Ke,setOperationReducer:tt,setOperationSchema:Ye,setOperationScope:Qe,setOperationTemplate:et,setStateSchema:it,updateChangeLogItem:xe,updateOperationExample:Be,updateStateExample:pt},Symbol.toStringTag,{value:"Module"})),le=S,ce={...O,...Et},de={...s.BaseActions,...jt},dt={Document:le,reducer:m,actions:de,utils:ce,documentModel:f},Pt=Object.freeze(Object.defineProperty({__proto__:null,Document:le,DocumentModel:S,actions:de,documentModel:f,module:dt,reducer:m,utils:ce,z:_e},Symbol.toStringTag,{value:"Module"}));exports.Document=le;exports.DocumentModel=Pt;exports.DocumentModel$1=S;exports.actions=de;exports.documentModel=f;exports.module=dt;exports.reducer=m;exports.utils=ce;exports.zod=_e;
@@ -1 +1 @@
1
- "use strict";const e=require("./object-397a9b23.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-24df9d92.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;