@useairfoil/connector-kit 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/METRICS.md +78 -0
  2. package/README.md +450 -88
  3. package/dist/auth/index.d.ts +2 -0
  4. package/dist/auth/index.js +3 -0
  5. package/dist/auth-DvU_CZ7C.js +42 -0
  6. package/dist/auth-DvU_CZ7C.js.map +1 -0
  7. package/dist/chunk-Bp6m_JJh.js +13 -0
  8. package/dist/connector-app/index.d.ts +14 -0
  9. package/dist/connector-app/index.js +11 -0
  10. package/dist/connector-app-d7Z-SZLQ.js +64 -0
  11. package/dist/connector-app-d7Z-SZLQ.js.map +1 -0
  12. package/dist/constants-BRhIX_rz.js +27 -0
  13. package/dist/constants-BRhIX_rz.js.map +1 -0
  14. package/dist/errors/index.d.ts +2 -0
  15. package/dist/errors/index.js +3 -0
  16. package/dist/errors-DHWylqRZ.js +8 -0
  17. package/dist/errors-DHWylqRZ.js.map +1 -0
  18. package/dist/index-Byr0Lf0C.d.ts +25 -0
  19. package/dist/index-CBT-JX-T.d.ts +173 -0
  20. package/dist/index-CTHVudvQ.d.ts +41 -0
  21. package/dist/index-CTLYQ74P.d.ts +80 -0
  22. package/dist/index-Coh_SkBs.d.ts +95 -0
  23. package/dist/index-D54ySAKn.d.ts +14 -0
  24. package/dist/index-DtJX_tic.d.ts +153 -0
  25. package/dist/index-J42AZaXU.d.ts +38 -0
  26. package/dist/index-fIIBVAai.d.ts +25 -0
  27. package/dist/index-o1-Z3n7V.d.ts +55 -0
  28. package/dist/index.d.ts +14 -165
  29. package/dist/index.js +50 -228
  30. package/dist/index.js.map +1 -1
  31. package/dist/ingestion/index.d.ts +6 -0
  32. package/dist/ingestion/index.js +10 -0
  33. package/dist/ingestion-BQo4cbGw.js +200 -0
  34. package/dist/ingestion-BQo4cbGw.js.map +1 -0
  35. package/dist/manifest/index.d.ts +2 -0
  36. package/dist/manifest/index.js +4 -0
  37. package/dist/manifest-ByE6YPG0.js +221 -0
  38. package/dist/manifest-ByE6YPG0.js.map +1 -0
  39. package/dist/metrics-CVAk1ALR.d.ts +53 -0
  40. package/dist/metrics-CWPy2Aqc.js +96 -0
  41. package/dist/metrics-CWPy2Aqc.js.map +1 -0
  42. package/dist/metrics.d.ts +4 -0
  43. package/dist/metrics.js +3 -0
  44. package/dist/publisher/index.d.ts +5 -0
  45. package/dist/publisher/index.js +6 -0
  46. package/dist/publisher-BYT3RLVO.js +131 -0
  47. package/dist/publisher-BYT3RLVO.js.map +1 -0
  48. package/dist/runtime-config/index.d.ts +2 -0
  49. package/dist/runtime-config/index.js +4 -0
  50. package/dist/runtime-config-BpB-d_bF.js +51 -0
  51. package/dist/runtime-config-BpB-d_bF.js.map +1 -0
  52. package/dist/server-CXTQ7odl.js +183 -0
  53. package/dist/server-CXTQ7odl.js.map +1 -0
  54. package/dist/service-DuFiQwid.js +191 -0
  55. package/dist/service-DuFiQwid.js.map +1 -0
  56. package/dist/service-IE5qaf9x.d.ts +32 -0
  57. package/dist/state-store/index.d.ts +3 -0
  58. package/dist/state-store/index.js +5 -0
  59. package/dist/state-store-yl6LiTQ0.js +198 -0
  60. package/dist/state-store-yl6LiTQ0.js.map +1 -0
  61. package/dist/status/index.d.ts +5 -0
  62. package/dist/status/index.js +6 -0
  63. package/dist/status-B-oZBc33.js +84 -0
  64. package/dist/status-B-oZBc33.js.map +1 -0
  65. package/dist/types-B35J5YPu.d.ts +174 -0
  66. package/dist/webhook/index.d.ts +6 -0
  67. package/dist/webhook/index.js +8 -0
  68. package/dist/webhook-DI-Afxkg.js +13 -0
  69. package/dist/webhook-DI-Afxkg.js.map +1 -0
  70. package/package.json +66 -8
  71. package/src/auth/index.ts +1 -0
  72. package/src/auth/token-cache.ts +54 -0
  73. package/src/connector-app/check.ts +76 -0
  74. package/src/connector-app/index.ts +2 -0
  75. package/src/connector-app/start.ts +42 -0
  76. package/src/core/builder.ts +81 -9
  77. package/src/core/index.ts +22 -0
  78. package/src/core/types.ts +204 -76
  79. package/src/errors/index.ts +1 -0
  80. package/src/index.ts +13 -28
  81. package/src/ingestion/engine.ts +409 -174
  82. package/src/ingestion/index.ts +1 -0
  83. package/src/manifest/config.ts +232 -0
  84. package/src/manifest/index.ts +14 -0
  85. package/src/manifest/manifest.ts +31 -0
  86. package/src/manifest/number-schema.ts +17 -0
  87. package/src/manifest/schema.ts +160 -0
  88. package/src/metrics.ts +128 -0
  89. package/src/publisher/console.ts +18 -0
  90. package/src/publisher/index.ts +7 -0
  91. package/src/publisher/instrumented.ts +68 -0
  92. package/src/publisher/service.ts +30 -13
  93. package/src/publisher/wings.ts +159 -72
  94. package/src/runtime/context.ts +15 -0
  95. package/src/runtime-config/constants.ts +27 -0
  96. package/src/runtime-config/error.ts +13 -0
  97. package/src/runtime-config/index.ts +3 -0
  98. package/src/runtime-config/layer.ts +56 -0
  99. package/src/state-store/index.ts +3 -0
  100. package/src/state-store/keys.ts +22 -0
  101. package/src/state-store/layer-key-value-store.ts +132 -0
  102. package/src/state-store/layer-memory.ts +11 -0
  103. package/src/state-store/layer-sql.ts +50 -0
  104. package/src/state-store/schema.ts +57 -0
  105. package/src/state-store/service.ts +51 -0
  106. package/src/state-store/state.ts +17 -0
  107. package/src/status/index.ts +2 -0
  108. package/src/status/route.ts +77 -0
  109. package/src/status/types.ts +33 -0
  110. package/src/telemetry.ts +288 -0
  111. package/src/webhook/index.ts +8 -0
  112. package/src/webhook/server.ts +209 -39
  113. package/src/webhook/types.ts +6 -17
  114. package/src/ingestion/state-store.ts +0 -36
  115. package/src/streams/pull-stream.ts +0 -54
  116. package/src/streams/webhook-queue.ts +0 -14
  117. /package/src/{core/errors.ts → errors/connector-error.ts} +0 -0
@@ -0,0 +1,42 @@
1
+ import { t as __export } from "./chunk-Bp6m_JJh.js";
2
+ import { Cache, Duration, Effect, Exit, Number, Redacted } from "effect";
3
+
4
+ //#region src/auth/token-cache.ts
5
+ /**
6
+ * Creates a lazy, in-memory token cache around an acquisition effect.
7
+ *
8
+ * `refreshFactor` controls how much of the provider lifetime is cached. It is
9
+ * clamped between `0` and `1`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const cache = yield* makeTokenCache({
14
+ * acquire: exchangeCredentials,
15
+ * refreshFactor: 0.5,
16
+ * })
17
+ *
18
+ * const token = yield* cache.get
19
+ * ```
20
+ */
21
+ const makeTokenCache = (options) => Effect.gen(function* () {
22
+ const refreshFactor = Number.clamp(options.refreshFactor ?? .5, {
23
+ minimum: 0,
24
+ maximum: 1
25
+ });
26
+ const cache = yield* Cache.makeWith((_) => options.acquire, {
27
+ capacity: 1,
28
+ timeToLive: (exit) => Exit.isSuccess(exit) ? Duration.millis(Duration.toMillis(exit.value.expiresIn) * refreshFactor) : Duration.zero
29
+ });
30
+ return {
31
+ get: Cache.get(cache, void 0).pipe(Effect.map((token) => token.value)),
32
+ invalidate: Cache.invalidate(cache, void 0)
33
+ };
34
+ });
35
+
36
+ //#endregion
37
+ //#region src/auth/index.ts
38
+ var auth_exports = /* @__PURE__ */ __export({ makeTokenCache: () => makeTokenCache });
39
+
40
+ //#endregion
41
+ export { makeTokenCache as n, auth_exports as t };
42
+ //# sourceMappingURL=auth-DvU_CZ7C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-DvU_CZ7C.js","names":[],"sources":["../src/auth/token-cache.ts","../src/auth/index.ts"],"sourcesContent":["import { Cache, Duration, Effect, Exit, Number, Redacted } from \"effect\";\n\nexport interface ExpiringToken {\n /** The credential kept in memory by the cache. */\n readonly value: Redacted.Redacted<string>;\n /** The lifetime reported by the provider. */\n readonly expiresIn: Duration.Duration;\n}\n\nexport interface TokenCache<E> {\n /** Returns the cached token or performs one shared acquisition. */\n readonly get: Effect.Effect<Redacted.Redacted<string>, E>;\n /** Removes the cached token so the next `get` reacquires it. */\n readonly invalidate: Effect.Effect<void>;\n}\n\n/**\n * Creates a lazy, in-memory token cache around an acquisition effect.\n *\n * `refreshFactor` controls how much of the provider lifetime is cached. It is\n * clamped between `0` and `1`.\n *\n * @example\n * ```ts\n * const cache = yield* makeTokenCache({\n * acquire: exchangeCredentials,\n * refreshFactor: 0.5,\n * })\n *\n * const token = yield* cache.get\n * ```\n */\nexport const makeTokenCache = <E, R>(options: {\n readonly acquire: Effect.Effect<ExpiringToken, E, R>;\n readonly refreshFactor?: number;\n}): Effect.Effect<TokenCache<E>, never, R> =>\n Effect.gen(function* () {\n const refreshFactor = Number.clamp(options.refreshFactor ?? 0.5, {\n minimum: 0,\n maximum: 1,\n });\n const cache = yield* Cache.makeWith((_: void) => options.acquire, {\n capacity: 1,\n timeToLive: (exit) =>\n Exit.isSuccess(exit)\n ? Duration.millis(Duration.toMillis(exit.value.expiresIn) * refreshFactor)\n : Duration.zero,\n });\n\n return {\n get: Cache.get(cache, undefined).pipe(Effect.map((token) => token.value)),\n invalidate: Cache.invalidate(cache, undefined),\n };\n });\n","export * from \"./token-cache\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,kBAAwB,YAInC,OAAO,IAAI,aAAa;CACtB,MAAM,gBAAgB,OAAO,MAAM,QAAQ,iBAAiB,IAAK;EAC/D,SAAS;EACT,SAAS;EACV,CAAC;CACF,MAAM,QAAQ,OAAO,MAAM,UAAU,MAAY,QAAQ,SAAS;EAChE,UAAU;EACV,aAAa,SACX,KAAK,UAAU,KAAK,GAChB,SAAS,OAAO,SAAS,SAAS,KAAK,MAAM,UAAU,GAAG,cAAc,GACxE,SAAS;EAChB,CAAC;AAEF,QAAO;EACL,KAAK,MAAM,IAAI,OAAO,OAAU,CAAC,KAAK,OAAO,KAAK,UAAU,MAAM,MAAM,CAAC;EACzE,YAAY,MAAM,WAAW,OAAO,OAAU;EAC/C;EACD"}
@@ -0,0 +1,13 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (all) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ return target;
10
+ };
11
+
12
+ //#endregion
13
+ export { __export as t };
@@ -0,0 +1,14 @@
1
+ import "../index-CTHVudvQ.js";
2
+ import "../index-D54ySAKn.js";
3
+ import "../types-B35J5YPu.js";
4
+ import { d as CheckResult, f as ResourceCheckResult, i as start, n as App, p as check, r as StartOptions, u as CheckOptions } from "../index-DtJX_tic.js";
5
+ import "../service-IE5qaf9x.js";
6
+ import "../index-Coh_SkBs.js";
7
+ import "../index-J42AZaXU.js";
8
+ import "../index-CBT-JX-T.js";
9
+ import "../metrics-CVAk1ALR.js";
10
+ import "../index-Byr0Lf0C.js";
11
+ import "../index-o1-Z3n7V.js";
12
+ import "../index-CTLYQ74P.js";
13
+ import "../index-fIIBVAai.js";
14
+ export { App, CheckOptions, CheckResult, ResourceCheckResult, StartOptions, check, start };
@@ -0,0 +1,11 @@
1
+ import "../errors-DHWylqRZ.js";
2
+ import { n as start, r as check } from "../connector-app-d7Z-SZLQ.js";
3
+ import "../metrics-CWPy2Aqc.js";
4
+ import "../constants-BRhIX_rz.js";
5
+ import "../service-DuFiQwid.js";
6
+ import "../server-CXTQ7odl.js";
7
+ import "../state-store-yl6LiTQ0.js";
8
+ import "../status-B-oZBc33.js";
9
+ import "../ingestion-BQo4cbGw.js";
10
+
11
+ export { check, start };
@@ -0,0 +1,64 @@
1
+ import { t as __export } from "./chunk-Bp6m_JJh.js";
2
+ import { n as run } from "./ingestion-BQo4cbGw.js";
3
+ import { Context, DateTime, Effect, Layer, Tuple } from "effect";
4
+ import { NodeHttpServer } from "@effect/platform-node";
5
+ import { HttpRouter } from "effect/unstable/http";
6
+ import { createServer } from "node:http";
7
+
8
+ //#region src/connector-app/check.ts
9
+ const ok = { _tag: "ok" };
10
+ const error = (message) => ({
11
+ _tag: "error",
12
+ message
13
+ });
14
+ const fromEntries = (entries) => Object.fromEntries(entries);
15
+ const resultsFor = (names, result) => fromEntries(names.map((name) => Tuple.make(name, result)));
16
+ /**
17
+ * Builds the connector service from its layer and validates only the selected
18
+ * resources. The layer remains open until every check finishes.
19
+ */
20
+ function check(service, layer, options) {
21
+ if (options.resources.length === 0) return Effect.succeed(fromEntries([]));
22
+ return service.pipe(Effect.flatMap((connector) => Effect.forEach(options.resources, (name) => {
23
+ const resource = connector.resources.find((candidate) => candidate.name === name);
24
+ return (resource ? resource.check.pipe(Effect.match({
25
+ onFailure: (failure) => error(failure.message),
26
+ onSuccess: () => ok
27
+ })) : Effect.succeed(error(`Unknown connector resource: ${name}`))).pipe(Effect.map((result) => Tuple.make(name, result)));
28
+ }).pipe(Effect.map(fromEntries))), Effect.provide(layer), Effect.match({
29
+ onFailure: (failure) => resultsFor(options.resources, error(failure.message)),
30
+ onSuccess: (results) => results
31
+ }));
32
+ }
33
+
34
+ //#endregion
35
+ //#region src/connector-app/start.ts
36
+ const start = (app, options) => Effect.gen(function* () {
37
+ const initialCutoff = options.initialCutoff ?? (yield* DateTime.now.pipe(Effect.map(DateTime.formatIso)));
38
+ const routes = app.webhooks?.map((route) => route.path) ?? [];
39
+ yield* Effect.logInfo("webhook server ready").pipe(Effect.annotateLogs({
40
+ port: options.port,
41
+ routes
42
+ }));
43
+ return yield* run(app, {
44
+ initialCutoff,
45
+ webhook: {
46
+ routes: app.webhooks ?? [],
47
+ healthPath: options.healthPath ?? "/health",
48
+ metricsPath: options.metricsPath,
49
+ statusPath: options.statusPath,
50
+ disableHttpLogger: options.disableHttpLogger ?? true
51
+ }
52
+ }).pipe(Effect.provide(NodeHttpServer.layer(createServer, { port: options.port })));
53
+ });
54
+
55
+ //#endregion
56
+ //#region src/connector-app/index.ts
57
+ var connector_app_exports = /* @__PURE__ */ __export({
58
+ check: () => check,
59
+ start: () => start
60
+ });
61
+
62
+ //#endregion
63
+ export { start as n, check as r, connector_app_exports as t };
64
+ //# sourceMappingURL=connector-app-d7Z-SZLQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-app-d7Z-SZLQ.js","names":["ok: ResourceCheckResult","runIngestion"],"sources":["../src/connector-app/check.ts","../src/connector-app/start.ts","../src/connector-app/index.ts"],"sourcesContent":["import { Context, Effect, Layer, Tuple } from \"effect\";\n\nimport type { ConnectorDefinition, ResourceDefinition, ResourceName } from \"../core/types\";\n\nexport type ResourceCheckResult =\n | { readonly _tag: \"ok\" }\n | { readonly _tag: \"error\"; readonly message: string };\n\nexport type CheckOptions<Name extends string> = {\n readonly resources: ReadonlyArray<Name>;\n};\n\ntype ResourceCheckResults<Name extends PropertyKey> = {\n readonly [Key in Name]: ResourceCheckResult;\n};\n\nexport type CheckResult<\n Resources extends ReadonlyArray<ResourceDefinition>,\n Name extends ResourceName<Resources> = ResourceName<Resources>,\n> = ResourceCheckResults<Name>;\n\ntype CheckFailure = { readonly message: string };\n\nconst ok: ResourceCheckResult = { _tag: \"ok\" };\n\nconst error = (message: string): ResourceCheckResult => ({ _tag: \"error\", message });\n\nconst fromEntries = <Name extends string>(\n entries: ReadonlyArray<readonly [Name, ResourceCheckResult]>,\n): ResourceCheckResults<Name> => Object.fromEntries(entries) as ResourceCheckResults<Name>;\n\nconst resultsFor = <Name extends string>(names: ReadonlyArray<Name>, result: ResourceCheckResult) =>\n fromEntries(names.map((name) => Tuple.make(name, result)));\n\n/**\n * Builds the connector service from its layer and validates only the selected\n * resources. The layer remains open until every check finishes.\n */\nexport function check<\n Identifier,\n const Resources extends ReadonlyArray<ResourceDefinition>,\n E extends CheckFailure,\n R,\n const Name extends ResourceName<Resources>,\n>(\n service: Context.Key<Identifier, ConnectorDefinition<Resources>>,\n layer: Layer.Layer<Identifier, E, R>,\n options: CheckOptions<Name>,\n): Effect.Effect<CheckResult<Resources, Name>, never, R> {\n if (options.resources.length === 0) {\n return Effect.succeed(fromEntries<Name>([]));\n }\n\n return service.pipe(\n Effect.flatMap((connector) =>\n Effect.forEach(options.resources, (name) => {\n const resource = connector.resources.find((candidate) => candidate.name === name);\n const result = resource\n ? resource.check.pipe(\n Effect.match({\n onFailure: (failure) => error(failure.message),\n onSuccess: () => ok,\n }),\n )\n : Effect.succeed(error(`Unknown connector resource: ${name}`));\n\n return result.pipe(Effect.map((result) => Tuple.make(name, result)));\n }).pipe(Effect.map(fromEntries)),\n ),\n Effect.provide(layer),\n Effect.match({\n onFailure: (failure) => resultsFor(options.resources, error(failure.message)),\n onSuccess: (results) => results,\n }),\n );\n}\n","import { NodeHttpServer } from \"@effect/platform-node\";\nimport { DateTime, Effect } from \"effect\";\nimport { HttpRouter } from \"effect/unstable/http\";\nimport { createServer } from \"node:http\";\n\nimport type { ConnectorDefinition } from \"../core\";\nimport type { Cursor } from \"../core/types\";\n\nimport { run as runIngestion } from \"../ingestion\";\n\nexport type App = ConnectorDefinition;\n\nexport type StartOptions = {\n readonly port: number;\n readonly initialCutoff?: Cursor.Value;\n readonly healthPath?: HttpRouter.PathInput;\n readonly metricsPath?: HttpRouter.PathInput | false;\n readonly statusPath?: HttpRouter.PathInput | false;\n readonly disableHttpLogger?: boolean;\n};\n\nexport const start = (app: App, options: StartOptions) =>\n Effect.gen(function* () {\n const initialCutoff =\n options.initialCutoff ?? (yield* DateTime.now.pipe(Effect.map(DateTime.formatIso)));\n const routes = app.webhooks?.map((route) => route.path) ?? [];\n\n yield* Effect.logInfo(\"webhook server ready\").pipe(\n Effect.annotateLogs({ port: options.port, routes }),\n );\n\n return yield* runIngestion(app, {\n initialCutoff,\n webhook: {\n routes: app.webhooks ?? [],\n healthPath: options.healthPath ?? \"/health\",\n metricsPath: options.metricsPath,\n statusPath: options.statusPath,\n disableHttpLogger: options.disableHttpLogger ?? true,\n },\n }).pipe(Effect.provide(NodeHttpServer.layer(createServer, { port: options.port })));\n });\n","export { check, type CheckOptions, type CheckResult, type ResourceCheckResult } from \"./check\";\nexport { start, type App, type StartOptions } from \"./start\";\n"],"mappings":";;;;;;;;AAuBA,MAAMA,KAA0B,EAAE,MAAM,MAAM;AAE9C,MAAM,SAAS,aAA0C;CAAE,MAAM;CAAS;CAAS;AAEnF,MAAM,eACJ,YAC+B,OAAO,YAAY,QAAQ;AAE5D,MAAM,cAAmC,OAA4B,WACnE,YAAY,MAAM,KAAK,SAAS,MAAM,KAAK,MAAM,OAAO,CAAC,CAAC;;;;;AAM5D,SAAgB,MAOd,SACA,OACA,SACuD;AACvD,KAAI,QAAQ,UAAU,WAAW,EAC/B,QAAO,OAAO,QAAQ,YAAkB,EAAE,CAAC,CAAC;AAG9C,QAAO,QAAQ,KACb,OAAO,SAAS,cACd,OAAO,QAAQ,QAAQ,YAAY,SAAS;EAC1C,MAAM,WAAW,UAAU,UAAU,MAAM,cAAc,UAAU,SAAS,KAAK;AAUjF,UATe,WACX,SAAS,MAAM,KACb,OAAO,MAAM;GACX,YAAY,YAAY,MAAM,QAAQ,QAAQ;GAC9C,iBAAiB;GAClB,CAAC,CACH,GACD,OAAO,QAAQ,MAAM,+BAA+B,OAAO,CAAC,EAElD,KAAK,OAAO,KAAK,WAAW,MAAM,KAAK,MAAM,OAAO,CAAC,CAAC;GACpE,CAAC,KAAK,OAAO,IAAI,YAAY,CAAC,CACjC,EACD,OAAO,QAAQ,MAAM,EACrB,OAAO,MAAM;EACX,YAAY,YAAY,WAAW,QAAQ,WAAW,MAAM,QAAQ,QAAQ,CAAC;EAC7E,YAAY,YAAY;EACzB,CAAC,CACH;;;;;ACrDH,MAAa,SAAS,KAAU,YAC9B,OAAO,IAAI,aAAa;CACtB,MAAM,gBACJ,QAAQ,kBAAkB,OAAO,SAAS,IAAI,KAAK,OAAO,IAAI,SAAS,UAAU,CAAC;CACpF,MAAM,SAAS,IAAI,UAAU,KAAK,UAAU,MAAM,KAAK,IAAI,EAAE;AAE7D,QAAO,OAAO,QAAQ,uBAAuB,CAAC,KAC5C,OAAO,aAAa;EAAE,MAAM,QAAQ;EAAM;EAAQ,CAAC,CACpD;AAED,QAAO,OAAOC,IAAa,KAAK;EAC9B;EACA,SAAS;GACP,QAAQ,IAAI,YAAY,EAAE;GAC1B,YAAY,QAAQ,cAAc;GAClC,aAAa,QAAQ;GACrB,YAAY,QAAQ;GACpB,mBAAmB,QAAQ,qBAAqB;GACjD;EACF,CAAC,CAAC,KAAK,OAAO,QAAQ,eAAe,MAAM,cAAc,EAAE,MAAM,QAAQ,MAAM,CAAC,CAAC,CAAC;EACnF"}
@@ -0,0 +1,27 @@
1
+ import { HashSet } from "effect";
2
+
3
+ //#region src/runtime-config/constants.ts
4
+ /** Shared runtime keys owned by Airfoil rather than an individual connector. */
5
+ const PlatformRuntimeKey = {
6
+ configPath: "AIRFOIL_CONFIG_PATH",
7
+ connectorInstanceId: "AIRFOIL_CONNECTOR_INSTANCE_ID",
8
+ stateTable: "AIRFOIL_STATE_TABLE",
9
+ postgresConnectionString: "POSTGRES_CONNECTION_STRING",
10
+ wingsHost: "WINGS_HOST",
11
+ wingsNamespace: "WINGS_NAMESPACE",
12
+ otelEnabled: "OTEL_ENABLED",
13
+ otelExporterOtlpEndpoint: "OTEL_EXPORTER_OTLP_ENDPOINT",
14
+ otelExporterOtlpHeaders: "OTEL_EXPORTER_OTLP_HEADERS",
15
+ otelServiceName: "OTEL_SERVICE_NAME",
16
+ otelServiceVersion: "OTEL_SERVICE_VERSION",
17
+ otelResourceAttributes: "OTEL_RESOURCE_ATTRIBUTES"
18
+ };
19
+ /** Defaults for optional platform-owned runtime configuration. */
20
+ const PlatformRuntimeDefault = { stateTable: "_airfoil_connectors_state" };
21
+ const platformRuntimeKeys = HashSet.fromIterable(Object.values(PlatformRuntimeKey));
22
+ /** @internal */
23
+ const isPlatformRuntimeKey = (key) => HashSet.has(platformRuntimeKeys, key);
24
+
25
+ //#endregion
26
+ export { PlatformRuntimeKey as n, isPlatformRuntimeKey as r, PlatformRuntimeDefault as t };
27
+ //# sourceMappingURL=constants-BRhIX_rz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-BRhIX_rz.js","names":[],"sources":["../src/runtime-config/constants.ts"],"sourcesContent":["import { HashSet } from \"effect\";\n\n/** Shared runtime keys owned by Airfoil rather than an individual connector. */\nexport const PlatformRuntimeKey = {\n configPath: \"AIRFOIL_CONFIG_PATH\",\n connectorInstanceId: \"AIRFOIL_CONNECTOR_INSTANCE_ID\",\n stateTable: \"AIRFOIL_STATE_TABLE\",\n postgresConnectionString: \"POSTGRES_CONNECTION_STRING\",\n wingsHost: \"WINGS_HOST\",\n wingsNamespace: \"WINGS_NAMESPACE\",\n otelEnabled: \"OTEL_ENABLED\",\n otelExporterOtlpEndpoint: \"OTEL_EXPORTER_OTLP_ENDPOINT\",\n otelExporterOtlpHeaders: \"OTEL_EXPORTER_OTLP_HEADERS\",\n otelServiceName: \"OTEL_SERVICE_NAME\",\n otelServiceVersion: \"OTEL_SERVICE_VERSION\",\n otelResourceAttributes: \"OTEL_RESOURCE_ATTRIBUTES\",\n} as const;\n\n/** Defaults for optional platform-owned runtime configuration. */\nexport const PlatformRuntimeDefault = {\n stateTable: \"_airfoil_connectors_state\",\n} as const;\n\nconst platformRuntimeKeys = HashSet.fromIterable(Object.values(PlatformRuntimeKey));\n\n/** @internal */\nexport const isPlatformRuntimeKey = (key: string): boolean => HashSet.has(platformRuntimeKeys, key);\n"],"mappings":";;;;AAGA,MAAa,qBAAqB;CAChC,YAAY;CACZ,qBAAqB;CACrB,YAAY;CACZ,0BAA0B;CAC1B,WAAW;CACX,gBAAgB;CAChB,aAAa;CACb,0BAA0B;CAC1B,yBAAyB;CACzB,iBAAiB;CACjB,oBAAoB;CACpB,wBAAwB;CACzB;;AAGD,MAAa,yBAAyB,EACpC,YAAY,6BACb;AAED,MAAM,sBAAsB,QAAQ,aAAa,OAAO,OAAO,mBAAmB,CAAC;;AAGnF,MAAa,wBAAwB,QAAyB,QAAQ,IAAI,qBAAqB,IAAI"}
@@ -0,0 +1,2 @@
1
+ import { t as ConnectorError } from "../index-D54ySAKn.js";
2
+ export { ConnectorError };
@@ -0,0 +1,3 @@
1
+ import { t as ConnectorError } from "../errors-DHWylqRZ.js";
2
+
3
+ export { ConnectorError };
@@ -0,0 +1,8 @@
1
+ import { Data } from "effect";
2
+
3
+ //#region src/errors/connector-error.ts
4
+ var ConnectorError = class extends Data.TaggedError("ConnectorError") {};
5
+
6
+ //#endregion
7
+ export { ConnectorError as t };
8
+ //# sourceMappingURL=errors-DHWylqRZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-DHWylqRZ.js","names":[],"sources":["../src/errors/connector-error.ts"],"sourcesContent":["import { Data } from \"effect\";\n\nexport class ConnectorError extends Data.TaggedError(\"ConnectorError\")<{\n readonly message: string;\n readonly cause?: unknown;\n}> {}\n"],"mappings":";;;AAEA,IAAa,iBAAb,cAAoC,KAAK,YAAY,iBAAiB,CAGnE"}
@@ -0,0 +1,25 @@
1
+ import { t as ConnectorError } from "./index-D54ySAKn.js";
2
+ import { c as ResourceBatch, n as ConnectorDefinition } from "./types-B35J5YPu.js";
3
+ import { a as PublisherService, i as Publisher, n as PublishOptions, r as PublishSource, t as PublishAck } from "./service-IE5qaf9x.js";
4
+ import { Layer } from "effect";
5
+ import * as Wings from "@useairfoil/wings";
6
+
7
+ //#region src/publisher/wings.d.ts
8
+ type WingsTableMapping = {
9
+ readonly name: string;
10
+ readonly partitionValue?: Wings.PartitionValue.PartitionValue;
11
+ };
12
+ type WingsPublisherConfig = {
13
+ readonly connector: ConnectorDefinition;
14
+ readonly tables: Record<string, string | WingsTableMapping>;
15
+ };
16
+ declare const layerWings: (config: WingsPublisherConfig) => Layer.Layer<Publisher, ConnectorError, Wings.WingsClient.WingsClient>;
17
+ //#endregion
18
+ //#region src/publisher/console.d.ts
19
+ declare const layerConsole: Layer.Layer<Publisher, never, never>;
20
+ declare namespace index_d_exports {
21
+ export { PublishAck, PublishOptions, PublishSource, Publisher, PublisherService, ResourceBatch, WingsPublisherConfig, layerConsole, layerWings };
22
+ }
23
+ //#endregion
24
+ export { layerWings as i, layerConsole as n, WingsPublisherConfig as r, index_d_exports as t };
25
+ //# sourceMappingURL=index-Byr0Lf0C.d.ts.map
@@ -0,0 +1,173 @@
1
+ import { Config, Option, Redacted, Schema, Types } from "effect";
2
+ import * as effect_Effect0 from "effect/Effect";
3
+
4
+ //#region src/manifest/number-schema.d.ts
5
+ type NumberConstraints = {
6
+ readonly integer?: boolean;
7
+ readonly minimum?: number;
8
+ };
9
+ //#endregion
10
+ //#region src/manifest/config.d.ts
11
+ type ConfigFieldSpecBase = {
12
+ readonly runtimeKey: string;
13
+ readonly required: boolean;
14
+ readonly description?: string;
15
+ };
16
+ type ConfigFieldDefinition = ConfigFieldSpecBase & ({
17
+ readonly type: "string";
18
+ readonly secret: false;
19
+ readonly default?: string;
20
+ readonly values?: never;
21
+ } | {
22
+ readonly type: "string";
23
+ readonly secret: true;
24
+ readonly default?: never;
25
+ readonly values?: never;
26
+ } | {
27
+ readonly type: "number";
28
+ readonly secret: false;
29
+ readonly default?: number;
30
+ readonly values?: never;
31
+ readonly integer?: boolean;
32
+ readonly minimum?: number;
33
+ } | {
34
+ readonly type: "boolean";
35
+ readonly secret: false;
36
+ readonly default?: boolean;
37
+ readonly values?: never;
38
+ } | {
39
+ readonly type: "select";
40
+ readonly secret: false;
41
+ readonly default?: string;
42
+ readonly values: readonly [string, ...Array<string>];
43
+ });
44
+ /** Serializable, browser-safe metadata for one user-provided connector setting. */
45
+ type ConfigFieldSpec = ConfigFieldDefinition & {
46
+ readonly name: string;
47
+ };
48
+ /** Pairs an Effect runtime config with the metadata used to generate its form field. */
49
+ type ConfigField<A$1> = {
50
+ readonly config: Config.Config<A$1>;
51
+ readonly spec: ConfigFieldDefinition;
52
+ };
53
+ type FieldBaseOptions = {
54
+ readonly runtimeKey: string;
55
+ readonly description?: string;
56
+ };
57
+ type FieldOptions<A$1 extends string | number | boolean = string | number | boolean> = FieldBaseOptions & ({
58
+ readonly required?: true;
59
+ readonly default?: A$1;
60
+ } | {
61
+ readonly required: false;
62
+ readonly default: A$1;
63
+ });
64
+ type NumberFieldOptions = FieldOptions<number> & NumberConstraints;
65
+ type FieldsRecord = Record<string, ConfigField<unknown>>;
66
+ type ConfigOf<Fields$1 extends FieldsRecord> = { readonly [Key in keyof Fields$1]: Fields$1[Key] extends ConfigField<infer A> ? A : never };
67
+ /** Effect config and serializable manifest metadata produced from one field definition. */
68
+ type ConnectorConfigDef<Fields$1 extends FieldsRecord> = {
69
+ readonly fields: { readonly [Key in keyof Fields$1]: Fields$1[Key] extends ConfigField<infer A> ? Config.Config<A> : never };
70
+ readonly config: Config.Config<ConfigOf<Fields$1>>;
71
+ readonly spec: ReadonlyArray<ConfigFieldSpec>;
72
+ };
73
+ type ConfigValuesOf<Def extends ConnectorConfigDef<FieldsRecord>> = Def extends ConnectorConfigDef<infer Fields> ? ConfigOf<Fields> : never;
74
+ /** Defines a required non-empty string, optionally with a default. */
75
+ declare const string: (options: FieldOptions<string>) => ConfigField<string>;
76
+ /** Defines a finite number with optional integer, minimum, and default constraints. */
77
+ declare const number: (options: NumberFieldOptions) => ConfigField<number>;
78
+ /** Defines a boolean, optionally with a default. */
79
+ declare const boolean: (options: FieldOptions<boolean>) => ConfigField<boolean>;
80
+ /** Defines a string literal choice whose values are preserved in the inferred type. */
81
+ declare const select: <const Values extends readonly [string, ...Array<string>]>(options: FieldOptions<Values[number]> & {
82
+ readonly values: Values;
83
+ }) => ConfigField<Values[number]>;
84
+ /** Defines a required, non-empty secret decoded as `Redacted<string>`. */
85
+ declare const secret: (options: FieldBaseOptions & {
86
+ readonly required?: true;
87
+ }) => ConfigField<Redacted.Redacted<string>>;
88
+ /** Makes an existing field optional and represents a missing value as `Option.none()`. */
89
+ declare const optional: <A$1>(field: ConfigField<A$1>) => ConfigField<Option.Option<A$1>>;
90
+ /**
91
+ * Defines user-facing connector config once for both Effect runtime loading and
92
+ * frontend form generation. The object keys become logical form/API field names;
93
+ * `runtimeKey` remains the key read by Effect Config.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const config = define({
98
+ * apiUrl: string({ runtimeKey: "API_URL" }),
99
+ * token: secret({ runtimeKey: "API_TOKEN" }),
100
+ * });
101
+ *
102
+ * const RuntimeConfig = config.config;
103
+ * const formFields = config.spec;
104
+ * ```
105
+ */
106
+ declare const define: <const Fields$1 extends FieldsRecord>(fields: Fields$1) => ConnectorConfigDef<Fields$1>;
107
+ //#endregion
108
+ //#region src/manifest/manifest.d.ts
109
+ type ResourceCapability = "backfill" | "changes" | "webhook";
110
+ /** Browser-safe connector metadata consumed by the platform and runtime adapters. */
111
+ type ConnectorManifest = {
112
+ readonly name: string;
113
+ readonly title: string;
114
+ readonly description?: string;
115
+ readonly config: ReadonlyArray<ConfigFieldSpec>;
116
+ readonly resources: ReadonlyArray<{
117
+ readonly name: string;
118
+ readonly capabilities: ReadonlyArray<ResourceCapability>;
119
+ }>;
120
+ };
121
+ /**
122
+ * Defines browser-safe connector metadata while preserving literal names and capabilities.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const manifest = define({
127
+ * name: "producer-example",
128
+ * title: "Example",
129
+ * config: ExampleConfig.spec,
130
+ * resources: [{ name: "orders", capabilities: ["backfill"] }],
131
+ * });
132
+ * ```
133
+ */
134
+ declare const define$1: <const Manifest extends ConnectorManifest>(manifest: Manifest) => Manifest;
135
+ //#endregion
136
+ //#region src/manifest/schema.d.ts
137
+ type FieldValueOf<Field$1 extends ConfigFieldSpec> = Field$1["type"] extends "number" ? number : Field$1["type"] extends "boolean" ? boolean : Field$1["values"] extends ReadonlyArray<string> ? Field$1["values"][number] : string;
138
+ type ConnectorConfigValues<Manifest extends ConnectorManifest> = Types.Simplify<{ readonly [Field in Manifest["config"][number] as Field["required"] extends true ? Field["name"] : never]: FieldValueOf<Field> } & { readonly [Field in Manifest["config"][number] as Field["required"] extends true ? never : Field["name"]]?: FieldValueOf<Field> | undefined }> & object;
139
+ type ConnectorConfigSchema<Manifest extends ConnectorManifest> = Schema.Codec<ConnectorConfigValues<Manifest>, unknown>;
140
+ /** Flat primitive document keyed by the runtime keys consumed by Effect Config. */
141
+ type RuntimeConfigDocument = Readonly<Record<string, string | number | boolean>>;
142
+ /**
143
+ * Builds an Effect Schema for logical form/API values from a connector manifest.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const decode = Schema.decodeUnknownEffect(configSchema(manifest));
148
+ * const values = decode({
149
+ * apiUrl: "https://example.com",
150
+ * retries: "3",
151
+ * });
152
+ * ```
153
+ */
154
+ declare const configSchema: <const Manifest extends ConnectorManifest>(manifest: Manifest) => ConnectorConfigSchema<Manifest>;
155
+ /** Decodes browser/API config, applies manifest defaults, and rejects undeclared fields. */
156
+ declare const decodeConfig: <const Manifest extends ConnectorManifest>(manifest: Manifest, input: unknown) => effect_Effect0.Effect<ConnectorConfigValues<Manifest>, Schema.SchemaError, never>;
157
+ /**
158
+ * Maps validated logical values to the flat runtime-key document mounted in a pod.
159
+ * Missing optional values are omitted.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * toRuntimeDocument(manifest, { apiUrl: "https://example.com" });
164
+ * // { API_URL: "https://example.com" }
165
+ * ```
166
+ */
167
+ declare const toRuntimeDocument: <const Manifest extends ConnectorManifest>(manifest: Manifest, values: ConnectorConfigValues<Manifest>) => RuntimeConfigDocument;
168
+ declare namespace index_d_exports {
169
+ export { ConfigField, ConfigFieldSpec, ConfigValuesOf, ConnectorConfigDef, ConnectorConfigSchema, ConnectorConfigValues, ConnectorManifest, ResourceCapability, RuntimeConfigDocument, boolean, configSchema, decodeConfig, define$1 as define, define as defineConfig, number, optional, secret, select, string, toRuntimeDocument };
170
+ }
171
+ //#endregion
172
+ export { number as _, configSchema as a, select as b, ConnectorManifest as c, ConfigField as d, ConfigFieldSpec as f, define as g, boolean as h, RuntimeConfigDocument as i, ResourceCapability as l, ConnectorConfigDef as m, ConnectorConfigSchema as n, decodeConfig as o, ConfigValuesOf as p, ConnectorConfigValues as r, toRuntimeDocument as s, index_d_exports as t, define$1 as u, optional as v, string as x, secret as y };
173
+ //# sourceMappingURL=index-CBT-JX-T.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { Duration, Effect, Redacted } from "effect";
2
+
3
+ //#region src/auth/token-cache.d.ts
4
+ interface ExpiringToken {
5
+ /** The credential kept in memory by the cache. */
6
+ readonly value: Redacted.Redacted<string>;
7
+ /** The lifetime reported by the provider. */
8
+ readonly expiresIn: Duration.Duration;
9
+ }
10
+ interface TokenCache<E> {
11
+ /** Returns the cached token or performs one shared acquisition. */
12
+ readonly get: Effect.Effect<Redacted.Redacted<string>, E>;
13
+ /** Removes the cached token so the next `get` reacquires it. */
14
+ readonly invalidate: Effect.Effect<void>;
15
+ }
16
+ /**
17
+ * Creates a lazy, in-memory token cache around an acquisition effect.
18
+ *
19
+ * `refreshFactor` controls how much of the provider lifetime is cached. It is
20
+ * clamped between `0` and `1`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const cache = yield* makeTokenCache({
25
+ * acquire: exchangeCredentials,
26
+ * refreshFactor: 0.5,
27
+ * })
28
+ *
29
+ * const token = yield* cache.get
30
+ * ```
31
+ */
32
+ declare const makeTokenCache: <E, R>(options: {
33
+ readonly acquire: Effect.Effect<ExpiringToken, E, R>;
34
+ readonly refreshFactor?: number;
35
+ }) => Effect.Effect<TokenCache<E>, never, R>;
36
+ declare namespace index_d_exports {
37
+ export { ExpiringToken, TokenCache, makeTokenCache };
38
+ }
39
+ //#endregion
40
+ export { makeTokenCache as i, ExpiringToken as n, TokenCache as r, index_d_exports as t };
41
+ //# sourceMappingURL=index-CTHVudvQ.d.ts.map
@@ -0,0 +1,80 @@
1
+ import { n as ConnectorDefinition } from "./types-B35J5YPu.js";
2
+ import { i as StateStore } from "./index-Coh_SkBs.js";
3
+ import { Schema } from "effect";
4
+ import { HttpRouter } from "effect/unstable/http";
5
+ import * as effect_Layer1 from "effect/Layer";
6
+
7
+ //#region src/status/route.d.ts
8
+ declare const statusRoute: (connector: ConnectorDefinition, path?: HttpRouter.PathInput) => effect_Layer1.Layer<never, never, HttpRouter.HttpRouter | HttpRouter.Request<"Requires", StateStore>>;
9
+ //#endregion
10
+ //#region src/status/types.d.ts
11
+ declare const SyncStateSchema: Schema.Literals<readonly ["pending", "backfilling", "live", "error"]>;
12
+ type SyncState = Schema.Schema.Type<typeof SyncStateSchema>;
13
+ /** Safe source failure returned by the status endpoint. */
14
+ declare const ResourceErrorSchema: Schema.Struct<{
15
+ readonly at: Schema.String;
16
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
17
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
18
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
19
+ readonly message: Schema.String;
20
+ }>;
21
+ type ResourceError = Schema.Schema.Type<typeof ResourceErrorSchema>;
22
+ declare const ResourceStatusSchema: Schema.Struct<{
23
+ readonly backfill: Schema.optional<Schema.Struct<{
24
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
25
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
26
+ readonly completed: Schema.Boolean;
27
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
28
+ }>>;
29
+ readonly changes: Schema.optional<Schema.Struct<{
30
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
31
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
32
+ }>>;
33
+ readonly lastError: Schema.optional<Schema.Struct<{
34
+ readonly at: Schema.String;
35
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
36
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
37
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
38
+ readonly message: Schema.String;
39
+ }>>;
40
+ readonly name: Schema.String;
41
+ readonly state: Schema.Literals<readonly ["pending", "backfilling", "live", "error"]>;
42
+ }>;
43
+ type ResourceStatus = Schema.Schema.Type<typeof ResourceStatusSchema>;
44
+ declare const StatusResponseSchema: Schema.Struct<{
45
+ readonly connector: Schema.String;
46
+ readonly resources: Schema.$Array<Schema.Struct<{
47
+ readonly backfill: Schema.optional<Schema.Struct<{
48
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
49
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
50
+ readonly completed: Schema.Boolean;
51
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
52
+ }>>;
53
+ readonly changes: Schema.optional<Schema.Struct<{
54
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
55
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
56
+ }>>;
57
+ readonly lastError: Schema.optional<Schema.Struct<{
58
+ readonly at: Schema.String;
59
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
60
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
61
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
62
+ readonly message: Schema.String;
63
+ }>>;
64
+ readonly name: Schema.String;
65
+ readonly state: Schema.Literals<readonly ["pending", "backfilling", "live", "error"]>;
66
+ }>>;
67
+ }>;
68
+ type StatusResponse = Schema.Schema.Type<typeof StatusResponseSchema>;
69
+ /** Returned when durable resource status cannot be read. */
70
+ declare const StatusUnavailableResponseSchema: Schema.Struct<{
71
+ readonly ok: Schema.Literal<false>;
72
+ readonly error: Schema.String;
73
+ }>;
74
+ type StatusUnavailableResponse = Schema.Schema.Type<typeof StatusUnavailableResponseSchema>;
75
+ declare namespace index_d_exports {
76
+ export { ResourceError, ResourceErrorSchema, ResourceStatus, ResourceStatusSchema, StatusResponse, StatusResponseSchema, StatusUnavailableResponse, StatusUnavailableResponseSchema, SyncState, SyncStateSchema, statusRoute };
77
+ }
78
+ //#endregion
79
+ export { ResourceStatusSchema as a, StatusUnavailableResponse as c, SyncStateSchema as d, statusRoute as f, ResourceStatus as i, StatusUnavailableResponseSchema as l, ResourceError as n, StatusResponse as o, ResourceErrorSchema as r, StatusResponseSchema as s, index_d_exports as t, SyncState as u };
80
+ //# sourceMappingURL=index-CTLYQ74P.d.ts.map
@@ -0,0 +1,95 @@
1
+ import { t as ConnectorError } from "./index-D54ySAKn.js";
2
+ import { Config, Context, Effect, Layer, Schema } from "effect";
3
+ import { SqlClient } from "effect/unstable/sql";
4
+
5
+ //#region src/state-store/schema.d.ts
6
+ /** Durable progress for a finite historical backfill. */
7
+ declare const BackfillStateSchema: Schema.Struct<{
8
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
9
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
10
+ readonly completed: Schema.Boolean;
11
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
12
+ }>;
13
+ /** Durable cursor for an ongoing incremental changes stream. */
14
+ declare const ChangesStateSchema: Schema.Struct<{
15
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
16
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
17
+ }>;
18
+ declare const StateSourceSchema: Schema.Literals<readonly ["backfill", "changes"]>;
19
+ declare const StateOperationSchema: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
20
+ /** Complete persisted state assembled from independently stored components. */
21
+ declare const ResourceStateSchema: Schema.Struct<{
22
+ readonly backfill: Schema.optional<Schema.Struct<{
23
+ readonly cutoff: Schema.Union<readonly [Schema.String, Schema.Number]>;
24
+ readonly pageCursor: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Number]>>;
25
+ readonly completed: Schema.Boolean;
26
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
27
+ }>>;
28
+ readonly changes: Schema.optional<Schema.Struct<{
29
+ readonly cursor: Schema.Union<readonly [Schema.String, Schema.Number]>;
30
+ readonly lastSuccessAt: Schema.optional<Schema.String>;
31
+ }>>;
32
+ readonly lastError: Schema.optional<Schema.Struct<{
33
+ readonly at: Schema.String;
34
+ readonly source: Schema.Literals<readonly ["backfill", "changes"]>;
35
+ readonly operation: Schema.Literals<readonly ["fetch", "publish", "checkpoint"]>;
36
+ readonly code: Schema.Literals<readonly ["fetch_failed", "publish_failed", "checkpoint_failed"]>;
37
+ readonly message: Schema.String;
38
+ }>>;
39
+ }>;
40
+ type PersistedBackfillState = Schema.Schema.Type<typeof BackfillStateSchema>;
41
+ type PersistedChangesState = Schema.Schema.Type<typeof ChangesStateSchema>;
42
+ type StateSource = Schema.Schema.Type<typeof StateSourceSchema>;
43
+ type StateOperation = Schema.Schema.Type<typeof StateOperationSchema>;
44
+ type PersistedResourceState = Schema.Schema.Type<typeof ResourceStateSchema>;
45
+ //#endregion
46
+ //#region src/state-store/service.d.ts
47
+ /** Connector-facing durable state operations, independent of the storage backend. */
48
+ interface StateStoreService {
49
+ readonly getResourceState: (resource: string) => Effect.Effect<PersistedResourceState | undefined, ConnectorError>;
50
+ readonly setBackfillState: (resource: string, state: PersistedBackfillState) => Effect.Effect<void, ConnectorError>;
51
+ readonly setChangesState: (resource: string, state: PersistedChangesState) => Effect.Effect<void, ConnectorError>;
52
+ readonly setResourceError: (resource: string, source: StateSource, operation: StateOperation) => Effect.Effect<void, ConnectorError>;
53
+ readonly clearResourceError: (resource: string, source: StateSource) => Effect.Effect<void, ConnectorError>;
54
+ }
55
+ declare const StateStore_base: Context.ServiceClass<StateStore, "@useairfoil/connector-kit/StateStore", StateStoreService>;
56
+ /**
57
+ * Effect service used by ingestion and status logic for connector checkpoints.
58
+ * Production provides `layerSql`; sandboxes and tests may provide `layerMemory`.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const program = Effect.gen(function* () {
63
+ * const state = yield* StateStore;
64
+ * yield* state.setChangesState("orders", { cursor: "next-page" });
65
+ * });
66
+ * ```
67
+ */
68
+ declare class StateStore extends StateStore_base {}
69
+ //#endregion
70
+ //#region src/state-store/layer-memory.d.ts
71
+ /** Process-local state for tests and explicit local sandbox commands. */
72
+ declare const layerMemory: Layer.Layer<StateStore>;
73
+ //#endregion
74
+ //#region src/state-store/layer-sql.d.ts
75
+ /**
76
+ * Shared SQL state using the immutable connector instance ID supplied by
77
+ * platform-owned Effect configuration. The table defaults to
78
+ * `_airfoil_connectors_state` and can be overridden with `AIRFOIL_STATE_TABLE`.
79
+ * Effect's SQL KeyValueStore owns the table, while `KeyValueStore.prefix`
80
+ * provides application-level isolation between connector instances in that
81
+ * table. The resulting layer exposes only StateStore, never the unscoped
82
+ * KeyValueStore.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const StateStoreLive = layerSql().pipe(Layer.provide(PostgresLive));
87
+ * ```
88
+ */
89
+ declare const layerSql: () => Layer.Layer<StateStore, Config.ConfigError, SqlClient.SqlClient>;
90
+ declare namespace index_d_exports {
91
+ export { StateStore, StateStoreService, layerMemory, layerSql };
92
+ }
93
+ //#endregion
94
+ export { StateStoreService as a, StateStore as i, layerSql as n, layerMemory as r, index_d_exports as t };
95
+ //# sourceMappingURL=index-Coh_SkBs.d.ts.map