@gitgov/core 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * IdEncoder for transforming IDs to storage-safe filenames.
3
+ * Useful for characters not allowed in filesystem (e.g., `:` on Windows)
4
+ * or URL-unsafe characters in remote backends.
5
+ */
6
+ interface IdEncoder {
7
+ /** Transform ID to storage-safe string */
8
+ encode: (id: string) => string;
9
+ /** Recover original ID from encoded string */
10
+ decode: (encoded: string) => string;
11
+ }
12
+ /**
13
+ * Default encoder: `:` → `_` (for IDs like "human:camilo")
14
+ * Reversible because IDs cannot contain `_` (see id_generator.ts)
15
+ */
16
+ declare const DEFAULT_ID_ENCODER: IdEncoder;
17
+ /**
18
+ * RecordStore<V, R, O> - Generic interface for record persistence
19
+ *
20
+ * Abstracts CRUD operations without assuming storage backend.
21
+ * Each implementation decides how to persist (fs, memory, db, remote).
22
+ *
23
+ * @typeParam V - Value type (the record being stored)
24
+ * @typeParam R - Return type for write operations (default: void for local, GitHubWriteResult for GitHub)
25
+ * @typeParam O - Options type for write operations (default: void for local, GitHubWriteOpts for GitHub)
26
+ */
27
+ interface RecordStore<V, R = void, O = void> {
28
+ /**
29
+ * Gets a record by ID
30
+ * @returns The record or null if it doesn't exist
31
+ */
32
+ get(id: string): Promise<V | null>;
33
+ /**
34
+ * Persists a record
35
+ * @param id - Unique identifier
36
+ * @param value - The record to persist
37
+ */
38
+ put(id: string, value: V, ...opts: O extends void ? [] : [opts?: O]): Promise<R>;
39
+ /**
40
+ * Persists multiple records in a single operation.
41
+ * Local backends iterate sequentially; GitHub backend uses atomic commits.
42
+ */
43
+ putMany(entries: Array<{
44
+ id: string;
45
+ value: V;
46
+ }>, ...opts: O extends void ? [] : [opts?: O]): Promise<R>;
47
+ /**
48
+ * Deletes a record
49
+ * @param id - Identifier of the record to delete
50
+ */
51
+ delete(id: string, ...opts: O extends void ? [] : [opts?: O]): Promise<R>;
52
+ /**
53
+ * Lists all record IDs
54
+ * @returns Array of IDs
55
+ */
56
+ list(): Promise<string[]>;
57
+ /**
58
+ * Checks if a record exists
59
+ * @param id - Identifier to check
60
+ */
61
+ exists(id: string): Promise<boolean>;
62
+ }
63
+
64
+ export { DEFAULT_ID_ENCODER as D, type IdEncoder as I, type RecordStore as R };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitgov/core",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "SDK for the GitGovernance ecosystem, providing a type-safe, local-first API to manage identities, agents, and workflows.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -25,6 +25,10 @@
25
25
  "types": "./dist/src/github.d.ts",
26
26
  "import": "./dist/src/github.js"
27
27
  },
28
+ "./prisma": {
29
+ "types": "./dist/src/prisma.d.ts",
30
+ "import": "./dist/src/prisma.js"
31
+ },
28
32
  "./package.json": "./package.json"
29
33
  },
30
34
  "scripts": {