@vibesdotdev/integrations-kafka 1.0.0-rc.1 → 1.0.0-rc.4

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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The shared `workers-kafka/db` context: the one store implementation every
3
+ * producer and drainer of a store composes, instead of an app-local copy.
4
+ * It reads `workers.store` (the credential keys naming the store) through the
5
+ * Workers config owner and opens the store through Storage's libSQL facade,
6
+ * so the host composes a `storage/libsql-provider`. It never opens a local
7
+ * file by default: an undeclared or unreachable store refuses, typed.
8
+ */
9
+ import { type VibesRuntime } from '@vibesdotdev/kernel';
10
+ import { type WorkersKafkaDbContext } from '../schemas/worker-context.ts';
11
+ /** No `workers.store` is declared on this host. */
12
+ export declare const QUEUE_STORE_UNDECLARED_REASON = "queue-store-undeclared";
13
+ /** The declared store's URL credential is not set. */
14
+ export declare const QUEUE_STORE_UNAVAILABLE_REASON = "queue-store-unavailable";
15
+ /** The store is reachable but lacks the migrated `provider_jobs` schema. */
16
+ export declare const QUEUE_STORE_UNMIGRATED_REASON = "queue-store-unmigrated";
17
+ /**
18
+ * One store per created implementation (one per registered context), never
19
+ * per module. A failed open is not cached: the next resolution retries, so a
20
+ * credential or migration applied after a failure is picked up.
21
+ */
22
+ export declare function createSharedStoreContext(): {
23
+ provide(runtime: VibesRuntime): Promise<WorkersKafkaDbContext>;
24
+ };
25
+ //# sourceMappingURL=shared-store.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-store.context.d.ts","sourceRoot":"","sources":["../../src/workers/shared-store.context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAM1F,OAAO,EAA+B,KAAK,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAIvG,mDAAmD;AACnD,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AACtE,sDAAsD;AACtD,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AACxE,4EAA4E;AAC5E,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AA0CtE;;;;GAIG;AACH,wBAAgB,wBAAwB;qBAIf,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC;EAWrE"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The shared `workers-kafka/db` context: the one store implementation every
3
+ * producer and drainer of a store composes, instead of an app-local copy.
4
+ * It reads `workers.store` (the credential keys naming the store) through the
5
+ * Workers config owner and opens the store through Storage's libSQL facade,
6
+ * so the host composes a `storage/libsql-provider`. It never opens a local
7
+ * file by default: an undeclared or unreachable store refuses, typed.
8
+ */
9
+ import { CapabilityError } from '@vibesdotdev/kernel';
10
+ import { readWorkersConfig } from '@vibesdotdev/workers/config/read';
11
+ import { createLibsqlDrizzleConnection } from '@vibesdotdev/storage/adapters/drizzle/libsql';
12
+ import { and, asc, desc, eq, sql } from 'drizzle-orm';
13
+ import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
14
+ import { createProviderJobsSqliteSchema } from "./provider-jobs.sqlite-schema.js";
15
+ import { WorkersKafkaDbContextSchema } from "../schemas/worker-context.js";
16
+ const providerJobs = createProviderJobsSqliteSchema({ sqliteTable, text, integer, index });
17
+ /** No `workers.store` is declared on this host. */
18
+ export const QUEUE_STORE_UNDECLARED_REASON = 'queue-store-undeclared';
19
+ /** The declared store's URL credential is not set. */
20
+ export const QUEUE_STORE_UNAVAILABLE_REASON = 'queue-store-unavailable';
21
+ /** The store is reachable but lacks the migrated `provider_jobs` schema. */
22
+ export const QUEUE_STORE_UNMIGRATED_REASON = 'queue-store-unmigrated';
23
+ /** A credential the store declares: unset is `undefined`; every other failure propagates. */
24
+ async function optionalCredential(runtime, key) {
25
+ const result = await runtime.resolveCredential({ source: 'secret', key });
26
+ if (result.ok)
27
+ return result.value.trim() || undefined;
28
+ if (result.error.reason === 'credential-not-set')
29
+ return undefined;
30
+ throw result.error;
31
+ }
32
+ async function openStore(runtime) {
33
+ const { store } = await readWorkersConfig(runtime);
34
+ if (!store) {
35
+ throw new CapabilityError('This host declares no workers.store for the workers-kafka queue.', 'UNAVAILABLE', {
36
+ reason: QUEUE_STORE_UNDECLARED_REASON,
37
+ retryable: false
38
+ });
39
+ }
40
+ const url = await optionalCredential(runtime, store.url);
41
+ if (!url) {
42
+ // Value-free: names the credential key, never a value.
43
+ throw new CapabilityError(`The workers.store URL credential '${store.url}' is not set.`, 'UNAVAILABLE', {
44
+ reason: QUEUE_STORE_UNAVAILABLE_REASON,
45
+ retryable: false,
46
+ details: { key: store.url }
47
+ });
48
+ }
49
+ const authToken = store.authToken && !url.startsWith('file:') ? await optionalCredential(runtime, store.authToken) : undefined;
50
+ const { client, db } = await createLibsqlDrizzleConnection(authToken ? { url, authToken } : { url }, runtime);
51
+ try {
52
+ await db.select().from(providerJobs).limit(0);
53
+ }
54
+ catch (error) {
55
+ client.close();
56
+ throw new CapabilityError('The workers.store does not provide the migrated provider_jobs schema.', 'UNAVAILABLE', {
57
+ reason: QUEUE_STORE_UNMIGRATED_REASON,
58
+ retryable: false,
59
+ cause: error
60
+ });
61
+ }
62
+ return WorkersKafkaDbContextSchema.parse({ db, providerJobs, ops: { eq, and, asc, desc, sql }, dialect: 'sqlite' });
63
+ }
64
+ /**
65
+ * One store per created implementation (one per registered context), never
66
+ * per module. A failed open is not cached: the next resolution retries, so a
67
+ * credential or migration applied after a failure is picked up.
68
+ */
69
+ export function createSharedStoreContext() {
70
+ let opened;
71
+ let opening;
72
+ return {
73
+ async provide(runtime) {
74
+ if (opened)
75
+ return opened;
76
+ opening ??= openStore(runtime);
77
+ try {
78
+ opened = await opening;
79
+ return opened;
80
+ }
81
+ finally {
82
+ if (!opened)
83
+ opening = undefined;
84
+ }
85
+ }
86
+ };
87
+ }
88
+ //# sourceMappingURL=shared-store.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-store.context.js","sourceRoot":"","sources":["../../src/workers/shared-store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AuE,EAAE,aAAa,EAAE;YACjH,MAAM,EAAE,6BAA6B;YACrC,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,KAAK;SACZ,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,2BAA2B,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AACrH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACvC,IAAI,MAAyC,CAAC;IAC9C,IAAI,OAAmD,CAAC;IACxD,OAAO;QACN,KAAK,CAAC,OAAO,CAAC,OAAqB;YAClC,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC;YAC1B,OAAO,KAAK,SAAS,CAAC,OAAO,CAAC,CAAC;YAC/B,IAAI,CAAC;gBACJ,MAAM,GAAG,MAAM,OAAO,CAAC;gBACvB,OAAO,MAAM,CAAC;YACf,CAAC;oBAAS,CAAC;gBACV,IAAI,CAAC,MAAM;oBAAE,OAAO,GAAG,SAAS,CAAC;YAClC,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Composes the shared `workers-kafka/db` context over the declared
3
+ * `workers.store`. A host composes this beside `./workers/plugin` (and
4
+ * `./workers/consumer.plugin` where it drains) plus a `storage/libsql-provider`.
5
+ */
6
+ declare const defaultExport: import("@vibesdotdev/kernel").RuntimePlugin;
7
+ export default defaultExport;
8
+ //# sourceMappingURL=shared-store.plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-store.plugin.d.ts","sourceRoot":"","sources":["../../src/workers/shared-store.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,QAAA,MAAM,aAAa,6CAWjB,CAAC;AAEH,eAAe,aAAa,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Composes the shared `workers-kafka/db` context over the declared
3
+ * `workers.store`. A host composes this beside `./workers/plugin` (and
4
+ * `./workers/consumer.plugin` where it drains) plus a `storage/libsql-provider`.
5
+ */
6
+ import { createRuntimePlugin } from '@vibesdotdev/kernel';
7
+ import { WORKERS_KAFKA_DB_CONTEXT_ID } from "./adapter/workers-kafka.db.context.js";
8
+ // Hoisted const: tsc rewriteRelativeImportExtensions does not rewrite `.ts` specifiers inside `export default <expr>` (TS 6.0.3).
9
+ const defaultExport = createRuntimePlugin({
10
+ id: 'workers-kafka-shared-store',
11
+ name: 'Workers Kafka shared store',
12
+ description: 'The workers-kafka/db context over the store declared in workers.store',
13
+ dependencies: ['workers-kafka', 'storage'],
14
+ onRegister(runtime) {
15
+ runtime.registerLoader('context', WORKERS_KAFKA_DB_CONTEXT_ID, async () => {
16
+ const { createSharedStoreContext } = await import("./shared-store.context.js");
17
+ return { impl: createSharedStoreContext() };
18
+ });
19
+ }
20
+ });
21
+ export default defaultExport;
22
+ //# sourceMappingURL=shared-store.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-store.plugin.js","sourceRoot":"","sources":["../../src/workers/shared-store.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AAEpF,kIAAkI;AAClI,MAAM,aAAa,GAAG,mBAAmB,CAAC;IACzC,EAAE,EAAE,4BAA4B;IAChC,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE,uEAAuE;IACpF,YAAY,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC;IAC1C,UAAU,CAAC,OAAO;QACjB,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,2BAA2B,EAAE,KAAK,IAAI,EAAE;YACzE,MAAM,EAAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;YAC/E,OAAO,EAAE,IAAI,EAAE,wBAAwB,EAAE,EAAE,CAAC;QAC7C,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,18 +1,25 @@
1
1
  {
2
2
  "name": "@vibesdotdev/integrations-kafka",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.4",
4
4
  "dependencies": {
5
- "@vibesdotdev/config": "^1.0.0-rc.2",
6
- "@vibesdotdev/integrations": "^1.0.0-rc.2",
7
- "@vibesdotdev/kernel": "^1.0.0-rc.5",
8
- "@vibesdotdev/logging": "^1.0.0-rc.3",
5
+ "@vibesdotdev/config": "^1.0.0-rc.0",
6
+ "@vibesdotdev/integrations": "^1.0.0-rc.6",
7
+ "@vibesdotdev/kernel": "^1.0.0-rc.0",
8
+ "@vibesdotdev/logging": "^1.0.0-rc.0",
9
9
  "kafkajs": "^2.2.4",
10
10
  "zod": "^4.6.7",
11
- "@vibesdotdev/workers": "^1.0.0-rc.2"
11
+ "@vibesdotdev/workers": "^1.0.0-rc.0",
12
+ "@vibesdotdev/storage": "^1.0.0-rc.0"
12
13
  },
13
14
  "peerDependencies": {
14
15
  "drizzle-orm": "^0.45.4"
15
16
  },
17
+ "gitHead": "319e9e534fac11da0c374ab44efeed6c9722d3ec",
18
+ "_vibes_source": {
19
+ "repo": "ssh://git@git.vibes.dev/vibesdotdev/integrations.git",
20
+ "sha": "319e9e534fac11da0c374ab44efeed6c9722d3ec",
21
+ "workspaceDigest": "sha256:fe0b50ab7efbcdf2f0128a0fd552e0518b5ad282a6ca796da22e17db06538652"
22
+ },
16
23
  "main": "./dist/index.js",
17
24
  "exports": {
18
25
  ".": {
@@ -105,6 +112,12 @@
105
112
  "import": "./dist/workers/workers-kafka.plugin.js",
106
113
  "default": "./dist/workers/workers-kafka.plugin.js"
107
114
  },
115
+ "./workers/shared-store/plugin": {
116
+ "bun": "./dist/workers/shared-store.plugin.js",
117
+ "types": "./dist/workers/shared-store.plugin.d.ts",
118
+ "import": "./dist/workers/shared-store.plugin.js",
119
+ "default": "./dist/workers/shared-store.plugin.js"
120
+ },
108
121
  "./workers/provider-jobs-schema": {
109
122
  "bun": "./dist/workers/provider-jobs.sqlite-schema.js",
110
123
  "types": "./dist/workers/provider-jobs.sqlite-schema.d.ts",
@@ -130,7 +143,34 @@
130
143
  "LICENSE",
131
144
  "AUDIT-CODE.md",
132
145
  "AUDIT-SEAL.md",
133
- "SEALED.md"
146
+ "SEALED.md",
147
+ "!**/.turbo/**",
148
+ "!**/.svelte-kit/**",
149
+ "!**/.vibes/**",
150
+ "!**/__tests__/**",
151
+ "!**/__stubs__/**",
152
+ "!**/*.test.js",
153
+ "!**/*.test.mjs",
154
+ "!**/*.test.cjs",
155
+ "!**/*.test.jsx",
156
+ "!**/*.test.ts",
157
+ "!**/*.test.mts",
158
+ "!**/*.test.cts",
159
+ "!**/*.test.tsx",
160
+ "!**/*.spec.js",
161
+ "!**/*.spec.mjs",
162
+ "!**/*.spec.cjs",
163
+ "!**/*.spec.jsx",
164
+ "!**/*.spec.ts",
165
+ "!**/*.spec.mts",
166
+ "!**/*.spec.cts",
167
+ "!**/*.spec.tsx",
168
+ "!**/SPEC.md",
169
+ "!**/tsconfig.json",
170
+ "!**/tsconfig.*.json",
171
+ "!**/*.tsbuildinfo",
172
+ "!**/.build-ok.json",
173
+ "!**/*.tgz"
134
174
  ],
135
175
  "scripts": {
136
176
  "lint": "node ../../node_modules/@vibesdotdev/internal-oxlint-toolchain/ratchet.mjs .",
@@ -149,11 +189,11 @@
149
189
  },
150
190
  "vibes": {
151
191
  "visibility": "public",
152
- "handedRuntimeLogging": true,
153
192
  "registry": {
154
193
  "repositoryId": "70be51c9-5ab7-4d7e-9f47-801cb17720d8",
155
194
  "directory": "integrations/kafka"
156
- }
195
+ },
196
+ "handedRuntimeLogging": true
157
197
  },
158
198
  "type": "module",
159
199
  "types": "./dist/index.d.ts",
@@ -168,11 +208,5 @@
168
208
  "optional": true
169
209
  }
170
210
  },
171
- "license": "BUSL-1.1",
172
- "gitHead": "494ddfcab4c073eef61acb182042223d7e4da2e5",
173
- "_vibes_source": {
174
- "repo": "ssh://git@git.vibes.dev/vibesdotdev/integrations.git",
175
- "sha": "494ddfcab4c073eef61acb182042223d7e4da2e5",
176
- "workspaceDigest": "sha256:ac1e3929eb2a083aec7ccac953652563b0477c4dce85783b01ddf46e01bdfb08"
177
- }
211
+ "license": "BUSL-1.1"
178
212
  }