@zenstackhq/server 3.6.4 → 3.7.0-beta.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/api.cjs +3 -3
- package/dist/api.mjs +1 -1
- package/dist/{common-D2RyWTAZ.cjs → common-CEe4nh_-.cjs} +2 -2
- package/dist/{common-D2RyWTAZ.cjs.map → common-CEe4nh_-.cjs.map} +1 -1
- package/dist/{common-Cdj4rLFr.mjs → common-DETPQ77o.mjs} +2 -2
- package/dist/{common-Cdj4rLFr.mjs.map → common-DETPQ77o.mjs.map} +1 -1
- package/dist/elysia.cjs +1 -1
- package/dist/elysia.mjs +1 -1
- package/dist/express.cjs +1 -1
- package/dist/express.mjs +1 -1
- package/dist/fastify.cjs +2 -2
- package/dist/fastify.mjs +1 -1
- package/dist/hono.cjs +1 -1
- package/dist/hono.mjs +1 -1
- package/dist/next.cjs +1 -1
- package/dist/next.mjs +1 -1
- package/dist/nuxt.cjs +2 -2
- package/dist/nuxt.mjs +1 -1
- package/dist/{openapi-BUzfCKi-.cjs → openapi-DhZIh0Ga.cjs} +3 -3
- package/dist/{openapi-BUzfCKi-.cjs.map → openapi-DhZIh0Ga.cjs.map} +1 -1
- package/dist/{spec-utils-C7vlChMD.cjs → spec-utils-CjQnZIo1.cjs} +2 -2
- package/dist/{spec-utils-C7vlChMD.cjs.map → spec-utils-CjQnZIo1.cjs.map} +1 -1
- package/dist/sveltekit.cjs +2 -2
- package/dist/sveltekit.mjs +1 -1
- package/dist/tanstack-start.cjs +1 -1
- package/dist/tanstack-start.mjs +1 -1
- package/dist/{utils-Doc_CQNd.mjs → utils-9j3D9BLL.mjs} +17 -1
- package/dist/utils-9j3D9BLL.mjs.map +1 -0
- package/dist/{utils-B9NX7OcP.cjs → utils-DpXvuv-L.cjs} +17 -1
- package/dist/utils-DpXvuv-L.cjs.map +1 -0
- package/package.json +8 -8
- package/dist/utils-B9NX7OcP.cjs.map +0 -1
- package/dist/utils-Doc_CQNd.mjs.map +0 -1
package/dist/api.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils = require("./utils-
|
|
3
|
-
const require_spec_utils = require("./spec-utils-
|
|
2
|
+
const require_utils = require("./utils-DpXvuv-L.cjs");
|
|
3
|
+
const require_spec_utils = require("./spec-utils-CjQnZIo1.cjs");
|
|
4
4
|
let _zenstackhq_common_helpers = require("@zenstackhq/common-helpers");
|
|
5
5
|
let _zenstackhq_orm = require("@zenstackhq/orm");
|
|
6
6
|
let decimal_js = require("decimal.js");
|
|
@@ -2721,7 +2721,7 @@ var RPCApiHandler = class {
|
|
|
2721
2721
|
return resp;
|
|
2722
2722
|
}
|
|
2723
2723
|
async generateSpec(options) {
|
|
2724
|
-
const { RPCApiSpecGenerator } = await Promise.resolve().then(() => require("./openapi-
|
|
2724
|
+
const { RPCApiSpecGenerator } = await Promise.resolve().then(() => require("./openapi-DhZIh0Ga.cjs"));
|
|
2725
2725
|
return new RPCApiSpecGenerator(this.options).generateSpec(options);
|
|
2726
2726
|
}
|
|
2727
2727
|
async processRequestPayload(args) {
|
package/dist/api.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as isFieldOmitted, c as isOperationIncluded, d as PROCEDURE_ROUTE_PREFIXES, f as getProcedureDef, i as getMetaDescription, l as isProcedureIncluded, o as isFilterKindIncluded, p as mapProcedureArgs, r as getIncludedModels, s as isModelIncluded, u as mayDenyAccess } from "./spec-utils-Syk4SLCX.mjs";
|
|
2
|
-
import { n as log, r as registerCustomSerializers, t as getZodErrorMessage } from "./utils-
|
|
2
|
+
import { n as log, r as registerCustomSerializers, t as getZodErrorMessage } from "./utils-9j3D9BLL.mjs";
|
|
3
3
|
import { clone, enumerate, lowerCaseFirst, paramCase, safeJSONStringify } from "@zenstackhq/common-helpers";
|
|
4
4
|
import { CoreCrudOperations, ORMError, ORMErrorReason } from "@zenstackhq/orm";
|
|
5
5
|
import { Decimal } from "decimal.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_utils = require("./utils-
|
|
1
|
+
const require_utils = require("./utils-DpXvuv-L.cjs");
|
|
2
2
|
//#region src/adapter/common.ts
|
|
3
3
|
function logInternalError(logger, err) {
|
|
4
4
|
require_utils.log(logger, "error", `An unhandled error occurred while processing the request: ${err}${err instanceof Error ? "\n" + err.stack : ""}`);
|
|
@@ -11,4 +11,4 @@ Object.defineProperty(exports, "logInternalError", {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
//# sourceMappingURL=common-
|
|
14
|
+
//# sourceMappingURL=common-CEe4nh_-.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-
|
|
1
|
+
{"version":3,"file":"common-CEe4nh_-.cjs","names":[],"sources":["../src/adapter/common.ts"],"sourcesContent":["import type { SchemaDef } from '@zenstackhq/orm/schema';\nimport { log } from '../api/utils';\nimport type { ApiHandler, LogConfig } from '../types';\n\n/**\n * Options common to all adapters\n */\nexport interface CommonAdapterOptions<Schema extends SchemaDef> {\n /**\n * The API handler to process requests\n */\n apiHandler: ApiHandler<Schema>;\n}\n\nexport function logInternalError(logger: LogConfig | undefined, err: unknown) {\n log(\n logger,\n 'error',\n `An unhandled error occurred while processing the request: ${err}${err instanceof Error ? '\\n' + err.stack : ''}`,\n );\n}\n"],"mappings":";;AAcA,SAAgB,iBAAiB,QAA+B,KAAc;AAC1E,eAAA,IACI,QACA,SACA,6DAA6D,MAAM,eAAe,QAAQ,OAAO,IAAI,QAAQ,KAChH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as log } from "./utils-
|
|
1
|
+
import { n as log } from "./utils-9j3D9BLL.mjs";
|
|
2
2
|
//#region src/adapter/common.ts
|
|
3
3
|
function logInternalError(logger, err) {
|
|
4
4
|
log(logger, "error", `An unhandled error occurred while processing the request: ${err}${err instanceof Error ? "\n" + err.stack : ""}`);
|
|
@@ -6,4 +6,4 @@ function logInternalError(logger, err) {
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { logInternalError as t };
|
|
8
8
|
|
|
9
|
-
//# sourceMappingURL=common-
|
|
9
|
+
//# sourceMappingURL=common-DETPQ77o.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-
|
|
1
|
+
{"version":3,"file":"common-DETPQ77o.mjs","names":[],"sources":["../src/adapter/common.ts"],"sourcesContent":["import type { SchemaDef } from '@zenstackhq/orm/schema';\nimport { log } from '../api/utils';\nimport type { ApiHandler, LogConfig } from '../types';\n\n/**\n * Options common to all adapters\n */\nexport interface CommonAdapterOptions<Schema extends SchemaDef> {\n /**\n * The API handler to process requests\n */\n apiHandler: ApiHandler<Schema>;\n}\n\nexport function logInternalError(logger: LogConfig | undefined, err: unknown) {\n log(\n logger,\n 'error',\n `An unhandled error occurred while processing the request: ${err}${err instanceof Error ? '\\n' + err.stack : ''}`,\n );\n}\n"],"mappings":";;AAcA,SAAgB,iBAAiB,QAA+B,KAAc;AAC1E,KACI,QACA,SACA,6DAA6D,MAAM,eAAe,QAAQ,OAAO,IAAI,QAAQ,KAChH"}
|
package/dist/elysia.cjs
CHANGED
package/dist/elysia.mjs
CHANGED
package/dist/express.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_common = require("./common-
|
|
2
|
+
const require_common = require("./common-CEe4nh_-.cjs");
|
|
3
3
|
//#region src/adapter/express/middleware.ts
|
|
4
4
|
/**
|
|
5
5
|
* Creates an Express middleware for handling CRUD requests.
|
package/dist/express.mjs
CHANGED
package/dist/fastify.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils = require("./utils-
|
|
3
|
-
const require_common = require("./common-
|
|
2
|
+
const require_utils = require("./utils-DpXvuv-L.cjs");
|
|
3
|
+
const require_common = require("./common-CEe4nh_-.cjs");
|
|
4
4
|
let fastify_plugin = require("fastify-plugin");
|
|
5
5
|
fastify_plugin = require_utils.__toESM(fastify_plugin, 1);
|
|
6
6
|
//#region src/adapter/fastify/plugin.ts
|
package/dist/fastify.mjs
CHANGED
package/dist/hono.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_common = require("./common-
|
|
2
|
+
const require_common = require("./common-CEe4nh_-.cjs");
|
|
3
3
|
//#region src/adapter/hono/handler.ts
|
|
4
4
|
function createHonoHandler(options) {
|
|
5
5
|
return async (ctx) => {
|
package/dist/hono.mjs
CHANGED
package/dist/next.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_common = require("./common-
|
|
2
|
+
const require_common = require("./common-CEe4nh_-.cjs");
|
|
3
3
|
//#region src/adapter/next/app-route-handler.ts
|
|
4
4
|
/**
|
|
5
5
|
* Creates a Next.js "app router" API route request handler that handles ZenStack CRUD requests.
|
package/dist/next.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as logInternalError } from "./common-
|
|
1
|
+
import { t as logInternalError } from "./common-DETPQ77o.mjs";
|
|
2
2
|
//#region src/adapter/next/app-route-handler.ts
|
|
3
3
|
/**
|
|
4
4
|
* Creates a Next.js "app router" API route request handler that handles ZenStack CRUD requests.
|
package/dist/nuxt.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("./utils-
|
|
3
|
-
const require_common = require("./common-
|
|
2
|
+
require("./utils-DpXvuv-L.cjs");
|
|
3
|
+
const require_common = require("./common-CEe4nh_-.cjs");
|
|
4
4
|
let h3 = require("h3");
|
|
5
5
|
//#region src/adapter/nuxt/handler.ts
|
|
6
6
|
function createEventHandler(options) {
|
package/dist/nuxt.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as logInternalError } from "./common-
|
|
1
|
+
import { t as logInternalError } from "./common-DETPQ77o.mjs";
|
|
2
2
|
import { defineEventHandler, getQuery, getRouterParams, readBody, setResponseStatus } from "h3";
|
|
3
3
|
//#region src/adapter/nuxt/handler.ts
|
|
4
4
|
function createEventHandler(options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require("./utils-
|
|
2
|
-
const require_spec_utils = require("./spec-utils-
|
|
1
|
+
require("./utils-DpXvuv-L.cjs");
|
|
2
|
+
const require_spec_utils = require("./spec-utils-CjQnZIo1.cjs");
|
|
3
3
|
let _zenstackhq_common_helpers = require("@zenstackhq/common-helpers");
|
|
4
4
|
let _zenstackhq_orm = require("@zenstackhq/orm");
|
|
5
5
|
//#region src/api/rpc/openapi.ts
|
|
@@ -583,4 +583,4 @@ var RPCApiSpecGenerator = class {
|
|
|
583
583
|
//#endregion
|
|
584
584
|
exports.RPCApiSpecGenerator = RPCApiSpecGenerator;
|
|
585
585
|
|
|
586
|
-
//# sourceMappingURL=openapi-
|
|
586
|
+
//# sourceMappingURL=openapi-DhZIh0Ga.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-BUzfCKi-.cjs","names":["getIncludedModels","CoreCrudOperations","isOperationIncluded","isProcedureIncluded","PROCEDURE_ROUTE_PREFIXES","mayDenyAccess","getMetaDescription"],"sources":["../src/api/rpc/openapi.ts"],"sourcesContent":["import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/common-helpers';\nimport { CoreCrudOperations, createQuerySchemaFactory, type ZodSchemaFactory } from '@zenstackhq/orm';\nimport type { BuiltinType, EnumDef, ModelDef, ProcedureDef, SchemaDef, TypeDefDef } from '@zenstackhq/orm/schema';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { RPCApiHandlerOptions } from '.';\nimport { PROCEDURE_ROUTE_PREFIXES } from '../common/procedures';\nimport {\n DEFAULT_SPEC_TITLE,\n DEFAULT_SPEC_VERSION,\n getIncludedModels,\n getMetaDescription,\n isOperationIncluded,\n isProcedureIncluded,\n mayDenyAccess,\n} from '../common/spec-utils';\nimport type { OpenApiSpecOptions } from '../common/types';\n\ntype SchemaObject = OpenAPIV3_1.SchemaObject;\ntype ReferenceObject = OpenAPIV3_1.ReferenceObject;\n\n// Operations that use GET with args in ?q= query parameter\nconst GET_OPERATIONS = new Set<string>([\n 'findFirst',\n 'findUnique',\n 'findMany',\n 'aggregate',\n 'groupBy',\n 'count',\n 'exists',\n]);\n// Operations that use POST with request body (201 on success)\nconst POST_OPERATIONS = new Set<string>(['create', 'createMany', 'createManyAndReturn', 'upsert']);\n// Operations that use PUT with request body\nconst PUT_OPERATIONS = new Set<string>(['update', 'updateMany', 'updateManyAndReturn']);\n// Operations that use DELETE with args in ?q= query parameter\nconst DELETE_OPERATIONS = new Set<string>(['delete', 'deleteMany']);\n\nconst JSON_CT = 'application/json';\n\ntype OperationInfo = {\n summary: (modelName: string) => string;\n dataSchema: (entityRef: ReferenceObject) => SchemaObject | ReferenceObject;\n};\n\n/**\n * Per-operation metadata: human-readable summary and response data schema shape.\n * Operations absent from this map (aggregate, groupBy, count) return a generic schema.\n */\nconst OPERATION_INFO: Record<string, OperationInfo> = {\n findUnique: {\n summary: (m) => `Find a unique ${m}`,\n dataSchema: (ref) => ({ anyOf: [ref, { type: 'null' }] }),\n },\n findFirst: {\n summary: (m) => `Find the first ${m}`,\n dataSchema: (ref) => ({ anyOf: [ref, { type: 'null' }] }),\n },\n findMany: {\n summary: (m) => `List ${m} entities`,\n dataSchema: (ref) => ({ type: 'array', items: ref }),\n },\n create: {\n summary: (m) => `Create a ${m}`,\n dataSchema: (ref) => ref,\n },\n createMany: {\n summary: (m) => `Create multiple ${m} entities`,\n dataSchema: () => ({ type: 'object', properties: { count: { type: 'integer' } }, required: ['count'] }),\n },\n createManyAndReturn: {\n summary: (m) => `Create multiple ${m}s and return them`,\n dataSchema: (ref) => ({ type: 'array', items: ref }),\n },\n update: {\n summary: (m) => `Update a ${m}`,\n dataSchema: (ref) => ref,\n },\n updateMany: {\n summary: (m) => `Update multiple ${m} entities`,\n dataSchema: () => ({ type: 'object', properties: { count: { type: 'integer' } }, required: ['count'] }),\n },\n updateManyAndReturn: {\n summary: (m) => `Update multiple ${m} entities and return them`,\n dataSchema: (ref) => ({ type: 'array', items: ref }),\n },\n upsert: {\n summary: (m) => `Upsert a ${m}`,\n dataSchema: (ref) => ref,\n },\n delete: {\n summary: (m) => `Delete a ${m}`,\n dataSchema: (ref) => ref,\n },\n deleteMany: {\n summary: (m) => `Delete multiple ${m} entities`,\n dataSchema: () => ({ type: 'object', properties: { count: { type: 'integer' } }, required: ['count'] }),\n },\n exists: {\n summary: (m) => `Check ${m} existence`,\n dataSchema: () => ({ type: 'boolean' }),\n },\n};\n\nfunction errorResponse(description: string): OpenAPIV3_1.ResponseObject {\n return {\n description,\n content: {\n [JSON_CT]: {\n schema: { $ref: '#/components/schemas/_rpcErrorResponse' },\n },\n },\n };\n}\n\nconst ERROR_400 = errorResponse('Error occurred while processing the request');\nconst ERROR_403 = errorResponse('Forbidden: insufficient permissions to perform this operation');\nconst ERROR_404 = errorResponse('Resource not found');\nconst ERROR_422 = errorResponse('Operation is unprocessable due to validation errors');\nconst ERROR_500 = errorResponse('Internal server error');\n\n// Operations that may throw NOT_FOUND when the target record does not exist\nconst NOT_FOUND_OPERATIONS = new Set<string>(['update', 'delete']);\n\n/**\n * Generates an OpenAPI v3.1 specification for the RPC-style API handler.\n */\nexport class RPCApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {\n private specOptions?: OpenApiSpecOptions;\n private readonly factory: ZodSchemaFactory<Schema>;\n /**\n * Schemas extracted from the Zod registry, keyed by their registered ID, with\n * all `$ref` values already rewritten to `#/components/schemas/<id>`.\n */\n private registrySchemas: Record<string, SchemaObject> = {};\n\n constructor(private readonly handlerOptions: RPCApiHandlerOptions<Schema>) {\n this.factory = createQuerySchemaFactory(handlerOptions.schema, handlerOptions.queryOptions);\n }\n\n private get schema(): SchemaDef {\n return this.handlerOptions.schema;\n }\n\n private get queryOptions() {\n return this.handlerOptions?.queryOptions;\n }\n\n generateSpec(options?: OpenApiSpecOptions): OpenAPIV3_1.Document {\n this.specOptions = options;\n\n // Build all model/procedure schemas eagerly and capture the full registry as\n // JSON Schema, then transform bare-ID $refs to OpenAPI component paths.\n const rawRegistry = this.factory.toJSONSchema();\n this.registrySchemas = this.transformRegistrySchemas(rawRegistry.schemas);\n\n return {\n openapi: '3.1.0',\n info: {\n title: options?.title ?? DEFAULT_SPEC_TITLE,\n version: options?.version ?? DEFAULT_SPEC_VERSION,\n ...(options?.description && { description: options.description }),\n ...(options?.summary && { summary: options.summary }),\n },\n tags: this.generateTags(),\n paths: this.generatePaths(),\n components: {\n schemas: {\n ...this.registrySchemas,\n ...this.generateSharedSchemas(),\n },\n },\n } as OpenAPIV3_1.Document;\n }\n\n /**\n * Takes the raw `schemas` map from `z.toJSONSchema(registry)` and:\n * 1. Rewrites bare-ID `$ref` values (e.g. `\"UserWhereInput\"`) to full\n * component paths (`\"#/components/schemas/UserWhereInput\"`).\n * 2. Strips the `$schema` keyword from each top-level schema object, as it\n * is redundant inside an OpenAPI document.\n * 3. Resolves Zod's auto-generated `__shared/$defs/schemaN` aliases.\n * When a `__shared/$defs/schemaN` entry is itself a plain `$ref` to a\n * named schema, every reference to it is rewritten to point directly at\n * the target schema, removing the double indirection. Any remaining\n * `__shared` entries (complex shared sub-schemas) are promoted to\n * top-level component schemas with stable names.\n */\n private transformRegistrySchemas(schemas: Record<string, unknown>): Record<string, SchemaObject> {\n let result: Record<string, SchemaObject>;\n\n // Step 1: rewrite bare-ID refs to full component paths, and replace repeated\n // inline integer bound schemas with $refs to shared named schemas.\n // Bare-ID refs produced by the Zod registry look like `\"$ref\":\"SomeName\"`.\n // __shared cross-refs look like `\"$ref\":\"__shared#/$defs/schemaN\"` and are\n // also rewritten here.\n const INT_PATTERN = '{\"type\":\"integer\",\"minimum\":-9007199254740991,\"maximum\":9007199254740991}';\n const NON_NEG_INT_PATTERN = '{\"type\":\"integer\",\"minimum\":0,\"maximum\":9007199254740991}';\n const serialized = JSON.stringify(schemas)\n .replace(/\"(\\$ref)\":\"([^\"#][^\"]*)\"/g, (_, key, id) => `\"${key}\":\"#/components/schemas/${id}\"`)\n .replaceAll(NON_NEG_INT_PATTERN, '{\"$ref\":\"#/components/schemas/_nonNegativeInteger\"}')\n .replaceAll(INT_PATTERN, '{\"$ref\":\"#/components/schemas/_integer\"}');\n result = JSON.parse(serialized) as Record<string, SchemaObject>;\n\n // Step 2: resolve __shared/$defs aliases produced by Zod's deduplication\n // of circular-reference lazy schemas.\n const shared = result['__shared'] as { $defs?: Record<string, SchemaObject> } | undefined;\n if (shared?.$defs) {\n // Build a substitution map: __shared ref → direct target ref (for pure aliases)\n // and collect complex entries that need promotion to top-level.\n const refMap: Record<string, string> = {};\n const promoted: Record<string, SchemaObject> = {};\n\n for (const [key, entry] of Object.entries(shared.$defs)) {\n const sharedRef = `#/components/schemas/__shared#/$defs/${key}`;\n if (entry && typeof entry === 'object' && '$ref' in entry && Object.keys(entry).length === 1) {\n // Pure alias — map it straight to the target.\n refMap[sharedRef] = entry.$ref as string;\n } else {\n // Complex sub-schema — promote to a top-level named schema.\n const promotedName = `_shared_${key}`;\n promoted[promotedName] = entry;\n refMap[sharedRef] = `#/components/schemas/${promotedName}`;\n }\n }\n\n if (Object.keys(refMap).length > 0) {\n // Replace all __shared refs in a single JSON round-trip.\n const escapedKeys = Object.keys(refMap).map((k) => k.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'));\n const pattern = new RegExp(`\"\\\\$ref\":\"(${escapedKeys.join('|')})\"`, 'g');\n const resolved = JSON.stringify(result).replace(pattern, (_, ref) => `\"$ref\":\"${refMap[ref]}\"`);\n result = JSON.parse(resolved) as Record<string, SchemaObject>;\n\n // Remove __shared and add any promoted complex schemas.\n delete result['__shared'];\n Object.assign(result, promoted);\n }\n }\n\n // Step 3: remove the $schema dialect keyword from each top-level entry.\n for (const s of Object.values(result)) {\n if (s && typeof s === 'object') {\n delete (s as Record<string, unknown>)['$schema'];\n }\n }\n\n return result;\n }\n\n private generateTags(): OpenAPIV3_1.TagObject[] {\n return getIncludedModels(this.schema, this.queryOptions).map((modelName) => ({\n name: lowerCaseFirst(modelName),\n description: `${modelName} operations`,\n }));\n }\n\n private generatePaths(): OpenAPIV3_1.PathsObject {\n const paths: OpenAPIV3_1.PathsObject = {};\n\n for (const modelName of getIncludedModels(this.schema, this.queryOptions)) {\n const modelDef = this.schema.models[modelName]!;\n const tag = lowerCaseFirst(modelName);\n\n for (const op of CoreCrudOperations) {\n if (!isOperationIncluded(modelName, op, this.queryOptions)) continue;\n const method = this.getHttpMethod(op);\n const operation = this.buildModelOperation(modelName, modelDef, op, tag);\n paths[`/${lowerCaseFirst(modelName)}/${op}`] = {\n [method]: operation,\n } as OpenAPIV3_1.PathItemObject;\n }\n }\n\n // Procedure paths\n if (this.schema.procedures) {\n for (const [procName, procDef] of Object.entries(this.schema.procedures)) {\n if (!isProcedureIncluded(procName, this.queryOptions)) continue;\n const method = procDef.mutation ? 'post' : 'get';\n paths[`/${PROCEDURE_ROUTE_PREFIXES}/${procName}`] = {\n [method]: this.buildProcedureOperation(procName, procDef, method),\n } as OpenAPIV3_1.PathItemObject;\n }\n }\n\n // Sequential transaction endpoint\n paths['/$transaction/sequential'] = {\n post: this.buildTransactionOperation(),\n } as OpenAPIV3_1.PathItemObject;\n\n return paths;\n }\n\n private getHttpMethod(op: string): string {\n if (GET_OPERATIONS.has(op)) return 'get';\n if (POST_OPERATIONS.has(op)) return 'post';\n if (PUT_OPERATIONS.has(op)) return 'put';\n if (DELETE_OPERATIONS.has(op)) return 'delete';\n return 'post';\n }\n\n /**\n * Returns a JSON Schema `$ref` pointing to the pre-built component schema for\n * the given model+operation, or `undefined` if the schema was not registered\n * (e.g. the operation is not supported for that model).\n */\n private getOperationInputSchemaRef(modelName: string, op: string): ReferenceObject | undefined {\n const id = `${modelName}${upperCaseFirst(op)}Args`;\n return id in this.registrySchemas ? { $ref: `#/components/schemas/${id}` } : undefined;\n }\n\n /**\n * Maps an RPC operation name to its corresponding access policy operation type.\n * Policy attributes use 'read', 'create', 'update', 'delete', 'all'.\n */\n private policyOp(op: string): string {\n if (GET_OPERATIONS.has(op)) return 'read';\n if (DELETE_OPERATIONS.has(op)) return 'delete';\n if (PUT_OPERATIONS.has(op)) return 'update';\n // create/createMany/createManyAndReturn/upsert → 'create'\n return 'create';\n }\n\n private buildModelOperation(\n modelName: string,\n modelDef: ModelDef,\n op: string,\n tag: string,\n ): Record<string, unknown> {\n const isQueryOp = GET_OPERATIONS.has(op) || DELETE_OPERATIONS.has(op);\n const successCode = POST_OPERATIONS.has(op) ? '201' : '200';\n const inputSchemaRef = this.getOperationInputSchemaRef(modelName, op);\n\n const operation: Record<string, unknown> = {\n tags: [tag],\n summary: OPERATION_INFO[op]?.summary(modelName) ?? `${modelName}.${op}`,\n operationId: `${lowerCaseFirst(modelName)}_${op}`,\n responses: {\n [successCode]: {\n description: 'Operation succeeded',\n content: {\n [JSON_CT]: {\n schema: this.buildOperationSuccessSchema(modelName, op),\n },\n },\n },\n '400': ERROR_400,\n ...(NOT_FOUND_OPERATIONS.has(op) && { '404': ERROR_404 }),\n '422': ERROR_422,\n '500': ERROR_500,\n ...(mayDenyAccess(modelDef, this.policyOp(op), this.specOptions?.respectAccessPolicies) && {\n '403': ERROR_403,\n }),\n },\n };\n\n if (inputSchemaRef) {\n if (isQueryOp) {\n // `q` is required when the input schema has required fields (e.g. `where` for delete/findUnique).\n // OAPI 3.1 supports content-typed parameters for structured query values.\n // `meta` is an optional companion to `q` used to carry SuperJSON serialization\n // metadata (see unmarshalQ in api/common/utils.ts).\n const inputSchemaId = `${modelName}${upperCaseFirst(op)}Args`;\n const inputSchema = this.registrySchemas[inputSchemaId];\n const qRequired = Array.isArray(inputSchema?.required) && inputSchema.required.length > 0;\n operation['parameters'] = [\n {\n name: 'q',\n in: 'query',\n ...(qRequired && { required: true }),\n description: `JSON-encoded arguments for ${modelName}.${op}`,\n content: {\n [JSON_CT]: { schema: inputSchemaRef },\n },\n },\n {\n name: 'meta',\n in: 'query',\n description: 'JSON-encoded SuperJSON serialization metadata for the \"q\" parameter',\n schema: { type: 'string' },\n },\n ];\n } else {\n operation['requestBody'] = {\n required: true,\n content: {\n [JSON_CT]: { schema: inputSchemaRef },\n },\n };\n }\n }\n\n return operation;\n }\n\n private buildProcedureOperation(\n procName: string,\n procDef: ProcedureDef,\n method: 'get' | 'post',\n ): Record<string, unknown> {\n const argsSchemaId = `${procName}ProcArgs`;\n const argsSchemaRef: ReferenceObject | SchemaObject =\n argsSchemaId in this.registrySchemas\n ? { $ref: `#/components/schemas/${argsSchemaId}` }\n : { type: 'object' };\n\n // The RPC handler accepts { args: { param1: val, ... } } envelope.\n // `args` is required when the procedure has at least one non-optional parameter\n // (mapProcedureArgs throws 'missing procedure arguments' otherwise).\n const hasRequiredParams = Object.values(procDef.params ?? {}).some((p) => !p.optional);\n const envelopeSchema: SchemaObject = {\n type: 'object',\n properties: { args: argsSchemaRef },\n ...(hasRequiredParams && { required: ['args'] }),\n };\n\n const op: Record<string, unknown> = {\n tags: ['$procs'],\n summary: `Execute procedure \\`${procName}\\``,\n operationId: `proc_${procName}`,\n responses: {\n '200': {\n description: `Result of ${procName}`,\n content: {\n [JSON_CT]: {\n schema: {\n type: 'object',\n properties: {\n data: this.getProcedureDataSchema(procDef),\n meta: {\n type: 'object',\n properties: {\n serialization: {},\n },\n },\n },\n },\n },\n },\n },\n '400': ERROR_400,\n '403': ERROR_403,\n '404': ERROR_404,\n '422': ERROR_422,\n '500': ERROR_500,\n },\n };\n\n const hasParams = Object.keys(procDef.params ?? {}).length > 0;\n if (method === 'get') {\n if (hasParams) {\n op['parameters'] = [\n {\n name: 'q',\n in: 'query',\n ...(hasRequiredParams && { required: true }),\n description: `JSON-encoded arguments for procedure ${procName}`,\n content: {\n [JSON_CT]: { schema: envelopeSchema },\n },\n },\n {\n name: 'meta',\n in: 'query',\n description: 'JSON-encoded SuperJSON serialization metadata for the \"q\" parameter',\n schema: { type: 'string' },\n },\n ];\n }\n } else {\n if (hasParams) {\n op['requestBody'] = {\n ...(hasRequiredParams && { required: true }),\n content: {\n [JSON_CT]: { schema: envelopeSchema },\n },\n };\n }\n }\n\n return op;\n }\n\n private getProcedureDataSchema(procDef: ProcedureDef): SchemaObject | ReferenceObject {\n const { returnType, returnArray } = procDef;\n let base: SchemaObject | ReferenceObject;\n\n if (this.isBuiltinType(returnType)) {\n base = this.builtinTypeToJsonSchema(returnType as BuiltinType);\n } else if (\n this.schema.enums?.[returnType] ||\n this.schema.models?.[returnType] ||\n this.schema.typeDefs?.[returnType]\n ) {\n base = { $ref: `#/components/schemas/${returnType}` };\n } else {\n base = {};\n }\n\n return returnArray ? { type: 'array', items: base } : base;\n }\n\n private buildTransactionOperation(): Record<string, unknown> {\n return {\n tags: ['$transaction'],\n summary: 'Execute a sequential transaction',\n operationId: 'transaction_sequential',\n requestBody: {\n required: true,\n content: {\n [JSON_CT]: {\n schema: { $ref: '#/components/schemas/_rpcTransactionRequest' },\n },\n },\n },\n responses: {\n '200': {\n description: 'Transaction succeeded',\n content: {\n [JSON_CT]: {\n schema: { $ref: '#/components/schemas/_rpcSuccessResponse' },\n },\n },\n },\n '400': ERROR_400,\n '403': ERROR_403,\n '404': ERROR_404,\n '422': ERROR_422,\n '500': ERROR_500,\n },\n };\n }\n\n private generateSharedSchemas(): Record<string, SchemaObject> {\n // Generate schemas for enums\n const enumSchemas: Record<string, SchemaObject> = {};\n for (const [enumName, enumDef] of Object.entries(this.schema.enums ?? {})) {\n enumSchemas[enumName] = this.buildEnumSchema(enumDef);\n }\n\n // Generate schemas for typedefs (e.g. `type Address { city String }`)\n const typeDefSchemas: Record<string, SchemaObject> = {};\n for (const [typeName, typeDef] of Object.entries(this.schema.typeDefs ?? {})) {\n typeDefSchemas[typeName] = this.buildTypeDefSchema(typeDef);\n }\n\n // Generate a response-side entity schema for every included model\n const modelEntitySchemas: Record<string, SchemaObject> = {};\n for (const modelName of getIncludedModels(this.schema as SchemaDef, this.queryOptions)) {\n modelEntitySchemas[modelName] = this.buildModelEntitySchema(this.schema.models[modelName]!);\n }\n\n return {\n ...enumSchemas,\n ...typeDefSchemas,\n ...modelEntitySchemas,\n _integer: { type: 'integer', minimum: -9007199254740991, maximum: 9007199254740991 },\n _nonNegativeInteger: { type: 'integer', minimum: 0, maximum: 9007199254740991 },\n _rpcSuccessResponse: {\n type: 'object',\n properties: {\n data: {},\n meta: {\n type: 'object',\n properties: {\n serialization: {},\n },\n },\n },\n },\n _rpcErrorResponse: {\n type: 'object',\n properties: {\n error: {\n type: 'object',\n properties: {\n message: { type: 'string' },\n reason: { type: 'string' },\n model: { type: 'string' },\n rejectedByPolicy: { type: 'boolean' },\n rejectedByValidation: { type: 'boolean' },\n rejectReason: { type: 'string' },\n dbErrorCode: { type: 'string' },\n },\n required: ['message'],\n },\n },\n required: ['error'],\n },\n _rpcTransactionRequest: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n model: { type: 'string' },\n op: {\n type: 'string',\n enum: [...CoreCrudOperations],\n },\n args: { type: 'object' },\n },\n required: ['model', 'op'],\n },\n },\n };\n }\n\n private builtinTypeToJsonSchema(type: BuiltinType): SchemaObject {\n switch (type) {\n case 'String':\n return { type: 'string' };\n case 'Boolean':\n return { type: 'boolean' };\n case 'Int':\n return { type: 'integer' };\n case 'Float':\n return { type: 'number' };\n case 'BigInt':\n return { type: 'integer' };\n case 'Decimal':\n return { type: 'string' };\n case 'DateTime':\n return { type: 'string', format: 'date-time' };\n case 'Bytes':\n return { type: 'string', format: 'byte' };\n default:\n // Json, Unsupported\n return {};\n }\n }\n\n private isBuiltinType(type: string): boolean {\n return [\n 'String',\n 'Boolean',\n 'Int',\n 'Float',\n 'BigInt',\n 'Decimal',\n 'DateTime',\n 'Bytes',\n 'Json',\n 'Unsupported',\n ].includes(type);\n }\n\n /**\n * Builds a JSON Schema object describing a custom typedef\n */\n private buildEnumSchema(enumDef: EnumDef): SchemaObject {\n return { type: 'string', enum: Object.values(enumDef.values) };\n }\n\n private buildTypeDefSchema(typeDef: TypeDefDef): SchemaObject {\n const properties: Record<string, SchemaObject | ReferenceObject> = {};\n const required: string[] = [];\n for (const [fieldName, fieldDef] of Object.entries(typeDef.fields)) {\n const isRef =\n !this.isBuiltinType(fieldDef.type) &&\n (this.schema.enums?.[fieldDef.type] || this.schema.typeDefs?.[fieldDef.type]);\n const base: SchemaObject | ReferenceObject = this.isBuiltinType(fieldDef.type)\n ? this.builtinTypeToJsonSchema(fieldDef.type as BuiltinType)\n : isRef\n ? { $ref: `#/components/schemas/${fieldDef.type}` }\n : { type: 'object' as const };\n const fieldDesc = getMetaDescription(fieldDef.attributes);\n if (fieldDesc && !isRef) {\n (base as SchemaObject).description = fieldDesc;\n }\n const typed: SchemaObject | ReferenceObject = fieldDef.array ? { type: 'array', items: base } : base;\n properties[fieldName] = fieldDef.optional ? { anyOf: [typed, { type: 'null' }] } : typed;\n if (!fieldDef.optional) required.push(fieldName);\n }\n const schema: SchemaObject = { type: 'object', properties };\n if (required.length > 0) schema['required'] = required;\n return schema;\n }\n\n /**\n * Builds a JSON Schema object describing a model entity\n */\n private buildModelEntitySchema(modelDef: ModelDef): SchemaObject {\n const properties: Record<string, SchemaObject | ReferenceObject> = {};\n const required: string[] = [];\n\n for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) {\n if (fieldDef.omit) continue;\n\n if (fieldDef.relation) {\n // Relation fields appear only with `include` — mark as optional.\n // To-one optional relations are nullable (the ORM returns null when not found).\n const refSchema: ReferenceObject = { $ref: `#/components/schemas/${fieldDef.type}` };\n const base: SchemaObject | ReferenceObject = fieldDef.array\n ? { type: 'array', items: refSchema }\n : refSchema;\n properties[fieldName] =\n !fieldDef.array && fieldDef.optional ? { anyOf: [base, { type: 'null' }] } : base;\n } else if (this.schema.enums?.[fieldDef.type]) {\n // Enum field\n const refSchema: ReferenceObject = { $ref: `#/components/schemas/${fieldDef.type}` };\n const base: SchemaObject | ReferenceObject = fieldDef.array\n ? { type: 'array', items: refSchema }\n : refSchema;\n properties[fieldName] = fieldDef.optional ? { anyOf: [base, { type: 'null' }] } : base;\n required.push(fieldName);\n } else if (this.isBuiltinType(fieldDef.type)) {\n // Scalar builtin field\n const base = this.builtinTypeToJsonSchema(fieldDef.type as BuiltinType);\n const fieldDesc = getMetaDescription(fieldDef.attributes);\n if (fieldDesc) base.description = fieldDesc;\n const typed: SchemaObject = fieldDef.array ? { type: 'array', items: base } : base;\n properties[fieldName] = fieldDef.optional ? { anyOf: [typed, { type: 'null' }] } : typed;\n required.push(fieldName);\n } else if (this.schema.typeDefs?.[fieldDef.type]) {\n // TypeDef field — reference the registered typedef schema\n const refSchema: ReferenceObject = { $ref: `#/components/schemas/${fieldDef.type}` };\n const base: SchemaObject | ReferenceObject = fieldDef.array\n ? { type: 'array', items: refSchema }\n : refSchema;\n properties[fieldName] = fieldDef.optional ? { anyOf: [base, { type: 'null' }] } : base;\n required.push(fieldName);\n } else {\n // Unknown type — represent as a generic object\n const typed: SchemaObject = fieldDef.array\n ? { type: 'array', items: { type: 'object' } }\n : { type: 'object' };\n properties[fieldName] = typed;\n required.push(fieldName);\n }\n }\n\n const schema: SchemaObject = { type: 'object', properties };\n if (required.length > 0) {\n schema['required'] = required;\n }\n const modelDesc = getMetaDescription(modelDef.attributes);\n if (modelDesc) schema.description = modelDesc;\n return schema;\n }\n\n private buildOperationSuccessSchema(modelName: string, op: string): SchemaObject {\n const entityRef: ReferenceObject = { $ref: `#/components/schemas/${modelName}` };\n // aggregate, groupBy, count shapes depend on query args — leave generic ({})\n const dataSchema = OPERATION_INFO[op]?.dataSchema(entityRef) ?? {};\n return {\n type: 'object',\n properties: {\n data: dataSchema,\n meta: {\n type: 'object',\n properties: {\n serialization: {},\n },\n },\n },\n };\n }\n}\n"],"mappings":";;;;;AAqBA,MAAM,iBAAiB,IAAI,IAAY;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACH,CAAC;AAEF,MAAM,kBAAkB,IAAI,IAAY;CAAC;CAAU;CAAc;CAAuB;CAAS,CAAC;AAElG,MAAM,iBAAiB,IAAI,IAAY;CAAC;CAAU;CAAc;CAAsB,CAAC;AAEvF,MAAM,oBAAoB,IAAI,IAAY,CAAC,UAAU,aAAa,CAAC;AAEnE,MAAM,UAAU;;;;;AAWhB,MAAM,iBAAgD;CAClD,YAAY;EACR,UAAU,MAAM,iBAAiB;EACjC,aAAa,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,QAAQ,CAAC,EAAE;EAC3D;CACD,WAAW;EACP,UAAU,MAAM,kBAAkB;EAClC,aAAa,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,QAAQ,CAAC,EAAE;EAC3D;CACD,UAAU;EACN,UAAU,MAAM,QAAQ,EAAE;EAC1B,aAAa,SAAS;GAAE,MAAM;GAAS,OAAO;GAAK;EACtD;CACD,QAAQ;EACJ,UAAU,MAAM,YAAY;EAC5B,aAAa,QAAQ;EACxB;CACD,YAAY;EACR,UAAU,MAAM,mBAAmB,EAAE;EACrC,mBAAmB;GAAE,MAAM;GAAU,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,EAAE;GAAE,UAAU,CAAC,QAAQ;GAAE;EACzG;CACD,qBAAqB;EACjB,UAAU,MAAM,mBAAmB,EAAE;EACrC,aAAa,SAAS;GAAE,MAAM;GAAS,OAAO;GAAK;EACtD;CACD,QAAQ;EACJ,UAAU,MAAM,YAAY;EAC5B,aAAa,QAAQ;EACxB;CACD,YAAY;EACR,UAAU,MAAM,mBAAmB,EAAE;EACrC,mBAAmB;GAAE,MAAM;GAAU,YAAY,EAAE,OAAO,E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,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,QAAQ,CAAC,EAAE,GAAG;AACnF,aAAS,KAAK,UAAU;cACjB,KAAK,OAAO,WAAW,SAAS,OAAO;IAE9C,MAAM,YAA6B,EAAE,MAAM,wBAAwB,SAAS,QAAQ;IACpF,MAAM,OAAuC,SAAS,QAChD;KAAE,MAAM;KAAS,OAAO;KAAW,GACnC;AACN,eAAW,aAAa,SAAS,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,GAAG;AAClF,aAAS,KAAK,UAAU;UACrB;AAKH,eAAW,aAHiB,SAAS,QAC/B;KAAE,MAAM;KAAS,OAAO,EAAE,MAAM,UAAU;KAAE,GAC5C,EAAE,MAAM,UAAU;AAExB,aAAS,KAAK,UAAU;;;EAIhC,MAAM,SAAuB;GAAE,MAAM;GAAU;GAAY;AAC3D,MAAI,SAAS,SAAS,EAClB,QAAO,cAAc;EAEzB,MAAM,YAAYA,mBAAAA,mBAAmB,SAAS,WAAW;AACzD,MAAI,UAAW,QAAO,cAAc;AACpC,SAAO;;CAGX,4BAAoC,WAAmB,IAA0B;EAC7E,MAAM,YAA6B,EAAE,MAAM,wBAAwB,aAAa;AAGhF,SAAO;GACH,MAAM;GACN,YAAY;IACR,MAJW,eAAe,KAAK,WAAW,UAAU,IAAI,EAAE;IAK1D,MAAM;KACF,MAAM;KACN,YAAY,EACR,eAAe,EAAE,EACpB;KACJ;IACJ;GACJ"}
|
|
1
|
+
{"version":3,"file":"openapi-DhZIh0Ga.cjs","names":["getIncludedModels","CoreCrudOperations","isOperationIncluded","isProcedureIncluded","PROCEDURE_ROUTE_PREFIXES","mayDenyAccess","getMetaDescription"],"sources":["../src/api/rpc/openapi.ts"],"sourcesContent":["import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/common-helpers';\nimport { CoreCrudOperations, createQuerySchemaFactory, type ZodSchemaFactory } from '@zenstackhq/orm';\nimport type { BuiltinType, EnumDef, ModelDef, ProcedureDef, SchemaDef, TypeDefDef } from '@zenstackhq/orm/schema';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { RPCApiHandlerOptions } from '.';\nimport { PROCEDURE_ROUTE_PREFIXES } from '../common/procedures';\nimport {\n DEFAULT_SPEC_TITLE,\n DEFAULT_SPEC_VERSION,\n getIncludedModels,\n getMetaDescription,\n isOperationIncluded,\n isProcedureIncluded,\n mayDenyAccess,\n} from '../common/spec-utils';\nimport type { OpenApiSpecOptions } from '../common/types';\n\ntype SchemaObject = OpenAPIV3_1.SchemaObject;\ntype ReferenceObject = OpenAPIV3_1.ReferenceObject;\n\n// Operations that use GET with args in ?q= query parameter\nconst GET_OPERATIONS = new Set<string>([\n 'findFirst',\n 'findUnique',\n 'findMany',\n 'aggregate',\n 'groupBy',\n 'count',\n 'exists',\n]);\n// Operations that use POST with request body (201 on success)\nconst POST_OPERATIONS = new Set<string>(['create', 'createMany', 'createManyAndReturn', 'upsert']);\n// Operations that use PUT with request body\nconst PUT_OPERATIONS = new Set<string>(['update', 'updateMany', 'updateManyAndReturn']);\n// Operations that use DELETE with args in ?q= query parameter\nconst DELETE_OPERATIONS = new Set<string>(['delete', 'deleteMany']);\n\nconst JSON_CT = 'application/json';\n\ntype OperationInfo = {\n summary: (modelName: string) => string;\n dataSchema: (entityRef: ReferenceObject) => SchemaObject | ReferenceObject;\n};\n\n/**\n * Per-operation metadata: human-readable summary and response data schema shape.\n * Operations absent from this map (aggregate, groupBy, count) return a generic schema.\n */\nconst OPERATION_INFO: Record<string, OperationInfo> = {\n findUnique: {\n summary: (m) => `Find a unique ${m}`,\n dataSchema: (ref) => ({ anyOf: [ref, { type: 'null' }] }),\n },\n findFirst: {\n summary: (m) => `Find the first ${m}`,\n dataSchema: (ref) => ({ anyOf: [ref, { type: 'null' }] }),\n },\n findMany: {\n summary: (m) => `List ${m} entities`,\n dataSchema: (ref) => ({ type: 'array', items: ref }),\n },\n create: {\n summary: (m) => `Create a ${m}`,\n dataSchema: (ref) => ref,\n },\n createMany: {\n summary: (m) => `Create multiple ${m} entities`,\n dataSchema: () => ({ type: 'object', properties: { count: { type: 'integer' } }, required: ['count'] }),\n },\n createManyAndReturn: {\n summary: (m) => `Create multiple ${m}s and return them`,\n dataSchema: (ref) => ({ type: 'array', items: ref }),\n },\n update: {\n summary: (m) => `Update a ${m}`,\n dataSchema: (ref) => ref,\n },\n updateMany: {\n summary: (m) => `Update multiple ${m} entities`,\n dataSchema: () => ({ type: 'object', properties: { count: { type: 'integer' } }, required: ['count'] }),\n },\n updateManyAndReturn: {\n summary: (m) => `Update multiple ${m} entities and return them`,\n dataSchema: (ref) => ({ type: 'array', items: ref }),\n },\n upsert: {\n summary: (m) => `Upsert a ${m}`,\n dataSchema: (ref) => ref,\n },\n delete: {\n summary: (m) => `Delete a ${m}`,\n dataSchema: (ref) => ref,\n },\n deleteMany: {\n summary: (m) => `Delete multiple ${m} entities`,\n dataSchema: () => ({ type: 'object', properties: { count: { type: 'integer' } }, required: ['count'] }),\n },\n exists: {\n summary: (m) => `Check ${m} existence`,\n dataSchema: () => ({ type: 'boolean' }),\n },\n};\n\nfunction errorResponse(description: string): OpenAPIV3_1.ResponseObject {\n return {\n description,\n content: {\n [JSON_CT]: {\n schema: { $ref: '#/components/schemas/_rpcErrorResponse' },\n },\n },\n };\n}\n\nconst ERROR_400 = errorResponse('Error occurred while processing the request');\nconst ERROR_403 = errorResponse('Forbidden: insufficient permissions to perform this operation');\nconst ERROR_404 = errorResponse('Resource not found');\nconst ERROR_422 = errorResponse('Operation is unprocessable due to validation errors');\nconst ERROR_500 = errorResponse('Internal server error');\n\n// Operations that may throw NOT_FOUND when the target record does not exist\nconst NOT_FOUND_OPERATIONS = new Set<string>(['update', 'delete']);\n\n/**\n * Generates an OpenAPI v3.1 specification for the RPC-style API handler.\n */\nexport class RPCApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {\n private specOptions?: OpenApiSpecOptions;\n private readonly factory: ZodSchemaFactory<Schema>;\n /**\n * Schemas extracted from the Zod registry, keyed by their registered ID, with\n * all `$ref` values already rewritten to `#/components/schemas/<id>`.\n */\n private registrySchemas: Record<string, SchemaObject> = {};\n\n constructor(private readonly handlerOptions: RPCApiHandlerOptions<Schema>) {\n this.factory = createQuerySchemaFactory(handlerOptions.schema, handlerOptions.queryOptions);\n }\n\n private get schema(): SchemaDef {\n return this.handlerOptions.schema;\n }\n\n private get queryOptions() {\n return this.handlerOptions?.queryOptions;\n }\n\n generateSpec(options?: OpenApiSpecOptions): OpenAPIV3_1.Document {\n this.specOptions = options;\n\n // Build all model/procedure schemas eagerly and capture the full registry as\n // JSON Schema, then transform bare-ID $refs to OpenAPI component paths.\n const rawRegistry = this.factory.toJSONSchema();\n this.registrySchemas = this.transformRegistrySchemas(rawRegistry.schemas);\n\n return {\n openapi: '3.1.0',\n info: {\n title: options?.title ?? DEFAULT_SPEC_TITLE,\n version: options?.version ?? DEFAULT_SPEC_VERSION,\n ...(options?.description && { description: options.description }),\n ...(options?.summary && { summary: options.summary }),\n },\n tags: this.generateTags(),\n paths: this.generatePaths(),\n components: {\n schemas: {\n ...this.registrySchemas,\n ...this.generateSharedSchemas(),\n },\n },\n } as OpenAPIV3_1.Document;\n }\n\n /**\n * Takes the raw `schemas` map from `z.toJSONSchema(registry)` and:\n * 1. Rewrites bare-ID `$ref` values (e.g. `\"UserWhereInput\"`) to full\n * component paths (`\"#/components/schemas/UserWhereInput\"`).\n * 2. Strips the `$schema` keyword from each top-level schema object, as it\n * is redundant inside an OpenAPI document.\n * 3. Resolves Zod's auto-generated `__shared/$defs/schemaN` aliases.\n * When a `__shared/$defs/schemaN` entry is itself a plain `$ref` to a\n * named schema, every reference to it is rewritten to point directly at\n * the target schema, removing the double indirection. Any remaining\n * `__shared` entries (complex shared sub-schemas) are promoted to\n * top-level component schemas with stable names.\n */\n private transformRegistrySchemas(schemas: Record<string, unknown>): Record<string, SchemaObject> {\n let result: Record<string, SchemaObject>;\n\n // Step 1: rewrite bare-ID refs to full component paths, and replace repeated\n // inline integer bound schemas with $refs to shared named schemas.\n // Bare-ID refs produced by the Zod registry look like `\"$ref\":\"SomeName\"`.\n // __shared cross-refs look like `\"$ref\":\"__shared#/$defs/schemaN\"` and are\n // also rewritten here.\n const INT_PATTERN = '{\"type\":\"integer\",\"minimum\":-9007199254740991,\"maximum\":9007199254740991}';\n const NON_NEG_INT_PATTERN = '{\"type\":\"integer\",\"minimum\":0,\"maximum\":9007199254740991}';\n const serialized = JSON.stringify(schemas)\n .replace(/\"(\\$ref)\":\"([^\"#][^\"]*)\"/g, (_, key, id) => `\"${key}\":\"#/components/schemas/${id}\"`)\n .replaceAll(NON_NEG_INT_PATTERN, '{\"$ref\":\"#/components/schemas/_nonNegativeInteger\"}')\n .replaceAll(INT_PATTERN, '{\"$ref\":\"#/components/schemas/_integer\"}');\n result = JSON.parse(serialized) as Record<string, SchemaObject>;\n\n // Step 2: resolve __shared/$defs aliases produced by Zod's deduplication\n // of circular-reference lazy schemas.\n const shared = result['__shared'] as { $defs?: Record<string, SchemaObject> } | undefined;\n if (shared?.$defs) {\n // Build a substitution map: __shared ref → direct target ref (for pure aliases)\n // and collect complex entries that need promotion to top-level.\n const refMap: Record<string, string> = {};\n const promoted: Record<string, SchemaObject> = {};\n\n for (const [key, entry] of Object.entries(shared.$defs)) {\n const sharedRef = `#/components/schemas/__shared#/$defs/${key}`;\n if (entry && typeof entry === 'object' && '$ref' in entry && Object.keys(entry).length === 1) {\n // Pure alias — map it straight to the target.\n refMap[sharedRef] = entry.$ref as string;\n } else {\n // Complex sub-schema — promote to a top-level named schema.\n const promotedName = `_shared_${key}`;\n promoted[promotedName] = entry;\n refMap[sharedRef] = `#/components/schemas/${promotedName}`;\n }\n }\n\n if (Object.keys(refMap).length > 0) {\n // Replace all __shared refs in a single JSON round-trip.\n const escapedKeys = Object.keys(refMap).map((k) => k.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'));\n const pattern = new RegExp(`\"\\\\$ref\":\"(${escapedKeys.join('|')})\"`, 'g');\n const resolved = JSON.stringify(result).replace(pattern, (_, ref) => `\"$ref\":\"${refMap[ref]}\"`);\n result = JSON.parse(resolved) as Record<string, SchemaObject>;\n\n // Remove __shared and add any promoted complex schemas.\n delete result['__shared'];\n Object.assign(result, promoted);\n }\n }\n\n // Step 3: remove the $schema dialect keyword from each top-level entry.\n for (const s of Object.values(result)) {\n if (s && typeof s === 'object') {\n delete (s as Record<string, unknown>)['$schema'];\n }\n }\n\n return result;\n }\n\n private generateTags(): OpenAPIV3_1.TagObject[] {\n return getIncludedModels(this.schema, this.queryOptions).map((modelName) => ({\n name: lowerCaseFirst(modelName),\n description: `${modelName} operations`,\n }));\n }\n\n private generatePaths(): OpenAPIV3_1.PathsObject {\n const paths: OpenAPIV3_1.PathsObject = {};\n\n for (const modelName of getIncludedModels(this.schema, this.queryOptions)) {\n const modelDef = this.schema.models[modelName]!;\n const tag = lowerCaseFirst(modelName);\n\n for (const op of CoreCrudOperations) {\n if (!isOperationIncluded(modelName, op, this.queryOptions)) continue;\n const method = this.getHttpMethod(op);\n const operation = this.buildModelOperation(modelName, modelDef, op, tag);\n paths[`/${lowerCaseFirst(modelName)}/${op}`] = {\n [method]: operation,\n } as OpenAPIV3_1.PathItemObject;\n }\n }\n\n // Procedure paths\n if (this.schema.procedures) {\n for (const [procName, procDef] of Object.entries(this.schema.procedures)) {\n if (!isProcedureIncluded(procName, this.queryOptions)) continue;\n const method = procDef.mutation ? 'post' : 'get';\n paths[`/${PROCEDURE_ROUTE_PREFIXES}/${procName}`] = {\n [method]: this.buildProcedureOperation(procName, procDef, method),\n } as OpenAPIV3_1.PathItemObject;\n }\n }\n\n // Sequential transaction endpoint\n paths['/$transaction/sequential'] = {\n post: this.buildTransactionOperation(),\n } as OpenAPIV3_1.PathItemObject;\n\n return paths;\n }\n\n private getHttpMethod(op: string): string {\n if (GET_OPERATIONS.has(op)) return 'get';\n if (POST_OPERATIONS.has(op)) return 'post';\n if (PUT_OPERATIONS.has(op)) return 'put';\n if (DELETE_OPERATIONS.has(op)) return 'delete';\n return 'post';\n }\n\n /**\n * Returns a JSON Schema `$ref` pointing to the pre-built component schema for\n * the given model+operation, or `undefined` if the schema was not registered\n * (e.g. the operation is not supported for that model).\n */\n private getOperationInputSchemaRef(modelName: string, op: string): ReferenceObject | undefined {\n const id = `${modelName}${upperCaseFirst(op)}Args`;\n return id in this.registrySchemas ? { $ref: `#/components/schemas/${id}` } : undefined;\n }\n\n /**\n * Maps an RPC operation name to its corresponding access policy operation type.\n * Policy attributes use 'read', 'create', 'update', 'delete', 'all'.\n */\n private policyOp(op: string): string {\n if (GET_OPERATIONS.has(op)) return 'read';\n if (DELETE_OPERATIONS.has(op)) return 'delete';\n if (PUT_OPERATIONS.has(op)) return 'update';\n // create/createMany/createManyAndReturn/upsert → 'create'\n return 'create';\n }\n\n private buildModelOperation(\n modelName: string,\n modelDef: ModelDef,\n op: string,\n tag: string,\n ): Record<string, unknown> {\n const isQueryOp = GET_OPERATIONS.has(op) || DELETE_OPERATIONS.has(op);\n const successCode = POST_OPERATIONS.has(op) ? '201' : '200';\n const inputSchemaRef = this.getOperationInputSchemaRef(modelName, op);\n\n const operation: Record<string, unknown> = {\n tags: [tag],\n summary: OPERATION_INFO[op]?.summary(modelName) ?? `${modelName}.${op}`,\n operationId: `${lowerCaseFirst(modelName)}_${op}`,\n responses: {\n [successCode]: {\n description: 'Operation succeeded',\n content: {\n [JSON_CT]: {\n schema: this.buildOperationSuccessSchema(modelName, op),\n },\n },\n },\n '400': ERROR_400,\n ...(NOT_FOUND_OPERATIONS.has(op) && { '404': ERROR_404 }),\n '422': ERROR_422,\n '500': ERROR_500,\n ...(mayDenyAccess(modelDef, this.policyOp(op), this.specOptions?.respectAccessPolicies) && {\n '403': ERROR_403,\n }),\n },\n };\n\n if (inputSchemaRef) {\n if (isQueryOp) {\n // `q` is required when the input schema has required fields (e.g. `where` for delete/findUnique).\n // OAPI 3.1 supports content-typed parameters for structured query values.\n // `meta` is an optional companion to `q` used to carry SuperJSON serialization\n // metadata (see unmarshalQ in api/common/utils.ts).\n const inputSchemaId = `${modelName}${upperCaseFirst(op)}Args`;\n const inputSchema = this.registrySchemas[inputSchemaId];\n const qRequired = Array.isArray(inputSchema?.required) && inputSchema.required.length > 0;\n operation['parameters'] = [\n {\n name: 'q',\n in: 'query',\n ...(qRequired && { required: true }),\n description: `JSON-encoded arguments for ${modelName}.${op}`,\n content: {\n [JSON_CT]: { schema: inputSchemaRef },\n },\n },\n {\n name: 'meta',\n in: 'query',\n description: 'JSON-encoded SuperJSON serialization metadata for the \"q\" parameter',\n schema: { type: 'string' },\n },\n ];\n } else {\n operation['requestBody'] = {\n required: true,\n content: {\n [JSON_CT]: { schema: inputSchemaRef },\n },\n };\n }\n }\n\n return operation;\n }\n\n private buildProcedureOperation(\n procName: string,\n procDef: ProcedureDef,\n method: 'get' | 'post',\n ): Record<string, unknown> {\n const argsSchemaId = `${procName}ProcArgs`;\n const argsSchemaRef: ReferenceObject | SchemaObject =\n argsSchemaId in this.registrySchemas\n ? { $ref: `#/components/schemas/${argsSchemaId}` }\n : { type: 'object' };\n\n // The RPC handler accepts { args: { param1: val, ... } } envelope.\n // `args` is required when the procedure has at least one non-optional parameter\n // (mapProcedureArgs throws 'missing procedure arguments' otherwise).\n const hasRequiredParams = Object.values(procDef.params ?? {}).some((p) => !p.optional);\n const envelopeSchema: SchemaObject = {\n type: 'object',\n properties: { args: argsSchemaRef },\n ...(hasRequiredParams && { required: ['args'] }),\n };\n\n const op: Record<string, unknown> = {\n tags: ['$procs'],\n summary: `Execute procedure \\`${procName}\\``,\n operationId: `proc_${procName}`,\n responses: {\n '200': {\n description: `Result of ${procName}`,\n content: {\n [JSON_CT]: {\n schema: {\n type: 'object',\n properties: {\n data: this.getProcedureDataSchema(procDef),\n meta: {\n type: 'object',\n properties: {\n serialization: {},\n },\n },\n },\n },\n },\n },\n },\n '400': ERROR_400,\n '403': ERROR_403,\n '404': ERROR_404,\n '422': ERROR_422,\n '500': ERROR_500,\n },\n };\n\n const hasParams = Object.keys(procDef.params ?? {}).length > 0;\n if (method === 'get') {\n if (hasParams) {\n op['parameters'] = [\n {\n name: 'q',\n in: 'query',\n ...(hasRequiredParams && { required: true }),\n description: `JSON-encoded arguments for procedure ${procName}`,\n content: {\n [JSON_CT]: { schema: envelopeSchema },\n },\n },\n {\n name: 'meta',\n in: 'query',\n description: 'JSON-encoded SuperJSON serialization metadata for the \"q\" parameter',\n schema: { type: 'string' },\n },\n ];\n }\n } else {\n if (hasParams) {\n op['requestBody'] = {\n ...(hasRequiredParams && { required: true }),\n content: {\n [JSON_CT]: { schema: envelopeSchema },\n },\n };\n }\n }\n\n return op;\n }\n\n private getProcedureDataSchema(procDef: ProcedureDef): SchemaObject | ReferenceObject {\n const { returnType, returnArray } = procDef;\n let base: SchemaObject | ReferenceObject;\n\n if (this.isBuiltinType(returnType)) {\n base = this.builtinTypeToJsonSchema(returnType as BuiltinType);\n } else if (\n this.schema.enums?.[returnType] ||\n this.schema.models?.[returnType] ||\n this.schema.typeDefs?.[returnType]\n ) {\n base = { $ref: `#/components/schemas/${returnType}` };\n } else {\n base = {};\n }\n\n return returnArray ? { type: 'array', items: base } : base;\n }\n\n private buildTransactionOperation(): Record<string, unknown> {\n return {\n tags: ['$transaction'],\n summary: 'Execute a sequential transaction',\n operationId: 'transaction_sequential',\n requestBody: {\n required: true,\n content: {\n [JSON_CT]: {\n schema: { $ref: '#/components/schemas/_rpcTransactionRequest' },\n },\n },\n },\n responses: {\n '200': {\n description: 'Transaction succeeded',\n content: {\n [JSON_CT]: {\n schema: { $ref: '#/components/schemas/_rpcSuccessResponse' },\n },\n },\n },\n '400': ERROR_400,\n '403': ERROR_403,\n '404': ERROR_404,\n '422': ERROR_422,\n '500': ERROR_500,\n },\n };\n }\n\n private generateSharedSchemas(): Record<string, SchemaObject> {\n // Generate schemas for enums\n const enumSchemas: Record<string, SchemaObject> = {};\n for (const [enumName, enumDef] of Object.entries(this.schema.enums ?? {})) {\n enumSchemas[enumName] = this.buildEnumSchema(enumDef);\n }\n\n // Generate schemas for typedefs (e.g. `type Address { city String }`)\n const typeDefSchemas: Record<string, SchemaObject> = {};\n for (const [typeName, typeDef] of Object.entries(this.schema.typeDefs ?? {})) {\n typeDefSchemas[typeName] = this.buildTypeDefSchema(typeDef);\n }\n\n // Generate a response-side entity schema for every included model\n const modelEntitySchemas: Record<string, SchemaObject> = {};\n for (const modelName of getIncludedModels(this.schema as SchemaDef, this.queryOptions)) {\n modelEntitySchemas[modelName] = this.buildModelEntitySchema(this.schema.models[modelName]!);\n }\n\n return {\n ...enumSchemas,\n ...typeDefSchemas,\n ...modelEntitySchemas,\n _integer: { type: 'integer', minimum: -9007199254740991, maximum: 9007199254740991 },\n _nonNegativeInteger: { type: 'integer', minimum: 0, maximum: 9007199254740991 },\n _rpcSuccessResponse: {\n type: 'object',\n properties: {\n data: {},\n meta: {\n type: 'object',\n properties: {\n serialization: {},\n },\n },\n },\n },\n _rpcErrorResponse: {\n type: 'object',\n properties: {\n error: {\n type: 'object',\n properties: {\n message: { type: 'string' },\n reason: { type: 'string' },\n model: { type: 'string' },\n rejectedByPolicy: { type: 'boolean' },\n rejectedByValidation: { type: 'boolean' },\n rejectReason: { type: 'string' },\n dbErrorCode: { type: 'string' },\n },\n required: ['message'],\n },\n },\n required: ['error'],\n },\n _rpcTransactionRequest: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n model: { type: 'string' },\n op: {\n type: 'string',\n enum: [...CoreCrudOperations],\n },\n args: { type: 'object' },\n },\n required: ['model', 'op'],\n },\n },\n };\n }\n\n private builtinTypeToJsonSchema(type: BuiltinType): SchemaObject {\n switch (type) {\n case 'String':\n return { type: 'string' };\n case 'Boolean':\n return { type: 'boolean' };\n case 'Int':\n return { type: 'integer' };\n case 'Float':\n return { type: 'number' };\n case 'BigInt':\n return { type: 'integer' };\n case 'Decimal':\n return { type: 'string' };\n case 'DateTime':\n return { type: 'string', format: 'date-time' };\n case 'Bytes':\n return { type: 'string', format: 'byte' };\n default:\n // Json, Unsupported\n return {};\n }\n }\n\n private isBuiltinType(type: string): boolean {\n return [\n 'String',\n 'Boolean',\n 'Int',\n 'Float',\n 'BigInt',\n 'Decimal',\n 'DateTime',\n 'Bytes',\n 'Json',\n 'Unsupported',\n ].includes(type);\n }\n\n /**\n * Builds a JSON Schema object describing a custom typedef\n */\n private buildEnumSchema(enumDef: EnumDef): SchemaObject {\n return { type: 'string', enum: Object.values(enumDef.values) };\n }\n\n private buildTypeDefSchema(typeDef: TypeDefDef): SchemaObject {\n const properties: Record<string, SchemaObject | ReferenceObject> = {};\n const required: string[] = [];\n for (const [fieldName, fieldDef] of Object.entries(typeDef.fields)) {\n const isRef =\n !this.isBuiltinType(fieldDef.type) &&\n (this.schema.enums?.[fieldDef.type] || this.schema.typeDefs?.[fieldDef.type]);\n const base: SchemaObject | ReferenceObject = this.isBuiltinType(fieldDef.type)\n ? this.builtinTypeToJsonSchema(fieldDef.type as BuiltinType)\n : isRef\n ? { $ref: `#/components/schemas/${fieldDef.type}` }\n : { type: 'object' as const };\n const fieldDesc = getMetaDescription(fieldDef.attributes);\n if (fieldDesc && !isRef) {\n (base as SchemaObject).description = fieldDesc;\n }\n const typed: SchemaObject | ReferenceObject = fieldDef.array ? { type: 'array', items: base } : base;\n properties[fieldName] = fieldDef.optional ? { anyOf: [typed, { type: 'null' }] } : typed;\n if (!fieldDef.optional) required.push(fieldName);\n }\n const schema: SchemaObject = { type: 'object', properties };\n if (required.length > 0) schema['required'] = required;\n return schema;\n }\n\n /**\n * Builds a JSON Schema object describing a model entity\n */\n private buildModelEntitySchema(modelDef: ModelDef): SchemaObject {\n const properties: Record<string, SchemaObject | ReferenceObject> = {};\n const required: string[] = [];\n\n for (const [fieldName, fieldDef] of Object.entries(modelDef.fields)) {\n if (fieldDef.omit) continue;\n\n if (fieldDef.relation) {\n // Relation fields appear only with `include` — mark as optional.\n // To-one optional relations are nullable (the ORM returns null when not found).\n const refSchema: ReferenceObject = { $ref: `#/components/schemas/${fieldDef.type}` };\n const base: SchemaObject | ReferenceObject = fieldDef.array\n ? { type: 'array', items: refSchema }\n : refSchema;\n properties[fieldName] =\n !fieldDef.array && fieldDef.optional ? { anyOf: [base, { type: 'null' }] } : base;\n } else if (this.schema.enums?.[fieldDef.type]) {\n // Enum field\n const refSchema: ReferenceObject = { $ref: `#/components/schemas/${fieldDef.type}` };\n const base: SchemaObject | ReferenceObject = fieldDef.array\n ? { type: 'array', items: refSchema }\n : refSchema;\n properties[fieldName] = fieldDef.optional ? { anyOf: [base, { type: 'null' }] } : base;\n required.push(fieldName);\n } else if (this.isBuiltinType(fieldDef.type)) {\n // Scalar builtin field\n const base = this.builtinTypeToJsonSchema(fieldDef.type as BuiltinType);\n const fieldDesc = getMetaDescription(fieldDef.attributes);\n if (fieldDesc) base.description = fieldDesc;\n const typed: SchemaObject = fieldDef.array ? { type: 'array', items: base } : base;\n properties[fieldName] = fieldDef.optional ? { anyOf: [typed, { type: 'null' }] } : typed;\n required.push(fieldName);\n } else if (this.schema.typeDefs?.[fieldDef.type]) {\n // TypeDef field — reference the registered typedef schema\n const refSchema: ReferenceObject = { $ref: `#/components/schemas/${fieldDef.type}` };\n const base: SchemaObject | ReferenceObject = fieldDef.array\n ? { type: 'array', items: refSchema }\n : refSchema;\n properties[fieldName] = fieldDef.optional ? { anyOf: [base, { type: 'null' }] } : base;\n required.push(fieldName);\n } else {\n // Unknown type — represent as a generic object\n const typed: SchemaObject = fieldDef.array\n ? { type: 'array', items: { type: 'object' } }\n : { type: 'object' };\n properties[fieldName] = typed;\n required.push(fieldName);\n }\n }\n\n const schema: SchemaObject = { type: 'object', properties };\n if (required.length > 0) {\n schema['required'] = required;\n }\n const modelDesc = getMetaDescription(modelDef.attributes);\n if (modelDesc) schema.description = modelDesc;\n return schema;\n }\n\n private buildOperationSuccessSchema(modelName: string, op: string): SchemaObject {\n const entityRef: ReferenceObject = { $ref: `#/components/schemas/${modelName}` };\n // aggregate, groupBy, count shapes depend on query args — leave generic ({})\n const dataSchema = OPERATION_INFO[op]?.dataSchema(entityRef) ?? {};\n return {\n type: 'object',\n properties: {\n data: dataSchema,\n meta: {\n type: 'object',\n properties: {\n serialization: {},\n },\n },\n },\n };\n }\n}\n"],"mappings":";;;;;AAqBA,MAAM,iBAAiB,IAAI,IAAY;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACH,CAAC;AAEF,MAAM,kBAAkB,IAAI,IAAY;CAAC;CAAU;CAAc;CAAuB;CAAS,CAAC;AAElG,MAAM,iBAAiB,IAAI,IAAY;CAAC;CAAU;CAAc;CAAsB,CAAC;AAEvF,MAAM,oBAAoB,IAAI,IAAY,CAAC,UAAU,aAAa,CAAC;AAEnE,MAAM,UAAU;;;;;AAWhB,MAAM,iBAAgD;CAClD,YAAY;EACR,UAAU,MAAM,iBAAiB;EACjC,aAAa,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,QAAQ,CAAC,EAAE;EAC3D;CACD,WAAW;EACP,UAAU,MAAM,kBAAkB;EAClC,aAAa,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,QAAQ,CAAC,EAAE;EAC3D;CACD,UAAU;EACN,UAAU,MAAM,QAAQ,EAAE;EAC1B,aAAa,SAAS;GAAE,MAAM;GAAS,OAAO;GAAK;EACtD;CACD,QAAQ;EACJ,UAAU,MAAM,YAAY;EAC5B,aAAa,QAAQ;EACxB;CACD,YAAY;EACR,UAAU,MAAM,mBAAmB,EAAE;EACrC,mBAAmB;GAAE,MAAM;GAAU,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,EAAE;GAAE,UAAU,CAAC,QAAQ;GAAE;EACzG;CACD,qBAAqB;EACjB,UAAU,MAAM,mBAAmB,EAAE;EACrC,aAAa,SAAS;GAAE,MAAM;GAAS,OAAO;GAAK;EACtD;CACD,QAAQ;EACJ,UAAU,MAAM,YAAY;EAC5B,aAAa,QAAQ;EACxB;CACD,YAAY;EACR,UAAU,MAAM,m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AAE,MAAM;KAAS,OAAO;KAAM,GAAG;AAC9E,eAAW,aAAa,SAAS,WAAW,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,QAAQ,CAAC,EAAE,GAAG;AACnF,aAAS,KAAK,UAAU;cACjB,KAAK,OAAO,WAAW,SAAS,OAAO;IAE9C,MAAM,YAA6B,EAAE,MAAM,wBAAwB,SAAS,QAAQ;IACpF,MAAM,OAAuC,SAAS,QAChD;KAAE,MAAM;KAAS,OAAO;KAAW,GACnC;AACN,eAAW,aAAa,SAAS,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,GAAG;AAClF,aAAS,KAAK,UAAU;UACrB;AAKH,eAAW,aAHiB,SAAS,QAC/B;KAAE,MAAM;KAAS,OAAO,EAAE,MAAM,UAAU;KAAE,GAC5C,EAAE,MAAM,UAAU;AAExB,aAAS,KAAK,UAAU;;;EAIhC,MAAM,SAAuB;GAAE,MAAM;GAAU;GAAY;AAC3D,MAAI,SAAS,SAAS,EAClB,QAAO,cAAc;EAEzB,MAAM,YAAYA,mBAAAA,mBAAmB,SAAS,WAAW;AACzD,MAAI,UAAW,QAAO,cAAc;AACpC,SAAO;;CAGX,4BAAoC,WAAmB,IAA0B;EAC7E,MAAM,YAA6B,EAAE,MAAM,wBAAwB,aAAa;AAGhF,SAAO;GACH,MAAM;GACN,YAAY;IACR,MAJW,eAAe,KAAK,WAAW,UAAU,IAAI,EAAE;IAK1D,MAAM;KACF,MAAM;KACN,YAAY,EACR,eAAe,EAAE,EACpB;KACJ;IACJ;GACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require("./utils-
|
|
1
|
+
require("./utils-DpXvuv-L.cjs");
|
|
2
2
|
let _zenstackhq_common_helpers = require("@zenstackhq/common-helpers");
|
|
3
3
|
require("@zenstackhq/orm");
|
|
4
4
|
let _zenstackhq_orm_schema = require("@zenstackhq/orm/schema");
|
|
@@ -275,4 +275,4 @@ Object.defineProperty(exports, "mayDenyAccess", {
|
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
277
|
|
|
278
|
-
//# sourceMappingURL=spec-utils-
|
|
278
|
+
//# sourceMappingURL=spec-utils-CjQnZIo1.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-utils-C7vlChMD.cjs","names":["ExpressionUtils"],"sources":["../src/api/common/procedures.ts","../src/api/common/spec-utils.ts"],"sourcesContent":["import { ORMError } from '@zenstackhq/orm';\nimport type { ProcedureDef, ProcedureParam, SchemaDef } from '@zenstackhq/orm/schema';\n\nexport const PROCEDURE_ROUTE_PREFIXES = '$procs' as const;\n\nexport function getProcedureDef(schema: SchemaDef, proc: string): ProcedureDef | undefined {\n const procs = schema.procedures ?? {};\n if (!Object.prototype.hasOwnProperty.call(procs, proc)) {\n return undefined;\n }\n return procs[proc];\n}\n\n/**\n * Maps and validates the incoming procedure payload for server-side routing.\n *\n * Supported payload formats:\n * - **Envelope (preferred)**: `{ args: { ... } }`\n * - **Direct object**: `{ ... }` (allowed only when *every* parameter is optional)\n *\n * The function returns the original `payload` unchanged; it only enforces payload\n * *shape* and argument presence/keys so downstream code can safely assume a\n * consistent contract.\n *\n * Validation / branching behavior (mirrors the code below):\n * - **Zero-parameter procedures** (`params.length === 0`)\n * - `undefined` payload is accepted.\n * - Object payloads without an `args` key are treated as “no args” and accepted.\n * - Envelope payloads with `args: {}` are accepted.\n * - Any other payload (including `args` with keys) is rejected.\n * - **All-optional parameter procedures**\n * - Payload may be omitted (`undefined`).\n * - If payload is an object and has no `args` key, it is treated as the direct\n * object form.\n * - **Missing payload** (required parameters exist)\n * - `undefined` is rejected.\n * - **Non-object or array payload**\n * - Rejected.\n * - **Undefined/invalid `args` (envelope form)**\n * - If `args` is missing and not all params are optional: rejected.\n * - If `args` exists but is not a non-array object: rejected.\n * - **Unknown keys**\n * - Any key in the `args` object that is not declared by the procedure is\n * rejected (prevents silently ignoring typos).\n * - **Missing required params**\n * - Any declared non-optional param missing from `args` is rejected.\n *\n * Rationale for rejecting null/falsey payloads:\n * - The checks `!payload` and `!argsPayload` intentionally reject values like\n * `null`, `false`, `0`, or `''` instead of treating them as “no args”. This\n * keeps the API strictly object-based and yields deterministic, descriptive\n * errors rather than surprising coercion.\n *\n * @throws {Error} \"procedure does not accept arguments\"\n * @throws {Error} \"missing procedure arguments\"\n * @throws {Error} \"procedure payload must be an object\"\n * @throws {Error} \"procedure `args` must be an object\"\n * @throws {Error} \"unknown procedure argument: <key>\"\n * @throws {Error} \"missing procedure argument: <name>\"\n */\nexport function mapProcedureArgs(procDef: { params: Record<string, ProcedureParam> }, payload: unknown): unknown {\n const params = Object.values(procDef.params ?? {});\n if (params.length === 0) {\n if (typeof payload === 'undefined') {\n return undefined;\n }\n if (payload && typeof payload === 'object' && !Array.isArray(payload)) {\n const envelope = payload as Record<string, unknown>;\n const argsPayload = Object.prototype.hasOwnProperty.call(envelope, 'args')\n ? (envelope as any).args\n : undefined;\n\n if (typeof argsPayload === 'undefined') {\n return payload;\n }\n\n if (argsPayload && typeof argsPayload === 'object' && !Array.isArray(argsPayload)) {\n if (Object.keys(argsPayload as any).length === 0) {\n return payload;\n }\n }\n }\n throw new Error('procedure does not accept arguments');\n }\n\n // For procedures where every parameter is optional, allow omitting the payload entirely.\n if (typeof payload === 'undefined' && params.every((p) => p.optional)) {\n return undefined;\n }\n\n if (typeof payload === 'undefined') {\n throw new Error('missing procedure arguments');\n }\n\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n throw new Error('procedure payload must be an object');\n }\n\n const envelope = payload as Record<string, unknown>;\n const argsPayload = Object.prototype.hasOwnProperty.call(envelope, 'args') ? (envelope as any).args : undefined;\n\n if (typeof argsPayload === 'undefined') {\n if (params.every((p) => p.optional)) {\n return payload;\n }\n throw new Error('missing procedure arguments');\n }\n\n if (!argsPayload || typeof argsPayload !== 'object' || Array.isArray(argsPayload)) {\n throw new Error('procedure `args` must be an object');\n }\n\n const obj = argsPayload as Record<string, unknown>;\n\n // reject unknown keys to avoid silently ignoring user mistakes\n for (const key of Object.keys(obj)) {\n if (!params.some((p) => p.name === key)) {\n throw new Error(`unknown procedure argument: ${key}`);\n }\n }\n\n // ensure required params are present\n for (const p of params) {\n if (!Object.prototype.hasOwnProperty.call(obj, p.name)) {\n if (p.optional) {\n continue;\n }\n throw new Error(`missing procedure argument: ${p.name}`);\n }\n }\n\n return payload;\n}\n\nexport function isOrmError(err: unknown): err is ORMError {\n return err instanceof ORMError;\n}\n","import { lowerCaseFirst } from '@zenstackhq/common-helpers';\nimport type { QueryOptions } from '@zenstackhq/orm';\nimport { ExpressionUtils, type AttributeApplication, type ModelDef, type SchemaDef } from '@zenstackhq/orm/schema';\n\nexport const DEFAULT_SPEC_TITLE = 'ZenStack Generated API';\nexport const DEFAULT_SPEC_VERSION = '1.0.0';\n\n/**\n * Checks if a model is included based on slicing options.\n */\nexport function isModelIncluded(modelName: string, queryOptions?: QueryOptions<any>): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing) return true;\n\n const excluded = slicing.excludedModels as readonly string[] | undefined;\n if (excluded?.includes(modelName)) return false;\n\n const included = slicing.includedModels as readonly string[] | undefined;\n if (included && !included.includes(modelName)) return false;\n\n return true;\n}\n\n/**\n * Checks if a CRUD operation is included for a model based on slicing options.\n */\nexport function isOperationIncluded(modelName: string, op: string, queryOptions?: QueryOptions<any>): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing?.models) return true;\n\n const modelKey = lowerCaseFirst(modelName);\n const modelSlicing = (slicing.models as Record<string, any>)[modelKey] ?? (slicing.models as any).$all;\n if (!modelSlicing) return true;\n\n const excluded = modelSlicing.excludedOperations as readonly string[] | undefined;\n if (excluded?.includes(op)) return false;\n\n const included = modelSlicing.includedOperations as readonly string[] | undefined;\n if (included && !included.includes(op)) return false;\n\n return true;\n}\n\n/**\n * Checks if a procedure is included based on slicing options.\n */\nexport function isProcedureIncluded(procName: string, queryOptions?: QueryOptions<any>): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing) return true;\n\n const excluded = slicing.excludedProcedures as readonly string[] | undefined;\n if (excluded?.includes(procName)) return false;\n\n const included = slicing.includedProcedures as readonly string[] | undefined;\n if (included && !included.includes(procName)) return false;\n\n return true;\n}\n\n/**\n * Checks if a field should be omitted from the output schema based on queryOptions.omit.\n */\nexport function isFieldOmitted(modelName: string, fieldName: string, queryOptions?: QueryOptions<any>): boolean {\n const omit = queryOptions?.omit as Record<string, Record<string, boolean>> | undefined;\n return omit?.[modelName]?.[fieldName] === true;\n}\n\n/**\n * Returns the list of model names from the schema that pass the slicing filter.\n */\nexport function getIncludedModels(schema: SchemaDef, queryOptions?: QueryOptions<any>): string[] {\n return Object.keys(schema.models).filter((name) => isModelIncluded(name, queryOptions));\n}\n\n/**\n * Checks if a filter kind is allowed for a specific field based on slicing options.\n */\nexport function isFilterKindIncluded(\n modelName: string,\n fieldName: string,\n filterKind: string,\n queryOptions?: QueryOptions<any>,\n): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing?.models) return true;\n\n const modelKey = lowerCaseFirst(modelName);\n const modelSlicing = (slicing.models as Record<string, any>)[modelKey] ?? (slicing.models as any).$all;\n if (!modelSlicing?.fields) return true;\n\n const fieldSlicing = modelSlicing.fields[fieldName] ?? modelSlicing.fields.$all;\n if (!fieldSlicing) return true;\n\n const excluded = fieldSlicing.excludedFilterKinds as readonly string[] | undefined;\n if (excluded?.includes(filterKind)) return false;\n\n const included = fieldSlicing.includedFilterKinds as readonly string[] | undefined;\n if (included && !included.includes(filterKind)) return false;\n\n return true;\n}\n\n/**\n * Checks if an operation on a model may be denied by access policies.\n * Returns true when `respectAccessPolicies` is enabled and the model's policies\n * for the given operation are NOT a constant allow.\n */\nexport function mayDenyAccess(modelDef: ModelDef, operation: string, respectAccessPolicies?: boolean): boolean {\n if (!respectAccessPolicies) return false;\n\n const policyAttrs = (modelDef.attributes ?? []).filter(\n (attr) => attr.name === '@@allow' || attr.name === '@@deny',\n );\n\n // No policy rules at all means default-deny\n if (policyAttrs.length === 0) return true;\n\n const getArgByName = (args: AttributeApplication['args'], name: string) =>\n args?.find((a) => a.name === name)?.value;\n\n const matchesOperation = (args: AttributeApplication['args']) => {\n const val = getArgByName(args, 'operation');\n if (!val || val.kind !== 'literal' || typeof val.value !== 'string') return false;\n const ops = val.value.split(',').map((s) => s.trim());\n return ops.includes(operation) || ops.includes('all');\n };\n\n const hasEffectiveDeny = policyAttrs.some((attr) => {\n if (attr.name !== '@@deny' || !matchesOperation(attr.args)) return false;\n const condition = getArgByName(attr.args, 'condition');\n // @@deny('op', false) is a no-op — skip it\n return !(condition?.kind === 'literal' && condition.value === false);\n });\n if (hasEffectiveDeny) return true;\n\n const relevantAllow = policyAttrs.filter((attr) => attr.name === '@@allow' && matchesOperation(attr.args));\n\n const hasConstantAllow = relevantAllow.some((attr) => {\n const condition = getArgByName(attr.args, 'condition');\n return condition?.kind === 'literal' && condition.value === true;\n });\n\n return !hasConstantAllow;\n}\n\n/**\n * Extracts a \"description\" from `@@meta(\"description\", \"...\")` or `@meta(\"description\", \"...\")` attributes.\n */\nexport function getMetaDescription(attributes: readonly AttributeApplication[] | undefined): string | undefined {\n if (!attributes) return undefined;\n for (const attr of attributes) {\n if (attr.name !== '@meta' && attr.name !== '@@meta') continue;\n const nameArg = attr.args?.find((a) => a.name === 'name');\n if (!nameArg || ExpressionUtils.getLiteralValue(nameArg.value) !== 'description') continue;\n const valueArg = attr.args?.find((a) => a.name === 'value');\n if (valueArg) {\n return ExpressionUtils.getLiteralValue(valueArg.value) as string | undefined;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;AAGA,MAAa,2BAA2B;AAExC,SAAgB,gBAAgB,QAAmB,MAAwC;CACvF,MAAM,QAAQ,OAAO,cAAc,EAAE;AACrC,KAAI,CAAC,OAAO,UAAU,eAAe,KAAK,OAAO,KAAK,CAClD;AAEJ,QAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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W,SAAS,aAAa,UAAU,UAAU;GAChE,CACoB,QAAO;AAS7B,QAAO,CAPe,YAAY,QAAQ,SAAS,KAAK,SAAS,aAAa,iBAAiB,KAAK,KAAK,CAAC,CAEnE,MAAM,SAAS;EAClD,MAAM,YAAY,aAAa,KAAK,MAAM,YAAY;AACtD,SAAO,WAAW,SAAS,aAAa,UAAU,UAAU;GAC9D;;;;;AAQN,SAAgB,mBAAmB,YAA6E;AAC5G,KAAI,CAAC,WAAY,QAAO,KAAA;AACxB,MAAK,MAAM,QAAQ,YAAY;AAC3B,MAAI,KAAK,SAAS,WAAW,KAAK,SAAS,SAAU;EACrD,MAAM,UAAU,KAAK,MAAM,MAAM,MAAM,EAAE,SAAS,OAAO;AACzD,MAAI,CAAC,WAAWA,uBAAAA,gBAAgB,gBAAgB,QAAQ,MAAM,KAAK,cAAe;EAClF,MAAM,WAAW,KAAK,MAAM,MAAM,MAAM,EAAE,SAAS,QAAQ;AAC3D,MAAI,SACA,QAAOA,uBAAAA,gBAAgB,gBAAgB,SAAS,MAAM"}
|
|
1
|
+
{"version":3,"file":"spec-utils-CjQnZIo1.cjs","names":["ExpressionUtils"],"sources":["../src/api/common/procedures.ts","../src/api/common/spec-utils.ts"],"sourcesContent":["import { ORMError } from '@zenstackhq/orm';\nimport type { ProcedureDef, ProcedureParam, SchemaDef } from '@zenstackhq/orm/schema';\n\nexport const PROCEDURE_ROUTE_PREFIXES = '$procs' as const;\n\nexport function getProcedureDef(schema: SchemaDef, proc: string): ProcedureDef | undefined {\n const procs = schema.procedures ?? {};\n if (!Object.prototype.hasOwnProperty.call(procs, proc)) {\n return undefined;\n }\n return procs[proc];\n}\n\n/**\n * Maps and validates the incoming procedure payload for server-side routing.\n *\n * Supported payload formats:\n * - **Envelope (preferred)**: `{ args: { ... } }`\n * - **Direct object**: `{ ... }` (allowed only when *every* parameter is optional)\n *\n * The function returns the original `payload` unchanged; it only enforces payload\n * *shape* and argument presence/keys so downstream code can safely assume a\n * consistent contract.\n *\n * Validation / branching behavior (mirrors the code below):\n * - **Zero-parameter procedures** (`params.length === 0`)\n * - `undefined` payload is accepted.\n * - Object payloads without an `args` key are treated as “no args” and accepted.\n * - Envelope payloads with `args: {}` are accepted.\n * - Any other payload (including `args` with keys) is rejected.\n * - **All-optional parameter procedures**\n * - Payload may be omitted (`undefined`).\n * - If payload is an object and has no `args` key, it is treated as the direct\n * object form.\n * - **Missing payload** (required parameters exist)\n * - `undefined` is rejected.\n * - **Non-object or array payload**\n * - Rejected.\n * - **Undefined/invalid `args` (envelope form)**\n * - If `args` is missing and not all params are optional: rejected.\n * - If `args` exists but is not a non-array object: rejected.\n * - **Unknown keys**\n * - Any key in the `args` object that is not declared by the procedure is\n * rejected (prevents silently ignoring typos).\n * - **Missing required params**\n * - Any declared non-optional param missing from `args` is rejected.\n *\n * Rationale for rejecting null/falsey payloads:\n * - The checks `!payload` and `!argsPayload` intentionally reject values like\n * `null`, `false`, `0`, or `''` instead of treating them as “no args”. This\n * keeps the API strictly object-based and yields deterministic, descriptive\n * errors rather than surprising coercion.\n *\n * @throws {Error} \"procedure does not accept arguments\"\n * @throws {Error} \"missing procedure arguments\"\n * @throws {Error} \"procedure payload must be an object\"\n * @throws {Error} \"procedure `args` must be an object\"\n * @throws {Error} \"unknown procedure argument: <key>\"\n * @throws {Error} \"missing procedure argument: <name>\"\n */\nexport function mapProcedureArgs(procDef: { params: Record<string, ProcedureParam> }, payload: unknown): unknown {\n const params = Object.values(procDef.params ?? {});\n if (params.length === 0) {\n if (typeof payload === 'undefined') {\n return undefined;\n }\n if (payload && typeof payload === 'object' && !Array.isArray(payload)) {\n const envelope = payload as Record<string, unknown>;\n const argsPayload = Object.prototype.hasOwnProperty.call(envelope, 'args')\n ? (envelope as any).args\n : undefined;\n\n if (typeof argsPayload === 'undefined') {\n return payload;\n }\n\n if (argsPayload && typeof argsPayload === 'object' && !Array.isArray(argsPayload)) {\n if (Object.keys(argsPayload as any).length === 0) {\n return payload;\n }\n }\n }\n throw new Error('procedure does not accept arguments');\n }\n\n // For procedures where every parameter is optional, allow omitting the payload entirely.\n if (typeof payload === 'undefined' && params.every((p) => p.optional)) {\n return undefined;\n }\n\n if (typeof payload === 'undefined') {\n throw new Error('missing procedure arguments');\n }\n\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n throw new Error('procedure payload must be an object');\n }\n\n const envelope = payload as Record<string, unknown>;\n const argsPayload = Object.prototype.hasOwnProperty.call(envelope, 'args') ? (envelope as any).args : undefined;\n\n if (typeof argsPayload === 'undefined') {\n if (params.every((p) => p.optional)) {\n return payload;\n }\n throw new Error('missing procedure arguments');\n }\n\n if (!argsPayload || typeof argsPayload !== 'object' || Array.isArray(argsPayload)) {\n throw new Error('procedure `args` must be an object');\n }\n\n const obj = argsPayload as Record<string, unknown>;\n\n // reject unknown keys to avoid silently ignoring user mistakes\n for (const key of Object.keys(obj)) {\n if (!params.some((p) => p.name === key)) {\n throw new Error(`unknown procedure argument: ${key}`);\n }\n }\n\n // ensure required params are present\n for (const p of params) {\n if (!Object.prototype.hasOwnProperty.call(obj, p.name)) {\n if (p.optional) {\n continue;\n }\n throw new Error(`missing procedure argument: ${p.name}`);\n }\n }\n\n return payload;\n}\n\nexport function isOrmError(err: unknown): err is ORMError {\n return err instanceof ORMError;\n}\n","import { lowerCaseFirst } from '@zenstackhq/common-helpers';\nimport type { QueryOptions } from '@zenstackhq/orm';\nimport { ExpressionUtils, type AttributeApplication, type ModelDef, type SchemaDef } from '@zenstackhq/orm/schema';\n\nexport const DEFAULT_SPEC_TITLE = 'ZenStack Generated API';\nexport const DEFAULT_SPEC_VERSION = '1.0.0';\n\n/**\n * Checks if a model is included based on slicing options.\n */\nexport function isModelIncluded(modelName: string, queryOptions?: QueryOptions<any>): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing) return true;\n\n const excluded = slicing.excludedModels as readonly string[] | undefined;\n if (excluded?.includes(modelName)) return false;\n\n const included = slicing.includedModels as readonly string[] | undefined;\n if (included && !included.includes(modelName)) return false;\n\n return true;\n}\n\n/**\n * Checks if a CRUD operation is included for a model based on slicing options.\n */\nexport function isOperationIncluded(modelName: string, op: string, queryOptions?: QueryOptions<any>): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing?.models) return true;\n\n const modelKey = lowerCaseFirst(modelName);\n const modelSlicing = (slicing.models as Record<string, any>)[modelKey] ?? (slicing.models as any).$all;\n if (!modelSlicing) return true;\n\n const excluded = modelSlicing.excludedOperations as readonly string[] | undefined;\n if (excluded?.includes(op)) return false;\n\n const included = modelSlicing.includedOperations as readonly string[] | undefined;\n if (included && !included.includes(op)) return false;\n\n return true;\n}\n\n/**\n * Checks if a procedure is included based on slicing options.\n */\nexport function isProcedureIncluded(procName: string, queryOptions?: QueryOptions<any>): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing) return true;\n\n const excluded = slicing.excludedProcedures as readonly string[] | undefined;\n if (excluded?.includes(procName)) return false;\n\n const included = slicing.includedProcedures as readonly string[] | undefined;\n if (included && !included.includes(procName)) return false;\n\n return true;\n}\n\n/**\n * Checks if a field should be omitted from the output schema based on queryOptions.omit.\n */\nexport function isFieldOmitted(modelName: string, fieldName: string, queryOptions?: QueryOptions<any>): boolean {\n const omit = queryOptions?.omit as Record<string, Record<string, boolean>> | undefined;\n return omit?.[modelName]?.[fieldName] === true;\n}\n\n/**\n * Returns the list of model names from the schema that pass the slicing filter.\n */\nexport function getIncludedModels(schema: SchemaDef, queryOptions?: QueryOptions<any>): string[] {\n return Object.keys(schema.models).filter((name) => isModelIncluded(name, queryOptions));\n}\n\n/**\n * Checks if a filter kind is allowed for a specific field based on slicing options.\n */\nexport function isFilterKindIncluded(\n modelName: string,\n fieldName: string,\n filterKind: string,\n queryOptions?: QueryOptions<any>,\n): boolean {\n const slicing = queryOptions?.slicing;\n if (!slicing?.models) return true;\n\n const modelKey = lowerCaseFirst(modelName);\n const modelSlicing = (slicing.models as Record<string, any>)[modelKey] ?? (slicing.models as any).$all;\n if (!modelSlicing?.fields) return true;\n\n const fieldSlicing = modelSlicing.fields[fieldName] ?? modelSlicing.fields.$all;\n if (!fieldSlicing) return true;\n\n const excluded = fieldSlicing.excludedFilterKinds as readonly string[] | undefined;\n if (excluded?.includes(filterKind)) return false;\n\n const included = fieldSlicing.includedFilterKinds as readonly string[] | undefined;\n if (included && !included.includes(filterKind)) return false;\n\n return true;\n}\n\n/**\n * Checks if an operation on a model may be denied by access policies.\n * Returns true when `respectAccessPolicies` is enabled and the model's policies\n * for the given operation are NOT a constant allow.\n */\nexport function mayDenyAccess(modelDef: ModelDef, operation: string, respectAccessPolicies?: boolean): boolean {\n if (!respectAccessPolicies) return false;\n\n const policyAttrs = (modelDef.attributes ?? []).filter(\n (attr) => attr.name === '@@allow' || attr.name === '@@deny',\n );\n\n // No policy rules at all means default-deny\n if (policyAttrs.length === 0) return true;\n\n const getArgByName = (args: AttributeApplication['args'], name: string) =>\n args?.find((a) => a.name === name)?.value;\n\n const matchesOperation = (args: AttributeApplication['args']) => {\n const val = getArgByName(args, 'operation');\n if (!val || val.kind !== 'literal' || typeof val.value !== 'string') return false;\n const ops = val.value.split(',').map((s) => s.trim());\n return ops.includes(operation) || ops.includes('all');\n };\n\n const hasEffectiveDeny = policyAttrs.some((attr) => {\n if (attr.name !== '@@deny' || !matchesOperation(attr.args)) return false;\n const condition = getArgByName(attr.args, 'condition');\n // @@deny('op', false) is a no-op — skip it\n return !(condition?.kind === 'literal' && condition.value === false);\n });\n if (hasEffectiveDeny) return true;\n\n const relevantAllow = policyAttrs.filter((attr) => attr.name === '@@allow' && matchesOperation(attr.args));\n\n const hasConstantAllow = relevantAllow.some((attr) => {\n const condition = getArgByName(attr.args, 'condition');\n return condition?.kind === 'literal' && condition.value === true;\n });\n\n return !hasConstantAllow;\n}\n\n/**\n * Extracts a \"description\" from `@@meta(\"description\", \"...\")` or `@meta(\"description\", \"...\")` attributes.\n */\nexport function getMetaDescription(attributes: readonly AttributeApplication[] | undefined): string | undefined {\n if (!attributes) return undefined;\n for (const attr of attributes) {\n if (attr.name !== '@meta' && attr.name !== '@@meta') continue;\n const nameArg = attr.args?.find((a) => a.name === 'name');\n if (!nameArg || ExpressionUtils.getLiteralValue(nameArg.value) !== 'description') continue;\n const valueArg = attr.args?.find((a) => a.name === 'value');\n if (valueArg) {\n return ExpressionUtils.getLiteralValue(valueArg.value) as string | undefined;\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;AAGA,MAAa,2BAA2B;AAExC,SAAgB,gBAAgB,QAAmB,MAAwC;CACvF,MAAM,QAAQ,OAAO,cAAc,EAAE;AACrC,KAAI,CAAC,OAAO,UAAU,eAAe,KAAK,OAAO,KAAK,CAClD;AAEJ,QAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDjB,SAAgB,iBAAiB,SAAqD,SAA2B;CAC7G,MAAM,SAAS,OAAO,OAAO,QAAQ,UAAU,EAAE,CAAC;AAClD,KAAI,OAAO,WAAW,GAAG;AACrB,MAAI,OAAO,YAAY,YACnB;AAEJ,MAAI,WAAW,OAAO,YAAY,YAAY,CAAC,MAAM,QAAQ,QAAQ,EAAE;GACnE,MAAM,WAAW;GACjB,MAAM,cAAc,OAAO,UAAU,eAAe,KAAK,UAAU,OAAO,GACnE,SAAiB,OAClB,KAAA;AAEN,OAAI,OAAO,gBAAgB,YACvB,QAAO;AAGX,OAAI,eAAe,OAAO,gBAAgB,YAAY,CAAC,MAAM,QAAQ,YAAY;QACzE,OAAO,KAAK,YAAmB,CAAC,WAAW,EAC3C,QAAO;;;AAInB,QAAM,IAAI,MAAM,sCAAsC;;AAI1D,KAAI,OAAO,YAAY,eAAe,OAAO,OAAO,MAAM,EAAE,SAAS,CACjE;AAGJ,KAAI,OAAO,YAAY,YACnB,OAAM,IAAI,MAAM,8BAA8B;AAGlD,KAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,QAAQ,CACjE,OAAM,IAAI,MAAM,sCAAsC;CAG1D,M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Tag, { value: "Module" });
|
|
2
|
-
require("./utils-
|
|
3
|
-
const require_common = require("./common-
|
|
2
|
+
require("./utils-DpXvuv-L.cjs");
|
|
3
|
+
const require_common = require("./common-CEe4nh_-.cjs");
|
|
4
4
|
let _sveltejs_kit = require("@sveltejs/kit");
|
|
5
5
|
//#region src/adapter/sveltekit/handler.ts
|
|
6
6
|
/**
|
package/dist/sveltekit.mjs
CHANGED
package/dist/tanstack-start.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_common = require("./common-
|
|
5
|
+
const require_common = require("./common-CEe4nh_-.cjs");
|
|
6
6
|
//#region src/adapter/tanstack-start/handler.ts
|
|
7
7
|
/**
|
|
8
8
|
* Creates a TanStack Start server route handler which encapsulates ZenStack CRUD operations.
|
package/dist/tanstack-start.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as logInternalError } from "./common-
|
|
1
|
+
import { t as logInternalError } from "./common-DETPQ77o.mjs";
|
|
2
2
|
//#region src/adapter/tanstack-start/handler.ts
|
|
3
3
|
/**
|
|
4
4
|
* Creates a TanStack Start server route handler which encapsulates ZenStack CRUD operations.
|
|
@@ -3,6 +3,7 @@ import SuperJSON from "superjson";
|
|
|
3
3
|
import { match } from "ts-pattern";
|
|
4
4
|
import "zod";
|
|
5
5
|
import { fromError } from "zod-validation-error/v4";
|
|
6
|
+
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from "@zenstackhq/orm/common-types";
|
|
6
7
|
import { fromError as fromError$1 } from "zod-validation-error/v3";
|
|
7
8
|
//#region src/api/utils.ts
|
|
8
9
|
function log(logger, level, message, error) {
|
|
@@ -20,6 +21,21 @@ function registerCustomSerializers() {
|
|
|
20
21
|
serialize: (v) => v.toJSON(),
|
|
21
22
|
deserialize: (v) => new Decimal(v)
|
|
22
23
|
}, "Decimal");
|
|
24
|
+
SuperJSON.registerCustom({
|
|
25
|
+
isApplicable: (v) => v instanceof DbNullClass,
|
|
26
|
+
serialize: () => "DbNull",
|
|
27
|
+
deserialize: () => DbNull
|
|
28
|
+
}, "DbNull");
|
|
29
|
+
SuperJSON.registerCustom({
|
|
30
|
+
isApplicable: (v) => v instanceof JsonNullClass,
|
|
31
|
+
serialize: () => "JsonNull",
|
|
32
|
+
deserialize: () => JsonNull
|
|
33
|
+
}, "JsonNull");
|
|
34
|
+
SuperJSON.registerCustom({
|
|
35
|
+
isApplicable: (v) => v instanceof AnyNullClass,
|
|
36
|
+
serialize: () => "AnyNull",
|
|
37
|
+
deserialize: () => AnyNull
|
|
38
|
+
}, "AnyNull");
|
|
23
39
|
if (globalThis.Buffer) SuperJSON.registerCustom({
|
|
24
40
|
isApplicable: (v) => Buffer.isBuffer(v),
|
|
25
41
|
serialize: (v) => v.toString("base64"),
|
|
@@ -36,4 +52,4 @@ function getZodErrorMessage(error) {
|
|
|
36
52
|
//#endregion
|
|
37
53
|
export { log as n, registerCustomSerializers as r, getZodErrorMessage as t };
|
|
38
54
|
|
|
39
|
-
//# sourceMappingURL=utils-
|
|
55
|
+
//# sourceMappingURL=utils-9j3D9BLL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-9j3D9BLL.mjs","names":["fromError4","fromError3"],"sources":["../src/api/utils.ts"],"sourcesContent":["import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from '@zenstackhq/orm/common-types';\nimport { Decimal } from 'decimal.js';\nimport SuperJSON from 'superjson';\nimport { match } from 'ts-pattern';\nimport { ZodError } from 'zod';\nimport { fromError as fromError3 } from 'zod-validation-error/v3';\nimport { fromError as fromError4 } from 'zod-validation-error/v4';\nimport type { LogConfig, LogLevel } from '../types';\n\nexport function log(logger: LogConfig | undefined, level: LogLevel, message: string | (() => string), error?: unknown) {\n if (!logger) {\n return;\n }\n\n const getMessage = typeof message === 'function' ? message : () => message;\n\n if (typeof logger === 'function') {\n logger(level, getMessage(), error);\n } else if (logger.includes(level)) {\n const logFn = match(level)\n .with('debug', () => console.debug)\n .with('info', () => console.info)\n .with('warn', () => console.warn)\n .with('error', () => console.error)\n .exhaustive();\n logFn(`@zenstackhq/server: [${level}] ${getMessage()}${error ? `\\n${error}` : ''}`);\n }\n}\n\n/**\n * Registers custom superjson serializers.\n */\nexport function registerCustomSerializers() {\n SuperJSON.registerCustom<Decimal, string>(\n {\n isApplicable: (v): v is Decimal => Decimal.isDecimal(v),\n serialize: (v) => v.toJSON(),\n deserialize: (v) => new Decimal(v),\n },\n 'Decimal',\n );\n\n SuperJSON.registerCustom<DbNullClass, string>(\n {\n isApplicable: (v): v is DbNullClass => v instanceof DbNullClass,\n serialize: () => 'DbNull',\n deserialize: () => DbNull,\n },\n 'DbNull',\n );\n\n SuperJSON.registerCustom<JsonNullClass, string>(\n {\n isApplicable: (v): v is JsonNullClass => v instanceof JsonNullClass,\n serialize: () => 'JsonNull',\n deserialize: () => JsonNull,\n },\n 'JsonNull',\n );\n\n SuperJSON.registerCustom<AnyNullClass, string>(\n {\n isApplicable: (v): v is AnyNullClass => v instanceof AnyNullClass,\n serialize: () => 'AnyNull',\n deserialize: () => AnyNull,\n },\n 'AnyNull',\n );\n\n // `Buffer` is not available in edge runtime\n if (globalThis.Buffer) {\n SuperJSON.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer => Buffer.isBuffer(v),\n serialize: (v) => v.toString('base64'),\n deserialize: (v) => Buffer.from(v, 'base64'),\n },\n 'Bytes',\n );\n }\n}\n\n/**\n * Format ZodError into a readable string\n */\nexport function getZodErrorMessage(error: ZodError): string {\n if ('_zod' in error) {\n return fromError4(error).toString();\n } else {\n return fromError3(error).toString();\n }\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,IAAI,QAA+B,OAAiB,SAAkC,OAAiB;AACnH,KAAI,CAAC,OACD;CAGJ,MAAM,aAAa,OAAO,YAAY,aAAa,gBAAgB;AAEnE,KAAI,OAAO,WAAW,WAClB,QAAO,OAAO,YAAY,EAAE,MAAM;UAC3B,OAAO,SAAS,MAAM,CACf,OAAM,MAAM,CACrB,KAAK,eAAe,QAAQ,MAAM,CAClC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,eAAe,QAAQ,MAAM,CAClC,YAAY,CACX,wBAAwB,MAAM,IAAI,YAAY,GAAG,QAAQ,KAAK,UAAU,KAAK;;;;;AAO3F,SAAgB,4BAA4B;AACxC,WAAU,eACN;EACI,eAAe,MAAoB,QAAQ,UAAU,EAAE;EACvD,YAAY,MAAM,EAAE,QAAQ;EAC5B,cAAc,MAAM,IAAI,QAAQ,EAAE;EACrC,EACD,UACH;AAED,WAAU,eACN;EACI,eAAe,MAAwB,aAAa;EACpD,iBAAiB;EACjB,mBAAmB;EACtB,EACD,SACH;AAED,WAAU,eACN;EACI,eAAe,MAA0B,aAAa;EACtD,iBAAiB;EACjB,mBAAmB;EACtB,EACD,WACH;AAED,WAAU,eACN;EACI,eAAe,MAAyB,aAAa;EACrD,iBAAiB;EACjB,mBAAmB;EACtB,EACD,UACH;AAGD,KAAI,WAAW,OACX,WAAU,eACN;EACI,eAAe,MAAmB,OAAO,SAAS,EAAE;EACpD,YAAY,MAAM,EAAE,SAAS,SAAS;EACtC,cAAc,MAAM,OAAO,KAAK,GAAG,SAAS;EAC/C,EACD,QACH;;;;;AAOT,SAAgB,mBAAmB,OAAyB;AACxD,KAAI,UAAU,MACV,QAAOA,UAAW,MAAM,CAAC,UAAU;KAEnC,QAAOC,YAAW,MAAM,CAAC,UAAU"}
|
|
@@ -26,6 +26,7 @@ superjson = __toESM(superjson, 1);
|
|
|
26
26
|
let ts_pattern = require("ts-pattern");
|
|
27
27
|
require("zod");
|
|
28
28
|
let zod_validation_error_v4 = require("zod-validation-error/v4");
|
|
29
|
+
let _zenstackhq_orm_common_types = require("@zenstackhq/orm/common-types");
|
|
29
30
|
let zod_validation_error_v3 = require("zod-validation-error/v3");
|
|
30
31
|
//#region src/api/utils.ts
|
|
31
32
|
function log(logger, level, message, error) {
|
|
@@ -43,6 +44,21 @@ function registerCustomSerializers() {
|
|
|
43
44
|
serialize: (v) => v.toJSON(),
|
|
44
45
|
deserialize: (v) => new decimal_js.Decimal(v)
|
|
45
46
|
}, "Decimal");
|
|
47
|
+
superjson.default.registerCustom({
|
|
48
|
+
isApplicable: (v) => v instanceof _zenstackhq_orm_common_types.DbNullClass,
|
|
49
|
+
serialize: () => "DbNull",
|
|
50
|
+
deserialize: () => _zenstackhq_orm_common_types.DbNull
|
|
51
|
+
}, "DbNull");
|
|
52
|
+
superjson.default.registerCustom({
|
|
53
|
+
isApplicable: (v) => v instanceof _zenstackhq_orm_common_types.JsonNullClass,
|
|
54
|
+
serialize: () => "JsonNull",
|
|
55
|
+
deserialize: () => _zenstackhq_orm_common_types.JsonNull
|
|
56
|
+
}, "JsonNull");
|
|
57
|
+
superjson.default.registerCustom({
|
|
58
|
+
isApplicable: (v) => v instanceof _zenstackhq_orm_common_types.AnyNullClass,
|
|
59
|
+
serialize: () => "AnyNull",
|
|
60
|
+
deserialize: () => _zenstackhq_orm_common_types.AnyNull
|
|
61
|
+
}, "AnyNull");
|
|
46
62
|
if (globalThis.Buffer) superjson.default.registerCustom({
|
|
47
63
|
isApplicable: (v) => Buffer.isBuffer(v),
|
|
48
64
|
serialize: (v) => v.toString("base64"),
|
|
@@ -82,4 +98,4 @@ Object.defineProperty(exports, "registerCustomSerializers", {
|
|
|
82
98
|
}
|
|
83
99
|
});
|
|
84
100
|
|
|
85
|
-
//# sourceMappingURL=utils-
|
|
101
|
+
//# sourceMappingURL=utils-DpXvuv-L.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-DpXvuv-L.cjs","names":["Decimal","DbNullClass","DbNull","JsonNullClass","JsonNull","AnyNullClass","AnyNull"],"sources":["../src/api/utils.ts"],"sourcesContent":["import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from '@zenstackhq/orm/common-types';\nimport { Decimal } from 'decimal.js';\nimport SuperJSON from 'superjson';\nimport { match } from 'ts-pattern';\nimport { ZodError } from 'zod';\nimport { fromError as fromError3 } from 'zod-validation-error/v3';\nimport { fromError as fromError4 } from 'zod-validation-error/v4';\nimport type { LogConfig, LogLevel } from '../types';\n\nexport function log(logger: LogConfig | undefined, level: LogLevel, message: string | (() => string), error?: unknown) {\n if (!logger) {\n return;\n }\n\n const getMessage = typeof message === 'function' ? message : () => message;\n\n if (typeof logger === 'function') {\n logger(level, getMessage(), error);\n } else if (logger.includes(level)) {\n const logFn = match(level)\n .with('debug', () => console.debug)\n .with('info', () => console.info)\n .with('warn', () => console.warn)\n .with('error', () => console.error)\n .exhaustive();\n logFn(`@zenstackhq/server: [${level}] ${getMessage()}${error ? `\\n${error}` : ''}`);\n }\n}\n\n/**\n * Registers custom superjson serializers.\n */\nexport function registerCustomSerializers() {\n SuperJSON.registerCustom<Decimal, string>(\n {\n isApplicable: (v): v is Decimal => Decimal.isDecimal(v),\n serialize: (v) => v.toJSON(),\n deserialize: (v) => new Decimal(v),\n },\n 'Decimal',\n );\n\n SuperJSON.registerCustom<DbNullClass, string>(\n {\n isApplicable: (v): v is DbNullClass => v instanceof DbNullClass,\n serialize: () => 'DbNull',\n deserialize: () => DbNull,\n },\n 'DbNull',\n );\n\n SuperJSON.registerCustom<JsonNullClass, string>(\n {\n isApplicable: (v): v is JsonNullClass => v instanceof JsonNullClass,\n serialize: () => 'JsonNull',\n deserialize: () => JsonNull,\n },\n 'JsonNull',\n );\n\n SuperJSON.registerCustom<AnyNullClass, string>(\n {\n isApplicable: (v): v is AnyNullClass => v instanceof AnyNullClass,\n serialize: () => 'AnyNull',\n deserialize: () => AnyNull,\n },\n 'AnyNull',\n );\n\n // `Buffer` is not available in edge runtime\n if (globalThis.Buffer) {\n SuperJSON.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer => Buffer.isBuffer(v),\n serialize: (v) => v.toString('base64'),\n deserialize: (v) => Buffer.from(v, 'base64'),\n },\n 'Bytes',\n );\n }\n}\n\n/**\n * Format ZodError into a readable string\n */\nexport function getZodErrorMessage(error: ZodError): string {\n if ('_zod' in error) {\n return fromError4(error).toString();\n } else {\n return fromError3(error).toString();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,SAAgB,IAAI,QAA+B,OAAiB,SAAkC,OAAiB;AACnH,KAAI,CAAC,OACD;CAGJ,MAAM,aAAa,OAAO,YAAY,aAAa,gBAAgB;AAEnE,KAAI,OAAO,WAAW,WAClB,QAAO,OAAO,YAAY,EAAE,MAAM;UAC3B,OAAO,SAAS,MAAM,CAO7B,EAAA,GAAA,WAAA,OANoB,MAAM,CACrB,KAAK,eAAe,QAAQ,MAAM,CAClC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,eAAe,QAAQ,MAAM,CAClC,YAAY,CACX,wBAAwB,MAAM,IAAI,YAAY,GAAG,QAAQ,KAAK,UAAU,KAAK;;;;;AAO3F,SAAgB,4BAA4B;AACxC,WAAA,QAAU,eACN;EACI,eAAe,MAAoBA,WAAAA,QAAQ,UAAU,EAAE;EACvD,YAAY,MAAM,EAAE,QAAQ;EAC5B,cAAc,MAAM,IAAIA,WAAAA,QAAQ,EAAE;EACrC,EACD,UACH;AAED,WAAA,QAAU,eACN;EACI,eAAe,MAAwB,aAAaC,6BAAAA;EACpD,iBAAiB;EACjB,mBAAmBC,6BAAAA;EACtB,EACD,SACH;AAED,WAAA,QAAU,eACN;EACI,eAAe,MAA0B,aAAaC,6BAAAA;EACtD,iBAAiB;EACjB,mBAAmBC,6BAAAA;EACtB,EACD,WACH;AAED,WAAA,QAAU,eACN;EACI,eAAe,MAAyB,aAAaC,6BAAAA;EACrD,iBAAiB;EACjB,mBAAmBC,6BAAAA;EACtB,EACD,UACH;AAGD,KAAI,WAAW,OACX,WAAA,QAAU,eACN;EACI,eAAe,MAAmB,OAAO,SAAS,EAAE;EACpD,YAAY,MAAM,EAAE,SAAS,SAAS;EACtC,cAAc,MAAM,OAAO,KAAK,GAAG,SAAS;EAC/C,EACD,QACH;;;;;AAOT,SAAgB,mBAAmB,OAAyB;AACxD,KAAI,UAAU,MACV,SAAA,GAAA,wBAAA,WAAkB,MAAM,CAAC,UAAU;KAEnC,SAAA,GAAA,wBAAA,WAAkB,MAAM,CAAC,UAAU"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@zenstackhq/server",
|
|
3
3
|
"displayName": "ZenStack Automatic CRUD Server",
|
|
4
4
|
"description": "ZenStack automatic CRUD API handlers and server adapters for popular frameworks",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.7.0-beta.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "ZenStack Team",
|
|
@@ -130,8 +130,8 @@
|
|
|
130
130
|
"ts-pattern": "^5.7.1",
|
|
131
131
|
"url-pattern": "^1.0.3",
|
|
132
132
|
"zod-validation-error": "^4.0.1",
|
|
133
|
-
"@zenstackhq/orm": "3.
|
|
134
|
-
"@zenstackhq/common-helpers": "3.
|
|
133
|
+
"@zenstackhq/orm": "3.7.0-beta.1",
|
|
134
|
+
"@zenstackhq/common-helpers": "3.7.0-beta.1"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
137
|
"@readme/openapi-parser": "^6.0.0",
|
|
@@ -150,11 +150,11 @@
|
|
|
150
150
|
"nuxt": "4.3.1",
|
|
151
151
|
"supertest": "^7.1.4",
|
|
152
152
|
"zod": "^4.1.0",
|
|
153
|
-
"@zenstackhq/
|
|
154
|
-
"@zenstackhq/
|
|
155
|
-
"@zenstackhq/
|
|
156
|
-
"@zenstackhq/
|
|
157
|
-
"@zenstackhq/
|
|
153
|
+
"@zenstackhq/tsdown-config": "3.7.0-beta.1",
|
|
154
|
+
"@zenstackhq/typescript-config": "3.7.0-beta.1",
|
|
155
|
+
"@zenstackhq/eslint-config": "3.7.0-beta.1",
|
|
156
|
+
"@zenstackhq/testtools": "3.7.0-beta.1",
|
|
157
|
+
"@zenstackhq/vitest-config": "3.7.0-beta.1"
|
|
158
158
|
},
|
|
159
159
|
"peerDependencies": {
|
|
160
160
|
"@sveltejs/kit": "^2.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-B9NX7OcP.cjs","names":["Decimal"],"sources":["../src/api/utils.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\nimport SuperJSON from 'superjson';\nimport { match } from 'ts-pattern';\nimport { ZodError } from 'zod';\nimport { fromError as fromError3 } from 'zod-validation-error/v3';\nimport { fromError as fromError4 } from 'zod-validation-error/v4';\nimport type { LogConfig, LogLevel } from '../types';\n\nexport function log(logger: LogConfig | undefined, level: LogLevel, message: string | (() => string), error?: unknown) {\n if (!logger) {\n return;\n }\n\n const getMessage = typeof message === 'function' ? message : () => message;\n\n if (typeof logger === 'function') {\n logger(level, getMessage(), error);\n } else if (logger.includes(level)) {\n const logFn = match(level)\n .with('debug', () => console.debug)\n .with('info', () => console.info)\n .with('warn', () => console.warn)\n .with('error', () => console.error)\n .exhaustive();\n logFn(`@zenstackhq/server: [${level}] ${getMessage()}${error ? `\\n${error}` : ''}`);\n }\n}\n\n/**\n * Registers custom superjson serializers.\n */\nexport function registerCustomSerializers() {\n SuperJSON.registerCustom<Decimal, string>(\n {\n isApplicable: (v): v is Decimal => Decimal.isDecimal(v),\n serialize: (v) => v.toJSON(),\n deserialize: (v) => new Decimal(v),\n },\n 'Decimal',\n );\n\n // `Buffer` is not available in edge runtime\n if (globalThis.Buffer) {\n SuperJSON.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer => Buffer.isBuffer(v),\n serialize: (v) => v.toString('base64'),\n deserialize: (v) => Buffer.from(v, 'base64'),\n },\n 'Bytes',\n );\n }\n}\n\n/**\n * Format ZodError into a readable string\n */\nexport function getZodErrorMessage(error: ZodError): string {\n if ('_zod' in error) {\n return fromError4(error).toString();\n } else {\n return fromError3(error).toString();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,SAAgB,IAAI,QAA+B,OAAiB,SAAkC,OAAiB;AACnH,KAAI,CAAC,OACD;CAGJ,MAAM,aAAa,OAAO,YAAY,aAAa,gBAAgB;AAEnE,KAAI,OAAO,WAAW,WAClB,QAAO,OAAO,YAAY,EAAE,MAAM;UAC3B,OAAO,SAAS,MAAM,CAO7B,EAAA,GAAA,WAAA,OANoB,MAAM,CACrB,KAAK,eAAe,QAAQ,MAAM,CAClC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,eAAe,QAAQ,MAAM,CAClC,YAAY,CACX,wBAAwB,MAAM,IAAI,YAAY,GAAG,QAAQ,KAAK,UAAU,KAAK;;;;;AAO3F,SAAgB,4BAA4B;AACxC,WAAA,QAAU,eACN;EACI,eAAe,MAAoBA,WAAAA,QAAQ,UAAU,EAAE;EACvD,YAAY,MAAM,EAAE,QAAQ;EAC5B,cAAc,MAAM,IAAIA,WAAAA,QAAQ,EAAE;EACrC,EACD,UACH;AAGD,KAAI,WAAW,OACX,WAAA,QAAU,eACN;EACI,eAAe,MAAmB,OAAO,SAAS,EAAE;EACpD,YAAY,MAAM,EAAE,SAAS,SAAS;EACtC,cAAc,MAAM,OAAO,KAAK,GAAG,SAAS;EAC/C,EACD,QACH;;;;;AAOT,SAAgB,mBAAmB,OAAyB;AACxD,KAAI,UAAU,MACV,SAAA,GAAA,wBAAA,WAAkB,MAAM,CAAC,UAAU;KAEnC,SAAA,GAAA,wBAAA,WAAkB,MAAM,CAAC,UAAU"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-Doc_CQNd.mjs","names":["fromError4","fromError3"],"sources":["../src/api/utils.ts"],"sourcesContent":["import { Decimal } from 'decimal.js';\nimport SuperJSON from 'superjson';\nimport { match } from 'ts-pattern';\nimport { ZodError } from 'zod';\nimport { fromError as fromError3 } from 'zod-validation-error/v3';\nimport { fromError as fromError4 } from 'zod-validation-error/v4';\nimport type { LogConfig, LogLevel } from '../types';\n\nexport function log(logger: LogConfig | undefined, level: LogLevel, message: string | (() => string), error?: unknown) {\n if (!logger) {\n return;\n }\n\n const getMessage = typeof message === 'function' ? message : () => message;\n\n if (typeof logger === 'function') {\n logger(level, getMessage(), error);\n } else if (logger.includes(level)) {\n const logFn = match(level)\n .with('debug', () => console.debug)\n .with('info', () => console.info)\n .with('warn', () => console.warn)\n .with('error', () => console.error)\n .exhaustive();\n logFn(`@zenstackhq/server: [${level}] ${getMessage()}${error ? `\\n${error}` : ''}`);\n }\n}\n\n/**\n * Registers custom superjson serializers.\n */\nexport function registerCustomSerializers() {\n SuperJSON.registerCustom<Decimal, string>(\n {\n isApplicable: (v): v is Decimal => Decimal.isDecimal(v),\n serialize: (v) => v.toJSON(),\n deserialize: (v) => new Decimal(v),\n },\n 'Decimal',\n );\n\n // `Buffer` is not available in edge runtime\n if (globalThis.Buffer) {\n SuperJSON.registerCustom<Buffer, string>(\n {\n isApplicable: (v): v is Buffer => Buffer.isBuffer(v),\n serialize: (v) => v.toString('base64'),\n deserialize: (v) => Buffer.from(v, 'base64'),\n },\n 'Bytes',\n );\n }\n}\n\n/**\n * Format ZodError into a readable string\n */\nexport function getZodErrorMessage(error: ZodError): string {\n if ('_zod' in error) {\n return fromError4(error).toString();\n } else {\n return fromError3(error).toString();\n }\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,IAAI,QAA+B,OAAiB,SAAkC,OAAiB;AACnH,KAAI,CAAC,OACD;CAGJ,MAAM,aAAa,OAAO,YAAY,aAAa,gBAAgB;AAEnE,KAAI,OAAO,WAAW,WAClB,QAAO,OAAO,YAAY,EAAE,MAAM;UAC3B,OAAO,SAAS,MAAM,CACf,OAAM,MAAM,CACrB,KAAK,eAAe,QAAQ,MAAM,CAClC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,cAAc,QAAQ,KAAK,CAChC,KAAK,eAAe,QAAQ,MAAM,CAClC,YAAY,CACX,wBAAwB,MAAM,IAAI,YAAY,GAAG,QAAQ,KAAK,UAAU,KAAK;;;;;AAO3F,SAAgB,4BAA4B;AACxC,WAAU,eACN;EACI,eAAe,MAAoB,QAAQ,UAAU,EAAE;EACvD,YAAY,MAAM,EAAE,QAAQ;EAC5B,cAAc,MAAM,IAAI,QAAQ,EAAE;EACrC,EACD,UACH;AAGD,KAAI,WAAW,OACX,WAAU,eACN;EACI,eAAe,MAAmB,OAAO,SAAS,EAAE;EACpD,YAAY,MAAM,EAAE,SAAS,SAAS;EACtC,cAAc,MAAM,OAAO,KAAK,GAAG,SAAS;EAC/C,EACD,QACH;;;;;AAOT,SAAgB,mBAAmB,OAAyB;AACxD,KAAI,UAAU,MACV,QAAOA,UAAW,MAAM,CAAC,UAAU;KAEnC,QAAOC,YAAW,MAAM,CAAC,UAAU"}
|