@hazeljs/data 0.2.0-beta.37

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 (71) hide show
  1. package/LICENSE +192 -0
  2. package/dist/data.module.d.ts +30 -0
  3. package/dist/data.module.d.ts.map +1 -0
  4. package/dist/data.module.js +120 -0
  5. package/dist/data.types.d.ts +51 -0
  6. package/dist/data.types.d.ts.map +1 -0
  7. package/dist/data.types.js +5 -0
  8. package/dist/decorators/index.d.ts +5 -0
  9. package/dist/decorators/index.d.ts.map +1 -0
  10. package/dist/decorators/index.js +17 -0
  11. package/dist/decorators/pipeline.decorator.d.ts +22 -0
  12. package/dist/decorators/pipeline.decorator.d.ts.map +1 -0
  13. package/dist/decorators/pipeline.decorator.js +42 -0
  14. package/dist/decorators/stream.decorator.d.ts +31 -0
  15. package/dist/decorators/stream.decorator.d.ts.map +1 -0
  16. package/dist/decorators/stream.decorator.js +48 -0
  17. package/dist/decorators/transform.decorator.d.ts +21 -0
  18. package/dist/decorators/transform.decorator.d.ts.map +1 -0
  19. package/dist/decorators/transform.decorator.js +37 -0
  20. package/dist/decorators/validate.decorator.d.ts +30 -0
  21. package/dist/decorators/validate.decorator.d.ts.map +1 -0
  22. package/dist/decorators/validate.decorator.js +45 -0
  23. package/dist/flink.service.d.ts +50 -0
  24. package/dist/flink.service.d.ts.map +1 -0
  25. package/dist/flink.service.js +86 -0
  26. package/dist/index.d.ts +26 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +68 -0
  29. package/dist/pipelines/etl.service.d.ts +20 -0
  30. package/dist/pipelines/etl.service.d.ts.map +1 -0
  31. package/dist/pipelines/etl.service.js +86 -0
  32. package/dist/pipelines/pipeline.base.d.ts +24 -0
  33. package/dist/pipelines/pipeline.base.d.ts.map +1 -0
  34. package/dist/pipelines/pipeline.base.js +29 -0
  35. package/dist/pipelines/pipeline.builder.d.ts +22 -0
  36. package/dist/pipelines/pipeline.builder.d.ts.map +1 -0
  37. package/dist/pipelines/pipeline.builder.js +62 -0
  38. package/dist/pipelines/stream.service.d.ts +12 -0
  39. package/dist/pipelines/stream.service.d.ts.map +1 -0
  40. package/dist/pipelines/stream.service.js +58 -0
  41. package/dist/quality/quality.service.d.ts +25 -0
  42. package/dist/quality/quality.service.d.ts.map +1 -0
  43. package/dist/quality/quality.service.js +87 -0
  44. package/dist/schema/schema.d.ts +47 -0
  45. package/dist/schema/schema.d.ts.map +1 -0
  46. package/dist/schema/schema.js +175 -0
  47. package/dist/streaming/flink/flink.client.d.ts +58 -0
  48. package/dist/streaming/flink/flink.client.d.ts.map +1 -0
  49. package/dist/streaming/flink/flink.client.js +104 -0
  50. package/dist/streaming/flink/flink.job.d.ts +28 -0
  51. package/dist/streaming/flink/flink.job.d.ts.map +1 -0
  52. package/dist/streaming/flink/flink.job.js +27 -0
  53. package/dist/streaming/flink/flink.operators.d.ts +35 -0
  54. package/dist/streaming/flink/flink.operators.d.ts.map +1 -0
  55. package/dist/streaming/flink/flink.operators.js +43 -0
  56. package/dist/streaming/stream.builder.d.ts +22 -0
  57. package/dist/streaming/stream.builder.d.ts.map +1 -0
  58. package/dist/streaming/stream.builder.js +50 -0
  59. package/dist/streaming/stream.processor.d.ts +12 -0
  60. package/dist/streaming/stream.processor.d.ts.map +1 -0
  61. package/dist/streaming/stream.processor.js +31 -0
  62. package/dist/transformers/built-in.transformers.d.ts +12 -0
  63. package/dist/transformers/built-in.transformers.d.ts.map +1 -0
  64. package/dist/transformers/built-in.transformers.js +75 -0
  65. package/dist/transformers/transformer.service.d.ts +14 -0
  66. package/dist/transformers/transformer.service.d.ts.map +1 -0
  67. package/dist/transformers/transformer.service.js +65 -0
  68. package/dist/validators/schema.validator.d.ts +21 -0
  69. package/dist/validators/schema.validator.d.ts.map +1 -0
  70. package/dist/validators/schema.validator.js +40 -0
  71. package/package.json +53 -0
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapToFlinkOperator = mapToFlinkOperator;
4
+ exports.createFlinkJobGraph = createFlinkJobGraph;
5
+ /**
6
+ * Maps HazelJS pipeline steps to Flink operators
7
+ * Note: Actual function/predicate execution happens in deployed Flink job
8
+ */
9
+ function mapToFlinkOperator(step) {
10
+ switch (step.type) {
11
+ case 'transform':
12
+ return {
13
+ type: 'map',
14
+ step: step.step,
15
+ name: step.name,
16
+ // Method name for job graph - actual handler in deployed job
17
+ };
18
+ case 'validate':
19
+ return {
20
+ type: 'filter',
21
+ step: step.step,
22
+ name: step.name,
23
+ predicate: () => true,
24
+ };
25
+ default:
26
+ return {
27
+ type: 'map',
28
+ step: step.step,
29
+ name: step.name,
30
+ };
31
+ }
32
+ }
33
+ function createFlinkJobGraph(steps, sourceConfig, sinkConfig) {
34
+ return {
35
+ source: sourceConfig,
36
+ transformations: steps.map((step) => ({
37
+ step: step.step,
38
+ name: step.name,
39
+ operator: mapToFlinkOperator(step),
40
+ })),
41
+ sink: sinkConfig,
42
+ };
43
+ }
@@ -0,0 +1,22 @@
1
+ import { ETLService } from '../pipelines/etl.service';
2
+ import type { FlinkJobConfig } from '../data.types';
3
+ import type { PipelineStep } from '../pipelines/etl.service';
4
+ import { createFlinkJobGraph } from './flink/flink.operators';
5
+ export interface StreamPipelineConfig {
6
+ source: string;
7
+ sink: string;
8
+ parallelism?: number;
9
+ steps: PipelineStep[];
10
+ }
11
+ /**
12
+ * Stream Builder - Builds Flink job config from @Stream decorated pipeline
13
+ */
14
+ export declare class StreamBuilder {
15
+ private readonly etlService;
16
+ constructor(etlService: ETLService);
17
+ buildConfig(pipelineInstance: object, overrideConfig?: Partial<FlinkJobConfig>): {
18
+ jobConfig: FlinkJobConfig;
19
+ jobGraph: ReturnType<typeof createFlinkJobGraph>;
20
+ };
21
+ }
22
+ //# sourceMappingURL=stream.builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.builder.d.ts","sourceRoot":"","sources":["../../src/streaming/stream.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEnD,WAAW,CACT,gBAAgB,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GACvC;QACD,SAAS,EAAE,cAAc,CAAC;QAC1B,QAAQ,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;KAClD;CA6CF"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamBuilder = void 0;
4
+ const decorators_1 = require("../decorators");
5
+ const flink_operators_1 = require("./flink/flink.operators");
6
+ /**
7
+ * Stream Builder - Builds Flink job config from @Stream decorated pipeline
8
+ */
9
+ class StreamBuilder {
10
+ constructor(etlService) {
11
+ this.etlService = etlService;
12
+ }
13
+ buildConfig(pipelineInstance, overrideConfig) {
14
+ const metadata = (0, decorators_1.getStreamMetadata)(pipelineInstance.constructor);
15
+ if (!metadata) {
16
+ throw new Error('Pipeline must be decorated with @Stream');
17
+ }
18
+ const steps = this.etlService.extractSteps(pipelineInstance);
19
+ const sourceTopic = metadata.source.replace('kafka://', '');
20
+ const sinkTopic = metadata.sink.replace('kafka://', '');
21
+ const jobConfig = {
22
+ jobName: pipelineInstance.constructor.name,
23
+ parallelism: metadata.parallelism ?? 4,
24
+ checkpointInterval: 60000,
25
+ restartStrategy: {
26
+ type: 'fixed-delay',
27
+ attempts: 3,
28
+ delay: 10000,
29
+ },
30
+ ...overrideConfig,
31
+ };
32
+ const jobGraph = (0, flink_operators_1.createFlinkJobGraph)(steps, {
33
+ type: 'kafka',
34
+ topic: sourceTopic,
35
+ properties: {
36
+ 'bootstrap.servers': process.env.KAFKA_BOOTSTRAP_SERVERS ?? 'localhost:9092',
37
+ 'group.id': `hazeljs-${metadata.name}`,
38
+ 'auto.offset.reset': 'latest',
39
+ },
40
+ }, {
41
+ type: 'kafka',
42
+ topic: sinkTopic,
43
+ properties: {
44
+ 'bootstrap.servers': process.env.KAFKA_BOOTSTRAP_SERVERS ?? 'localhost:9092',
45
+ },
46
+ });
47
+ return { jobConfig, jobGraph };
48
+ }
49
+ }
50
+ exports.StreamBuilder = StreamBuilder;
@@ -0,0 +1,12 @@
1
+ import { ETLService } from '../pipelines/etl.service';
2
+ /**
3
+ * Stream Processor - In-process stream processing logic
4
+ * Processes items through pipeline without Flink (for testing/simple use cases)
5
+ */
6
+ export declare class StreamProcessor {
7
+ private readonly etlService;
8
+ constructor(etlService: ETLService);
9
+ processItem<T>(pipelineInstance: object, item: unknown): Promise<T>;
10
+ processStream<T>(pipelineInstance: object, source: AsyncIterable<unknown>): AsyncGenerator<T>;
11
+ }
12
+ //# sourceMappingURL=stream.processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.processor.d.ts","sourceRoot":"","sources":["../../src/streaming/stream.processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD;;;GAGG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAE7C,WAAW,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlE,aAAa,CAAC,CAAC,EACpB,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,cAAc,CAAC,CAAC,CAAC;CAUrB"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StreamProcessor = void 0;
7
+ const core_1 = __importDefault(require("@hazeljs/core"));
8
+ /**
9
+ * Stream Processor - In-process stream processing logic
10
+ * Processes items through pipeline without Flink (for testing/simple use cases)
11
+ */
12
+ class StreamProcessor {
13
+ constructor(etlService) {
14
+ this.etlService = etlService;
15
+ }
16
+ async processItem(pipelineInstance, item) {
17
+ return this.etlService.execute(pipelineInstance, item);
18
+ }
19
+ async *processStream(pipelineInstance, source) {
20
+ for await (const item of source) {
21
+ try {
22
+ yield await this.processItem(pipelineInstance, item);
23
+ }
24
+ catch (error) {
25
+ core_1.default.error('Stream processor error:', error);
26
+ throw error;
27
+ }
28
+ }
29
+ }
30
+ }
31
+ exports.StreamProcessor = StreamProcessor;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Built-in transformers for common data operations
3
+ */
4
+ export declare const trimString: (value: unknown) => string;
5
+ export declare const toLowerCase: (value: unknown) => string;
6
+ export declare const toUpperCase: (value: unknown) => string;
7
+ export declare const parseJson: (value: unknown) => unknown;
8
+ export declare const stringifyJson: (value: unknown) => string;
9
+ export declare const pick: (keys: string[]) => (obj: unknown) => Record<string, unknown>;
10
+ export declare const omit: (keys: string[]) => (obj: unknown) => Record<string, unknown>;
11
+ export declare const renameKeys: (mapping: Record<string, string>) => (obj: unknown) => Record<string, unknown>;
12
+ //# sourceMappingURL=built-in.transformers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"built-in.transformers.d.ts","sourceRoot":"","sources":["../../src/transformers/built-in.transformers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,MAG3C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,MAG5C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,KAAG,MAG5C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,OAK1C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,MAE9C,CAAC;AAEF,eAAO,MAAM,IAAI,GACd,MAAM,MAAM,EAAE,MACd,KAAK,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAQrC,CAAC;AAEJ,eAAO,MAAM,IAAI,GACd,MAAM,MAAM,EAAE,MACd,KAAK,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAQrC,CAAC;AAEJ,eAAO,MAAM,UAAU,GACpB,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAC/B,KAAK,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAWrC,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Built-in transformers for common data operations
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.renameKeys = exports.omit = exports.pick = exports.stringifyJson = exports.parseJson = exports.toUpperCase = exports.toLowerCase = exports.trimString = void 0;
7
+ const trimString = (value) => {
8
+ if (typeof value !== 'string')
9
+ return String(value);
10
+ return value.trim();
11
+ };
12
+ exports.trimString = trimString;
13
+ const toLowerCase = (value) => {
14
+ if (typeof value !== 'string')
15
+ return String(value).toLowerCase();
16
+ return value.toLowerCase();
17
+ };
18
+ exports.toLowerCase = toLowerCase;
19
+ const toUpperCase = (value) => {
20
+ if (typeof value !== 'string')
21
+ return String(value).toUpperCase();
22
+ return value.toUpperCase();
23
+ };
24
+ exports.toUpperCase = toUpperCase;
25
+ const parseJson = (value) => {
26
+ if (typeof value === 'string') {
27
+ return JSON.parse(value);
28
+ }
29
+ return value;
30
+ };
31
+ exports.parseJson = parseJson;
32
+ const stringifyJson = (value) => {
33
+ return JSON.stringify(value);
34
+ };
35
+ exports.stringifyJson = stringifyJson;
36
+ const pick = (keys) => (obj) => {
37
+ if (obj === null || typeof obj !== 'object')
38
+ return {};
39
+ const result = {};
40
+ const source = obj;
41
+ for (const key of keys) {
42
+ if (key in source)
43
+ result[key] = source[key];
44
+ }
45
+ return result;
46
+ };
47
+ exports.pick = pick;
48
+ const omit = (keys) => (obj) => {
49
+ if (obj === null || typeof obj !== 'object')
50
+ return {};
51
+ const result = {};
52
+ const source = obj;
53
+ for (const key of Object.keys(source)) {
54
+ if (!keys.includes(key))
55
+ result[key] = source[key];
56
+ }
57
+ return result;
58
+ };
59
+ exports.omit = omit;
60
+ const renameKeys = (mapping) => (obj) => {
61
+ if (obj === null || typeof obj !== 'object')
62
+ return {};
63
+ const result = {};
64
+ const source = obj;
65
+ for (const [oldKey, newKey] of Object.entries(mapping)) {
66
+ if (oldKey in source)
67
+ result[newKey] = source[oldKey];
68
+ }
69
+ for (const [key, value] of Object.entries(source)) {
70
+ if (!(key in mapping))
71
+ result[key] = value;
72
+ }
73
+ return result;
74
+ };
75
+ exports.renameKeys = renameKeys;
@@ -0,0 +1,14 @@
1
+ export type TransformFn<T = unknown, R = unknown> = (input: T) => R | Promise<R>;
2
+ /**
3
+ * Transformer Service - Data transformations
4
+ * Provides utilities for common data transformation patterns
5
+ */
6
+ export declare class TransformerService {
7
+ private transforms;
8
+ register(name: string, fn: TransformFn): void;
9
+ apply<T, R>(name: string, input: T): Promise<R>;
10
+ pipe<T>(...fns: Array<(x: unknown) => unknown | Promise<unknown>>): (input: T) => Promise<unknown>;
11
+ map<T, R>(fn: (item: T) => R | Promise<R>): (items: T[]) => Promise<R[]>;
12
+ filter<T>(predicate: (item: T) => boolean | Promise<boolean>): (items: T[]) => Promise<T[]>;
13
+ }
14
+ //# sourceMappingURL=transformer.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.service.d.ts","sourceRoot":"","sources":["../../src/transformers/transformer.service.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEjF;;;GAGG;AACH,qBACa,kBAAkB;IAC7B,OAAO,CAAC,UAAU,CAAuC;IAEzD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI;IAKvC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IASrD,IAAI,CAAC,CAAC,EACJ,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GACxD,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC;IAWjC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;IAMxE,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;CAU5F"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TransformerService = void 0;
13
+ const core_1 = require("@hazeljs/core");
14
+ const core_2 = __importDefault(require("@hazeljs/core"));
15
+ /**
16
+ * Transformer Service - Data transformations
17
+ * Provides utilities for common data transformation patterns
18
+ */
19
+ let TransformerService = class TransformerService {
20
+ constructor() {
21
+ this.transforms = new Map();
22
+ }
23
+ register(name, fn) {
24
+ this.transforms.set(name, fn);
25
+ core_2.default.debug(`Registered transform: ${name}`);
26
+ }
27
+ async apply(name, input) {
28
+ const fn = this.transforms.get(name);
29
+ if (!fn) {
30
+ throw new Error(`Transform not found: ${name}`);
31
+ }
32
+ const result = fn(input);
33
+ return (result instanceof Promise ? await result : result);
34
+ }
35
+ pipe(...fns) {
36
+ return async (input) => {
37
+ let data = input;
38
+ for (const fn of fns) {
39
+ const result = fn(data);
40
+ data = result instanceof Promise ? await result : result;
41
+ }
42
+ return data;
43
+ };
44
+ }
45
+ map(fn) {
46
+ return async (items) => {
47
+ return Promise.all(items.map((item) => Promise.resolve(fn(item))));
48
+ };
49
+ }
50
+ filter(predicate) {
51
+ return async (items) => {
52
+ const results = [];
53
+ for (const item of items) {
54
+ const keep = await Promise.resolve(predicate(item));
55
+ if (keep)
56
+ results.push(item);
57
+ }
58
+ return results;
59
+ };
60
+ }
61
+ };
62
+ exports.TransformerService = TransformerService;
63
+ exports.TransformerService = TransformerService = __decorate([
64
+ (0, core_1.Injectable)()
65
+ ], TransformerService);
@@ -0,0 +1,21 @@
1
+ import type { BaseSchema } from '../schema/schema';
2
+ import type { SchemaValidationError } from '../schema/schema';
3
+ export declare class SchemaValidationException extends Error {
4
+ readonly errors: SchemaValidationError[];
5
+ constructor(message: string, errors: SchemaValidationError[]);
6
+ }
7
+ /**
8
+ * Schema Validator - Validates data against schemas
9
+ */
10
+ export declare class SchemaValidator {
11
+ validate<T>(schema: BaseSchema<T>, value: unknown): T;
12
+ validateOrThrow<T>(schema: BaseSchema<T>, value: unknown): T;
13
+ safeValidate<T>(schema: BaseSchema<T>, value: unknown): {
14
+ success: true;
15
+ data: T;
16
+ } | {
17
+ success: false;
18
+ errors: SchemaValidationError[];
19
+ };
20
+ }
21
+ //# sourceMappingURL=schema.validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.validator.d.ts","sourceRoot":"","sources":["../../src/validators/schema.validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,qBAAa,yBAA0B,SAAQ,KAAK;aAGhC,MAAM,EAAE,qBAAqB,EAAE;gBAD/C,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,qBAAqB,EAAE;CAKlD;AAED;;GAEG;AACH,qBACa,eAAe;IAC1B,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC;IAWrD,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC;IAI5D,YAAY,CAAC,CAAC,EACZ,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EACrB,KAAK,EAAE,OAAO,GACb;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,qBAAqB,EAAE,CAAA;KAAE;CAKpF"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SchemaValidator = exports.SchemaValidationException = void 0;
10
+ const core_1 = require("@hazeljs/core");
11
+ class SchemaValidationException extends Error {
12
+ constructor(message, errors) {
13
+ super(message);
14
+ this.errors = errors;
15
+ this.name = 'SchemaValidationException';
16
+ }
17
+ }
18
+ exports.SchemaValidationException = SchemaValidationException;
19
+ /**
20
+ * Schema Validator - Validates data against schemas
21
+ */
22
+ let SchemaValidator = class SchemaValidator {
23
+ validate(schema, value) {
24
+ const result = schema.validate(value);
25
+ if (result.success) {
26
+ return result.data;
27
+ }
28
+ throw new SchemaValidationException(`Validation failed: ${result.errors.map((e) => `${e.path}: ${e.message}`).join('; ')}`, result.errors);
29
+ }
30
+ validateOrThrow(schema, value) {
31
+ return this.validate(schema, value);
32
+ }
33
+ safeValidate(schema, value) {
34
+ return schema.validate(value);
35
+ }
36
+ };
37
+ exports.SchemaValidator = SchemaValidator;
38
+ exports.SchemaValidator = SchemaValidator = __decorate([
39
+ (0, core_1.Injectable)()
40
+ ], SchemaValidator);
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@hazeljs/data",
3
+ "version": "0.2.0-beta.37",
4
+ "description": "Data Processing & ETL for HazelJS framework",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc --skipLibCheck",
12
+ "test": "jest --coverage --maxWorkers=1",
13
+ "lint": "eslint \"src/**/*.ts\"",
14
+ "lint:fix": "eslint \"src/**/*.ts\" --fix",
15
+ "clean": "rm -rf dist"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^20.17.50",
19
+ "@typescript-eslint/eslint-plugin": "^8.18.2",
20
+ "@typescript-eslint/parser": "^8.18.2",
21
+ "eslint": "^8.56.0",
22
+ "jest": "^29.7.0",
23
+ "ts-jest": "^29.1.2",
24
+ "typescript": "^5.3.3"
25
+ },
26
+ "peerDependencies": {
27
+ "@hazeljs/core": ">=0.2.0-beta.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/hazel-js/hazeljs.git",
35
+ "directory": "packages/data"
36
+ },
37
+ "keywords": [
38
+ "hazeljs",
39
+ "data",
40
+ "etl",
41
+ "pipeline",
42
+ "flink",
43
+ "streaming",
44
+ "validation"
45
+ ],
46
+ "author": "Muhammad Arslan <muhammad.arslan@hazeljs.com>",
47
+ "license": "Apache-2.0",
48
+ "bugs": {
49
+ "url": "https://github.com/hazeljs/hazel-js/issues"
50
+ },
51
+ "homepage": "https://hazeljs.com",
52
+ "gitHead": "d39af9d45d13caed182bc8ecc5d3c517b2ffe8d5"
53
+ }