@bjornpagen/bumbledb 0.1.0 → 0.3.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 (112) hide show
  1. package/COOKBOOK.md +1450 -0
  2. package/README.md +69 -30
  3. package/dist/closed.d.ts +157 -38
  4. package/dist/closed.d.ts.map +1 -1
  5. package/dist/closed.js +232 -47
  6. package/dist/closed.js.map +1 -1
  7. package/dist/count.d.ts +64 -17
  8. package/dist/count.d.ts.map +1 -1
  9. package/dist/count.js +37 -14
  10. package/dist/count.js.map +1 -1
  11. package/dist/db.d.ts +27 -8
  12. package/dist/db.d.ts.map +1 -1
  13. package/dist/db.js +33 -10
  14. package/dist/db.js.map +1 -1
  15. package/dist/exhume.d.ts +12 -11
  16. package/dist/exhume.d.ts.map +1 -1
  17. package/dist/exhume.js +7 -6
  18. package/dist/exhume.js.map +1 -1
  19. package/dist/face.d.ts +135 -30
  20. package/dist/face.d.ts.map +1 -1
  21. package/dist/face.js +44 -19
  22. package/dist/face.js.map +1 -1
  23. package/dist/fields.d.ts +130 -130
  24. package/dist/fields.d.ts.map +1 -1
  25. package/dist/fields.js +60 -94
  26. package/dist/fields.js.map +1 -1
  27. package/dist/index.d.ts +29 -24
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +19 -14
  30. package/dist/index.js.map +1 -1
  31. package/dist/law.d.ts +224 -0
  32. package/dist/law.d.ts.map +1 -0
  33. package/dist/law.js +224 -0
  34. package/dist/law.js.map +1 -0
  35. package/dist/lower.d.ts +17 -7
  36. package/dist/lower.d.ts.map +1 -1
  37. package/dist/lower.js +66 -24
  38. package/dist/lower.js.map +1 -1
  39. package/dist/marshal.d.ts +36 -21
  40. package/dist/marshal.d.ts.map +1 -1
  41. package/dist/marshal.js +41 -25
  42. package/dist/marshal.js.map +1 -1
  43. package/dist/native.d.ts +6 -2
  44. package/dist/native.d.ts.map +1 -1
  45. package/dist/native.js +2 -2
  46. package/dist/native.js.map +1 -1
  47. package/dist/query/atom.d.ts +370 -174
  48. package/dist/query/atom.d.ts.map +1 -1
  49. package/dist/query/atom.js +75 -172
  50. package/dist/query/atom.js.map +1 -1
  51. package/dist/query/lower.d.ts +312 -109
  52. package/dist/query/lower.d.ts.map +1 -1
  53. package/dist/query/lower.js +906 -387
  54. package/dist/query/lower.js.map +1 -1
  55. package/dist/query/predicate.d.ts +70 -88
  56. package/dist/query/predicate.d.ts.map +1 -1
  57. package/dist/query/predicate.js +118 -72
  58. package/dist/query/predicate.js.map +1 -1
  59. package/dist/query/run.d.ts +19 -16
  60. package/dist/query/run.d.ts.map +1 -1
  61. package/dist/query/run.js +31 -24
  62. package/dist/query/run.js.map +1 -1
  63. package/dist/query/scope.d.ts +178 -127
  64. package/dist/query/scope.d.ts.map +1 -1
  65. package/dist/query/scope.js +111 -108
  66. package/dist/query/scope.js.map +1 -1
  67. package/dist/query/select.d.ts +102 -80
  68. package/dist/query/select.d.ts.map +1 -1
  69. package/dist/query/select.js +39 -34
  70. package/dist/query/select.js.map +1 -1
  71. package/dist/relation.d.ts +48 -38
  72. package/dist/relation.d.ts.map +1 -1
  73. package/dist/relation.js +24 -19
  74. package/dist/relation.js.map +1 -1
  75. package/dist/schema.d.ts +41 -3
  76. package/dist/schema.d.ts.map +1 -1
  77. package/dist/schema.js +34 -9
  78. package/dist/schema.js.map +1 -1
  79. package/dist/spec.d.ts +7 -5
  80. package/dist/spec.d.ts.map +1 -1
  81. package/dist/spec.js.map +1 -1
  82. package/dist/statements.d.ts +91 -36
  83. package/dist/statements.d.ts.map +1 -1
  84. package/dist/statements.js +42 -12
  85. package/dist/statements.js.map +1 -1
  86. package/package.json +4 -3
  87. package/src/closed.ts +448 -95
  88. package/src/count.ts +112 -18
  89. package/src/db.ts +45 -17
  90. package/src/exhume.ts +12 -11
  91. package/src/face.ts +211 -41
  92. package/src/fields.ts +199 -234
  93. package/src/index.ts +78 -61
  94. package/src/law.ts +519 -0
  95. package/src/lower.ts +82 -27
  96. package/src/marshal.ts +48 -30
  97. package/src/native.ts +8 -4
  98. package/src/query/atom.ts +525 -374
  99. package/src/query/lower.ts +1469 -538
  100. package/src/query/predicate.ts +208 -161
  101. package/src/query/run.ts +35 -25
  102. package/src/query/scope.ts +264 -218
  103. package/src/query/select.ts +168 -93
  104. package/src/relation.ts +47 -47
  105. package/src/schema.ts +69 -18
  106. package/src/spec.ts +7 -5
  107. package/src/statements.ts +124 -41
  108. package/dist/brand.d.ts +0 -59
  109. package/dist/brand.d.ts.map +0 -1
  110. package/dist/brand.js +0 -47
  111. package/dist/brand.js.map +0 -1
  112. package/src/brand.ts +0 -82
package/src/index.ts CHANGED
@@ -1,23 +1,28 @@
1
1
  /**
2
2
  * @bjornpagen/bumbledb — the type-theoretic TypeScript SDK for the
3
- * bumbledb embedded relational engine. Public surface: the type kernel
4
- * (brands, fields, `relation()`, `closed()` — PRD-05), the statement
5
- * algebra with `schema()` and `SchemaSpec` lowering (PRD-06), the `Db`
3
+ * bumbledb embedded relational engine. Public surface: the structural type
4
+ * kernel (fields as pure structure, `relation()`, `closed()` — domains are
5
+ * never declared: THE LAWS TYPE THE COLUMNS, `schema()` computing every
6
+ * field's equivalence class FROM the statement list at both tiers), the
7
+ * statement algebra with `schema()` and `SchemaSpec` lowering (PRD-06), the `Db`
6
8
  * runtime (path-cached stores, transactions, typed violations, scoped
7
9
  * snapshot reads, the witnessed write loop with `abandon` — PRD-07, zero
8
- * closables), the query surface (Datalog as values: scoped vars/params,
9
- * atoms, negation, conditions, aggregates, engine recursion via predicates,
10
- * `db.prepare` as a plain value PRD-08), and the exhume surface
10
+ * closables), the query surface (Datalog as values, kysely-shaped:
11
+ * `query(S).rule(r => r.match(...).where(...).select(...))` with
12
+ * string-named domain-typed vars, params typed by use, negation,
13
+ * conditions, aggregates, and stratified recursion via `program()`/`rec` —
14
+ * `db.prepare` as a plain value; the comparison/connective builders are
15
+ * also free exports, and the free names `eq`/`not`/`and`/`or` collide with
16
+ * common host identifiers — import aliasing is the answer; the SDK does
17
+ * not rename for collision-avoidance), and the exhume surface
11
18
  * (`Db.exhume` — the one schema-independent read path: the store's
12
- * self-described shapes and raw facts by name, deliberately untyped
13
- * course-serialization PRD-02). The raw native bridge is not exported (the
14
- * PRD-03 stub died here as scheduled).
19
+ * self-described shapes and raw facts by name, typed at bare structural
20
+ * values, deliberately schema-free). The raw native bridge is not exported.
15
21
  */
16
22
 
17
- export type { Brand, Interval, IntervalValue } from "#brand.ts"
18
- export { span } from "#brand.ts"
19
23
  export type {
20
24
  AnyClosed,
25
+ AnySelectedClosed,
21
26
  AxiomRow,
22
27
  Axioms,
23
28
  Closed,
@@ -25,7 +30,9 @@ export type {
25
30
  ClosedCore,
26
31
  ClosedData,
27
32
  ClosedRow,
28
- PayloadField
33
+ ClosedSelectionInput,
34
+ PayloadField,
35
+ SelectedClosed
29
36
  } from "#closed.ts"
30
37
  export { closed } from "#closed.ts"
31
38
  export type { Count } from "#count.ts"
@@ -43,7 +50,7 @@ export type {
43
50
  WitnessedWriteResult,
44
51
  WriteResult
45
52
  } from "#db.ts"
46
- export { abandon, Db } from "#db.ts"
53
+ export { abandon, Db, ErrNewtypeMismatch } from "#db.ts"
47
54
  export type {
48
55
  Exhumed,
49
56
  ExhumedAxiom,
@@ -65,32 +72,31 @@ export type {
65
72
  FaceData,
66
73
  FaceFields,
67
74
  FaceOwner,
75
+ FaceShapeMismatch,
76
+ FaceShapes,
68
77
  FaceSource,
69
78
  OneOf,
70
- SameArity
79
+ OwnerOf,
80
+ SameArity,
81
+ SameShapes
71
82
  } from "#face.ts"
72
83
  export { on, oneOf } from "#face.ts"
73
84
  export type {
74
85
  AnyField,
75
86
  BoolField,
76
87
  BytesField,
77
- BytesNewtype,
78
88
  ClosedIdField,
79
89
  ClosedRoster,
80
- Field,
81
- FieldData,
82
- FieldValue,
83
- FreshU64Newtype,
90
+ FreshU64Field,
84
91
  I64Field,
85
- I64Newtype,
86
92
  Infer,
87
93
  IntervalField,
88
- IntervalNewtype,
94
+ IntervalValue,
89
95
  StrField,
90
- U64Field,
91
- U64Newtype
96
+ U64Field
92
97
  } from "#fields.ts"
93
- export { bool, bytes, i64, interval, str, u64 } from "#fields.ts"
98
+ export { bool, bytes, i64, interval, span, str, u64 } from "#fields.ts"
99
+ export type { ClassesOf, ClassWall, LawfulStatements, RelationClasses, SchemaClasses } from "#law.ts"
94
100
  export { lower, lowerClosed, lowerRelation } from "#lower.ts"
95
101
  export type { KeyFact, Minted } from "#marshal.ts"
96
102
  export type {
@@ -102,51 +108,53 @@ export type {
102
108
  } from "#native.ts"
103
109
 
104
110
  export type {
105
- AnyBodyItem,
106
- AnyCondition,
107
- ComparisonItem,
108
- ConditionTreeItem,
109
- Duration,
110
- MatchAtom,
111
- MatchInput,
112
- TermInput
113
- } from "#query/atom.ts"
114
-
115
- export {
116
- ALLEN,
117
- allen,
118
- and,
119
- covers,
120
- duration,
121
- ge,
122
- gt,
123
- is,
124
- le,
125
- lt,
126
- match,
127
- ne,
128
- not,
129
- or
111
+ AnyCond,
112
+ BindingInput,
113
+ Cmp,
114
+ MatchFields,
115
+ MatchOwner,
116
+ MatchShape,
117
+ NotAtom,
118
+ RecData,
119
+ RuleData,
120
+ SelectColumn,
121
+ Tree
130
122
  } from "#query/atom.ts"
131
-
123
+ export { ALLEN, allen, and, covers, eq, ge, gt, le, lt, ne, not, or, pointIn } from "#query/atom.ts"
132
124
  export type {
133
125
  AnyQuery,
126
+ AnyRuleValue,
127
+ OutputRuleChain,
128
+ OutputRuleScope,
134
129
  Query,
135
- QueryBuild,
130
+ QueryData,
136
131
  QueryParams,
132
+ QueryRelation,
137
133
  QueryRow,
138
- Scope
134
+ QueryRuleChain,
135
+ QueryRuleScope,
136
+ QueryStart,
137
+ RecRef,
138
+ RecRuleChain,
139
+ RecRuleScope,
140
+ RuleValue,
141
+ TermOps
139
142
  } from "#query/lower.ts"
140
143
  export { lowerQuery, query } from "#query/lower.ts"
144
+ export type { ProgramScope, Rec } from "#query/predicate.ts"
145
+ export { program } from "#query/predicate.ts"
141
146
  export type {
142
- Predicate,
143
- PredicateBindings,
144
- PredicateRuleInput,
145
- PredicateSelf
146
- } from "#query/predicate.ts"
147
- export type { MaskParam, Param, ParamSet, ParamsRecord, Var } from "#query/scope.ts"
148
- export type { Aggregate, RowOf, SelectShape } from "#query/select.ts"
149
- export { argmax, argmin, count, countDistinct, max, min, pack, sum } from "#query/select.ts"
147
+ ClassedField,
148
+ Duration,
149
+ MaskParam,
150
+ Param,
151
+ ParamEntry,
152
+ ParamsRecord,
153
+ SetParam,
154
+ Var,
155
+ VarsRecord
156
+ } from "#query/scope.ts"
157
+ export type { Agg, SelectEntry } from "#query/select.ts"
150
158
  export type {
151
159
  AnyRelation,
152
160
  AnySelected,
@@ -181,5 +189,14 @@ export type {
181
189
  WindowSpec
182
190
  } from "#spec.ts"
183
191
  export { renderLiteral, renderLiteralSet, renderWindow } from "#spec.ts"
184
- export type { KeyStatement, Statement, StatementData } from "#statements.ts"
192
+ export type {
193
+ ContainedStatement,
194
+ ContainmentData,
195
+ KeyData,
196
+ KeyStatement,
197
+ Statement,
198
+ StatementData,
199
+ WindowData,
200
+ WindowStatement
201
+ } from "#statements.ts"
185
202
  export { contained, key, mirrors, renderStatement, window } from "#statements.ts"