@toride/drizzle 0.1.0 → 0.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +6 -3
  2. package/package.json +6 -2
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ConstraintAdapter, ResourceRef } from 'toride';
1
+ import { ConstraintAdapter, TorideSchema, DefaultSchema, ResourceRef } from 'toride';
2
2
 
3
3
  declare const VERSION = "0.0.1";
4
4
 
@@ -35,8 +35,11 @@ interface DrizzleAdapterOptions {
35
35
  * Produces intermediate query description objects that capture the
36
36
  * operation type, field, and value. These can be used with drizzle-orm
37
37
  * operators or processed by custom query builders.
38
+ *
39
+ * @typeParam TQueryMap - Maps resource type names to their Drizzle query types.
40
+ * Defaults to `Record<string, DrizzleQuery>` for backward compatibility.
38
41
  */
39
- declare function createDrizzleAdapter(table: AnyTable, options?: DrizzleAdapterOptions): ConstraintAdapter<DrizzleQuery>;
42
+ declare function createDrizzleAdapter<TQueryMap extends Record<string, DrizzleQuery> = Record<string, DrizzleQuery>>(table: AnyTable, options?: DrizzleAdapterOptions): ConstraintAdapter<TQueryMap>;
40
43
  /** Options for createDrizzleResolver. */
41
44
  interface DrizzleResolverOptions {
42
45
  /** Column used as the resource ID. Defaults to "id". */
@@ -54,6 +57,6 @@ interface DrizzleResolverOptions {
54
57
  * @param options - Optional configuration.
55
58
  * @returns A ResourceResolver function.
56
59
  */
57
- declare function createDrizzleResolver(db: any, table: any, options?: DrizzleResolverOptions): (ref: ResourceRef) => Promise<Record<string, unknown>>;
60
+ declare function createDrizzleResolver<S extends TorideSchema = DefaultSchema, R extends S["resources"] = S["resources"]>(db: any, table: any, options?: DrizzleResolverOptions): (ref: ResourceRef<S, R>) => Promise<S["resourceAttributeMap"][R]>;
58
61
 
59
62
  export { type AnyTable, type DrizzleAdapterOptions, type DrizzleQuery, type DrizzleResolverOptions, type RelationConfig, type RoleAssignmentConfig, VERSION, createDrizzleAdapter, createDrizzleResolver };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toride/drizzle",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Drizzle ORM integration for Toride authorization engine",
5
5
  "type": "module",
6
6
  "exports": {
@@ -20,7 +20,7 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "toride": "0.1.0"
23
+ "toride": "0.3.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "drizzle-orm": ">=0.29.0"
@@ -33,6 +33,9 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
+ "devDependencies": {
37
+ "tsd": "^0.33.0"
38
+ },
36
39
  "keywords": [
37
40
  "authorization",
38
41
  "drizzle",
@@ -46,6 +49,7 @@
46
49
  "scripts": {
47
50
  "build": "tsup",
48
51
  "test": "vitest run",
52
+ "typetest": "tsd --files 'src/__typetests__/*.test-d.ts'",
49
53
  "lint": "tsc --noEmit"
50
54
  }
51
55
  }