@vercel/factory 0.0.3 → 0.0.5

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 (73) hide show
  1. package/dist/approval-h5aj8HYN.d.mts +510 -0
  2. package/dist/blob/index.d.mts +32 -0
  3. package/dist/blob/index.mjs +141 -0
  4. package/dist/blob/index.mjs.map +1 -0
  5. package/dist/connectors/index.d.mts +2 -0
  6. package/dist/connectors/index.mjs +49 -0
  7. package/dist/connectors/index.mjs.map +1 -0
  8. package/dist/connectors/slack.d.mts +43 -0
  9. package/dist/connectors/slack.mjs +50 -0
  10. package/dist/connectors/slack.mjs.map +1 -0
  11. package/dist/driver-Bbd25rNM.mjs +23 -0
  12. package/dist/driver-Bbd25rNM.mjs.map +1 -0
  13. package/dist/driver-CrZsy7sm.d.mts +34 -0
  14. package/dist/eve/index.d.mts +1101 -0
  15. package/dist/eve/index.mjs +853 -0
  16. package/dist/eve/index.mjs.map +1 -0
  17. package/dist/github-3sbHe-fo.d.mts +149 -0
  18. package/dist/github.d.mts +2 -0
  19. package/dist/github.mjs +332 -0
  20. package/dist/github.mjs.map +1 -0
  21. package/dist/id-DwCihQr4.mjs +31 -0
  22. package/dist/id-DwCihQr4.mjs.map +1 -0
  23. package/dist/index-WNGZJRRH.d.mts +67 -0
  24. package/dist/index.d.mts +187 -0
  25. package/dist/index.mjs +907 -0
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/next-page.d.mts +5 -0
  28. package/dist/next-page.mjs +71 -0
  29. package/dist/next-page.mjs.map +1 -0
  30. package/dist/next.d.mts +12 -0
  31. package/dist/{next.js → next.mjs} +13 -14
  32. package/dist/next.mjs.map +1 -0
  33. package/dist/postgres/index.d.mts +137 -0
  34. package/dist/postgres/index.mjs +96 -0
  35. package/dist/postgres/index.mjs.map +1 -0
  36. package/dist/signal-CHVEmzvI.d.mts +59 -0
  37. package/dist/task-Cj7Ei9Nh.mjs +336 -0
  38. package/dist/task-Cj7Ei9Nh.mjs.map +1 -0
  39. package/package.json +29 -22
  40. package/dist/approval-Z7iaWibT.d.ts +0 -541
  41. package/dist/blob/index.d.ts +0 -26
  42. package/dist/blob/index.js +0 -127
  43. package/dist/blob/index.js.map +0 -1
  44. package/dist/chunk-2JFES6BA.js +0 -41
  45. package/dist/chunk-2JFES6BA.js.map +0 -1
  46. package/dist/chunk-CEF6VJZC.js +0 -28
  47. package/dist/chunk-CEF6VJZC.js.map +0 -1
  48. package/dist/chunk-D2XMABG4.js +0 -311
  49. package/dist/chunk-D2XMABG4.js.map +0 -1
  50. package/dist/chunk-EFL4PDDE.js +0 -325
  51. package/dist/chunk-EFL4PDDE.js.map +0 -1
  52. package/dist/common-CaHaEOAS.d.ts +0 -18
  53. package/dist/connectors/index.d.ts +0 -53
  54. package/dist/connectors/index.js +0 -64
  55. package/dist/connectors/index.js.map +0 -1
  56. package/dist/driver-tRNggCCJ.d.ts +0 -32
  57. package/dist/eve/index.d.ts +0 -1053
  58. package/dist/eve/index.js +0 -752
  59. package/dist/eve/index.js.map +0 -1
  60. package/dist/github.d.ts +0 -139
  61. package/dist/github.js +0 -27
  62. package/dist/github.js.map +0 -1
  63. package/dist/index.d.ts +0 -164
  64. package/dist/index.js +0 -940
  65. package/dist/index.js.map +0 -1
  66. package/dist/next-page.d.ts +0 -5
  67. package/dist/next-page.js +0 -75
  68. package/dist/next-page.js.map +0 -1
  69. package/dist/next.d.ts +0 -12
  70. package/dist/next.js.map +0 -1
  71. package/dist/postgres/index.d.ts +0 -137
  72. package/dist/postgres/index.js +0 -118
  73. package/dist/postgres/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/blob/index.ts"],"sourcesContent":["import { get, list, put } from \"@vercel/blob\";\nimport {\n RecordExistsError,\n RecordNotFoundError,\n VersionConflictError,\n type CollectionName,\n type StoredEntry,\n type StoreDriver,\n} from \"../store/driver\";\n\nexport interface BlobObject {\n body: string;\n etag: string;\n}\n\n/** The narrow blob operations the driver needs; injectable for tests. */\nexport interface BlobClient {\n /** Must return the latest content, never a cached copy. */\n read(pathname: string): Promise<BlobObject | null>;\n /** Must reject if overwrite is false and the path exists, or if ifMatch is given and the ETag differs. */\n write(pathname: string, body: string, overwrite: boolean, ifMatch?: string): Promise<void>;\n listPaths(prefix: string): Promise<string[]>;\n}\n\n// @vercel/blob throws BlobNotFoundError with the message\n// \"Vercel Blob: The requested blob does not exist\".\nfunction isNotFoundError(error: unknown): boolean {\n return (\n error instanceof Error &&\n (error.name === \"BlobNotFoundError\" ||\n /does not exist|not.?found|404/iu.test(error.message))\n );\n}\n\nfunction isAlreadyExistsError(error: unknown): boolean {\n return (\n error instanceof Error &&\n /already exists|not allowed to overwrite|overwrite/iu.test(error.message)\n );\n}\n\n// @vercel/blob throws BlobPreconditionFailedError when ifMatch does not hold.\nfunction isPreconditionError(error: unknown): boolean {\n return (\n error instanceof Error &&\n (error.name === \"BlobPreconditionFailedError\" || /precondition|etag|412/iu.test(error.message))\n );\n}\n\nexport const vercelBlobClient: BlobClient = {\n async read(pathname) {\n let result;\n try {\n // Uncached: the ledger is read-modify-write and must see the latest version.\n result = await get(pathname, { access: \"private\", useCache: false });\n } catch (error) {\n if (isNotFoundError(error)) {\n return null;\n }\n throw error;\n }\n if (result === null || result.stream === null) {\n return null;\n }\n return { body: await new Response(result.stream).text(), etag: result.blob.etag };\n },\n\n async write(pathname, body, overwrite, ifMatch) {\n await put(pathname, body, {\n access: \"private\",\n allowOverwrite: overwrite,\n contentType: \"application/json\",\n ...(ifMatch === undefined ? {} : { ifMatch }),\n });\n },\n\n async listPaths(prefix) {\n const paths: string[] = [];\n let cursor: string | undefined;\n do {\n const page = await list({ prefix, cursor, limit: 1000 });\n paths.push(...page.blobs.map((blob) => blob.pathname));\n cursor = page.hasMore ? page.cursor : undefined;\n } while (cursor !== undefined);\n return paths;\n },\n};\n\nexport interface BlobDriverOptions {\n client?: BlobClient;\n /** Path prefix inside the blob store; defaults to \"factory\". */\n prefix?: string;\n}\n\n/**\n * Store driver on Vercel Blob: durable and dependency-free (one Blob store on\n * the project, no database). Inserts and receipts are exactly as safe as on\n * Postgres (create-if-absent is atomic). Updates read the latest content,\n * bypassing Blob's CDN cache, and write with an ETag precondition, so a\n * writer that lost a race gets a VersionConflictError rather than\n * overwriting the winner.\n */\nexport function createBlobDriver(options: BlobDriverOptions = {}): StoreDriver {\n const client = options.client ?? vercelBlobClient;\n const prefix = options.prefix ?? \"factory\";\n\n function pathFor(collection: CollectionName, id: string): string {\n return `${prefix}/${collection}/${id}.json`;\n }\n\n async function readRecord(\n collection: CollectionName,\n id: string,\n ): Promise<{ value: unknown; version: number; etag: string } | null> {\n let object: BlobObject | null;\n try {\n object = await client.read(pathFor(collection, id));\n } catch (error) {\n if (isNotFoundError(error)) {\n return null;\n }\n throw error;\n }\n if (object === null) {\n return null;\n }\n const parsed = JSON.parse(object.body) as { value: unknown; version: number };\n if (typeof parsed.version !== \"number\") {\n throw new Error(`malformed stored record at ${pathFor(collection, id)}`);\n }\n return { value: parsed.value, version: parsed.version, etag: object.etag };\n }\n\n return {\n name: \"blob\",\n\n async get(collection, id) {\n const record = await readRecord(collection, id);\n return record === null ? null : { value: record.value, version: record.version };\n },\n\n async insert(collection, id, value) {\n try {\n await client.write(\n pathFor(collection, id),\n JSON.stringify({ value, version: 1 }),\n false,\n );\n } catch (error) {\n if (isAlreadyExistsError(error)) {\n throw new RecordExistsError(collection, id);\n }\n throw error;\n }\n },\n\n async update(collection, id, value, expectedVersion) {\n const existing = await readRecord(collection, id);\n if (existing === null) {\n throw new RecordNotFoundError(collection, id);\n }\n if (existing.version !== expectedVersion) {\n throw new VersionConflictError(collection, id, expectedVersion);\n }\n try {\n await client.write(\n pathFor(collection, id),\n JSON.stringify({ value, version: expectedVersion + 1 }),\n true,\n // The write API's ifMatch rejects the weak form (W/\"…\") that reads return.\n existing.etag.replace(/^W\\//u, \"\"),\n );\n } catch (error) {\n if (isPreconditionError(error)) {\n throw new VersionConflictError(collection, id, expectedVersion);\n }\n throw error;\n }\n },\n\n async list(collection) {\n const dir = `${prefix}/${collection}/`;\n const paths = await client.listPaths(dir);\n const entries: StoredEntry[] = [];\n for (const pathname of paths) {\n const id = pathname.slice(dir.length).replace(/\\.json$/u, \"\");\n const record = await readRecord(collection, id);\n if (record !== null) {\n entries.push({ id, record: { value: record.value, version: record.version } });\n }\n }\n return entries;\n },\n };\n}\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import { a as NormalizedSignal, c as communicationEventSchema, d as createCommunicationRouter, i as CommunicationRouter, l as communicationOutcomeSchema, n as CommunicationEvent, o as SignalNormalizer, r as CommunicationOutcome, s as WebhookEvent, t as CommunicationAdapter, u as communicationOutcomes } from "../index-WNGZJRRH.mjs";
2
+ export { CommunicationAdapter, CommunicationEvent, CommunicationOutcome, CommunicationRouter, NormalizedSignal, SignalNormalizer, WebhookEvent, communicationEventSchema, communicationOutcomeSchema, communicationOutcomes, createCommunicationRouter };
@@ -0,0 +1,49 @@
1
+ import { i as repositoryIdSchema, s as taskIdSchema, t as changeIdSchema, u as replyToSchema } from "../id-DwCihQr4.mjs";
2
+ import { z } from "zod";
3
+ //#region src/connectors/index.ts
4
+ const communicationOutcomes = [
5
+ "accepted",
6
+ "started",
7
+ "succeeded",
8
+ "failed",
9
+ "needs_human",
10
+ "question",
11
+ "digest",
12
+ "rolled_back",
13
+ "budget_warning",
14
+ "budget_exhausted",
15
+ "message"
16
+ ];
17
+ const communicationOutcomeSchema = z.enum(communicationOutcomes).describe("Lifecycle outcome a connector should render and deliver.");
18
+ const communicationEventSchema = z.strictObject({
19
+ eventId: z.string().min(1).describe("Stable idempotency key for this delivery."),
20
+ repositoryId: repositoryIdSchema,
21
+ taskId: taskIdSchema.optional(),
22
+ changeId: changeIdSchema.optional(),
23
+ replyTo: replyToSchema,
24
+ outcome: communicationOutcomeSchema,
25
+ data: z.record(z.string(), z.unknown()).describe("Outcome-specific data rendered by the selected connector.")
26
+ });
27
+ function createCommunicationRouter(adapters) {
28
+ const byChannel = /* @__PURE__ */ new Map();
29
+ for (const adapter of adapters) {
30
+ const channel = adapter.channel.trim();
31
+ if (channel.length === 0) throw new Error("Communication adapter channel is required.");
32
+ if (byChannel.has(channel)) throw new Error(`Communication adapter ${channel} is registered more than once.`);
33
+ byChannel.set(channel, adapter);
34
+ }
35
+ const channels = Object.freeze([...byChannel.keys()]);
36
+ return Object.freeze({
37
+ channels,
38
+ async deliver(input) {
39
+ const event = communicationEventSchema.parse(input);
40
+ const adapter = byChannel.get(event.replyTo.channel);
41
+ if (adapter === void 0) throw new Error(`No communication adapter is registered for ${event.replyTo.channel}.`);
42
+ await adapter.deliver(event);
43
+ }
44
+ });
45
+ }
46
+ //#endregion
47
+ export { communicationEventSchema, communicationOutcomeSchema, communicationOutcomes, createCommunicationRouter };
48
+
49
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/connectors/index.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { changeIdSchema, repositoryIdSchema, taskIdSchema } from \"../schema/id\";\nimport { replyToSchema } from \"../schema/common\";\nimport type { ReplyTo } from \"../schema/common\";\nimport type { SignalSource } from \"../schema/signal\";\n\nexport interface WebhookEvent {\n deliveryId: string;\n event: string;\n payload: unknown;\n}\n\nexport interface NormalizedSignal<TSource extends SignalSource = SignalSource> {\n source: TSource;\n deliveryId: string;\n replyTo: ReplyTo;\n payload: unknown;\n}\n\nexport type SignalNormalizer<TSignal extends NormalizedSignal = NormalizedSignal> = (\n event: WebhookEvent,\n) => TSignal | null;\n\nexport const communicationOutcomes = [\n \"accepted\",\n \"started\",\n \"succeeded\",\n \"failed\",\n \"needs_human\",\n \"question\",\n \"digest\",\n \"rolled_back\",\n \"budget_warning\",\n \"budget_exhausted\",\n \"message\",\n] as const;\n\nexport const communicationOutcomeSchema = z\n .enum(communicationOutcomes)\n .describe(\"Lifecycle outcome a connector should render and deliver.\");\n\nexport const communicationEventSchema = z.strictObject({\n eventId: z.string().min(1).describe(\"Stable idempotency key for this delivery.\"),\n repositoryId: repositoryIdSchema,\n taskId: taskIdSchema.optional(),\n changeId: changeIdSchema.optional(),\n replyTo: replyToSchema,\n outcome: communicationOutcomeSchema,\n data: z\n .record(z.string(), z.unknown())\n .describe(\"Outcome-specific data rendered by the selected connector.\"),\n});\n\nexport type CommunicationOutcome = z.infer<typeof communicationOutcomeSchema>;\nexport type CommunicationEvent = z.infer<typeof communicationEventSchema>;\n\nexport interface CommunicationAdapter {\n readonly channel: string;\n deliver(event: CommunicationEvent): Promise<void>;\n}\n\nexport interface CommunicationRouter {\n readonly channels: readonly string[];\n deliver(event: CommunicationEvent): Promise<void>;\n}\n\nexport function createCommunicationRouter(\n adapters: readonly CommunicationAdapter[],\n): CommunicationRouter {\n const byChannel = new Map<string, CommunicationAdapter>();\n for (const adapter of adapters) {\n const channel = adapter.channel.trim();\n if (channel.length === 0) {\n throw new Error(\"Communication adapter channel is required.\");\n }\n if (byChannel.has(channel)) {\n throw new Error(`Communication adapter ${channel} is registered more than once.`);\n }\n byChannel.set(channel, adapter);\n }\n const channels = Object.freeze([...byChannel.keys()]);\n\n return Object.freeze({\n channels,\n async deliver(input: CommunicationEvent): Promise<void> {\n const event = communicationEventSchema.parse(input);\n const adapter = byChannel.get(event.replyTo.channel);\n if (adapter === undefined) {\n throw new Error(`No communication adapter is registered for ${event.replyTo.channel}.`);\n }\n await adapter.deliver(event);\n },\n });\n}\n"],"mappings":";;;AAuBA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,6BAA6B,EACvC,KAAK,qBAAqB,CAAC,CAC3B,SAAS,0DAA0D;AAEtE,MAAa,2BAA2B,EAAE,aAAa;CACrD,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,2CAA2C;CAC/E,cAAc;CACd,QAAQ,aAAa,SAAS;CAC9B,UAAU,eAAe,SAAS;CAClC,SAAS;CACT,SAAS;CACT,MAAM,EACH,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC/B,SAAS,2DAA2D;AACzE,CAAC;AAeD,SAAgB,0BACd,UACqB;CACrB,MAAM,4BAAY,IAAI,IAAkC;CACxD,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,UAAU,QAAQ,QAAQ,KAAK;EACrC,IAAI,QAAQ,WAAW,GACrB,MAAM,IAAI,MAAM,4CAA4C;EAE9D,IAAI,UAAU,IAAI,OAAO,GACvB,MAAM,IAAI,MAAM,yBAAyB,QAAQ,+BAA+B;EAElF,UAAU,IAAI,SAAS,OAAO;CAChC;CACA,MAAM,WAAW,OAAO,OAAO,CAAC,GAAG,UAAU,KAAK,CAAC,CAAC;CAEpD,OAAO,OAAO,OAAO;EACnB;EACA,MAAM,QAAQ,OAA0C;GACtD,MAAM,QAAQ,yBAAyB,MAAM,KAAK;GAClD,MAAM,UAAU,UAAU,IAAI,MAAM,QAAQ,OAAO;GACnD,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,8CAA8C,MAAM,QAAQ,QAAQ,EAAE;GAExF,MAAM,QAAQ,QAAQ,KAAK;EAC7B;CACF,CAAC;AACH"}
@@ -0,0 +1,43 @@
1
+ import { a as NormalizedSignal } from "../index-WNGZJRRH.mjs";
2
+ //#region src/connectors/slack.d.ts
3
+ interface SlackMessageEvent {
4
+ teamId: string;
5
+ channelId: string;
6
+ messageTs: string;
7
+ threadTs: string;
8
+ actorId: string;
9
+ text: string;
10
+ replyAddress: string;
11
+ repositorySlug: string;
12
+ payload: unknown;
13
+ }
14
+ interface SlackMessageSignal extends NormalizedSignal<"slack"> {
15
+ repositorySlug: string;
16
+ message: {
17
+ teamId: string;
18
+ channelId: string;
19
+ messageTs: string;
20
+ threadTs: string;
21
+ actorId: string;
22
+ text: string;
23
+ };
24
+ }
25
+ /** Normalize an Eve-verified Slack message after the caller resolves its repository. */
26
+ declare function normalizeSlackMessage(event: SlackMessageEvent): SlackMessageSignal;
27
+ type SlackRepositorySelection = {
28
+ status: "selected";
29
+ repositorySlug: string;
30
+ } | {
31
+ status: "required";
32
+ } | {
33
+ status: "ambiguous";
34
+ repositorySlugs: readonly string[];
35
+ };
36
+ /**
37
+ * Select the only configured repository, or require an explicit owner/name
38
+ * when a Slack surface fronts more than one repository.
39
+ */
40
+ declare function selectSlackRepository(text: string, repositories: readonly string[]): SlackRepositorySelection;
41
+ //#endregion
42
+ export { SlackMessageEvent, SlackMessageSignal, SlackRepositorySelection, normalizeSlackMessage, selectSlackRepository };
43
+ //# sourceMappingURL=slack.d.mts.map
@@ -0,0 +1,50 @@
1
+ //#region src/connectors/slack.ts
2
+ /** Normalize an Eve-verified Slack message after the caller resolves its repository. */
3
+ function normalizeSlackMessage(event) {
4
+ return {
5
+ source: "slack",
6
+ deliveryId: `${event.teamId}:${event.channelId}:${event.messageTs}`,
7
+ repositorySlug: event.repositorySlug.toLowerCase(),
8
+ replyTo: {
9
+ channel: "slack",
10
+ address: event.replyAddress
11
+ },
12
+ message: {
13
+ teamId: event.teamId,
14
+ channelId: event.channelId,
15
+ messageTs: event.messageTs,
16
+ threadTs: event.threadTs,
17
+ actorId: event.actorId,
18
+ text: event.text
19
+ },
20
+ payload: event.payload
21
+ };
22
+ }
23
+ /**
24
+ * Select the only configured repository, or require an explicit owner/name
25
+ * when a Slack surface fronts more than one repository.
26
+ */
27
+ function selectSlackRepository(text, repositories) {
28
+ const normalized = [...new Set(repositories.map((slug) => slug.toLowerCase()))];
29
+ if (normalized.length === 1) return {
30
+ status: "selected",
31
+ repositorySlug: normalized[0]
32
+ };
33
+ const matches = normalized.filter((slug) => {
34
+ const escaped = slug.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
35
+ return new RegExp(`(^|[^a-z0-9._/-])${escaped}($|[^a-z0-9._/-])`, "i").test(text);
36
+ });
37
+ if (matches.length === 1) return {
38
+ status: "selected",
39
+ repositorySlug: matches[0]
40
+ };
41
+ if (matches.length > 1) return {
42
+ status: "ambiguous",
43
+ repositorySlugs: matches
44
+ };
45
+ return { status: "required" };
46
+ }
47
+ //#endregion
48
+ export { normalizeSlackMessage, selectSlackRepository };
49
+
50
+ //# sourceMappingURL=slack.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slack.mjs","names":[],"sources":["../../src/connectors/slack.ts"],"sourcesContent":["import type { NormalizedSignal } from \"./index\";\n\nexport interface SlackMessageEvent {\n teamId: string;\n channelId: string;\n messageTs: string;\n threadTs: string;\n actorId: string;\n text: string;\n replyAddress: string;\n repositorySlug: string;\n payload: unknown;\n}\n\nexport interface SlackMessageSignal extends NormalizedSignal<\"slack\"> {\n repositorySlug: string;\n message: {\n teamId: string;\n channelId: string;\n messageTs: string;\n threadTs: string;\n actorId: string;\n text: string;\n };\n}\n\n/** Normalize an Eve-verified Slack message after the caller resolves its repository. */\nexport function normalizeSlackMessage(event: SlackMessageEvent): SlackMessageSignal {\n return {\n source: \"slack\",\n deliveryId: `${event.teamId}:${event.channelId}:${event.messageTs}`,\n repositorySlug: event.repositorySlug.toLowerCase(),\n replyTo: { channel: \"slack\", address: event.replyAddress },\n message: {\n teamId: event.teamId,\n channelId: event.channelId,\n messageTs: event.messageTs,\n threadTs: event.threadTs,\n actorId: event.actorId,\n text: event.text,\n },\n payload: event.payload,\n };\n}\n\nexport type SlackRepositorySelection =\n | { status: \"selected\"; repositorySlug: string }\n | { status: \"required\" }\n | { status: \"ambiguous\"; repositorySlugs: readonly string[] };\n\n/**\n * Select the only configured repository, or require an explicit owner/name\n * when a Slack surface fronts more than one repository.\n */\nexport function selectSlackRepository(\n text: string,\n repositories: readonly string[],\n): SlackRepositorySelection {\n const normalized = [...new Set(repositories.map((slug) => slug.toLowerCase()))];\n if (normalized.length === 1) {\n return { status: \"selected\", repositorySlug: normalized[0]! };\n }\n\n const matches = normalized.filter((slug) => {\n const escaped = slug.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`(^|[^a-z0-9._/-])${escaped}($|[^a-z0-9._/-])`, \"i\").test(text);\n });\n if (matches.length === 1) {\n return { status: \"selected\", repositorySlug: matches[0]! };\n }\n if (matches.length > 1) {\n return { status: \"ambiguous\", repositorySlugs: matches };\n }\n return { status: \"required\" };\n}\n"],"mappings":";;AA2BA,SAAgB,sBAAsB,OAA8C;CAClF,OAAO;EACL,QAAQ;EACR,YAAY,GAAG,MAAM,OAAO,GAAG,MAAM,UAAU,GAAG,MAAM;EACxD,gBAAgB,MAAM,eAAe,YAAY;EACjD,SAAS;GAAE,SAAS;GAAS,SAAS,MAAM;EAAa;EACzD,SAAS;GACP,QAAQ,MAAM;GACd,WAAW,MAAM;GACjB,WAAW,MAAM;GACjB,UAAU,MAAM;GAChB,SAAS,MAAM;GACf,MAAM,MAAM;EACd;EACA,SAAS,MAAM;CACjB;AACF;;;;;AAWA,SAAgB,sBACd,MACA,cAC0B;CAC1B,MAAM,aAAa,CAAC,GAAG,IAAI,IAAI,aAAa,KAAK,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC;CAC9E,IAAI,WAAW,WAAW,GACxB,OAAO;EAAE,QAAQ;EAAY,gBAAgB,WAAW;CAAI;CAG9D,MAAM,UAAU,WAAW,QAAQ,SAAS;EAC1C,MAAM,UAAU,KAAK,QAAQ,uBAAuB,MAAM;EAC1D,OAAO,IAAI,OAAO,oBAAoB,QAAQ,oBAAoB,GAAG,CAAC,CAAC,KAAK,IAAI;CAClF,CAAC;CACD,IAAI,QAAQ,WAAW,GACrB,OAAO;EAAE,QAAQ;EAAY,gBAAgB,QAAQ;CAAI;CAE3D,IAAI,QAAQ,SAAS,GACnB,OAAO;EAAE,QAAQ;EAAa,iBAAiB;CAAQ;CAEzD,OAAO,EAAE,QAAQ,WAAW;AAC9B"}
@@ -0,0 +1,23 @@
1
+ //#region src/store/driver.ts
2
+ var RecordExistsError = class extends Error {
3
+ constructor(collection, id) {
4
+ super(`record "${id}" already exists in "${collection}"`);
5
+ this.name = "RecordExistsError";
6
+ }
7
+ };
8
+ var RecordNotFoundError = class extends Error {
9
+ constructor(collection, id) {
10
+ super(`record "${id}" not found in "${collection}"`);
11
+ this.name = "RecordNotFoundError";
12
+ }
13
+ };
14
+ var VersionConflictError = class extends Error {
15
+ constructor(collection, id, expectedVersion) {
16
+ super(`record "${id}" in "${collection}" changed since version ${expectedVersion} was read`);
17
+ this.name = "VersionConflictError";
18
+ }
19
+ };
20
+ //#endregion
21
+ export { RecordNotFoundError as n, VersionConflictError as r, RecordExistsError as t };
22
+
23
+ //# sourceMappingURL=driver-Bbd25rNM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver-Bbd25rNM.mjs","names":[],"sources":["../src/store/driver.ts"],"sourcesContent":["export type CollectionName = \"repositories\" | \"signals\" | \"tasks\" | \"changes\" | \"receipts\";\n\nexport interface StoredRecord {\n readonly value: unknown;\n readonly version: number;\n}\n\nexport interface StoredEntry {\n readonly id: string;\n readonly record: StoredRecord;\n}\n\nexport class RecordExistsError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" already exists in \"${collection}\"`);\n this.name = \"RecordExistsError\";\n }\n}\n\nexport class RecordNotFoundError extends Error {\n constructor(collection: CollectionName, id: string) {\n super(`record \"${id}\" not found in \"${collection}\"`);\n this.name = \"RecordNotFoundError\";\n }\n}\n\nexport class VersionConflictError extends Error {\n constructor(collection: CollectionName, id: string, expectedVersion: number) {\n super(\n `record \"${id}\" in \"${collection}\" changed since version ${expectedVersion} was read`,\n );\n this.name = \"VersionConflictError\";\n }\n}\n\n/**\n * Raw persistence contract. Drivers store opaque values and enforce nothing\n * about their content; every invariant lives in the engine above. `update`\n * must be an atomic compare-and-swap on `expectedVersion`.\n */\nexport interface StoreDriver {\n readonly name: string;\n get(collection: CollectionName, id: string): Promise<StoredRecord | null>;\n insert(collection: CollectionName, id: string, value: unknown): Promise<void>;\n update(\n collection: CollectionName,\n id: string,\n value: unknown,\n expectedVersion: number,\n ): Promise<void>;\n list(collection: CollectionName): Promise<readonly StoredEntry[]>;\n}\n"],"mappings":";AAYA,IAAa,oBAAb,cAAuC,MAAM;CAC3C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,uBAAuB,WAAW,EAAE;EACxD,KAAK,OAAO;CACd;AACF;AAEA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,YAA4B,IAAY;EAClD,MAAM,WAAW,GAAG,kBAAkB,WAAW,EAAE;EACnD,KAAK,OAAO;CACd;AACF;AAEA,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAY,YAA4B,IAAY,iBAAyB;EAC3E,MACE,WAAW,GAAG,QAAQ,WAAW,0BAA0B,gBAAgB,UAC7E;EACA,KAAK,OAAO;CACd;AACF"}
@@ -0,0 +1,34 @@
1
+ //#region src/store/driver.d.ts
2
+ type CollectionName = "repositories" | "signals" | "tasks" | "changes" | "receipts";
3
+ interface StoredRecord {
4
+ readonly value: unknown;
5
+ readonly version: number;
6
+ }
7
+ interface StoredEntry {
8
+ readonly id: string;
9
+ readonly record: StoredRecord;
10
+ }
11
+ declare class RecordExistsError extends Error {
12
+ constructor(collection: CollectionName, id: string);
13
+ }
14
+ declare class RecordNotFoundError extends Error {
15
+ constructor(collection: CollectionName, id: string);
16
+ }
17
+ declare class VersionConflictError extends Error {
18
+ constructor(collection: CollectionName, id: string, expectedVersion: number);
19
+ }
20
+ /**
21
+ * Raw persistence contract. Drivers store opaque values and enforce nothing
22
+ * about their content; every invariant lives in the engine above. `update`
23
+ * must be an atomic compare-and-swap on `expectedVersion`.
24
+ */
25
+ interface StoreDriver {
26
+ readonly name: string;
27
+ get(collection: CollectionName, id: string): Promise<StoredRecord | null>;
28
+ insert(collection: CollectionName, id: string, value: unknown): Promise<void>;
29
+ update(collection: CollectionName, id: string, value: unknown, expectedVersion: number): Promise<void>;
30
+ list(collection: CollectionName): Promise<readonly StoredEntry[]>;
31
+ }
32
+ //#endregion
33
+ export { StoredEntry as a, StoreDriver as i, RecordExistsError as n, StoredRecord as o, RecordNotFoundError as r, VersionConflictError as s, CollectionName as t };
34
+ //# sourceMappingURL=driver-CrZsy7sm.d.mts.map