@usegraft/contracts 0.1.1 → 0.2.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.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @usegraft/contracts
2
+
3
+ > Shared error codes and introspection schemas. The vocabulary every other Graft package speaks.
4
+
5
+ Part of [Graft](https://github.com/AndersonDesign1/graft), a CMS built so an AI agent is the primary operator.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i @usegraft/contracts
11
+ ```
12
+
13
+ You rarely install this directly. It arrives as a dependency of the packages that throw.
14
+
15
+ ## Errors an agent can act on
16
+
17
+ ```ts
18
+ import { GraftError, ErrorCodes } from "@usegraft/contracts";
19
+
20
+ throw new GraftError({
21
+ code: "INPUT_VALIDATION_FAILED",
22
+ message: 'Slug "My Page" is not URL-safe.',
23
+ fix: 'Slugs are kebab-case: lowercase letters, digits and single hyphens, e.g. "my-page".',
24
+ details: { slug: "My Page" },
25
+ });
26
+ ```
27
+
28
+ `fix` is not decoration. Every error carries the next action, because the primary reader is an agent deciding what to do rather than a human reading a stack trace. That is why `message` says what happened and `fix` says what to do about it.
29
+
30
+ ## Introspection
31
+
32
+ `CollectionDescriptor`, `FieldDescriptor`, `FunctionDescriptor` and the registry descriptors are the shapes `describe_schema` and friends return over MCP. They are declared here so the CLI, the MCP server and the Studio cannot drift on what a collection looks like.
33
+
34
+ ---
35
+
36
+ MIT. [Repository](https://github.com/AndersonDesign1/graft) · [Changelog](https://github.com/AndersonDesign1/graft/blob/feat/core/packages/contracts/CHANGELOG.md)
package/dist/index.d.ts CHANGED
@@ -34,6 +34,7 @@ declare const ErrorCodes: {
34
34
  readonly DESTRUCTIVE_OP_REQUIRES_APPROVAL: "DESTRUCTIVE_OP_REQUIRES_APPROVAL";
35
35
  readonly APPROVAL_INVALID: "APPROVAL_INVALID";
36
36
  readonly APPROVAL_SELF_DECISION: "APPROVAL_SELF_DECISION";
37
+ readonly APPROVAL_UNATTRIBUTED: "APPROVAL_UNATTRIBUTED";
37
38
  readonly BRANCH_NOT_FOUND: "BRANCH_NOT_FOUND";
38
39
  readonly BRANCH_EXISTS: "BRANCH_EXISTS";
39
40
  readonly BRANCH_INVALID: "BRANCH_INVALID";
@@ -278,4 +279,17 @@ declare const RegistryItemDescriptor: z.ZodObject<{
278
279
  }, z.core.$strip>;
279
280
  type RegistryItemDescriptor = z.infer<typeof RegistryItemDescriptor>;
280
281
 
281
- export { CollectionDescriptor, ContentAuthority, EditorComponentList, EditorComponentSpec, type ErrorCode, ErrorCodes, FieldDescriptor, FunctionDescriptor, GraftError, type GraftErrorJSON, type GraftErrorOptions, RegistryFileDescriptor, RegistryFileRole, RegistryItemDescriptor, RegistryItemType, SchemaDescription };
282
+ /**
283
+ * Well-known paths shared across packages.
284
+ */
285
+ /**
286
+ * Where a static-tier project's compiled index lives, relative to the project
287
+ * root.
288
+ *
289
+ * Here rather than in @usegraft/db because the CLI resolves it while loading a
290
+ * config and deliberately lazy-loads the database package — a static import
291
+ * just to read one string would pull Postgres into every `graft` invocation.
292
+ */
293
+ declare const STATIC_INDEX_DEFAULT_PATH = ".graft/index.db";
294
+
295
+ export { CollectionDescriptor, ContentAuthority, EditorComponentList, EditorComponentSpec, type ErrorCode, ErrorCodes, FieldDescriptor, FunctionDescriptor, GraftError, type GraftErrorJSON, type GraftErrorOptions, RegistryFileDescriptor, RegistryFileRole, RegistryItemDescriptor, RegistryItemType, STATIC_INDEX_DEFAULT_PATH, SchemaDescription };
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ var ErrorCodes = {
26
26
  DESTRUCTIVE_OP_REQUIRES_APPROVAL: "DESTRUCTIVE_OP_REQUIRES_APPROVAL",
27
27
  APPROVAL_INVALID: "APPROVAL_INVALID",
28
28
  APPROVAL_SELF_DECISION: "APPROVAL_SELF_DECISION",
29
+ APPROVAL_UNATTRIBUTED: "APPROVAL_UNATTRIBUTED",
29
30
  BRANCH_NOT_FOUND: "BRANCH_NOT_FOUND",
30
31
  BRANCH_EXISTS: "BRANCH_EXISTS",
31
32
  BRANCH_INVALID: "BRANCH_INVALID",
@@ -172,6 +173,9 @@ var RegistryItemDescriptor = z.object({
172
173
  /** Whether the item ships an llms.txt teaching fragment. */
173
174
  llms: z.boolean()
174
175
  });
176
+
177
+ // src/paths.ts
178
+ var STATIC_INDEX_DEFAULT_PATH = ".graft/index.db";
175
179
  export {
176
180
  CollectionDescriptor,
177
181
  ContentAuthority,
@@ -185,5 +189,6 @@ export {
185
189
  RegistryFileRole,
186
190
  RegistryItemDescriptor,
187
191
  RegistryItemType,
192
+ STATIC_INDEX_DEFAULT_PATH,
188
193
  SchemaDescription
189
194
  };
package/package.json CHANGED
@@ -1,6 +1,20 @@
1
1
  {
2
2
  "name": "@usegraft/contracts",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
+ "description": "Shared error codes and introspection schemas: the vocabulary every Graft package speaks.",
5
+ "keywords": [
6
+ "agent",
7
+ "ai",
8
+ "cms",
9
+ "errors",
10
+ "graft",
11
+ "headless-cms",
12
+ "introspection",
13
+ "mcp",
14
+ "schemas",
15
+ "typescript"
16
+ ],
17
+ "homepage": "https://github.com/AndersonDesign1/graft#readme",
4
18
  "license": "MIT",
5
19
  "repository": {
6
20
  "type": "git",
@@ -33,7 +47,6 @@
33
47
  "build": "tsup src/index.ts --format esm --dts --clean",
34
48
  "dev": "tsup src/index.ts --format esm --watch",
35
49
  "typecheck": "tsc --noEmit",
36
- "test": "vitest run",
37
- "lint": "oxlint ."
50
+ "test": "vitest run"
38
51
  }
39
52
  }