@hazeljs/data 0.7.9 → 0.8.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 (2) hide show
  1. package/README.md +29 -28
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -107,9 +107,7 @@ import { OrderProcessingPipeline } from './pipelines/order-processing.pipeline';
107
107
 
108
108
  @Controller('data')
109
109
  export class DataController {
110
- constructor(
111
- @Inject(OrderProcessingPipeline) private pipeline: OrderProcessingPipeline
112
- ) {}
110
+ constructor(@Inject(OrderProcessingPipeline) private pipeline: OrderProcessingPipeline) {}
113
111
 
114
112
  @Post('pipeline/orders')
115
113
  async processOrder(@Body() body: unknown) {
@@ -151,17 +149,17 @@ if (result.success) {
151
149
 
152
150
  ### Schema types and modifiers
153
151
 
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()` |
152
+ | Type | Example |
153
+ | -------------------------- | ------------------------------------------------------------------------------------------------------- |
154
+ | `Schema.string()` | `.email()`, `.url()`, `.min()`, `.max()`, `.uuid()`, `.oneOf()`, `.pattern()`, `.required()`, `.trim()` |
155
+ | `Schema.number()` | `.min()`, `.max()`, `.integer()`, `.positive()`, `.negative()`, `.multipleOf()` |
156
+ | `Schema.boolean()` | `.default()` |
157
+ | `Schema.date()` | `.min()`, `.max()`, `.default()` |
158
+ | `Schema.object({...})` | `.strict()`, `.pick()`, `.omit()`, `.extend()` |
159
+ | `Schema.array(itemSchema)` | `.min()`, `.max()`, `.nonempty()` |
160
+ | `Schema.literal(value)` | Literal values |
161
+ | `Schema.union([a, b])` | Discriminated unions |
162
+ | Modifiers | `.optional()`, `.nullable()`, `.default()`, `.transform()`, `.refine()`, `.refineAsync()` |
165
163
 
166
164
  ## Pipeline options
167
165
 
@@ -189,17 +187,17 @@ Build pipelines in code without decorators:
189
187
  import { PipelineBuilder } from '@hazeljs/data';
190
188
 
191
189
  const pipeline = new PipelineBuilder('orders')
192
- .addTransform('normalize', (d) => ({ ...d, email: (d as { email: string }).email?.toLowerCase() }))
190
+ .addTransform('normalize', (d) => ({
191
+ ...d,
192
+ email: (d as { email: string }).email?.toLowerCase(),
193
+ }))
193
194
  .branch(
194
195
  'classify',
195
196
  (d) => (d as { type: string }).type === 'premium',
196
197
  (b) => b.addTransform('enrichPremium', enrichPremium),
197
198
  (b) => b.addTransform('enrichStandard', enrichStandard)
198
199
  )
199
- .parallel('enrich', [
200
- (d) => ({ ...d, a: 1 }),
201
- (d) => ({ ...d, b: 2 }),
202
- ])
200
+ .parallel('enrich', [(d) => ({ ...d, a: 1 }), (d) => ({ ...d, b: 2 })])
203
201
  .catch((data, err) => ({ ...data, error: err.message }));
204
202
 
205
203
  const result = await pipeline.execute(rawData);
@@ -233,7 +231,10 @@ qualityService.registerCheck('notNull', qualityService.notNull(['id']));
233
231
  qualityService.registerCheck('uniqueness', qualityService.uniqueness(['id']));
234
232
  qualityService.registerCheck('range', qualityService.range('age', { min: 0, max: 120 }));
235
233
  qualityService.registerCheck('pattern', qualityService.pattern('phone', /^\d{10}$/));
236
- qualityService.registerCheck('ref', qualityService.referentialIntegrity('status', ['active', 'inactive']));
234
+ qualityService.registerCheck(
235
+ 'ref',
236
+ qualityService.referentialIntegrity('status', ['active', 'inactive'])
237
+ );
237
238
 
238
239
  const report = await qualityService.runChecks('users', records);
239
240
  const profile = qualityService.profile('users', records);
@@ -276,14 +277,14 @@ const sink = new MockSink();
276
277
 
277
278
  ## Built-in transformers
278
279
 
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 |
280
+ | Transformer | Description |
281
+ | ----------------------------- | --------------------------------- |
282
+ | `trimString` | Trim whitespace from strings |
283
+ | `toLowerCase` / `toUpperCase` | Case conversion |
284
+ | `parseJson` / `stringifyJson` | JSON parsing and serialization |
285
+ | `pick` | Select specific keys from objects |
286
+ | `omit` | Remove specific keys from objects |
287
+ | `renameKeys` | Rename object keys |
287
288
 
288
289
  ## Flink configuration (optional)
289
290
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hazeljs/data",
3
- "version": "0.7.9",
3
+ "version": "0.8.1",
4
4
  "description": "Data Processing & ETL for HazelJS framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -49,5 +49,5 @@
49
49
  "url": "https://github.com/hazeljs/hazel-js/issues"
50
50
  },
51
51
  "homepage": "https://hazeljs.ai",
52
- "gitHead": "28c21c509aeca3bf2d0878fbee737d906b654c67"
52
+ "gitHead": "8b7685d1250c4622f25d83992f58e13a59bb3dba"
53
53
  }