document-model 1.0.55 → 1.1.0-debug.2

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