hekireki 0.51.0 → 0.52.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.
Files changed (66) hide show
  1. package/README.md +72 -9
  2. package/dist/bin/activerecord.js +1 -1
  3. package/dist/bin/ajv.js +1 -1
  4. package/dist/bin/arktype.js +1 -1
  5. package/dist/bin/atlas.js +1 -1
  6. package/dist/bin/django.js +1 -1
  7. package/dist/bin/docs.js +1 -1
  8. package/dist/bin/drizzle.js +1 -1
  9. package/dist/bin/ecto.js +1 -1
  10. package/dist/bin/efcore.js +1 -1
  11. package/dist/bin/effect.js +1 -1
  12. package/dist/bin/eloquent.js +1 -1
  13. package/dist/bin/er.js +1 -1
  14. package/dist/bin/exposed.js +1 -1
  15. package/dist/bin/gorm.js +1 -1
  16. package/dist/bin/hekireki.js +5 -5
  17. package/dist/bin/kysely.js +1 -1
  18. package/dist/bin/openapi.js +1 -1
  19. package/dist/bin/pydantic.js +1 -1
  20. package/dist/bin/sea-orm.js +1 -1
  21. package/dist/bin/seed.js +1 -1
  22. package/dist/bin/sqlalchemy.js +1 -1
  23. package/dist/bin/typebox.js +1 -1
  24. package/dist/bin/valibot.js +1 -1
  25. package/dist/bin/zod-openapi-hono.js +1 -1
  26. package/dist/bin/zod.js +1 -1
  27. package/dist/{bin-DqjEDWJu.js → bin-Ds90Ze0I.js} +3714 -2475
  28. package/dist/case-D3JCqTLI.js +54 -0
  29. package/dist/{discover-C0ef4bHT.js → discover-HsZu2aJ7.js} +3 -3
  30. package/dist/{emit-Cz3yGQN2.js → emit-COI2F4Vx.js} +5 -2
  31. package/dist/{errors-fAN1Og-7.js → errors-CRIxtr-P.js} +88 -26
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/{migrate-CdaZW-P-.js → migrate-B_LmJjyl.js} +77 -21
  35. package/dist/{native-engine-DcCamR8F.js → native-engine-CiYCdB3Z.js} +145 -30
  36. package/dist/{plan-P2yzjNsy.js → plan-C4tSF0Di.js} +1294 -768
  37. package/dist/{run-CiIfED-2.js → run-CVdbTDka.js} +235 -128
  38. package/dist/{schema-CRiLGfEP.js → schema-TL20sYuM.js} +45 -181
  39. package/dist/{sql-BDYu__ri.js → sql-Dul-J3wN.js} +48 -19
  40. package/dist/{start-Cc_4AkrJ.js → start-DCy-nE2o.js} +1304 -929
  41. package/dist/studio/assets/client-8R97eV42.js +2 -0
  42. package/dist/studio/assets/{confirm-dialog-CKCkchiq.js → confirm-dialog-BfMzwGyk.js} +1 -1
  43. package/dist/studio/assets/docs-C7FtC4KG.js +1 -0
  44. package/dist/studio/assets/enums._name-DLAiEdMc.js +1 -0
  45. package/dist/studio/assets/{field-icon-C1wSRFKO.js → field-icon-LVK7vIIn.js} +1 -1
  46. package/dist/studio/assets/index-T46k2NyA.js +15 -0
  47. package/dist/studio/assets/{labels-B5gZ2suK.js → labels-Bn-KWaMa.js} +2 -2
  48. package/dist/studio/assets/{marked-text-B27DfhKS.js → marked-text-BdU5_qSK.js} +1 -1
  49. package/dist/studio/assets/models._name-BKzAVcW3.js +1 -0
  50. package/dist/studio/assets/{monaco-DRYJTcJl.js → monaco-33yj-p0X.js} +1 -1
  51. package/dist/studio/assets/prisma-DqpMbUwJ.js +2 -0
  52. package/dist/studio/assets/result-table-PN64JbsN.js +1 -0
  53. package/dist/studio/assets/{routes-Bl7HRpBJ.js → routes-C1Aze5QM.js} +1 -1
  54. package/dist/studio/assets/{schema-view-BEdx0cC2.js → schema-view-Bq2_9B5a.js} +4 -4
  55. package/dist/studio/assets/sql-FZV6GAdV.js +6 -0
  56. package/dist/studio/assets/{tabs-BpZ0hh1V.js → tabs-GBri63Xo.js} +1 -1
  57. package/dist/studio/index.html +2 -2
  58. package/package.json +9 -9
  59. package/dist/studio/assets/client-C-v3Paav.js +0 -2
  60. package/dist/studio/assets/docs-CXORFY0Y.js +0 -1
  61. package/dist/studio/assets/enums._name-BUBU_WMt.js +0 -1
  62. package/dist/studio/assets/index-DzCcMC-d.js +0 -15
  63. package/dist/studio/assets/models._name-CQFgPD0T.js +0 -1
  64. package/dist/studio/assets/prisma-1nDx08Wb.js +0 -2
  65. package/dist/studio/assets/result-table-0P18Nywh.js +0 -1
  66. package/dist/studio/assets/sql-GBZZtEKI.js +0 -6
package/README.md CHANGED
@@ -113,9 +113,9 @@ take `///` lines of their own, described below.
113
113
 
114
114
  ### API
115
115
 
116
- | Provider | Writes | Options |
117
- | --------------------------- | ------------------------------------------ | --------------------------------------------------------- |
118
- | `hekireki-zod-openapi-hono` | Hono app of the CRUD (`@hono/zod-openapi`) | `prisma` (`./prisma`), `auth` (`jwt`), `title`, `version` |
116
+ | Provider | Writes | Options |
117
+ | --------------------------- | ------------------------------------------ | -------------------------------------------------------------------------------------- |
118
+ | `hekireki-zod-openapi-hono` | Hono app of the CRUD (`@hono/zod-openapi`) | `prisma` (`./prisma`), `auth` (`jwt`, `jwks`, `cloudflare-access`), `title`, `version` |
119
119
 
120
120
  `hekireki-zod-openapi-hono` writes, in the directory `output` names, `openapi.yaml`: the CRUD of
121
121
  each model, `GET` and `POST /users` and `GET`, `PATCH` and `DELETE /users/{id}`, with the rows as
@@ -138,12 +138,75 @@ export const prisma = new PrismaClient({
138
138
  })
139
139
  ```
140
140
 
141
- With `auth = "jwt"`, every operation asks for a bearer JWT (`bearerAuth` in the document, and a
142
- 401 among its answers), and the app entry runs `auth` on every model's paths,
143
- `app.use('/users/*', auth)`. `auth.ts`, written when it is not there and left as it is after, lets
144
- a request through with a JWT signed with HS256 by the secret `JWT_SECRET`, read from the runtime's
145
- environment; a handler reads the token's payload with `c.get('jwtPayload')`. A guard of a model's
146
- paths that is not in the app entry is added again when the generator runs.
141
+ `GET /users` answers a page: `limit` rows (20 by default, at most 100) after `offset`, in the
142
+ order of the key, and the number of rows in all in the `X-Total-Count` header. No request reads a
143
+ whole table.
144
+
145
+ A `POST` or a `PATCH` takes only the fields a client may write. A field the server fills is left
146
+ out: `@updatedAt`, and a `@default` the database or Prisma makes (`autoincrement()`, `now()`,
147
+ `uuid()`, `cuid()`, `ulid()`, `nanoid()`, `dbgenerated()`); a plain `@default("user")` is not. A
148
+ `///` line keeps any other field from the API: `@api.readonly` answers it and never takes it,
149
+ `@api.hidden` neither answers nor takes it, and every query omits it. Zod drops a field its schema
150
+ does not have, so a request that sends one changes nothing.
151
+
152
+ ```prisma
153
+ model User {
154
+ id Int @id @default(autoincrement()) // answered, never taken
155
+ email String @unique
156
+ /// @api.readonly
157
+ role String @default("user") // answered, never taken
158
+ /// @api.hidden
159
+ passwordHash String // neither answered nor taken
160
+ createdAt DateTime @default(now()) // answered, never taken
161
+ }
162
+ ```
163
+
164
+ A required field the API never takes and that has no `@default` (`passwordHash` above) leaves
165
+ `POST /users` unable to make a row: such a model is created by a handler of your own.
166
+
167
+ With `auth`, every operation asks for a token (`bearerAuth` in the document, `cloudflareAccess`
168
+ for `cloudflare-access`, and a 401 and a 403 among its answers), and the app entry runs `auth` on every model's paths, `app.use('/users/*', auth)`.
169
+ `auth.ts`, written when it is not there and left as it is after, checks the token; a handler reads
170
+ its payload with `c.get('jwtPayload')`. A guard of a model's paths that is not in the app entry is
171
+ added again when the generator runs.
172
+
173
+ | `auth` | The token | Environment |
174
+ | ------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------ |
175
+ | `jwks` | Signed by an issuer with a key it publishes (RS256, PS256, ES256, EdDSA) | `JWKS_URI`, `JWT_ISSUER`, `JWT_AUDIENCE` |
176
+ | `jwt` | Signed with HS256 by a secret the app shares with the issuer | `JWT_SECRET`, `JWT_ISSUER`, `JWT_AUDIENCE` |
177
+ | `cloudflare-access` | Put in `Cf-Access-Jwt-Assertion` by Cloudflare Access, signed with RS256 by a key the team publishes | `CF_ACCESS_TEAM_DOMAIN`, `CF_ACCESS_AUD` |
178
+
179
+ Whatever the kind, a token passes only with the `iss` and `aud` named, and with an `exp`: Hono checks `exp`
180
+ only when a token has it, so `auth.ts` refuses one without it, which would never expire. A missing
181
+ variable fails every request with 500 rather than let one through.
182
+
183
+ With `jwt` and `jwks`, the API writes every model, so a valid token also has to hold the `admin`
184
+ role, in its `role` claim (a string or an array of strings), or it is answered 403. `REQUIRED_ROLES` and `ROLE_CLAIM` in
185
+ `auth.ts` say which roles and which claim (an identity provider may put roles under a claim of its
186
+ own, such as `https://example.com/roles`); an empty `REQUIRED_ROLES` lets any valid token through.
187
+
188
+ `jwks` is safer than `jwt`: the app holds no key that signs a token, and the issuer (an identity
189
+ provider such as Auth0, Clerk or Okta) rotates and revokes them. `JWKS_URI` is https
190
+ (http only on `localhost`); the keys are cached for ten minutes and fetched again for a `kid` the
191
+ cache lacks, at most once a minute.
192
+
193
+ `cloudflare-access` is for an app behind
194
+ [Cloudflare Access](https://developers.cloudflare.com/cloudflare-one/policies/access/), on Workers
195
+ or behind a Cloudflare Tunnel. `CF_ACCESS_TEAM_DOMAIN` is the team domain
196
+ (`https://<team>.cloudflareaccess.com`), the token's `iss`, and `CF_ACCESS_AUD` the application's
197
+ Application Audience (AUD) tag. The keys come from `<team domain>/cdn-cgi/access/certs`, cached as
198
+ with `jwks`. Access's token carries no role, since its policy decides who passes, so
199
+ `REQUIRED_ROLES` starts empty there. The signature is checked all the same, so a request that
200
+ reaches the app around Access (its `workers.dev` URL, the origin's own address) is refused. The
201
+ document names the header (`cloudflareAccess`) rather than a bearer token.
202
+
203
+ With `jwt`, `JWT_SECRET` is at least 32 bytes (`openssl rand -base64 48`), shared with nothing but
204
+ the issuer, and a token lives at most an hour from its `iat` (`MAX_TOKEN_LIFETIME_SECONDS` in
205
+ `auth.ts`). A token cannot be taken back before its `exp`; only a new secret ends every token.
206
+
207
+ An `auth.ts` written by a release before 0.52.0 lets through a token without `exp`, and does not
208
+ check `iss`, `aud` or a role. Delete it and run the generator to have the current one, then set the
209
+ variables above.
147
210
 
148
211
  A handler that has a body is kept when the generator runs again, as Hono Takibi keeps it, so a
149
212
  handler changed by hand stays as it is; only an empty one is filled. A `BigInt` is answered as a
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/activerecord.ts
4
4
  registerGenerator("activerecord");
5
5
  export {};
package/dist/bin/ajv.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/ajv.ts
4
4
  registerGenerator("ajv");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/arktype.ts
4
4
  registerGenerator("arktype");
5
5
  export {};
package/dist/bin/atlas.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/atlas.ts
4
4
  registerGenerator("atlas");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/django.ts
4
4
  registerGenerator("django");
5
5
  export {};
package/dist/bin/docs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/docs.ts
4
4
  registerGenerator("docs");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/drizzle.ts
4
4
  registerGenerator("drizzle");
5
5
  export {};
package/dist/bin/ecto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/ecto.ts
4
4
  registerGenerator("ecto");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/efcore.ts
4
4
  registerGenerator("efcore");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/effect.ts
4
4
  registerGenerator("effect");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/eloquent.ts
4
4
  registerGenerator("eloquent");
5
5
  export {};
package/dist/bin/er.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/er.ts
4
4
  registerGenerator("er");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/exposed.ts
4
4
  registerGenerator("exposed");
5
5
  export {};
package/dist/bin/gorm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/gorm.ts
4
4
  registerGenerator("gorm");
5
5
  export {};
@@ -6,7 +6,7 @@ import { Console, Data, Effect, Schema } from "effect";
6
6
  import path from "node:path";
7
7
  import { CliError, Command, Flag } from "effect/cli";
8
8
  // package.json
9
- var version = "0.51.0";
9
+ var version = "0.52.1";
10
10
  // src/schema/path.ts
11
11
  /** Where Prisma looks for a schema when neither the command nor prisma.config.ts names one. */
12
12
  const DEFAULT_SCHEMA_PATHS = ["prisma/schema.prisma", "schema.prisma"];
@@ -149,7 +149,7 @@ const studioFlags = {
149
149
  function runStudio(args) {
150
150
  return Effect.gen(function* () {
151
151
  const schemaPath = yield* resolveSchemaPath(args.schema, [COMMAND_NAME, "studio"]);
152
- const { startStudioServer } = yield* Effect.promise(() => import("../start-Cc_4AkrJ.js"));
152
+ const { startStudioServer } = yield* Effect.promise(() => import("../start-DCy-nE2o.js"));
153
153
  const started = yield* startStudioServer({
154
154
  schemaPath,
155
155
  port: args.port,
@@ -201,7 +201,7 @@ const seedFlags = {
201
201
  };
202
202
  function runSeedCommand(args) {
203
203
  return Effect.gen(function* () {
204
- const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-CiIfED-2.js"));
204
+ const { runSeed, seedBanner } = yield* Effect.promise(() => import("../run-CVdbTDka.js"));
205
205
  const report = yield* runSeed(args, process.cwd()).pipe(Effect.mapError((error) => new CliError.UserError({ cause: error.message })));
206
206
  yield* Console.log(seedBanner(report));
207
207
  });
@@ -244,7 +244,7 @@ function runMigrateCheckCommand(args) {
244
244
  "migrate",
245
245
  "check"
246
246
  ]);
247
- const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-CdaZW-P-.js"));
247
+ const { checkBanner, checkJson, runMigrateCheck, summarize } = yield* Effect.promise(() => import("../migrate-B_LmJjyl.js"));
248
248
  const report = yield* runMigrateCheck({
249
249
  ...args,
250
250
  schemaPath,
@@ -291,7 +291,7 @@ function runMigratePlanCommand(args) {
291
291
  "migrate",
292
292
  "plan"
293
293
  ]);
294
- const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-CdaZW-P-.js"));
294
+ const { checkBanner, planSql, readMigration, runMigrateCheck, summarize, writePlan } = yield* Effect.promise(() => import("../migrate-B_LmJjyl.js"));
295
295
  const report = yield* runMigrateCheck({
296
296
  ...args,
297
297
  schemaPath,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/kysely.ts
4
4
  registerGenerator("kysely");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/openapi.ts
4
4
  registerGenerator("openapi");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/pydantic.ts
4
4
  registerGenerator("pydantic");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/sea-orm.ts
4
4
  registerGenerator("sea-orm");
5
5
  export {};
package/dist/bin/seed.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/seed.ts
4
4
  registerGenerator("seed");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/sqlalchemy.ts
4
4
  registerGenerator("sqlalchemy");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/typebox.ts
4
4
  registerGenerator("typebox");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/valibot.ts
4
4
  registerGenerator("valibot");
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/zod-openapi-hono.ts
4
4
  registerGenerator("zod-openapi-hono");
5
5
  export {};
package/dist/bin/zod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as registerGenerator } from "../bin-DqjEDWJu.js";
2
+ import { t as registerGenerator } from "../bin-Ds90Ze0I.js";
3
3
  // src/bin/zod.ts
4
4
  registerGenerator("zod");
5
5
  export {};