@crubal/engine 0.0.0-stage → 0.4.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.
Files changed (114) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +97 -2
  3. package/dist/bin/crubal.d.ts +2 -0
  4. package/dist/bin/crubal.js +103 -0
  5. package/dist/bin/crubal.js.map +1 -0
  6. package/dist/src/access.d.ts +149 -0
  7. package/dist/src/access.js +584 -0
  8. package/dist/src/access.js.map +1 -0
  9. package/dist/src/acts.d.ts +531 -0
  10. package/dist/src/acts.js +1466 -0
  11. package/dist/src/acts.js.map +1 -0
  12. package/dist/src/address.d.ts +29 -0
  13. package/dist/src/address.js +59 -0
  14. package/dist/src/address.js.map +1 -0
  15. package/dist/src/arrival.d.ts +55 -0
  16. package/dist/src/arrival.js +127 -0
  17. package/dist/src/arrival.js.map +1 -0
  18. package/dist/src/browser.d.ts +10 -0
  19. package/dist/src/browser.js +13 -0
  20. package/dist/src/browser.js.map +1 -0
  21. package/dist/src/bundle.d.ts +74 -0
  22. package/dist/src/bundle.js +1108 -0
  23. package/dist/src/bundle.js.map +1 -0
  24. package/dist/src/canonical.d.ts +6 -0
  25. package/dist/src/canonical.js +47 -0
  26. package/dist/src/canonical.js.map +1 -0
  27. package/dist/src/carriers.d.ts +7 -0
  28. package/dist/src/carriers.js +33 -0
  29. package/dist/src/carriers.js.map +1 -0
  30. package/dist/src/conditions.d.ts +28 -0
  31. package/dist/src/conditions.js +227 -0
  32. package/dist/src/conditions.js.map +1 -0
  33. package/dist/src/corpus.d.ts +8 -0
  34. package/dist/src/corpus.js +1207 -0
  35. package/dist/src/corpus.js.map +1 -0
  36. package/dist/src/defs.d.ts +174 -0
  37. package/dist/src/defs.js +690 -0
  38. package/dist/src/defs.js.map +1 -0
  39. package/dist/src/dictionary.d.ts +77 -0
  40. package/dist/src/dictionary.js +629 -0
  41. package/dist/src/dictionary.js.map +1 -0
  42. package/dist/src/exchange.d.ts +259 -0
  43. package/dist/src/exchange.js +1088 -0
  44. package/dist/src/exchange.js.map +1 -0
  45. package/dist/src/forms.d.ts +16 -0
  46. package/dist/src/forms.js +181 -0
  47. package/dist/src/forms.js.map +1 -0
  48. package/dist/src/index.d.ts +32 -0
  49. package/dist/src/index.js +34 -0
  50. package/dist/src/index.js.map +1 -0
  51. package/dist/src/lex.d.ts +21 -0
  52. package/dist/src/lex.js +142 -0
  53. package/dist/src/lex.js.map +1 -0
  54. package/dist/src/lifecycle.d.ts +92 -0
  55. package/dist/src/lifecycle.js +451 -0
  56. package/dist/src/lifecycle.js.map +1 -0
  57. package/dist/src/log.d.ts +91 -0
  58. package/dist/src/log.js +629 -0
  59. package/dist/src/log.js.map +1 -0
  60. package/dist/src/migrate.d.ts +129 -0
  61. package/dist/src/migrate.js +415 -0
  62. package/dist/src/migrate.js.map +1 -0
  63. package/dist/src/model.d.ts +81 -0
  64. package/dist/src/model.js +188 -0
  65. package/dist/src/model.js.map +1 -0
  66. package/dist/src/packages.d.ts +372 -0
  67. package/dist/src/packages.js +1158 -0
  68. package/dist/src/packages.js.map +1 -0
  69. package/dist/src/print-text.d.ts +7 -0
  70. package/dist/src/print-text.js +223 -0
  71. package/dist/src/print-text.js.map +1 -0
  72. package/dist/src/publish.d.ts +27 -0
  73. package/dist/src/publish.js +279 -0
  74. package/dist/src/publish.js.map +1 -0
  75. package/dist/src/read-text.d.ts +10 -0
  76. package/dist/src/read-text.js +400 -0
  77. package/dist/src/read-text.js.map +1 -0
  78. package/dist/src/records.d.ts +32 -0
  79. package/dist/src/records.js +104 -0
  80. package/dist/src/records.js.map +1 -0
  81. package/dist/src/review.d.ts +22 -0
  82. package/dist/src/review.js +198 -0
  83. package/dist/src/review.js.map +1 -0
  84. package/dist/src/rules.d.ts +101 -0
  85. package/dist/src/rules.js +670 -0
  86. package/dist/src/rules.js.map +1 -0
  87. package/dist/src/schedule.d.ts +24 -0
  88. package/dist/src/schedule.js +126 -0
  89. package/dist/src/schedule.js.map +1 -0
  90. package/dist/src/std-packages.d.ts +9 -0
  91. package/dist/src/std-packages.js +268 -0
  92. package/dist/src/std-packages.js.map +1 -0
  93. package/dist/src/store.d.ts +191 -0
  94. package/dist/src/store.js +671 -0
  95. package/dist/src/store.js.map +1 -0
  96. package/dist/src/surface.d.ts +47 -0
  97. package/dist/src/surface.js +92 -0
  98. package/dist/src/surface.js.map +1 -0
  99. package/dist/src/tree.d.ts +35 -0
  100. package/dist/src/tree.js +159 -0
  101. package/dist/src/tree.js.map +1 -0
  102. package/dist/src/units-table.d.ts +1 -0
  103. package/dist/src/units-table.js +200 -0
  104. package/dist/src/units-table.js.map +1 -0
  105. package/dist/src/units.d.ts +42 -0
  106. package/dist/src/units.js +98 -0
  107. package/dist/src/units.js.map +1 -0
  108. package/dist/src/versions.d.ts +10 -0
  109. package/dist/src/versions.js +27 -0
  110. package/dist/src/versions.js.map +1 -0
  111. package/dist/src/views.d.ts +372 -0
  112. package/dist/src/views.js +1170 -0
  113. package/dist/src/views.js.map +1 -0
  114. package/package.json +60 -4
@@ -0,0 +1,91 @@
1
+ import type { Edge } from "./access.ts";
2
+ import type { Json, JsonObject, Record } from "./model.ts";
3
+ import { type RecordSet } from "./records.ts";
4
+ export type Entry = JsonObject;
5
+ /** Everything a store holds that the log carries. */
6
+ export type State = {
7
+ records: RecordSet;
8
+ /** Every edge written, by id; the store's commit checks each (14.5, 14.12) before it lands here. */
9
+ edges: Map<string, Edge>;
10
+ /** `contract|ref` → record */
11
+ bindings: Map<string, string>;
12
+ /** issuer → its instructions, in order */
13
+ instructions: Map<string, JsonObject[]>;
14
+ observations: JsonObject[];
15
+ reviews: JsonObject[];
16
+ runs: Map<string, JsonObject>;
17
+ installed: JsonObject[];
18
+ reads: JsonObject[];
19
+ /** The owner's working package (11.4): `<member>:<name>` → the definition as it now stands. */
20
+ definitions: Map<string, JsonObject>;
21
+ };
22
+ export declare function emptyState(): State;
23
+ /** Apply one entry's effects to the state. */
24
+ export declare function applyEntry(state: State, entry: Entry): void;
25
+ /** Rebuild a store's state from its log alone (8.5.3). */
26
+ export declare function rebuild(entries: Entry[]): State;
27
+ /**
28
+ * Revision 50: one record as it stood. The entries are the log's, in order; only this record's own writes are
29
+ * applied, and only those of entries at or before `until` (every one when it is not said). Answers the record
30
+ * as it then stood (nothing when it was not yet made) and, for each address of its values, when it last
31
+ * changed: the moment of the last entry that left it other than it was. An entry or a write redacted is
32
+ * passed over as a rebuild passes it over, so what it held is not answered.
33
+ */
34
+ export declare function recordAt(entries: Entry[], id: string, until?: string): {
35
+ record?: Record;
36
+ changed: {
37
+ [address: string]: string;
38
+ };
39
+ };
40
+ /** The state as JSON, for comparing and for a dump. */
41
+ export declare function stateJson(state: State): JsonObject;
42
+ /** What an operation works on: a scratch copy of the state. Nothing in it is the truth until it is logged. */
43
+ export type Draft = {
44
+ records: RecordSet;
45
+ bindings: Map<string, string>;
46
+ instructions: Map<string, JsonObject[]>;
47
+ edges: Map<string, Edge>;
48
+ review: JsonObject[];
49
+ };
50
+ /** One write of an entry (8.5): a value at an address, an envelope field, a held value, an edge, a define, a review. */
51
+ export type Write = JsonObject & {
52
+ record?: string;
53
+ address?: string;
54
+ value?: Json;
55
+ removed?: true;
56
+ envelope?: string;
57
+ as?: "held";
58
+ source?: JsonObject;
59
+ edge?: Edge;
60
+ };
61
+ /** The writes that take `before` to `after`: exactly the effects, nothing computed (8.5). */
62
+ export declare function diffWrites(before: State, after: Draft): JsonObject[];
63
+ /** Where a draft and a state disagree, or null. */
64
+ export declare function differs(state: State, draft: Draft): string | null;
65
+ /**
66
+ * The journal (8.5): operations work on a draft, every change becomes an entry, and the state is only ever
67
+ * what applying the entries gives. A commit whose entries don't describe the whole change is refused, so
68
+ * the log can never fall behind the state.
69
+ */
70
+ export declare class Journal {
71
+ readonly state: State;
72
+ readonly entries: Entry[];
73
+ readonly draft: Draft;
74
+ readonly owner: string;
75
+ private n;
76
+ constructor(owner: string, records?: Record[], at?: string);
77
+ /**
78
+ * Run an operation on the draft, log what it changed, and apply the entry to the state. `extra` carries
79
+ * writes the diff can't see (a run's state, a read under an emergency edge, a define).
80
+ */
81
+ commit(by: JsonObject, mutate: (draft: Draft) => void, at?: string, extra?: JsonObject[]): Entry | null;
82
+ }
83
+ /**
84
+ * Can this whole entry be redacted (8.5.2)? Only when it holds nothing but value, observation and read
85
+ * writes and isn't witnessed; otherwise it is redacted write by write. Returns the reason it can't, or null.
86
+ */
87
+ export declare function redactable(entry: Entry): string | null;
88
+ /** Can this write be redacted (8.5.2)? Null when it can, else why not. */
89
+ export declare function redactableWrite(entry: Entry, w: JsonObject): string | null;
90
+ /** Redact one write of an entry (8.5.2): it becomes its own hash, and the entry's hash stays where it was. */
91
+ export declare function redactWrite(entry: Entry, index: number): Entry;