@the-package-labs/idocs-core 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/schema.d.ts CHANGED
@@ -28,10 +28,24 @@ export declare const DirectionSchema: z.ZodEnum<{
28
28
  RIGHT: "RIGHT";
29
29
  UP: "UP";
30
30
  }>;
31
+ /** One field per list item: `- name`, `- name: type` or `- name: { type, key, ref, note }`. */
32
+ declare const FieldSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodObject<{
33
+ type: z.ZodOptional<z.ZodString>;
34
+ key: z.ZodOptional<z.ZodBoolean>;
35
+ ref: z.ZodOptional<z.ZodString>;
36
+ note: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strict>]>>]>;
31
38
  export declare const NodeSchema: z.ZodObject<{
32
39
  title: z.ZodOptional<z.ZodString>;
33
40
  sub: z.ZodOptional<z.ZodString>;
41
+ pill: z.ZodOptional<z.ZodString>;
34
42
  lines: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
+ fields: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodObject<{
44
+ type: z.ZodOptional<z.ZodString>;
45
+ key: z.ZodOptional<z.ZodBoolean>;
46
+ ref: z.ZodOptional<z.ZodString>;
47
+ note: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strict>]>>]>>>;
35
49
  icon: z.ZodOptional<z.ZodString>;
36
50
  kind: z.ZodOptional<z.ZodString>;
37
51
  family: z.ZodOptional<z.ZodEnum<{
@@ -65,6 +79,17 @@ export declare const NodeSchema: z.ZodObject<{
65
79
  }, z.core.$strict>>>;
66
80
  refs: z.ZodOptional<z.ZodArray<z.ZodString>>;
67
81
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
82
+ diagram: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
83
+ name: z.ZodString;
84
+ view: z.ZodOptional<z.ZodString>;
85
+ scenario: z.ZodOptional<z.ZodString>;
86
+ mode: z.ZodOptional<z.ZodEnum<{
87
+ both: "both";
88
+ expand: "expand";
89
+ open: "open";
90
+ }>>;
91
+ expanded: z.ZodOptional<z.ZodBoolean>;
92
+ }, z.core.$strict>]>>;
68
93
  }, z.core.$strict>;
69
94
  export declare const GroupSchema: z.ZodObject<{
70
95
  label: z.ZodString;
@@ -429,10 +454,34 @@ export declare const ScenarioSchema: z.ZodObject<{
429
454
  }, z.core.$strict>], "type">>;
430
455
  }, z.core.$strict>], "type">>>;
431
456
  }, z.core.$strict>;
457
+ export declare const DefaultsSchema: z.ZodObject<{
458
+ view: z.ZodOptional<z.ZodString>;
459
+ scenario: z.ZodOptional<z.ZodString>;
460
+ mode: z.ZodOptional<z.ZodEnum<{
461
+ flow: "flow";
462
+ sequence: "sequence";
463
+ story: "story";
464
+ }>>;
465
+ sidebar: z.ZodOptional<z.ZodBoolean>;
466
+ subtitles: z.ZodOptional<z.ZodBoolean>;
467
+ autoplay: z.ZodOptional<z.ZodBoolean>;
468
+ }, z.core.$strict>;
432
469
  export declare const RootSchema: z.ZodObject<{
433
470
  $schema: z.ZodOptional<z.ZodString>;
434
471
  title: z.ZodString;
435
472
  description: z.ZodOptional<z.ZodString>;
473
+ defaults: z.ZodOptional<z.ZodObject<{
474
+ view: z.ZodOptional<z.ZodString>;
475
+ scenario: z.ZodOptional<z.ZodString>;
476
+ mode: z.ZodOptional<z.ZodEnum<{
477
+ flow: "flow";
478
+ sequence: "sequence";
479
+ story: "story";
480
+ }>>;
481
+ sidebar: z.ZodOptional<z.ZodBoolean>;
482
+ subtitles: z.ZodOptional<z.ZodBoolean>;
483
+ autoplay: z.ZodOptional<z.ZodBoolean>;
484
+ }, z.core.$strict>>;
436
485
  kinds: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
437
486
  icon: z.ZodOptional<z.ZodString>;
438
487
  family: z.ZodOptional<z.ZodEnum<{
@@ -487,7 +536,14 @@ export declare const RootSchema: z.ZodObject<{
487
536
  nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
488
537
  title: z.ZodOptional<z.ZodString>;
489
538
  sub: z.ZodOptional<z.ZodString>;
539
+ pill: z.ZodOptional<z.ZodString>;
490
540
  lines: z.ZodOptional<z.ZodArray<z.ZodString>>;
541
+ fields: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodObject<{
542
+ type: z.ZodOptional<z.ZodString>;
543
+ key: z.ZodOptional<z.ZodBoolean>;
544
+ ref: z.ZodOptional<z.ZodString>;
545
+ note: z.ZodOptional<z.ZodString>;
546
+ }, z.core.$strict>]>>]>>>;
491
547
  icon: z.ZodOptional<z.ZodString>;
492
548
  kind: z.ZodOptional<z.ZodString>;
493
549
  family: z.ZodOptional<z.ZodEnum<{
@@ -521,6 +577,17 @@ export declare const RootSchema: z.ZodObject<{
521
577
  }, z.core.$strict>>>;
522
578
  refs: z.ZodOptional<z.ZodArray<z.ZodString>>;
523
579
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
580
+ diagram: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
581
+ name: z.ZodString;
582
+ view: z.ZodOptional<z.ZodString>;
583
+ scenario: z.ZodOptional<z.ZodString>;
584
+ mode: z.ZodOptional<z.ZodEnum<{
585
+ both: "both";
586
+ expand: "expand";
587
+ open: "open";
588
+ }>>;
589
+ expanded: z.ZodOptional<z.ZodBoolean>;
590
+ }, z.core.$strict>]>>;
524
591
  }, z.core.$strict>>;
525
592
  edges: z.ZodOptional<z.ZodArray<z.ZodObject<{
526
593
  id: z.ZodOptional<z.ZodString>;
@@ -762,6 +829,7 @@ export declare const RootSchema: z.ZodObject<{
762
829
  }, z.core.$strict>>>;
763
830
  }, z.core.$strict>;
764
831
  export type RootInput = z.infer<typeof RootSchema>;
832
+ export type FieldInput = z.infer<typeof FieldSchema>;
765
833
  export type Step = z.infer<typeof StepSchema>;
766
834
  export declare const KNOWN_KEYS: {
767
835
  readonly root: string[];
@@ -770,6 +838,7 @@ export declare const KNOWN_KEYS: {
770
838
  readonly edge: string[];
771
839
  readonly view: string[];
772
840
  readonly scenario: string[];
841
+ readonly defaults: string[];
773
842
  };
774
843
  type Json = Record<string, unknown>;
775
844
  /**
@@ -0,0 +1,34 @@
1
+ import type { Timeline } from './timeline';
2
+ /** One stop of the slider: a step, or the steps of a `par` block that start together. */
3
+ export interface Slot {
4
+ /** First and last step of the slot, as indexes into `scenario.steps`. */
5
+ from: number;
6
+ to: number;
7
+ /** The time it covers. A slot runs until the next one starts, so pauses belong to the step before. */
8
+ t0: number;
9
+ t1: number;
10
+ }
11
+ /** A run of slots under one phase. A scenario without named phases is one section with no title. */
12
+ export interface Section {
13
+ /** Index in `scenario.phases`. */
14
+ phase: number;
15
+ title: string;
16
+ caption?: string;
17
+ /** First and last slot. */
18
+ from: number;
19
+ to: number;
20
+ }
21
+ export interface Scrubber {
22
+ slots: Slot[];
23
+ sections: Section[];
24
+ duration: number;
25
+ }
26
+ export declare function buildScrubber(tl: Timeline): Scrubber;
27
+ /** Where on the slider, 0 to 1, the moment `t` falls. */
28
+ export declare function positionAt(s: Scrubber, t: number): number;
29
+ /** The moment a place on the slider stands for. The inverse of `positionAt`. */
30
+ export declare function timeAt(s: Scrubber, position: number): number;
31
+ /** The slot a place on the slider falls in. */
32
+ export declare function slotAt(s: Scrubber, position: number): number;
33
+ /** The slot that holds step `index`, or -1. */
34
+ export declare function slotOfStep(s: Scrubber, index: number): number;
@@ -0,0 +1,22 @@
1
+ import type { CompiledDiagram, ScenarioMode } from './types';
2
+ /** What the page that shows a diagram asked for, if anything. Its choices win over the diagram's. */
3
+ export interface StartWant {
4
+ view?: string;
5
+ scenario?: string;
6
+ mode?: ScenarioMode;
7
+ }
8
+ export interface Start {
9
+ /** Always one of the diagram's views. */
10
+ view: string;
11
+ /** The scenario selected first, or null for the overview. */
12
+ scenario: string | null;
13
+ mode: ScenarioMode;
14
+ }
15
+ /** The mode a scenario is drawn in when neither it nor the page says: the diagram's, then `flow`. */
16
+ export declare const defaultMode: (diagram: CompiledDiagram) => ScenarioMode;
17
+ /**
18
+ * Where a diagram opens. The page's props come first, then what the diagram's author wrote under
19
+ * `defaults`, then the first view with nothing selected. The page choosing a scenario takes its
20
+ * view along, and one choosing a view leaves the default scenario out unless it plays there.
21
+ */
22
+ export declare function startOf(diagram: CompiledDiagram, want?: StartWant): Start;
@@ -0,0 +1 @@
1
+ export declare function didYouMean(word: string, options: readonly string[]): string | undefined;
package/dist/types.d.ts CHANGED
@@ -19,11 +19,37 @@ export interface NodeLink {
19
19
  label: string;
20
20
  url: string;
21
21
  }
22
+ /** Another diagram that shows the inside of a node. Resolved by name against the project's diagrams. */
23
+ export interface NodeDiagram {
24
+ name: string;
25
+ view?: string;
26
+ scenario?: string;
27
+ /** How a reader can get at it: shown in place (`expand`), moved into (`open`), or either. */
28
+ mode?: 'both' | 'expand' | 'open';
29
+ /** Starts shown in place. */
30
+ expanded?: boolean;
31
+ }
32
+ /** A row of an entity card: one column, property or attribute of what the node stores. */
33
+ export interface CompiledField {
34
+ name: string;
35
+ type?: string;
36
+ /** Part of the primary key. */
37
+ key?: boolean;
38
+ /** The node (and field) this one points at, like a foreign key. Each one draws a relation. */
39
+ ref?: {
40
+ node: string;
41
+ field?: string;
42
+ };
43
+ note?: string;
44
+ }
22
45
  export interface CompiledNode {
23
46
  id: string;
24
47
  title: string;
25
48
  sub?: string;
49
+ /** A short label in the card header, like `TABLE` or `ES INDEX`. */
50
+ pill?: string;
26
51
  lines: string[];
52
+ fields: CompiledField[];
27
53
  icon?: IconData;
28
54
  kind?: string;
29
55
  family?: Family;
@@ -37,6 +63,8 @@ export interface CompiledNode {
37
63
  links: NodeLink[];
38
64
  refs: string[];
39
65
  tags: string[];
66
+ /** Opens one level deeper: the diagram that describes this node's inside. */
67
+ diagram?: NodeDiagram;
40
68
  }
41
69
  export interface CompiledGroup {
42
70
  id: string;
@@ -64,6 +92,9 @@ export interface CompiledEdge {
64
92
  id: string;
65
93
  from: string;
66
94
  to: string;
95
+ /** Set when the edge starts or ends on one field of an entity card. */
96
+ fromField?: string;
97
+ toField?: string;
67
98
  label?: string;
68
99
  kind: string;
69
100
  both: boolean;
@@ -135,16 +166,35 @@ export interface CompiledScenario {
135
166
  phases: CompiledPhase[];
136
167
  steps: CompiledStep[];
137
168
  }
169
+ /**
170
+ * How a diagram opens, as its author wrote it. A page's own choices (the props of `<Diagram>`) win
171
+ * over these. Validated by the compiler: the view and the scenario exist, and agree.
172
+ */
173
+ export interface DiagramDefaults {
174
+ view?: string;
175
+ scenario?: string;
176
+ mode?: ScenarioMode;
177
+ sidebar?: boolean;
178
+ subtitles?: boolean;
179
+ autoplay?: boolean;
180
+ }
138
181
  export interface CompiledDiagram {
139
182
  name: string;
140
183
  title: string;
141
184
  descriptionHtml?: string;
185
+ defaults?: DiagramDefaults;
142
186
  nodes: Record<string, CompiledNode>;
143
187
  groups: Record<string, CompiledGroup>;
144
188
  edges: Record<string, CompiledEdge>;
145
189
  edgeKinds: Record<string, EdgeKindDef>;
146
190
  views: CompiledView[];
147
191
  scenarios: CompiledScenario[];
192
+ /**
193
+ * The diagrams its nodes open, by name, and the ones those open in turn. Added once every
194
+ * diagram of the project has compiled (`attachNested`), so a diagram is all a viewer needs. The
195
+ * entries themselves carry no `nested`.
196
+ */
197
+ nested?: Record<string, CompiledDiagram>;
148
198
  }
149
199
  export interface Pt {
150
200
  x: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-package-labs/idocs-core",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {