@usegraft/sdk-sveltekit 0.2.0 → 1.0.0-beta.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/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
 
@@ -28,7 +29,15 @@ interface Graft<TCollections extends Record<string, AnyCollection>> {
28
29
  /** The underlying sdk-core client, for anything the helpers don't cover. */
29
30
  client: GraftClient<TCollections>;
30
31
  }
31
- declare function createGraft<TCollections extends Record<string, AnyCollection>>(options: ClientOptions<TCollections>): Graft<TCollections>;
32
+ /**
33
+ * Either an index this adapter reads through, or a Postgres handle it builds
34
+ * the reader for. Two shapes rather than one optional field so that neither can
35
+ * be omitted: `createClient` no longer accepts `db`, because taking it there
36
+ * meant every consumer of `@usegraft/sdk-core` — the browser client included —
37
+ * carried a Postgres driver in its dependency graph.
38
+ */
39
+ type GraftOptions<TCollections extends Record<string, AnyCollection>> = ClientOptions<TCollections> | DbClientOptions<TCollections>;
40
+ declare function createGraft<TCollections extends Record<string, AnyCollection>>(options: GraftOptions<TCollections>): Graft<TCollections>;
32
41
 
33
42
  /**
34
43
  * Mounting the Graft runtime in SvelteKit — `+server.ts` endpoints are
@@ -57,4 +66,4 @@ declare function graftRoute(handler: FetchHandler): (event: {
57
66
  request: Request;
58
67
  }) => Promise<Response>;
59
68
 
60
- export { type FetchHandler, type Graft, createGraft, graftRoute };
69
+ 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-sveltekit",
3
- "version": "0.2.0",
3
+ "version": "1.0.0-beta.0",
4
4
  "description": "SvelteKit adapter: typed content reads and endpoint mounts over Graft's stateless handlers.",
5
5
  "keywords": [
6
6
  "agent",
@@ -37,10 +37,11 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@usegraft/sdk-core": "0.2.0"
40
+ "@usegraft/db": "1.0.0-beta.0",
41
+ "@usegraft/sdk-core": "1.0.0-beta.0"
41
42
  },
42
43
  "devDependencies": {
43
- "@usegraft/core": "0.2.0"
44
+ "@usegraft/core": "1.0.0-beta.0"
44
45
  },
45
46
  "engines": {
46
47
  "node": ">=22.16"