hazo_collect 0.2.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.
- package/CHANGE_LOG.md +44 -0
- package/README.md +104 -0
- package/SETUP_CHECKLIST.md +112 -0
- package/dist/ddl/postgres.sql +78 -0
- package/dist/ddl/sqlite.sql +75 -0
- package/dist/index-C47n5Xur.d.ts +60 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +159 -0
- package/dist/run-envelope-COvdsleR.d.ts +129 -0
- package/dist/run-result-qW7bJEZ-.d.ts +88 -0
- package/dist/sdk/index.d.ts +5 -0
- package/dist/sdk/index.js +47 -0
- package/dist/server/index.d.ts +66 -0
- package/dist/server/index.js +592 -0
- package/package.json +82 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const ManifestSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
kind: z.ZodEnum<["source", "sink"]>;
|
|
6
|
+
version: z.ZodString;
|
|
7
|
+
runtime: z.ZodEnum<["node", "python"]>;
|
|
8
|
+
entry: z.ZodString;
|
|
9
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
10
|
+
timezone: z.ZodDefault<z.ZodString>;
|
|
11
|
+
timeout_sec: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
retry: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
max: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
backoff: z.ZodDefault<z.ZodEnum<["exponential", "linear", "constant"]>>;
|
|
16
|
+
base_ms: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
jitter: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
max: number;
|
|
20
|
+
backoff: "exponential" | "linear" | "constant";
|
|
21
|
+
base_ms: number;
|
|
22
|
+
jitter: boolean;
|
|
23
|
+
}, {
|
|
24
|
+
max?: number | undefined;
|
|
25
|
+
backoff?: "exponential" | "linear" | "constant" | undefined;
|
|
26
|
+
base_ms?: number | undefined;
|
|
27
|
+
jitter?: boolean | undefined;
|
|
28
|
+
}>>;
|
|
29
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
+
produces: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
31
|
+
consumes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
32
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
33
|
+
idempotency_key: z.ZodArray<z.ZodString, "many">;
|
|
34
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
name: string;
|
|
37
|
+
kind: "source" | "sink";
|
|
38
|
+
version: string;
|
|
39
|
+
runtime: "node" | "python";
|
|
40
|
+
entry: string;
|
|
41
|
+
timezone: string;
|
|
42
|
+
timeout_sec: number;
|
|
43
|
+
concurrency: number;
|
|
44
|
+
idempotency_key: string[];
|
|
45
|
+
schedule?: string | undefined;
|
|
46
|
+
retry?: {
|
|
47
|
+
max: number;
|
|
48
|
+
backoff: "exponential" | "linear" | "constant";
|
|
49
|
+
base_ms: number;
|
|
50
|
+
jitter: boolean;
|
|
51
|
+
} | undefined;
|
|
52
|
+
inputs?: Record<string, unknown> | undefined;
|
|
53
|
+
produces?: string[] | undefined;
|
|
54
|
+
consumes?: string[] | undefined;
|
|
55
|
+
secrets?: string[] | undefined;
|
|
56
|
+
labels?: Record<string, string> | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
name: string;
|
|
59
|
+
kind: "source" | "sink";
|
|
60
|
+
version: string;
|
|
61
|
+
runtime: "node" | "python";
|
|
62
|
+
entry: string;
|
|
63
|
+
idempotency_key: string[];
|
|
64
|
+
schedule?: string | undefined;
|
|
65
|
+
timezone?: string | undefined;
|
|
66
|
+
timeout_sec?: number | undefined;
|
|
67
|
+
concurrency?: number | undefined;
|
|
68
|
+
retry?: {
|
|
69
|
+
max?: number | undefined;
|
|
70
|
+
backoff?: "exponential" | "linear" | "constant" | undefined;
|
|
71
|
+
base_ms?: number | undefined;
|
|
72
|
+
jitter?: boolean | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
inputs?: Record<string, unknown> | undefined;
|
|
75
|
+
produces?: string[] | undefined;
|
|
76
|
+
consumes?: string[] | undefined;
|
|
77
|
+
secrets?: string[] | undefined;
|
|
78
|
+
labels?: Record<string, string> | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
type Manifest = z.infer<typeof ManifestSchema>;
|
|
81
|
+
declare function parseManifest(input: unknown): Manifest;
|
|
82
|
+
|
|
83
|
+
declare const RunEnvelopeSchema: z.ZodObject<{
|
|
84
|
+
run_id: z.ZodString;
|
|
85
|
+
correlation_id: z.ZodString;
|
|
86
|
+
plugin: z.ZodString;
|
|
87
|
+
inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
88
|
+
secrets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
89
|
+
window: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
since: z.ZodOptional<z.ZodString>;
|
|
91
|
+
until: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
since?: string | undefined;
|
|
94
|
+
until?: string | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
since?: string | undefined;
|
|
97
|
+
until?: string | undefined;
|
|
98
|
+
}>>;
|
|
99
|
+
attempt: z.ZodDefault<z.ZodNumber>;
|
|
100
|
+
contract_version: z.ZodDefault<z.ZodString>;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
inputs: Record<string, unknown>;
|
|
103
|
+
secrets: Record<string, string>;
|
|
104
|
+
plugin: string;
|
|
105
|
+
run_id: string;
|
|
106
|
+
contract_version: string;
|
|
107
|
+
correlation_id: string;
|
|
108
|
+
attempt: number;
|
|
109
|
+
window?: {
|
|
110
|
+
since?: string | undefined;
|
|
111
|
+
until?: string | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
}, {
|
|
114
|
+
plugin: string;
|
|
115
|
+
run_id: string;
|
|
116
|
+
correlation_id: string;
|
|
117
|
+
inputs?: Record<string, unknown> | undefined;
|
|
118
|
+
secrets?: Record<string, string> | undefined;
|
|
119
|
+
contract_version?: string | undefined;
|
|
120
|
+
window?: {
|
|
121
|
+
since?: string | undefined;
|
|
122
|
+
until?: string | undefined;
|
|
123
|
+
} | undefined;
|
|
124
|
+
attempt?: number | undefined;
|
|
125
|
+
}>;
|
|
126
|
+
type RunEnvelope = z.infer<typeof RunEnvelopeSchema>;
|
|
127
|
+
declare function parseRunEnvelope(input: unknown): RunEnvelope;
|
|
128
|
+
|
|
129
|
+
export { type Manifest as M, type RunEnvelope as R, ManifestSchema as a, RunEnvelopeSchema as b, parseRunEnvelope as c, parseManifest as p };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const RunErrorSchema: z.ZodObject<{
|
|
4
|
+
code: z.ZodString;
|
|
5
|
+
message: z.ZodString;
|
|
6
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
context: z.ZodOptional<z.ZodUnknown>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
retryable?: boolean | undefined;
|
|
12
|
+
context?: unknown;
|
|
13
|
+
}, {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
retryable?: boolean | undefined;
|
|
17
|
+
context?: unknown;
|
|
18
|
+
}>;
|
|
19
|
+
declare const RunResultSchema: z.ZodObject<{
|
|
20
|
+
plugin: z.ZodString;
|
|
21
|
+
run_id: z.ZodString;
|
|
22
|
+
kind: z.ZodEnum<["source", "sink"]>;
|
|
23
|
+
started_at: z.ZodString;
|
|
24
|
+
completed_at: z.ZodString;
|
|
25
|
+
status: z.ZodEnum<["success", "partial", "failed"]>;
|
|
26
|
+
records_fetched: z.ZodNumber;
|
|
27
|
+
records_written: z.ZodNumber;
|
|
28
|
+
watermark: z.ZodOptional<z.ZodString>;
|
|
29
|
+
errors: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
30
|
+
code: z.ZodString;
|
|
31
|
+
message: z.ZodString;
|
|
32
|
+
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
context: z.ZodOptional<z.ZodUnknown>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
code: string;
|
|
36
|
+
message: string;
|
|
37
|
+
retryable?: boolean | undefined;
|
|
38
|
+
context?: unknown;
|
|
39
|
+
}, {
|
|
40
|
+
code: string;
|
|
41
|
+
message: string;
|
|
42
|
+
retryable?: boolean | undefined;
|
|
43
|
+
context?: unknown;
|
|
44
|
+
}>, "many">>;
|
|
45
|
+
metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
46
|
+
contract_version: z.ZodDefault<z.ZodString>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
status: "success" | "partial" | "failed";
|
|
49
|
+
kind: "source" | "sink";
|
|
50
|
+
plugin: string;
|
|
51
|
+
run_id: string;
|
|
52
|
+
started_at: string;
|
|
53
|
+
completed_at: string;
|
|
54
|
+
records_fetched: number;
|
|
55
|
+
records_written: number;
|
|
56
|
+
errors: {
|
|
57
|
+
code: string;
|
|
58
|
+
message: string;
|
|
59
|
+
retryable?: boolean | undefined;
|
|
60
|
+
context?: unknown;
|
|
61
|
+
}[];
|
|
62
|
+
contract_version: string;
|
|
63
|
+
watermark?: string | undefined;
|
|
64
|
+
metrics?: Record<string, number> | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
status: "success" | "partial" | "failed";
|
|
67
|
+
kind: "source" | "sink";
|
|
68
|
+
plugin: string;
|
|
69
|
+
run_id: string;
|
|
70
|
+
started_at: string;
|
|
71
|
+
completed_at: string;
|
|
72
|
+
records_fetched: number;
|
|
73
|
+
records_written: number;
|
|
74
|
+
watermark?: string | undefined;
|
|
75
|
+
errors?: {
|
|
76
|
+
code: string;
|
|
77
|
+
message: string;
|
|
78
|
+
retryable?: boolean | undefined;
|
|
79
|
+
context?: unknown;
|
|
80
|
+
}[] | undefined;
|
|
81
|
+
metrics?: Record<string, number> | undefined;
|
|
82
|
+
contract_version?: string | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
type RunResult = z.infer<typeof RunResultSchema>;
|
|
85
|
+
type RunError = z.infer<typeof RunErrorSchema>;
|
|
86
|
+
declare function parseRunResult(input: unknown): RunResult;
|
|
87
|
+
|
|
88
|
+
export { type RunError as R, type RunResult as a, RunResultSchema as b, parseRunResult as p };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import 'hazo_core';
|
|
2
|
+
import '../run-envelope-COvdsleR.js';
|
|
3
|
+
export { a as CollectorContext, b as CollectorDefinition, c as CollectorOutcome, S as SinkDefinition, g as defineCollector, h as defineSink, i as getCollector, j as getSink, l as listCollectors, r as resetCollectorRegistry } from '../index-C47n5Xur.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import 'hazo_connect/server';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/sdk/index.ts
|
|
2
|
+
import { HazoConfigError } from "hazo_core";
|
|
3
|
+
var _collectors = /* @__PURE__ */ new Map();
|
|
4
|
+
var _sinks = /* @__PURE__ */ new Map();
|
|
5
|
+
function defineCollector(def) {
|
|
6
|
+
if (_collectors.has(def.manifest.name)) {
|
|
7
|
+
throw new HazoConfigError({
|
|
8
|
+
code: "HAZO_COLLECT_DUPLICATE_COLLECTOR",
|
|
9
|
+
pkg: "hazo_collect",
|
|
10
|
+
message: `Collector "${def.manifest.name}" is already registered`
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_collectors.set(def.manifest.name, def);
|
|
14
|
+
return def;
|
|
15
|
+
}
|
|
16
|
+
function getCollector(name) {
|
|
17
|
+
return _collectors.get(name);
|
|
18
|
+
}
|
|
19
|
+
function listCollectors() {
|
|
20
|
+
return Array.from(_collectors.values());
|
|
21
|
+
}
|
|
22
|
+
function defineSink(def) {
|
|
23
|
+
if (_sinks.has(def.manifest.name)) {
|
|
24
|
+
throw new HazoConfigError({
|
|
25
|
+
code: "HAZO_COLLECT_DUPLICATE_SINK",
|
|
26
|
+
pkg: "hazo_collect",
|
|
27
|
+
message: `Sink "${def.manifest.name}" is already registered`
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
_sinks.set(def.manifest.name, def);
|
|
31
|
+
return def;
|
|
32
|
+
}
|
|
33
|
+
function getSink(name) {
|
|
34
|
+
return _sinks.get(name);
|
|
35
|
+
}
|
|
36
|
+
function resetCollectorRegistry() {
|
|
37
|
+
_collectors.clear();
|
|
38
|
+
_sinks.clear();
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
defineCollector,
|
|
42
|
+
defineSink,
|
|
43
|
+
getCollector,
|
|
44
|
+
getSink,
|
|
45
|
+
listCollectors,
|
|
46
|
+
resetCollectorRegistry
|
|
47
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { b as CollectorDefinition, c as CollectorOutcome } from '../index-C47n5Xur.js';
|
|
2
|
+
export { C as CanonicalTarget, L as LandingRow, W as WriteAdapter, d as WriteArgs, e as WriteResult, f as createWriteAdapter } from '../index-C47n5Xur.js';
|
|
3
|
+
import { HazoConnectAdapter, DbResult } from 'hazo_connect/server';
|
|
4
|
+
import { a as RunResult } from '../run-result-qW7bJEZ-.js';
|
|
5
|
+
import { M as Manifest, R as RunEnvelope } from '../run-envelope-COvdsleR.js';
|
|
6
|
+
import 'hazo_core';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
interface DiscoverOptions {
|
|
10
|
+
adapter: HazoConnectAdapter;
|
|
11
|
+
pluginsDir?: string;
|
|
12
|
+
reseed?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare function discover(opts: DiscoverOptions): Promise<Registry>;
|
|
15
|
+
|
|
16
|
+
interface RegistryEntry {
|
|
17
|
+
manifest: Manifest;
|
|
18
|
+
worker: CollectorDefinition;
|
|
19
|
+
}
|
|
20
|
+
interface Registry {
|
|
21
|
+
get(name: string): RegistryEntry | undefined;
|
|
22
|
+
list(): RegistryEntry[];
|
|
23
|
+
refresh?(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
declare function createInMemoryRegistry(): Registry;
|
|
26
|
+
/**
|
|
27
|
+
* Upsert all registry entries into hazo_collect_plugin_registry.
|
|
28
|
+
* Invalid manifests (parse failure) are quarantined: valid=0, quarantine_reason=error message.
|
|
29
|
+
*/
|
|
30
|
+
declare function persistRegistry(adapter: HazoConnectAdapter, entries: Array<{
|
|
31
|
+
manifest: Manifest;
|
|
32
|
+
source?: string;
|
|
33
|
+
}>, opts?: {
|
|
34
|
+
reseed?: boolean;
|
|
35
|
+
}): Promise<DbResult<void>>;
|
|
36
|
+
|
|
37
|
+
interface RuntimeAdapter {
|
|
38
|
+
run(def: CollectorDefinition, envelope: RunEnvelope, adapter: HazoConnectAdapter): Promise<{
|
|
39
|
+
ok: true;
|
|
40
|
+
outcome: CollectorOutcome;
|
|
41
|
+
} | {
|
|
42
|
+
ok: false;
|
|
43
|
+
error: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
declare const nodeRuntime: RuntimeAdapter;
|
|
47
|
+
|
|
48
|
+
interface SecretsProvider {
|
|
49
|
+
resolve(names: string[]): Promise<Record<string, string>>;
|
|
50
|
+
get(name: string): Promise<string>;
|
|
51
|
+
}
|
|
52
|
+
interface ManagerOptions {
|
|
53
|
+
adapter: HazoConnectAdapter;
|
|
54
|
+
registry: Registry;
|
|
55
|
+
secrets?: SecretsProvider;
|
|
56
|
+
runtime?: RuntimeAdapter;
|
|
57
|
+
}
|
|
58
|
+
interface Manager {
|
|
59
|
+
runNow(pluginName: string, opts?: {
|
|
60
|
+
inputs?: unknown;
|
|
61
|
+
}): Promise<DbResult<RunResult>>;
|
|
62
|
+
runEnvelope(envelope: RunEnvelope): Promise<DbResult<RunResult>>;
|
|
63
|
+
}
|
|
64
|
+
declare function createManager(opts: ManagerOptions): Manager;
|
|
65
|
+
|
|
66
|
+
export { type DiscoverOptions, type Manager, type ManagerOptions, type Registry, type RegistryEntry, type RuntimeAdapter, createInMemoryRegistry, createManager, discover, nodeRuntime, persistRegistry };
|