@usegraft/sdk-react-router 0.2.0 → 1.0.0-beta.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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DbClientOptions } from '@usegraft/sdk-core/db';
1
2
  import { AnyCollection, ReadOptions, Document, ListOptions, SearchOptions, SearchHit, GraftClient, ClientOptions } from '@usegraft/sdk-core';
2
3
  export { AnyCollection, ChangeSet, ClientOptions, Document, GraftClient, ListOptions, ReadOptions, SearchHit, SearchOptions, TAG_NAMESPACE, collectionTag, createClient, documentTag, tagsFor, tagsForChanges, toDocument } from '@usegraft/sdk-core';
3
4
 
@@ -33,7 +34,15 @@ interface Graft<TCollections extends Record<string, AnyCollection>> {
33
34
  /** The underlying sdk-core client, for anything the helpers don't cover. */
34
35
  client: GraftClient<TCollections>;
35
36
  }
36
- declare function createGraft<TCollections extends Record<string, AnyCollection>>(options: ClientOptions<TCollections>): Graft<TCollections>;
37
+ /**
38
+ * Either an index this adapter reads through, or a Postgres handle it builds
39
+ * the reader for. Two shapes rather than one optional field so that neither can
40
+ * be omitted: `createClient` no longer accepts `db`, because taking it there
41
+ * meant every consumer of `@usegraft/sdk-core` — the browser client included —
42
+ * carried a Postgres driver in its dependency graph.
43
+ */
44
+ type GraftOptions<TCollections extends Record<string, AnyCollection>> = ClientOptions<TCollections> | DbClientOptions<TCollections>;
45
+ declare function createGraft<TCollections extends Record<string, AnyCollection>>(options: GraftOptions<TCollections>): Graft<TCollections>;
37
46
 
38
47
  /**
39
48
  * Mounting the Graft runtime in React Router v7 — a resource route (a route
@@ -73,4 +82,4 @@ declare function graftRoute(handler: FetchHandler): (args: {
73
82
  request: Request;
74
83
  }) => Promise<Response>;
75
84
 
76
- export { type FetchHandler, type Graft, createGraft, graftRoute };
85
+ export { type FetchHandler, type Graft, type GraftOptions, createGraft, graftRoute };
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  // src/graft.ts
2
+ import { createDbClient } from "@usegraft/sdk-core/db";
2
3
  import {
3
4
  createClient
4
5
  } from "@usegraft/sdk-core";
5
6
  function createGraft(options) {
6
- const client = createClient(options);
7
+ const client = "db" in options ? createDbClient(options) : createClient(options);
7
8
  return {
8
9
  client,
9
10
  getContent: (collection, slug, opts) => client.getDocument(collection, slug, opts),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usegraft/sdk-react-router",
3
- "version": "0.2.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "React Router v7 adapter: typed content reads and loader/action mounts over Graft's stateless handlers.",
5
5
  "keywords": [
6
6
  "agent",
@@ -38,10 +38,11 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@usegraft/sdk-core": "0.2.0"
41
+ "@usegraft/db": "1.0.0-beta.1",
42
+ "@usegraft/sdk-core": "1.0.0-beta.1"
42
43
  },
43
44
  "devDependencies": {
44
- "@usegraft/core": "0.2.0"
45
+ "@usegraft/core": "1.0.0-beta.1"
45
46
  },
46
47
  "engines": {
47
48
  "node": ">=22.16"