@hockeymask/core 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Khadim Fall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,127 @@
1
- # Temporary Holding Version
1
+ # @hockeymask/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Different schemas. Same story.**
4
+
5
+ Typed transformation graphs for mapping one data model onto another. A mapping is a
6
+ versioned JSON document: a DAG of collection nodes (`source`, `filter`, `map`, `join`,
7
+ `aggregate`, `distinct`, `union`, `sink`, ...) whose `map` nodes run small per-field
8
+ pipelines (`extract`, `trim`, `to_number`, `convert_unit`, `when`, ...).
9
+
10
+ The engine is pure. Your connectors read the sources, the engine compiles and checks the
11
+ mapping against your target schema, runs it over a frozen snapshot, and returns the rows each
12
+ sink would write. Writing them is up to you.
13
+
14
+ ```sh
15
+ npm install @hockeymask/core
16
+ ```
17
+
18
+ ## Example
19
+
20
+ ```ts
21
+ import { compileVersion, execute, parseVersion, type TargetSchema } from '@hockeymask/core'
22
+
23
+ const targets: TargetSchema = {
24
+ name: 'shop',
25
+ entities: [
26
+ {
27
+ name: 'product',
28
+ description: null,
29
+ identity: ['sku'],
30
+ fields: [
31
+ {
32
+ name: 'sku',
33
+ logicalType: 'string',
34
+ nullable: false,
35
+ description: null,
36
+ unit: null,
37
+ references: null,
38
+ },
39
+ {
40
+ name: 'title',
41
+ logicalType: 'string',
42
+ nullable: true,
43
+ description: null,
44
+ unit: null,
45
+ references: null,
46
+ },
47
+ {
48
+ name: 'weight_g',
49
+ logicalType: 'decimal',
50
+ nullable: true,
51
+ description: null,
52
+ unit: null,
53
+ references: null,
54
+ },
55
+ ],
56
+ },
57
+ ],
58
+ }
59
+
60
+ const version = parseVersion({
61
+ id: 'items-to-products',
62
+ expectedSchema: {
63
+ items: {
64
+ type: 'object',
65
+ properties: {
66
+ itemid: { type: 'string' },
67
+ displayname: { type: ['string', 'null'] },
68
+ weight_kg: { type: ['number', 'null'] },
69
+ },
70
+ required: ['itemid', 'displayname', 'weight_kg'],
71
+ },
72
+ },
73
+ nodes: [
74
+ { id: 'items', op: 'source', system: 'erp', entity: 'item' },
75
+ {
76
+ id: 'products',
77
+ op: 'map',
78
+ in: 'items',
79
+ fields: [
80
+ { key: 'product.sku', pipeline: [{ op: 'extract', path: 'itemid' }] },
81
+ {
82
+ key: 'product.title',
83
+ pipeline: [
84
+ { op: 'extract', path: 'displayname' },
85
+ { op: 'trim' },
86
+ { op: 'blank_to_null' },
87
+ ],
88
+ },
89
+ {
90
+ key: 'product.weight_g',
91
+ pipeline: [
92
+ { op: 'extract', path: 'weight_kg' },
93
+ { op: 'multiply', by: 1000 },
94
+ ],
95
+ },
96
+ ],
97
+ },
98
+ { id: 'out', op: 'sink', in: 'products', target: 'product', key: ['product.sku'] },
99
+ ],
100
+ })
101
+
102
+ const compiled = compileVersion(version, { targets })
103
+ if (!compiled.ok) throw new Error(compiled.issues.map((i) => i.message).join('\n'))
104
+
105
+ const result = execute(
106
+ compiled.plan,
107
+ { items: [{ itemid: 'A-1', displayname: ' Product A ', weight_kg: 2 }] },
108
+ { now: '2026-10-24T12:00:00Z' },
109
+ )
110
+ // result.sinks[0].write.rows:
111
+ // [{ 'product.sku': 'A-1', 'product.title': 'Product A', 'product.weight_g': 2000 }]
112
+ ```
113
+
114
+ ## What is in the package
115
+
116
+ - **Schema**: `Table`, `Column`, `Row`, `TargetSchema` (zod schemas with inferred types).
117
+ - **Connector**: the `Connector` contract a source fulfils (`listTables`, `describe`, `sample`,
118
+ `read`, `query`), plus `ConnectorError` and `SourceUnavailable`.
119
+ - **Mapping**: `parseVersion`, `compileVersion`, `readSnapshot`, `execute`, the node and
120
+ operator registry, expectations and examples (fixtures checked at compile time).
121
+
122
+ See the [architecture](https://github.com/mono424/hockeymask/blob/main/arch.md) and the
123
+ [operators reference](https://github.com/mono424/hockeymask/blob/main/docs/operators.md).
124
+
125
+ ## License
126
+
127
+ MIT