@hazeljs/data 0.2.0-alpha.1

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 (171) hide show
  1. package/LICENSE +192 -0
  2. package/README.md +308 -0
  3. package/dist/connectors/connector.interface.d.ts +29 -0
  4. package/dist/connectors/connector.interface.d.ts.map +1 -0
  5. package/dist/connectors/connector.interface.js +6 -0
  6. package/dist/connectors/csv.connector.d.ts +63 -0
  7. package/dist/connectors/csv.connector.d.ts.map +1 -0
  8. package/dist/connectors/csv.connector.js +147 -0
  9. package/dist/connectors/http.connector.d.ts +68 -0
  10. package/dist/connectors/http.connector.d.ts.map +1 -0
  11. package/dist/connectors/http.connector.js +131 -0
  12. package/dist/connectors/index.d.ts +7 -0
  13. package/dist/connectors/index.d.ts.map +1 -0
  14. package/dist/connectors/index.js +12 -0
  15. package/dist/connectors/memory.connector.d.ts +38 -0
  16. package/dist/connectors/memory.connector.d.ts.map +1 -0
  17. package/dist/connectors/memory.connector.js +56 -0
  18. package/dist/connectors/memory.connector.test.d.ts +2 -0
  19. package/dist/connectors/memory.connector.test.d.ts.map +1 -0
  20. package/dist/connectors/memory.connector.test.js +43 -0
  21. package/dist/data.module.d.ts +30 -0
  22. package/dist/data.module.d.ts.map +1 -0
  23. package/dist/data.module.js +120 -0
  24. package/dist/data.module.test.d.ts +2 -0
  25. package/dist/data.module.test.d.ts.map +1 -0
  26. package/dist/data.module.test.js +28 -0
  27. package/dist/data.types.d.ts +67 -0
  28. package/dist/data.types.d.ts.map +1 -0
  29. package/dist/data.types.js +5 -0
  30. package/dist/decorators/index.d.ts +6 -0
  31. package/dist/decorators/index.d.ts.map +1 -0
  32. package/dist/decorators/index.js +24 -0
  33. package/dist/decorators/pii.decorator.d.ts +59 -0
  34. package/dist/decorators/pii.decorator.d.ts.map +1 -0
  35. package/dist/decorators/pii.decorator.js +197 -0
  36. package/dist/decorators/pii.decorator.test.d.ts +2 -0
  37. package/dist/decorators/pii.decorator.test.d.ts.map +1 -0
  38. package/dist/decorators/pii.decorator.test.js +150 -0
  39. package/dist/decorators/pipeline.decorator.d.ts +22 -0
  40. package/dist/decorators/pipeline.decorator.d.ts.map +1 -0
  41. package/dist/decorators/pipeline.decorator.js +42 -0
  42. package/dist/decorators/pipeline.decorator.test.d.ts +2 -0
  43. package/dist/decorators/pipeline.decorator.test.d.ts.map +1 -0
  44. package/dist/decorators/pipeline.decorator.test.js +104 -0
  45. package/dist/decorators/stream.decorator.d.ts +31 -0
  46. package/dist/decorators/stream.decorator.d.ts.map +1 -0
  47. package/dist/decorators/stream.decorator.js +48 -0
  48. package/dist/decorators/transform.decorator.d.ts +29 -0
  49. package/dist/decorators/transform.decorator.d.ts.map +1 -0
  50. package/dist/decorators/transform.decorator.js +41 -0
  51. package/dist/decorators/validate.decorator.d.ts +34 -0
  52. package/dist/decorators/validate.decorator.d.ts.map +1 -0
  53. package/dist/decorators/validate.decorator.js +49 -0
  54. package/dist/flink.service.d.ts +80 -0
  55. package/dist/flink.service.d.ts.map +1 -0
  56. package/dist/flink.service.js +134 -0
  57. package/dist/flink.service.test.d.ts +2 -0
  58. package/dist/flink.service.test.d.ts.map +1 -0
  59. package/dist/flink.service.test.js +60 -0
  60. package/dist/index.d.ts +32 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +96 -0
  63. package/dist/pipelines/etl.service.d.ts +59 -0
  64. package/dist/pipelines/etl.service.d.ts.map +1 -0
  65. package/dist/pipelines/etl.service.js +223 -0
  66. package/dist/pipelines/etl.service.test.d.ts +2 -0
  67. package/dist/pipelines/etl.service.test.d.ts.map +1 -0
  68. package/dist/pipelines/etl.service.test.js +319 -0
  69. package/dist/pipelines/pipeline.base.d.ts +24 -0
  70. package/dist/pipelines/pipeline.base.d.ts.map +1 -0
  71. package/dist/pipelines/pipeline.base.js +29 -0
  72. package/dist/pipelines/pipeline.base.test.d.ts +2 -0
  73. package/dist/pipelines/pipeline.base.test.d.ts.map +1 -0
  74. package/dist/pipelines/pipeline.base.test.js +38 -0
  75. package/dist/pipelines/pipeline.builder.d.ts +95 -0
  76. package/dist/pipelines/pipeline.builder.d.ts.map +1 -0
  77. package/dist/pipelines/pipeline.builder.js +212 -0
  78. package/dist/pipelines/pipeline.builder.test.d.ts +2 -0
  79. package/dist/pipelines/pipeline.builder.test.d.ts.map +1 -0
  80. package/dist/pipelines/pipeline.builder.test.js +185 -0
  81. package/dist/pipelines/stream.service.d.ts +12 -0
  82. package/dist/pipelines/stream.service.d.ts.map +1 -0
  83. package/dist/pipelines/stream.service.js +58 -0
  84. package/dist/pipelines/stream.service.test.d.ts +2 -0
  85. package/dist/pipelines/stream.service.test.d.ts.map +1 -0
  86. package/dist/pipelines/stream.service.test.js +103 -0
  87. package/dist/quality/quality.service.d.ts +87 -0
  88. package/dist/quality/quality.service.d.ts.map +1 -0
  89. package/dist/quality/quality.service.js +326 -0
  90. package/dist/quality/quality.service.test.d.ts +2 -0
  91. package/dist/quality/quality.service.test.d.ts.map +1 -0
  92. package/dist/quality/quality.service.test.js +128 -0
  93. package/dist/schema/schema.d.ts +127 -0
  94. package/dist/schema/schema.d.ts.map +1 -0
  95. package/dist/schema/schema.js +487 -0
  96. package/dist/schema/schema.test.d.ts +2 -0
  97. package/dist/schema/schema.test.d.ts.map +1 -0
  98. package/dist/schema/schema.test.js +411 -0
  99. package/dist/streaming/flink/flink.client.d.ts +96 -0
  100. package/dist/streaming/flink/flink.client.d.ts.map +1 -0
  101. package/dist/streaming/flink/flink.client.js +267 -0
  102. package/dist/streaming/flink/flink.client.test.d.ts +2 -0
  103. package/dist/streaming/flink/flink.client.test.d.ts.map +1 -0
  104. package/dist/streaming/flink/flink.client.test.js +59 -0
  105. package/dist/streaming/flink/flink.job.d.ts +29 -0
  106. package/dist/streaming/flink/flink.job.d.ts.map +1 -0
  107. package/dist/streaming/flink/flink.job.js +27 -0
  108. package/dist/streaming/flink/flink.job.test.d.ts +2 -0
  109. package/dist/streaming/flink/flink.job.test.d.ts.map +1 -0
  110. package/dist/streaming/flink/flink.job.test.js +37 -0
  111. package/dist/streaming/flink/flink.operators.d.ts +35 -0
  112. package/dist/streaming/flink/flink.operators.d.ts.map +1 -0
  113. package/dist/streaming/flink/flink.operators.js +43 -0
  114. package/dist/streaming/flink/flink.operators.test.d.ts +2 -0
  115. package/dist/streaming/flink/flink.operators.test.d.ts.map +1 -0
  116. package/dist/streaming/flink/flink.operators.test.js +38 -0
  117. package/dist/streaming/stream.builder.d.ts +22 -0
  118. package/dist/streaming/stream.builder.d.ts.map +1 -0
  119. package/dist/streaming/stream.builder.js +50 -0
  120. package/dist/streaming/stream.builder.test.d.ts +2 -0
  121. package/dist/streaming/stream.builder.test.d.ts.map +1 -0
  122. package/dist/streaming/stream.builder.test.js +59 -0
  123. package/dist/streaming/stream.processor.d.ts +66 -0
  124. package/dist/streaming/stream.processor.d.ts.map +1 -0
  125. package/dist/streaming/stream.processor.js +178 -0
  126. package/dist/streaming/stream.processor.test.d.ts +2 -0
  127. package/dist/streaming/stream.processor.test.d.ts.map +1 -0
  128. package/dist/streaming/stream.processor.test.js +151 -0
  129. package/dist/streaming/stream.processor.windowing.test.d.ts +2 -0
  130. package/dist/streaming/stream.processor.windowing.test.d.ts.map +1 -0
  131. package/dist/streaming/stream.processor.windowing.test.js +69 -0
  132. package/dist/telemetry/telemetry.d.ts +124 -0
  133. package/dist/telemetry/telemetry.d.ts.map +1 -0
  134. package/dist/telemetry/telemetry.js +259 -0
  135. package/dist/telemetry/telemetry.test.d.ts +2 -0
  136. package/dist/telemetry/telemetry.test.d.ts.map +1 -0
  137. package/dist/telemetry/telemetry.test.js +51 -0
  138. package/dist/testing/index.d.ts +12 -0
  139. package/dist/testing/index.d.ts.map +1 -0
  140. package/dist/testing/index.js +18 -0
  141. package/dist/testing/pipeline-test-harness.d.ts +40 -0
  142. package/dist/testing/pipeline-test-harness.d.ts.map +1 -0
  143. package/dist/testing/pipeline-test-harness.js +55 -0
  144. package/dist/testing/pipeline-test-harness.test.d.ts +2 -0
  145. package/dist/testing/pipeline-test-harness.test.d.ts.map +1 -0
  146. package/dist/testing/pipeline-test-harness.test.js +102 -0
  147. package/dist/testing/schema-faker.d.ts +32 -0
  148. package/dist/testing/schema-faker.d.ts.map +1 -0
  149. package/dist/testing/schema-faker.js +91 -0
  150. package/dist/testing/schema-faker.test.d.ts +2 -0
  151. package/dist/testing/schema-faker.test.d.ts.map +1 -0
  152. package/dist/testing/schema-faker.test.js +66 -0
  153. package/dist/transformers/built-in.transformers.d.ts +12 -0
  154. package/dist/transformers/built-in.transformers.d.ts.map +1 -0
  155. package/dist/transformers/built-in.transformers.js +75 -0
  156. package/dist/transformers/built-in.transformers.test.d.ts +2 -0
  157. package/dist/transformers/built-in.transformers.test.d.ts.map +1 -0
  158. package/dist/transformers/built-in.transformers.test.js +85 -0
  159. package/dist/transformers/transformer.service.d.ts +14 -0
  160. package/dist/transformers/transformer.service.d.ts.map +1 -0
  161. package/dist/transformers/transformer.service.js +65 -0
  162. package/dist/transformers/transformer.service.test.d.ts +2 -0
  163. package/dist/transformers/transformer.service.test.d.ts.map +1 -0
  164. package/dist/transformers/transformer.service.test.js +42 -0
  165. package/dist/validators/schema.validator.d.ts +21 -0
  166. package/dist/validators/schema.validator.d.ts.map +1 -0
  167. package/dist/validators/schema.validator.js +40 -0
  168. package/dist/validators/schema.validator.test.d.ts +2 -0
  169. package/dist/validators/schema.validator.test.d.ts.map +1 -0
  170. package/dist/validators/schema.validator.test.js +42 -0
  171. package/package.json +53 -0
package/LICENSE ADDED
@@ -0,0 +1,192 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2024 HazelJS Team
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ ---
20
+
21
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
22
+
23
+ 1. Definitions.
24
+
25
+ "License" shall mean the terms and conditions for use, reproduction,
26
+ and distribution as defined by Sections 1 through 9 of this document.
27
+
28
+ "Licensor" shall mean the copyright owner or entity authorized by
29
+ the copyright owner that is granting the License.
30
+
31
+ "Legal Entity" shall mean the union of the acting entity and all
32
+ other entities that control, are controlled by, or are under common
33
+ control with that entity. For the purposes of this definition,
34
+ "control" means (i) the power, direct or indirect, to cause the
35
+ direction or management of such entity, whether by contract or
36
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
37
+ outstanding shares, or (iii) beneficial ownership of such entity.
38
+
39
+ "You" (or "Your") shall mean an individual or Legal Entity
40
+ exercising permissions granted by this License.
41
+
42
+ "Source" form shall mean the preferred form for making modifications,
43
+ including but not limited to software source code, documentation
44
+ source, and configuration files.
45
+
46
+ "Object" form shall mean any form resulting from mechanical
47
+ transformation or translation of a Source form, including but
48
+ not limited to compiled object code, generated documentation,
49
+ and conversions to other media types.
50
+
51
+ "Work" shall mean the work of authorship, whether in Source or
52
+ Object form, made available under the License, as indicated by a
53
+ copyright notice that is included in or attached to the work
54
+ (an example is provided in the Appendix below).
55
+
56
+ "Derivative Works" shall mean any work, whether in Source or Object
57
+ form, that is based on (or derived from) the Work and for which the
58
+ editorial revisions, annotations, elaborations, or other modifications
59
+ represent, as a whole, an original work of authorship. For the purposes
60
+ of this License, Derivative Works shall not include works that remain
61
+ separable from, or merely link (or bind by name) to the interfaces of,
62
+ the Work and Derivative Works thereof.
63
+
64
+ "Contribution" shall mean any work of authorship, including
65
+ the original version of the Work and any modifications or additions
66
+ to that Work or Derivative Works thereof, that is intentionally
67
+ submitted to Licensor for inclusion in the Work by the copyright owner
68
+ or by an individual or Legal Entity authorized to submit on behalf of
69
+ the copyright owner. For the purposes of this definition, "submitted"
70
+ means any form of electronic, verbal, or written communication sent
71
+ to the Licensor or its representatives, including but not limited to
72
+ communication on electronic mailing lists, source code control systems,
73
+ and issue tracking systems that are managed by, or on behalf of, the
74
+ Licensor for the purpose of discussing and improving the Work, but
75
+ excluding communication that is conspicuously marked or otherwise
76
+ designated in writing by the copyright owner as "Not a Contribution."
77
+
78
+ "Contributor" shall mean Licensor and any individual or Legal Entity
79
+ on behalf of whom a Contribution has been received by Licensor and
80
+ subsequently incorporated within the Work.
81
+
82
+ 2. Grant of Copyright License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ copyright license to reproduce, prepare Derivative Works of,
86
+ publicly display, publicly perform, sublicense, and distribute the
87
+ Work and such Derivative Works in Source or Object form.
88
+
89
+ 3. Grant of Patent License. Subject to the terms and conditions of
90
+ this License, each Contributor hereby grants to You a perpetual,
91
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
92
+ (except as stated in this section) patent license to make, have made,
93
+ use, offer to sell, sell, import, and otherwise transfer the Work,
94
+ where such license applies only to those patent claims licensable
95
+ by such Contributor that are necessarily infringed by their
96
+ Contribution(s) alone or by combination of their Contribution(s)
97
+ with the Work to which such Contribution(s) was submitted. If You
98
+ institute patent litigation against any entity (including a
99
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
100
+ or a Contribution incorporated within the Work constitutes direct
101
+ or contributory patent infringement, then any patent licenses
102
+ granted to You under this License for that Work shall terminate
103
+ as of the date such litigation is filed.
104
+
105
+ 4. Redistribution. You may reproduce and distribute copies of the
106
+ Work or Derivative Works thereof in any medium, with or without
107
+ modifications, and in Source or Object form, provided that You
108
+ meet the following conditions:
109
+
110
+ (a) You must give any other recipients of the Work or
111
+ Derivative Works a copy of this License; and
112
+
113
+ (b) You must cause any modified files to carry prominent notices
114
+ stating that You changed the files; and
115
+
116
+ (c) You must retain, in the Source form of any Derivative Works
117
+ that You distribute, all copyright, patent, trademark, and
118
+ attribution notices from the Source form of the Work,
119
+ excluding those notices that do not pertain to any part of
120
+ the Derivative Works; and
121
+
122
+ (d) If the Work includes a "NOTICE" text file as part of its
123
+ distribution, then any Derivative Works that You distribute must
124
+ include a readable copy of the attribution notices contained
125
+ within such NOTICE file, excluding those notices that do not
126
+ pertain to any part of the Derivative Works, in at least one
127
+ of the following places: within a NOTICE text file distributed
128
+ as part of the Derivative Works; within the Source form or
129
+ documentation, if provided along with the Derivative Works; or,
130
+ within a display generated by the Derivative Works, if and
131
+ wherever such third-party notices normally appear. The contents
132
+ of the NOTICE file are for informational purposes only and
133
+ do not modify the License. You may add Your own attribution
134
+ notices within Derivative Works that You distribute, alongside
135
+ or as an addendum to the NOTICE text from the Work, provided
136
+ that such additional attribution notices cannot be construed
137
+ as modifying the License.
138
+
139
+ You may add Your own copyright statement to Your modifications and
140
+ may provide additional or different license terms and conditions
141
+ for use, reproduction, or distribution of Your modifications, or
142
+ for any such Derivative Works as a whole, provided Your use,
143
+ reproduction, and distribution of the Work otherwise complies with
144
+ the conditions stated in this License.
145
+
146
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
147
+ any Contribution intentionally submitted for inclusion in the Work
148
+ by You to the Licensor shall be under the terms and conditions of
149
+ this License, without any additional terms or conditions.
150
+ Notwithstanding the above, nothing herein shall supersede or modify
151
+ the terms of any separate license agreement you may have executed
152
+ with Licensor regarding such Contributions.
153
+
154
+ 6. Trademarks. This License does not grant permission to use the trade
155
+ names, trademarks, service marks, or product names of the Licensor,
156
+ except as required for reasonable and customary use in describing the
157
+ origin of the Work and reproducing the content of the NOTICE file.
158
+
159
+ 7. Disclaimer of Warranty. Unless required by applicable law or
160
+ agreed to in writing, Licensor provides the Work (and each
161
+ Contributor provides its Contributions) on an "AS IS" BASIS,
162
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
163
+ implied, including, without limitation, any warranties or conditions
164
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
165
+ PARTICULAR PURPOSE. You are solely responsible for determining the
166
+ appropriateness of using or redistributing the Work and assume any
167
+ risks associated with Your exercise of permissions under this License.
168
+
169
+ 8. Limitation of Liability. In no event and under no legal theory,
170
+ whether in tort (including negligence), contract, or otherwise,
171
+ unless required by applicable law (such as deliberate and grossly
172
+ negligent acts) or agreed to in writing, shall any Contributor be
173
+ liable to You for damages, including any direct, indirect, special,
174
+ incidental, or consequential damages of any character arising as a
175
+ result of this License or out of the use or inability to use the
176
+ Work (including but not limited to damages for loss of goodwill,
177
+ work stoppage, computer failure or malfunction, or any and all
178
+ other commercial damages or losses), even if such Contributor
179
+ has been advised of the possibility of such damages.
180
+
181
+ 9. Accepting Warranty or Additional Liability. While redistributing
182
+ the Work or Derivative Works thereof, You may choose to offer,
183
+ and charge a fee for, acceptance of support, warranty, indemnity,
184
+ or other liability obligations and/or rights consistent with this
185
+ License. However, in accepting such obligations, You may act only
186
+ on Your own behalf and on Your sole responsibility, not on behalf
187
+ of any other Contributor, and only if You agree to indemnify,
188
+ defend, and hold each Contributor harmless for any liability
189
+ incurred by, or claims asserted against, such Contributor by reason
190
+ of your accepting any such warranty or additional liability.
191
+
192
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,308 @@
1
+ # @hazeljs/data
2
+
3
+ Data Processing & ETL for HazelJS - pipelines, schema validation, streaming, data quality, and more.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@hazeljs/data.svg)](https://www.npmjs.com/package/@hazeljs/data)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@hazeljs/data)](https://www.npmjs.com/package/@hazeljs/data)
7
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
8
+
9
+ ## Features
10
+
11
+ - **Pipelines** – Declarative ETL with `@Pipeline`, `@Transform`, `@Validate` decorators
12
+ - **Schema validation** – Fluent Schema API (string, number, boolean, date, object, array, literal, union) with `.optional()`, `.nullable()`, `.default()`, `.transform()`, `.refine()`, `Infer<T>`, `.toJsonSchema()`
13
+ - **Pipeline options** – Conditional steps (`when`), per-step retry, timeout, dead letter queue (DLQ)
14
+ - **PipelineBuilder** – Programmatic pipelines with `.branch()`, `.parallel()`, `.catch()`, `.toSchema()`
15
+ - **ETL service** – Execute multi-step pipelines with `executeBatch`, `onStepComplete`
16
+ - **Stream processing** – StreamService, StreamProcessor with tumbling/sliding/session windows and stream join
17
+ - **Built-in transformers** – trimString, toLowerCase, toUpperCase, parseJson, stringifyJson, pick, omit, renameKeys
18
+ - **Data quality** – QualityService with completeness, notNull, uniqueness, range, pattern, referentialIntegrity, profile(), detectAnomalies()
19
+ - **Connectors** – DataSource/DataSink (MemorySource, MemorySink, CsvSource, HttpSource)
20
+ - **PII decorators** – @Mask, @Redact, @Encrypt, @Decrypt for sensitive data
21
+ - **Test utilities** – SchemaFaker, PipelineTestHarness, MockSource, MockSink
22
+ - **Flink integration** – Optional Apache Flink deployment for distributed stream processing
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npm install @hazeljs/data @hazeljs/core
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ### 1. Import DataModule
33
+
34
+ ```typescript
35
+ import { HazelApp } from '@hazeljs/core';
36
+ import { DataModule } from '@hazeljs/data';
37
+
38
+ const app = new HazelApp({
39
+ imports: [DataModule.forRoot()],
40
+ });
41
+
42
+ app.listen(3000);
43
+ ```
44
+
45
+ ### 2. Define a pipeline with decorators
46
+
47
+ ```typescript
48
+ import { Injectable } from '@hazeljs/core';
49
+ import {
50
+ Pipeline,
51
+ PipelineBase,
52
+ Transform,
53
+ Validate,
54
+ ETLService,
55
+ Schema,
56
+ Infer,
57
+ } from '@hazeljs/data';
58
+
59
+ const OrderSchema = Schema.object({
60
+ id: Schema.string().min(1),
61
+ customerId: Schema.string().min(1),
62
+ items: Schema.array(
63
+ Schema.object({
64
+ sku: Schema.string().min(1),
65
+ qty: Schema.number().min(1),
66
+ price: Schema.number().min(0),
67
+ })
68
+ ),
69
+ status: Schema.string().oneOf(['pending', 'paid', 'shipped', 'delivered', 'cancelled']),
70
+ createdAt: Schema.string().min(1),
71
+ });
72
+
73
+ type Order = Infer<typeof OrderSchema>;
74
+
75
+ @Pipeline('order-processing')
76
+ @Injectable()
77
+ export class OrderProcessingPipeline extends PipelineBase {
78
+ constructor(etlService: ETLService) {
79
+ super(etlService);
80
+ }
81
+
82
+ @Transform({ step: 1, name: 'normalize' })
83
+ async normalize(data: unknown): Promise<Order> {
84
+ return { ...(data as Order), status: String((data as Order).status).toLowerCase() };
85
+ }
86
+
87
+ @Validate({ step: 2, name: 'validate', schema: OrderSchema })
88
+ async validate(data: Order): Promise<Order> {
89
+ return data;
90
+ }
91
+
92
+ @Transform({ step: 3, name: 'enrich' })
93
+ async enrich(data: Order): Promise<Order & { total: number; tax: number }> {
94
+ const items = data.items ?? [];
95
+ const subtotal = items.reduce((sum, i) => sum + i.qty * i.price, 0);
96
+ const tax = subtotal * 0.1;
97
+ return { ...data, subtotal, tax, total: subtotal + tax };
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### 3. Execute from a controller or service
103
+
104
+ ```typescript
105
+ import { Controller, Post, Body, Inject } from '@hazeljs/core';
106
+ import { OrderProcessingPipeline } from './pipelines/order-processing.pipeline';
107
+
108
+ @Controller('data')
109
+ export class DataController {
110
+ constructor(
111
+ @Inject(OrderProcessingPipeline) private pipeline: OrderProcessingPipeline
112
+ ) {}
113
+
114
+ @Post('pipeline/orders')
115
+ async processOrder(@Body() body: unknown) {
116
+ const result = await this.pipeline.execute(body);
117
+ return { ok: true, data: result };
118
+ }
119
+ }
120
+ ```
121
+
122
+ ## Schema validation
123
+
124
+ Build schemas with the fluent API. Full type inference via `Infer<T>`:
125
+
126
+ ```typescript
127
+ import { Schema, Infer, SchemaValidator } from '@hazeljs/data';
128
+
129
+ const UserSchema = Schema.object({
130
+ email: Schema.string().email(),
131
+ name: Schema.string().min(1).max(200),
132
+ age: Schema.number().min(0).max(150),
133
+ role: Schema.string().oneOf(['user', 'admin', 'moderator', 'guest']),
134
+ active: Schema.boolean().default(true),
135
+ });
136
+
137
+ type User = Infer<typeof UserSchema>;
138
+
139
+ // Validate (throws on failure)
140
+ const validator = new SchemaValidator();
141
+ const user = validator.validate(UserSchema, rawData);
142
+
143
+ // Safe validate (returns result)
144
+ const result = validator.safeValidate(UserSchema, rawData);
145
+ if (result.success) {
146
+ const user = result.data;
147
+ } else {
148
+ console.error(result.errors);
149
+ }
150
+ ```
151
+
152
+ ### Schema types and modifiers
153
+
154
+ | Type | Example |
155
+ |------|---------|
156
+ | `Schema.string()` | `.email()`, `.url()`, `.min()`, `.max()`, `.uuid()`, `.oneOf()`, `.pattern()`, `.required()`, `.trim()` |
157
+ | `Schema.number()` | `.min()`, `.max()`, `.integer()`, `.positive()`, `.negative()`, `.multipleOf()` |
158
+ | `Schema.boolean()` | `.default()` |
159
+ | `Schema.date()` | `.min()`, `.max()`, `.default()` |
160
+ | `Schema.object({...})` | `.strict()`, `.pick()`, `.omit()`, `.extend()` |
161
+ | `Schema.array(itemSchema)` | `.min()`, `.max()`, `.nonempty()` |
162
+ | `Schema.literal(value)` | Literal values |
163
+ | `Schema.union([a, b])` | Discriminated unions |
164
+ | Modifiers | `.optional()`, `.nullable()`, `.default()`, `.transform()`, `.refine()`, `.refineAsync()` |
165
+
166
+ ## Pipeline options
167
+
168
+ Steps support conditional execution, retry, timeout, and DLQ:
169
+
170
+ ```typescript
171
+ @Transform({
172
+ step: 2,
173
+ name: 'enrich',
174
+ when: (data) => (data as { type: string }).type === 'order',
175
+ retry: { attempts: 3, delay: 500, backoff: 'exponential' },
176
+ timeoutMs: 5000,
177
+ dlq: { handler: (item, err, step) => logger.error('DLQ', { item, err, step }) },
178
+ })
179
+ async enrich(data: unknown) {
180
+ return { ...data, enriched: true };
181
+ }
182
+ ```
183
+
184
+ ## PipelineBuilder (programmatic pipelines)
185
+
186
+ Build pipelines in code without decorators:
187
+
188
+ ```typescript
189
+ import { PipelineBuilder } from '@hazeljs/data';
190
+
191
+ const pipeline = new PipelineBuilder('orders')
192
+ .addTransform('normalize', (d) => ({ ...d, email: (d as { email: string }).email?.toLowerCase() }))
193
+ .branch(
194
+ 'classify',
195
+ (d) => (d as { type: string }).type === 'premium',
196
+ (b) => b.addTransform('enrichPremium', enrichPremium),
197
+ (b) => b.addTransform('enrichStandard', enrichStandard)
198
+ )
199
+ .parallel('enrich', [
200
+ (d) => ({ ...d, a: 1 }),
201
+ (d) => ({ ...d, b: 2 }),
202
+ ])
203
+ .catch((data, err) => ({ ...data, error: err.message }));
204
+
205
+ const result = await pipeline.execute(rawData);
206
+ ```
207
+
208
+ ## Batch and stream processing
209
+
210
+ ```typescript
211
+ import { StreamService, StreamProcessor } from '@hazeljs/data';
212
+
213
+ // Batch
214
+ const results = await streamService.processBatch(pipeline, items);
215
+
216
+ // Streaming with windowing
217
+ const processor = new StreamProcessor(etlService);
218
+ for await (const batch of processor.tumblingWindow(source, 60_000)) {
219
+ console.log(batch.items, batch.windowStart, batch.windowEnd);
220
+ }
221
+ // Also: slidingWindow, sessionWindow, joinStreams
222
+ ```
223
+
224
+ ## Data quality
225
+
226
+ ```typescript
227
+ import { QualityService } from '@hazeljs/data';
228
+
229
+ const qualityService = new QualityService();
230
+
231
+ qualityService.registerCheck('completeness', qualityService.completeness(['id', 'email']));
232
+ qualityService.registerCheck('notNull', qualityService.notNull(['id']));
233
+ qualityService.registerCheck('uniqueness', qualityService.uniqueness(['id']));
234
+ qualityService.registerCheck('range', qualityService.range('age', { min: 0, max: 120 }));
235
+ qualityService.registerCheck('pattern', qualityService.pattern('phone', /^\d{10}$/));
236
+ qualityService.registerCheck('ref', qualityService.referentialIntegrity('status', ['active', 'inactive']));
237
+
238
+ const report = await qualityService.runChecks('users', records);
239
+ const profile = qualityService.profile('users', records);
240
+ const anomalies = qualityService.detectAnomalies(records, ['value'], 2);
241
+ ```
242
+
243
+ ## PII decorators
244
+
245
+ ```typescript
246
+ import { Transform, Mask, Redact } from '@hazeljs/data';
247
+
248
+ @Transform({ step: 1, name: 'sanitize' })
249
+ @Mask({ fields: ['email', 'ssn'], showLast: 4 })
250
+ sanitize(data: User) {
251
+ return data; // email/ssn already masked
252
+ }
253
+
254
+ @Transform({ step: 2, name: 'redact' })
255
+ @Redact({ fields: ['internalId'] })
256
+ redact(data: Record<string, unknown>) {
257
+ return data; // internalId removed
258
+ }
259
+ ```
260
+
261
+ ## Test utilities
262
+
263
+ ```typescript
264
+ import { SchemaFaker, PipelineTestHarness, MockSource, MockSink } from '@hazeljs/data';
265
+
266
+ const fake = SchemaFaker.generate(UserSchema);
267
+ const many = SchemaFaker.generateMany(UserSchema, 10);
268
+
269
+ const harness = PipelineTestHarness.create(etlService, pipeline);
270
+ const { result, events } = await harness.run(input);
271
+ await harness.runAndAssertSuccess(input);
272
+
273
+ const source = new MockSource([{ x: 1 }]);
274
+ const sink = new MockSink();
275
+ ```
276
+
277
+ ## Built-in transformers
278
+
279
+ | Transformer | Description |
280
+ |-------------|-------------|
281
+ | `trimString` | Trim whitespace from strings |
282
+ | `toLowerCase` / `toUpperCase` | Case conversion |
283
+ | `parseJson` / `stringifyJson` | JSON parsing and serialization |
284
+ | `pick` | Select specific keys from objects |
285
+ | `omit` | Remove specific keys from objects |
286
+ | `renameKeys` | Rename object keys |
287
+
288
+ ## Flink configuration (optional)
289
+
290
+ ```typescript
291
+ DataModule.forRoot({
292
+ flink: {
293
+ url: process.env.FLINK_REST_URL ?? 'http://localhost:8081',
294
+ timeout: 30000,
295
+ },
296
+ });
297
+ ```
298
+
299
+ ## Example
300
+
301
+ See [hazeljs-data-starter](../../../hazeljs-data-starter) for a full example with order and user pipelines, PipelineBuilder, PII decorators, quality profiling, anomaly detection, and REST API.
302
+
303
+ ## Links
304
+
305
+ - [Documentation](https://hazeljs.com/docs/packages/data)
306
+ - [GitHub](https://github.com/hazel-js/hazeljs)
307
+ - [Issues](https://github.com/hazel-js/hazeljs/issues)
308
+ - [Homepage](https://hazeljs.com)
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Connector interfaces for data sources and sinks.
3
+ * All connectors implement DataSource<T> or DataSink<T>.
4
+ */
5
+ export interface DataSource<T = unknown> {
6
+ readonly name: string;
7
+ /** Open/initialize the connection */
8
+ open(): Promise<void>;
9
+ /** Close/release the connection */
10
+ close(): Promise<void>;
11
+ /** Read all records as an array */
12
+ readAll(): Promise<T[]>;
13
+ /** Read records as an async generator (streaming) */
14
+ read(): AsyncGenerator<T>;
15
+ }
16
+ export interface DataSink<T = unknown> {
17
+ readonly name: string;
18
+ open(): Promise<void>;
19
+ close(): Promise<void>;
20
+ /** Write a single record */
21
+ write(record: T): Promise<void>;
22
+ /** Write a batch of records (more efficient when supported) */
23
+ writeBatch(records: T[]): Promise<void>;
24
+ }
25
+ export interface ConnectorOptions {
26
+ /** Connector display name */
27
+ name?: string;
28
+ }
29
+ //# sourceMappingURL=connector.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.interface.d.ts","sourceRoot":"","sources":["../../src/connectors/connector.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,mCAAmC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,mCAAmC;IACnC,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACxB,qDAAqD;IACrD,IAAI,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,4BAA4B;IAC5B,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,+DAA+D;IAC/D,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Connector interfaces for data sources and sinks.
4
+ * All connectors implement DataSource<T> or DataSink<T>.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,63 @@
1
+ import type { DataSource, DataSink } from './connector.interface';
2
+ export interface CsvSourceOptions {
3
+ filePath: string;
4
+ delimiter?: string;
5
+ hasHeader?: boolean;
6
+ /** Custom header names (used when hasHeader is false) */
7
+ headers?: string[];
8
+ name?: string;
9
+ }
10
+ export interface CsvSinkOptions {
11
+ filePath: string;
12
+ delimiter?: string;
13
+ /** Write header row on open */
14
+ writeHeader?: boolean;
15
+ name?: string;
16
+ }
17
+ /**
18
+ * CSV file data source — reads records from a CSV file.
19
+ *
20
+ * @example
21
+ * const source = new CsvSource({ filePath: './data.csv', hasHeader: true });
22
+ * await source.open();
23
+ * const records = await source.readAll();
24
+ * await source.close();
25
+ */
26
+ export declare class CsvSource implements DataSource<Record<string, string>> {
27
+ readonly name: string;
28
+ private readonly filePath;
29
+ private readonly delimiter;
30
+ private readonly hasHeader;
31
+ private readonly customHeaders?;
32
+ constructor(options: CsvSourceOptions);
33
+ open(): Promise<void>;
34
+ close(): Promise<void>;
35
+ readAll(): Promise<Record<string, string>[]>;
36
+ read(): AsyncGenerator<Record<string, string>>;
37
+ private parseLine;
38
+ }
39
+ /**
40
+ * CSV file data sink — writes records to a CSV file.
41
+ *
42
+ * @example
43
+ * const sink = new CsvSink({ filePath: './output.csv', writeHeader: true });
44
+ * await sink.open();
45
+ * await sink.writeBatch(records);
46
+ * await sink.close();
47
+ */
48
+ export declare class CsvSink implements DataSink<Record<string, unknown>> {
49
+ readonly name: string;
50
+ private readonly filePath;
51
+ private readonly delimiter;
52
+ private readonly writeHeader;
53
+ private headers;
54
+ private stream;
55
+ private headerWritten;
56
+ constructor(options: CsvSinkOptions);
57
+ open(): Promise<void>;
58
+ close(): Promise<void>;
59
+ write(record: Record<string, unknown>): Promise<void>;
60
+ writeBatch(records: Record<string, unknown>[]): Promise<void>;
61
+ private writeLine;
62
+ }
63
+ //# sourceMappingURL=csv.connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.connector.d.ts","sourceRoot":"","sources":["../../src/connectors/csv.connector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,qBAAa,SAAU,YAAW,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAU;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAW;gBAE9B,OAAO,EAAE,gBAAgB;IAQ/B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAQ3C,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IA4BrD,OAAO,CAAC,SAAS;CAwBlB;AAED;;;;;;;;GAQG;AACH,qBAAa,OAAQ,YAAW,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,MAAM,CAAqD;IACnE,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,EAAE,cAAc;IAO7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAUtB,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAerD,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE,OAAO,CAAC,SAAS;CAWlB"}