@useairfoil/connector-kit 0.6.1 → 0.7.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.
Files changed (102) hide show
  1. package/LICENSE.txt +201 -0
  2. package/METRICS.md +27 -30
  3. package/README.md +33 -51
  4. package/dist/{annotations-BE74YmAO.d.mts → annotations-vzSzXtr-.d.mts} +5 -10
  5. package/dist/{wings-I56hGtNv.mjs → arrow-flight-DDQ0ktx9.mjs} +25 -99
  6. package/dist/arrow-flight-DDQ0ktx9.mjs.map +1 -0
  7. package/dist/connector-app/index.d.mts +2 -2
  8. package/dist/connector-app/index.mjs +2 -2
  9. package/dist/connector-app-C6_dZnhE.mjs +256 -0
  10. package/dist/connector-app-C6_dZnhE.mjs.map +1 -0
  11. package/dist/{constants-D-GQzpHZ.mjs → constants-v3UX-hf6.mjs} +3 -2
  12. package/dist/constants-v3UX-hf6.mjs.map +1 -0
  13. package/dist/demo/index.d.mts +1 -1
  14. package/dist/demo/index.mjs +1 -1
  15. package/dist/{demo-B30Vlkk2.mjs → demo-DqTJ7TWI.mjs} +32 -19
  16. package/dist/demo-DqTJ7TWI.mjs.map +1 -0
  17. package/dist/iceberg/index.d.mts +3 -3
  18. package/dist/iceberg/index.mjs +3 -3
  19. package/dist/iceberg-Cj2PwlNm.mjs +30 -0
  20. package/dist/iceberg-Cj2PwlNm.mjs.map +1 -0
  21. package/dist/{index-DJhDp4Xc.d.mts → index-BTAbexBp.d.mts} +13 -16
  22. package/dist/{index-BUHSGm9Q.d.mts → index-Byr8NTdG.d.mts} +2 -2
  23. package/dist/{index-Dk7urvpF.d.mts → index-CV6V6fyx.d.mts} +9 -6
  24. package/dist/{index-NnCutIqM.d.mts → index-CZKx2Yce.d.mts} +29 -19
  25. package/dist/{index-BfXpgxk9.d.mts → index-DeTwIUKl.d.mts} +3 -3
  26. package/dist/{index-CRVAwJ5-.d.mts → index-dHS59EZl.d.mts} +4 -4
  27. package/dist/{index-ygpml2kC.d.mts → index-fHIJJoRe.d.mts} +17 -10
  28. package/dist/index-uFa2wwYo.d.mts +27 -0
  29. package/dist/index.d.mts +11 -11
  30. package/dist/index.mjs +10 -10
  31. package/dist/ingestion/index.d.mts +1 -1
  32. package/dist/ingestion/index.mjs +1 -1
  33. package/dist/{ingestion-q0WwqUSt.mjs → ingestion-DoCUwm5N.mjs} +6 -6
  34. package/dist/{ingestion-q0WwqUSt.mjs.map → ingestion-DoCUwm5N.mjs.map} +1 -1
  35. package/dist/ingestor/index.d.mts +3 -3
  36. package/dist/ingestor/index.mjs +3 -3
  37. package/dist/{ingestor-D4L-HPkg.mjs → ingestor-DjCEzBzZ.mjs} +6 -6
  38. package/dist/ingestor-DjCEzBzZ.mjs.map +1 -0
  39. package/dist/{instrumented-Bhp7fyvh.mjs → instrumented-Bq1WX2L5.mjs} +2 -2
  40. package/dist/{instrumented-Bhp7fyvh.mjs.map → instrumented-Bq1WX2L5.mjs.map} +1 -1
  41. package/dist/manifest/index.mjs +1 -1
  42. package/dist/{manifest-BGKxmKLy.mjs → manifest-CABeIhAG.mjs} +2 -2
  43. package/dist/{manifest-BGKxmKLy.mjs.map → manifest-CABeIhAG.mjs.map} +1 -1
  44. package/dist/{metrics-BaEX__MN.mjs → metrics-C901IIYZ.mjs} +6 -11
  45. package/dist/metrics-C901IIYZ.mjs.map +1 -0
  46. package/dist/{metrics-CVXFL7YT.d.mts → metrics-DoJ0WeKu.d.mts} +2 -2
  47. package/dist/metrics.d.mts +1 -1
  48. package/dist/metrics.mjs +1 -1
  49. package/dist/runtime-config/index.d.mts +2 -2
  50. package/dist/runtime-config/index.mjs +3 -3
  51. package/dist/{runtime-config-Oa55gAew.mjs → runtime-config-Bn8Fivt1.mjs} +11 -8
  52. package/dist/runtime-config-Bn8Fivt1.mjs.map +1 -0
  53. package/dist/{server-CMnxz3h0.mjs → server-D1TTN0_D.mjs} +3 -3
  54. package/dist/{server-CMnxz3h0.mjs.map → server-D1TTN0_D.mjs.map} +1 -1
  55. package/dist/{service-DLkhuxYl.d.mts → service-BRoy_EId.d.mts} +2 -2
  56. package/dist/state-store/index.mjs +1 -1
  57. package/dist/{state-store-uFvHY7Ax.mjs → state-store-DhSrKVEH.mjs} +2 -2
  58. package/dist/{state-store-uFvHY7Ax.mjs.map → state-store-DhSrKVEH.mjs.map} +1 -1
  59. package/dist/status/index.d.mts +1 -1
  60. package/dist/status/index.mjs +1 -1
  61. package/dist/{status-CKb9IhQ9.mjs → status-4h6Oxh-O.mjs} +2 -2
  62. package/dist/{status-CKb9IhQ9.mjs.map → status-4h6Oxh-O.mjs.map} +1 -1
  63. package/dist/{table-V0tgUC5i.mjs → table-CxM09xf7.mjs} +22 -85
  64. package/dist/table-CxM09xf7.mjs.map +1 -0
  65. package/dist/{types-xZtSmrGA.d.mts → types-NtSv6gwl.d.mts} +3 -3
  66. package/dist/webhook/index.d.mts +2 -2
  67. package/dist/webhook/index.mjs +1 -1
  68. package/package.json +19 -18
  69. package/src/catalog/retry.ts +25 -0
  70. package/src/catalog/table.ts +73 -37
  71. package/src/connector-app/create-table.ts +8 -8
  72. package/src/connector-app/demo.ts +24 -19
  73. package/src/connector-app/index.ts +1 -0
  74. package/src/connector-app/setup.ts +69 -0
  75. package/src/core/types.ts +1 -1
  76. package/src/demo/definition.ts +1 -1
  77. package/src/demo/generate.ts +1 -1
  78. package/src/demo/run.ts +60 -30
  79. package/src/iceberg/annotations.ts +3 -16
  80. package/src/iceberg/index.ts +2 -2
  81. package/src/iceberg/table.ts +28 -78
  82. package/src/ingestion/engine.ts +1 -1
  83. package/src/ingestor/{wings.ts → arrow-flight.ts} +25 -27
  84. package/src/ingestor/console.ts +1 -1
  85. package/src/ingestor/index.ts +5 -1
  86. package/src/runtime-config/config.ts +8 -3
  87. package/src/runtime-config/constants.ts +2 -1
  88. package/src/runtime-config/index.ts +1 -1
  89. package/src/runtime-config/table-bindings.ts +6 -4
  90. package/src/telemetry.ts +11 -19
  91. package/dist/connector-app-C-L4QqG6.mjs +0 -123
  92. package/dist/connector-app-C-L4QqG6.mjs.map +0 -1
  93. package/dist/constants-D-GQzpHZ.mjs.map +0 -1
  94. package/dist/demo-B30Vlkk2.mjs.map +0 -1
  95. package/dist/iceberg-D6L8I6vA.mjs +0 -39
  96. package/dist/iceberg-D6L8I6vA.mjs.map +0 -1
  97. package/dist/index-CUPP2A_m.d.mts +0 -27
  98. package/dist/ingestor-D4L-HPkg.mjs.map +0 -1
  99. package/dist/metrics-BaEX__MN.mjs.map +0 -1
  100. package/dist/runtime-config-Oa55gAew.mjs.map +0 -1
  101. package/dist/table-V0tgUC5i.mjs.map +0 -1
  102. package/dist/wings-I56hGtNv.mjs.map +0 -1
package/LICENSE.txt ADDED
@@ -0,0 +1,201 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 GNC Labs Limited
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
193
+ this file except in compliance with the License. You may obtain a copy of the
194
+ License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software distributed
199
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
200
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
201
+ specific language governing permissions and limitations under the License.
package/METRICS.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Connector Metrics And Status
2
2
 
3
- Connector Kit emits standard metrics through Effect metrics. Production runtimes should use `Telemetry.layerOtlp()` with `OTEL_ENABLED=true`, `OTEL_EXPORTER_OTLP_ENDPOINT`, and optional `OTEL_EXPORTER_OTLP_HEADERS`. HTTP runtimes expose shallow process health at `GET /health`, Prometheus text at `GET /metrics`, and durable sync state at `GET /status`. Sandboxes can also merge `Telemetry.layerMetricsConsoleDump()` for periodic log output.
3
+ Connector Kit emits standard metrics through Effect metrics.
4
+
5
+ ## Configuration
6
+
7
+ ### Production
8
+
9
+ Production runtimes should use `Telemetry.layerOtlp()` with `OTEL_ENABLED=true`, `OTEL_EXPORTER_OTLP_ENDPOINT`, and optional `OTEL_EXPORTER_OTLP_HEADERS`.
10
+
11
+ ### Sandbox
12
+
13
+ Sandboxes can also merge `Telemetry.layerMetricsConsoleDump()` for periodic log output.
4
14
 
5
15
  ## Metrics
6
16
 
@@ -16,19 +26,24 @@ Connector Kit emits standard metrics through Effect metrics. Production runtimes
16
26
  | `airfoil.connector.last_success.timestamp` | `airfoil_connector_last_success_timestamp` | gauge | `s` |
17
27
  | `airfoil.connector.api.retries` | `airfoil_connector_api_retries` | counter | `{retry}` |
18
28
 
19
- OTLP attributes use dotted OTel names. Common dimensions are `airfoil.connector.name`, `airfoil.resource.name`, and `airfoil.resource.source`; specialized attributes are `airfoil.batch.outcome`, `airfoil.webhook.path`, `airfoil.webhook.outcome`, `airfoil.connector.sync.state`, and `airfoil.connector.api.retry.reason`. The Prometheus endpoint replaces dots in metric and label names with underscores and does not append `_total`.
29
+ ### Fields
20
30
 
21
- Batch `source` is `backfill`, `changes`, `webhook`, or `demo`. Batch `outcome` is `success` or `error`. Webhook `outcome` is `ok`, `read_error`, `invalid_json`, `invalid_payload`, `rejected`, or `handler_error`. Sync `state` is `pending`, `backfilling`, `live`, or `error`.
31
+ **Batch**
22
32
 
23
- API retry `reason` is `transport`, `timeout`, `rate_limit`, or `server_error`. The counter increments only when another request will be attempted. Provider-side limiter waits without a failed request are not retries.
33
+ - `source`: `backfill`, `changes`, `webhook`, or `demo`.
34
+ - `outcome`: `success` or `error`.
24
35
 
25
- Counters are activity since process start, not table population. Use `increase()` or `rate()` and let Prometheus/OTLP consumers handle process restarts.
36
+ **Webhook**
26
37
 
27
- The last-success gauge is restored from durable state after restart and is `0` until the source commits its first checkpoint. Calculate source freshness in Prometheus:
38
+ - `outcome`: `ok`, `read_error`, `invalid_json`, `invalid_payload`, `rejected`, or `handler_error`.
28
39
 
29
- ```promql
30
- time() - airfoil_connector_last_success_timestamp
31
- ```
40
+ **Sync**
41
+
42
+ - `state`: `pending`, `backfilling`, `live`, or `error`.
43
+
44
+ **API retry**
45
+
46
+ - `reason`: `transport`, `timeout`, `rate_limit`, or `server_error`.
32
47
 
33
48
  ## Sync Status
34
49
 
@@ -55,25 +70,7 @@ HTTP connector runtimes expose `GET /status` by default. The response shape is d
55
70
  }
56
71
  ```
57
72
 
58
- `ResourceStatusSchema`, `ResourceErrorSchema`, and `StatusUnavailableResponseSchema` are also exported from `@useairfoil/connector-kit/status` with their derived TypeScript types.
59
-
60
- A resource with no persisted state is `pending`; an incomplete backfill is `backfilling`; completed backfill or changes-only resources are `live`. `lastSuccessAt` advances in the same durable write as its checkpoint and only after Wings acknowledges the batch.
61
-
62
- Backfill or changes failures set `error` with a structured `lastError`. The error includes `source`, `operation`, a stable `code` and SDK-owned `message`, plus `at`; it never contains the raw Effect cause. Backfill and changes errors are stored independently, and `/status` returns the newer outstanding error when both exist.
63
-
64
- When an expected source failure reaches the ingestion engine after any dependency retries, that source is parked until the process restarts. Other resources, webhooks, and HTTP routes keep running. Defects and interruption still terminate the runtime. `GET /health` only proves that the HTTP process is serving requests; provider, Wings, or PostgreSQL failures are reported through status and metrics instead.
65
-
66
- ## Wings Contract
67
-
68
- Import pure connector manifests from first-party producer packages, for example `@useairfoil/producer-polar/manifest`, through a registry. Use `Manifest.decodeConfig(manifest, input)` for canonical server-side validation and `Schema.toStandardSchemaV1(Manifest.configSchema(manifest))` for form resolvers. The schema accepts JSON-shaped config and browser form-shaped values, including stringified numbers/booleans and empty optional fields. Treat `field.required` and `field.default` independently: the canonical decoder treats an empty optional field as omitted and resolves its default, while an optional field without a default remains absent. Store user-facing connector config by manifest field `name`, then use `Manifest.toRuntimeDocument(...)` to map it to `field.runtimeKey` names. Hosted pods mount that complete JSON document read-only and point `AIRFOIL_CONFIG_PATH` at it; they do not receive one environment variable per user field. Secret rendering/redaction comes from `field.secret`, and existing secret values must not be returned to the browser. Platform-owned runtime config such as the Wings URL, Iceberg catalog and tables, PostgreSQL bindings, webhook ports, and telemetry remains infrastructure-owned environment/Secret configuration outside the manifest document.
69
-
70
- ```ts
71
- import * as Manifest from "@useairfoil/connector-kit/manifest";
72
- import { manifest as polarManifest } from "@useairfoil/producer-polar/manifest";
73
- import { Schema } from "effect";
74
-
75
- const schema = Schema.toStandardSchemaV1(Manifest.configSchema(polarManifest));
76
- const result = await schema["~standard"].validate(formValues);
77
- ```
73
+ For information about the shape of the response, look at `StatusResponseSchema` in
74
+ `@useairfoil/connector-kit/status`.
78
75
 
79
- Poll `GET /status` and decode with `Status.StatusResponseSchema`. Chart ingestion with `increase(airfoil_connector_rows_ingested[...])`, alert on `airfoil_connector_sync_state{airfoil_connector_sync_state="error"} == 1`, and alert on non-`ok` `airfoil_webhook_outcome` values.
76
+ HTTP runtimes expose shallow process health at `GET /health`, Prometheus at `GET /metrics`, and durable sync state at `GET /status`.
package/README.md CHANGED
@@ -13,9 +13,9 @@ pnpm add @useairfoil/connector-kit effect@^4
13
13
  - `Connector`, `Resource`, `Fetch`, and `Cursor` define the data flow.
14
14
  - `Manifest` defines user config.
15
15
  - `ConnectorApp` checks config and runs the HTTP server.
16
- - `Ingestor` writes batches to the console or Wings.
17
- - `StateStore` keeps ingestion progress.
18
16
  - `Webhook` defines webhook routes.
17
+ - `Ingestor` writes batches to the console or Iceberg.
18
+ - `StateStore` keeps ingestion progress.
19
19
 
20
20
  Here is a small resource:
21
21
 
@@ -83,28 +83,41 @@ read across runs.
83
83
  Each resource in the feed stores the feed cursor, so status shows it per
84
84
  resource. A resource in the feed cannot also define its own `changes`.
85
85
 
86
- `fetch` also gets `selected`, the resources that run. Skip the work for the
87
- others.
86
+ The Airfoil Storage Engine supports upsert operations on Iceberg rows. Use the
87
+ `Iceberg.identifier` helper to annotate identifier rows (primary keys). This
88
+ annotation must always be used last.
89
+
90
+ Upsert operations replace the full row conten, for this reason the change feed
91
+ must include all fields. If the webhook events don't include all fields, the
92
+ implementation must fetch the resource before pushing it into the engine.
93
+
94
+ The Airfoil Storage Engine implements soft deletions. To delete a row, push only
95
+ the key, version column (if any), `_deleted = true` and any other required column.
96
+ If the target service supports restoring records, the connector must send
97
+ `_deleted = false` with every row.
98
+
99
+ ### Running
88
100
 
89
- `Iceberg.identifier` names the row key. Put it last on the schema. Wings
90
- upserts rows with the same key, and replaces the whole row.
101
+ When testing locally, you can run the connector in memory:
91
102
 
92
- So changes and webhooks return full rows. When a webhook leaves fields out,
93
- read the record again. For a delete, send only the key, version, and
94
- `_deleted: true`; the other columns become null. Send `_deleted: false` on other
95
- rows only when the provider can restore records, so a restore comes back.
96
- Otherwise leave it out.
103
+ - `StateStore.layerMemory`: stores the connector's state in memory.
104
+ - `Ingestor.layerConsole`: outputs new batches to console.
97
105
 
98
- For local runs, use `StateStore.layerMemory` and `Ingestor.layerConsole`. For a
99
- hosted run, use `RuntimeConfig.layerHosted()`, PostgreSQL state, and
100
- `Ingestor.layerWingsConfig(connector)`.
106
+ For a durable run:
107
+
108
+ - `RuntimeConfig.layerHosted()`: loads the configuration from a file.
109
+ - `StateStore.layerSql()`: stores the connector's state in PostgreSQL.
110
+ - `Ingestor.layerArrowFlightConfig(connector)`: publish data to Apache Iceberg
111
+ using the Airfoil Storage Engine and Arrow Flight.
112
+
113
+ The built-in HTTP server has `/health`, `/status`, and `/metrics` endpoints.
101
114
 
102
115
  ## Configuration
103
116
 
104
117
  | Variable | Required | Default |
105
118
  | ------------------------------- | -------- | --------------------------- |
106
119
  | `AIRFOIL_CONFIG_PATH` | yes | none |
107
- | `WINGS_URI` | yes | none |
120
+ | `ENGINE_URI` | yes | none |
108
121
  | `AIRFOIL_CATALOG` | yes | none |
109
122
  | `AIRFOIL_TABLE_BINDINGS` | yes | none |
110
123
  | `AIRFOIL_CONNECTOR_INSTANCE_ID` | yes | none |
@@ -112,18 +125,16 @@ hosted run, use `RuntimeConfig.layerHosted()`, PostgreSQL state, and
112
125
  | `AIRFOIL_HTTP_PORT` | no | `8080` |
113
126
  | `AIRFOIL_STATE_TABLE` | no | `_airfoil_connectors_state` |
114
127
 
128
+ The `AIRFOIL_TABLE_BINDINGS` environment variables controls which resources are
129
+ synced and the target table. At least one resource must be defined.
130
+
115
131
  ```env
116
- AIRFOIL_TABLE_BINDINGS={"posts":{"namespace":["default"],"name":"posts","location":"s3://warehouse/default/posts"}}
132
+ AIRFOIL_TABLE_BINDINGS={"posts":{"namespace":["default"],"name":"posts"}}
117
133
  ```
118
134
 
119
- Only the resources in `AIRFOIL_TABLE_BINDINGS` run. List at least one, and use
120
- only the connector's resource names.
121
-
122
135
  Use only lowercase letters, numbers, and underscores in table names. S3 Tables
123
136
  catalogs reject other characters, such as `-`.
124
137
 
125
- The HTTP server has `/health`, `/status`, and `/metrics` endpoints.
126
-
127
138
  ## Demo data
128
139
 
129
140
  A connector with a demo has a `demo` command. It writes made-up rows to
@@ -143,7 +154,7 @@ producer-stripe demo --size 128MiB --seed 42
143
154
  - Setup tables, written once, such as a product catalog, don't grow. If only
144
155
  those are bound, the run writes them once and stops below the size. Demos
145
156
  with limited history, such as daily reports, also stop when they run out.
146
- - It needs `AIRFOIL_CONFIG_PATH`, `WINGS_URI`, `AIRFOIL_CATALOG`, and
157
+ - It needs `AIRFOIL_CONFIG_PATH`, `ENGINE_URI`, `AIRFOIL_CATALOG`, and
147
158
  `AIRFOIL_TABLE_BINDINGS`. An empty `{}` config file is enough.
148
159
 
149
160
  A demo lists its `setup` and `group` tables and builds their rows with
@@ -151,32 +162,3 @@ A demo lists its `setup` and `group` tables and builds their rows with
151
162
  rows can point to them. Required fields a row leaves out get placeholder values
152
163
  from the row schema. Every row is checked against its row schema before it's
153
164
  written.
154
-
155
- ## Iceberg field IDs
156
-
157
- Give each field a unique ID. Keep its ID if you rename it, and never reuse an ID
158
- after removing a field. Use `Iceberg.field` for struct fields. Put list element
159
- and map key/value IDs on their schemas with `.annotate({ fieldId })`.
160
-
161
- ```ts
162
- import { Iceberg } from "@useairfoil/connector-kit";
163
- import { Schema } from "effect";
164
-
165
- const Row = Schema.Struct({
166
- id: Schema.String.pipe(Iceberg.field(1, { description: "Row ID." })),
167
- tags: Schema.Array(Schema.String.annotate({ fieldId: 101 })).pipe(
168
- Iceberg.field(2, { description: "Tags for the row." }),
169
- ),
170
- })
171
- .annotate({ description: "Example rows." })
172
- .pipe(Iceberg.identifier("id"));
173
- ```
174
-
175
- Hosted connectors create missing tables from these bindings. To create one
176
- manually, use the connector's `create-table <namespace.table> --catalog <id>`
177
- command. Use `--resource <name>` if the table name differs from the resource.
178
-
179
- Both paths use `commitTable` and check the schema after creation. The catalog's
180
- `createTable` can change field IDs. Set `location` in the binding, or pass
181
- `--location <uri>` to the command, if the catalog cannot choose a location or
182
- you want to choose it yourself.
@@ -3,15 +3,10 @@ import { Schema } from "effect";
3
3
  declare module "effect/Schema" {
4
4
  namespace Annotations {
5
5
  interface Annotations {
6
- readonly fieldId?: number | undefined;
7
6
  readonly icebergIdentifierFields?: ReadonlyArray<string> | undefined;
8
7
  }
9
8
  }
10
9
  }
11
- /** Sets a field's Iceberg ID, and any other annotations. */
12
- declare const field: <A = unknown>(fieldId: number, annotations?: Schema.Annotations.Key<A>) => <S extends Schema.Schema<A>>(schema: S) => S["Rebuild"];
13
- /** Adds an offset to a base ID for reusable schemas. */
14
- declare const ids: (baseId: number) => (offset: number) => number;
15
10
  type KnownField<S extends Schema.Top> = keyof S["Type"] & string;
16
11
  /** A row field that cannot be null or undefined. */
17
12
  type RequiredField<S extends Schema.Top> = [KnownField<S>] extends [never] ? string : { readonly [Field in KnownField<S>]-?: undefined extends S["Type"][Field] ? never : null extends S["Type"][Field] ? never : Field; }[KnownField<S>];
@@ -20,7 +15,7 @@ interface Identified<Key extends string> {
20
15
  readonly "~iceberg.identifier": Key;
21
16
  }
22
17
  /**
23
- * Marks the fields that identify a row. Wings upserts rows by them.
18
+ * Marks the fields that identify a row. The engine upserts rows by them.
24
19
  *
25
20
  * Put it last. A later `.annotate()` keeps the runtime annotation, but the type
26
21
  * loses the key, so `Resource.entity` stops compiling.
@@ -28,12 +23,12 @@ interface Identified<Key extends string> {
28
23
  * @example
29
24
  * ```ts
30
25
  * const Post = Schema.Struct({
31
- * id: Schema.String.pipe(Iceberg.field(1)),
32
- * updatedAt: Schema.String.pipe(Iceberg.field(2)),
26
+ * id: Schema.String,
27
+ * updatedAt: Schema.String,
33
28
  * }).pipe(Iceberg.identifier("id"));
34
29
  * ```
35
30
  */
36
31
  declare const identifier: <S extends Schema.Top, const Key extends RequiredField<S>>(...keys: readonly [Key, ...ReadonlyArray<Key>]) => (schema: S) => S["Rebuild"] & Identified<Key>;
37
32
  //#endregion
38
- export { ids as a, identifier as i, RequiredField as n, field as r, Identified as t };
39
- //# sourceMappingURL=annotations-BE74YmAO.d.mts.map
33
+ export { RequiredField as n, identifier as r, Identified as t };
34
+ //# sourceMappingURL=annotations-vzSzXtr-.d.mts.map
@@ -1,86 +1,12 @@
1
1
  import { t as ConnectorError } from "./errors-pT0YVJU5.mjs";
2
- import { a as IcebergSchemaError, n as compileTable, r as makeCommitRequest } from "./table-V0tgUC5i.mjs";
3
- import { a as catalog, n as loadTableBindings, s as wingsUri } from "./runtime-config-Oa55gAew.mjs";
2
+ import { n as compileTable } from "./table-CxM09xf7.mjs";
3
+ import { a as catalog, n as loadTableBindings, o as engineUri, s as flightUri } from "./runtime-config-Bn8Fivt1.mjs";
4
4
  import { t as Ingestor } from "./service-jWxxfEht.mjs";
5
5
  import { Config, Effect, Layer, Schema } from "effect";
6
- import * as Wings from "@useairfoil/wings";
6
+ import { CatalogManager } from "@useairfoil/api";
7
7
  import { FetchHttpClient } from "effect/http";
8
- import { getCurrentSchema, parseDecimalType, parseFixedType } from "iceberg-js";
8
+ import { parseDecimalType, parseFixedType } from "iceberg-js";
9
9
  import { Bool, DateDay, Decimal, Field, FixedSizeBinary, Float32, Float64, Int32, Int64, LargeBinary, List, Map_, RecordBatch, Schema as Schema$1, Struct as Struct$1, TimeMicrosecond, TimestampMicrosecond, Utf8, makeBuilder } from "apache-arrow";
10
- //#region src/catalog/table.ts
11
- const tableError = (cause) => {
12
- if (cause instanceof ConnectorError) return cause;
13
- const message = cause instanceof Error ? cause.message : "Failed to prepare Iceberg table";
14
- return new ConnectorError({
15
- message: cause instanceof IcebergSchemaError ? `${cause.path}: ${message}` : message,
16
- cause
17
- });
18
- };
19
- const compareTypes = (expected, actual, path) => {
20
- if (typeof expected === "string" || typeof actual === "string") return expected === actual ? void 0 : path;
21
- if (expected.type !== actual.type) return path;
22
- switch (expected.type) {
23
- case "struct":
24
- if (actual.type !== "struct") return path;
25
- return compareFields(expected.fields, actual.fields, path);
26
- case "list":
27
- if (actual.type !== "list" || expected["element-id"] !== actual["element-id"] || expected["element-required"] !== actual["element-required"]) return path;
28
- return compareTypes(expected.element, actual.element, `${path}.element`);
29
- case "map":
30
- if (actual.type !== "map" || expected["key-id"] !== actual["key-id"] || expected["value-id"] !== actual["value-id"] || expected["value-required"] !== actual["value-required"]) return path;
31
- return compareTypes(expected.key, actual.key, `${path}.key`) ?? compareTypes(expected.value, actual.value, `${path}.value`);
32
- }
33
- };
34
- const compareFields = (expected, actual, path) => {
35
- if (expected.length !== actual.length) return path;
36
- for (const field of expected) {
37
- const fieldPath = `${path}.${field.name}`;
38
- const other = actual.find((candidate) => candidate.name === field.name);
39
- if (!other || field.id !== other.id || field.required !== other.required) return fieldPath;
40
- const mismatch = compareTypes(field.type, other.type, fieldPath);
41
- if (mismatch) return mismatch;
42
- }
43
- };
44
- const verifyTable = (metadata, expected) => Effect.try({
45
- try: () => {
46
- if (!Array.isArray(metadata.schemas)) throw new Error("Invalid table metadata");
47
- const actual = getCurrentSchema(metadata);
48
- if (!actual) throw new Error("Table has no current schema");
49
- const path = compareFields(expected.fields, actual.fields, "$");
50
- if (path) throw new Error(`Table schema does not match at ${path}. Migrate the table or revert the schema change.`);
51
- const expectedIds = new Set(expected["identifier-field-ids"]);
52
- const actualIds = new Set(actual["identifier-field-ids"]);
53
- if (expectedIds.size !== actualIds.size || [...expectedIds].some((id) => !actualIds.has(id))) throw new Error("Table identifier fields do not match. Recreate the table or revert the schema change.");
54
- return actual;
55
- },
56
- catch: (cause) => new ConnectorError({
57
- message: cause instanceof Error ? cause.message : "Invalid table metadata",
58
- cause
59
- })
60
- });
61
- /** Creates a table with the IDs from its Effect schema, then checks the loaded schema. */
62
- const createTable = (schema, options) => Effect.gen(function* () {
63
- const table = yield* compileTable(schema);
64
- yield* options.catalog.commitTable(options.identifier, makeCommitRequest(table, { location: options.location }));
65
- const metadata = yield* options.catalog.loadTable(options.identifier);
66
- return yield* verifyTable(metadata, table.schema);
67
- }).pipe(Effect.mapError(tableError));
68
- /** Creates a table through a Wings catalog. */
69
- const createTableFromWings = (schema, options) => Effect.scoped(Effect.gen(function* () {
70
- const catalog = yield* (yield* Wings.CatalogManager.make({ baseUrl: options.wingsUri })).getIcebergCatalog(options.catalogId);
71
- return yield* createTable(schema, {
72
- catalog,
73
- identifier: options.identifier,
74
- location: options.location
75
- });
76
- })).pipe(Effect.mapError(tableError));
77
- /** Loads a table, creating it when it is missing. */
78
- const ensureTable = (schema, options) => Effect.gen(function* () {
79
- const table = yield* compileTable(schema);
80
- const metadata = yield* options.catalog.loadTable(options.identifier).pipe(Effect.catchIf((error) => error.status === 404, () => options.catalog.commitTable(options.identifier, makeCommitRequest(table, { location: options.location })).pipe(Effect.catchIf((error) => error.status === 409 || error.status === 412, () => Effect.void), Effect.flatMap(() => options.catalog.loadTable(options.identifier)))));
81
- return yield* verifyTable(metadata, table.schema);
82
- }).pipe(Effect.mapError(tableError));
83
- //#endregion
84
10
  //#region src/ingestor/arrow.ts
85
11
  const bytes = (length) => Schema.Uint8Array.check(Schema.makeFilter((value) => value.byteLength === length || `expected ${length} bytes`));
86
12
  const int32 = Schema.Number.check(Schema.isInt(), Schema.isBetween({
@@ -244,30 +170,25 @@ const makeRowEncoder = (tableSchema, version) => Effect.try({
244
170
  })
245
171
  });
246
172
  //#endregion
247
- //#region src/ingestor/wings.ts
173
+ //#region src/ingestor/arrow-flight.ts
248
174
  const connectorError = (message, cause) => new ConnectorError({
249
175
  message,
250
176
  cause
251
177
  });
252
- /** Loads each table schema and opens one Wings stream per bound resource. */
253
- const layerWings = (config) => Layer.effect(Ingestor)(Effect.gen(function* () {
254
- const manager = yield* Wings.CatalogManager.CatalogManager;
255
- const catalog = yield* manager.getIcebergCatalog(config.catalog).pipe(Effect.mapError((cause) => connectorError("Failed to load Wings catalog", cause)));
178
+ /** Compiles local schemas and opens one Arrow Flight stream per bound resource. */
179
+ const layerArrowFlight = (config) => Layer.effect(Ingestor)(Effect.gen(function* () {
180
+ const manager = yield* CatalogManager.CatalogManager;
256
181
  const bindings = config.tables;
257
182
  const prepared = [];
258
183
  for (const resource of config.connector.resources) {
259
184
  const binding = bindings[resource.name];
260
185
  if (!binding) continue;
261
- const { namespace, name, location } = binding;
186
+ const { namespace, name } = binding;
262
187
  const identifier = {
263
188
  namespace,
264
189
  name
265
190
  };
266
- const schema = yield* ensureTable(resource.rowSchema, {
267
- catalog,
268
- identifier,
269
- location
270
- }).pipe(Effect.mapError((cause) => connectorError(`Failed to prepare table for ${resource.name}: ${cause.message}`, cause)));
191
+ const { schema } = yield* compileTable(resource.rowSchema).pipe(Effect.mapError((cause) => connectorError(`Invalid schema for ${resource.name}: ${cause.message}`, cause)));
271
192
  const encode = yield* makeRowEncoder(schema, resource.version);
272
193
  prepared.push({
273
194
  resource: resource.name,
@@ -304,22 +225,27 @@ const layerWings = (config) => Layer.effect(Ingestor)(Effect.gen(function* () {
304
225
  };
305
226
  return Ingestor.of(service);
306
227
  }));
307
- /** Reads the Wings URL, catalog and table bindings from hosted config. */
308
- const layerWingsConfig = (connector) => Layer.unwrap(Effect.gen(function* () {
309
- const { catalog: catalog$1, uri } = yield* Config.all({
228
+ /** Configures Arrow Flight ingestion from the hosted URL, catalog and table bindings. */
229
+ const layerArrowFlightConfig = (connector) => Layer.unwrap(Effect.gen(function* () {
230
+ const { catalog: catalog$1, uri, flightUri: flightUri$1 } = yield* Config.all({
310
231
  catalog,
311
- uri: wingsUri
312
- }).pipe(Effect.mapError((cause) => connectorError("Invalid Wings configuration", cause)));
313
- if (uri.protocol !== "http:" && uri.protocol !== "https:") return yield* Effect.fail(connectorError("Invalid Wings URL"));
232
+ uri: engineUri,
233
+ flightUri
234
+ }).pipe(Effect.mapError((cause) => connectorError("Invalid Arrow Flight configuration", cause)));
235
+ if (uri.protocol !== "http:" && uri.protocol !== "https:") return yield* Effect.fail(connectorError("Invalid Arrow Flight URL"));
236
+ if (flightUri$1.protocol !== "http:" && flightUri$1.protocol !== "https:") return yield* Effect.fail(connectorError("Invalid Arrow Flight URL"));
314
237
  const tables = yield* loadTableBindings(connector).pipe(Effect.mapError((cause) => connectorError(cause.message, cause)));
315
- const manager = Wings.CatalogManager.layer({ baseUrl: uri.href }).pipe(Layer.provide(FetchHttpClient.layer));
316
- return layerWings({
238
+ const manager = CatalogManager.layer({
239
+ engineUri: uri.href,
240
+ flightUri: flightUri$1.href
241
+ }).pipe(Layer.provide(FetchHttpClient.layer));
242
+ return layerArrowFlight({
317
243
  connector,
318
244
  catalog: catalog$1,
319
245
  tables
320
246
  }).pipe(Layer.provide(manager));
321
247
  }));
322
248
  //#endregion
323
- export { layerWingsConfig as n, createTableFromWings as r, layerWings as t };
249
+ export { layerArrowFlightConfig as n, layerArrowFlight as t };
324
250
 
325
- //# sourceMappingURL=wings-I56hGtNv.mjs.map
251
+ //# sourceMappingURL=arrow-flight-DDQ0ktx9.mjs.map