document-model 1.1.0-experimental.4 → 1.1.0-experimental.6

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 (77) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/browser/cjs/document-model.js +21 -1
  3. package/dist/browser/cjs/document-model.js.map +1 -0
  4. package/dist/browser/cjs/document.js +18 -1
  5. package/dist/browser/cjs/document.js.map +1 -0
  6. package/dist/browser/cjs/index.js +18 -1
  7. package/dist/browser/cjs/index.js.map +1 -0
  8. package/dist/browser/cjs/internal/index-NVU298uP.js +49 -0
  9. package/dist/browser/cjs/internal/index-NVU298uP.js.map +1 -0
  10. package/dist/browser/cjs/internal/index-mGRVNAlq.js +2339 -0
  11. package/dist/browser/cjs/internal/index-mGRVNAlq.js.map +1 -0
  12. package/dist/browser/cjs/internal/object-Br60UD-O.js +4345 -0
  13. package/dist/browser/cjs/internal/object-Br60UD-O.js.map +1 -0
  14. package/dist/browser/es/document-model.js +16 -15
  15. package/dist/browser/es/document-model.js.map +1 -0
  16. package/dist/browser/es/document.js +13 -11
  17. package/dist/browser/es/document.js.map +1 -0
  18. package/dist/browser/es/index.js +13 -11
  19. package/dist/browser/es/index.js.map +1 -0
  20. package/dist/browser/es/internal/index-CUIVdtOX.js +2340 -0
  21. package/dist/browser/es/internal/index-CUIVdtOX.js.map +1 -0
  22. package/dist/browser/es/internal/index-DrVs-I4f.js +50 -0
  23. package/dist/browser/es/internal/index-DrVs-I4f.js.map +1 -0
  24. package/dist/browser/es/internal/object-CRn9ifD4.js +4346 -0
  25. package/dist/browser/es/internal/object-CRn9ifD4.js.map +1 -0
  26. package/dist/browser/src/document/object.d.ts +55 -5
  27. package/dist/browser/src/document/reducer.d.ts +13 -0
  28. package/dist/browser/src/document/types.d.ts +4 -0
  29. package/dist/browser/src/document/utils/base.d.ts +2 -1
  30. package/dist/browser/src/document/utils/document-helpers.d.ts +9 -0
  31. package/dist/node/cjs/document-model.js +25 -1
  32. package/dist/node/cjs/document-model.js.map +1 -0
  33. package/dist/node/cjs/document.js +22 -1
  34. package/dist/node/cjs/document.js.map +1 -0
  35. package/dist/node/cjs/index.js +22 -1
  36. package/dist/node/cjs/index.js.map +1 -0
  37. package/dist/node/cjs/internal/index-CUe2eK-w.js +49 -0
  38. package/dist/node/cjs/internal/index-CUe2eK-w.js.map +1 -0
  39. package/dist/node/cjs/internal/index-CXEcxd1A.js +2343 -0
  40. package/dist/node/cjs/internal/index-CXEcxd1A.js.map +1 -0
  41. package/dist/node/cjs/internal/object-BWoRFP9b.js +2347 -0
  42. package/dist/node/cjs/internal/object-BWoRFP9b.js.map +1 -0
  43. package/dist/node/es/document-model.js +15 -14
  44. package/dist/node/es/document-model.js.map +1 -0
  45. package/dist/node/es/document.js +13 -11
  46. package/dist/node/es/document.js.map +1 -0
  47. package/dist/node/es/index.js +13 -11
  48. package/dist/node/es/index.js.map +1 -0
  49. package/dist/node/es/internal/index-BrOKDV9w.js +50 -0
  50. package/dist/node/es/internal/index-BrOKDV9w.js.map +1 -0
  51. package/dist/node/es/internal/index-BzOhAlo9.js +2344 -0
  52. package/dist/node/es/internal/index-BzOhAlo9.js.map +1 -0
  53. package/dist/node/es/internal/object-tOQPLlfl.js +2348 -0
  54. package/dist/node/es/internal/object-tOQPLlfl.js.map +1 -0
  55. package/dist/node/src/document/object.d.ts +55 -5
  56. package/dist/node/src/document/reducer.d.ts +13 -0
  57. package/dist/node/src/document/types.d.ts +4 -0
  58. package/dist/node/src/document/utils/base.d.ts +2 -1
  59. package/dist/node/src/document/utils/document-helpers.d.ts +9 -0
  60. package/dist/src/document/object.d.ts +55 -5
  61. package/dist/src/document/reducer.d.ts +13 -0
  62. package/dist/src/document/types.d.ts +4 -0
  63. package/dist/src/document/utils/base.d.ts +2 -1
  64. package/dist/src/document/utils/document-helpers.d.ts +9 -0
  65. package/package.json +3 -1
  66. package/dist/browser/cjs/internal/index-BLpgsifL.js +0 -1
  67. package/dist/browser/cjs/internal/index-BTG_-qY6.js +0 -22
  68. package/dist/browser/cjs/internal/object-BHB7lY3H.js +0 -25
  69. package/dist/browser/es/internal/index-2Qq00NLA.js +0 -46
  70. package/dist/browser/es/internal/index-BD2hB9El.js +0 -2104
  71. package/dist/browser/es/internal/object-BW-G4r5m.js +0 -2798
  72. package/dist/node/cjs/internal/index-B31DqWHj.js +0 -1
  73. package/dist/node/cjs/internal/index-BBm_wnUa.js +0 -22
  74. package/dist/node/cjs/internal/object-CxVzP-Xe.js +0 -20
  75. package/dist/node/es/internal/index-BPCSW4M1.js +0 -2108
  76. package/dist/node/es/internal/index-C7I4OGkU.js +0 -46
  77. package/dist/node/es/internal/object-C-_SkpQ0.js +0 -1696
@@ -0,0 +1,2344 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ var _a;
8
+ import { c as createReducer, i as isBaseAction, a as createExtendedState, b as createDocument, s as saveToFile, d as saveToFileHandle, l as loadFromFile, e as loadFromInput, f as createAction, B as BaseDocument, g as applyMixins, h as BaseActions } from "./object-tOQPLlfl.js";
9
+ import "immer";
10
+ import "jszip";
11
+ import "crypto";
12
+ import "fs";
13
+ import "https";
14
+ import "path";
15
+ import { z } from "zod";
16
+ const SPLIT_LOWER_UPPER_RE = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
17
+ const SPLIT_UPPER_UPPER_RE = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
18
+ const SPLIT_SEPARATE_NUMBER_RE = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u");
19
+ const DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
20
+ const SPLIT_REPLACE_VALUE = "$1\0$2";
21
+ const DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
22
+ function split(value) {
23
+ let result = value.trim();
24
+ result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
25
+ result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
26
+ let start = 0;
27
+ let end = result.length;
28
+ while (result.charAt(start) === "\0")
29
+ start++;
30
+ if (start === end)
31
+ return [];
32
+ while (result.charAt(end - 1) === "\0")
33
+ end--;
34
+ return result.slice(start, end).split(/\0/g);
35
+ }
36
+ function splitSeparateNumbers(value) {
37
+ const words = split(value);
38
+ for (let i = 0; i < words.length; i++) {
39
+ const word = words[i];
40
+ const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
41
+ if (match) {
42
+ const offset = match.index + (match[1] ?? match[2]).length;
43
+ words.splice(i, 1, word.slice(0, offset), word.slice(offset));
44
+ }
45
+ }
46
+ return words;
47
+ }
48
+ function pascalCase(input, options) {
49
+ const [prefix, words, suffix] = splitPrefixSuffix(input, options);
50
+ const lower = lowerFactory(options == null ? void 0 : options.locale);
51
+ const upper = upperFactory(options == null ? void 0 : options.locale);
52
+ const transform = (options == null ? void 0 : options.mergeAmbiguousCharacters) ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
53
+ return prefix + words.map(transform).join((options == null ? void 0 : options.delimiter) ?? "") + suffix;
54
+ }
55
+ function lowerFactory(locale) {
56
+ return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
57
+ }
58
+ function upperFactory(locale) {
59
+ return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
60
+ }
61
+ function capitalCaseTransformFactory(lower, upper) {
62
+ return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
63
+ }
64
+ function pascalCaseTransformFactory(lower, upper) {
65
+ return (word, index) => {
66
+ const char0 = word[0];
67
+ const initial = index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0);
68
+ return initial + lower(word.slice(1));
69
+ };
70
+ }
71
+ function splitPrefixSuffix(input, options = {}) {
72
+ const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
73
+ const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
74
+ const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
75
+ let prefixIndex = 0;
76
+ let suffixIndex = input.length;
77
+ while (prefixIndex < input.length) {
78
+ const char = input.charAt(prefixIndex);
79
+ if (!prefixCharacters.includes(char))
80
+ break;
81
+ prefixIndex++;
82
+ }
83
+ while (suffixIndex > prefixIndex) {
84
+ const index = suffixIndex - 1;
85
+ const char = input.charAt(index);
86
+ if (!suffixCharacters.includes(char))
87
+ break;
88
+ suffixIndex = index;
89
+ }
90
+ return [
91
+ input.slice(0, prefixIndex),
92
+ splitFn(input.slice(prefixIndex, suffixIndex)),
93
+ input.slice(suffixIndex)
94
+ ];
95
+ }
96
+ function validateInitialState(initialState, allowEmptyState = false) {
97
+ const errors = [];
98
+ if (allowEmptyState && initialState === "")
99
+ return errors;
100
+ try {
101
+ const state = JSON.parse(initialState);
102
+ if (!allowEmptyState && !Object.keys(state).length) {
103
+ errors.push({
104
+ message: "Initial state cannot be empty",
105
+ details: {
106
+ initialState
107
+ }
108
+ });
109
+ }
110
+ } catch {
111
+ errors.push({
112
+ message: "Invalid initial state",
113
+ details: {
114
+ initialState
115
+ }
116
+ });
117
+ }
118
+ return errors;
119
+ }
120
+ function validateStateSchemaName(schema, documentName, scope = "", allowEmptySchema = true) {
121
+ const errors = [];
122
+ if (!allowEmptySchema && !schema) {
123
+ errors.push({
124
+ message: "State schema is required",
125
+ details: {
126
+ schema
127
+ }
128
+ });
129
+ return errors;
130
+ }
131
+ if (allowEmptySchema && !schema)
132
+ return errors;
133
+ const expectedTypeName = `type ${pascalCase(documentName)}${pascalCase(scope)}State`;
134
+ if (!schema.includes(expectedTypeName)) {
135
+ errors.push({
136
+ message: `Invalid state schema name. Expected ${expectedTypeName}`,
137
+ details: {
138
+ schema
139
+ }
140
+ });
141
+ }
142
+ return errors;
143
+ }
144
+ function validateModules(modules) {
145
+ const errors = [];
146
+ if (!modules.length) {
147
+ errors.push({
148
+ message: "Modules are required",
149
+ details: {
150
+ modules
151
+ }
152
+ });
153
+ }
154
+ const modulesError = modules.reduce(
155
+ (acc, mod) => [...acc, ...validateModule(mod)],
156
+ []
157
+ );
158
+ return [...errors, ...modulesError];
159
+ }
160
+ function validateModule(mod) {
161
+ const errors = [];
162
+ if (!mod.name) {
163
+ errors.push({
164
+ message: "Module name is required",
165
+ details: {
166
+ module: mod
167
+ }
168
+ });
169
+ }
170
+ if (!mod.operations.length) {
171
+ errors.push({
172
+ message: "Module operations are required",
173
+ details: {
174
+ module: mod
175
+ }
176
+ });
177
+ }
178
+ const operationErrors = mod.operations.reduce(
179
+ (acc, operation) => [...acc, ...validateModuleOperation(operation)],
180
+ []
181
+ );
182
+ return [...errors, ...operationErrors];
183
+ }
184
+ function validateModuleOperation(operation) {
185
+ const errors = [];
186
+ if (!operation.name) {
187
+ errors.push({
188
+ message: "Operation name is required",
189
+ details: {
190
+ operation
191
+ }
192
+ });
193
+ }
194
+ if (!operation.schema) {
195
+ errors.push({
196
+ message: "Operation schema is required",
197
+ details: {
198
+ operation
199
+ }
200
+ });
201
+ }
202
+ return errors;
203
+ }
204
+ const customUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
205
+ __proto__: null,
206
+ validateInitialState,
207
+ validateModule,
208
+ validateModuleOperation,
209
+ validateModules,
210
+ validateStateSchemaName
211
+ }, Symbol.toStringTag, { value: "Module" }));
212
+ const documentModel = {
213
+ id: "powerhouse/document-model",
214
+ name: "DocumentModel",
215
+ extension: "phdm",
216
+ description: "The Powerhouse Document Model describes the state and operations of a document type.",
217
+ author: {
218
+ name: "Powerhouse",
219
+ website: "https://www.powerhouse.inc/"
220
+ },
221
+ specifications: [
222
+ {
223
+ version: 1,
224
+ changeLog: [],
225
+ modules: [
226
+ {
227
+ name: "header",
228
+ operations: [
229
+ {
230
+ name: "SetModelName",
231
+ id: "",
232
+ description: "",
233
+ schema: "",
234
+ template: "",
235
+ reducer: "",
236
+ examples: [],
237
+ errors: [],
238
+ scope: "global"
239
+ },
240
+ {
241
+ name: "SetModelId",
242
+ id: "",
243
+ description: "",
244
+ schema: "",
245
+ template: "",
246
+ reducer: "",
247
+ examples: [],
248
+ errors: [],
249
+ scope: "global"
250
+ },
251
+ {
252
+ name: "SetModelExtension",
253
+ id: "",
254
+ description: "",
255
+ schema: "",
256
+ template: "",
257
+ reducer: "",
258
+ examples: [],
259
+ errors: [],
260
+ scope: "global"
261
+ },
262
+ {
263
+ name: "SetModelDescription",
264
+ id: "",
265
+ description: "",
266
+ schema: "",
267
+ template: "",
268
+ reducer: "",
269
+ examples: [],
270
+ errors: [],
271
+ scope: "global"
272
+ },
273
+ {
274
+ name: "SetAuthorName",
275
+ id: "",
276
+ description: "",
277
+ schema: "",
278
+ template: "",
279
+ reducer: "",
280
+ examples: [],
281
+ errors: [],
282
+ scope: "global"
283
+ },
284
+ {
285
+ name: "SetAuthorWebsite",
286
+ id: "",
287
+ description: "",
288
+ schema: "",
289
+ template: "",
290
+ reducer: "",
291
+ examples: [],
292
+ errors: [],
293
+ scope: "global"
294
+ }
295
+ ],
296
+ id: "",
297
+ description: ""
298
+ },
299
+ {
300
+ name: "versioning",
301
+ operations: [
302
+ {
303
+ name: "AddChangeLogItem",
304
+ id: "",
305
+ description: "",
306
+ schema: "",
307
+ template: "",
308
+ reducer: "",
309
+ examples: [],
310
+ errors: [],
311
+ scope: "global"
312
+ },
313
+ {
314
+ name: "UpdateChangeLogItem",
315
+ id: "",
316
+ description: "",
317
+ schema: "",
318
+ template: "",
319
+ reducer: "",
320
+ examples: [],
321
+ errors: [],
322
+ scope: "global"
323
+ },
324
+ {
325
+ name: "DeleteChangeLogItem",
326
+ id: "",
327
+ description: "",
328
+ schema: "",
329
+ template: "",
330
+ reducer: "",
331
+ examples: [],
332
+ errors: [],
333
+ scope: "global"
334
+ },
335
+ {
336
+ name: "ReorderChangeLogItems",
337
+ id: "",
338
+ description: "",
339
+ schema: "",
340
+ template: "",
341
+ reducer: "",
342
+ examples: [],
343
+ errors: [],
344
+ scope: "global"
345
+ },
346
+ {
347
+ name: "ReleaseNewVersion",
348
+ schema: null,
349
+ id: "",
350
+ description: "",
351
+ template: "",
352
+ reducer: "",
353
+ examples: [],
354
+ errors: [],
355
+ scope: "global"
356
+ }
357
+ ],
358
+ id: "",
359
+ description: ""
360
+ },
361
+ {
362
+ name: "module",
363
+ operations: [
364
+ {
365
+ name: "AddModule",
366
+ id: "",
367
+ description: "",
368
+ schema: "",
369
+ template: "",
370
+ reducer: "",
371
+ examples: [],
372
+ errors: [],
373
+ scope: "global"
374
+ },
375
+ {
376
+ name: "SetModuleName",
377
+ id: "",
378
+ description: "",
379
+ schema: "",
380
+ template: "",
381
+ reducer: "",
382
+ examples: [],
383
+ errors: [],
384
+ scope: "global"
385
+ },
386
+ {
387
+ name: "SetModuleDescription",
388
+ id: "",
389
+ description: "",
390
+ schema: "",
391
+ template: "",
392
+ reducer: "",
393
+ examples: [],
394
+ errors: [],
395
+ scope: "global"
396
+ },
397
+ {
398
+ name: "DeleteModule",
399
+ id: "",
400
+ description: "",
401
+ schema: "",
402
+ template: "",
403
+ reducer: "",
404
+ examples: [],
405
+ errors: [],
406
+ scope: "global"
407
+ },
408
+ {
409
+ name: "ReorderModules",
410
+ id: "",
411
+ description: "",
412
+ schema: "",
413
+ template: "",
414
+ reducer: "",
415
+ examples: [],
416
+ errors: [],
417
+ scope: "global"
418
+ }
419
+ ],
420
+ id: "",
421
+ description: ""
422
+ },
423
+ {
424
+ name: "operation-error",
425
+ operations: [
426
+ {
427
+ name: "AddOperationError",
428
+ id: "",
429
+ description: "",
430
+ schema: "",
431
+ template: "",
432
+ reducer: "",
433
+ examples: [],
434
+ errors: [],
435
+ scope: "global"
436
+ },
437
+ {
438
+ name: "SetOperationErrorCode",
439
+ id: "",
440
+ description: "",
441
+ schema: "",
442
+ template: "",
443
+ reducer: "",
444
+ examples: [],
445
+ errors: [],
446
+ scope: "global"
447
+ },
448
+ {
449
+ name: "SetOperationErrorName",
450
+ id: "",
451
+ description: "",
452
+ schema: "",
453
+ template: "",
454
+ reducer: "",
455
+ examples: [],
456
+ errors: [],
457
+ scope: "global"
458
+ },
459
+ {
460
+ name: "SetOperationErrorDescription",
461
+ id: "",
462
+ description: "",
463
+ schema: "",
464
+ template: "",
465
+ reducer: "",
466
+ examples: [],
467
+ errors: [],
468
+ scope: "global"
469
+ },
470
+ {
471
+ name: "SetOperationErrorTemplate",
472
+ id: "",
473
+ description: "",
474
+ schema: "",
475
+ template: "",
476
+ reducer: "",
477
+ examples: [],
478
+ errors: [],
479
+ scope: "global"
480
+ },
481
+ {
482
+ name: "DeleteOperationError",
483
+ id: "",
484
+ description: "",
485
+ schema: "",
486
+ template: "",
487
+ reducer: "",
488
+ examples: [],
489
+ errors: [],
490
+ scope: "global"
491
+ },
492
+ {
493
+ name: "ReorderOperationErrors",
494
+ id: "",
495
+ description: "",
496
+ schema: "",
497
+ template: "",
498
+ reducer: "",
499
+ examples: [],
500
+ errors: [],
501
+ scope: "global"
502
+ }
503
+ ],
504
+ id: "",
505
+ description: ""
506
+ },
507
+ {
508
+ name: "operation-example",
509
+ operations: [
510
+ {
511
+ name: "AddOperationExample",
512
+ id: "",
513
+ description: "",
514
+ schema: "",
515
+ template: "",
516
+ reducer: "",
517
+ examples: [],
518
+ errors: [],
519
+ scope: "global"
520
+ },
521
+ {
522
+ name: "UpdateOperationExample",
523
+ id: "",
524
+ description: "",
525
+ schema: "",
526
+ template: "",
527
+ reducer: "",
528
+ examples: [],
529
+ errors: [],
530
+ scope: "global"
531
+ },
532
+ {
533
+ name: "DeleteOperationExample",
534
+ id: "",
535
+ description: "",
536
+ schema: "",
537
+ template: "",
538
+ reducer: "",
539
+ examples: [],
540
+ errors: [],
541
+ scope: "global"
542
+ },
543
+ {
544
+ name: "ReorderOperationExamples",
545
+ id: "",
546
+ description: "",
547
+ schema: "",
548
+ template: "",
549
+ reducer: "",
550
+ examples: [],
551
+ errors: [],
552
+ scope: "global"
553
+ }
554
+ ],
555
+ id: "",
556
+ description: ""
557
+ },
558
+ {
559
+ name: "operation",
560
+ operations: [
561
+ {
562
+ name: "AddOperation",
563
+ id: "",
564
+ description: "",
565
+ schema: "",
566
+ template: "",
567
+ reducer: "",
568
+ examples: [],
569
+ errors: [],
570
+ scope: "global"
571
+ },
572
+ {
573
+ name: "SetOperationName",
574
+ id: "",
575
+ description: "",
576
+ schema: "",
577
+ template: "",
578
+ reducer: "",
579
+ examples: [],
580
+ errors: [],
581
+ scope: "global"
582
+ },
583
+ {
584
+ name: "SetOperationSchema",
585
+ id: "",
586
+ description: "",
587
+ schema: "",
588
+ template: "",
589
+ reducer: "",
590
+ examples: [],
591
+ errors: [],
592
+ scope: "global"
593
+ },
594
+ {
595
+ name: "SetOperationDescription",
596
+ id: "",
597
+ description: "",
598
+ schema: "",
599
+ template: "",
600
+ reducer: "",
601
+ examples: [],
602
+ errors: [],
603
+ scope: "global"
604
+ },
605
+ {
606
+ name: "SetOperationTemplate",
607
+ id: "",
608
+ description: "",
609
+ schema: "",
610
+ template: "",
611
+ reducer: "",
612
+ examples: [],
613
+ errors: [],
614
+ scope: "global"
615
+ },
616
+ {
617
+ name: "SetOperationReducer",
618
+ id: "",
619
+ description: "",
620
+ schema: "",
621
+ template: "",
622
+ reducer: "",
623
+ examples: [],
624
+ errors: [],
625
+ scope: "global"
626
+ },
627
+ {
628
+ name: "MoveOperation",
629
+ id: "",
630
+ description: "",
631
+ schema: "",
632
+ template: "",
633
+ reducer: "",
634
+ examples: [],
635
+ errors: [],
636
+ scope: "global"
637
+ },
638
+ {
639
+ name: "DeleteOperation",
640
+ id: "",
641
+ description: "",
642
+ schema: "",
643
+ template: "",
644
+ reducer: "",
645
+ examples: [],
646
+ errors: [],
647
+ scope: "global"
648
+ },
649
+ {
650
+ name: "ReorderModuleOperations",
651
+ id: "",
652
+ description: "",
653
+ schema: "",
654
+ template: "",
655
+ reducer: "",
656
+ examples: [],
657
+ errors: [],
658
+ scope: "global"
659
+ }
660
+ ],
661
+ id: "",
662
+ description: ""
663
+ },
664
+ {
665
+ name: "state",
666
+ operations: [
667
+ {
668
+ name: "SetStateSchema",
669
+ id: "",
670
+ description: "",
671
+ schema: "",
672
+ template: "",
673
+ reducer: "",
674
+ examples: [],
675
+ errors: [],
676
+ scope: "global"
677
+ },
678
+ {
679
+ name: "SetInitialState",
680
+ id: "",
681
+ description: "",
682
+ schema: "",
683
+ template: "",
684
+ reducer: "",
685
+ examples: [],
686
+ errors: [],
687
+ scope: "global"
688
+ },
689
+ {
690
+ name: "AddStateExample",
691
+ id: "",
692
+ description: "",
693
+ schema: "",
694
+ template: "",
695
+ reducer: "",
696
+ examples: [],
697
+ errors: [],
698
+ scope: "global"
699
+ },
700
+ {
701
+ name: "UpdateStateExample",
702
+ id: "",
703
+ description: "",
704
+ schema: "",
705
+ template: "",
706
+ reducer: "",
707
+ examples: [],
708
+ errors: [],
709
+ scope: "global"
710
+ },
711
+ {
712
+ name: "DeleteStateExample",
713
+ id: "",
714
+ description: "",
715
+ schema: "",
716
+ template: "",
717
+ reducer: "",
718
+ examples: [],
719
+ errors: [],
720
+ scope: "global"
721
+ },
722
+ {
723
+ name: "ReorderStateExamples",
724
+ id: "",
725
+ description: "",
726
+ schema: "",
727
+ template: "",
728
+ reducer: "",
729
+ examples: [],
730
+ errors: [],
731
+ scope: "global"
732
+ }
733
+ ],
734
+ id: "",
735
+ description: ""
736
+ }
737
+ ],
738
+ state: {
739
+ global: {
740
+ schema: "",
741
+ initialValue: '{\n "id": "",\n "name": "",\n "extension": "",\n "description": "",\n "author": {\n "name": "",\n "website": ""\n },\n "specifications": [\n {\n "version": 1,\n "changeLog": [],\n "state": {\n "schema": "",\n "initialValue": "",\n "examples": []\n },\n "modules": []\n }\n ]\n}',
742
+ examples: []
743
+ },
744
+ local: {
745
+ schema: "",
746
+ initialValue: `{}`,
747
+ examples: []
748
+ }
749
+ }
750
+ }
751
+ ]
752
+ };
753
+ const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
754
+ const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
755
+ function AddChangeLogItemInputSchema() {
756
+ return z.object({
757
+ __typename: z.literal("AddChangeLogItemInput").optional(),
758
+ content: z.string(),
759
+ id: z.string(),
760
+ insertBefore: z.string().nullable()
761
+ });
762
+ }
763
+ function AddModuleInputSchema() {
764
+ return z.object({
765
+ description: z.string().nullish(),
766
+ id: z.string(),
767
+ name: z.string()
768
+ });
769
+ }
770
+ function AddOperationErrorInputSchema() {
771
+ return z.object({
772
+ errorCode: z.string().nullish(),
773
+ errorDescription: z.string().nullish(),
774
+ errorName: z.string().nullish(),
775
+ errorTemplate: z.string().nullish(),
776
+ id: z.string(),
777
+ operationId: z.string()
778
+ });
779
+ }
780
+ function AddOperationExampleInputSchema() {
781
+ return z.object({
782
+ example: z.string(),
783
+ id: z.string(),
784
+ operationId: z.string()
785
+ });
786
+ }
787
+ function AddOperationInputSchema() {
788
+ return z.object({
789
+ description: z.string().nullish(),
790
+ id: z.string(),
791
+ moduleId: z.string(),
792
+ name: z.string(),
793
+ reducer: z.string().nullish(),
794
+ schema: z.string().nullish(),
795
+ template: z.string().nullish(),
796
+ scope: OperationScopeSchema().nullish()
797
+ });
798
+ }
799
+ function AddStateExampleInputSchema() {
800
+ return z.object({
801
+ scope: z.string(),
802
+ example: z.string(),
803
+ id: z.string(),
804
+ insertBefore: z.string().nullish()
805
+ });
806
+ }
807
+ function AuthorSchema() {
808
+ return z.object({
809
+ __typename: z.literal("Author").optional(),
810
+ name: z.string(),
811
+ website: z.string().nullable()
812
+ });
813
+ }
814
+ function CodeExampleSchema() {
815
+ return z.object({
816
+ __typename: z.literal("CodeExample").optional(),
817
+ id: z.string(),
818
+ value: z.string()
819
+ });
820
+ }
821
+ function DeleteChangeLogItemInputSchema() {
822
+ return z.object({
823
+ __typename: z.literal("DeleteChangeLogItemInput").optional(),
824
+ id: z.string()
825
+ });
826
+ }
827
+ function DeleteModuleInputSchema() {
828
+ return z.object({
829
+ id: z.string()
830
+ });
831
+ }
832
+ function DeleteOperationErrorInputSchema() {
833
+ return z.object({
834
+ id: z.string()
835
+ });
836
+ }
837
+ function DeleteOperationExampleInputSchema() {
838
+ return z.object({
839
+ id: z.string()
840
+ });
841
+ }
842
+ function DeleteOperationInputSchema() {
843
+ return z.object({
844
+ id: z.string()
845
+ });
846
+ }
847
+ function DeleteStateExampleInputSchema() {
848
+ return z.object({
849
+ scope: z.string(),
850
+ id: z.string()
851
+ });
852
+ }
853
+ function OperationScopeSchema() {
854
+ return z.literal("global").or(z.literal("local"));
855
+ }
856
+ function DocumentModelInputSchema() {
857
+ return z.union([
858
+ AddChangeLogItemInputSchema(),
859
+ AddModuleInputSchema(),
860
+ AddOperationErrorInputSchema(),
861
+ AddOperationExampleInputSchema(),
862
+ AddOperationInputSchema(),
863
+ AddStateExampleInputSchema(),
864
+ DeleteChangeLogItemInputSchema(),
865
+ DeleteModuleInputSchema(),
866
+ DeleteOperationErrorInputSchema(),
867
+ DeleteOperationExampleInputSchema(),
868
+ DeleteOperationInputSchema(),
869
+ DeleteStateExampleInputSchema(),
870
+ MoveOperationInputSchema(),
871
+ ReorderChangeLogItemsInputSchema(),
872
+ ReorderModuleOperationsInputSchema(),
873
+ ReorderModulesInputSchema(),
874
+ ReorderOperationErrorsInputSchema(),
875
+ ReorderOperationExamplesInputSchema(),
876
+ ReorderStateExamplesInputSchema(),
877
+ SetAuthorNameInputSchema(),
878
+ SetAuthorWebsiteInputSchema(),
879
+ SetInitialStateInputSchema(),
880
+ SetModelDescriptionInputSchema(),
881
+ SetModelExtensionInputSchema(),
882
+ SetModelIdInputSchema(),
883
+ SetModelNameInputSchema(),
884
+ SetModuleDescriptionInputSchema(),
885
+ SetModuleNameInputSchema(),
886
+ SetOperationDescriptionInputSchema(),
887
+ SetOperationErrorCodeInputSchema(),
888
+ SetOperationErrorDescriptionInputSchema(),
889
+ SetOperationErrorNameInputSchema(),
890
+ SetOperationErrorTemplateInputSchema(),
891
+ SetOperationNameInputSchema(),
892
+ SetOperationReducerInputSchema(),
893
+ SetOperationSchemaInputSchema(),
894
+ SetOperationTemplateInputSchema(),
895
+ SetStateSchemaInputSchema(),
896
+ UpdateChangeLogItemInputSchema(),
897
+ UpdateOperationExampleInputSchema(),
898
+ UpdateStateExampleInputSchema()
899
+ ]);
900
+ }
901
+ function DocumentModelStateSchema() {
902
+ return z.object({
903
+ __typename: z.literal("DocumentModelState").optional(),
904
+ author: AuthorSchema(),
905
+ description: z.string(),
906
+ extension: z.string(),
907
+ id: z.string(),
908
+ name: z.string(),
909
+ specifications: z.array(DocumentSpecificationSchema())
910
+ });
911
+ }
912
+ function DocumentSpecificationSchema() {
913
+ return z.object({
914
+ __typename: z.literal("DocumentSpecification").optional(),
915
+ changeLog: z.array(z.string()),
916
+ modules: z.array(ModuleSchema()),
917
+ state: ScopeStateSchema(),
918
+ version: z.number()
919
+ });
920
+ }
921
+ function ModuleSchema() {
922
+ return z.object({
923
+ __typename: z.literal("Module").optional(),
924
+ description: z.string().nullable(),
925
+ id: z.string(),
926
+ name: z.string(),
927
+ operations: z.array(OperationSchema())
928
+ });
929
+ }
930
+ function MoveOperationInputSchema() {
931
+ return z.object({
932
+ newModuleId: z.string(),
933
+ operationId: z.string()
934
+ });
935
+ }
936
+ function OperationSchema() {
937
+ return z.object({
938
+ __typename: z.literal("Operation").optional(),
939
+ description: z.string().nullable(),
940
+ errors: z.array(OperationErrorSchema()),
941
+ examples: z.array(CodeExampleSchema()),
942
+ id: z.string(),
943
+ name: z.string().nullable(),
944
+ reducer: z.string().nullable(),
945
+ schema: z.string().nullable(),
946
+ template: z.string().nullable(),
947
+ scope: OperationScopeSchema()
948
+ });
949
+ }
950
+ function OperationErrorSchema() {
951
+ return z.object({
952
+ __typename: z.literal("OperationError").optional(),
953
+ code: z.string().nullable(),
954
+ description: z.string().nullable(),
955
+ id: z.string(),
956
+ name: z.string().nullable(),
957
+ template: z.string().nullable()
958
+ });
959
+ }
960
+ function ReorderChangeLogItemsInputSchema() {
961
+ return z.object({
962
+ __typename: z.literal("ReorderChangeLogItemsInput").optional(),
963
+ order: z.array(z.string())
964
+ });
965
+ }
966
+ function ReorderModuleOperationsInputSchema() {
967
+ return z.object({
968
+ moduleId: z.string(),
969
+ order: z.array(z.string())
970
+ });
971
+ }
972
+ function ReorderModulesInputSchema() {
973
+ return z.object({
974
+ order: z.array(z.string())
975
+ });
976
+ }
977
+ function ReorderOperationErrorsInputSchema() {
978
+ return z.object({
979
+ operationId: z.string(),
980
+ order: z.array(z.string())
981
+ });
982
+ }
983
+ function ReorderOperationExamplesInputSchema() {
984
+ return z.object({
985
+ operationId: z.string(),
986
+ order: z.array(z.string())
987
+ });
988
+ }
989
+ function ReorderStateExamplesInputSchema() {
990
+ return z.object({
991
+ scope: z.string(),
992
+ order: z.array(z.string())
993
+ });
994
+ }
995
+ function SetAuthorNameInputSchema() {
996
+ return z.object({
997
+ authorName: z.string()
998
+ });
999
+ }
1000
+ function SetAuthorWebsiteInputSchema() {
1001
+ return z.object({
1002
+ authorWebsite: z.string()
1003
+ });
1004
+ }
1005
+ function SetInitialStateInputSchema() {
1006
+ return z.object({
1007
+ scope: z.string(),
1008
+ initialValue: z.string()
1009
+ });
1010
+ }
1011
+ function SetModelDescriptionInputSchema() {
1012
+ return z.object({
1013
+ description: z.string()
1014
+ });
1015
+ }
1016
+ function SetModelExtensionInputSchema() {
1017
+ return z.object({
1018
+ extension: z.string()
1019
+ });
1020
+ }
1021
+ function SetModelIdInputSchema() {
1022
+ return z.object({
1023
+ id: z.string()
1024
+ });
1025
+ }
1026
+ function SetModelNameInputSchema() {
1027
+ return z.object({
1028
+ name: z.string()
1029
+ });
1030
+ }
1031
+ function SetModuleDescriptionInputSchema() {
1032
+ return z.object({
1033
+ description: z.string().nullish(),
1034
+ id: z.string()
1035
+ });
1036
+ }
1037
+ function SetModuleNameInputSchema() {
1038
+ return z.object({
1039
+ id: z.string(),
1040
+ name: z.string().nullish()
1041
+ });
1042
+ }
1043
+ function SetOperationDescriptionInputSchema() {
1044
+ return z.object({
1045
+ description: z.string().nullish(),
1046
+ id: z.string()
1047
+ });
1048
+ }
1049
+ function SetOperationErrorCodeInputSchema() {
1050
+ return z.object({
1051
+ errorCode: z.string().nullish(),
1052
+ id: z.string()
1053
+ });
1054
+ }
1055
+ function SetOperationErrorDescriptionInputSchema() {
1056
+ return z.object({
1057
+ errorDescription: z.string().nullish(),
1058
+ id: z.string()
1059
+ });
1060
+ }
1061
+ function SetOperationErrorNameInputSchema() {
1062
+ return z.object({
1063
+ errorName: z.string().nullish(),
1064
+ id: z.string()
1065
+ });
1066
+ }
1067
+ function SetOperationErrorTemplateInputSchema() {
1068
+ return z.object({
1069
+ errorTemplate: z.string().nullish(),
1070
+ id: z.string()
1071
+ });
1072
+ }
1073
+ function SetOperationNameInputSchema() {
1074
+ return z.object({
1075
+ id: z.string(),
1076
+ name: z.string().nullish()
1077
+ });
1078
+ }
1079
+ function SetOperationScopeInputSchema() {
1080
+ return z.object({
1081
+ id: z.string(),
1082
+ scope: OperationScopeSchema()
1083
+ });
1084
+ }
1085
+ function SetOperationReducerInputSchema() {
1086
+ return z.object({
1087
+ id: z.string(),
1088
+ reducer: z.string().nullish()
1089
+ });
1090
+ }
1091
+ function SetOperationSchemaInputSchema() {
1092
+ return z.object({
1093
+ id: z.string(),
1094
+ schema: z.string().nullish()
1095
+ });
1096
+ }
1097
+ function SetOperationTemplateInputSchema() {
1098
+ return z.object({
1099
+ id: z.string(),
1100
+ template: z.string().nullish()
1101
+ });
1102
+ }
1103
+ function SetStateSchemaInputSchema() {
1104
+ return z.object({
1105
+ scope: z.string(),
1106
+ schema: z.string()
1107
+ });
1108
+ }
1109
+ function StateSchema() {
1110
+ return z.object({
1111
+ __typename: z.literal("State").optional(),
1112
+ examples: z.array(CodeExampleSchema()),
1113
+ initialValue: z.string(),
1114
+ schema: z.string()
1115
+ });
1116
+ }
1117
+ function ScopeStateSchema() {
1118
+ return z.object({
1119
+ global: StateSchema(),
1120
+ local: StateSchema()
1121
+ });
1122
+ }
1123
+ function UpdateChangeLogItemInputSchema() {
1124
+ return z.object({
1125
+ __typename: z.literal("UpdateChangeLogItemInput").optional(),
1126
+ id: z.string(),
1127
+ newContent: z.string()
1128
+ });
1129
+ }
1130
+ function UpdateOperationExampleInputSchema() {
1131
+ return z.object({
1132
+ example: z.string(),
1133
+ id: z.string()
1134
+ });
1135
+ }
1136
+ function UpdateStateExampleInputSchema() {
1137
+ return z.object({
1138
+ scope: z.string(),
1139
+ id: z.string(),
1140
+ newExample: z.string()
1141
+ });
1142
+ }
1143
+ const zod = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1144
+ __proto__: null,
1145
+ AddChangeLogItemInputSchema,
1146
+ AddModuleInputSchema,
1147
+ AddOperationErrorInputSchema,
1148
+ AddOperationExampleInputSchema,
1149
+ AddOperationInputSchema,
1150
+ AddStateExampleInputSchema,
1151
+ AuthorSchema,
1152
+ CodeExampleSchema,
1153
+ DeleteChangeLogItemInputSchema,
1154
+ DeleteModuleInputSchema,
1155
+ DeleteOperationErrorInputSchema,
1156
+ DeleteOperationExampleInputSchema,
1157
+ DeleteOperationInputSchema,
1158
+ DeleteStateExampleInputSchema,
1159
+ DocumentModelInputSchema,
1160
+ DocumentModelStateSchema,
1161
+ DocumentSpecificationSchema,
1162
+ ModuleSchema,
1163
+ MoveOperationInputSchema,
1164
+ OperationErrorSchema,
1165
+ OperationSchema,
1166
+ OperationScopeSchema,
1167
+ ReorderChangeLogItemsInputSchema,
1168
+ ReorderModuleOperationsInputSchema,
1169
+ ReorderModulesInputSchema,
1170
+ ReorderOperationErrorsInputSchema,
1171
+ ReorderOperationExamplesInputSchema,
1172
+ ReorderStateExamplesInputSchema,
1173
+ ScopeStateSchema,
1174
+ SetAuthorNameInputSchema,
1175
+ SetAuthorWebsiteInputSchema,
1176
+ SetInitialStateInputSchema,
1177
+ SetModelDescriptionInputSchema,
1178
+ SetModelExtensionInputSchema,
1179
+ SetModelIdInputSchema,
1180
+ SetModelNameInputSchema,
1181
+ SetModuleDescriptionInputSchema,
1182
+ SetModuleNameInputSchema,
1183
+ SetOperationDescriptionInputSchema,
1184
+ SetOperationErrorCodeInputSchema,
1185
+ SetOperationErrorDescriptionInputSchema,
1186
+ SetOperationErrorNameInputSchema,
1187
+ SetOperationErrorTemplateInputSchema,
1188
+ SetOperationNameInputSchema,
1189
+ SetOperationReducerInputSchema,
1190
+ SetOperationSchemaInputSchema,
1191
+ SetOperationScopeInputSchema,
1192
+ SetOperationTemplateInputSchema,
1193
+ SetStateSchemaInputSchema,
1194
+ StateSchema,
1195
+ UpdateChangeLogItemInputSchema,
1196
+ UpdateOperationExampleInputSchema,
1197
+ UpdateStateExampleInputSchema,
1198
+ definedNonNullAnySchema,
1199
+ isDefinedNonNullAny
1200
+ }, Symbol.toStringTag, { value: "Module" }));
1201
+ const reducer$7 = {
1202
+ setModelNameOperation(state, action) {
1203
+ state.name = action.input.name;
1204
+ },
1205
+ setModelIdOperation(state, action) {
1206
+ state.id = action.input.id;
1207
+ },
1208
+ setModelExtensionOperation(state, action) {
1209
+ state.extension = action.input.extension;
1210
+ },
1211
+ setModelDescriptionOperation(state, action) {
1212
+ state.description = action.input.description;
1213
+ },
1214
+ setAuthorNameOperation(state, action) {
1215
+ state.author = state.author || { name: "", website: null };
1216
+ state.author.name = action.input.authorName;
1217
+ },
1218
+ setAuthorWebsiteOperation(state, action) {
1219
+ state.author = state.author || { name: "", website: null };
1220
+ state.author.website = action.input.authorWebsite;
1221
+ }
1222
+ };
1223
+ const reducer$6 = {
1224
+ addChangeLogItemOperation(state, action) {
1225
+ throw new Error(
1226
+ 'Reducer "addChangeLogItemOperation" not yet implemented'
1227
+ );
1228
+ },
1229
+ updateChangeLogItemOperation(state, action) {
1230
+ throw new Error(
1231
+ 'Reducer "updateChangeLogItemOperation" not yet implemented'
1232
+ );
1233
+ },
1234
+ deleteChangeLogItemOperation(state, action) {
1235
+ throw new Error(
1236
+ 'Reducer "deleteChangeLogItemOperation" not yet implemented'
1237
+ );
1238
+ },
1239
+ reorderChangeLogItemsOperation(state, action) {
1240
+ throw new Error(
1241
+ 'Reducer "reorderChangeLogItemsOperation" not yet implemented'
1242
+ );
1243
+ },
1244
+ releaseNewVersionOperation(state, action) {
1245
+ throw new Error(
1246
+ 'Reducer "releaseNewVersionOperation" not yet implemented'
1247
+ );
1248
+ }
1249
+ };
1250
+ const moduleSorter = (order) => {
1251
+ const mapping = {};
1252
+ order.forEach((key, index) => mapping[key] = index);
1253
+ return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
1254
+ };
1255
+ const reducer$5 = {
1256
+ addModuleOperation(state, action) {
1257
+ const latestSpec = state.specifications[state.specifications.length - 1];
1258
+ latestSpec.modules.push({
1259
+ id: action.input.id,
1260
+ name: action.input.name,
1261
+ description: action.input.description || "",
1262
+ operations: []
1263
+ });
1264
+ },
1265
+ setModuleNameOperation(state, action) {
1266
+ const latestSpec = state.specifications[state.specifications.length - 1];
1267
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1268
+ if (latestSpec.modules[i].id === action.input.id) {
1269
+ latestSpec.modules[i].name = action.input.name || "";
1270
+ }
1271
+ }
1272
+ },
1273
+ setModuleDescriptionOperation(state, action) {
1274
+ const latestSpec = state.specifications[state.specifications.length - 1];
1275
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1276
+ if (latestSpec.modules[i].id === action.input.id) {
1277
+ latestSpec.modules[i].description = action.input.description || "";
1278
+ }
1279
+ }
1280
+ },
1281
+ deleteModuleOperation(state, action) {
1282
+ const latestSpec = state.specifications[state.specifications.length - 1];
1283
+ latestSpec.modules = latestSpec.modules.filter(
1284
+ (m) => m.id != action.input.id
1285
+ );
1286
+ },
1287
+ reorderModulesOperation(state, action) {
1288
+ const latestSpec = state.specifications[state.specifications.length - 1];
1289
+ latestSpec.modules.sort(moduleSorter(action.input.order));
1290
+ }
1291
+ };
1292
+ const errorSorter = (order) => {
1293
+ const mapping = {};
1294
+ order.forEach((key, index) => mapping[key] = index);
1295
+ return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
1296
+ };
1297
+ const reducer$4 = {
1298
+ addOperationErrorOperation(state, action) {
1299
+ const latestSpec = state.specifications[state.specifications.length - 1];
1300
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1301
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1302
+ if (latestSpec.modules[i].operations[j].id == action.input.operationId) {
1303
+ latestSpec.modules[i].operations[j].errors.push({
1304
+ id: action.input.id,
1305
+ name: action.input.errorName || "",
1306
+ code: action.input.errorCode || "",
1307
+ description: action.input.errorDescription || "",
1308
+ template: action.input.errorTemplate || ""
1309
+ });
1310
+ }
1311
+ }
1312
+ }
1313
+ },
1314
+ setOperationErrorCodeOperation(state, action) {
1315
+ const latestSpec = state.specifications[state.specifications.length - 1];
1316
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1317
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1318
+ for (let k = 0; k < latestSpec.modules[i].operations[j].errors.length; k++) {
1319
+ if (latestSpec.modules[i].operations[j].errors[k].id == action.input.id) {
1320
+ latestSpec.modules[i].operations[j].errors[k].code = action.input.errorCode || "";
1321
+ }
1322
+ }
1323
+ }
1324
+ }
1325
+ },
1326
+ setOperationErrorNameOperation(state, action) {
1327
+ const latestSpec = state.specifications[state.specifications.length - 1];
1328
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1329
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1330
+ for (let k = 0; k < latestSpec.modules[i].operations[j].errors.length; k++) {
1331
+ if (latestSpec.modules[i].operations[j].errors[k].id == action.input.id) {
1332
+ latestSpec.modules[i].operations[j].errors[k].name = action.input.errorName || "";
1333
+ }
1334
+ }
1335
+ }
1336
+ }
1337
+ },
1338
+ setOperationErrorDescriptionOperation(state, action) {
1339
+ const latestSpec = state.specifications[state.specifications.length - 1];
1340
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1341
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1342
+ for (let k = 0; k < latestSpec.modules[i].operations[j].errors.length; k++) {
1343
+ if (latestSpec.modules[i].operations[j].errors[k].id == action.input.id) {
1344
+ latestSpec.modules[i].operations[j].errors[k].description = action.input.errorDescription || "";
1345
+ }
1346
+ }
1347
+ }
1348
+ }
1349
+ },
1350
+ setOperationErrorTemplateOperation(state, action) {
1351
+ const latestSpec = state.specifications[state.specifications.length - 1];
1352
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1353
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1354
+ for (let k = 0; k < latestSpec.modules[i].operations[j].errors.length; k++) {
1355
+ if (latestSpec.modules[i].operations[j].errors[k].id == action.input.id) {
1356
+ latestSpec.modules[i].operations[j].errors[k].template = action.input.errorTemplate || "";
1357
+ }
1358
+ }
1359
+ }
1360
+ }
1361
+ },
1362
+ deleteOperationErrorOperation(state, action) {
1363
+ const latestSpec = state.specifications[state.specifications.length - 1];
1364
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1365
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1366
+ latestSpec.modules[i].operations[j].errors = latestSpec.modules[i].operations[j].errors.filter((e) => e.id != action.input.id);
1367
+ }
1368
+ }
1369
+ },
1370
+ reorderOperationErrorsOperation(state, action) {
1371
+ const latestSpec = state.specifications[state.specifications.length - 1];
1372
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1373
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1374
+ if (latestSpec.modules[i].operations[j].id == action.input.operationId) {
1375
+ latestSpec.modules[i].operations[j].errors.sort(
1376
+ errorSorter(action.input.order)
1377
+ );
1378
+ }
1379
+ }
1380
+ }
1381
+ }
1382
+ };
1383
+ const exampleSorter$1 = (order) => {
1384
+ const mapping = {};
1385
+ order.forEach((key, index) => mapping[key] = index);
1386
+ return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
1387
+ };
1388
+ const reducer$3 = {
1389
+ addOperationExampleOperation(state, action) {
1390
+ const latestSpec = state.specifications[state.specifications.length - 1];
1391
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1392
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1393
+ if (latestSpec.modules[i].operations[j].id == action.input.operationId) {
1394
+ latestSpec.modules[i].operations[j].examples.push({
1395
+ id: action.input.id,
1396
+ value: action.input.example
1397
+ });
1398
+ }
1399
+ }
1400
+ }
1401
+ },
1402
+ updateOperationExampleOperation(state, action) {
1403
+ const latestSpec = state.specifications[state.specifications.length - 1];
1404
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1405
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1406
+ for (let k = 0; k < latestSpec.modules[i].operations[j].examples.length; k++) {
1407
+ if (latestSpec.modules[i].operations[j].examples[k].id == action.input.id) {
1408
+ latestSpec.modules[i].operations[j].examples[k].value = action.input.example;
1409
+ }
1410
+ }
1411
+ }
1412
+ }
1413
+ },
1414
+ deleteOperationExampleOperation(state, action) {
1415
+ const latestSpec = state.specifications[state.specifications.length - 1];
1416
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1417
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1418
+ latestSpec.modules[i].operations[j].examples = latestSpec.modules[i].operations[j].examples.filter(
1419
+ (e) => e.id != action.input.id
1420
+ );
1421
+ }
1422
+ }
1423
+ },
1424
+ reorderOperationExamplesOperation(state, action) {
1425
+ const latestSpec = state.specifications[state.specifications.length - 1];
1426
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1427
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1428
+ if (latestSpec.modules[i].operations[j].id == action.input.operationId) {
1429
+ latestSpec.modules[i].operations[j].examples.sort(
1430
+ exampleSorter$1(action.input.order)
1431
+ );
1432
+ }
1433
+ }
1434
+ }
1435
+ }
1436
+ };
1437
+ const operationSorter = (order) => {
1438
+ const mapping = {};
1439
+ order.forEach((key, index) => mapping[key] = index);
1440
+ return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
1441
+ };
1442
+ const reducer$2 = {
1443
+ addOperationOperation(state, action) {
1444
+ const latestSpec = state.specifications[state.specifications.length - 1];
1445
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1446
+ if (latestSpec.modules[i].id == action.input.moduleId) {
1447
+ latestSpec.modules[i].operations.push({
1448
+ id: action.input.id,
1449
+ name: action.input.name,
1450
+ description: action.input.description || "",
1451
+ schema: action.input.schema || "",
1452
+ template: action.input.template || action.input.description || "",
1453
+ reducer: action.input.reducer || "",
1454
+ errors: [],
1455
+ examples: [],
1456
+ scope: action.input.scope || "global"
1457
+ });
1458
+ }
1459
+ }
1460
+ },
1461
+ setOperationNameOperation(state, action) {
1462
+ const latestSpec = state.specifications[state.specifications.length - 1];
1463
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1464
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1465
+ if (latestSpec.modules[i].operations[j].id == action.input.id) {
1466
+ latestSpec.modules[i].operations[j].name = action.input.name || "";
1467
+ }
1468
+ }
1469
+ }
1470
+ },
1471
+ setOperationScopeOperation(state, action) {
1472
+ const latestSpec = state.specifications[state.specifications.length - 1];
1473
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1474
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1475
+ if (latestSpec.modules[i].operations[j].id == action.input.id) {
1476
+ latestSpec.modules[i].operations[j].scope = action.input.scope || "global";
1477
+ }
1478
+ }
1479
+ }
1480
+ },
1481
+ setOperationSchemaOperation(state, action) {
1482
+ const latestSpec = state.specifications[state.specifications.length - 1];
1483
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1484
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1485
+ if (latestSpec.modules[i].operations[j].id == action.input.id) {
1486
+ latestSpec.modules[i].operations[j].schema = action.input.schema || "";
1487
+ }
1488
+ }
1489
+ }
1490
+ },
1491
+ setOperationDescriptionOperation(state, action) {
1492
+ const latestSpec = state.specifications[state.specifications.length - 1];
1493
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1494
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1495
+ if (latestSpec.modules[i].operations[j].id == action.input.id) {
1496
+ latestSpec.modules[i].operations[j].description = action.input.description || "";
1497
+ }
1498
+ }
1499
+ }
1500
+ },
1501
+ setOperationTemplateOperation(state, action) {
1502
+ const latestSpec = state.specifications[state.specifications.length - 1];
1503
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1504
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1505
+ if (latestSpec.modules[i].operations[j].id == action.input.id) {
1506
+ latestSpec.modules[i].operations[j].template = action.input.template || "";
1507
+ }
1508
+ }
1509
+ }
1510
+ },
1511
+ setOperationReducerOperation(state, action) {
1512
+ const latestSpec = state.specifications[state.specifications.length - 1];
1513
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1514
+ for (let j = 0; j < latestSpec.modules[i].operations.length; j++) {
1515
+ if (latestSpec.modules[i].operations[j].id == action.input.id) {
1516
+ latestSpec.modules[i].operations[j].reducer = action.input.reducer || "";
1517
+ }
1518
+ }
1519
+ }
1520
+ },
1521
+ moveOperationOperation(state, action) {
1522
+ const moveOperations = [];
1523
+ const latestSpec = state.specifications[state.specifications.length - 1];
1524
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1525
+ latestSpec.modules[i].operations = latestSpec.modules[i].operations.filter((operation) => {
1526
+ if (operation.id == action.input.operationId) {
1527
+ moveOperations.push(operation);
1528
+ return false;
1529
+ }
1530
+ return true;
1531
+ });
1532
+ }
1533
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1534
+ if (latestSpec.modules[i].id == action.input.newModuleId) {
1535
+ latestSpec.modules[i].operations.push(...moveOperations);
1536
+ }
1537
+ }
1538
+ },
1539
+ deleteOperationOperation(state, action) {
1540
+ const latestSpec = state.specifications[state.specifications.length - 1];
1541
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1542
+ latestSpec.modules[i].operations = latestSpec.modules[i].operations.filter((operation) => operation.id != action.input.id);
1543
+ }
1544
+ },
1545
+ reorderModuleOperationsOperation(state, action) {
1546
+ const latestSpec = state.specifications[state.specifications.length - 1];
1547
+ for (let i = 0; i < latestSpec.modules.length; i++) {
1548
+ if (latestSpec.modules[i].id == action.input.moduleId) {
1549
+ latestSpec.modules[i].operations.sort(
1550
+ operationSorter(action.input.order)
1551
+ );
1552
+ }
1553
+ }
1554
+ }
1555
+ };
1556
+ const exampleSorter = (order) => {
1557
+ const mapping = {};
1558
+ order.forEach((key, index) => mapping[key] = index);
1559
+ return (a, b) => (mapping[b.id] || 999999) - (mapping[a.id] || 999999);
1560
+ };
1561
+ const reducer$1 = {
1562
+ setStateSchemaOperation(state, action) {
1563
+ const latestSpec = state.specifications[state.specifications.length - 1];
1564
+ if (Object.keys(latestSpec.state).includes(action.input.scope)) {
1565
+ latestSpec.state[action.input.scope].schema = action.input.schema;
1566
+ } else {
1567
+ throw new Error(`Invalid scope: ${action.input.scope}`);
1568
+ }
1569
+ },
1570
+ setInitialStateOperation(state, action) {
1571
+ const latestSpec = state.specifications[state.specifications.length - 1];
1572
+ if (Object.keys(latestSpec.state).includes(action.input.scope)) {
1573
+ latestSpec.state[action.input.scope].initialValue = action.input.initialValue;
1574
+ } else {
1575
+ throw new Error(`Invalid scope: ${action.input.scope}`);
1576
+ }
1577
+ },
1578
+ addStateExampleOperation(state, action) {
1579
+ const latestSpec = state.specifications[state.specifications.length - 1];
1580
+ if (Object.keys(latestSpec.state).includes(action.input.scope)) {
1581
+ latestSpec.state[action.input.scope].examples.push({
1582
+ id: action.input.id,
1583
+ value: action.input.example
1584
+ });
1585
+ } else {
1586
+ throw new Error(`Invalid scope: ${action.input.scope}`);
1587
+ }
1588
+ },
1589
+ updateStateExampleOperation(state, action) {
1590
+ const latestSpec = state.specifications[state.specifications.length - 1];
1591
+ if (!Object.keys(latestSpec.state).includes(action.input.scope)) {
1592
+ throw new Error(`Invalid scope: ${action.input.scope}`);
1593
+ }
1594
+ const examples = latestSpec.state[action.input.scope].examples;
1595
+ for (let i = 0; i < examples.length; i++) {
1596
+ if (examples[i].id == action.input.id) {
1597
+ examples[i].value = action.input.newExample;
1598
+ }
1599
+ }
1600
+ },
1601
+ deleteStateExampleOperation(state, action) {
1602
+ const latestSpec = state.specifications[state.specifications.length - 1];
1603
+ if (Object.keys(latestSpec.state).includes(action.input.scope)) {
1604
+ latestSpec.state[action.input.scope].examples = latestSpec.state[action.input.scope].examples.filter((e) => e.id != action.input.id);
1605
+ } else {
1606
+ throw new Error(`Invalid scope: ${action.input.scope}`);
1607
+ }
1608
+ },
1609
+ reorderStateExamplesOperation(state, action) {
1610
+ const latestSpec = state.specifications[state.specifications.length - 1];
1611
+ if (Object.keys(latestSpec.state).includes(action.input.scope)) {
1612
+ latestSpec.state[action.input.scope].examples.sort(exampleSorter(action.input.order));
1613
+ } else {
1614
+ throw new Error(`Invalid scope: ${action.input.scope}`);
1615
+ }
1616
+ }
1617
+ };
1618
+ const stateReducer = (state, action) => {
1619
+ if (isBaseAction(action)) {
1620
+ return state;
1621
+ }
1622
+ switch (action.type) {
1623
+ case "SET_MODEL_NAME":
1624
+ SetModelNameInputSchema().parse(action.input);
1625
+ reducer$7.setModelNameOperation(state.global, action);
1626
+ break;
1627
+ case "SET_MODEL_ID":
1628
+ SetModelIdInputSchema().parse(action.input);
1629
+ reducer$7.setModelIdOperation(state.global, action);
1630
+ break;
1631
+ case "SET_MODEL_EXTENSION":
1632
+ SetModelExtensionInputSchema().parse(action.input);
1633
+ reducer$7.setModelExtensionOperation(state.global, action);
1634
+ break;
1635
+ case "SET_MODEL_DESCRIPTION":
1636
+ SetModelDescriptionInputSchema().parse(action.input);
1637
+ reducer$7.setModelDescriptionOperation(state.global, action);
1638
+ break;
1639
+ case "SET_AUTHOR_NAME":
1640
+ SetAuthorNameInputSchema().parse(action.input);
1641
+ reducer$7.setAuthorNameOperation(state.global, action);
1642
+ break;
1643
+ case "SET_AUTHOR_WEBSITE":
1644
+ SetAuthorWebsiteInputSchema().parse(action.input);
1645
+ reducer$7.setAuthorWebsiteOperation(state.global, action);
1646
+ break;
1647
+ case "ADD_CHANGE_LOG_ITEM":
1648
+ AddChangeLogItemInputSchema().parse(action.input);
1649
+ reducer$6.addChangeLogItemOperation(state.global, action);
1650
+ break;
1651
+ case "UPDATE_CHANGE_LOG_ITEM":
1652
+ UpdateChangeLogItemInputSchema().parse(action.input);
1653
+ reducer$6.updateChangeLogItemOperation(
1654
+ state.global,
1655
+ action
1656
+ );
1657
+ break;
1658
+ case "DELETE_CHANGE_LOG_ITEM":
1659
+ DeleteChangeLogItemInputSchema().parse(action.input);
1660
+ reducer$6.deleteChangeLogItemOperation(
1661
+ state.global,
1662
+ action
1663
+ );
1664
+ break;
1665
+ case "REORDER_CHANGE_LOG_ITEMS":
1666
+ ReorderChangeLogItemsInputSchema().parse(action.input);
1667
+ reducer$6.reorderChangeLogItemsOperation(
1668
+ state.global,
1669
+ action
1670
+ );
1671
+ break;
1672
+ case "RELEASE_NEW_VERSION":
1673
+ if (Object.keys(action.input).length > 0)
1674
+ throw new Error(
1675
+ "Expected empty input for action RELEASE_NEW_VERSION"
1676
+ );
1677
+ reducer$6.releaseNewVersionOperation(state.global, action);
1678
+ break;
1679
+ case "ADD_MODULE":
1680
+ AddModuleInputSchema().parse(action.input);
1681
+ reducer$5.addModuleOperation(state.global, action);
1682
+ break;
1683
+ case "SET_MODULE_NAME":
1684
+ SetModuleNameInputSchema().parse(action.input);
1685
+ reducer$5.setModuleNameOperation(state.global, action);
1686
+ break;
1687
+ case "SET_MODULE_DESCRIPTION":
1688
+ SetModuleDescriptionInputSchema().parse(action.input);
1689
+ reducer$5.setModuleDescriptionOperation(state.global, action);
1690
+ break;
1691
+ case "DELETE_MODULE":
1692
+ DeleteModuleInputSchema().parse(action.input);
1693
+ reducer$5.deleteModuleOperation(state.global, action);
1694
+ break;
1695
+ case "REORDER_MODULES":
1696
+ ReorderModulesInputSchema().parse(action.input);
1697
+ reducer$5.reorderModulesOperation(state.global, action);
1698
+ break;
1699
+ case "ADD_OPERATION_ERROR":
1700
+ AddOperationErrorInputSchema().parse(action.input);
1701
+ reducer$4.addOperationErrorOperation(
1702
+ state.global,
1703
+ action
1704
+ );
1705
+ break;
1706
+ case "SET_OPERATION_ERROR_CODE":
1707
+ SetOperationErrorCodeInputSchema().parse(action.input);
1708
+ reducer$4.setOperationErrorCodeOperation(
1709
+ state.global,
1710
+ action
1711
+ );
1712
+ break;
1713
+ case "SET_OPERATION_ERROR_NAME":
1714
+ SetOperationErrorNameInputSchema().parse(action.input);
1715
+ reducer$4.setOperationErrorNameOperation(
1716
+ state.global,
1717
+ action
1718
+ );
1719
+ break;
1720
+ case "SET_OPERATION_ERROR_DESCRIPTION":
1721
+ SetOperationErrorDescriptionInputSchema().parse(action.input);
1722
+ reducer$4.setOperationErrorDescriptionOperation(
1723
+ state.global,
1724
+ action
1725
+ );
1726
+ break;
1727
+ case "SET_OPERATION_ERROR_TEMPLATE":
1728
+ SetOperationErrorTemplateInputSchema().parse(action.input);
1729
+ reducer$4.setOperationErrorTemplateOperation(
1730
+ state.global,
1731
+ action
1732
+ );
1733
+ break;
1734
+ case "DELETE_OPERATION_ERROR":
1735
+ DeleteOperationErrorInputSchema().parse(action.input);
1736
+ reducer$4.deleteOperationErrorOperation(
1737
+ state.global,
1738
+ action
1739
+ );
1740
+ break;
1741
+ case "REORDER_OPERATION_ERRORS":
1742
+ ReorderOperationErrorsInputSchema().parse(action.input);
1743
+ reducer$4.reorderOperationErrorsOperation(
1744
+ state.global,
1745
+ action
1746
+ );
1747
+ break;
1748
+ case "ADD_OPERATION_EXAMPLE":
1749
+ AddOperationExampleInputSchema().parse(action.input);
1750
+ reducer$3.addOperationExampleOperation(
1751
+ state.global,
1752
+ action
1753
+ );
1754
+ break;
1755
+ case "UPDATE_OPERATION_EXAMPLE":
1756
+ UpdateOperationExampleInputSchema().parse(action.input);
1757
+ reducer$3.updateOperationExampleOperation(
1758
+ state.global,
1759
+ action
1760
+ );
1761
+ break;
1762
+ case "DELETE_OPERATION_EXAMPLE":
1763
+ DeleteOperationExampleInputSchema().parse(action.input);
1764
+ reducer$3.deleteOperationExampleOperation(
1765
+ state.global,
1766
+ action
1767
+ );
1768
+ break;
1769
+ case "REORDER_OPERATION_EXAMPLES":
1770
+ ReorderOperationExamplesInputSchema().parse(action.input);
1771
+ reducer$3.reorderOperationExamplesOperation(
1772
+ state.global,
1773
+ action
1774
+ );
1775
+ break;
1776
+ case "ADD_OPERATION":
1777
+ AddOperationInputSchema().parse(action.input);
1778
+ reducer$2.addOperationOperation(state.global, action);
1779
+ break;
1780
+ case "SET_OPERATION_NAME":
1781
+ SetOperationNameInputSchema().parse(action.input);
1782
+ reducer$2.setOperationNameOperation(state.global, action);
1783
+ break;
1784
+ case "SET_OPERATION_SCOPE":
1785
+ SetOperationScopeInputSchema().parse(action.input);
1786
+ reducer$2.setOperationScopeOperation(state.global, action);
1787
+ break;
1788
+ case "SET_OPERATION_SCHEMA":
1789
+ SetOperationSchemaInputSchema().parse(action.input);
1790
+ reducer$2.setOperationSchemaOperation(state.global, action);
1791
+ break;
1792
+ case "SET_OPERATION_DESCRIPTION":
1793
+ SetOperationDescriptionInputSchema().parse(action.input);
1794
+ reducer$2.setOperationDescriptionOperation(
1795
+ state.global,
1796
+ action
1797
+ );
1798
+ break;
1799
+ case "SET_OPERATION_TEMPLATE":
1800
+ SetOperationTemplateInputSchema().parse(action.input);
1801
+ reducer$2.setOperationTemplateOperation(
1802
+ state.global,
1803
+ action
1804
+ );
1805
+ break;
1806
+ case "SET_OPERATION_REDUCER":
1807
+ SetOperationReducerInputSchema().parse(action.input);
1808
+ reducer$2.setOperationReducerOperation(state.global, action);
1809
+ break;
1810
+ case "MOVE_OPERATION":
1811
+ MoveOperationInputSchema().parse(action.input);
1812
+ reducer$2.moveOperationOperation(state.global, action);
1813
+ break;
1814
+ case "DELETE_OPERATION":
1815
+ DeleteOperationInputSchema().parse(action.input);
1816
+ reducer$2.deleteOperationOperation(state.global, action);
1817
+ break;
1818
+ case "REORDER_MODULE_OPERATIONS":
1819
+ ReorderModuleOperationsInputSchema().parse(action.input);
1820
+ reducer$2.reorderModuleOperationsOperation(
1821
+ state.global,
1822
+ action
1823
+ );
1824
+ break;
1825
+ case "SET_STATE_SCHEMA":
1826
+ SetStateSchemaInputSchema().parse(action.input);
1827
+ reducer$1.setStateSchemaOperation(state.global, action);
1828
+ break;
1829
+ case "SET_INITIAL_STATE":
1830
+ SetInitialStateInputSchema().parse(action.input);
1831
+ reducer$1.setInitialStateOperation(state.global, action);
1832
+ break;
1833
+ case "ADD_STATE_EXAMPLE":
1834
+ AddStateExampleInputSchema().parse(action.input);
1835
+ reducer$1.addStateExampleOperation(state.global, action);
1836
+ break;
1837
+ case "UPDATE_STATE_EXAMPLE":
1838
+ UpdateStateExampleInputSchema().parse(action.input);
1839
+ reducer$1.updateStateExampleOperation(state.global, action);
1840
+ break;
1841
+ case "DELETE_STATE_EXAMPLE":
1842
+ DeleteStateExampleInputSchema().parse(action.input);
1843
+ reducer$1.deleteStateExampleOperation(state.global, action);
1844
+ break;
1845
+ case "REORDER_STATE_EXAMPLES":
1846
+ ReorderStateExamplesInputSchema().parse(action.input);
1847
+ reducer$1.reorderStateExamplesOperation(state.global, action);
1848
+ break;
1849
+ default:
1850
+ return state;
1851
+ }
1852
+ };
1853
+ const reducer = createReducer(stateReducer);
1854
+ const initialGlobalState = {
1855
+ id: "",
1856
+ name: "",
1857
+ extension: "",
1858
+ description: "",
1859
+ author: {
1860
+ name: "",
1861
+ website: ""
1862
+ },
1863
+ specifications: [
1864
+ {
1865
+ version: 1,
1866
+ changeLog: [],
1867
+ state: {
1868
+ global: {
1869
+ schema: "",
1870
+ initialValue: "",
1871
+ examples: []
1872
+ },
1873
+ local: {
1874
+ schema: "",
1875
+ initialValue: "",
1876
+ examples: []
1877
+ }
1878
+ },
1879
+ modules: []
1880
+ }
1881
+ ]
1882
+ };
1883
+ const initialLocalState = {};
1884
+ const utils$1 = {
1885
+ fileExtension: "phdm",
1886
+ createState(state) {
1887
+ return {
1888
+ global: { ...initialGlobalState, ...state == null ? void 0 : state.global },
1889
+ local: { ...initialLocalState, ...state == null ? void 0 : state.local }
1890
+ };
1891
+ },
1892
+ createExtendedState(extendedState) {
1893
+ return createExtendedState(
1894
+ { ...extendedState, documentType: "powerhouse/document-model" },
1895
+ utils$1.createState
1896
+ );
1897
+ },
1898
+ createDocument(state) {
1899
+ return createDocument(
1900
+ utils$1.createExtendedState(state),
1901
+ utils$1.createState
1902
+ );
1903
+ },
1904
+ saveToFile(document, path, name) {
1905
+ return saveToFile(document, path, "phdm", name);
1906
+ },
1907
+ saveToFileHandle(document, input) {
1908
+ return saveToFileHandle(document, input);
1909
+ },
1910
+ loadFromFile(path) {
1911
+ return loadFromFile(path, reducer);
1912
+ },
1913
+ loadFromInput(input) {
1914
+ return loadFromInput(input, reducer);
1915
+ }
1916
+ };
1917
+ const setModelName = (input) => createAction(
1918
+ "SET_MODEL_NAME",
1919
+ { ...input }
1920
+ );
1921
+ const setModelId = (input) => createAction(
1922
+ "SET_MODEL_ID",
1923
+ { ...input }
1924
+ );
1925
+ const setModelExtension = (input) => createAction(
1926
+ "SET_MODEL_EXTENSION",
1927
+ { ...input }
1928
+ );
1929
+ const setModelDescription = (input) => createAction(
1930
+ "SET_MODEL_DESCRIPTION",
1931
+ { ...input }
1932
+ );
1933
+ const setAuthorName = (input) => createAction(
1934
+ "SET_AUTHOR_NAME",
1935
+ { ...input }
1936
+ );
1937
+ const setAuthorWebsite = (input) => createAction(
1938
+ "SET_AUTHOR_WEBSITE",
1939
+ { ...input }
1940
+ );
1941
+ class DocumentModel_Header extends BaseDocument {
1942
+ setModelName(input, options) {
1943
+ return this.dispatch(setModelName(input), options);
1944
+ }
1945
+ setModelId(input, options) {
1946
+ return this.dispatch(setModelId(input), options);
1947
+ }
1948
+ setModelExtension(input, options) {
1949
+ return this.dispatch(setModelExtension(input), options);
1950
+ }
1951
+ setModelDescription(input, options) {
1952
+ return this.dispatch(setModelDescription(input), options);
1953
+ }
1954
+ setAuthorName(input, options) {
1955
+ return this.dispatch(setAuthorName(input), options);
1956
+ }
1957
+ setAuthorWebsite(input, options) {
1958
+ return this.dispatch(setAuthorWebsite(input), options);
1959
+ }
1960
+ }
1961
+ const addChangeLogItem = (input) => createAction(
1962
+ "ADD_CHANGE_LOG_ITEM",
1963
+ { ...input }
1964
+ );
1965
+ const updateChangeLogItem = (input) => createAction(
1966
+ "UPDATE_CHANGE_LOG_ITEM",
1967
+ { ...input }
1968
+ );
1969
+ const deleteChangeLogItem = (input) => createAction(
1970
+ "DELETE_CHANGE_LOG_ITEM",
1971
+ { ...input }
1972
+ );
1973
+ const reorderChangeLogItems = (input) => createAction(
1974
+ "REORDER_CHANGE_LOG_ITEMS",
1975
+ { ...input }
1976
+ );
1977
+ const releaseNewVersion = () => createAction(
1978
+ "RELEASE_NEW_VERSION"
1979
+ );
1980
+ class DocumentModel_Versioning extends BaseDocument {
1981
+ addChangeLogItem(input, options) {
1982
+ return this.dispatch(addChangeLogItem(input), options);
1983
+ }
1984
+ updateChangeLogItem(input, options) {
1985
+ return this.dispatch(updateChangeLogItem(input), options);
1986
+ }
1987
+ deleteChangeLogItem(input, options) {
1988
+ return this.dispatch(deleteChangeLogItem(input), options);
1989
+ }
1990
+ reorderChangeLogItems(input, options) {
1991
+ return this.dispatch(reorderChangeLogItems(input), options);
1992
+ }
1993
+ releaseNewVersion(options) {
1994
+ return this.dispatch(releaseNewVersion(), options);
1995
+ }
1996
+ }
1997
+ const addModule = (input) => createAction(
1998
+ "ADD_MODULE",
1999
+ { ...input }
2000
+ );
2001
+ const setModuleName = (input) => createAction(
2002
+ "SET_MODULE_NAME",
2003
+ { ...input }
2004
+ );
2005
+ const setModuleDescription = (input) => createAction(
2006
+ "SET_MODULE_DESCRIPTION",
2007
+ { ...input }
2008
+ );
2009
+ const deleteModule = (input) => createAction(
2010
+ "DELETE_MODULE",
2011
+ { ...input }
2012
+ );
2013
+ const reorderModules = (input) => createAction(
2014
+ "REORDER_MODULES",
2015
+ { ...input }
2016
+ );
2017
+ class DocumentModel_Module extends BaseDocument {
2018
+ addModule(input, options) {
2019
+ return this.dispatch(addModule(input), options);
2020
+ }
2021
+ setModuleName(input, options) {
2022
+ return this.dispatch(setModuleName(input), options);
2023
+ }
2024
+ setModuleDescription(input, options) {
2025
+ return this.dispatch(setModuleDescription(input), options);
2026
+ }
2027
+ deleteModule(input, options) {
2028
+ return this.dispatch(deleteModule(input), options);
2029
+ }
2030
+ reorderModules(input, options) {
2031
+ return this.dispatch(reorderModules(input), options);
2032
+ }
2033
+ }
2034
+ const addOperationError = (input) => createAction(
2035
+ "ADD_OPERATION_ERROR",
2036
+ { ...input }
2037
+ );
2038
+ const setOperationErrorCode = (input) => createAction(
2039
+ "SET_OPERATION_ERROR_CODE",
2040
+ { ...input }
2041
+ );
2042
+ const setOperationErrorName = (input) => createAction(
2043
+ "SET_OPERATION_ERROR_NAME",
2044
+ { ...input }
2045
+ );
2046
+ const setOperationErrorDescription = (input) => createAction(
2047
+ "SET_OPERATION_ERROR_DESCRIPTION",
2048
+ { ...input }
2049
+ );
2050
+ const setOperationErrorTemplate = (input) => createAction(
2051
+ "SET_OPERATION_ERROR_TEMPLATE",
2052
+ { ...input }
2053
+ );
2054
+ const deleteOperationError = (input) => createAction(
2055
+ "DELETE_OPERATION_ERROR",
2056
+ { ...input }
2057
+ );
2058
+ const reorderOperationErrors = (input) => createAction(
2059
+ "REORDER_OPERATION_ERRORS",
2060
+ { ...input }
2061
+ );
2062
+ class DocumentModel_OperationError extends BaseDocument {
2063
+ addOperationError(input, options) {
2064
+ return this.dispatch(addOperationError(input), options);
2065
+ }
2066
+ setOperationErrorCode(input, options) {
2067
+ return this.dispatch(setOperationErrorCode(input), options);
2068
+ }
2069
+ setOperationErrorName(input, options) {
2070
+ return this.dispatch(setOperationErrorName(input), options);
2071
+ }
2072
+ setOperationErrorDescription(input, options) {
2073
+ return this.dispatch(setOperationErrorDescription(input), options);
2074
+ }
2075
+ setOperationErrorTemplate(input, options) {
2076
+ return this.dispatch(setOperationErrorTemplate(input), options);
2077
+ }
2078
+ deleteOperationError(input, options) {
2079
+ return this.dispatch(deleteOperationError(input), options);
2080
+ }
2081
+ reorderOperationErrors(input, options) {
2082
+ return this.dispatch(reorderOperationErrors(input), options);
2083
+ }
2084
+ }
2085
+ const addOperationExample = (input) => createAction(
2086
+ "ADD_OPERATION_EXAMPLE",
2087
+ { ...input }
2088
+ );
2089
+ const updateOperationExample = (input) => createAction(
2090
+ "UPDATE_OPERATION_EXAMPLE",
2091
+ { ...input }
2092
+ );
2093
+ const deleteOperationExample = (input) => createAction(
2094
+ "DELETE_OPERATION_EXAMPLE",
2095
+ { ...input }
2096
+ );
2097
+ const reorderOperationExamples = (input) => createAction(
2098
+ "REORDER_OPERATION_EXAMPLES",
2099
+ { ...input }
2100
+ );
2101
+ class DocumentModel_OperationExample extends BaseDocument {
2102
+ addOperationExample(input, options) {
2103
+ return this.dispatch(addOperationExample(input), options);
2104
+ }
2105
+ updateOperationExample(input, options) {
2106
+ return this.dispatch(updateOperationExample(input), options);
2107
+ }
2108
+ deleteOperationExample(input, options) {
2109
+ return this.dispatch(deleteOperationExample(input), options);
2110
+ }
2111
+ reorderOperationExamples(input, options) {
2112
+ return this.dispatch(reorderOperationExamples(input), options);
2113
+ }
2114
+ }
2115
+ const addOperation = (input) => createAction(
2116
+ "ADD_OPERATION",
2117
+ { ...input }
2118
+ );
2119
+ const setOperationName = (input) => createAction(
2120
+ "SET_OPERATION_NAME",
2121
+ { ...input }
2122
+ );
2123
+ const setOperationScope = (input) => createAction(
2124
+ "SET_OPERATION_SCOPE",
2125
+ { ...input }
2126
+ );
2127
+ const setOperationSchema = (input) => createAction(
2128
+ "SET_OPERATION_SCHEMA",
2129
+ { ...input }
2130
+ );
2131
+ const setOperationDescription = (input) => createAction(
2132
+ "SET_OPERATION_DESCRIPTION",
2133
+ { ...input }
2134
+ );
2135
+ const setOperationTemplate = (input) => createAction(
2136
+ "SET_OPERATION_TEMPLATE",
2137
+ { ...input }
2138
+ );
2139
+ const setOperationReducer = (input) => createAction(
2140
+ "SET_OPERATION_REDUCER",
2141
+ { ...input }
2142
+ );
2143
+ const moveOperation = (input) => createAction(
2144
+ "MOVE_OPERATION",
2145
+ { ...input }
2146
+ );
2147
+ const deleteOperation = (input) => createAction(
2148
+ "DELETE_OPERATION",
2149
+ { ...input }
2150
+ );
2151
+ const reorderModuleOperations = (input) => createAction(
2152
+ "REORDER_MODULE_OPERATIONS",
2153
+ { ...input }
2154
+ );
2155
+ class DocumentModel_Operation extends BaseDocument {
2156
+ addOperation(input, options) {
2157
+ return this.dispatch(addOperation(input), options);
2158
+ }
2159
+ setOperationName(input, options) {
2160
+ return this.dispatch(setOperationName(input), options);
2161
+ }
2162
+ setOperationScope(input, options) {
2163
+ return this.dispatch(setOperationScope(input), options);
2164
+ }
2165
+ setOperationSchema(input, options) {
2166
+ return this.dispatch(setOperationSchema(input), options);
2167
+ }
2168
+ setOperationDescription(input, options) {
2169
+ return this.dispatch(setOperationDescription(input), options);
2170
+ }
2171
+ setOperationTemplate(input, options) {
2172
+ return this.dispatch(setOperationTemplate(input), options);
2173
+ }
2174
+ setOperationReducer(input, options) {
2175
+ return this.dispatch(setOperationReducer(input), options);
2176
+ }
2177
+ moveOperation(input, options) {
2178
+ return this.dispatch(moveOperation(input), options);
2179
+ }
2180
+ deleteOperation(input, options) {
2181
+ return this.dispatch(deleteOperation(input), options);
2182
+ }
2183
+ reorderModuleOperations(input, options) {
2184
+ return this.dispatch(reorderModuleOperations(input), options);
2185
+ }
2186
+ }
2187
+ const setStateSchema = (input) => createAction(
2188
+ "SET_STATE_SCHEMA",
2189
+ { ...input }
2190
+ );
2191
+ const setInitialState = (input) => createAction(
2192
+ "SET_INITIAL_STATE",
2193
+ { ...input }
2194
+ );
2195
+ const addStateExample = (input) => createAction(
2196
+ "ADD_STATE_EXAMPLE",
2197
+ { ...input }
2198
+ );
2199
+ const updateStateExample = (input) => createAction(
2200
+ "UPDATE_STATE_EXAMPLE",
2201
+ { ...input }
2202
+ );
2203
+ const deleteStateExample = (input) => createAction(
2204
+ "DELETE_STATE_EXAMPLE",
2205
+ { ...input }
2206
+ );
2207
+ const reorderStateExamples = (input) => createAction(
2208
+ "REORDER_STATE_EXAMPLES",
2209
+ { ...input }
2210
+ );
2211
+ class DocumentModel_State extends BaseDocument {
2212
+ setStateSchema(input, options) {
2213
+ return this.dispatch(setStateSchema(input), options);
2214
+ }
2215
+ setInitialState(input, options) {
2216
+ return this.dispatch(setInitialState(input), options);
2217
+ }
2218
+ addStateExample(input, options) {
2219
+ return this.dispatch(addStateExample(input), options);
2220
+ }
2221
+ updateStateExample(input, options) {
2222
+ return this.dispatch(updateStateExample(input), options);
2223
+ }
2224
+ deleteStateExample(input, options) {
2225
+ return this.dispatch(deleteStateExample(input), options);
2226
+ }
2227
+ reorderStateExamples(input, options) {
2228
+ return this.dispatch(reorderStateExamples(input), options);
2229
+ }
2230
+ }
2231
+ let DocumentModel$1 = (_a = class extends BaseDocument {
2232
+ constructor(initialState, dispatch) {
2233
+ super(reducer, utils$1.createDocument(initialState), dispatch);
2234
+ }
2235
+ saveToFile(path, name) {
2236
+ return super.saveToFile(path, _a.fileExtension, name);
2237
+ }
2238
+ loadFromFile(path) {
2239
+ return super.loadFromFile(path);
2240
+ }
2241
+ static async fromFile(path) {
2242
+ const document = new this();
2243
+ await document.loadFromFile(path);
2244
+ return document;
2245
+ }
2246
+ }, __publicField(_a, "fileExtension", "phdm"), _a);
2247
+ applyMixins(DocumentModel$1, [
2248
+ DocumentModel_Header,
2249
+ DocumentModel_Versioning,
2250
+ DocumentModel_Module,
2251
+ DocumentModel_OperationError,
2252
+ DocumentModel_OperationExample,
2253
+ DocumentModel_Operation,
2254
+ DocumentModel_State
2255
+ ]);
2256
+ const DocumentModelActions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2257
+ __proto__: null,
2258
+ addChangeLogItem,
2259
+ addModule,
2260
+ addOperation,
2261
+ addOperationError,
2262
+ addOperationExample,
2263
+ addStateExample,
2264
+ deleteChangeLogItem,
2265
+ deleteModule,
2266
+ deleteOperation,
2267
+ deleteOperationError,
2268
+ deleteOperationExample,
2269
+ deleteStateExample,
2270
+ moveOperation,
2271
+ releaseNewVersion,
2272
+ reorderChangeLogItems,
2273
+ reorderModuleOperations,
2274
+ reorderModules,
2275
+ reorderOperationErrors,
2276
+ reorderOperationExamples,
2277
+ reorderStateExamples,
2278
+ setAuthorName,
2279
+ setAuthorWebsite,
2280
+ setInitialState,
2281
+ setModelDescription,
2282
+ setModelExtension,
2283
+ setModelId,
2284
+ setModelName,
2285
+ setModuleDescription,
2286
+ setModuleName,
2287
+ setOperationDescription,
2288
+ setOperationErrorCode,
2289
+ setOperationErrorDescription,
2290
+ setOperationErrorName,
2291
+ setOperationErrorTemplate,
2292
+ setOperationName,
2293
+ setOperationReducer,
2294
+ setOperationSchema,
2295
+ setOperationScope,
2296
+ setOperationTemplate,
2297
+ setStateSchema,
2298
+ updateChangeLogItem,
2299
+ updateOperationExample,
2300
+ updateStateExample
2301
+ }, Symbol.toStringTag, { value: "Module" }));
2302
+ const Document = DocumentModel$1;
2303
+ const utils = { ...utils$1, ...customUtils };
2304
+ const actions = { ...BaseActions, ...DocumentModelActions };
2305
+ const module = {
2306
+ Document,
2307
+ reducer,
2308
+ actions,
2309
+ utils,
2310
+ documentModel
2311
+ };
2312
+ const DocumentModel = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2313
+ __proto__: null,
2314
+ Document,
2315
+ DocumentModel: DocumentModel$1,
2316
+ actions,
2317
+ documentModel,
2318
+ module,
2319
+ reducer,
2320
+ utils,
2321
+ validateInitialState,
2322
+ validateModule,
2323
+ validateModuleOperation,
2324
+ validateModules,
2325
+ validateStateSchemaName,
2326
+ z: zod
2327
+ }, Symbol.toStringTag, { value: "Module" }));
2328
+ export {
2329
+ DocumentModel as D,
2330
+ DocumentModel$1 as a,
2331
+ Document as b,
2332
+ actions as c,
2333
+ documentModel as d,
2334
+ validateStateSchemaName as e,
2335
+ validateModules as f,
2336
+ validateModule as g,
2337
+ validateModuleOperation as h,
2338
+ module as m,
2339
+ reducer as r,
2340
+ utils as u,
2341
+ validateInitialState as v,
2342
+ zod as z
2343
+ };
2344
+ //# sourceMappingURL=index-BzOhAlo9.js.map