@guren/core 1.8.0 → 1.9.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.
@@ -1,3 +1,4 @@
1
+ //#region src/internal/zod-compat.d.ts
1
2
  /**
2
3
  * Zod 4 schema-reading primitives shared by `@guren/cli`'s TypeScript-type
3
4
  * renderer (`src/schema-type-extractor.ts`) and the OpenAPI schema-object
@@ -29,13 +30,13 @@
29
30
  * `_def`. They stay with their callers until someone does that.
30
31
  */
31
32
  interface ZodSchemaLike {
32
- _def?: Record<string, unknown>;
33
- /** zod 4's internal container; `values` is its own computed set of accepted literals. */
34
- _zod?: {
35
- values?: Set<unknown>;
36
- };
37
- type?: string;
38
- shape?: Record<string, ZodSchemaLike>;
33
+ _def?: Record<string, unknown>;
34
+ /** zod 4's internal container; `values` is its own computed set of accepted literals. */
35
+ _zod?: {
36
+ values?: Set<unknown>;
37
+ };
38
+ type?: string;
39
+ shape?: Record<string, ZodSchemaLike>;
39
40
  }
40
41
  /**
41
42
  * Which side of a schema is being read.
@@ -90,8 +91,8 @@ declare function isTransform(schema: ZodSchemaLike): boolean;
90
91
  * absent for a transform, leaving `from` as the only readable answer.
91
92
  */
92
93
  declare function pipeSides(def: Record<string, unknown>): {
93
- from: ZodSchemaLike | undefined;
94
- to: ZodSchemaLike | undefined;
94
+ from: ZodSchemaLike | undefined;
95
+ to: ZodSchemaLike | undefined;
95
96
  };
96
97
  /** The one side of a `.pipe()` that describes the `io` direction being rendered. */
97
98
  declare function pipeSide(def: Record<string, unknown>, io: SchemaIo): ZodSchemaLike | undefined;
@@ -137,5 +138,5 @@ declare const PRESENCE_WRAPPERS: ReadonlySet<string>;
137
138
  * which is why the list lives here rather than once per package.
138
139
  */
139
140
  declare const SINGLE_CHILD_WRAPPERS: ReadonlySet<string>;
140
-
141
- export { PRESENCE_WRAPPERS, SINGLE_CHILD_WRAPPERS, type SchemaIo, TRANSPARENT_WRAPPERS, ZOD3_UNSUPPORTED_MESSAGE, type ZodSchemaLike, arrayElement, enumValues, getTypeName, innerSchema, isTransform, isZod3Schema, literalValues, objectShape, pipeSide, pipeSides, recordValueType, schemaAt, typeOf };
141
+ //#endregion
142
+ export { PRESENCE_WRAPPERS, SINGLE_CHILD_WRAPPERS, SchemaIo, TRANSPARENT_WRAPPERS, ZOD3_UNSUPPORTED_MESSAGE, ZodSchemaLike, arrayElement, enumValues, getTypeName, innerSchema, isTransform, isZod3Schema, literalValues, objectShape, pipeSide, pipeSides, recordValueType, schemaAt, typeOf };
@@ -1,89 +1,141 @@
1
- // src/internal/zod-compat.ts
1
+ //#region src/internal/zod-compat.ts
2
+ /**
3
+ * Whether this node was authored with the zod 3 API. Only v3 sets
4
+ * `_def.typeName` (`"ZodString"`), so its presence is the discriminator —
5
+ * checked before any other read, because on a v3 node `_def.type` holds a
6
+ * nested *schema* and every v4-shaped read below would misfire on it.
7
+ */
2
8
  function isZod3Schema(schema) {
3
- return typeof schema._def?.typeName === "string";
9
+ return typeof schema._def?.typeName === "string";
4
10
  }
5
- var ZOD3_UNSUPPORTED_MESSAGE = "this schema was authored with the zod v3 API (zod@3 or the zod/v3 subpath), which Guren does not support. Rewrite it with the zod 4 API (`import { z } from 'zod'`).";
11
+ /**
12
+ * The one refusal message, stated once so the CLI's console warning and the
13
+ * OpenAPI document's warnings array cannot drift apart.
14
+ */
15
+ const ZOD3_UNSUPPORTED_MESSAGE = "this schema was authored with the zod v3 API (zod@3 or the zod/v3 subpath), which Guren does not support. Rewrite it with the zod 4 API (`import { z } from 'zod'`).";
16
+ /** The node's type name: `_def.type` (`"string"`, `"object"`, …) or the schema's own `.type`. */
6
17
  function getTypeName(schema) {
7
- const name = schema._def?.type ?? schema.type;
8
- return typeof name === "string" ? name : void 0;
18
+ const name = schema._def?.type ?? schema.type;
19
+ return typeof name === "string" ? name : void 0;
9
20
  }
21
+ /** `getTypeName` with `'unknown'` for a node that has no readable name. */
10
22
  function typeOf(schema) {
11
- return getTypeName(schema) ?? "unknown";
23
+ return getTypeName(schema) ?? "unknown";
12
24
  }
25
+ /**
26
+ * The schema at `def[key]`, if it actually holds one. The object check is
27
+ * load-bearing: `_def` is untyped data from someone else's package, and a key
28
+ * holding a string or function must read as absent, not as a schema. (The
29
+ * v3-era version of this helper took a key *list* and returned the first
30
+ * match; with one dialect there is no precedence left to encode.)
31
+ */
13
32
  function schemaAt(def, key) {
14
- const candidate = def[key];
15
- return candidate && typeof candidate === "object" ? candidate : void 0;
33
+ const candidate = def[key];
34
+ return candidate && typeof candidate === "object" ? candidate : void 0;
16
35
  }
36
+ /** The schema wrapped by a single-child wrapper (`.optional()`, `.readonly()`, `.catch()`, …) — always `_def.innerType` in zod 4. */
17
37
  function innerSchema(def) {
18
- return schemaAt(def, "innerType");
38
+ return schemaAt(def, "innerType");
19
39
  }
40
+ /** An array's element schema — `_def.element`, never `_def.type`, which holds the string `'array'`. */
20
41
  function arrayElement(def) {
21
- return schemaAt(def, "element");
42
+ return schemaAt(def, "element");
22
43
  }
44
+ /** A record's value schema — `_def.valueType`. */
23
45
  function recordValueType(def) {
24
- return schemaAt(def, "valueType");
46
+ return schemaAt(def, "valueType");
25
47
  }
48
+ /**
49
+ * Whether this node is a `.transform()`'s output half — a wrapped function
50
+ * with no type to read, as opposed to a schema that genuinely parses to
51
+ * `unknown`.
52
+ */
26
53
  function isTransform(schema) {
27
- return typeOf(schema) === "transform";
54
+ return typeOf(schema) === "transform";
28
55
  }
56
+ /**
57
+ * Both halves of a `.pipe()`. Zod 4 uses one `pipe` node for both `.pipe()`
58
+ * and `.transform()`: `_def.in` is what a caller sends, `_def.out` what a
59
+ * controller receives — except for a transform, whose out side is the
60
+ * transform function itself and so has no type to read. `to` is therefore
61
+ * absent for a transform, leaving `from` as the only readable answer.
62
+ */
29
63
  function pipeSides(def) {
30
- const to = schemaAt(def, "out");
31
- return { from: schemaAt(def, "in"), to: to && !isTransform(to) ? to : void 0 };
64
+ const to = schemaAt(def, "out");
65
+ return {
66
+ from: schemaAt(def, "in"),
67
+ to: to && !isTransform(to) ? to : void 0
68
+ };
32
69
  }
70
+ /** The one side of a `.pipe()` that describes the `io` direction being rendered. */
33
71
  function pipeSide(def, io) {
34
- const { from, to } = pipeSides(def);
35
- return io === "output" && to ? to : from;
72
+ const { from, to } = pipeSides(def);
73
+ return io === "output" && to ? to : from;
36
74
  }
75
+ /** An object's property map — `_def.shape`, or the schema's own `.shape`. */
37
76
  function objectShape(schema) {
38
- const def = schema._def ?? {};
39
- return def.shape ?? schema.shape;
77
+ return (schema._def ?? {}).shape ?? schema.shape;
40
78
  }
79
+ /**
80
+ * An enum's accepted values, read from zod's own computed set at
81
+ * `_zod.values` rather than re-derived from `_def.entries`. The distinction
82
+ * matters because `z.nativeEnum` produces the same node and a real TypeScript
83
+ * numeric enum's runtime object carries reverse mappings (`{ A: 0, '0': 'A' }`)
84
+ * — and any hand-rolled filter for those has a false positive: in
85
+ * `{ A: 'B', B: 1 }`, the key `A` *looks* like a reverse entry (`entries['B']`
86
+ * is a number) but zod accepts `'B'`. Reading zod's set makes what we document
87
+ * what zod parses, by construction. The `entries` fallback (values unfiltered)
88
+ * only runs if a future zod 4.x stops exposing the set.
89
+ */
41
90
  function enumValues(schema) {
42
- const values = schema._zod?.values;
43
- if (values) {
44
- return [...values].filter(
45
- (value) => typeof value === "string" || typeof value === "number"
46
- );
47
- }
48
- const entries = schema._def?.entries;
49
- return entries ? Object.values(entries) : [];
91
+ const values = schema._zod?.values;
92
+ if (values) return [...values].filter((value) => typeof value === "string" || typeof value === "number");
93
+ const entries = schema._def?.entries;
94
+ return entries ? Object.values(entries) : [];
50
95
  }
96
+ /** A literal's values — always the `_def.values` array in zod 4, which may hold more than one. */
51
97
  function literalValues(def) {
52
- return Array.isArray(def.values) ? def.values : [];
98
+ return Array.isArray(def.values) ? def.values : [];
53
99
  }
54
- var TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
55
- "catch",
56
- "readonly",
57
- "lazy"
100
+ /**
101
+ * Wrappers that neither add to a rendered type nor decide whether a field may
102
+ * be omitted — whatever they wrap answers both questions. (`lazy` is here for
103
+ * membership only: its child hides behind `_def.getter`, which no walker
104
+ * calls, so looking through it reads as "contents unavailable" rather than
105
+ * "unsupported type".)
106
+ */
107
+ const TRANSPARENT_WRAPPERS = /* @__PURE__ */ new Set([
108
+ "catch",
109
+ "readonly",
110
+ "lazy"
58
111
  ]);
59
- var PRESENCE_WRAPPERS = /* @__PURE__ */ new Set([
60
- "optional",
61
- "default",
62
- "prefault",
63
- "nonoptional"
112
+ /**
113
+ * Wrappers that pass their type through but *do* decide presence: each makes a
114
+ * field omissible, or (in `nonoptional`'s case) re-requires one.
115
+ */
116
+ const PRESENCE_WRAPPERS = /* @__PURE__ */ new Set([
117
+ "optional",
118
+ "default",
119
+ "prefault",
120
+ "nonoptional"
64
121
  ]);
65
- var SINGLE_CHILD_WRAPPERS = /* @__PURE__ */ new Set([
66
- ...TRANSPARENT_WRAPPERS,
67
- ...PRESENCE_WRAPPERS,
68
- "nullable",
69
- "pipe"
122
+ /**
123
+ * Every type name that carries exactly one nested schema and no shape of its
124
+ * own — the union of the two sets above plus the two that render specially
125
+ * (`nullable` becomes a union with null; a pipe holds one schema per side).
126
+ *
127
+ * This is the vocabulary, not a policy: callers partition it however their
128
+ * rendering needs (the CLI splits transparent from presence-deciding because
129
+ * it walks types and presence separately; the OpenAPI walker looks through all
130
+ * of them uniformly). What none of them may do is disagree about *membership*
131
+ * — a name known to one walker and not the other silently changes an output,
132
+ * which is why the list lives here rather than once per package.
133
+ */
134
+ const SINGLE_CHILD_WRAPPERS = /* @__PURE__ */ new Set([
135
+ ...TRANSPARENT_WRAPPERS,
136
+ ...PRESENCE_WRAPPERS,
137
+ "nullable",
138
+ "pipe"
70
139
  ]);
71
- export {
72
- PRESENCE_WRAPPERS,
73
- SINGLE_CHILD_WRAPPERS,
74
- TRANSPARENT_WRAPPERS,
75
- ZOD3_UNSUPPORTED_MESSAGE,
76
- arrayElement,
77
- enumValues,
78
- getTypeName,
79
- innerSchema,
80
- isTransform,
81
- isZod3Schema,
82
- literalValues,
83
- objectShape,
84
- pipeSide,
85
- pipeSides,
86
- recordValueType,
87
- schemaAt,
88
- typeOf
89
- };
140
+ //#endregion
141
+ export { PRESENCE_WRAPPERS, SINGLE_CHILD_WRAPPERS, TRANSPARENT_WRAPPERS, ZOD3_UNSUPPORTED_MESSAGE, arrayElement, enumValues, getTypeName, innerSchema, isTransform, isZod3Schema, literalValues, objectShape, pipeSide, pipeSides, recordValueType, schemaAt, typeOf };
package/dist/lambda.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { APIGatewayProxyResult, LambdaEvent, createConsoleHandler, createLambdaHandler, createScheduleHandler, createSqsHandler, getLambdaContext, isLambda } from '@guren/server/lambda';
1
+ import { APIGatewayProxyResult, LambdaEvent, createConsoleHandler, createLambdaHandler, createScheduleHandler, createSqsHandler, getLambdaContext, isLambda } from "@guren/server/lambda";
2
+ export { type APIGatewayProxyResult, type LambdaEvent, createConsoleHandler, createLambdaHandler, createScheduleHandler, createSqsHandler, getLambdaContext, isLambda };
package/dist/lambda.js CHANGED
@@ -1,17 +1,2 @@
1
- // src/lambda.ts
2
- import {
3
- createLambdaHandler,
4
- createSqsHandler,
5
- createScheduleHandler,
6
- createConsoleHandler,
7
- isLambda,
8
- getLambdaContext
9
- } from "@guren/server/lambda";
10
- export {
11
- createConsoleHandler,
12
- createLambdaHandler,
13
- createScheduleHandler,
14
- createSqsHandler,
15
- getLambdaContext,
16
- isLambda
17
- };
1
+ import { createConsoleHandler, createLambdaHandler, createScheduleHandler, createSqsHandler, getLambdaContext, isLambda } from "@guren/server/lambda";
2
+ export { createConsoleHandler, createLambdaHandler, createScheduleHandler, createSqsHandler, getLambdaContext, isLambda };
package/dist/redis.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { Redis, RedisApiTokenStore, RedisApiTokenStoreOptions, RedisClientOptions, RedisEmailVerificationStore, RedisEmailVerificationStoreOptions, RedisOAuthStateStore, RedisOAuthStateStoreOptions, RedisOptions, RedisPasswordResetStore, RedisPasswordResetStoreOptions, RedisRateLimitStore, RedisRateLimitStoreOptions, RedisSessionStore, RedisSessionStoreOptions, RedisSlidingWindowRateLimitStore, createRedisClient } from '@guren/server/redis';
1
+ import { Redis, RedisApiTokenStore, RedisApiTokenStoreOptions, RedisClientOptions, RedisEmailVerificationStore, RedisEmailVerificationStoreOptions, RedisOAuthStateStore, RedisOAuthStateStoreOptions, RedisOptions, RedisPasswordResetStore, RedisPasswordResetStoreOptions, RedisRateLimitStore, RedisRateLimitStoreOptions, RedisSessionStore, RedisSessionStoreOptions, RedisSlidingWindowRateLimitStore, createRedisClient } from "@guren/server/redis";
2
+ export { Redis, RedisApiTokenStore, type RedisApiTokenStoreOptions, type RedisClientOptions, RedisEmailVerificationStore, type RedisEmailVerificationStoreOptions, RedisOAuthStateStore, type RedisOAuthStateStoreOptions, type RedisOptions, RedisPasswordResetStore, type RedisPasswordResetStoreOptions, RedisRateLimitStore, type RedisRateLimitStoreOptions, RedisSessionStore, type RedisSessionStoreOptions, RedisSlidingWindowRateLimitStore, createRedisClient };
package/dist/redis.js CHANGED
@@ -1,23 +1,2 @@
1
- // src/redis.ts
2
- import {
3
- createRedisClient,
4
- Redis,
5
- RedisSessionStore,
6
- RedisRateLimitStore,
7
- RedisSlidingWindowRateLimitStore,
8
- RedisApiTokenStore,
9
- RedisPasswordResetStore,
10
- RedisEmailVerificationStore,
11
- RedisOAuthStateStore
12
- } from "@guren/server/redis";
13
- export {
14
- Redis,
15
- RedisApiTokenStore,
16
- RedisEmailVerificationStore,
17
- RedisOAuthStateStore,
18
- RedisPasswordResetStore,
19
- RedisRateLimitStore,
20
- RedisSessionStore,
21
- RedisSlidingWindowRateLimitStore,
22
- createRedisClient
23
- };
1
+ import { Redis, RedisApiTokenStore, RedisEmailVerificationStore, RedisOAuthStateStore, RedisPasswordResetStore, RedisRateLimitStore, RedisSessionStore, RedisSlidingWindowRateLimitStore, createRedisClient } from "@guren/server/redis";
2
+ export { Redis, RedisApiTokenStore, RedisEmailVerificationStore, RedisOAuthStateStore, RedisPasswordResetStore, RedisRateLimitStore, RedisSessionStore, RedisSlidingWindowRateLimitStore, createRedisClient };
package/dist/runtime.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '@guren/server/runtime';
1
+ export * from "@guren/server/runtime";
package/dist/runtime.js CHANGED
@@ -1,2 +1,2 @@
1
- // src/runtime.ts
2
1
  export * from "@guren/server/runtime";
2
+ export {};
package/dist/vite.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from '@guren/server/vite';
2
- export { default } from '@guren/server/vite';
1
+ import vite_default from "@guren/server/vite";
2
+ export * from "@guren/server/vite";
3
+ export { vite_default as default };
package/dist/vite.js CHANGED
@@ -1,6 +1,3 @@
1
- // src/vite.ts
2
- import { default as default2 } from "@guren/server/vite";
1
+ import vite_default from "@guren/server/vite";
3
2
  export * from "@guren/server/vite";
4
- export {
5
- default2 as default
6
- };
3
+ export { vite_default as default };
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@guren/core",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "type": "module",
5
+ "sideEffects": [
6
+ "./src/bin.ts",
7
+ "./dist/bin.js"
8
+ ],
5
9
  "license": "MIT",
6
10
  "repository": {
7
11
  "type": "git",
@@ -54,20 +58,20 @@
54
58
  "guren": "./dist/bin.js"
55
59
  },
56
60
  "scripts": {
57
- "build": "tsup",
61
+ "build": "bun --bun tsdown",
58
62
  "dev": "bun --watch src/index.ts",
59
63
  "test": "bun test",
60
64
  "typecheck": "tsc --noEmit"
61
65
  },
62
66
  "dependencies": {
63
- "@guren/cli": "^2.7.0",
64
- "@guren/orm": "^2.6.0",
65
- "@guren/server": "^2.9.0"
67
+ "@guren/cli": "^2.10.0",
68
+ "@guren/orm": "^2.6.1",
69
+ "@guren/server": "^2.11.0"
66
70
  },
67
71
  "devDependencies": {
68
72
  "@types/node": "^20.14.10",
69
73
  "drizzle-orm": "1.0.0-rc.4",
70
- "tsup": "^8.5.0",
71
- "typescript": "^5.4.0"
74
+ "tsdown": "^0.22.14",
75
+ "typescript": "^7.0.2"
72
76
  }
73
77
  }