@davidtnfsh/etl-contracts 1.0.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/README.md +52 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas.d.ts +82 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +51 -0
- package/dist/schemas.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @davidtnfsh/etl-contracts
|
|
2
|
+
|
|
3
|
+
Shared TypeScript and Zod contracts for the All Weather ETL job status system.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @davidtnfsh/etl-contracts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { EtlJobStatusSchema, type EtlJobStatus } from '@davidtnfsh/etl-contracts';
|
|
15
|
+
|
|
16
|
+
// Validate API responses
|
|
17
|
+
const response = await fetch('/api/jobs/123');
|
|
18
|
+
const data = await response.json();
|
|
19
|
+
const validated = EtlJobStatusSchema.parse(data);
|
|
20
|
+
|
|
21
|
+
// TypeScript types
|
|
22
|
+
const job: EtlJobStatus = {
|
|
23
|
+
jobId: 'etl_123',
|
|
24
|
+
status: 'completed',
|
|
25
|
+
trigger: 'webhook',
|
|
26
|
+
createdAt: '2025-01-07T10:00:00Z',
|
|
27
|
+
recordsProcessed: 100,
|
|
28
|
+
recordsInserted: 95
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Schemas
|
|
33
|
+
|
|
34
|
+
- `EtlJobStatusSchema` - Job status response (flat structure)
|
|
35
|
+
- `EtlJobCreatedSchema` - Job creation response
|
|
36
|
+
- `EtlErrorSchema` - Error structure
|
|
37
|
+
- `JobStatusEnum` - Status values: `pending`, `processing`, `completed`, `failed`
|
|
38
|
+
- `ErrorCodeEnum` - Error codes: `API_ERROR`, `VALIDATION_ERROR`, `INTERNAL_ERROR`, `RATE_LIMIT_EXCEEDED`
|
|
39
|
+
|
|
40
|
+
## Types
|
|
41
|
+
|
|
42
|
+
All types are inferred from Zod schemas:
|
|
43
|
+
|
|
44
|
+
- `EtlJobStatus`
|
|
45
|
+
- `EtlJobCreated`
|
|
46
|
+
- `EtlError`
|
|
47
|
+
- `JobStatus`
|
|
48
|
+
- `ErrorCode`
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
ISC
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACd,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,SAAS,EACT,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,SAAS,EACV,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JobStatusEnum = exports.ErrorCodeEnum = exports.EtlJobStatusSchema = exports.EtlJobCreatedSchema = exports.EtlErrorSchema = void 0;
|
|
4
|
+
// Export all schemas
|
|
5
|
+
var schemas_1 = require("./schemas");
|
|
6
|
+
Object.defineProperty(exports, "EtlErrorSchema", { enumerable: true, get: function () { return schemas_1.EtlErrorSchema; } });
|
|
7
|
+
Object.defineProperty(exports, "EtlJobCreatedSchema", { enumerable: true, get: function () { return schemas_1.EtlJobCreatedSchema; } });
|
|
8
|
+
Object.defineProperty(exports, "EtlJobStatusSchema", { enumerable: true, get: function () { return schemas_1.EtlJobStatusSchema; } });
|
|
9
|
+
Object.defineProperty(exports, "ErrorCodeEnum", { enumerable: true, get: function () { return schemas_1.ErrorCodeEnum; } });
|
|
10
|
+
Object.defineProperty(exports, "JobStatusEnum", { enumerable: true, get: function () { return schemas_1.JobStatusEnum; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,qCAMmB;AALjB,yGAAA,cAAc,OAAA;AACd,8GAAA,mBAAmB,OAAA;AACnB,6GAAA,kBAAkB,OAAA;AAClB,wGAAA,aAAa,OAAA;AACb,wGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Job status enum - the source of truth for all status values
|
|
4
|
+
*/
|
|
5
|
+
export declare const JobStatusEnum: z.ZodEnum<["pending", "processing", "completed", "failed"]>;
|
|
6
|
+
/**
|
|
7
|
+
* Error code enum - simple set for now, extensible
|
|
8
|
+
*/
|
|
9
|
+
export declare const ErrorCodeEnum: z.ZodEnum<["API_ERROR", "VALIDATION_ERROR", "INTERNAL_ERROR", "RATE_LIMIT_EXCEEDED"]>;
|
|
10
|
+
/**
|
|
11
|
+
* Error structure - simple and clear
|
|
12
|
+
*/
|
|
13
|
+
export declare const EtlErrorSchema: z.ZodObject<{
|
|
14
|
+
code: z.ZodEnum<["API_ERROR", "VALIDATION_ERROR", "INTERNAL_ERROR", "RATE_LIMIT_EXCEEDED"]>;
|
|
15
|
+
message: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
code: "API_ERROR" | "VALIDATION_ERROR" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED";
|
|
18
|
+
message: string;
|
|
19
|
+
}, {
|
|
20
|
+
code: "API_ERROR" | "VALIDATION_ERROR" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED";
|
|
21
|
+
message: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Job status response - flat structure, no nesting
|
|
25
|
+
*/
|
|
26
|
+
export declare const EtlJobStatusSchema: z.ZodObject<{
|
|
27
|
+
jobId: z.ZodString;
|
|
28
|
+
status: z.ZodEnum<["pending", "processing", "completed", "failed"]>;
|
|
29
|
+
trigger: z.ZodEnum<["webhook", "manual", "scheduled"]>;
|
|
30
|
+
createdAt: z.ZodString;
|
|
31
|
+
recordsProcessed: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
recordsInserted: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
completedAt: z.ZodOptional<z.ZodString>;
|
|
35
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
code: z.ZodEnum<["API_ERROR", "VALIDATION_ERROR", "INTERNAL_ERROR", "RATE_LIMIT_EXCEEDED"]>;
|
|
37
|
+
message: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
code: "API_ERROR" | "VALIDATION_ERROR" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED";
|
|
40
|
+
message: string;
|
|
41
|
+
}, {
|
|
42
|
+
code: "API_ERROR" | "VALIDATION_ERROR" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED";
|
|
43
|
+
message: string;
|
|
44
|
+
}>>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
status: "pending" | "processing" | "completed" | "failed";
|
|
47
|
+
jobId: string;
|
|
48
|
+
trigger: "webhook" | "manual" | "scheduled";
|
|
49
|
+
createdAt: string;
|
|
50
|
+
recordsProcessed?: number | undefined;
|
|
51
|
+
recordsInserted?: number | undefined;
|
|
52
|
+
duration?: number | undefined;
|
|
53
|
+
completedAt?: string | undefined;
|
|
54
|
+
error?: {
|
|
55
|
+
code: "API_ERROR" | "VALIDATION_ERROR" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED";
|
|
56
|
+
message: string;
|
|
57
|
+
} | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
status: "pending" | "processing" | "completed" | "failed";
|
|
60
|
+
jobId: string;
|
|
61
|
+
trigger: "webhook" | "manual" | "scheduled";
|
|
62
|
+
createdAt: string;
|
|
63
|
+
recordsProcessed?: number | undefined;
|
|
64
|
+
recordsInserted?: number | undefined;
|
|
65
|
+
duration?: number | undefined;
|
|
66
|
+
completedAt?: string | undefined;
|
|
67
|
+
error?: {
|
|
68
|
+
code: "API_ERROR" | "VALIDATION_ERROR" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED";
|
|
69
|
+
message: string;
|
|
70
|
+
} | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Webhook trigger response - returned when creating a job
|
|
74
|
+
*/
|
|
75
|
+
export declare const EtlJobCreatedSchema: z.ZodObject<{
|
|
76
|
+
jobId: z.ZodString;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
jobId: string;
|
|
79
|
+
}, {
|
|
80
|
+
jobId: string;
|
|
81
|
+
}>;
|
|
82
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,aAAa,6DAKxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,uFAKxB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;EAGzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;EAE9B,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EtlJobCreatedSchema = exports.EtlJobStatusSchema = exports.EtlErrorSchema = exports.ErrorCodeEnum = exports.JobStatusEnum = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Job status enum - the source of truth for all status values
|
|
7
|
+
*/
|
|
8
|
+
exports.JobStatusEnum = zod_1.z.enum([
|
|
9
|
+
'pending',
|
|
10
|
+
'processing',
|
|
11
|
+
'completed',
|
|
12
|
+
'failed'
|
|
13
|
+
]);
|
|
14
|
+
/**
|
|
15
|
+
* Error code enum - simple set for now, extensible
|
|
16
|
+
*/
|
|
17
|
+
exports.ErrorCodeEnum = zod_1.z.enum([
|
|
18
|
+
'API_ERROR',
|
|
19
|
+
'VALIDATION_ERROR',
|
|
20
|
+
'INTERNAL_ERROR',
|
|
21
|
+
'RATE_LIMIT_EXCEEDED'
|
|
22
|
+
]);
|
|
23
|
+
/**
|
|
24
|
+
* Error structure - simple and clear
|
|
25
|
+
*/
|
|
26
|
+
exports.EtlErrorSchema = zod_1.z.object({
|
|
27
|
+
code: exports.ErrorCodeEnum,
|
|
28
|
+
message: zod_1.z.string()
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Job status response - flat structure, no nesting
|
|
32
|
+
*/
|
|
33
|
+
exports.EtlJobStatusSchema = zod_1.z.object({
|
|
34
|
+
jobId: zod_1.z.string(),
|
|
35
|
+
status: exports.JobStatusEnum,
|
|
36
|
+
trigger: zod_1.z.enum(['webhook', 'manual', 'scheduled']),
|
|
37
|
+
createdAt: zod_1.z.string().datetime(), // ISO-8601
|
|
38
|
+
// Optional fields - only present when relevant
|
|
39
|
+
recordsProcessed: zod_1.z.number().int().nonnegative().optional(),
|
|
40
|
+
recordsInserted: zod_1.z.number().int().nonnegative().optional(),
|
|
41
|
+
duration: zod_1.z.number().int().nonnegative().optional(), // milliseconds
|
|
42
|
+
completedAt: zod_1.z.string().datetime().optional(), // ISO-8601
|
|
43
|
+
error: exports.EtlErrorSchema.optional()
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Webhook trigger response - returned when creating a job
|
|
47
|
+
*/
|
|
48
|
+
exports.EtlJobCreatedSchema = zod_1.z.object({
|
|
49
|
+
jobId: zod_1.z.string()
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;GAEG;AACU,QAAA,aAAa,GAAG,OAAC,CAAC,IAAI,CAAC;IAClC,SAAS;IACT,YAAY;IACZ,WAAW;IACX,QAAQ;CACT,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,aAAa,GAAG,OAAC,CAAC,IAAI,CAAC;IAClC,WAAW;IACX,kBAAkB;IAClB,gBAAgB;IAChB,qBAAqB;CACtB,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,qBAAa;IACnB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,qBAAa;IACrB,OAAO,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;IACnD,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,WAAW;IAE7C,+CAA+C;IAC/C,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IAC3D,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IAC1D,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,eAAe;IACpE,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,WAAW;IAC1D,KAAK,EAAE,sBAAc,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { EtlErrorSchema, EtlJobCreatedSchema, EtlJobStatusSchema, ErrorCodeEnum, JobStatusEnum } from './schemas';
|
|
3
|
+
/**
|
|
4
|
+
* Inferred TypeScript types from Zod schemas
|
|
5
|
+
*/
|
|
6
|
+
export type JobStatus = z.infer<typeof JobStatusEnum>;
|
|
7
|
+
export type ErrorCode = z.infer<typeof ErrorCodeEnum>;
|
|
8
|
+
export type EtlError = z.infer<typeof EtlErrorSchema>;
|
|
9
|
+
export type EtlJobStatus = z.infer<typeof EtlJobStatusSchema>;
|
|
10
|
+
export type EtlJobCreated = z.infer<typeof EtlJobCreatedSchema>;
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACd,MAAM,WAAW,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@davidtnfsh/etl-contracts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared contracts for ETL job status system",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"clean": "rm -rf dist",
|
|
10
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"etl",
|
|
14
|
+
"contracts",
|
|
15
|
+
"types"
|
|
16
|
+
],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"zod": "^3.0.0 || ^4.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.3.3",
|
|
24
|
+
"zod": "^3.22.4"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|