@lssm/lib.graphql-prisma 0.0.0-canary-20251217072406 → 0.0.0-canary-20251217080011
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/index.js +1 -63
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/schema/dist/EnumType.js +0 -2
- package/dist/schema/dist/FieldType.js +0 -50
- package/dist/schema/dist/FieldType.js.map +0 -1
- package/dist/schema/dist/ScalarTypeEnum.js +0 -237
- package/dist/schema/dist/ScalarTypeEnum.js.map +0 -1
- package/dist/schema/dist/SchemaModel.js +0 -3
- package/dist/schema/dist/entity/defineEntity.js +0 -1
- package/dist/schema/dist/entity/index.js +0 -2
- package/dist/schema/dist/entity/types.js +0 -1
- package/dist/schema/dist/index.js +0 -6
package/dist/index.js
CHANGED
|
@@ -1,64 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./schema/dist/index.js";
|
|
3
|
-
import SchemaBuilder from "@pothos/core";
|
|
4
|
-
import PrismaPlugin from "@pothos/plugin-prisma";
|
|
5
|
-
import ComplexityPlugin from "@pothos/plugin-complexity";
|
|
6
|
-
import DataloaderPlugin from "@pothos/plugin-dataloader";
|
|
7
|
-
import RelayPlugin from "@pothos/plugin-relay";
|
|
8
|
-
import TracingPlugin, { isRootField, wrapResolver } from "@pothos/plugin-tracing";
|
|
9
|
-
import { GeoJSONResolver } from "graphql-scalars";
|
|
10
|
-
|
|
11
|
-
//#region src/index.ts
|
|
12
|
-
function createPrismaSchemaBuilder(options) {
|
|
13
|
-
const debugBuilder = process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === "true";
|
|
14
|
-
const builder = new SchemaBuilder({
|
|
15
|
-
defaultInputFieldRequiredness: true,
|
|
16
|
-
plugins: [
|
|
17
|
-
RelayPlugin,
|
|
18
|
-
ComplexityPlugin,
|
|
19
|
-
TracingPlugin,
|
|
20
|
-
DataloaderPlugin,
|
|
21
|
-
PrismaPlugin
|
|
22
|
-
],
|
|
23
|
-
relay: {},
|
|
24
|
-
prisma: {
|
|
25
|
-
client: options.prisma.client,
|
|
26
|
-
dmmf: options.prisma.dmmf || {},
|
|
27
|
-
exposeDescriptions: options.prisma.exposeDescriptions ?? true,
|
|
28
|
-
filterConnectionTotalCount: options.prisma.filterConnectionTotalCount ?? true,
|
|
29
|
-
onUnusedQuery: options.prisma.onUnusedQuery ?? null
|
|
30
|
-
},
|
|
31
|
-
complexity: {
|
|
32
|
-
defaultComplexity: options.complexity?.defaultComplexity ?? 1,
|
|
33
|
-
defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10
|
|
34
|
-
},
|
|
35
|
-
tracing: {
|
|
36
|
-
default: (cfg) => options.tracing?.enableByDefault ?? true ? isRootField(cfg) : false,
|
|
37
|
-
wrap: (resolver, _opts, cfg) => wrapResolver(resolver, (_err, dur) => {
|
|
38
|
-
options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
if (debugBuilder) console.log("[graphql-prisma] initializing schema builder");
|
|
43
|
-
Object.entries(ScalarTypeEnum).forEach(([name, type]) => {
|
|
44
|
-
if (["ID", "Boolean"].includes(name)) return;
|
|
45
|
-
if (typeof type !== "function") throw new Error(`ScalarTypeEnum entry "${name}" must be a function but received ${typeof type}`);
|
|
46
|
-
if (debugBuilder) console.log(`[graphql-prisma] registering scalar ${name}`);
|
|
47
|
-
builder.addScalarType(name, type());
|
|
48
|
-
});
|
|
49
|
-
builder.addScalarType("GeoJSON", GeoJSONResolver);
|
|
50
|
-
builder.queryType({ fields: (t) => ({}) });
|
|
51
|
-
builder.mutationType({ fields: (t) => ({}) });
|
|
52
|
-
if (debugBuilder) console.log("[graphql-prisma] schema builder ready");
|
|
53
|
-
return builder;
|
|
54
|
-
}
|
|
55
|
-
function createLoggerTracing(logger, opLabel = "gql.field") {
|
|
56
|
-
return {
|
|
57
|
-
enableByDefault: true,
|
|
58
|
-
onResolved: (parentType, fieldName, durationMs, ...others) => {}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
export { createLoggerTracing, createPrismaSchemaBuilder };
|
|
1
|
+
import e from"@pothos/core";import t from"@pothos/plugin-prisma";import n from"@pothos/plugin-complexity";import r from"@pothos/plugin-dataloader";import i from"@pothos/plugin-relay";import a,{isRootField as o,wrapResolver as s}from"@pothos/plugin-tracing";import{GeoJSONResolver as c}from"graphql-scalars";import{ScalarTypeEnum as l}from"@lssm/lib.schema";function u(u){let d=process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER===`true`,f=new e({defaultInputFieldRequiredness:!0,plugins:[i,n,a,r,t],relay:{},prisma:{client:u.prisma.client,dmmf:u.prisma.dmmf||{},exposeDescriptions:u.prisma.exposeDescriptions??!0,filterConnectionTotalCount:u.prisma.filterConnectionTotalCount??!0,onUnusedQuery:u.prisma.onUnusedQuery??null},complexity:{defaultComplexity:u.complexity?.defaultComplexity??1,defaultListMultiplier:u.complexity?.defaultListMultiplier??10},tracing:{default:e=>u.tracing?.enableByDefault??!0?o(e):!1,wrap:(e,t,n)=>s(e,(e,t)=>{u.tracing?.onResolved?.(n.parentType,n.name,t)})}});return d&&console.log(`[graphql-prisma] initializing schema builder`),Object.entries(l).forEach(([e,t])=>{if(![`ID`,`Boolean`].includes(e)){if(typeof t!=`function`)throw Error(`ScalarTypeEnum entry "${e}" must be a function but received ${typeof t}`);d&&console.log(`[graphql-prisma] registering scalar ${e}`),f.addScalarType(e,t())}}),f.addScalarType(`GeoJSON`,c),f.queryType({fields:e=>({})}),f.mutationType({fields:e=>({})}),d&&console.log(`[graphql-prisma] schema builder ready`),f}function d(e,t=`gql.field`){return{enableByDefault:!0,onResolved:(e,t,n,...r)=>{}}}export{d as createLoggerTracing,u as createPrismaSchemaBuilder};
|
|
64
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import SchemaBuilder, { type SchemaTypes } from '@pothos/core';\nimport PrismaPlugin, { type PrismaClient } from '@pothos/plugin-prisma';\nimport ComplexityPlugin from '@pothos/plugin-complexity';\nimport DataloaderPlugin from '@pothos/plugin-dataloader';\nimport RelayPlugin from '@pothos/plugin-relay';\nimport TracingPlugin, {\n isRootField,\n wrapResolver,\n} from '@pothos/plugin-tracing';\nimport '@pothos/plugin-prisma';\nimport '@pothos/plugin-relay';\nimport '@pothos/plugin-complexity';\nimport { GeoJSONResolver } from 'graphql-scalars';\nimport { ScalarTypeEnum } from '@lssm/lib.schema';\n\nexport interface PrismaBuilderOptions {\n complexity?: {\n defaultComplexity?: number;\n defaultListMultiplier?: number;\n };\n tracing?: {\n enableByDefault?: boolean;\n onResolved?: (\n parentType: string,\n fieldName: string,\n durationMs: number\n ) => void;\n };\n federation?: boolean;\n prisma: {\n client: PrismaClient;\n dmmf?: {\n datamodel: unknown;\n };\n exposeDescriptions?: boolean;\n filterConnectionTotalCount?: boolean;\n onUnusedQuery?: 'warn' | null;\n };\n}\n\nexport function createPrismaSchemaBuilder<\n C extends object,\n PT extends {} | undefined,\n Objects extends object = object,\n Scalars extends object = object,\n>(options: PrismaBuilderOptions) {\n const debugBuilder =\n process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === 'true';\n // const plugins: (keyof PothosSchemaTypes.Plugins<SchemaTypes>)[] = [\n const plugins = [\n RelayPlugin,\n ComplexityPlugin,\n TracingPlugin,\n DataloaderPlugin,\n PrismaPlugin,\n ] satisfies (keyof PothosSchemaTypes.Plugins<SchemaTypes>)[];\n // if (options.federation) plugins.push(FederationPlugin);\n\n const builder = new SchemaBuilder<{\n DefaultInputFieldRequiredness: true;\n PrismaTypes: PT;\n Context: C;\n Objects: Objects;\n Scalars: {\n JSON: { Input: unknown; Output: unknown };\n Date: { Input: Date; Output: Date };\n EmailAddress: { Input: string; Output: string };\n Locale: { Input: string; Output: string };\n URL: { Input: string; Output: string };\n GeoJSON: { Input: string; Output: string };\n } & Scalars;\n ObjectType: { CommunityRule: { id: string } };\n }>({\n defaultInputFieldRequiredness: true,\n plugins,\n relay: {},\n prisma: {\n client: options.prisma.client,\n // ...(options.prisma.dmmf ? { dmmf: options.prisma.dmmf as any } : {}),\n dmmf: (options.prisma.dmmf as any) || {},\n exposeDescriptions: options.prisma.exposeDescriptions ?? true,\n filterConnectionTotalCount:\n options.prisma.filterConnectionTotalCount ?? true,\n onUnusedQuery: options.prisma.onUnusedQuery ?? null,\n },\n complexity: {\n defaultComplexity: options.complexity?.defaultComplexity ?? 1,\n defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10,\n },\n tracing: {\n default: (cfg) =>\n (options.tracing?.enableByDefault ?? true) ? isRootField(cfg) : false,\n wrap: (resolver, _opts, cfg) =>\n wrapResolver(resolver, (_err, dur) => {\n options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);\n }),\n },\n });\n\n if (debugBuilder) {\n console.log('[graphql-prisma] initializing schema builder');\n }\n\n Object.entries(ScalarTypeEnum).forEach(([name, type]) => {\n if (['ID', 'Boolean'].includes(name)) {\n return;\n }\n if (typeof type !== 'function') {\n throw new Error(\n `ScalarTypeEnum entry \"${name}\" must be a function but received ${typeof type}`\n );\n }\n if (debugBuilder) {\n console.log(`[graphql-prisma] registering scalar ${name}`);\n }\n builder.addScalarType(name as any, type());\n });\n builder.addScalarType('GeoJSON', GeoJSONResolver);\n\n builder.queryType({\n fields: (t) => ({}),\n });\n\n // Mutation Type (reduced, moved fields into modules)\n builder.mutationType({\n fields: (t) => ({}),\n });\n\n if (debugBuilder) {\n console.log('[graphql-prisma] schema builder ready');\n }\n\n return builder;\n}\n\n// export async function loadDmmfFromClient(\n// client: any\n// ): Promise<PrismaDMMF.Document> {\n// const dmmf: PrismaDMMF.Document | undefined = (client as any)?._dmmf;\n// if (dmmf) return dmmf;\n// if (typeof (client as any).$extends === 'function') {\n// const ext = await (client as any).$extends({});\n// if (ext && ext._dmmf) return ext._dmmf as PrismaDMMF.Document;\n// }\n// throw new Error('Unable to load Prisma DMMF from client');\n// }\n\n// export type PrismaSchemaBuilder<\n// C extends object,\n// PT extends {} | undefined,\n// > = PothosSchemaTypes.SchemaBuilder<\n// PothosSchemaTypes.ExtendDefaultTypes<{\n// PrismaTypes: PT;\n// Context: C;\n// Scalars: {\n// JSON: { Input: unknown; Output: unknown };\n// Date: { Input: Date; Output: Date };\n// };\n// }>\n// >;\n\n// export type PrismaSchemaBuilder<C, PT> = InstanceType<typeof SchemaBuilder><{\n// PrismaTypes: PT;\n// Context: C;\n// Scalars: {\n// JSON: { Input: unknown; Output: unknown };\n// Date: { Input: Date; Output: Date };\n// };\n// }>;\n\n// export function createTypedPrismaBuilder<PT extends {}>() {\n// return function create<C extends object>(options: PrismaBuilderOptions<C>) {\n// return createPrismaSchemaBuilder<C, PT>(options);\n// };\n// }\n\n// Tracing helper that integrates with a logger-like object\nexport interface LoggerLike {\n info: (msg: string, meta?: unknown) => void;\n}\nexport function createLoggerTracing(logger: LoggerLike, opLabel = 'gql.field') {\n return {\n enableByDefault: true,\n onResolved: (\n parentType: string,\n fieldName: string,\n durationMs: number,\n ...others: any[]\n ) => {\n // logger.info(opLabel, { parentType, fieldName, durationMs, others });\n },\n } as PrismaBuilderOptions['tracing'];\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import SchemaBuilder, { type SchemaTypes } from '@pothos/core';\nimport PrismaPlugin, { type PrismaClient } from '@pothos/plugin-prisma';\nimport ComplexityPlugin from '@pothos/plugin-complexity';\nimport DataloaderPlugin from '@pothos/plugin-dataloader';\nimport RelayPlugin from '@pothos/plugin-relay';\nimport TracingPlugin, {\n isRootField,\n wrapResolver,\n} from '@pothos/plugin-tracing';\nimport '@pothos/plugin-prisma';\nimport '@pothos/plugin-relay';\nimport '@pothos/plugin-complexity';\nimport { GeoJSONResolver } from 'graphql-scalars';\nimport { ScalarTypeEnum } from '@lssm/lib.schema';\n\nexport interface PrismaBuilderOptions {\n complexity?: {\n defaultComplexity?: number;\n defaultListMultiplier?: number;\n };\n tracing?: {\n enableByDefault?: boolean;\n onResolved?: (\n parentType: string,\n fieldName: string,\n durationMs: number\n ) => void;\n };\n federation?: boolean;\n prisma: {\n client: PrismaClient;\n dmmf?: {\n datamodel: unknown;\n };\n exposeDescriptions?: boolean;\n filterConnectionTotalCount?: boolean;\n onUnusedQuery?: 'warn' | null;\n };\n}\n\nexport function createPrismaSchemaBuilder<\n C extends object,\n PT extends {} | undefined,\n Objects extends object = object,\n Scalars extends object = object,\n>(options: PrismaBuilderOptions) {\n const debugBuilder =\n process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === 'true';\n // const plugins: (keyof PothosSchemaTypes.Plugins<SchemaTypes>)[] = [\n const plugins = [\n RelayPlugin,\n ComplexityPlugin,\n TracingPlugin,\n DataloaderPlugin,\n PrismaPlugin,\n ] satisfies (keyof PothosSchemaTypes.Plugins<SchemaTypes>)[];\n // if (options.federation) plugins.push(FederationPlugin);\n\n const builder = new SchemaBuilder<{\n DefaultInputFieldRequiredness: true;\n PrismaTypes: PT;\n Context: C;\n Objects: Objects;\n Scalars: {\n JSON: { Input: unknown; Output: unknown };\n Date: { Input: Date; Output: Date };\n EmailAddress: { Input: string; Output: string };\n Locale: { Input: string; Output: string };\n URL: { Input: string; Output: string };\n GeoJSON: { Input: string; Output: string };\n } & Scalars;\n ObjectType: { CommunityRule: { id: string } };\n }>({\n defaultInputFieldRequiredness: true,\n plugins,\n relay: {},\n prisma: {\n client: options.prisma.client,\n // ...(options.prisma.dmmf ? { dmmf: options.prisma.dmmf as any } : {}),\n dmmf: (options.prisma.dmmf as any) || {},\n exposeDescriptions: options.prisma.exposeDescriptions ?? true,\n filterConnectionTotalCount:\n options.prisma.filterConnectionTotalCount ?? true,\n onUnusedQuery: options.prisma.onUnusedQuery ?? null,\n },\n complexity: {\n defaultComplexity: options.complexity?.defaultComplexity ?? 1,\n defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10,\n },\n tracing: {\n default: (cfg) =>\n (options.tracing?.enableByDefault ?? true) ? isRootField(cfg) : false,\n wrap: (resolver, _opts, cfg) =>\n wrapResolver(resolver, (_err, dur) => {\n options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);\n }),\n },\n });\n\n if (debugBuilder) {\n console.log('[graphql-prisma] initializing schema builder');\n }\n\n Object.entries(ScalarTypeEnum).forEach(([name, type]) => {\n if (['ID', 'Boolean'].includes(name)) {\n return;\n }\n if (typeof type !== 'function') {\n throw new Error(\n `ScalarTypeEnum entry \"${name}\" must be a function but received ${typeof type}`\n );\n }\n if (debugBuilder) {\n console.log(`[graphql-prisma] registering scalar ${name}`);\n }\n builder.addScalarType(name as any, type());\n });\n builder.addScalarType('GeoJSON', GeoJSONResolver);\n\n builder.queryType({\n fields: (t) => ({}),\n });\n\n // Mutation Type (reduced, moved fields into modules)\n builder.mutationType({\n fields: (t) => ({}),\n });\n\n if (debugBuilder) {\n console.log('[graphql-prisma] schema builder ready');\n }\n\n return builder;\n}\n\n// export async function loadDmmfFromClient(\n// client: any\n// ): Promise<PrismaDMMF.Document> {\n// const dmmf: PrismaDMMF.Document | undefined = (client as any)?._dmmf;\n// if (dmmf) return dmmf;\n// if (typeof (client as any).$extends === 'function') {\n// const ext = await (client as any).$extends({});\n// if (ext && ext._dmmf) return ext._dmmf as PrismaDMMF.Document;\n// }\n// throw new Error('Unable to load Prisma DMMF from client');\n// }\n\n// export type PrismaSchemaBuilder<\n// C extends object,\n// PT extends {} | undefined,\n// > = PothosSchemaTypes.SchemaBuilder<\n// PothosSchemaTypes.ExtendDefaultTypes<{\n// PrismaTypes: PT;\n// Context: C;\n// Scalars: {\n// JSON: { Input: unknown; Output: unknown };\n// Date: { Input: Date; Output: Date };\n// };\n// }>\n// >;\n\n// export type PrismaSchemaBuilder<C, PT> = InstanceType<typeof SchemaBuilder><{\n// PrismaTypes: PT;\n// Context: C;\n// Scalars: {\n// JSON: { Input: unknown; Output: unknown };\n// Date: { Input: Date; Output: Date };\n// };\n// }>;\n\n// export function createTypedPrismaBuilder<PT extends {}>() {\n// return function create<C extends object>(options: PrismaBuilderOptions<C>) {\n// return createPrismaSchemaBuilder<C, PT>(options);\n// };\n// }\n\n// Tracing helper that integrates with a logger-like object\nexport interface LoggerLike {\n info: (msg: string, meta?: unknown) => void;\n}\nexport function createLoggerTracing(logger: LoggerLike, opLabel = 'gql.field') {\n return {\n enableByDefault: true,\n onResolved: (\n parentType: string,\n fieldName: string,\n durationMs: number,\n ...others: any[]\n ) => {\n // logger.info(opLabel, { parentType, fieldName, durationMs, others });\n },\n } as PrismaBuilderOptions['tracing'];\n}\n"],"mappings":"qWAwCA,SAAgB,EAKd,EAA+B,CAC/B,IAAM,EACJ,QAAQ,IAAI,qCAAuC,OAW/C,EAAU,IAAI,EAcjB,CACD,8BAA+B,GAC/B,QAzBc,CACd,EACA,EACA,EACA,EACA,EACD,CAoBC,MAAO,EAAE,CACT,OAAQ,CACN,OAAQ,EAAQ,OAAO,OAEvB,KAAO,EAAQ,OAAO,MAAgB,EAAE,CACxC,mBAAoB,EAAQ,OAAO,oBAAsB,GACzD,2BACE,EAAQ,OAAO,4BAA8B,GAC/C,cAAe,EAAQ,OAAO,eAAiB,KAChD,CACD,WAAY,CACV,kBAAmB,EAAQ,YAAY,mBAAqB,EAC5D,sBAAuB,EAAQ,YAAY,uBAAyB,GACrE,CACD,QAAS,CACP,QAAU,GACP,EAAQ,SAAS,iBAAmB,GAAQ,EAAY,EAAI,CAAG,GAClE,MAAO,EAAU,EAAO,IACtB,EAAa,GAAW,EAAM,IAAQ,CACpC,EAAQ,SAAS,aAAa,EAAI,WAAY,EAAI,KAAM,EAAI,EAC5D,CACL,CACF,CAAC,CAmCF,OAjCI,GACF,QAAQ,IAAI,+CAA+C,CAG7D,OAAO,QAAQ,EAAe,CAAC,SAAS,CAAC,EAAM,KAAU,CACnD,KAAC,KAAM,UAAU,CAAC,SAAS,EAAK,CAGpC,IAAI,OAAO,GAAS,WAClB,MAAU,MACR,yBAAyB,EAAK,oCAAoC,OAAO,IAC1E,CAEC,GACF,QAAQ,IAAI,uCAAuC,IAAO,CAE5D,EAAQ,cAAc,EAAa,GAAM,CAAC,GAC1C,CACF,EAAQ,cAAc,UAAW,EAAgB,CAEjD,EAAQ,UAAU,CAChB,OAAS,IAAO,EAAE,EACnB,CAAC,CAGF,EAAQ,aAAa,CACnB,OAAS,IAAO,EAAE,EACnB,CAAC,CAEE,GACF,QAAQ,IAAI,wCAAwC,CAG/C,EAgDT,SAAgB,EAAoB,EAAoB,EAAU,YAAa,CAC7E,MAAO,CACL,gBAAiB,GACjB,YACE,EACA,EACA,EACA,GAAG,IACA,GAGN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.graphql-prisma",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251217080011",
|
|
4
4
|
"description": "Pothos + Prisma builder factory with injectable client/DMMF",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"clean": "rm -rf dist"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@lssm/lib.schema": "0.0.0-canary-
|
|
19
|
+
"@lssm/lib.schema": "0.0.0-canary-20251217080011",
|
|
20
20
|
"@pothos/core": "^4.9.1",
|
|
21
21
|
"@pothos/plugin-complexity": "^4.1.2",
|
|
22
22
|
"@pothos/plugin-dataloader": "^4.4.2",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"graphql": ">=16.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
34
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
33
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251217080011",
|
|
34
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251217080011",
|
|
35
35
|
"tsdown": "^0.17.4",
|
|
36
36
|
"typescript": "^5.9.3"
|
|
37
37
|
},
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import "zod";
|
|
2
|
-
import { GraphQLScalarType } from "graphql";
|
|
3
|
-
|
|
4
|
-
//#region ../schema/dist/FieldType.js
|
|
5
|
-
/**
|
|
6
|
-
* GraphQL scalar wrapper that carries zod and JSON Schema metadata.
|
|
7
|
-
*
|
|
8
|
-
* TInternal is the runtime representation; TExternal is the GraphQL output.
|
|
9
|
-
*/
|
|
10
|
-
var FieldType = class extends GraphQLScalarType {
|
|
11
|
-
zodSchema;
|
|
12
|
-
jsonSchemaDef;
|
|
13
|
-
constructor(config) {
|
|
14
|
-
super(config);
|
|
15
|
-
this.zodSchema = config.zod;
|
|
16
|
-
this.jsonSchemaDef = config.jsonSchema;
|
|
17
|
-
}
|
|
18
|
-
/** Return the attached zod schema for validation. */
|
|
19
|
-
getZod() {
|
|
20
|
-
return this.zodSchema;
|
|
21
|
-
}
|
|
22
|
-
/** GraphQL scalar instance usable by Pothos or vanilla GraphQL. */
|
|
23
|
-
getPothos() {
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
/** Return the JSON Schema (evaluates factory if provided). */
|
|
27
|
-
getJson() {
|
|
28
|
-
return typeof this.jsonSchemaDef === "function" ? this.jsonSchemaDef() : this.jsonSchemaDef;
|
|
29
|
-
}
|
|
30
|
-
getJsonSchemaDef() {
|
|
31
|
-
return this.jsonSchemaDef;
|
|
32
|
-
}
|
|
33
|
-
getJsonSchema() {
|
|
34
|
-
const deepResolve = (v) => {
|
|
35
|
-
const value = typeof v === "function" ? v() : v;
|
|
36
|
-
if (Array.isArray(value)) return value.map((item) => deepResolve(item));
|
|
37
|
-
if (value && typeof value === "object") {
|
|
38
|
-
const obj = {};
|
|
39
|
-
for (const [k, val] of Object.entries(value)) obj[k] = deepResolve(val);
|
|
40
|
-
return obj;
|
|
41
|
-
}
|
|
42
|
-
return value;
|
|
43
|
-
};
|
|
44
|
-
return deepResolve(this.getJson());
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { FieldType };
|
|
50
|
-
//# sourceMappingURL=FieldType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FieldType.js","names":[],"sources":["../../../../schema/dist/FieldType.js"],"sourcesContent":["import \"zod\";\nimport { GraphQLScalarType } from \"graphql\";\n\n//#region src/FieldType.ts\n/**\n* GraphQL scalar wrapper that carries zod and JSON Schema metadata.\n*\n* TInternal is the runtime representation; TExternal is the GraphQL output.\n*/\nvar FieldType = class extends GraphQLScalarType {\n\tzodSchema;\n\tjsonSchemaDef;\n\tconstructor(config) {\n\t\tsuper(config);\n\t\tthis.zodSchema = config.zod;\n\t\tthis.jsonSchemaDef = config.jsonSchema;\n\t}\n\t/** Return the attached zod schema for validation. */\n\tgetZod() {\n\t\treturn this.zodSchema;\n\t}\n\t/** GraphQL scalar instance usable by Pothos or vanilla GraphQL. */\n\tgetPothos() {\n\t\treturn this;\n\t}\n\t/** Return the JSON Schema (evaluates factory if provided). */\n\tgetJson() {\n\t\treturn typeof this.jsonSchemaDef === \"function\" ? this.jsonSchemaDef() : this.jsonSchemaDef;\n\t}\n\tgetJsonSchemaDef() {\n\t\treturn this.jsonSchemaDef;\n\t}\n\tgetJsonSchema() {\n\t\tconst deepResolve = (v) => {\n\t\t\tconst value = typeof v === \"function\" ? v() : v;\n\t\t\tif (Array.isArray(value)) return value.map((item) => deepResolve(item));\n\t\t\tif (value && typeof value === \"object\") {\n\t\t\t\tconst obj = {};\n\t\t\t\tfor (const [k, val] of Object.entries(value)) obj[k] = deepResolve(val);\n\t\t\t\treturn obj;\n\t\t\t}\n\t\t\treturn value;\n\t\t};\n\t\treturn deepResolve(this.getJson());\n\t}\n};\n\n//#endregion\nexport { FieldType };"],"mappings":";;;;;;;;;AASA,IAAI,YAAY,cAAc,kBAAkB;CAC/C;CACA;CACA,YAAY,QAAQ;AACnB,QAAM,OAAO;AACb,OAAK,YAAY,OAAO;AACxB,OAAK,gBAAgB,OAAO;;;CAG7B,SAAS;AACR,SAAO,KAAK;;;CAGb,YAAY;AACX,SAAO;;;CAGR,UAAU;AACT,SAAO,OAAO,KAAK,kBAAkB,aAAa,KAAK,eAAe,GAAG,KAAK;;CAE/E,mBAAmB;AAClB,SAAO,KAAK;;CAEb,gBAAgB;EACf,MAAM,eAAe,MAAM;GAC1B,MAAM,QAAQ,OAAO,MAAM,aAAa,GAAG,GAAG;AAC9C,OAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,KAAK,SAAS,YAAY,KAAK,CAAC;AACvE,OAAI,SAAS,OAAO,UAAU,UAAU;IACvC,MAAM,MAAM,EAAE;AACd,SAAK,MAAM,CAAC,GAAG,QAAQ,OAAO,QAAQ,MAAM,CAAE,KAAI,KAAK,YAAY,IAAI;AACvE,WAAO;;AAER,UAAO;;AAER,SAAO,YAAY,KAAK,SAAS,CAAC"}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { FieldType } from "./FieldType.js";
|
|
2
|
-
import * as z from "zod";
|
|
3
|
-
import { Kind } from "graphql";
|
|
4
|
-
|
|
5
|
-
//#region ../schema/dist/ScalarTypeEnum.js
|
|
6
|
-
const localeRegex = /^[A-Za-z]{2}(?:-[A-Za-z0-9]{2,8})*$/;
|
|
7
|
-
const timezoneRegex = /^(?:UTC|[A-Za-z_]+\/[A-Za-z_]+)$/;
|
|
8
|
-
const phoneRegex = /^[+]?\d[\d\s().-]{3,}$/;
|
|
9
|
-
const currencyRegex = /^[A-Z]{3}$/;
|
|
10
|
-
const countryRegex = /^[A-Z]{2}$/;
|
|
11
|
-
const latMin = -90;
|
|
12
|
-
const latMax = 90;
|
|
13
|
-
const lonMin = -180;
|
|
14
|
-
const lonMax = 180;
|
|
15
|
-
/**
|
|
16
|
-
* Factory functions for common scalar FieldTypes with zod/GraphQL/JSON Schema.
|
|
17
|
-
*/
|
|
18
|
-
const ScalarTypeEnum = {
|
|
19
|
-
String_unsecure: () => new FieldType({
|
|
20
|
-
name: "String_unsecure",
|
|
21
|
-
description: "Unvalidated string scalar",
|
|
22
|
-
zod: z.string(),
|
|
23
|
-
parseValue: (v) => z.string().parse(v),
|
|
24
|
-
serialize: (v) => String(v),
|
|
25
|
-
parseLiteral: (ast) => {
|
|
26
|
-
if (ast.kind !== Kind.STRING) throw new TypeError("Invalid literal");
|
|
27
|
-
return ast.value;
|
|
28
|
-
},
|
|
29
|
-
jsonSchema: { type: "string" }
|
|
30
|
-
}),
|
|
31
|
-
Int_unsecure: () => new FieldType({
|
|
32
|
-
name: "Int_unsecure",
|
|
33
|
-
description: "Unvalidated integer scalar",
|
|
34
|
-
zod: z.number().int(),
|
|
35
|
-
parseValue: (v) => {
|
|
36
|
-
const num = typeof v === "number" ? v : Number(v);
|
|
37
|
-
return z.number().int().parse(num);
|
|
38
|
-
},
|
|
39
|
-
serialize: (v) => Math.trunc(typeof v === "number" ? v : Number(v)),
|
|
40
|
-
parseLiteral: (ast) => {
|
|
41
|
-
if (ast.kind !== Kind.INT) throw new TypeError("Invalid literal");
|
|
42
|
-
return Number(ast.value);
|
|
43
|
-
},
|
|
44
|
-
jsonSchema: { type: "integer" }
|
|
45
|
-
}),
|
|
46
|
-
Float_unsecure: () => new FieldType({
|
|
47
|
-
name: "Float_unsecure",
|
|
48
|
-
description: "Unvalidated float scalar",
|
|
49
|
-
zod: z.number(),
|
|
50
|
-
parseValue: (v) => {
|
|
51
|
-
const num = typeof v === "number" ? v : Number(v);
|
|
52
|
-
return z.number().parse(num);
|
|
53
|
-
},
|
|
54
|
-
serialize: (v) => Number(v),
|
|
55
|
-
parseLiteral: (ast) => {
|
|
56
|
-
if (ast.kind !== Kind.FLOAT && ast.kind !== Kind.INT) throw new TypeError("Invalid literal");
|
|
57
|
-
return Number(ast.value);
|
|
58
|
-
},
|
|
59
|
-
jsonSchema: { type: "number" }
|
|
60
|
-
}),
|
|
61
|
-
Boolean: () => new FieldType({
|
|
62
|
-
name: "Boolean",
|
|
63
|
-
description: "Unvalidated boolean scalar",
|
|
64
|
-
zod: z.boolean(),
|
|
65
|
-
parseValue: (v) => z.coerce.boolean().parse(v),
|
|
66
|
-
serialize: (v) => Boolean(v),
|
|
67
|
-
parseLiteral: (ast) => {
|
|
68
|
-
if (ast.kind !== Kind.BOOLEAN) throw new TypeError("Invalid literal");
|
|
69
|
-
return ast.value;
|
|
70
|
-
},
|
|
71
|
-
jsonSchema: { type: "boolean" }
|
|
72
|
-
}),
|
|
73
|
-
ID: () => new FieldType({
|
|
74
|
-
name: "ID",
|
|
75
|
-
description: "Unvalidated id scalar",
|
|
76
|
-
zod: z.string(),
|
|
77
|
-
parseValue: (v) => z.string().parse(v),
|
|
78
|
-
serialize: (v) => String(v),
|
|
79
|
-
parseLiteral: (ast) => {
|
|
80
|
-
if (ast.kind !== Kind.STRING) throw new TypeError("Invalid literal");
|
|
81
|
-
return ast.value;
|
|
82
|
-
},
|
|
83
|
-
jsonSchema: { type: "string" }
|
|
84
|
-
}),
|
|
85
|
-
JSON: () => new FieldType({
|
|
86
|
-
name: "JSON",
|
|
87
|
-
zod: z.any(),
|
|
88
|
-
parseValue: (v) => v,
|
|
89
|
-
serialize: (v) => v,
|
|
90
|
-
jsonSchema: {}
|
|
91
|
-
}),
|
|
92
|
-
JSONObject: () => new FieldType({
|
|
93
|
-
name: "JSONObject",
|
|
94
|
-
zod: z.record(z.string(), z.any()),
|
|
95
|
-
parseValue: (v) => z.record(z.string(), z.any()).parse(v),
|
|
96
|
-
serialize: (v) => v ?? {},
|
|
97
|
-
jsonSchema: { type: "object" }
|
|
98
|
-
}),
|
|
99
|
-
Date: () => new FieldType({
|
|
100
|
-
name: "Date",
|
|
101
|
-
zod: z.date(),
|
|
102
|
-
parseValue: (v) => v instanceof Date ? v : new Date(String(v)),
|
|
103
|
-
serialize: (v) => v instanceof Date ? v.toISOString().split("T")[0] : String(v),
|
|
104
|
-
jsonSchema: {
|
|
105
|
-
type: "string",
|
|
106
|
-
format: "date"
|
|
107
|
-
}
|
|
108
|
-
}),
|
|
109
|
-
DateTime: () => new FieldType({
|
|
110
|
-
name: "DateTime",
|
|
111
|
-
zod: z.date(),
|
|
112
|
-
parseValue: (v) => v instanceof Date ? v : new Date(String(v)),
|
|
113
|
-
serialize: (v) => {
|
|
114
|
-
return v instanceof Date ? v.toISOString() : String(v);
|
|
115
|
-
},
|
|
116
|
-
jsonSchema: {
|
|
117
|
-
type: "string",
|
|
118
|
-
format: "date-time"
|
|
119
|
-
}
|
|
120
|
-
}),
|
|
121
|
-
Time: () => new FieldType({
|
|
122
|
-
name: "Time",
|
|
123
|
-
zod: z.string().regex(/^\d{2}:\d{2}(:\d{2})?$/),
|
|
124
|
-
parseValue: (v) => z.string().regex(/^\d{2}:\d{2}(:\d{2})?$/).parse(v),
|
|
125
|
-
serialize: (v) => String(v),
|
|
126
|
-
jsonSchema: {
|
|
127
|
-
type: "string",
|
|
128
|
-
pattern: "^\\d{2}:\\d{2}(:\\d{2})?$"
|
|
129
|
-
}
|
|
130
|
-
}),
|
|
131
|
-
EmailAddress: () => new FieldType({
|
|
132
|
-
name: "EmailAddress",
|
|
133
|
-
zod: z.string().email(),
|
|
134
|
-
parseValue: (v) => z.string().email().parse(v),
|
|
135
|
-
serialize: (v) => String(v),
|
|
136
|
-
jsonSchema: {
|
|
137
|
-
type: "string",
|
|
138
|
-
format: "email"
|
|
139
|
-
}
|
|
140
|
-
}),
|
|
141
|
-
URL: () => new FieldType({
|
|
142
|
-
name: "URL",
|
|
143
|
-
zod: z.string().url(),
|
|
144
|
-
parseValue: (v) => z.string().url().parse(v),
|
|
145
|
-
serialize: (v) => String(v),
|
|
146
|
-
jsonSchema: {
|
|
147
|
-
type: "string",
|
|
148
|
-
format: "uri"
|
|
149
|
-
}
|
|
150
|
-
}),
|
|
151
|
-
PhoneNumber: () => new FieldType({
|
|
152
|
-
name: "PhoneNumber",
|
|
153
|
-
zod: z.string().regex(phoneRegex),
|
|
154
|
-
parseValue: (v) => z.string().regex(phoneRegex).parse(v),
|
|
155
|
-
serialize: (v) => String(v),
|
|
156
|
-
jsonSchema: {
|
|
157
|
-
type: "string",
|
|
158
|
-
pattern: phoneRegex.source
|
|
159
|
-
}
|
|
160
|
-
}),
|
|
161
|
-
NonEmptyString: () => new FieldType({
|
|
162
|
-
name: "NonEmptyString",
|
|
163
|
-
zod: z.string().min(1),
|
|
164
|
-
parseValue: (v) => z.string().min(1).parse(v),
|
|
165
|
-
serialize: (v) => String(v),
|
|
166
|
-
jsonSchema: {
|
|
167
|
-
type: "string",
|
|
168
|
-
minLength: 1
|
|
169
|
-
}
|
|
170
|
-
}),
|
|
171
|
-
Locale: () => new FieldType({
|
|
172
|
-
name: "Locale",
|
|
173
|
-
zod: z.string().regex(localeRegex),
|
|
174
|
-
parseValue: (v) => z.string().regex(localeRegex).parse(v),
|
|
175
|
-
serialize: (v) => String(v),
|
|
176
|
-
jsonSchema: {
|
|
177
|
-
type: "string",
|
|
178
|
-
pattern: localeRegex.source
|
|
179
|
-
}
|
|
180
|
-
}),
|
|
181
|
-
TimeZone: () => new FieldType({
|
|
182
|
-
name: "TimeZone",
|
|
183
|
-
zod: z.string().regex(timezoneRegex),
|
|
184
|
-
parseValue: (v) => z.string().regex(timezoneRegex).parse(v),
|
|
185
|
-
serialize: (v) => String(v),
|
|
186
|
-
jsonSchema: {
|
|
187
|
-
type: "string",
|
|
188
|
-
pattern: timezoneRegex.source
|
|
189
|
-
}
|
|
190
|
-
}),
|
|
191
|
-
Latitude: () => new FieldType({
|
|
192
|
-
name: "Latitude",
|
|
193
|
-
zod: z.number().min(latMin).max(latMax),
|
|
194
|
-
parseValue: (v) => z.coerce.number().min(latMin).max(latMax).parse(v),
|
|
195
|
-
serialize: (v) => Number(v),
|
|
196
|
-
jsonSchema: {
|
|
197
|
-
type: "number",
|
|
198
|
-
minimum: latMin,
|
|
199
|
-
maximum: latMax
|
|
200
|
-
}
|
|
201
|
-
}),
|
|
202
|
-
Longitude: () => new FieldType({
|
|
203
|
-
name: "Longitude",
|
|
204
|
-
zod: z.number().min(lonMin).max(lonMax),
|
|
205
|
-
parseValue: (v) => z.coerce.number().min(lonMin).max(lonMax).parse(v),
|
|
206
|
-
serialize: (v) => Number(v),
|
|
207
|
-
jsonSchema: {
|
|
208
|
-
type: "number",
|
|
209
|
-
minimum: lonMin,
|
|
210
|
-
maximum: lonMax
|
|
211
|
-
}
|
|
212
|
-
}),
|
|
213
|
-
Currency: () => new FieldType({
|
|
214
|
-
name: "Currency",
|
|
215
|
-
zod: z.string().regex(currencyRegex),
|
|
216
|
-
parseValue: (v) => z.string().regex(currencyRegex).parse(v),
|
|
217
|
-
serialize: (v) => String(v),
|
|
218
|
-
jsonSchema: {
|
|
219
|
-
type: "string",
|
|
220
|
-
pattern: currencyRegex.source
|
|
221
|
-
}
|
|
222
|
-
}),
|
|
223
|
-
CountryCode: () => new FieldType({
|
|
224
|
-
name: "CountryCode",
|
|
225
|
-
zod: z.string().regex(countryRegex),
|
|
226
|
-
parseValue: (v) => z.string().regex(countryRegex).parse(v),
|
|
227
|
-
serialize: (v) => String(v),
|
|
228
|
-
jsonSchema: {
|
|
229
|
-
type: "string",
|
|
230
|
-
pattern: countryRegex.source
|
|
231
|
-
}
|
|
232
|
-
})
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
//#endregion
|
|
236
|
-
export { ScalarTypeEnum };
|
|
237
|
-
//# sourceMappingURL=ScalarTypeEnum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarTypeEnum.js","names":[],"sources":["../../../../schema/dist/ScalarTypeEnum.js"],"sourcesContent":["import { FieldType } from \"./FieldType.js\";\nimport * as z from \"zod\";\nimport { Kind } from \"graphql\";\n\n//#region src/ScalarTypeEnum.ts\nconst localeRegex = /^[A-Za-z]{2}(?:-[A-Za-z0-9]{2,8})*$/;\nconst timezoneRegex = /^(?:UTC|[A-Za-z_]+\\/[A-Za-z_]+)$/;\nconst phoneRegex = /^[+]?\\d[\\d\\s().-]{3,}$/;\nconst currencyRegex = /^[A-Z]{3}$/;\nconst countryRegex = /^[A-Z]{2}$/;\nconst latMin = -90;\nconst latMax = 90;\nconst lonMin = -180;\nconst lonMax = 180;\n/**\n* Factory functions for common scalar FieldTypes with zod/GraphQL/JSON Schema.\n*/\nconst ScalarTypeEnum = {\n\tString_unsecure: () => new FieldType({\n\t\tname: \"String_unsecure\",\n\t\tdescription: \"Unvalidated string scalar\",\n\t\tzod: z.string(),\n\t\tparseValue: (v) => z.string().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.STRING) throw new TypeError(\"Invalid literal\");\n\t\t\treturn ast.value;\n\t\t},\n\t\tjsonSchema: { type: \"string\" }\n\t}),\n\tInt_unsecure: () => new FieldType({\n\t\tname: \"Int_unsecure\",\n\t\tdescription: \"Unvalidated integer scalar\",\n\t\tzod: z.number().int(),\n\t\tparseValue: (v) => {\n\t\t\tconst num = typeof v === \"number\" ? v : Number(v);\n\t\t\treturn z.number().int().parse(num);\n\t\t},\n\t\tserialize: (v) => Math.trunc(typeof v === \"number\" ? v : Number(v)),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.INT) throw new TypeError(\"Invalid literal\");\n\t\t\treturn Number(ast.value);\n\t\t},\n\t\tjsonSchema: { type: \"integer\" }\n\t}),\n\tFloat_unsecure: () => new FieldType({\n\t\tname: \"Float_unsecure\",\n\t\tdescription: \"Unvalidated float scalar\",\n\t\tzod: z.number(),\n\t\tparseValue: (v) => {\n\t\t\tconst num = typeof v === \"number\" ? v : Number(v);\n\t\t\treturn z.number().parse(num);\n\t\t},\n\t\tserialize: (v) => Number(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.FLOAT && ast.kind !== Kind.INT) throw new TypeError(\"Invalid literal\");\n\t\t\treturn Number(ast.value);\n\t\t},\n\t\tjsonSchema: { type: \"number\" }\n\t}),\n\tBoolean: () => new FieldType({\n\t\tname: \"Boolean\",\n\t\tdescription: \"Unvalidated boolean scalar\",\n\t\tzod: z.boolean(),\n\t\tparseValue: (v) => z.coerce.boolean().parse(v),\n\t\tserialize: (v) => Boolean(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.BOOLEAN) throw new TypeError(\"Invalid literal\");\n\t\t\treturn ast.value;\n\t\t},\n\t\tjsonSchema: { type: \"boolean\" }\n\t}),\n\tID: () => new FieldType({\n\t\tname: \"ID\",\n\t\tdescription: \"Unvalidated id scalar\",\n\t\tzod: z.string(),\n\t\tparseValue: (v) => z.string().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.STRING) throw new TypeError(\"Invalid literal\");\n\t\t\treturn ast.value;\n\t\t},\n\t\tjsonSchema: { type: \"string\" }\n\t}),\n\tJSON: () => new FieldType({\n\t\tname: \"JSON\",\n\t\tzod: z.any(),\n\t\tparseValue: (v) => v,\n\t\tserialize: (v) => v,\n\t\tjsonSchema: {}\n\t}),\n\tJSONObject: () => new FieldType({\n\t\tname: \"JSONObject\",\n\t\tzod: z.record(z.string(), z.any()),\n\t\tparseValue: (v) => z.record(z.string(), z.any()).parse(v),\n\t\tserialize: (v) => v ?? {},\n\t\tjsonSchema: { type: \"object\" }\n\t}),\n\tDate: () => new FieldType({\n\t\tname: \"Date\",\n\t\tzod: z.date(),\n\t\tparseValue: (v) => v instanceof Date ? v : new Date(String(v)),\n\t\tserialize: (v) => v instanceof Date ? v.toISOString().split(\"T\")[0] : String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date\"\n\t\t}\n\t}),\n\tDateTime: () => new FieldType({\n\t\tname: \"DateTime\",\n\t\tzod: z.date(),\n\t\tparseValue: (v) => v instanceof Date ? v : new Date(String(v)),\n\t\tserialize: (v) => {\n\t\t\treturn v instanceof Date ? v.toISOString() : String(v);\n\t\t},\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\"\n\t\t}\n\t}),\n\tTime: () => new FieldType({\n\t\tname: \"Time\",\n\t\tzod: z.string().regex(/^\\d{2}:\\d{2}(:\\d{2})?$/),\n\t\tparseValue: (v) => z.string().regex(/^\\d{2}:\\d{2}(:\\d{2})?$/).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: \"^\\\\d{2}:\\\\d{2}(:\\\\d{2})?$\"\n\t\t}\n\t}),\n\tEmailAddress: () => new FieldType({\n\t\tname: \"EmailAddress\",\n\t\tzod: z.string().email(),\n\t\tparseValue: (v) => z.string().email().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"email\"\n\t\t}\n\t}),\n\tURL: () => new FieldType({\n\t\tname: \"URL\",\n\t\tzod: z.string().url(),\n\t\tparseValue: (v) => z.string().url().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"uri\"\n\t\t}\n\t}),\n\tPhoneNumber: () => new FieldType({\n\t\tname: \"PhoneNumber\",\n\t\tzod: z.string().regex(phoneRegex),\n\t\tparseValue: (v) => z.string().regex(phoneRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: phoneRegex.source\n\t\t}\n\t}),\n\tNonEmptyString: () => new FieldType({\n\t\tname: \"NonEmptyString\",\n\t\tzod: z.string().min(1),\n\t\tparseValue: (v) => z.string().min(1).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tminLength: 1\n\t\t}\n\t}),\n\tLocale: () => new FieldType({\n\t\tname: \"Locale\",\n\t\tzod: z.string().regex(localeRegex),\n\t\tparseValue: (v) => z.string().regex(localeRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: localeRegex.source\n\t\t}\n\t}),\n\tTimeZone: () => new FieldType({\n\t\tname: \"TimeZone\",\n\t\tzod: z.string().regex(timezoneRegex),\n\t\tparseValue: (v) => z.string().regex(timezoneRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: timezoneRegex.source\n\t\t}\n\t}),\n\tLatitude: () => new FieldType({\n\t\tname: \"Latitude\",\n\t\tzod: z.number().min(latMin).max(latMax),\n\t\tparseValue: (v) => z.coerce.number().min(latMin).max(latMax).parse(v),\n\t\tserialize: (v) => Number(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"number\",\n\t\t\tminimum: latMin,\n\t\t\tmaximum: latMax\n\t\t}\n\t}),\n\tLongitude: () => new FieldType({\n\t\tname: \"Longitude\",\n\t\tzod: z.number().min(lonMin).max(lonMax),\n\t\tparseValue: (v) => z.coerce.number().min(lonMin).max(lonMax).parse(v),\n\t\tserialize: (v) => Number(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"number\",\n\t\t\tminimum: lonMin,\n\t\t\tmaximum: lonMax\n\t\t}\n\t}),\n\tCurrency: () => new FieldType({\n\t\tname: \"Currency\",\n\t\tzod: z.string().regex(currencyRegex),\n\t\tparseValue: (v) => z.string().regex(currencyRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: currencyRegex.source\n\t\t}\n\t}),\n\tCountryCode: () => new FieldType({\n\t\tname: \"CountryCode\",\n\t\tzod: z.string().regex(countryRegex),\n\t\tparseValue: (v) => z.string().regex(countryRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: countryRegex.source\n\t\t}\n\t})\n};\n\n//#endregion\nexport { ScalarTypeEnum };"],"mappings":";;;;;AAKA,MAAM,cAAc;AACpB,MAAM,gBAAgB;AACtB,MAAM,aAAa;AACnB,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,SAAS;;;;AAIf,MAAM,iBAAiB;CACtB,uBAAuB,IAAI,UAAU;EACpC,MAAM;EACN,aAAa;EACb,KAAK,EAAE,QAAQ;EACf,aAAa,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE;EACtC,YAAY,MAAM,OAAO,EAAE;EAC3B,eAAe,QAAQ;AACtB,OAAI,IAAI,SAAS,KAAK,OAAQ,OAAM,IAAI,UAAU,kBAAkB;AACpE,UAAO,IAAI;;EAEZ,YAAY,EAAE,MAAM,UAAU;EAC9B,CAAC;CACF,oBAAoB,IAAI,UAAU;EACjC,MAAM;EACN,aAAa;EACb,KAAK,EAAE,QAAQ,CAAC,KAAK;EACrB,aAAa,MAAM;GAClB,MAAM,MAAM,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE;AACjD,UAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,IAAI;;EAEnC,YAAY,MAAM,KAAK,MAAM,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE,CAAC;EACnE,eAAe,QAAQ;AACtB,OAAI,IAAI,SAAS,KAAK,IAAK,OAAM,IAAI,UAAU,kBAAkB;AACjE,UAAO,OAAO,IAAI,MAAM;;EAEzB,YAAY,EAAE,MAAM,WAAW;EAC/B,CAAC;CACF,sBAAsB,IAAI,UAAU;EACnC,MAAM;EACN,aAAa;EACb,KAAK,EAAE,QAAQ;EACf,aAAa,MAAM;GAClB,MAAM,MAAM,OAAO,MAAM,WAAW,IAAI,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