@useairfoil/connector-kit 0.6.0 → 0.6.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 (179) hide show
  1. package/METRICS.md +16 -17
  2. package/README.md +127 -442
  3. package/dist/annotations-BE74YmAO.d.mts +39 -0
  4. package/dist/auth/index.d.mts +2 -0
  5. package/dist/{auth-DvU_CZ7C.js → auth/index.mjs} +6 -8
  6. package/dist/auth/index.mjs.map +1 -0
  7. package/dist/connector-app/index.d.mts +2 -0
  8. package/dist/connector-app/index.mjs +2 -0
  9. package/dist/connector-app-C-L4QqG6.mjs +123 -0
  10. package/dist/connector-app-C-L4QqG6.mjs.map +1 -0
  11. package/dist/{constants-D113Ut1x.js → constants-D-GQzpHZ.mjs} +4 -5
  12. package/dist/constants-D-GQzpHZ.mjs.map +1 -0
  13. package/dist/demo/index.d.mts +2 -0
  14. package/dist/demo/index.mjs +2 -0
  15. package/dist/demo-B30Vlkk2.mjs +191 -0
  16. package/dist/demo-B30Vlkk2.mjs.map +1 -0
  17. package/dist/errors/index.d.mts +2 -0
  18. package/dist/errors/index.mjs +2 -0
  19. package/dist/{errors-DHWylqRZ.js → errors-pT0YVJU5.mjs} +2 -3
  20. package/dist/errors-pT0YVJU5.mjs.map +1 -0
  21. package/dist/iceberg/index.d.mts +3 -0
  22. package/dist/iceberg/index.mjs +3 -0
  23. package/dist/iceberg-D6L8I6vA.mjs +39 -0
  24. package/dist/iceberg-D6L8I6vA.mjs.map +1 -0
  25. package/dist/{index-VpHaZXZw.d.ts → index-BUHSGm9Q.d.mts} +11 -13
  26. package/dist/{index-DXa26Ry5.d.ts → index-BX8G7d41.d.mts} +1 -2
  27. package/dist/{index-bfjH7Yb0.d.ts → index-BfXpgxk9.d.mts} +9 -10
  28. package/dist/{index-BKw7jA2a.d.ts → index-CRVAwJ5-.d.mts} +10 -8
  29. package/dist/index-CUPP2A_m.d.mts +27 -0
  30. package/dist/{index-DYpEMJf-.d.ts → index-CgvFomO6.d.mts} +6 -7
  31. package/dist/index-DJhDp4Xc.d.mts +58 -0
  32. package/dist/index-Dk7urvpF.d.mts +76 -0
  33. package/dist/{index-DKoRwyFn.d.ts → index-DkVNO6ks.d.mts} +2 -5
  34. package/dist/{index-C5Ma7V7t.d.ts → index-NnCutIqM.d.mts} +62 -37
  35. package/dist/{index-CR9HJDdr.d.ts → index-eFuoMZZ3.d.mts} +18 -20
  36. package/dist/{index-ZSuiZX5H.d.ts → index-ygpml2kC.d.mts} +19 -31
  37. package/dist/index.d.mts +16 -0
  38. package/dist/index.mjs +45 -0
  39. package/dist/index.mjs.map +1 -0
  40. package/dist/ingestion/index.d.mts +2 -0
  41. package/dist/ingestion/index.mjs +2 -0
  42. package/dist/ingestion-q0WwqUSt.mjs +275 -0
  43. package/dist/ingestion-q0WwqUSt.mjs.map +1 -0
  44. package/dist/ingestor/index.d.mts +3 -0
  45. package/dist/ingestor/index.mjs +4 -0
  46. package/dist/ingestor-D4L-HPkg.mjs +26 -0
  47. package/dist/ingestor-D4L-HPkg.mjs.map +1 -0
  48. package/dist/instrumented-Bhp7fyvh.mjs +29 -0
  49. package/dist/instrumented-Bhp7fyvh.mjs.map +1 -0
  50. package/dist/manifest/index.d.mts +2 -0
  51. package/dist/manifest/{index.js → index.mjs} +2 -4
  52. package/dist/{manifest-P7kBnch9.js → manifest-BGKxmKLy.mjs} +14 -19
  53. package/dist/manifest-BGKxmKLy.mjs.map +1 -0
  54. package/dist/{telemetry-j_nxwYfh.js → metrics-BaEX__MN.mjs} +170 -19
  55. package/dist/metrics-BaEX__MN.mjs.map +1 -0
  56. package/dist/{metrics-C4V1pm6v.d.ts → metrics-CVXFL7YT.d.mts} +18 -13
  57. package/dist/metrics.d.mts +2 -0
  58. package/dist/metrics.mjs +2 -0
  59. package/dist/{chunk-Bp6m_JJh.js → rolldown-runtime-D7D4PA-g.mjs} +4 -4
  60. package/dist/runtime-config/index.d.mts +2 -0
  61. package/dist/runtime-config/index.mjs +3 -0
  62. package/dist/runtime-config-Oa55gAew.mjs +97 -0
  63. package/dist/runtime-config-Oa55gAew.mjs.map +1 -0
  64. package/dist/server-CMnxz3h0.mjs +144 -0
  65. package/dist/server-CMnxz3h0.mjs.map +1 -0
  66. package/dist/service-DLkhuxYl.d.mts +27 -0
  67. package/dist/service-jWxxfEht.mjs +7 -0
  68. package/dist/service-jWxxfEht.mjs.map +1 -0
  69. package/dist/state-store/index.d.mts +2 -0
  70. package/dist/state-store/index.mjs +2 -0
  71. package/dist/{state-store-BdYulQOY.js → state-store-uFvHY7Ax.mjs} +15 -22
  72. package/dist/state-store-uFvHY7Ax.mjs.map +1 -0
  73. package/dist/status/{index.d.ts → index.d.mts} +1 -4
  74. package/dist/status/{index.js → index.mjs} +2 -6
  75. package/dist/{status-BTTd7AUR.js → status-CKb9IhQ9.mjs} +14 -16
  76. package/dist/status-CKb9IhQ9.mjs.map +1 -0
  77. package/dist/table-V0tgUC5i.mjs +370 -0
  78. package/dist/table-V0tgUC5i.mjs.map +1 -0
  79. package/dist/types-xZtSmrGA.d.mts +220 -0
  80. package/dist/webhook/index.d.mts +3 -0
  81. package/dist/webhook/index.mjs +12 -0
  82. package/dist/webhook/index.mjs.map +1 -0
  83. package/dist/wings-I56hGtNv.mjs +325 -0
  84. package/dist/wings-I56hGtNv.mjs.map +1 -0
  85. package/package.json +64 -51
  86. package/src/catalog/table.ts +201 -0
  87. package/src/connector-app/create-table.ts +47 -0
  88. package/src/connector-app/demo.ts +42 -0
  89. package/src/connector-app/index.ts +2 -0
  90. package/src/connector-app/start.ts +1 -1
  91. package/src/core/builder.ts +15 -23
  92. package/src/core/index.ts +11 -1
  93. package/src/core/types.ts +114 -39
  94. package/src/demo/definition.ts +68 -0
  95. package/src/demo/generate.ts +167 -0
  96. package/src/demo/index.ts +3 -0
  97. package/src/demo/run.ts +142 -0
  98. package/src/iceberg/annotations.ts +62 -0
  99. package/src/iceberg/error.ts +9 -0
  100. package/src/iceberg/index.ts +3 -0
  101. package/src/iceberg/table.ts +511 -0
  102. package/src/index.ts +3 -1
  103. package/src/ingestion/engine.ts +240 -60
  104. package/src/ingestor/arrow.ts +248 -0
  105. package/src/ingestor/console.ts +13 -0
  106. package/src/ingestor/index.ts +9 -0
  107. package/src/ingestor/instrumented.ts +61 -0
  108. package/src/ingestor/service.ts +30 -0
  109. package/src/ingestor/wings.ts +143 -0
  110. package/src/manifest/config.ts +3 -3
  111. package/src/metrics.ts +66 -20
  112. package/src/runtime-config/config.ts +6 -8
  113. package/src/runtime-config/constants.ts +2 -2
  114. package/src/runtime-config/index.ts +2 -7
  115. package/src/runtime-config/layer.ts +1 -1
  116. package/src/runtime-config/table-bindings.ts +48 -136
  117. package/src/state-store/layer-key-value-store.ts +8 -3
  118. package/src/state-store/layer-memory.ts +1 -1
  119. package/src/state-store/layer-sql.ts +4 -4
  120. package/src/state-store/schema.ts +2 -2
  121. package/src/state-store/state.ts +14 -2
  122. package/src/status/route.ts +2 -2
  123. package/src/telemetry.ts +10 -10
  124. package/src/webhook/server.ts +39 -40
  125. package/dist/auth/index.d.ts +0 -2
  126. package/dist/auth/index.js +0 -3
  127. package/dist/auth-DvU_CZ7C.js.map +0 -1
  128. package/dist/connector-app/index.d.ts +0 -14
  129. package/dist/connector-app/index.js +0 -12
  130. package/dist/connector-app-BljHd0Pe.js +0 -64
  131. package/dist/connector-app-BljHd0Pe.js.map +0 -1
  132. package/dist/constants-D113Ut1x.js.map +0 -1
  133. package/dist/errors/index.d.ts +0 -2
  134. package/dist/errors/index.js +0 -3
  135. package/dist/errors-DHWylqRZ.js.map +0 -1
  136. package/dist/index-BA8ASHKr.d.ts +0 -31
  137. package/dist/index.d.ts +0 -14
  138. package/dist/index.js +0 -60
  139. package/dist/index.js.map +0 -1
  140. package/dist/ingestion/index.d.ts +0 -6
  141. package/dist/ingestion/index.js +0 -11
  142. package/dist/ingestion-QBGKrFr9.js +0 -200
  143. package/dist/ingestion-QBGKrFr9.js.map +0 -1
  144. package/dist/manifest/index.d.ts +0 -2
  145. package/dist/manifest-P7kBnch9.js.map +0 -1
  146. package/dist/metrics-inkCAxKq.js +0 -136
  147. package/dist/metrics-inkCAxKq.js.map +0 -1
  148. package/dist/metrics.d.ts +0 -4
  149. package/dist/metrics.js +0 -5
  150. package/dist/publisher/index.d.ts +0 -6
  151. package/dist/publisher/index.js +0 -8
  152. package/dist/publisher-BdWJOfer.js +0 -138
  153. package/dist/publisher-BdWJOfer.js.map +0 -1
  154. package/dist/runtime-config/index.d.ts +0 -4
  155. package/dist/runtime-config/index.js +0 -5
  156. package/dist/runtime-config-IbyCVpei.js +0 -60
  157. package/dist/runtime-config-IbyCVpei.js.map +0 -1
  158. package/dist/server-D-eLX3yN.js +0 -183
  159. package/dist/server-D-eLX3yN.js.map +0 -1
  160. package/dist/service-CUjGhe-7.d.ts +0 -32
  161. package/dist/service-DiP-XETo.js +0 -8
  162. package/dist/service-DiP-XETo.js.map +0 -1
  163. package/dist/state-store/index.d.ts +0 -3
  164. package/dist/state-store/index.js +0 -5
  165. package/dist/state-store-BdYulQOY.js.map +0 -1
  166. package/dist/status-BTTd7AUR.js.map +0 -1
  167. package/dist/table-bindings-Dp1DhTeS.js +0 -106
  168. package/dist/table-bindings-Dp1DhTeS.js.map +0 -1
  169. package/dist/telemetry-j_nxwYfh.js.map +0 -1
  170. package/dist/types-jVD5Ys43.d.ts +0 -174
  171. package/dist/webhook/index.d.ts +0 -7
  172. package/dist/webhook/index.js +0 -9
  173. package/dist/webhook-MhFcLW-o.js +0 -13
  174. package/dist/webhook-MhFcLW-o.js.map +0 -1
  175. package/src/publisher/console.ts +0 -18
  176. package/src/publisher/index.ts +0 -7
  177. package/src/publisher/instrumented.ts +0 -75
  178. package/src/publisher/service.ts +0 -37
  179. package/src/publisher/wings.ts +0 -204
@@ -1,20 +1,18 @@
1
- import { t as __export } from "./chunk-Bp6m_JJh.js";
2
- import { r as isPlatformRuntimeKey } from "./constants-D113Ut1x.js";
3
- import { Config, Option, Predicate, Redacted, Schema, SchemaTransformation, Struct } from "effect";
4
-
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { r as isPlatformRuntimeKey } from "./constants-D-GQzpHZ.mjs";
3
+ import { Config, Predicate, Schema, SchemaTransformation, Struct } from "effect";
5
4
  //#region src/manifest/number-schema.ts
6
5
  const makeNumberSchema = (constraints) => {
7
6
  if (constraints.integer) return constraints.minimum === void 0 ? Schema.Int : Schema.Int.check(Schema.isGreaterThanOrEqualTo(constraints.minimum));
8
7
  return constraints.minimum === void 0 ? Schema.Finite : Schema.Finite.check(Schema.isGreaterThanOrEqualTo(constraints.minimum));
9
8
  };
10
-
11
9
  //#endregion
12
10
  //#region src/manifest/config.ts
13
11
  const configFieldToConfig = Struct.lambda((field) => field.config);
14
12
  const withDefault = (config, defaultValue) => defaultValue === void 0 ? config : Config.withDefault(config, defaultValue);
15
13
  /** Defines a required non-empty string, optionally with a default. */
16
14
  const string = (options) => ({
17
- config: withDefault(Config.nonEmptyString(options.runtimeKey), options.default),
15
+ config: withDefault(Config.NonEmptyString(options.runtimeKey), options.default),
18
16
  spec: {
19
17
  runtimeKey: options.runtimeKey,
20
18
  type: "string",
@@ -44,7 +42,7 @@ const number = (options) => {
44
42
  };
45
43
  /** Defines a boolean, optionally with a default. */
46
44
  const boolean = (options) => ({
47
- config: withDefault(Config.boolean(options.runtimeKey), options.default),
45
+ config: withDefault(Config.Boolean(options.runtimeKey), options.default),
48
46
  spec: {
49
47
  runtimeKey: options.runtimeKey,
50
48
  type: "boolean",
@@ -56,7 +54,7 @@ const boolean = (options) => ({
56
54
  });
57
55
  /** Defines a string literal choice whose values are preserved in the inferred type. */
58
56
  const select = (options) => ({
59
- config: withDefault(Config.literals(options.values, options.runtimeKey), options.default),
57
+ config: withDefault(Config.Literals(options.values, options.runtimeKey), options.default),
60
58
  spec: {
61
59
  runtimeKey: options.runtimeKey,
62
60
  type: "select",
@@ -102,7 +100,7 @@ const optional = (field) => ({
102
100
  * const formFields = config.spec;
103
101
  * ```
104
102
  */
105
- const define = (fields) => {
103
+ const define$1 = (fields) => {
106
104
  const spec = Object.entries(fields).map(([name, field]) => ({
107
105
  name,
108
106
  ...field.spec
@@ -116,7 +114,6 @@ const define = (fields) => {
116
114
  spec
117
115
  };
118
116
  };
119
-
120
117
  //#endregion
121
118
  //#region src/manifest/manifest.ts
122
119
  /**
@@ -132,8 +129,7 @@ const define = (fields) => {
132
129
  * });
133
130
  * ```
134
131
  */
135
- const define$1 = (manifest) => manifest;
136
-
132
+ const define = (manifest) => manifest;
137
133
  //#endregion
138
134
  //#region src/manifest/schema.ts
139
135
  const numberFromForm = (field) => {
@@ -199,15 +195,14 @@ const toRuntimeDocument = (manifest, values) => {
199
195
  }
200
196
  return document;
201
197
  };
202
-
203
198
  //#endregion
204
199
  //#region src/manifest/index.ts
205
- var manifest_exports = /* @__PURE__ */ __export({
200
+ var manifest_exports = /* @__PURE__ */ __exportAll({
206
201
  boolean: () => boolean,
207
202
  configSchema: () => configSchema,
208
203
  decodeConfig: () => decodeConfig,
209
- define: () => define$1,
210
- defineConfig: () => define,
204
+ define: () => define,
205
+ defineConfig: () => define$1,
211
206
  number: () => number,
212
207
  optional: () => optional,
213
208
  secret: () => secret,
@@ -215,7 +210,7 @@ var manifest_exports = /* @__PURE__ */ __export({
215
210
  string: () => string,
216
211
  toRuntimeDocument: () => toRuntimeDocument
217
212
  });
218
-
219
213
  //#endregion
220
- export { define$1 as a, number as c, select as d, string as f, toRuntimeDocument as i, optional as l, configSchema as n, boolean as o, decodeConfig as r, define as s, manifest_exports as t, secret as u };
221
- //# sourceMappingURL=manifest-P7kBnch9.js.map
214
+ export { define as a, number as c, select as d, string as f, toRuntimeDocument as i, optional as l, configSchema as n, boolean as o, decodeConfig as r, define$1 as s, manifest_exports as t, secret as u };
215
+
216
+ //# sourceMappingURL=manifest-BGKxmKLy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-BGKxmKLy.mjs","names":["define"],"sources":["../src/manifest/number-schema.ts","../src/manifest/config.ts","../src/manifest/manifest.ts","../src/manifest/schema.ts","../src/manifest/index.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport type NumberConstraints = {\n readonly integer?: boolean;\n readonly minimum?: number;\n};\n\nexport const makeNumberSchema = (constraints: NumberConstraints) => {\n if (constraints.integer) {\n return constraints.minimum === undefined\n ? Schema.Int\n : Schema.Int.check(Schema.isGreaterThanOrEqualTo(constraints.minimum));\n }\n return constraints.minimum === undefined\n ? Schema.Finite\n : Schema.Finite.check(Schema.isGreaterThanOrEqualTo(constraints.minimum));\n};\n","import { Config, Option, Redacted, Schema, Struct } from \"effect\";\n\nimport { isPlatformRuntimeKey } from \"../runtime-config/constants\";\nimport { makeNumberSchema, type NumberConstraints } from \"./number-schema\";\n\ntype ConfigFieldSpecBase = {\n readonly runtimeKey: string;\n readonly required: boolean;\n readonly description?: string;\n};\n\ntype ConfigFieldDefinition = ConfigFieldSpecBase &\n (\n | {\n readonly type: \"string\";\n readonly secret: false;\n readonly default?: string;\n readonly values?: never;\n }\n | {\n readonly type: \"string\";\n readonly secret: true;\n readonly default?: never;\n readonly values?: never;\n }\n | {\n readonly type: \"number\";\n readonly secret: false;\n readonly default?: number;\n readonly values?: never;\n readonly integer?: boolean;\n readonly minimum?: number;\n }\n | {\n readonly type: \"boolean\";\n readonly secret: false;\n readonly default?: boolean;\n readonly values?: never;\n }\n | {\n readonly type: \"select\";\n readonly secret: false;\n readonly default?: string;\n readonly values: readonly [string, ...Array<string>];\n }\n );\n\n/** Serializable, browser-safe metadata for one user-provided connector setting. */\nexport type ConfigFieldSpec = ConfigFieldDefinition & { readonly name: string };\n\n/** Pairs an Effect runtime config with the metadata used to generate its form field. */\nexport type ConfigField<A> = {\n readonly config: Config.Config<A>;\n readonly spec: ConfigFieldDefinition;\n};\n\ntype FieldBaseOptions = {\n readonly runtimeKey: string;\n readonly description?: string;\n};\n\ntype FieldOptions<A extends string | number | boolean = string | number | boolean> =\n FieldBaseOptions &\n (\n | {\n readonly required?: true;\n readonly default?: A;\n }\n | {\n readonly required: false;\n readonly default: A;\n }\n );\n\ntype NumberFieldOptions = FieldOptions<number> & NumberConstraints;\n\ntype FieldsRecord = Record<string, ConfigField<unknown>>;\n\n/** Preserves each field's value type while `Struct.map` extracts its Effect Config. */\ninterface ConfigFieldToConfig extends Struct.Lambda {\n <A>(field: ConfigField<A>): Config.Config<A>;\n readonly \"~lambda.out\": this[\"~lambda.in\"] extends ConfigField<infer A>\n ? Config.Config<A>\n : never;\n}\n\nconst configFieldToConfig = Struct.lambda<ConfigFieldToConfig>((field) => field.config);\n\ntype ConfigOf<Fields extends FieldsRecord> = {\n readonly [Key in keyof Fields]: Fields[Key] extends ConfigField<infer A> ? A : never;\n};\n\n/** Effect config and serializable manifest metadata produced from one field definition. */\nexport type ConnectorConfigDef<Fields extends FieldsRecord> = {\n readonly fields: {\n readonly [Key in keyof Fields]: Fields[Key] extends ConfigField<infer A>\n ? Config.Config<A>\n : never;\n };\n readonly config: Config.Config<ConfigOf<Fields>>;\n readonly spec: ReadonlyArray<ConfigFieldSpec>;\n};\n\nexport type ConfigValuesOf<Def extends ConnectorConfigDef<FieldsRecord>> =\n Def extends ConnectorConfigDef<infer Fields> ? ConfigOf<Fields> : never;\n\nconst withDefault = <A extends string | number | boolean>(\n config: Config.Config<A>,\n defaultValue: A | undefined,\n) => (defaultValue === undefined ? config : Config.withDefault(config, defaultValue));\n\n/** Defines a required non-empty string, optionally with a default. */\nexport const string = (options: FieldOptions<string>): ConfigField<string> => ({\n config: withDefault(Config.NonEmptyString(options.runtimeKey), options.default),\n spec: {\n runtimeKey: options.runtimeKey,\n type: \"string\",\n required: options.required ?? true,\n secret: false,\n ...(options.description !== undefined ? { description: options.description } : {}),\n ...(options.default !== undefined ? { default: options.default } : {}),\n },\n});\n\n/** Defines a finite number with optional integer, minimum, and default constraints. */\nexport const number = (options: NumberFieldOptions): ConfigField<number> => {\n const schema = makeNumberSchema(options);\n const defaultValue =\n options.default === undefined ? undefined : Schema.decodeUnknownSync(schema)(options.default);\n\n return {\n config: withDefault(Config.schema(schema, options.runtimeKey), defaultValue),\n spec: {\n runtimeKey: options.runtimeKey,\n type: \"number\",\n required: options.required ?? true,\n secret: false,\n ...(options.description !== undefined ? { description: options.description } : {}),\n ...(defaultValue !== undefined ? { default: defaultValue } : {}),\n ...(options.integer !== undefined ? { integer: options.integer } : {}),\n ...(options.minimum !== undefined ? { minimum: options.minimum } : {}),\n },\n };\n};\n\n/** Defines a boolean, optionally with a default. */\nexport const boolean = (options: FieldOptions<boolean>): ConfigField<boolean> => ({\n config: withDefault(Config.Boolean(options.runtimeKey), options.default),\n spec: {\n runtimeKey: options.runtimeKey,\n type: \"boolean\",\n required: options.required ?? true,\n secret: false,\n ...(options.description !== undefined ? { description: options.description } : {}),\n ...(options.default !== undefined ? { default: options.default } : {}),\n },\n});\n\n/** Defines a string literal choice whose values are preserved in the inferred type. */\nexport const select = <const Values extends readonly [string, ...Array<string>]>(\n options: FieldOptions<Values[number]> & { readonly values: Values },\n): ConfigField<Values[number]> => ({\n config: withDefault(Config.Literals(options.values, options.runtimeKey), options.default),\n spec: {\n runtimeKey: options.runtimeKey,\n type: \"select\",\n required: options.required ?? true,\n secret: false,\n values: options.values,\n ...(options.description !== undefined ? { description: options.description } : {}),\n ...(options.default !== undefined ? { default: options.default } : {}),\n },\n});\n\n/** Defines a required, non-empty secret decoded as `Redacted<string>`. */\nexport const secret = (\n options: FieldBaseOptions & { readonly required?: true },\n): ConfigField<Redacted.Redacted<string>> => ({\n config: Config.schema(Schema.Redacted(Schema.NonEmptyString), options.runtimeKey),\n spec: {\n runtimeKey: options.runtimeKey,\n type: \"string\",\n required: options.required ?? true,\n secret: true,\n ...(options.description !== undefined ? { description: options.description } : {}),\n },\n});\n\n/** Makes an existing field optional and represents a missing value as `Option.none()`. */\nexport const optional = <A>(field: ConfigField<A>): ConfigField<Option.Option<A>> => ({\n config: Config.option(field.config),\n spec: {\n ...field.spec,\n required: false,\n },\n});\n\n/**\n * Defines user-facing connector config once for both Effect runtime loading and\n * frontend form generation. The object keys become logical form/API field names;\n * `runtimeKey` remains the key read by Effect Config.\n *\n * @example\n * ```ts\n * const config = define({\n * apiUrl: string({ runtimeKey: \"API_URL\" }),\n * token: secret({ runtimeKey: \"API_TOKEN\" }),\n * });\n *\n * const RuntimeConfig = config.config;\n * const formFields = config.spec;\n * ```\n */\nexport const define = <const Fields extends FieldsRecord>(\n fields: Fields,\n): ConnectorConfigDef<Fields> => {\n const spec = Object.entries(fields).map(([name, field]) => ({ name, ...field.spec }));\n const platformField = spec.find((field) => isPlatformRuntimeKey(field.runtimeKey));\n if (platformField !== undefined) {\n throw new Error(`Connector runtime key is platform-owned: ${platformField.runtimeKey}`);\n }\n\n const configFields = Struct.map(fields, configFieldToConfig);\n\n return {\n fields: configFields,\n // Effect's recursive Config.Wrap cannot reduce this generic mapped type,\n // although ConfigFieldToConfig preserves the value type of every property.\n config: Config.unwrap(configFields as Config.Wrap<ConfigOf<Fields>>),\n spec,\n };\n};\n","import type { ConfigFieldSpec } from \"./config\";\n\nexport type ResourceCapability = \"backfill\" | \"changes\" | \"webhook\";\n\n/** Browser-safe connector metadata consumed by the platform and runtime adapters. */\nexport type ConnectorManifest = {\n readonly name: string;\n readonly title: string;\n readonly description?: string;\n readonly config: ReadonlyArray<ConfigFieldSpec>;\n readonly resources: ReadonlyArray<{\n readonly name: string;\n readonly capabilities: ReadonlyArray<ResourceCapability>;\n }>;\n};\n\n/**\n * Defines browser-safe connector metadata while preserving literal names and capabilities.\n *\n * @example\n * ```ts\n * const manifest = define({\n * name: \"producer-example\",\n * title: \"Example\",\n * config: ExampleConfig.spec,\n * resources: [{ name: \"orders\", capabilities: [\"backfill\"] }],\n * });\n * ```\n */\nexport const define = <const Manifest extends ConnectorManifest>(manifest: Manifest): Manifest =>\n manifest;\n","import { Predicate, Schema, SchemaTransformation, type Types } from \"effect\";\n\nimport type { ConfigFieldSpec } from \"./config\";\nimport type { ConnectorManifest } from \"./manifest\";\n\nimport { makeNumberSchema } from \"./number-schema\";\n\ntype FieldValueOf<Field extends ConfigFieldSpec> = Field[\"type\"] extends \"number\"\n ? number\n : Field[\"type\"] extends \"boolean\"\n ? boolean\n : Field[\"values\"] extends ReadonlyArray<string>\n ? Field[\"values\"][number]\n : string;\n\nexport type ConnectorConfigValues<Manifest extends ConnectorManifest> = Types.Simplify<\n {\n readonly [Field in Manifest[\"config\"][number] as Field[\"required\"] extends true\n ? Field[\"name\"]\n : never]: FieldValueOf<Field>;\n } & {\n readonly [Field in Manifest[\"config\"][number] as Field[\"required\"] extends true\n ? never\n : Field[\"name\"]]?: FieldValueOf<Field> | undefined;\n }\n> &\n object;\n\nexport type ConnectorConfigSchema<Manifest extends ConnectorManifest> = Schema.Codec<\n ConnectorConfigValues<Manifest>,\n unknown\n>;\n\n/** Flat primitive document keyed by the runtime keys consumed by Effect Config. */\nexport type RuntimeConfigDocument = Readonly<Record<string, string | number | boolean>>;\n\n// Browser forms submit numbers and booleans as strings, while API callers may\n// already send their canonical JSON representations. These schemas accept both.\nconst numberFromForm = (field: Extract<ConfigFieldSpec, { readonly type: \"number\" }>) => {\n const numberSchema = makeNumberSchema(field);\n return Schema.Union([\n numberSchema,\n Schema.NonEmptyString.pipe(\n Schema.decodeTo(numberSchema, SchemaTransformation.numberFromString),\n ),\n ]);\n};\n\nconst BooleanFromForm = Schema.Union([\n Schema.Boolean,\n Schema.Literals([\"true\", \"false\"]).pipe(\n Schema.decodeTo(\n Schema.Boolean,\n SchemaTransformation.transform({\n decode: (value) => value === \"true\",\n encode: (value) => (value ? \"true\" : \"false\"),\n }),\n ),\n ),\n]);\n\n// An empty optional form control means \"not supplied\", not an empty config value.\nconst EmptyStringAsUndefined = Schema.Literal(\"\").pipe(\n Schema.decodeTo(\n Schema.Undefined,\n SchemaTransformation.transform({ decode: () => undefined, encode: () => \"\" }),\n ),\n);\n\nconst baseFieldSchema = (field: ConfigFieldSpec): Schema.Codec<unknown, unknown> => {\n switch (field.type) {\n case \"number\":\n return numberFromForm(field);\n case \"boolean\":\n return BooleanFromForm;\n case \"select\":\n return Schema.Literals(field.values);\n case \"string\":\n return Schema.NonEmptyString;\n }\n};\n\nconst fieldSchema = (field: ConfigFieldSpec) =>\n field.required\n ? baseFieldSchema(field)\n : Schema.optional(Schema.Union([EmptyStringAsUndefined, baseFieldSchema(field)]));\n\n/**\n * Builds an Effect Schema for logical form/API values from a connector manifest.\n *\n * @example\n * ```ts\n * const decode = Schema.decodeUnknownEffect(configSchema(manifest));\n * const values = decode({\n * apiUrl: \"https://example.com\",\n * retries: \"3\",\n * });\n * ```\n */\nexport const configSchema = <const Manifest extends ConnectorManifest>(\n manifest: Manifest,\n): ConnectorConfigSchema<Manifest> => {\n const fields = Object.fromEntries(\n manifest.config.map((field) => [field.name, fieldSchema(field)]),\n );\n // Object.fromEntries cannot retain keys discovered from the runtime manifest;\n // the public mapped type restores the same relationship for callers.\n return Schema.Struct(fields) as unknown as ConnectorConfigSchema<Manifest>;\n};\n\n/** Decodes browser/API config, applies manifest defaults, and rejects undeclared fields. */\nexport const decodeConfig = <const Manifest extends ConnectorManifest>(\n manifest: Manifest,\n input: unknown,\n) => {\n const defaults = Object.fromEntries(\n manifest.config.flatMap((field) =>\n field.default === undefined ? [] : [[field.name, field.default]],\n ),\n );\n const optionalFields = new Set(\n manifest.config.flatMap((field) => (field.required ? [] : [field.name])),\n );\n const normalizedInput = Predicate.isObject(input)\n ? Object.fromEntries(\n Object.entries(input).filter(([name, value]) => value !== \"\" || !optionalFields.has(name)),\n )\n : input;\n const inputWithDefaults = Predicate.isObject(normalizedInput)\n ? Object.assign({}, defaults, normalizedInput)\n : normalizedInput;\n\n return Schema.decodeUnknownEffect(configSchema(manifest))(inputWithDefaults, {\n onExcessProperty: \"error\",\n });\n};\n\n/**\n * Maps validated logical values to the flat runtime-key document mounted in a pod.\n * Missing optional values are omitted.\n *\n * @example\n * ```ts\n * toRuntimeDocument(manifest, { apiUrl: \"https://example.com\" });\n * // { API_URL: \"https://example.com\" }\n * ```\n */\nexport const toRuntimeDocument = <const Manifest extends ConnectorManifest>(\n manifest: Manifest,\n values: ConnectorConfigValues<Manifest>,\n): RuntimeConfigDocument => {\n const document: Record<string, string | number | boolean> = {};\n for (const field of manifest.config) {\n const value: unknown = Reflect.get(values, field.name);\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n document[field.runtimeKey] = value;\n }\n }\n return document;\n};\n","export {\n boolean,\n define as defineConfig,\n number,\n optional,\n secret,\n select,\n string,\n} from \"./config\";\nexport type { ConfigField, ConfigFieldSpec, ConfigValuesOf, ConnectorConfigDef } from \"./config\";\nexport { define } from \"./manifest\";\nexport type { ConnectorManifest, ResourceCapability } from \"./manifest\";\nexport { configSchema, decodeConfig, toRuntimeDocument } from \"./schema\";\nexport type { ConnectorConfigSchema, ConnectorConfigValues, RuntimeConfigDocument } from \"./schema\";\n"],"mappings":";;;;AAOA,MAAa,oBAAoB,gBAAmC;CAClE,IAAI,YAAY,SACd,OAAO,YAAY,YAAY,KAAA,IAC3B,OAAO,MACP,OAAO,IAAI,MAAM,OAAO,uBAAuB,YAAY,OAAO,CAAC;CAEzE,OAAO,YAAY,YAAY,KAAA,IAC3B,OAAO,SACP,OAAO,OAAO,MAAM,OAAO,uBAAuB,YAAY,OAAO,CAAC;AAC5E;;;ACsEA,MAAM,sBAAsB,OAAO,QAA6B,UAAU,MAAM,MAAM;AAoBtF,MAAM,eACJ,QACA,iBACI,iBAAiB,KAAA,IAAY,SAAS,OAAO,YAAY,QAAQ,YAAY;;AAGnF,MAAa,UAAU,aAAwD;CAC7E,QAAQ,YAAY,OAAO,eAAe,QAAQ,UAAU,GAAG,QAAQ,OAAO;CAC9E,MAAM;EACJ,YAAY,QAAQ;EACpB,MAAM;EACN,UAAU,QAAQ,YAAY;EAC9B,QAAQ;EACR,GAAI,QAAQ,gBAAgB,KAAA,IAAY,EAAE,aAAa,QAAQ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AAQ,CAAC,MAAM,WAAW,UAAU,MAAM,CAAC,eAAe,IAAI,IAAI,CAAC,CAC3F,IACA;CACJ,MAAM,oBAAoB,UAAU,SAAS,eAAe,IACxD,OAAO,OAAO,CAAC,GAAG,UAAU,eAAe,IAC3C;CAEJ,OAAO,OAAO,oBAAoB,aAAa,QAAQ,CAAC,CAAC,CAAC,mBAAmB,EAC3E,kBAAkB,QACpB,CAAC;AACH;;;;;;;;;;;AAYA,MAAa,qBACX,UACA,WAC0B;CAC1B,MAAM,WAAsD,CAAC;CAC7D,KAAK,MAAM,SAAS,SAAS,QAAQ;EACnC,MAAM,QAAiB,QAAQ,IAAI,QAAQ,MAAM,IAAI;EACrD,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,SAAS,MAAM,cAAc;CAEjC;CACA,OAAO;AACT"}
@@ -1,11 +1,10 @@
1
- import { t as __export } from "./chunk-Bp6m_JJh.js";
2
- import { n as PlatformRuntimeKey } from "./constants-D113Ut1x.js";
3
- import { Cause, Config, Effect, Layer, Metric, Option } from "effect";
4
- import { Headers } from "effect/unstable/http";
5
- import * as Observability from "effect/unstable/observability";
6
-
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { n as PlatformRuntimeKey } from "./constants-D-GQzpHZ.mjs";
3
+ import { Cause, Config, DateTime, Effect, Layer, Metric, Option, Predicate, Schedule } from "effect";
4
+ import { Headers, HttpClientError, HttpClientResponse } from "effect/http";
5
+ import * as Observability from "effect/observability";
7
6
  //#region src/telemetry.ts
8
- var telemetry_exports = /* @__PURE__ */ __export({
7
+ var telemetry_exports = /* @__PURE__ */ __exportAll({
9
8
  Attr: () => Attr,
10
9
  EventAttr: () => EventAttr,
11
10
  EventName: () => EventName,
@@ -25,7 +24,7 @@ const SpanName = {
25
24
  batchProcess: "connector.batch.process",
26
25
  webhookDecode: "connector.webhook.decode",
27
26
  webhookHandle: "connector.webhook.handle",
28
- publish: "connector.publish",
27
+ ingest: "connector.ingest",
29
28
  stateSet: "connector.state.set",
30
29
  apiFetch: "connector.api.fetch"
31
30
  };
@@ -35,13 +34,13 @@ const Attr = {
35
34
  connectorResourcesCount: "airfoil.connector.resources.count",
36
35
  resourceName: "airfoil.resource.name",
37
36
  resourceSource: "airfoil.resource.source",
38
- batchMutations: "airfoil.batch.mutations",
37
+ batchRows: "airfoil.batch.rows",
39
38
  batchOutcome: "airfoil.batch.outcome",
40
39
  webhookPath: "airfoil.webhook.path",
41
40
  webhookOutcome: "airfoil.webhook.outcome",
42
41
  syncState: "airfoil.connector.sync.state",
43
42
  apiRetryReason: "airfoil.connector.api.retry.reason",
44
- publisherSuccess: "airfoil.publisher.success",
43
+ ingestionSuccess: "airfoil.ingestion.success",
45
44
  stateKey: "airfoil.state.key",
46
45
  apiPath: "airfoil.api.path",
47
46
  errorPhase: "airfoil.error.phase",
@@ -62,9 +61,9 @@ const EventAttr = { batchCursor: "airfoil.batch.cursor" };
62
61
  const isRecord = (value) => typeof value === "object" && value !== null;
63
62
  const maxErrorMessageLength = 500;
64
63
  const OtlpEnvConfig = Config.all({
65
- enabled: Config.boolean(PlatformRuntimeKey.otelEnabled).pipe(Config.withDefault(false)),
66
- baseUrl: Config.option(Config.string(PlatformRuntimeKey.otelExporterOtlpEndpoint)),
67
- rawHeaders: Config.option(Config.string(PlatformRuntimeKey.otelExporterOtlpHeaders))
64
+ enabled: Config.Boolean(PlatformRuntimeKey.otelEnabled).pipe(Config.withDefault(false)),
65
+ baseUrl: Config.option(Config.String(PlatformRuntimeKey.otelExporterOtlpEndpoint)),
66
+ rawHeaders: Config.option(Config.String(PlatformRuntimeKey.otelExporterOtlpHeaders))
68
67
  });
69
68
  const defaultRedactedHeaders = [
70
69
  "authorization",
@@ -153,12 +152,13 @@ const layer = (config = {}, options = {}) => Layer.unwrap(buildOtlpTracingLayer(
153
152
  *
154
153
  * @example
155
154
  * Telemetry.layerConfig({
156
- * enabled: Config.boolean("MY_OTEL_ENABLED"),
157
- * endpoint: Config.string("MY_COLLECTOR_URL"),
155
+ * enabled: Config.Boolean("MY_OTEL_ENABLED"),
156
+ * endpoint: Config.String("MY_COLLECTOR_URL"),
158
157
  * })
159
158
  */
160
159
  const layerConfig = (config, options = {}) => Layer.unwrap(Effect.gen(function* () {
161
- return yield* buildOtlpTracingLayer(yield* Config.unwrap(config), options);
160
+ const resolved = yield* Config.unwrap(config);
161
+ return yield* buildOtlpTracingLayer(resolved, options);
162
162
  }));
163
163
  /**
164
164
  * Trace-only OTLP export with sensitive HTTP header redaction.
@@ -195,7 +195,158 @@ const layerOtlp = (options = {}) => Layer.mergeAll(layerOtlpTracing(options), la
195
195
  const layerMetricsConsoleDump = (interval = "30 seconds") => Layer.effectDiscard(Effect.gen(function* () {
196
196
  yield* Effect.forkScoped(Effect.forever(Metric.dump.pipe(Effect.flatMap((snapshot) => Effect.logInfo(snapshot)), Effect.andThen(Effect.sleep(interval)))));
197
197
  }));
198
-
199
198
  //#endregion
200
- export { addCurrentSpanEvent as a, SpanName as i, EventAttr as n, annotateError as o, EventName as r, telemetry_exports as s, Attr as t };
201
- //# sourceMappingURL=telemetry-j_nxwYfh.js.map
199
+ //#region src/metrics.ts
200
+ var metrics_exports = /* @__PURE__ */ __exportAll({
201
+ apiRetries: () => apiRetries,
202
+ batchSize: () => batchSize,
203
+ batches: () => batches,
204
+ ingestDuration: () => ingestDuration,
205
+ lastSuccessTimestamp: () => lastSuccessTimestamp,
206
+ recordApiRetry: () => recordApiRetry,
207
+ recordWebhookRequest: () => recordWebhookRequest,
208
+ retrySchedule: () => retrySchedule,
209
+ rowsIngested: () => rowsIngested,
210
+ setLastSuccessTimestamp: () => setLastSuccessTimestamp,
211
+ setSyncState: () => setSyncState,
212
+ setWebhookQueueDepth: () => setWebhookQueueDepth,
213
+ syncState: () => syncState,
214
+ webhookQueueDepth: () => webhookQueueDepth,
215
+ webhookRequests: () => webhookRequests,
216
+ withResourceAttributes: () => withResourceAttributes
217
+ });
218
+ const batches = Metric.counter("airfoil.connector.batches", {
219
+ description: "Total resource batches ingested by connector sources",
220
+ incremental: true,
221
+ attributes: { unit: "{batch}" }
222
+ });
223
+ const rowsIngested = Metric.counter("airfoil.connector.rows.ingested", {
224
+ description: "Total resource rows successfully ingested",
225
+ incremental: true,
226
+ attributes: { unit: "{row}" }
227
+ });
228
+ const batchSize = Metric.histogram("airfoil.connector.batch.size", {
229
+ description: "Distribution of resource row batch sizes",
230
+ boundaries: [
231
+ 1,
232
+ 5,
233
+ 10,
234
+ 25,
235
+ 50,
236
+ 100,
237
+ 250,
238
+ 500,
239
+ 1e3
240
+ ],
241
+ attributes: { unit: "{row}" }
242
+ });
243
+ const ingestDuration = Metric.timer("airfoil.connector.ingest.duration", {
244
+ description: "Ingestor call duration in milliseconds",
245
+ boundaries: [
246
+ 1,
247
+ 5,
248
+ 10,
249
+ 25,
250
+ 50,
251
+ 100,
252
+ 250,
253
+ 500,
254
+ 1e3,
255
+ 2500,
256
+ 5e3,
257
+ 1e4
258
+ ],
259
+ attributes: { unit: "ms" }
260
+ });
261
+ const webhookRequests = Metric.counter("airfoil.connector.webhook.requests", {
262
+ description: "Total webhook HTTP requests handled by connector routes",
263
+ incremental: true,
264
+ attributes: { unit: "{request}" }
265
+ });
266
+ const webhookQueueDepth = Metric.gauge("airfoil.connector.webhook.queue.depth", {
267
+ description: "Current queued webhook batches waiting for ingestion",
268
+ attributes: { unit: "{batch}" }
269
+ });
270
+ const syncState = Metric.gauge("airfoil.connector.sync.state", {
271
+ description: "Connector resource sync state as a Prometheus state-set gauge",
272
+ attributes: { unit: "1" }
273
+ });
274
+ const lastSuccessTimestamp = Metric.gauge("airfoil.connector.last_success.timestamp", {
275
+ description: "Unix timestamp of the last successful durable source checkpoint",
276
+ attributes: { unit: "s" }
277
+ });
278
+ const apiRetries = Metric.counter("airfoil.connector.api.retries", {
279
+ description: "Total provider API retries performed by the connector",
280
+ incremental: true,
281
+ attributes: { unit: "{retry}" }
282
+ });
283
+ const resourceAttributes = (attrs) => ({
284
+ [Attr.connectorName]: attrs.connector,
285
+ [Attr.resourceName]: attrs.resource,
286
+ [Attr.resourceSource]: attrs.source
287
+ });
288
+ const syncAttributes = (attrs) => ({
289
+ [Attr.connectorName]: attrs.connector,
290
+ [Attr.resourceName]: attrs.resource
291
+ });
292
+ const recordWebhookRequest = (attrs) => Metric.update(Metric.withAttributes(webhookRequests, {
293
+ [Attr.connectorName]: attrs.connector,
294
+ [Attr.webhookPath]: attrs.path,
295
+ [Attr.webhookOutcome]: attrs.outcome
296
+ }), 1);
297
+ const setWebhookQueueDepth = (connector, depth) => Metric.update(Metric.withAttributes(webhookQueueDepth, { [Attr.connectorName]: connector }), depth);
298
+ const setLastSuccessTimestamp = (attrs, lastSuccessAt) => {
299
+ const timestamp = lastSuccessAt === void 0 ? 0 : DateTime.make(lastSuccessAt).pipe(Option.map((dateTime) => DateTime.toEpochMillis(dateTime) / 1e3), Option.getOrElse(() => 0));
300
+ return Metric.update(Metric.withAttributes(lastSuccessTimestamp, {
301
+ [Attr.connectorName]: attrs.connector,
302
+ [Attr.resourceName]: attrs.resource,
303
+ [Attr.resourceSource]: attrs.source
304
+ }), timestamp);
305
+ };
306
+ const recordApiRetry = (attrs) => Metric.update(Metric.withAttributes(apiRetries, {
307
+ [Attr.connectorName]: attrs.connector,
308
+ [Attr.apiRetryReason]: attrs.reason
309
+ }), 1);
310
+ const transientStatuses = /* @__PURE__ */ new Set([
311
+ 408,
312
+ 429,
313
+ 500,
314
+ 502,
315
+ 503,
316
+ 504
317
+ ]);
318
+ const reasonForStatus = (status) => status === 408 ? "timeout" : status === 429 || status === 403 ? "rate_limit" : "server_error";
319
+ const isResponse = (value) => Predicate.hasProperty(value, HttpClientResponse.TypeId);
320
+ /** Why `HttpClient.retryTransient` retries. Undefined for a response it keeps. */
321
+ const retryReason = (value) => {
322
+ if (isResponse(value)) return transientStatuses.has(value.status) ? reasonForStatus(value.status) : void 0;
323
+ if (HttpClientError.isHttpClientError(value) && value.reason._tag === "StatusCodeError") return reasonForStatus(value.reason.response.status);
324
+ return Cause.isTimeoutError(value) ? "timeout" : "transport";
325
+ };
326
+ /**
327
+ * A jittered exponential schedule for `HttpClient.retryTransient` that records
328
+ * each retry with its reason.
329
+ */
330
+ const retrySchedule = (options) => Schedule.exponential(options.baseDelay).pipe(Schedule.jittered, Schedule.upTo({ times: options.times }), Schedule.tap(({ input }) => {
331
+ const reason = retryReason(input);
332
+ return reason === void 0 ? Effect.void : recordApiRetry({
333
+ connector: options.connector,
334
+ reason
335
+ });
336
+ }));
337
+ const syncStates = [
338
+ "pending",
339
+ "backfilling",
340
+ "live",
341
+ "error"
342
+ ];
343
+ const setSyncState = (attrs, current) => Effect.forEach(syncStates, (state) => Metric.update(Metric.withAttributes(syncState, {
344
+ ...syncAttributes(attrs),
345
+ [Attr.syncState]: state
346
+ }), state === current ? 1 : 0), { discard: true });
347
+ /** @internal Converts the ergonomic SDK input to canonical OTel attributes. */
348
+ const withResourceAttributes = resourceAttributes;
349
+ //#endregion
350
+ export { annotateError as C, addCurrentSpanEvent as S, withResourceAttributes as _, lastSuccessTimestamp as a, EventName as b, recordWebhookRequest as c, setLastSuccessTimestamp as d, setSyncState as f, webhookRequests as g, webhookQueueDepth as h, ingestDuration as i, retrySchedule as l, syncState as m, batchSize as n, metrics_exports as o, setWebhookQueueDepth as p, batches as r, recordApiRetry as s, apiRetries as t, rowsIngested as u, Attr as v, telemetry_exports as w, SpanName as x, EventAttr as y };
351
+
352
+ //# sourceMappingURL=metrics-BaEX__MN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics-BaEX__MN.mjs","names":[],"sources":["../src/telemetry.ts","../src/metrics.ts"],"sourcesContent":["import { Cause, Config, Effect, Layer, Metric, Option, type Duration } from \"effect\";\nimport { Headers } from \"effect/http\";\nimport * as Observability from \"effect/observability\";\n\nimport { PlatformRuntimeKey } from \"./runtime-config/constants\";\n\n/** Canonical span names emitted by connector-kit runtime instrumentation. */\nexport const SpanName = {\n batchProcess: \"connector.batch.process\",\n webhookDecode: \"connector.webhook.decode\",\n webhookHandle: \"connector.webhook.handle\",\n ingest: \"connector.ingest\",\n stateSet: \"connector.state.set\",\n apiFetch: \"connector.api.fetch\",\n} as const;\n\n/** Canonical span attribute names. Keep these stable for collector queries. */\nexport const Attr = {\n connectorName: \"airfoil.connector.name\",\n connectorResourcesCount: \"airfoil.connector.resources.count\",\n resourceName: \"airfoil.resource.name\",\n resourceSource: \"airfoil.resource.source\",\n batchRows: \"airfoil.batch.rows\",\n batchOutcome: \"airfoil.batch.outcome\",\n webhookPath: \"airfoil.webhook.path\",\n webhookOutcome: \"airfoil.webhook.outcome\",\n syncState: \"airfoil.connector.sync.state\",\n apiRetryReason: \"airfoil.connector.api.retry.reason\",\n ingestionSuccess: \"airfoil.ingestion.success\",\n stateKey: \"airfoil.state.key\",\n apiPath: \"airfoil.api.path\",\n errorPhase: \"airfoil.error.phase\",\n errorType: \"airfoil.error.type\",\n errorMessage: \"airfoil.error.message\",\n errorDetails: \"airfoil.error.details\",\n} as const;\n\n/** Resource attributes injected by the hosted operator through standard OTel environment keys. */\nexport const ResourceAttr = {\n serviceInstanceId: \"service.instance.id\",\n connectorRevision: \"airfoil.connector.revision\",\n teamId: \"airfoil.team.id\",\n} as const;\n\n/** Span event names for high-cardinality reproduction details. */\nexport const EventName = {\n batchCheckpoint: \"airfoil.batch.checkpoint\",\n} as const;\n\n/** Event-only attributes. These are intentionally not span attributes. */\nexport const EventAttr = {\n batchCursor: \"airfoil.batch.cursor\",\n} as const;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst maxErrorMessageLength = 500;\n\nconst OtlpEnvConfig = Config.all({\n enabled: Config.Boolean(PlatformRuntimeKey.otelEnabled).pipe(Config.withDefault(false)),\n baseUrl: Config.option(Config.String(PlatformRuntimeKey.otelExporterOtlpEndpoint)),\n rawHeaders: Config.option(Config.String(PlatformRuntimeKey.otelExporterOtlpHeaders)),\n});\n\nconst defaultRedactedHeaders: ReadonlyArray<string | RegExp> = [\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n /api[-_]?key/i,\n /secret/i,\n /signature/i,\n /token/i,\n];\n\nconst parseOtelHeaders = (value: string): Record<string, string> =>\n Object.fromEntries(\n value\n .split(\",\")\n .map((entry) => entry.trim())\n .filter(Boolean)\n .flatMap((entry) => {\n const separator = entry.indexOf(\"=\");\n if (separator < 1) return [];\n return [[entry.slice(0, separator).trim(), entry.slice(separator + 1).trim()]];\n }),\n );\n\nconst appendPath = (baseUrl: string, path: string) =>\n `${baseUrl.replace(/\\/$/, \"\")}/${path.replace(/^\\//, \"\")}`;\n\n/**\n * Best-effort stable error classifier for span metadata.\n *\n * Effect/Data tagged errors expose `_tag`; that is the most useful value for\n * connector bugs (`ConnectorError`, `InvalidWebhookPayloadError`, etc.). For\n * non-tagged errors we fall back to the JS `Error.name`, then constructor name,\n * then the primitive type.\n */\nconst errorType = (error: unknown) => {\n if (isRecord(error) && typeof error._tag === \"string\") {\n return String(error._tag);\n }\n if (error instanceof Error) {\n return error.name;\n }\n if (isRecord(error) && typeof error.constructor?.name === \"string\") {\n return error.constructor.name;\n }\n return typeof error;\n};\n\n/**\n * Human-readable error summary for span metadata.\n *\n * Tagged errors in this package carry a `message` field, so this preserves the\n * important diagnostic text. Unknown object failures are intentionally reduced\n * to their type; full structured error payloads belong in logs, not span attrs.\n */\nconst errorMessage = (error: unknown) => {\n const message = (() => {\n if (isRecord(error) && typeof error.message === \"string\") {\n return error.message;\n }\n if (typeof error === \"string\") {\n return error;\n }\n return errorType(error);\n })();\n\n if (message.length > maxErrorMessageLength) {\n return `${message.slice(0, maxErrorMessageLength)}...`;\n }\n\n return message;\n};\n\nconst errorDetails = (error: unknown): string | undefined => {\n if (!isRecord(error) || error.cause === undefined) return undefined;\n return Cause.pretty(Cause.die(error.cause));\n};\n\n/** Annotates the active span with phase-aware error metadata before re-failing. */\nexport const annotateError = (phase: string, error: unknown) => {\n const details = errorDetails(error);\n return Effect.annotateCurrentSpan({\n [Attr.errorPhase]: phase,\n [Attr.errorType]: errorType(error),\n [Attr.errorMessage]: errorMessage(error),\n ...(details !== undefined ? { [Attr.errorDetails]: details } : {}),\n });\n};\n\n/** Adds an event to the active span, or no-ops when no span is active. */\nexport const addCurrentSpanEvent = (name: string, attributes?: Record<string, unknown>) =>\n Effect.currentSpan.pipe(\n Effect.flatMap((span) =>\n Effect.clockWith((clock) =>\n Effect.sync(() => span.event(name, clock.currentTimeNanosUnsafe(), attributes)),\n ),\n ),\n Effect.ignore,\n );\n\n/** Transport configuration for OTLP trace export. All fields are direct values. */\nexport type OtlpTracingConfig = {\n readonly enabled?: boolean;\n readonly endpoint?: string;\n readonly headers?: Record<string, string>;\n};\n\n/** Runtime options — not config-wrappable since RegExp cannot live in Config. */\nexport type OtlpTracingOptions = {\n /** Additional connector-specific header names or regexes to redact from HTTP logs/traces. */\n readonly redactedHeaders?: ReadonlyArray<string | RegExp>;\n};\n\n/** OTLP metric export settings. */\nexport type OtlpMetricsOptions = {\n readonly exportInterval?: Duration.Input;\n};\n\nconst buildOtlpTracingLayer = (config: OtlpTracingConfig, options: OtlpTracingOptions) =>\n Effect.gen(function* () {\n const allRedacted = [...defaultRedactedHeaders, ...(options.redactedHeaders ?? [])];\n const RedactionLayer = Layer.succeed(Headers.CurrentRedactedNames)(allRedacted);\n\n if (!config.enabled) {\n return RedactionLayer;\n }\n\n if (!config.endpoint) {\n return yield* Effect.fail(new Error(\"enabled=true requires endpoint\"));\n }\n\n yield* Effect.logInfo(\"telemetry enabled\").pipe(\n Effect.annotateLogs({\n endpoint: config.endpoint,\n headers: config.headers ? Object.keys(config.headers) : [],\n }),\n );\n\n return Layer.mergeAll(\n RedactionLayer,\n Observability.OtlpTracer.layer({\n url: appendPath(config.endpoint, \"/v1/traces\"),\n headers: config.headers,\n }).pipe(Layer.provide(Observability.OtlpSerialization.layerJson)),\n );\n });\n\n/**\n * Trace-only OTLP export with sensitive HTTP header redaction.\n * Takes direct config values — no `ConfigProvider` required.\n */\nexport const layer = (config: OtlpTracingConfig = {}, options: OtlpTracingOptions = {}) =>\n Layer.unwrap(buildOtlpTracingLayer(config, options));\n\n/**\n * Trace-only OTLP export with sensitive HTTP header redaction.\n * Takes Effect Config-wrapped values — reads from `ConfigProvider`.\n *\n * @example\n * Telemetry.layerConfig({\n * enabled: Config.Boolean(\"MY_OTEL_ENABLED\"),\n * endpoint: Config.String(\"MY_COLLECTOR_URL\"),\n * })\n */\nexport const layerConfig = (\n config: Config.Wrap<OtlpTracingConfig>,\n options: OtlpTracingOptions = {},\n) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const resolved = yield* Config.unwrap(config);\n return yield* buildOtlpTracingLayer(resolved, options);\n }),\n );\n\n/**\n * Trace-only OTLP export with sensitive HTTP header redaction.\n * Zero-config shortcut that reads the standard `OTEL_*` env var names.\n *\n * Reads `OTEL_ENABLED`, `OTEL_EXPORTER_OTLP_ENDPOINT`, and\n * `OTEL_EXPORTER_OTLP_HEADERS`. Effect's OTLP resource handling reads\n * `OTEL_SERVICE_NAME`, `OTEL_SERVICE_VERSION`, and `OTEL_RESOURCE_ATTRIBUTES`.\n */\nexport const layerOtlpTracing = (options: OtlpTracingOptions = {}) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const raw = yield* OtlpEnvConfig;\n return yield* buildOtlpTracingLayer(\n {\n enabled: raw.enabled,\n endpoint: Option.getOrUndefined(raw.baseUrl),\n headers: Option.isSome(raw.rawHeaders)\n ? parseOtelHeaders(raw.rawHeaders.value)\n : undefined,\n },\n options,\n );\n }),\n );\n\n/** Exports connector metrics over OTLP when telemetry is enabled. */\nexport const layerOtlpMetrics = (options: OtlpMetricsOptions = {}) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const raw = yield* OtlpEnvConfig;\n if (!raw.enabled) return Layer.empty;\n const endpoint = Option.getOrUndefined(raw.baseUrl);\n if (!endpoint)\n return yield* Effect.fail(\n new Error(\"OTEL_ENABLED=true requires OTEL_EXPORTER_OTLP_ENDPOINT\"),\n );\n return Observability.OtlpMetrics.layer({\n url: appendPath(endpoint, \"/v1/metrics\"),\n headers: Option.isSome(raw.rawHeaders) ? parseOtelHeaders(raw.rawHeaders.value) : undefined,\n exportInterval: options.exportInterval,\n temporality: \"cumulative\",\n }).pipe(Layer.provide(Observability.OtlpSerialization.layerJson));\n }),\n );\n\n/** Enables OTLP traces and metrics with shared environment configuration. */\nexport const layerOtlp = (options: OtlpTracingOptions & OtlpMetricsOptions = {}) =>\n Layer.mergeAll(layerOtlpTracing(options), layerOtlpMetrics(options));\n\n/** Periodically logs the in-memory metric snapshot for local debugging. */\nexport const layerMetricsConsoleDump = (interval: Duration.Input = \"30 seconds\") =>\n Layer.effectDiscard(\n Effect.gen(function* () {\n yield* Effect.forkScoped(\n Effect.forever(\n Metric.dump.pipe(\n Effect.flatMap((snapshot) => Effect.logInfo(snapshot)),\n Effect.andThen(Effect.sleep(interval)),\n ),\n ),\n );\n }),\n );\n","import {\n Cause,\n DateTime,\n type Duration,\n Effect,\n Metric,\n Option,\n Predicate,\n Schedule,\n} from \"effect\";\nimport { HttpClientError, HttpClientResponse } from \"effect/http\";\n\nimport type { SyncState } from \"./core/types\";\n\nimport { Attr } from \"./telemetry\";\n\nexport type BatchSource = \"backfill\" | \"changes\" | \"webhook\" | \"demo\";\nexport type BatchOutcome = \"success\" | \"error\";\nexport type ApiRetryReason = \"transport\" | \"timeout\" | \"rate_limit\" | \"server_error\";\nexport type WebhookOutcome =\n | \"ok\"\n | \"read_error\"\n | \"invalid_json\"\n | \"invalid_payload\"\n | \"rejected\"\n | \"handler_error\";\n\nexport type ResourceMetricAttrs = {\n readonly connector: string;\n readonly resource: string;\n readonly source: BatchSource;\n};\n\nexport type WebhookMetricAttrs = {\n readonly connector: string;\n readonly path: string;\n readonly outcome: WebhookOutcome;\n};\n\nexport type SyncStateAttrs = {\n readonly connector: string;\n readonly resource: string;\n};\n\nexport type LastSuccessMetricAttrs = {\n readonly connector: string;\n readonly resource: string;\n readonly source: \"backfill\" | \"changes\";\n};\n\nexport type ApiRetryMetricAttrs = {\n readonly connector: string;\n readonly reason: ApiRetryReason;\n};\n\nexport const batches = Metric.counter(\"airfoil.connector.batches\", {\n description: \"Total resource batches ingested by connector sources\",\n incremental: true,\n attributes: { unit: \"{batch}\" },\n});\n\nexport const rowsIngested = Metric.counter(\"airfoil.connector.rows.ingested\", {\n description: \"Total resource rows successfully ingested\",\n incremental: true,\n attributes: { unit: \"{row}\" },\n});\n\nexport const batchSize = Metric.histogram(\"airfoil.connector.batch.size\", {\n description: \"Distribution of resource row batch sizes\",\n boundaries: [1, 5, 10, 25, 50, 100, 250, 500, 1000],\n attributes: { unit: \"{row}\" },\n});\n\nexport const ingestDuration = Metric.timer(\"airfoil.connector.ingest.duration\", {\n description: \"Ingestor call duration in milliseconds\",\n boundaries: [1, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],\n attributes: { unit: \"ms\" },\n});\n\nexport const webhookRequests = Metric.counter(\"airfoil.connector.webhook.requests\", {\n description: \"Total webhook HTTP requests handled by connector routes\",\n incremental: true,\n attributes: { unit: \"{request}\" },\n});\n\nexport const webhookQueueDepth = Metric.gauge(\"airfoil.connector.webhook.queue.depth\", {\n description: \"Current queued webhook batches waiting for ingestion\",\n attributes: { unit: \"{batch}\" },\n});\n\nexport const syncState = Metric.gauge(\"airfoil.connector.sync.state\", {\n description: \"Connector resource sync state as a Prometheus state-set gauge\",\n attributes: { unit: \"1\" },\n});\n\nexport const lastSuccessTimestamp = Metric.gauge(\"airfoil.connector.last_success.timestamp\", {\n description: \"Unix timestamp of the last successful durable source checkpoint\",\n attributes: { unit: \"s\" },\n});\n\nexport const apiRetries = Metric.counter(\"airfoil.connector.api.retries\", {\n description: \"Total provider API retries performed by the connector\",\n incremental: true,\n attributes: { unit: \"{retry}\" },\n});\n\nconst resourceAttributes = (attrs: ResourceMetricAttrs) => ({\n [Attr.connectorName]: attrs.connector,\n [Attr.resourceName]: attrs.resource,\n [Attr.resourceSource]: attrs.source,\n});\n\nconst syncAttributes = (attrs: SyncStateAttrs) => ({\n [Attr.connectorName]: attrs.connector,\n [Attr.resourceName]: attrs.resource,\n});\n\nexport const recordWebhookRequest = (attrs: WebhookMetricAttrs) =>\n Metric.update(\n Metric.withAttributes(webhookRequests, {\n [Attr.connectorName]: attrs.connector,\n [Attr.webhookPath]: attrs.path,\n [Attr.webhookOutcome]: attrs.outcome,\n }),\n 1,\n );\n\nexport const setWebhookQueueDepth = (connector: string, depth: number) =>\n Metric.update(\n Metric.withAttributes(webhookQueueDepth, { [Attr.connectorName]: connector }),\n depth,\n );\n\nexport const setLastSuccessTimestamp = (attrs: LastSuccessMetricAttrs, lastSuccessAt?: string) => {\n const timestamp =\n lastSuccessAt === undefined\n ? 0\n : DateTime.make(lastSuccessAt).pipe(\n Option.map((dateTime) => DateTime.toEpochMillis(dateTime) / 1000),\n Option.getOrElse(() => 0),\n );\n return Metric.update(\n Metric.withAttributes(lastSuccessTimestamp, {\n [Attr.connectorName]: attrs.connector,\n [Attr.resourceName]: attrs.resource,\n [Attr.resourceSource]: attrs.source,\n }),\n timestamp,\n );\n};\n\nexport const recordApiRetry = (attrs: ApiRetryMetricAttrs) =>\n Metric.update(\n Metric.withAttributes(apiRetries, {\n [Attr.connectorName]: attrs.connector,\n [Attr.apiRetryReason]: attrs.reason,\n }),\n 1,\n );\n\n// Same statuses as `HttpClient.retryTransient`.\nconst transientStatuses = new Set([408, 429, 500, 502, 503, 504]);\n\n// A connector only retries a `403` when the provider uses it for rate limits.\nconst reasonForStatus = (status: number): ApiRetryReason =>\n status === 408 ? \"timeout\" : status === 429 || status === 403 ? \"rate_limit\" : \"server_error\";\n\n// Effect exports the response type ID, not a guard.\nconst isResponse = (value: unknown): value is HttpClientResponse.HttpClientResponse =>\n Predicate.hasProperty(value, HttpClientResponse.TypeId);\n\n/** Why `HttpClient.retryTransient` retries. Undefined for a response it keeps. */\nconst retryReason = (value: unknown): ApiRetryReason | undefined => {\n if (isResponse(value)) {\n return transientStatuses.has(value.status) ? reasonForStatus(value.status) : undefined;\n }\n if (HttpClientError.isHttpClientError(value) && value.reason._tag === \"StatusCodeError\") {\n return reasonForStatus(value.reason.response.status);\n }\n return Cause.isTimeoutError(value) ? \"timeout\" : \"transport\";\n};\n\n/**\n * A jittered exponential schedule for `HttpClient.retryTransient` that records\n * each retry with its reason.\n */\nexport const retrySchedule = (options: {\n readonly connector: string;\n readonly baseDelay: Duration.Input;\n readonly times: number;\n}) =>\n Schedule.exponential(options.baseDelay).pipe(\n Schedule.jittered,\n Schedule.upTo({ times: options.times }),\n Schedule.tap(({ input }) => {\n const reason = retryReason(input);\n return reason === undefined\n ? Effect.void\n : recordApiRetry({ connector: options.connector, reason });\n }),\n );\n\nconst syncStates = [\"pending\", \"backfilling\", \"live\", \"error\"] as const;\n\nexport const setSyncState = (attrs: SyncStateAttrs, current: SyncState) =>\n Effect.forEach(\n syncStates,\n (state) =>\n Metric.update(\n Metric.withAttributes(syncState, {\n ...syncAttributes(attrs),\n [Attr.syncState]: state,\n }),\n state === current ? 1 : 0,\n ),\n { discard: true },\n );\n\n/** @internal Converts the ergonomic SDK input to canonical OTel attributes. */\nexport const withResourceAttributes = resourceAttributes;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,WAAW;CACtB,cAAc;CACd,eAAe;CACf,eAAe;CACf,QAAQ;CACR,UAAU;CACV,UAAU;AACZ;;AAGA,MAAa,OAAO;CAClB,eAAe;CACf,yBAAyB;CACzB,cAAc;CACd,gBAAgB;CAChB,WAAW;CACX,cAAc;CACd,aAAa;CACb,gBAAgB;CAChB,WAAW;CACX,gBAAgB;CAChB,kBAAkB;CAClB,UAAU;CACV,SAAS;CACT,YAAY;CACZ,WAAW;CACX,cAAc;CACd,cAAc;AAChB;;AAGA,MAAa,eAAe;CAC1B,mBAAmB;CACnB,mBAAmB;CACnB,QAA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,MAAM;AAC/B,CAAC,GACD,CACF;AAGF,MAAM,oCAAoB,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG,CAAC;AAGhE,MAAM,mBAAmB,WACvB,WAAW,MAAM,YAAY,WAAW,OAAO,WAAW,MAAM,eAAe;AAGjF,MAAM,cAAc,UAClB,UAAU,YAAY,OAAO,mBAAmB,MAAM;;AAGxD,MAAM,eAAe,UAA+C;CAClE,IAAI,WAAW,KAAK,GAClB,OAAO,kBAAkB,IAAI,MAAM,MAAM,IAAI,gBAAgB,MAAM,MAAM,IAAI,KAAA;CAE/E,IAAI,gBAAgB,kBAAkB,KAAK,KAAK,MAAM,OAAO,SAAS,mBACpE,OAAO,gBAAgB,MAAM,OAAO,SAAS,MAAM;CAErD,OAAO,MAAM,eAAe,KAAK,IAAI,YAAY;AACnD;;;;;AAMA,MAAa,iBAAiB,YAK5B,SAAS,YAAY,QAAQ,SAAS,CAAC,CAAC,KACtC,SAAS,UACT,SAAS,KAAK,EAAE,OAAO,QAAQ,MAAM,CAAC,GACtC,SAAS,KAAK,EAAE,YAAY;CAC1B,MAAM,SAAS,YAAY,KAAK;CAChC,OAAO,WAAW,KAAA,IACd,OAAO,OACP,eAAe;EAAE,WAAW,QAAQ;EAAW;CAAO,CAAC;AAC7D,CAAC,CACH;AAEF,MAAM,aAAa;CAAC;CAAW;CAAe;CAAQ;AAAO;AAE7D,MAAa,gBAAgB,OAAuB,YAClD,OAAO,QACL,aACC,UACC,OAAO,OACL,OAAO,eAAe,WAAW;CAC/B,GAAG,eAAe,KAAK;EACtB,KAAK,YAAY;AACpB,CAAC,GACD,UAAU,UAAU,IAAI,CAC1B,GACF,EAAE,SAAS,KAAK,CAClB;;AAGF,MAAa,yBAAyB"}
@@ -1,13 +1,10 @@
1
- import { v as SyncState } from "./types-jVD5Ys43.js";
2
- import { Effect, Metric } from "effect";
3
- import * as effect_Duration0 from "effect/Duration";
4
-
5
- //#region src/metrics.d.ts
1
+ import { w as SyncState } from "./types-xZtSmrGA.mjs";
2
+ import { Duration, Effect, Metric, Schedule } from "effect";
6
3
  declare namespace metrics_d_exports {
7
- export { ApiRetryMetricAttrs, ApiRetryReason, BatchOutcome, BatchSource, LastSuccessMetricAttrs, ResourceMetricAttrs, SyncStateAttrs, WebhookMetricAttrs, WebhookOutcome, apiRetries, batchSize, batches, entitiesDeleted, entitiesUpserted, lastSuccessTimestamp, publishDuration, recordApiRetry, recordWebhookRequest, setLastSuccessTimestamp, setSyncState, setWebhookQueueDepth, syncState, webhookQueueDepth, webhookRequests, withResourceAttributes };
4
+ export { ApiRetryMetricAttrs, ApiRetryReason, BatchOutcome, BatchSource, LastSuccessMetricAttrs, ResourceMetricAttrs, SyncStateAttrs, WebhookMetricAttrs, WebhookOutcome, apiRetries, batchSize, batches, ingestDuration, lastSuccessTimestamp, recordApiRetry, recordWebhookRequest, retrySchedule, rowsIngested, setLastSuccessTimestamp, setSyncState, setWebhookQueueDepth, syncState, webhookQueueDepth, webhookRequests, withResourceAttributes };
8
5
  }
9
- type BatchSource = "backfill" | "changes" | "webhook";
10
- type BatchOutcome = "accepted" | "rejected" | "error";
6
+ type BatchSource = "backfill" | "changes" | "webhook" | "demo";
7
+ type BatchOutcome = "success" | "error";
11
8
  type ApiRetryReason = "transport" | "timeout" | "rate_limit" | "server_error";
12
9
  type WebhookOutcome = "ok" | "read_error" | "invalid_json" | "invalid_payload" | "rejected" | "handler_error";
13
10
  type ResourceMetricAttrs = {
@@ -33,11 +30,10 @@ type ApiRetryMetricAttrs = {
33
30
  readonly connector: string;
34
31
  readonly reason: ApiRetryReason;
35
32
  };
36
- declare const entitiesUpserted: Metric.Counter<number>;
37
- declare const entitiesDeleted: Metric.Counter<number>;
38
33
  declare const batches: Metric.Counter<number>;
34
+ declare const rowsIngested: Metric.Counter<number>;
39
35
  declare const batchSize: Metric.Histogram<number>;
40
- declare const publishDuration: Metric.Histogram<effect_Duration0.Duration>;
36
+ declare const ingestDuration: Metric.Histogram<Duration.Duration>;
41
37
  declare const webhookRequests: Metric.Counter<number>;
42
38
  declare const webhookQueueDepth: Metric.Gauge<number>;
43
39
  declare const syncState: Metric.Gauge<number>;
@@ -47,6 +43,15 @@ declare const recordWebhookRequest: (attrs: WebhookMetricAttrs) => Effect.Effect
47
43
  declare const setWebhookQueueDepth: (connector: string, depth: number) => Effect.Effect<void, never, never>;
48
44
  declare const setLastSuccessTimestamp: (attrs: LastSuccessMetricAttrs, lastSuccessAt?: string) => Effect.Effect<void, never, never>;
49
45
  declare const recordApiRetry: (attrs: ApiRetryMetricAttrs) => Effect.Effect<void, never, never>;
46
+ /**
47
+ * A jittered exponential schedule for `HttpClient.retryTransient` that records
48
+ * each retry with its reason.
49
+ */
50
+ declare const retrySchedule: (options: {
51
+ readonly connector: string;
52
+ readonly baseDelay: Duration.Input;
53
+ readonly times: number;
54
+ }) => Schedule.Schedule<Duration.Duration, unknown, never, never>;
50
55
  declare const setSyncState: (attrs: SyncStateAttrs, current: SyncState) => Effect.Effect<void, never, never>;
51
56
  /** @internal Converts the ergonomic SDK input to canonical OTel attributes. */
52
57
  declare const withResourceAttributes: (attrs: ResourceMetricAttrs) => {
@@ -55,5 +60,5 @@ declare const withResourceAttributes: (attrs: ResourceMetricAttrs) => {
55
60
  "airfoil.resource.source": BatchSource;
56
61
  };
57
62
  //#endregion
58
- export { syncState as C, withResourceAttributes as E, setWebhookQueueDepth as S, webhookRequests as T, publishDuration as _, LastSuccessMetricAttrs as a, setLastSuccessTimestamp as b, WebhookMetricAttrs as c, batchSize as d, batches as f, metrics_d_exports as g, lastSuccessTimestamp as h, BatchSource as i, WebhookOutcome as l, entitiesUpserted as m, ApiRetryReason as n, ResourceMetricAttrs as o, entitiesDeleted as p, BatchOutcome as r, SyncStateAttrs as s, ApiRetryMetricAttrs as t, apiRetries as u, recordApiRetry as v, webhookQueueDepth as w, setSyncState as x, recordWebhookRequest as y };
59
- //# sourceMappingURL=metrics-C4V1pm6v.d.ts.map
63
+ export { syncState as C, withResourceAttributes as E, setWebhookQueueDepth as S, webhookRequests as T, recordWebhookRequest as _, LastSuccessMetricAttrs as a, setLastSuccessTimestamp as b, WebhookMetricAttrs as c, batchSize as d, batches as f, recordApiRetry as g, metrics_d_exports as h, BatchSource as i, WebhookOutcome as l, lastSuccessTimestamp as m, ApiRetryReason as n, ResourceMetricAttrs as o, ingestDuration as p, BatchOutcome as r, SyncStateAttrs as s, ApiRetryMetricAttrs as t, apiRetries as u, retrySchedule as v, webhookQueueDepth as w, setSyncState as x, rowsIngested as y };
64
+ //# sourceMappingURL=metrics-CVXFL7YT.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { C as syncState, E as withResourceAttributes, S as setWebhookQueueDepth, T as webhookRequests, _ as recordWebhookRequest, a as LastSuccessMetricAttrs, b as setLastSuccessTimestamp, c as WebhookMetricAttrs, d as batchSize, f as batches, g as recordApiRetry, i as BatchSource, l as WebhookOutcome, m as lastSuccessTimestamp, n as ApiRetryReason, o as ResourceMetricAttrs, p as ingestDuration, r as BatchOutcome, s as SyncStateAttrs, t as ApiRetryMetricAttrs, u as apiRetries, v as retrySchedule, w as webhookQueueDepth, x as setSyncState, y as rowsIngested } from "./metrics-CVXFL7YT.mjs";
2
+ export { ApiRetryMetricAttrs, ApiRetryReason, BatchOutcome, BatchSource, LastSuccessMetricAttrs, ResourceMetricAttrs, SyncStateAttrs, WebhookMetricAttrs, WebhookOutcome, apiRetries, batchSize, batches, ingestDuration, lastSuccessTimestamp, recordApiRetry, recordWebhookRequest, retrySchedule, rowsIngested, setLastSuccessTimestamp, setSyncState, setWebhookQueueDepth, syncState, webhookQueueDepth, webhookRequests, withResourceAttributes };
@@ -0,0 +1,2 @@
1
+ import { _ as withResourceAttributes, a as lastSuccessTimestamp, c as recordWebhookRequest, d as setLastSuccessTimestamp, f as setSyncState, g as webhookRequests, h as webhookQueueDepth, i as ingestDuration, l as retrySchedule, m as syncState, n as batchSize, p as setWebhookQueueDepth, r as batches, s as recordApiRetry, t as apiRetries, u as rowsIngested } from "./metrics-BaEX__MN.mjs";
2
+ export { apiRetries, batchSize, batches, ingestDuration, lastSuccessTimestamp, recordApiRetry, recordWebhookRequest, retrySchedule, rowsIngested, setLastSuccessTimestamp, setSyncState, setWebhookQueueDepth, syncState, webhookQueueDepth, webhookRequests, withResourceAttributes };
@@ -1,13 +1,13 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
- var __export = (all) => {
3
+ var __exportAll = (all, no_symbols) => {
4
4
  let target = {};
5
5
  for (var name in all) __defProp(target, name, {
6
6
  get: all[name],
7
7
  enumerable: true
8
8
  });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
9
10
  return target;
10
11
  };
11
-
12
12
  //#endregion
13
- export { __export as t };
13
+ export { __exportAll as t };
@@ -0,0 +1,2 @@
1
+ import { a as layerHosted, c as catalog, d as RuntimeConfigError, f as RuntimeConfigErrorCode, i as loadTableBindings, l as httpPort, n as ResolvedTableBindings, o as PlatformRuntimeDefault, r as TableBinding, s as PlatformRuntimeKey, u as wingsUri } from "../index-ygpml2kC.mjs";
2
+ export { PlatformRuntimeDefault, PlatformRuntimeKey, type ResolvedTableBindings, RuntimeConfigError, type RuntimeConfigErrorCode, type TableBinding, catalog, httpPort, layerHosted, loadTableBindings, wingsUri };
@@ -0,0 +1,3 @@
1
+ import { n as PlatformRuntimeKey, t as PlatformRuntimeDefault } from "../constants-D-GQzpHZ.mjs";
2
+ import { a as catalog, i as RuntimeConfigError, n as loadTableBindings, o as httpPort, r as layerHosted, s as wingsUri } from "../runtime-config-Oa55gAew.mjs";
3
+ export { PlatformRuntimeDefault, PlatformRuntimeKey, RuntimeConfigError, catalog, httpPort, layerHosted, loadTableBindings, wingsUri };
@@ -0,0 +1,97 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { n as PlatformRuntimeKey, t as PlatformRuntimeDefault } from "./constants-D-GQzpHZ.mjs";
3
+ import { Config, ConfigProvider, Data, Effect, FileSystem, Schema } from "effect";
4
+ //#region src/runtime-config/config.ts
5
+ /** Shared HTTP port used by hosted and sandbox connector entrypoints. */
6
+ const httpPort = Config.Port(PlatformRuntimeKey.httpPort).pipe(Config.withDefault(PlatformRuntimeDefault.httpPort));
7
+ /** Wings URL, including the protocol. */
8
+ const wingsUri = Config.URL(PlatformRuntimeKey.wingsUri);
9
+ /** Wings catalog ID. */
10
+ const catalog = Config.NonEmptyString(PlatformRuntimeKey.catalog);
11
+ //#endregion
12
+ //#region src/runtime-config/error.ts
13
+ /** Expected hosted-config failure with a stable code and diagnostic cause. */
14
+ var RuntimeConfigError = class extends Data.TaggedError("RuntimeConfigError") {};
15
+ //#endregion
16
+ //#region src/runtime-config/layer.ts
17
+ const providerFromFile = Effect.gen(function* () {
18
+ const configPath = yield* Config.NonEmptyString(PlatformRuntimeKey.configPath).pipe(Effect.mapError((error) => new RuntimeConfigError({
19
+ code: "CONFIG_PATH_MISSING",
20
+ message: `${PlatformRuntimeKey.configPath} is required in hosted mode`,
21
+ cause: error.cause
22
+ })));
23
+ const contents = yield* (yield* FileSystem.FileSystem).readFileString(configPath).pipe(Effect.mapError((cause) => new RuntimeConfigError({
24
+ code: "CONFIG_FILE_UNREADABLE",
25
+ message: "Connector config file could not be read",
26
+ cause
27
+ })));
28
+ const document = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(contents).pipe(Effect.mapError((error) => new RuntimeConfigError({
29
+ code: "CONFIG_JSON_INVALID",
30
+ message: "Connector config is not valid JSON",
31
+ cause: error
32
+ })));
33
+ return ConfigProvider.fromUnknown(document, { preserveEmptyStrings: true });
34
+ });
35
+ /**
36
+ * Loads the required JSON file and lets environment values override it per key.
37
+ * Connector field validation remains in the connector's Effect Config.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * program.pipe(Effect.provide(layerHosted()));
42
+ * ```
43
+ */
44
+ const layerHosted = () => ConfigProvider.layerAdd(providerFromFile);
45
+ //#endregion
46
+ //#region src/runtime-config/table-bindings.ts
47
+ const TableIdentifierSchema = Schema.Struct({
48
+ namespace: Schema.NonEmptyArray(Schema.NonEmptyString),
49
+ name: Schema.NonEmptyString,
50
+ location: Schema.optional(Schema.NonEmptyString)
51
+ });
52
+ const RawBindingsSchema = Schema.fromJsonString(Schema.Record(Schema.String, TableIdentifierSchema));
53
+ const asError = (cause) => cause instanceof Error ? cause : new Error(String(cause));
54
+ const fail = (code, message) => new RuntimeConfigError({
55
+ code,
56
+ message,
57
+ cause: new Error(message)
58
+ });
59
+ /** Reads hosted table bindings and checks they name resources of the connector. */
60
+ const loadTableBindings = (connector) => Effect.gen(function* () {
61
+ const raw = yield* Config.NonEmptyString(PlatformRuntimeKey.tableBindings).pipe(Effect.mapError((cause) => new RuntimeConfigError({
62
+ code: "TABLE_BINDINGS_MISSING",
63
+ message: `${PlatformRuntimeKey.tableBindings} is required in hosted mode`,
64
+ cause: asError(cause)
65
+ })));
66
+ const decoded = yield* Schema.decodeUnknownEffect(RawBindingsSchema)(raw, { onExcessProperty: "error" }).pipe(Effect.mapError((cause) => new RuntimeConfigError({
67
+ code: "TABLE_BINDINGS_INVALID",
68
+ message: "Hosted table bindings are invalid",
69
+ cause: asError(cause)
70
+ })));
71
+ const actual = Object.keys(decoded);
72
+ if (actual.length === 0) return yield* Effect.fail(fail("TABLE_BINDINGS_INVALID", "Hosted table bindings name no resources"));
73
+ const expected = new Set(connector.resources.map((resource) => resource.name));
74
+ const unknown = actual.filter((name) => !expected.has(name));
75
+ if (unknown.length > 0) return yield* Effect.fail(fail("TABLE_BINDINGS_MISMATCH", `Hosted table bindings name resources the connector doesn't have (${unknown.length})`));
76
+ return Object.fromEntries(Object.entries(decoded).map(([resource, identifier]) => [resource, {
77
+ namespace: Array.from(identifier.namespace),
78
+ name: identifier.name,
79
+ ...identifier.location === void 0 ? {} : { location: identifier.location }
80
+ }]));
81
+ });
82
+ //#endregion
83
+ //#region src/runtime-config/index.ts
84
+ var runtime_config_exports = /* @__PURE__ */ __exportAll({
85
+ PlatformRuntimeDefault: () => PlatformRuntimeDefault,
86
+ PlatformRuntimeKey: () => PlatformRuntimeKey,
87
+ RuntimeConfigError: () => RuntimeConfigError,
88
+ catalog: () => catalog,
89
+ httpPort: () => httpPort,
90
+ layerHosted: () => layerHosted,
91
+ loadTableBindings: () => loadTableBindings,
92
+ wingsUri: () => wingsUri
93
+ });
94
+ //#endregion
95
+ export { catalog as a, RuntimeConfigError as i, loadTableBindings as n, httpPort as o, layerHosted as r, wingsUri as s, runtime_config_exports as t };
96
+
97
+ //# sourceMappingURL=runtime-config-Oa55gAew.mjs.map