@useairfoil/connector-kit 0.5.0 → 0.5.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 (110) hide show
  1. package/METRICS.md +78 -0
  2. package/README.md +190 -21
  3. package/dist/auth/index.d.ts +2 -0
  4. package/dist/auth/index.js +3 -0
  5. package/dist/auth-DvU_CZ7C.js +42 -0
  6. package/dist/auth-DvU_CZ7C.js.map +1 -0
  7. package/dist/connector-app/index.d.ts +14 -9
  8. package/dist/connector-app/index.js +9 -6
  9. package/dist/connector-app-d7Z-SZLQ.js +64 -0
  10. package/dist/connector-app-d7Z-SZLQ.js.map +1 -0
  11. package/dist/constants-BRhIX_rz.js +27 -0
  12. package/dist/constants-BRhIX_rz.js.map +1 -0
  13. package/dist/errors/index.d.ts +1 -1
  14. package/dist/{index-DK9YcR6W.d.ts → index-Byr0Lf0C.d.ts} +4 -4
  15. package/dist/index-CBT-JX-T.d.ts +173 -0
  16. package/dist/index-CTHVudvQ.d.ts +41 -0
  17. package/dist/index-CTLYQ74P.d.ts +80 -0
  18. package/dist/index-Coh_SkBs.d.ts +95 -0
  19. package/dist/{index-DyuT2jzP.d.ts → index-D54ySAKn.d.ts} +1 -1
  20. package/dist/{index-BlhJCpEk.d.ts → index-DtJX_tic.d.ts} +39 -10
  21. package/dist/{index-8KnVpoZp.d.ts → index-J42AZaXU.d.ts} +11 -5
  22. package/dist/{index-CQJsFJs3.d.ts → index-fIIBVAai.d.ts} +6 -4
  23. package/dist/index-o1-Z3n7V.d.ts +55 -0
  24. package/dist/index.d.ts +14 -9
  25. package/dist/index.js +14 -8
  26. package/dist/index.js.map +1 -1
  27. package/dist/ingestion/index.d.ts +5 -5
  28. package/dist/ingestion/index.js +7 -4
  29. package/dist/ingestion-BQo4cbGw.js +200 -0
  30. package/dist/ingestion-BQo4cbGw.js.map +1 -0
  31. package/dist/manifest/index.d.ts +2 -0
  32. package/dist/manifest/index.js +4 -0
  33. package/dist/manifest-ByE6YPG0.js +221 -0
  34. package/dist/manifest-ByE6YPG0.js.map +1 -0
  35. package/dist/metrics-CVAk1ALR.d.ts +53 -0
  36. package/dist/metrics-CWPy2Aqc.js +96 -0
  37. package/dist/metrics-CWPy2Aqc.js.map +1 -0
  38. package/dist/metrics.d.ts +4 -0
  39. package/dist/metrics.js +3 -0
  40. package/dist/publisher/index.d.ts +4 -4
  41. package/dist/publisher/index.js +3 -2
  42. package/dist/{publisher-DusgYvaV.js → publisher-BYT3RLVO.js} +2 -2
  43. package/dist/{publisher-DusgYvaV.js.map → publisher-BYT3RLVO.js.map} +1 -1
  44. package/dist/runtime-config/index.d.ts +2 -0
  45. package/dist/runtime-config/index.js +4 -0
  46. package/dist/runtime-config-BpB-d_bF.js +51 -0
  47. package/dist/runtime-config-BpB-d_bF.js.map +1 -0
  48. package/dist/server-CXTQ7odl.js +183 -0
  49. package/dist/server-CXTQ7odl.js.map +1 -0
  50. package/dist/{telemetry-p0dE5Mdu.js → service-DuFiQwid.js} +30 -10
  51. package/dist/service-DuFiQwid.js.map +1 -0
  52. package/dist/{service-B7g_lHMI.d.ts → service-IE5qaf9x.d.ts} +3 -3
  53. package/dist/state-store/index.d.ts +3 -4
  54. package/dist/state-store/index.js +4 -2
  55. package/dist/state-store-yl6LiTQ0.js +198 -0
  56. package/dist/state-store-yl6LiTQ0.js.map +1 -0
  57. package/dist/status/index.d.ts +5 -0
  58. package/dist/status/index.js +6 -0
  59. package/dist/status-B-oZBc33.js +84 -0
  60. package/dist/status-B-oZBc33.js.map +1 -0
  61. package/dist/{types-ZNrA-Dn0.d.ts → types-B35J5YPu.d.ts} +20 -6
  62. package/dist/webhook/index.d.ts +5 -4
  63. package/dist/webhook/index.js +5 -3
  64. package/dist/{webhook-BSA-tXtU.js → webhook-DI-Afxkg.js} +2 -2
  65. package/dist/{webhook-BSA-tXtU.js.map → webhook-DI-Afxkg.js.map} +1 -1
  66. package/package.json +36 -7
  67. package/src/auth/index.ts +1 -0
  68. package/src/auth/token-cache.ts +54 -0
  69. package/src/connector-app/check.ts +76 -0
  70. package/src/connector-app/index.ts +1 -0
  71. package/src/connector-app/start.ts +4 -0
  72. package/src/core/builder.ts +8 -3
  73. package/src/core/types.ts +20 -2
  74. package/src/index.ts +5 -0
  75. package/src/ingestion/engine.ts +246 -133
  76. package/src/manifest/config.ts +232 -0
  77. package/src/manifest/index.ts +14 -0
  78. package/src/manifest/manifest.ts +31 -0
  79. package/src/manifest/number-schema.ts +17 -0
  80. package/src/manifest/schema.ts +160 -0
  81. package/src/metrics.ts +128 -0
  82. package/src/publisher/instrumented.ts +68 -0
  83. package/src/runtime-config/constants.ts +27 -0
  84. package/src/runtime-config/error.ts +13 -0
  85. package/src/runtime-config/index.ts +3 -0
  86. package/src/runtime-config/layer.ts +56 -0
  87. package/src/state-store/index.ts +2 -1
  88. package/src/state-store/keys.ts +22 -0
  89. package/src/state-store/layer-key-value-store.ts +132 -0
  90. package/src/state-store/layer-memory.ts +11 -0
  91. package/src/state-store/layer-sql.ts +50 -0
  92. package/src/state-store/schema.ts +57 -0
  93. package/src/state-store/service.ts +39 -6
  94. package/src/state-store/state.ts +17 -0
  95. package/src/status/index.ts +2 -0
  96. package/src/status/route.ts +77 -0
  97. package/src/status/types.ts +33 -0
  98. package/src/telemetry.ts +46 -4
  99. package/src/webhook/server.ts +54 -19
  100. package/dist/connector-app-CvqbfN6R.js +0 -32
  101. package/dist/connector-app-CvqbfN6R.js.map +0 -1
  102. package/dist/index-DaNW63Mv.d.ts +0 -21
  103. package/dist/ingestion-CMCroK7Y.js +0 -171
  104. package/dist/ingestion-CMCroK7Y.js.map +0 -1
  105. package/dist/server-DAeFWT4o.js +0 -113
  106. package/dist/server-DAeFWT4o.js.map +0 -1
  107. package/dist/state-store-DG_4QpWG.js +0 -31
  108. package/dist/state-store-DG_4QpWG.js.map +0 -1
  109. package/dist/telemetry-p0dE5Mdu.js.map +0 -1
  110. package/src/state-store/memory.ts +0 -25
@@ -1,6 +1,6 @@
1
- import { t as ConnectorError } from "./index-DyuT2jzP.js";
2
- import { c as ResourceBatch, n as ConnectorDefinition } from "./types-ZNrA-Dn0.js";
3
- import { a as PublisherService, i as Publisher, n as PublishOptions, r as PublishSource, t as PublishAck } from "./service-B7g_lHMI.js";
1
+ import { t as ConnectorError } from "./index-D54ySAKn.js";
2
+ import { c as ResourceBatch, n as ConnectorDefinition } from "./types-B35J5YPu.js";
3
+ import { a as PublisherService, i as Publisher, n as PublishOptions, r as PublishSource, t as PublishAck } from "./service-IE5qaf9x.js";
4
4
  import { Layer } from "effect";
5
5
  import * as Wings from "@useairfoil/wings";
6
6
 
@@ -22,4 +22,4 @@ declare namespace index_d_exports {
22
22
  }
23
23
  //#endregion
24
24
  export { layerWings as i, layerConsole as n, WingsPublisherConfig as r, index_d_exports as t };
25
- //# sourceMappingURL=index-DK9YcR6W.d.ts.map
25
+ //# sourceMappingURL=index-Byr0Lf0C.d.ts.map
@@ -0,0 +1,173 @@
1
+ import { Config, Option, Redacted, Schema, Types } from "effect";
2
+ import * as effect_Effect0 from "effect/Effect";
3
+
4
+ //#region src/manifest/number-schema.d.ts
5
+ type NumberConstraints = {
6
+ readonly integer?: boolean;
7
+ readonly minimum?: number;
8
+ };
9
+ //#endregion
10
+ //#region src/manifest/config.d.ts
11
+ type ConfigFieldSpecBase = {
12
+ readonly runtimeKey: string;
13
+ readonly required: boolean;
14
+ readonly description?: string;
15
+ };
16
+ type ConfigFieldDefinition = ConfigFieldSpecBase & ({
17
+ readonly type: "string";
18
+ readonly secret: false;
19
+ readonly default?: string;
20
+ readonly values?: never;
21
+ } | {
22
+ readonly type: "string";
23
+ readonly secret: true;
24
+ readonly default?: never;
25
+ readonly values?: never;
26
+ } | {
27
+ readonly type: "number";
28
+ readonly secret: false;
29
+ readonly default?: number;
30
+ readonly values?: never;
31
+ readonly integer?: boolean;
32
+ readonly minimum?: number;
33
+ } | {
34
+ readonly type: "boolean";
35
+ readonly secret: false;
36
+ readonly default?: boolean;
37
+ readonly values?: never;
38
+ } | {
39
+ readonly type: "select";
40
+ readonly secret: false;
41
+ readonly default?: string;
42
+ readonly values: readonly [string, ...Array<string>];
43
+ });
44
+ /** Serializable, browser-safe metadata for one user-provided connector setting. */
45
+ type ConfigFieldSpec = ConfigFieldDefinition & {
46
+ readonly name: string;
47
+ };
48
+ /** Pairs an Effect runtime config with the metadata used to generate its form field. */
49
+ type ConfigField<A$1> = {
50
+ readonly config: Config.Config<A$1>;
51
+ readonly spec: ConfigFieldDefinition;
52
+ };
53
+ type FieldBaseOptions = {
54
+ readonly runtimeKey: string;
55
+ readonly description?: string;
56
+ };
57
+ type FieldOptions<A$1 extends string | number | boolean = string | number | boolean> = FieldBaseOptions & ({
58
+ readonly required?: true;
59
+ readonly default?: A$1;
60
+ } | {
61
+ readonly required: false;
62
+ readonly default: A$1;
63
+ });
64
+ type NumberFieldOptions = FieldOptions<number> & NumberConstraints;
65
+ type FieldsRecord = Record<string, ConfigField<unknown>>;
66
+ type ConfigOf<Fields$1 extends FieldsRecord> = { readonly [Key in keyof Fields$1]: Fields$1[Key] extends ConfigField<infer A> ? A : never };
67
+ /** Effect config and serializable manifest metadata produced from one field definition. */
68
+ type ConnectorConfigDef<Fields$1 extends FieldsRecord> = {
69
+ readonly fields: { readonly [Key in keyof Fields$1]: Fields$1[Key] extends ConfigField<infer A> ? Config.Config<A> : never };
70
+ readonly config: Config.Config<ConfigOf<Fields$1>>;
71
+ readonly spec: ReadonlyArray<ConfigFieldSpec>;
72
+ };
73
+ type ConfigValuesOf<Def extends ConnectorConfigDef<FieldsRecord>> = Def extends ConnectorConfigDef<infer Fields> ? ConfigOf<Fields> : never;
74
+ /** Defines a required non-empty string, optionally with a default. */
75
+ declare const string: (options: FieldOptions<string>) => ConfigField<string>;
76
+ /** Defines a finite number with optional integer, minimum, and default constraints. */
77
+ declare const number: (options: NumberFieldOptions) => ConfigField<number>;
78
+ /** Defines a boolean, optionally with a default. */
79
+ declare const boolean: (options: FieldOptions<boolean>) => ConfigField<boolean>;
80
+ /** Defines a string literal choice whose values are preserved in the inferred type. */
81
+ declare const select: <const Values extends readonly [string, ...Array<string>]>(options: FieldOptions<Values[number]> & {
82
+ readonly values: Values;
83
+ }) => ConfigField<Values[number]>;
84
+ /** Defines a required, non-empty secret decoded as `Redacted<string>`. */
85
+ declare const secret: (options: FieldBaseOptions & {
86
+ readonly required?: true;
87
+ }) => ConfigField<Redacted.Redacted<string>>;
88
+ /** Makes an existing field optional and represents a missing value as `Option.none()`. */
89
+ declare const optional: <A$1>(field: ConfigField<A$1>) => ConfigField<Option.Option<A$1>>;
90
+ /**
91
+ * Defines user-facing connector config once for both Effect runtime loading and
92
+ * frontend form generation. The object keys become logical form/API field names;
93
+ * `runtimeKey` remains the key read by Effect Config.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const config = define({
98
+ * apiUrl: string({ runtimeKey: "API_URL" }),
99
+ * token: secret({ runtimeKey: "API_TOKEN" }),
100
+ * });
101
+ *
102
+ * const RuntimeConfig = config.config;
103
+ * const formFields = config.spec;
104
+ * ```
105
+ */
106
+ declare const define: <const Fields$1 extends FieldsRecord>(fields: Fields$1) => ConnectorConfigDef<Fields$1>;
107
+ //#endregion
108
+ //#region src/manifest/manifest.d.ts
109
+ type ResourceCapability = "backfill" | "changes" | "webhook";
110
+ /** Browser-safe connector metadata consumed by the platform and runtime adapters. */
111
+ type ConnectorManifest = {
112
+ readonly name: string;
113
+ readonly title: string;
114
+ readonly description?: string;
115
+ readonly config: ReadonlyArray<ConfigFieldSpec>;
116
+ readonly resources: ReadonlyArray<{
117
+ readonly name: string;
118
+ readonly capabilities: ReadonlyArray<ResourceCapability>;
119
+ }>;
120
+ };
121
+ /**
122
+ * Defines browser-safe connector metadata while preserving literal names and capabilities.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const manifest = define({
127
+ * name: "producer-example",
128
+ * title: "Example",
129
+ * config: ExampleConfig.spec,
130
+ * resources: [{ name: "orders", capabilities: ["backfill"] }],
131
+ * });
132
+ * ```
133
+ */
134
+ declare const define$1: <const Manifest extends ConnectorManifest>(manifest: Manifest) => Manifest;
135
+ //#endregion
136
+ //#region src/manifest/schema.d.ts
137
+ type FieldValueOf<Field$1 extends ConfigFieldSpec> = Field$1["type"] extends "number" ? number : Field$1["type"] extends "boolean" ? boolean : Field$1["values"] extends ReadonlyArray<string> ? Field$1["values"][number] : string;
138
+ type ConnectorConfigValues<Manifest extends ConnectorManifest> = Types.Simplify<{ readonly [Field in Manifest["config"][number] as Field["required"] extends true ? Field["name"] : never]: FieldValueOf<Field> } & { readonly [Field in Manifest["config"][number] as Field["required"] extends true ? never : Field["name"]]?: FieldValueOf<Field> | undefined }> & object;
139
+ type ConnectorConfigSchema<Manifest extends ConnectorManifest> = Schema.Codec<ConnectorConfigValues<Manifest>, unknown>;
140
+ /** Flat primitive document keyed by the runtime keys consumed by Effect Config. */
141
+ type RuntimeConfigDocument = Readonly<Record<string, string | number | boolean>>;
142
+ /**
143
+ * Builds an Effect Schema for logical form/API values from a connector manifest.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const decode = Schema.decodeUnknownEffect(configSchema(manifest));
148
+ * const values = decode({
149
+ * apiUrl: "https://example.com",
150
+ * retries: "3",
151
+ * });
152
+ * ```
153
+ */
154
+ declare const configSchema: <const Manifest extends ConnectorManifest>(manifest: Manifest) => ConnectorConfigSchema<Manifest>;
155
+ /** Decodes browser/API config, applies manifest defaults, and rejects undeclared fields. */
156
+ declare const decodeConfig: <const Manifest extends ConnectorManifest>(manifest: Manifest, input: unknown) => effect_Effect0.Effect<ConnectorConfigValues<Manifest>, Schema.SchemaError, never>;
157
+ /**
158
+ * Maps validated logical values to the flat runtime-key document mounted in a pod.
159
+ * Missing optional values are omitted.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * toRuntimeDocument(manifest, { apiUrl: "https://example.com" });
164
+ * // { API_URL: "https://example.com" }
165
+ * ```
166
+ */
167
+ declare const toRuntimeDocument: <const Manifest extends ConnectorManifest>(manifest: Manifest, values: ConnectorConfigValues<Manifest>) => RuntimeConfigDocument;
168
+ declare namespace index_d_exports {
169
+ export { ConfigField, ConfigFieldSpec, ConfigValuesOf, ConnectorConfigDef, ConnectorConfigSchema, ConnectorConfigValues, ConnectorManifest, ResourceCapability, RuntimeConfigDocument, boolean, configSchema, decodeConfig, define$1 as define, define as defineConfig, number, optional, secret, select, string, toRuntimeDocument };
170
+ }
171
+ //#endregion
172
+ export { number as _, configSchema as a, select as b, ConnectorManifest as c, ConfigField as d, ConfigFieldSpec as f, define as g, boolean as h, RuntimeConfigDocument as i, ResourceCapability as l, ConnectorConfigDef as m, ConnectorConfigSchema as n, decodeConfig as o, ConfigValuesOf as p, ConnectorConfigValues as r, toRuntimeDocument as s, index_d_exports as t, define$1 as u, optional as v, string as x, secret as y };
173
+ //# sourceMappingURL=index-CBT-JX-T.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { Duration, Effect, Redacted } from "effect";
2
+
3
+ //#region src/auth/token-cache.d.ts
4
+ interface ExpiringToken {
5
+ /** The credential kept in memory by the cache. */
6
+ readonly value: Redacted.Redacted<string>;
7
+ /** The lifetime reported by the provider. */
8
+ readonly expiresIn: Duration.Duration;
9
+ }
10
+ interface TokenCache<E> {
11
+ /** Returns the cached token or performs one shared acquisition. */
12
+ readonly get: Effect.Effect<Redacted.Redacted<string>, E>;
13
+ /** Removes the cached token so the next `get` reacquires it. */
14
+ readonly invalidate: Effect.Effect<void>;
15
+ }
16
+ /**
17
+ * Creates a lazy, in-memory token cache around an acquisition effect.
18
+ *
19
+ * `refreshFactor` controls how much of the provider lifetime is cached. It is
20
+ * clamped between `0` and `1`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const cache = yield* makeTokenCache({
25
+ * acquire: exchangeCredentials,
26
+ * refreshFactor: 0.5,
27
+ * })
28
+ *
29
+ * const token = yield* cache.get
30
+ * ```
31
+ */
32
+ declare const makeTokenCache: <E, R>(options: {
33
+ readonly acquire: Effect.Effect<ExpiringToken, E, R>;
34
+ readonly refreshFactor?: number;
35
+ }) => Effect.Effect<TokenCache<E>, never, R>;
36
+ declare namespace index_d_exports {
37
+ export { ExpiringToken, TokenCache, makeTokenCache };
38
+ }
39
+ //#endregion
40
+ export { makeTokenCache as i, ExpiringToken as n, TokenCache as r, index_d_exports as t };
41
+ //# sourceMappingURL=index-CTHVudvQ.d.ts.map
@@ -0,0 +1,80 @@
1
+ import { n as ConnectorDefinition } from "./types-B35J5YPu.js";
2
+ import { i as StateStore } from "./index-Coh_SkBs.js";
3
+ import { Schema } from "effect";
4
+ import { HttpRouter } from "effect/unstable/http";
5
+ import * as effect_Layer1 from "effect/Layer";
6
+
7
+ //#region src/status/route.d.ts
8
+ declare const statusRoute: (connector: ConnectorDefinition, path?: HttpRouter.PathInput) => effect_Layer1.Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", StateStore>>;
9
+ //#endregion
10
+ //#region src/status/types.d.ts
11
+ declare const SyncStateSchema: Schema.Literals<readonly ["pending", "backfilling", "live", "error"]>;
12
+ type SyncState = Schema.Schema.Type<typeof SyncStateSchema>;
13
+ /** Safe source failure returned by the status endpoint. */
14
+ declare const ResourceErrorSchema: Schema.Struct<{
15
+ readonly at: Schema.String;
16
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
17
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
18
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
19
+ readonly message: Schema.String;
20
+ }>;
21
+ type ResourceError = Schema.Schema.Type<typeof ResourceErrorSchema>;
22
+ declare const ResourceStatusSchema: Schema.Struct<{
23
+ readonly backfill: Schema.optional<Schema.Struct<{
24
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
25
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
26
+ readonly completed: Schema.Boolean;
27
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
28
+ }>>;
29
+ readonly changes: Schema.optional<Schema.Struct<{
30
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
31
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
32
+ }>>;
33
+ readonly lastError: Schema.optional<Schema.Struct<{
34
+ readonly at: Schema.String;
35
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
36
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
37
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
38
+ readonly message: Schema.String;
39
+ }>>;
40
+ readonly name: Schema.String;
41
+ readonly state: Schema.Literals<readonly ["pending", "backfilling", "live", "error"]>;
42
+ }>;
43
+ type ResourceStatus = Schema.Schema.Type<typeof ResourceStatusSchema>;
44
+ declare const StatusResponseSchema: Schema.Struct<{
45
+ readonly connector: Schema.String;
46
+ readonly resources: Schema.$Array<Schema.Struct<{
47
+ readonly backfill: Schema.optional<Schema.Struct<{
48
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
49
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
50
+ readonly completed: Schema.Boolean;
51
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
52
+ }>>;
53
+ readonly changes: Schema.optional<Schema.Struct<{
54
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
55
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
56
+ }>>;
57
+ readonly lastError: Schema.optional<Schema.Struct<{
58
+ readonly at: Schema.String;
59
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
60
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
61
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
62
+ readonly message: Schema.String;
63
+ }>>;
64
+ readonly name: Schema.String;
65
+ readonly state: Schema.Literals<readonly ["pending", "backfilling", "live", "error"]>;
66
+ }>>;
67
+ }>;
68
+ type StatusResponse = Schema.Schema.Type<typeof StatusResponseSchema>;
69
+ /** Returned when durable resource status cannot be read. */
70
+ declare const StatusUnavailableResponseSchema: Schema.Struct<{
71
+ readonly ok: Schema.Literal<false>;
72
+ readonly error: Schema.String;
73
+ }>;
74
+ type StatusUnavailableResponse = Schema.Schema.Type<typeof StatusUnavailableResponseSchema>;
75
+ declare namespace index_d_exports {
76
+ export { ResourceError, ResourceErrorSchema, ResourceStatus, ResourceStatusSchema, StatusResponse, StatusResponseSchema, StatusUnavailableResponse, StatusUnavailableResponseSchema, SyncState, SyncStateSchema, statusRoute };
77
+ }
78
+ //#endregion
79
+ export { ResourceStatusSchema as a, StatusUnavailableResponse as c, SyncStateSchema as d, statusRoute as f, ResourceStatus as i, StatusUnavailableResponseSchema as l, ResourceError as n, StatusResponse as o, ResourceErrorSchema as r, StatusResponseSchema as s, index_d_exports as t, SyncState as u };
80
+ //# sourceMappingURL=index-CTLYQ74P.d.ts.map
@@ -0,0 +1,95 @@
1
+ import { t as ConnectorError } from "./index-D54ySAKn.js";
2
+ import { Config, Context, Effect, Layer, Schema } from "effect";
3
+ import { SqlClient } from "effect/unstable/sql";
4
+
5
+ //#region src/state-store/schema.d.ts
6
+ /** Durable progress for a finite historical backfill. */
7
+ declare const BackfillStateSchema: Schema.Struct<{
8
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
9
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
10
+ readonly completed: Schema.Boolean;
11
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
12
+ }>;
13
+ /** Durable cursor for an ongoing incremental changes stream. */
14
+ declare const ChangesStateSchema: Schema.Struct<{
15
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
16
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
17
+ }>;
18
+ declare const StateSourceSchema: Schema.Literals<readonly ["backfill", "changes"]>;
19
+ declare const StateOperationSchema: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
20
+ /** Complete persisted state assembled from independently stored components. */
21
+ declare const ResourceStateSchema: Schema.Struct<{
22
+ readonly backfill: Schema.optional<Schema.Struct<{
23
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
24
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
25
+ readonly completed: Schema.Boolean;
26
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
27
+ }>>;
28
+ readonly changes: Schema.optional<Schema.Struct<{
29
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
30
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
31
+ }>>;
32
+ readonly lastError: Schema.optional<Schema.Struct<{
33
+ readonly at: Schema.String;
34
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
35
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
36
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
37
+ readonly message: Schema.String;
38
+ }>>;
39
+ }>;
40
+ type PersistedBackfillState = Schema.Schema.Type<typeof BackfillStateSchema>;
41
+ type PersistedChangesState = Schema.Schema.Type<typeof ChangesStateSchema>;
42
+ type StateSource = Schema.Schema.Type<typeof StateSourceSchema>;
43
+ type StateOperation = Schema.Schema.Type<typeof StateOperationSchema>;
44
+ type PersistedResourceState = Schema.Schema.Type<typeof ResourceStateSchema>;
45
+ //#endregion
46
+ //#region src/state-store/service.d.ts
47
+ /** Connector-facing durable state operations, independent of the storage backend. */
48
+ interface StateStoreService {
49
+ readonly getResourceState: (resource: string) => Effect.Effect<PersistedResourceState | undefined, ConnectorError>;
50
+ readonly setBackfillState: (resource: string, state: PersistedBackfillState) => Effect.Effect<void, ConnectorError>;
51
+ readonly setChangesState: (resource: string, state: PersistedChangesState) => Effect.Effect<void, ConnectorError>;
52
+ readonly setResourceError: (resource: string, source: StateSource, operation: StateOperation) => Effect.Effect<void, ConnectorError>;
53
+ readonly clearResourceError: (resource: string, source: StateSource) => Effect.Effect<void, ConnectorError>;
54
+ }
55
+ declare const StateStore_base: Context.ServiceClass<StateStore, "@useairfoil/connector-kit/StateStore", StateStoreService>;
56
+ /**
57
+ * Effect service used by ingestion and status logic for connector checkpoints.
58
+ * Production provides `layerSql`; sandboxes and tests may provide `layerMemory`.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const program = Effect.gen(function* () {
63
+ * const state = yield* StateStore;
64
+ * yield* state.setChangesState("orders", { cursor: "next-page" });
65
+ * });
66
+ * ```
67
+ */
68
+ declare class StateStore extends StateStore_base {}
69
+ //#endregion
70
+ //#region src/state-store/layer-memory.d.ts
71
+ /** Process-local state for tests and explicit local sandbox commands. */
72
+ declare const layerMemory: Layer.Layer<StateStore>;
73
+ //#endregion
74
+ //#region src/state-store/layer-sql.d.ts
75
+ /**
76
+ * Shared SQL state using the immutable connector instance ID supplied by
77
+ * platform-owned Effect configuration. The table defaults to
78
+ * `_airfoil_connectors_state` and can be overridden with `AIRFOIL_STATE_TABLE`.
79
+ * Effect's SQL KeyValueStore owns the table, while `KeyValueStore.prefix`
80
+ * provides application-level isolation between connector instances in that
81
+ * table. The resulting layer exposes only StateStore, never the unscoped
82
+ * KeyValueStore.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const StateStoreLive = layerSql().pipe(Layer.provide(PostgresLive));
87
+ * ```
88
+ */
89
+ declare const layerSql: () => Layer.Layer<StateStore, Config.ConfigError, SqlClient.SqlClient>;
90
+ declare namespace index_d_exports {
91
+ export { StateStore, StateStoreService, layerMemory, layerSql };
92
+ }
93
+ //#endregion
94
+ export { StateStoreService as a, StateStore as i, layerSql as n, layerMemory as r, index_d_exports as t };
95
+ //# sourceMappingURL=index-Coh_SkBs.d.ts.map
@@ -11,4 +11,4 @@ declare class ConnectorError extends ConnectorError_base<{
11
11
  }> {}
12
12
  //#endregion
13
13
  export { ConnectorError as t };
14
- //# sourceMappingURL=index-DyuT2jzP.d.ts.map
14
+ //# sourceMappingURL=index-D54ySAKn.d.ts.map
@@ -1,18 +1,39 @@
1
- import { t as ConnectorError } from "./index-DyuT2jzP.js";
2
- import { d as ResourceMutation, h as ResourceSchema, i as DeleteValue, l as ResourceDefinition, n as ConnectorDefinition, r as Cursor, s as PageFetch, t as ChangesFetch, v as WebhookHandler } from "./types-ZNrA-Dn0.js";
3
- import { i as Publisher } from "./service-B7g_lHMI.js";
4
- import { r as StateStore } from "./index-DaNW63Mv.js";
5
- import { Config, Effect, Layer } from "effect";
1
+ import { t as ConnectorError } from "./index-D54ySAKn.js";
2
+ import { b as WebhookHandler, d as ResourceMutation, f as ResourceName, g as ResourceSchema, i as DeleteValue, l as ResourceDefinition, n as ConnectorDefinition, r as Cursor, s as PageFetch, t as ChangesFetch } from "./types-B35J5YPu.js";
3
+ import { i as Publisher } from "./service-IE5qaf9x.js";
4
+ import { i as StateStore } from "./index-Coh_SkBs.js";
5
+ import { Config, Context, Duration, Effect, Layer } from "effect";
6
6
  import { HttpRouter } from "effect/unstable/http";
7
7
  import * as effect_unstable_http_HttpClient0 from "effect/unstable/http/HttpClient";
8
8
  import * as effect_unstable_http_HttpServerError0 from "effect/unstable/http/HttpServerError";
9
9
 
10
+ //#region src/connector-app/check.d.ts
11
+ type ResourceCheckResult = {
12
+ readonly _tag: "ok";
13
+ } | {
14
+ readonly _tag: "error";
15
+ readonly message: string;
16
+ };
17
+ type CheckOptions<Name extends string> = {
18
+ readonly resources: ReadonlyArray<Name>;
19
+ };
20
+ type ResourceCheckResults<Name extends PropertyKey> = { readonly [Key in Name]: ResourceCheckResult };
21
+ type CheckResult<Resources extends ReadonlyArray<ResourceDefinition>, Name extends ResourceName<Resources> = ResourceName<Resources>> = ResourceCheckResults<Name>;
22
+ type CheckFailure = {
23
+ readonly message: string;
24
+ };
25
+ /**
26
+ * Builds the connector service from its layer and validates only the selected
27
+ * resources. The layer remains open until every check finishes.
28
+ */
29
+ declare function check<Identifier, const Resources extends ReadonlyArray<ResourceDefinition>, E extends CheckFailure, R, const Name extends ResourceName<Resources>>(service: Context.Key<Identifier, ConnectorDefinition<Resources>>, layer: Layer.Layer<Identifier, E, R>, options: CheckOptions<Name>): Effect.Effect<CheckResult<Resources, Name>, never, R>;
30
+ //#endregion
10
31
  //#region src/core/builder.d.ts
11
32
  declare const Connector: {
12
33
  define: <const Resources extends ReadonlyArray<ResourceDefinition>>(definition: ConnectorDefinition<Resources>) => ConnectorDefinition<Resources>;
13
34
  };
14
35
  declare const Resource: {
15
- entity: <S extends ResourceSchema, Payload = never, R = never>(definition: ResourceDefinition<S, Payload, R>) => ResourceDefinition<S, Payload, R>;
36
+ entity: <S extends ResourceSchema, Payload = never, R = never, const Name extends string = string>(definition: ResourceDefinition<S, Payload, R, Name>) => ResourceDefinition<S, Payload, R, Name>;
16
37
  webhook: <Payload, Row extends object = never>(definition: WebhookHandler<Row, Payload>) => WebhookHandler<Row, Payload>;
17
38
  upsert: <Row extends object>(row: Row) => ResourceMutation<Row>;
18
39
  delete: (options: {
@@ -31,7 +52,7 @@ declare const Cursor$1: {
31
52
  nowIsoDateTime: Effect.Effect<string, never, never>;
32
53
  };
33
54
  declare namespace telemetry_d_exports {
34
- export { Attr, EventAttr, EventName, OtlpTracingConfig, OtlpTracingOptions, SpanName, addCurrentSpanEvent, annotateError, layer, layerConfig, layerOtlpTracing };
55
+ export { Attr, EventAttr, EventName, OtlpMetricsOptions, OtlpTracingConfig, OtlpTracingOptions, SpanName, addCurrentSpanEvent, annotateError, layer, layerConfig, layerMetricsConsoleDump, layerOtlp, layerOtlpMetrics, layerOtlpTracing };
35
56
  }
36
57
  /** Canonical span names emitted by connector-kit runtime instrumentation. */
37
58
  declare const SpanName: {
@@ -81,6 +102,9 @@ type OtlpTracingOptions = {
81
102
  /** Additional connector-specific header names or regexes to redact from HTTP logs/traces. */
82
103
  readonly redactedHeaders?: ReadonlyArray<string | RegExp>;
83
104
  };
105
+ type OtlpMetricsOptions = {
106
+ readonly exportInterval?: Duration.Input;
107
+ };
84
108
  /**
85
109
  * Trace-only OTLP export with sensitive HTTP header redaction.
86
110
  * Takes direct config values — no `ConfigProvider` required.
@@ -106,6 +130,9 @@ declare const layerConfig: (config: Config.Wrap<OtlpTracingConfig>, options?: Ot
106
130
  * `OTEL_SERVICE_NAME`, `OTEL_SERVICE_VERSION`, and `OTEL_RESOURCE_ATTRIBUTES`.
107
131
  */
108
132
  declare const layerOtlpTracing: (options?: OtlpTracingOptions) => Layer.Layer<never, Error | Config.ConfigError, effect_unstable_http_HttpClient0.HttpClient>;
133
+ declare const layerOtlpMetrics: (options?: OtlpMetricsOptions) => Layer.Layer<never, Error | Config.ConfigError, effect_unstable_http_HttpClient0.HttpClient>;
134
+ declare const layerOtlp: (options?: OtlpTracingOptions & OtlpMetricsOptions) => Layer.Layer<never, Error | Config.ConfigError, effect_unstable_http_HttpClient0.HttpClient>;
135
+ declare const layerMetricsConsoleDump: (interval?: Duration.Input) => Layer.Layer<never, never, never>;
109
136
  //#endregion
110
137
  //#region src/connector-app/start.d.ts
111
138
  type App = ConnectorDefinition;
@@ -113,12 +140,14 @@ type StartOptions = {
113
140
  readonly port: number;
114
141
  readonly initialCutoff?: Cursor.Value;
115
142
  readonly healthPath?: HttpRouter.PathInput;
143
+ readonly metricsPath?: HttpRouter.PathInput | false;
144
+ readonly statusPath?: HttpRouter.PathInput | false;
116
145
  readonly disableHttpLogger?: boolean;
117
146
  };
118
147
  declare const start: (app: App, options: StartOptions) => Effect.Effect<void, ConnectorError | effect_unstable_http_HttpServerError0.ServeError, StateStore | Publisher>;
119
148
  declare namespace index_d_exports {
120
- export { App, StartOptions, start };
149
+ export { App, CheckOptions, CheckResult, ResourceCheckResult, StartOptions, check, start };
121
150
  }
122
151
  //#endregion
123
- export { telemetry_d_exports as a, Fetch as c, start as i, Resource as l, App as n, Connector as o, StartOptions as r, Cursor$1 as s, index_d_exports as t };
124
- //# sourceMappingURL=index-BlhJCpEk.d.ts.map
152
+ export { telemetry_d_exports as a, Fetch as c, CheckResult as d, ResourceCheckResult as f, start as i, Resource as l, App as n, Connector as o, check as p, StartOptions as r, Cursor$1 as s, index_d_exports as t, CheckOptions as u };
153
+ //# sourceMappingURL=index-DtJX_tic.d.ts.map
@@ -1,7 +1,7 @@
1
- import { t as ConnectorError } from "./index-DyuT2jzP.js";
2
- import { l as ResourceDefinition, n as ConnectorDefinition, r as Cursor, y as WebhookRoute } from "./types-ZNrA-Dn0.js";
3
- import { i as Publisher } from "./service-B7g_lHMI.js";
4
- import { r as StateStore } from "./index-DaNW63Mv.js";
1
+ import { t as ConnectorError } from "./index-D54ySAKn.js";
2
+ import { l as ResourceDefinition, n as ConnectorDefinition, r as Cursor, x as WebhookRoute } from "./types-B35J5YPu.js";
3
+ import { i as Publisher } from "./service-IE5qaf9x.js";
4
+ import { i as StateStore } from "./index-Coh_SkBs.js";
5
5
  import { Effect } from "effect";
6
6
  import { HttpRouter, HttpServer } from "effect/unstable/http";
7
7
 
@@ -13,6 +13,8 @@ type RunOptions = RunBaseOptions & {
13
13
  readonly webhook?: {
14
14
  readonly routes: ReadonlyArray<WebhookRoute>;
15
15
  readonly healthPath?: HttpRouter.PathInput;
16
+ readonly metricsPath?: HttpRouter.PathInput | false;
17
+ readonly statusPath?: HttpRouter.PathInput | false;
16
18
  readonly disableHttpLogger?: boolean;
17
19
  };
18
20
  };
@@ -22,6 +24,10 @@ type RunNoWebhookOptions = RunBaseOptions & {
22
24
  type RunWebhookOptions = RunOptions & {
23
25
  readonly webhook: NonNullable<RunOptions["webhook"]>;
24
26
  };
27
+ /**
28
+ * Runs all connector ingestion loops. Callers provide the Publisher and
29
+ * StateStore layers; webhook mode additionally requires an HttpServer layer.
30
+ */
25
31
  declare function run<const Resources extends ReadonlyArray<ResourceDefinition>>(connector: ConnectorDefinition<Resources>, options?: RunNoWebhookOptions): Effect.Effect<void, ConnectorError, StateStore | Publisher>;
26
32
  declare function run<const Resources extends ReadonlyArray<ResourceDefinition>>(connector: ConnectorDefinition<Resources>, options: RunWebhookOptions): Effect.Effect<void, ConnectorError, StateStore | Publisher | HttpServer.HttpServer>;
27
33
  declare namespace index_d_exports {
@@ -29,4 +35,4 @@ declare namespace index_d_exports {
29
35
  }
30
36
  //#endregion
31
37
  export { RunOptions as n, run as r, index_d_exports as t };
32
- //# sourceMappingURL=index-8KnVpoZp.d.ts.map
38
+ //# sourceMappingURL=index-J42AZaXU.d.ts.map
@@ -1,5 +1,5 @@
1
- import { _ as WebhookAckMode, b as WebhookRouteContext, c as ResourceBatch, l as ResourceDefinition, x as WebhookRouteInput, y as WebhookRoute } from "./types-ZNrA-Dn0.js";
2
- import { i as Publisher } from "./service-B7g_lHMI.js";
1
+ import { C as WebhookRouteInput, S as WebhookRouteContext, c as ResourceBatch, l as ResourceDefinition, x as WebhookRoute, y as WebhookAckMode } from "./types-B35J5YPu.js";
2
+ import { i as Publisher } from "./service-IE5qaf9x.js";
3
3
  import { Context, Queue } from "effect";
4
4
  import { HttpRouter } from "effect/unstable/http";
5
5
  import * as effect_Layer0 from "effect/Layer";
@@ -13,11 +13,13 @@ declare const WebhookQueue_base: Context.ServiceClass<WebhookQueue, "@useairfoil
13
13
  readonly queue: Queue.Queue<QueuedWebhookBatch>;
14
14
  }>;
15
15
  declare class WebhookQueue extends WebhookQueue_base {}
16
- declare const router: (routes: ReadonlyArray<WebhookRoute>) => effect_Layer0.Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", Publisher> | HttpRouter.Request<"Requires", WebhookQueue>>;
16
+ declare const router: (routes: ReadonlyArray<WebhookRoute>, options: {
17
+ readonly connectorName: string;
18
+ }) => effect_Layer0.Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", WebhookQueue> | HttpRouter.Request<"Requires", Publisher>>;
17
19
  declare namespace index_d_exports {
18
20
  export { WebhookAckMode, WebhookRoute, WebhookRouteContext, WebhookRouteInput, route, router };
19
21
  }
20
22
  declare const route: <const Resources extends ReadonlyArray<ResourceDefinition>, Payload>(definition: WebhookRouteInput<Resources, Payload>) => WebhookRoute<Resources, Payload>;
21
23
  //#endregion
22
24
  export { route as n, router as r, index_d_exports as t };
23
- //# sourceMappingURL=index-CQJsFJs3.d.ts.map
25
+ //# sourceMappingURL=index-fIIBVAai.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { FileSystem } from "effect";
2
+ import * as effect_Types0 from "effect/Types";
3
+ import * as effect_Cause0 from "effect/Cause";
4
+ import * as effect_Layer0 from "effect/Layer";
5
+
6
+ //#region src/runtime-config/error.d.ts
7
+ type RuntimeConfigErrorCode = "CONFIG_PATH_MISSING" | "CONFIG_FILE_UNREADABLE" | "CONFIG_JSON_INVALID";
8
+ declare const RuntimeConfigError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => effect_Cause0.YieldableError & {
9
+ readonly _tag: "RuntimeConfigError";
10
+ } & Readonly<A>;
11
+ /** Expected hosted-config failure with a stable code and diagnostic cause. */
12
+ declare class RuntimeConfigError extends RuntimeConfigError_base<{
13
+ readonly code: RuntimeConfigErrorCode;
14
+ readonly message: string;
15
+ readonly cause: Error;
16
+ }> {}
17
+ //#endregion
18
+ //#region src/runtime-config/constants.d.ts
19
+ /** Shared runtime keys owned by Airfoil rather than an individual connector. */
20
+ declare const PlatformRuntimeKey: {
21
+ readonly configPath: "AIRFOIL_CONFIG_PATH";
22
+ readonly connectorInstanceId: "AIRFOIL_CONNECTOR_INSTANCE_ID";
23
+ readonly stateTable: "AIRFOIL_STATE_TABLE";
24
+ readonly postgresConnectionString: "POSTGRES_CONNECTION_STRING";
25
+ readonly wingsHost: "WINGS_HOST";
26
+ readonly wingsNamespace: "WINGS_NAMESPACE";
27
+ readonly otelEnabled: "OTEL_ENABLED";
28
+ readonly otelExporterOtlpEndpoint: "OTEL_EXPORTER_OTLP_ENDPOINT";
29
+ readonly otelExporterOtlpHeaders: "OTEL_EXPORTER_OTLP_HEADERS";
30
+ readonly otelServiceName: "OTEL_SERVICE_NAME";
31
+ readonly otelServiceVersion: "OTEL_SERVICE_VERSION";
32
+ readonly otelResourceAttributes: "OTEL_RESOURCE_ATTRIBUTES";
33
+ };
34
+ /** Defaults for optional platform-owned runtime configuration. */
35
+ declare const PlatformRuntimeDefault: {
36
+ readonly stateTable: "_airfoil_connectors_state";
37
+ };
38
+ //#endregion
39
+ //#region src/runtime-config/layer.d.ts
40
+ /**
41
+ * Loads the required JSON file and lets environment values override it per key.
42
+ * Connector field validation remains in the connector's Effect Config.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * program.pipe(Effect.provide(layerHosted()));
47
+ * ```
48
+ */
49
+ declare const layerHosted: () => effect_Layer0.Layer<never, RuntimeConfigError, FileSystem.FileSystem>;
50
+ declare namespace index_d_exports {
51
+ export { PlatformRuntimeDefault, PlatformRuntimeKey, RuntimeConfigError, RuntimeConfigErrorCode, layerHosted };
52
+ }
53
+ //#endregion
54
+ export { RuntimeConfigError as a, PlatformRuntimeKey as i, layerHosted as n, RuntimeConfigErrorCode as o, PlatformRuntimeDefault as r, index_d_exports as t };
55
+ //# sourceMappingURL=index-o1-Z3n7V.d.ts.map