@guren/core 1.8.0 → 1.8.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/bin.d.ts +1 -5
- package/dist/bin.js +1 -2
- package/dist/index.d.ts +113 -111
- package/dist/index.js +342 -287
- package/dist/internal/deploy-build.d.ts +71 -70
- package/dist/internal/deploy-build.js +467 -209
- package/dist/internal/zod-compat.d.ts +12 -11
- package/dist/internal/zod-compat.js +112 -60
- package/dist/lambda.d.ts +2 -1
- package/dist/lambda.js +2 -17
- package/dist/redis.d.ts +2 -1
- package/dist/redis.js +2 -23
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/vite.d.ts +3 -2
- package/dist/vite.js +2 -5
- package/package.json +11 -7
|
@@ -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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
94
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
9
|
+
return typeof schema._def?.typeName === "string";
|
|
4
10
|
}
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
+
return schemaAt(def, "element");
|
|
22
43
|
}
|
|
44
|
+
/** A record's value schema — `_def.valueType`. */
|
|
23
45
|
function recordValueType(def) {
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
98
|
+
return Array.isArray(def.values) ? def.values : [];
|
|
53
99
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
|
1
|
+
export * from "@guren/server/runtime";
|
package/dist/runtime.js
CHANGED
package/dist/vite.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
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
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/core",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
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": "
|
|
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.
|
|
64
|
-
"@guren/orm": "^2.6.
|
|
65
|
-
"@guren/server": "^2.
|
|
67
|
+
"@guren/cli": "^2.9.1",
|
|
68
|
+
"@guren/orm": "^2.6.1",
|
|
69
|
+
"@guren/server": "^2.10.1"
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
72
|
"@types/node": "^20.14.10",
|
|
69
73
|
"drizzle-orm": "1.0.0-rc.4",
|
|
70
|
-
"
|
|
71
|
-
"typescript": "^
|
|
74
|
+
"tsdown": "^0.22.14",
|
|
75
|
+
"typescript": "^7.0.2"
|
|
72
76
|
}
|
|
73
77
|
}
|