@lyku/lockstep-core 0.2.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/HandlerModel.d.ts +38 -0
- package/HandlerModel.d.ts.map +1 -0
- package/HandlerModel.js +2 -0
- package/HandlerModel.js.map +1 -0
- package/HttpRoute.d.ts +8 -0
- package/HttpRoute.d.ts.map +1 -0
- package/HttpRoute.js +2 -0
- package/HttpRoute.js.map +1 -0
- package/LLMs.md +979 -0
- package/MongoCollectionModel.d.ts +9 -0
- package/MongoCollectionModel.d.ts.map +1 -0
- package/MongoCollectionModel.js +2 -0
- package/MongoCollectionModel.js.map +1 -0
- package/MongoDatabaseModel.d.ts +7 -0
- package/MongoDatabaseModel.d.ts.map +1 -0
- package/MongoDatabaseModel.js +2 -0
- package/MongoDatabaseModel.js.map +1 -0
- package/ProtoValidator.d.ts +6 -0
- package/ProtoValidator.d.ts.map +1 -0
- package/ProtoValidator.js +2 -0
- package/ProtoValidator.js.map +1 -0
- package/README.md +311 -0
- package/TsonHandlerModel.d.ts +126 -0
- package/TsonHandlerModel.d.ts.map +1 -0
- package/TsonHandlerModel.js +2 -0
- package/TsonHandlerModel.js.map +1 -0
- package/Validator.d.ts +6 -0
- package/Validator.d.ts.map +1 -0
- package/Validator.js +2 -0
- package/Validator.js.map +1 -0
- package/WebSocketRoute.d.ts +3 -0
- package/WebSocketRoute.d.ts.map +1 -0
- package/WebSocketRoute.js +2 -0
- package/WebSocketRoute.js.map +1 -0
- package/alpha.d.ts +2 -0
- package/alpha.d.ts.map +1 -0
- package/alpha.js +2 -0
- package/alpha.js.map +1 -0
- package/bson/AllOfBsonSchema.d.ts +8 -0
- package/bson/AllOfBsonSchema.d.ts.map +1 -0
- package/bson/AllOfBsonSchema.js +2 -0
- package/bson/AllOfBsonSchema.js.map +1 -0
- package/bson/AnyOfBsonSchema.d.ts +8 -0
- package/bson/AnyOfBsonSchema.d.ts.map +1 -0
- package/bson/AnyOfBsonSchema.js +2 -0
- package/bson/AnyOfBsonSchema.js.map +1 -0
- package/bson/ArrayBsonSchema.d.ts +10 -0
- package/bson/ArrayBsonSchema.d.ts.map +1 -0
- package/bson/ArrayBsonSchema.js +2 -0
- package/bson/ArrayBsonSchema.js.map +1 -0
- package/bson/BooleanBsonSchema.d.ts +6 -0
- package/bson/BooleanBsonSchema.d.ts.map +1 -0
- package/bson/BooleanBsonSchema.js +2 -0
- package/bson/BooleanBsonSchema.js.map +1 -0
- package/bson/BsonSchemaOrPrimitive.d.ts +17 -0
- package/bson/BsonSchemaOrPrimitive.d.ts.map +1 -0
- package/bson/BsonSchemaOrPrimitive.js +2 -0
- package/bson/BsonSchemaOrPrimitive.js.map +1 -0
- package/bson/DateBsonSchema.d.ts +7 -0
- package/bson/DateBsonSchema.d.ts.map +1 -0
- package/bson/DateBsonSchema.js +2 -0
- package/bson/DateBsonSchema.js.map +1 -0
- package/bson/DecimalBsonSchema.d.ts +5 -0
- package/bson/DecimalBsonSchema.d.ts.map +1 -0
- package/bson/DecimalBsonSchema.js +2 -0
- package/bson/DecimalBsonSchema.js.map +1 -0
- package/bson/DoubleBsonSchema.d.ts +5 -0
- package/bson/DoubleBsonSchema.d.ts.map +1 -0
- package/bson/DoubleBsonSchema.js +2 -0
- package/bson/DoubleBsonSchema.js.map +1 -0
- package/bson/EmailBsonSchema.d.ts +5 -0
- package/bson/EmailBsonSchema.d.ts.map +1 -0
- package/bson/EmailBsonSchema.js +2 -0
- package/bson/EmailBsonSchema.js.map +1 -0
- package/bson/EnumBsonSchema.d.ts +8 -0
- package/bson/EnumBsonSchema.d.ts.map +1 -0
- package/bson/EnumBsonSchema.js +2 -0
- package/bson/EnumBsonSchema.js.map +1 -0
- package/bson/EnumBsonSchemaOf.d.ts +6 -0
- package/bson/EnumBsonSchemaOf.d.ts.map +1 -0
- package/bson/EnumBsonSchemaOf.js +2 -0
- package/bson/EnumBsonSchemaOf.js.map +1 -0
- package/bson/FromBsonSchema.d.ts +13 -0
- package/bson/FromBsonSchema.d.ts.map +1 -0
- package/bson/FromBsonSchema.js +2 -0
- package/bson/FromBsonSchema.js.map +1 -0
- package/bson/FromObjectBsonSchema.d.ts +5 -0
- package/bson/FromObjectBsonSchema.d.ts.map +1 -0
- package/bson/FromObjectBsonSchema.js +2 -0
- package/bson/FromObjectBsonSchema.js.map +1 -0
- package/bson/FromObjectSchema.d.ts +5 -0
- package/bson/FromObjectSchema.d.ts.map +1 -0
- package/bson/FromObjectSchema.js +2 -0
- package/bson/FromObjectSchema.js.map +1 -0
- package/bson/FromPropertyBsonSchemas.d.ts +6 -0
- package/bson/FromPropertyBsonSchemas.d.ts.map +1 -0
- package/bson/FromPropertyBsonSchemas.js +2 -0
- package/bson/FromPropertyBsonSchemas.js.map +1 -0
- package/bson/IntBsonSchema.d.ts +5 -0
- package/bson/IntBsonSchema.d.ts.map +1 -0
- package/bson/IntBsonSchema.js +2 -0
- package/bson/IntBsonSchema.js.map +1 -0
- package/bson/LongBsonSchema.d.ts +5 -0
- package/bson/LongBsonSchema.d.ts.map +1 -0
- package/bson/LongBsonSchema.js +2 -0
- package/bson/LongBsonSchema.js.map +1 -0
- package/bson/MapBsonSchema.d.ts +25 -0
- package/bson/MapBsonSchema.d.ts.map +1 -0
- package/bson/MapBsonSchema.js +2 -0
- package/bson/MapBsonSchema.js.map +1 -0
- package/bson/NaturalNumberSchema.d.ts +5 -0
- package/bson/NaturalNumberSchema.d.ts.map +1 -0
- package/bson/NaturalNumberSchema.js +2 -0
- package/bson/NaturalNumberSchema.js.map +1 -0
- package/bson/NumberBsonSchema.d.ts +6 -0
- package/bson/NumberBsonSchema.d.ts.map +1 -0
- package/bson/NumberBsonSchema.js +2 -0
- package/bson/NumberBsonSchema.js.map +1 -0
- package/bson/NumberBsonSchemaBase.d.ts +7 -0
- package/bson/NumberBsonSchemaBase.d.ts.map +1 -0
- package/bson/NumberBsonSchemaBase.js +2 -0
- package/bson/NumberBsonSchemaBase.js.map +1 -0
- package/bson/ObjectBsonSchema.d.ts +14 -0
- package/bson/ObjectBsonSchema.d.ts.map +1 -0
- package/bson/ObjectBsonSchema.js +2 -0
- package/bson/ObjectBsonSchema.js.map +1 -0
- package/bson/ObjectIdBsonSchema.d.ts +5 -0
- package/bson/ObjectIdBsonSchema.d.ts.map +1 -0
- package/bson/ObjectIdBsonSchema.js +2 -0
- package/bson/ObjectIdBsonSchema.js.map +1 -0
- package/bson/OneOfBsonSchema.d.ts +8 -0
- package/bson/OneOfBsonSchema.d.ts.map +1 -0
- package/bson/OneOfBsonSchema.js +2 -0
- package/bson/OneOfBsonSchema.js.map +1 -0
- package/bson/OnlyOptionalBson.d.ts +5 -0
- package/bson/OnlyOptionalBson.d.ts.map +1 -0
- package/bson/OnlyOptionalBson.js +2 -0
- package/bson/OnlyOptionalBson.js.map +1 -0
- package/bson/OnlyRequiredBson.d.ts +5 -0
- package/bson/OnlyRequiredBson.d.ts.map +1 -0
- package/bson/OnlyRequiredBson.js +2 -0
- package/bson/OnlyRequiredBson.js.map +1 -0
- package/bson/PrimitiveOrFromBsonSchema.d.ts +4 -0
- package/bson/PrimitiveOrFromBsonSchema.d.ts.map +1 -0
- package/bson/PrimitiveOrFromBsonSchema.js +2 -0
- package/bson/PrimitiveOrFromBsonSchema.js.map +1 -0
- package/bson/RequiredPropOfBson.d.ts +3 -0
- package/bson/RequiredPropOfBson.d.ts.map +1 -0
- package/bson/RequiredPropOfBson.js +2 -0
- package/bson/RequiredPropOfBson.js.map +1 -0
- package/bson/StringBsonSchema.d.ts +9 -0
- package/bson/StringBsonSchema.d.ts.map +1 -0
- package/bson/StringBsonSchema.js +2 -0
- package/bson/StringBsonSchema.js.map +1 -0
- package/bson/UidBsonSchema.d.ts +5 -0
- package/bson/UidBsonSchema.d.ts.map +1 -0
- package/bson/UidBsonSchema.js +2 -0
- package/bson/UidBsonSchema.js.map +1 -0
- package/bson/UnionBsonSchema.d.ts +19 -0
- package/bson/UnionBsonSchema.d.ts.map +1 -0
- package/bson/UnionBsonSchema.js +2 -0
- package/bson/UnionBsonSchema.js.map +1 -0
- package/bson/UuidV4BsonSchema.d.ts +5 -0
- package/bson/UuidV4BsonSchema.d.ts.map +1 -0
- package/bson/UuidV4BsonSchema.js +2 -0
- package/bson/UuidV4BsonSchema.js.map +1 -0
- package/bson/UuidV5BsonSchema.d.ts +5 -0
- package/bson/UuidV5BsonSchema.d.ts.map +1 -0
- package/bson/UuidV5BsonSchema.js +2 -0
- package/bson/UuidV5BsonSchema.js.map +1 -0
- package/bson/WholeNumberBsonSchema.d.ts +5 -0
- package/bson/WholeNumberBsonSchema.d.ts.map +1 -0
- package/bson/WholeNumberBsonSchema.js +2 -0
- package/bson/WholeNumberBsonSchema.js.map +1 -0
- package/bson/index.d.ts +31 -0
- package/bson/index.d.ts.map +1 -0
- package/bson/index.js +32 -0
- package/bson/index.js.map +1 -0
- package/bson/primitives.d.ts +58 -0
- package/bson/primitives.d.ts.map +1 -0
- package/bson/primitives.js +58 -0
- package/bson/primitives.js.map +1 -0
- package/bson2json/allOfBsonToJson.d.ts +4 -0
- package/bson2json/allOfBsonToJson.d.ts.map +1 -0
- package/bson2json/allOfBsonToJson.js +7 -0
- package/bson2json/allOfBsonToJson.js.map +1 -0
- package/bson2json/anyOfBsonToJson.d.ts +4 -0
- package/bson2json/anyOfBsonToJson.d.ts.map +1 -0
- package/bson2json/anyOfBsonToJson.js +7 -0
- package/bson2json/anyOfBsonToJson.js.map +1 -0
- package/bson2json/arrayBsonToJson.d.ts +4 -0
- package/bson2json/arrayBsonToJson.d.ts.map +1 -0
- package/bson2json/arrayBsonToJson.js +8 -0
- package/bson2json/arrayBsonToJson.js.map +1 -0
- package/bson2json/booleanBsonToJson.d.ts +4 -0
- package/bson2json/booleanBsonToJson.d.ts.map +1 -0
- package/bson2json/booleanBsonToJson.js +6 -0
- package/bson2json/booleanBsonToJson.js.map +1 -0
- package/bson2json/bsonToJson.d.ts +4 -0
- package/bson2json/bsonToJson.d.ts.map +1 -0
- package/bson2json/bsonToJson.js +57 -0
- package/bson2json/bsonToJson.js.map +1 -0
- package/bson2json/dateBsonToJson.d.ts +4 -0
- package/bson2json/dateBsonToJson.d.ts.map +1 -0
- package/bson2json/dateBsonToJson.js +5 -0
- package/bson2json/dateBsonToJson.js.map +1 -0
- package/bson2json/enumBsonToJson.d.ts +4 -0
- package/bson2json/enumBsonToJson.d.ts.map +1 -0
- package/bson2json/enumBsonToJson.js +5 -0
- package/bson2json/enumBsonToJson.js.map +1 -0
- package/bson2json/index.d.ts +10 -0
- package/bson2json/index.d.ts.map +1 -0
- package/bson2json/index.js +10 -0
- package/bson2json/index.js.map +1 -0
- package/bson2json/numberBsonToJson.d.ts +4 -0
- package/bson2json/numberBsonToJson.d.ts.map +1 -0
- package/bson2json/numberBsonToJson.js +6 -0
- package/bson2json/numberBsonToJson.js.map +1 -0
- package/bson2json/objectBsonToJson.d.ts +4 -0
- package/bson2json/objectBsonToJson.d.ts.map +1 -0
- package/bson2json/objectBsonToJson.js +16 -0
- package/bson2json/objectBsonToJson.js.map +1 -0
- package/bson2json/objectIdBsonToJson.d.ts +4 -0
- package/bson2json/objectIdBsonToJson.d.ts.map +1 -0
- package/bson2json/objectIdBsonToJson.js +5 -0
- package/bson2json/objectIdBsonToJson.js.map +1 -0
- package/bson2json/oneOfBsonToJson.d.ts +4 -0
- package/bson2json/oneOfBsonToJson.d.ts.map +1 -0
- package/bson2json/oneOfBsonToJson.js +7 -0
- package/bson2json/oneOfBsonToJson.js.map +1 -0
- package/bson2json/stringBsonToJson.d.ts +4 -0
- package/bson2json/stringBsonToJson.d.ts.map +1 -0
- package/bson2json/stringBsonToJson.js +10 -0
- package/bson2json/stringBsonToJson.js.map +1 -0
- package/bson2json/stripBsonType.d.ts +5 -0
- package/bson2json/stripBsonType.d.ts.map +1 -0
- package/bson2json/stripBsonType.js +6 -0
- package/bson2json/stripBsonType.js.map +1 -0
- package/bson2json/wholeBsonToJson.d.ts +4 -0
- package/bson2json/wholeBsonToJson.d.ts.map +1 -0
- package/bson2json/wholeBsonToJson.js +6 -0
- package/bson2json/wholeBsonToJson.js.map +1 -0
- package/cli.d.ts +23 -0
- package/cli.d.ts.map +1 -0
- package/cli.js +138 -0
- package/cli.js.map +1 -0
- package/cli.ts +160 -0
- package/contexts/index.d.ts +39 -0
- package/contexts/index.d.ts.map +1 -0
- package/contexts/index.js +2 -0
- package/contexts/index.js.map +1 -0
- package/errors.d.ts +1 -0
- package/errors.d.ts.map +1 -0
- package/errors.js +2 -0
- package/errors.js.map +1 -0
- package/generators/filterHandlerModels.d.ts +8 -0
- package/generators/filterHandlerModels.d.ts.map +1 -0
- package/generators/filterHandlerModels.js +18 -0
- package/generators/filterHandlerModels.js.map +1 -0
- package/generators/format.d.ts +2 -0
- package/generators/format.d.ts.map +1 -0
- package/generators/format.js +29 -0
- package/generators/format.js.map +1 -0
- package/generators/generateApiTypes.d.ts +10 -0
- package/generators/generateApiTypes.d.ts.map +1 -0
- package/generators/generateApiTypes.js +61 -0
- package/generators/generateApiTypes.js.map +1 -0
- package/generators/generateClient.d.ts +12 -0
- package/generators/generateClient.d.ts.map +1 -0
- package/generators/generateClient.js +193 -0
- package/generators/generateClient.js.map +1 -0
- package/generators/generateDbTypes.d.ts +10 -0
- package/generators/generateDbTypes.d.ts.map +1 -0
- package/generators/generateDbTypes.js +37 -0
- package/generators/generateDbTypes.js.map +1 -0
- package/generators/generateHandles.d.ts +22 -0
- package/generators/generateHandles.d.ts.map +1 -0
- package/generators/generateHandles.js +103 -0
- package/generators/generateHandles.js.map +1 -0
- package/generators/generateJsonModels.d.ts +10 -0
- package/generators/generateJsonModels.d.ts.map +1 -0
- package/generators/generateJsonModels.js +99 -0
- package/generators/generateJsonModels.js.map +1 -0
- package/generators/index.d.ts +13 -0
- package/generators/index.d.ts.map +1 -0
- package/generators/index.js +8 -0
- package/generators/index.js.map +1 -0
- package/generic/NumberJsonSchemaBase.d.ts +7 -0
- package/generic/NumberJsonSchemaBase.d.ts.map +1 -0
- package/generic/NumberJsonSchemaBase.js +2 -0
- package/generic/NumberJsonSchemaBase.js.map +1 -0
- package/generic/Primitive.d.ts +2 -0
- package/generic/Primitive.d.ts.map +1 -0
- package/generic/Primitive.js +2 -0
- package/generic/Primitive.js.map +1 -0
- package/generic/SchemaBase.d.ts +5 -0
- package/generic/SchemaBase.d.ts.map +1 -0
- package/generic/SchemaBase.js +2 -0
- package/generic/SchemaBase.js.map +1 -0
- package/generic/index.d.ts +4 -0
- package/generic/index.d.ts.map +1 -0
- package/generic/index.js +4 -0
- package/generic/index.js.map +1 -0
- package/index.d.ts +23 -0
- package/index.d.ts.map +1 -0
- package/index.js +25 -0
- package/index.js.map +1 -0
- package/isObject.d.ts +2 -0
- package/isObject.d.ts.map +1 -0
- package/isObject.js +4 -0
- package/isObject.js.map +1 -0
- package/json/ArrayJsonSchema.d.ts +12 -0
- package/json/ArrayJsonSchema.d.ts.map +1 -0
- package/json/ArrayJsonSchema.js +2 -0
- package/json/ArrayJsonSchema.js.map +1 -0
- package/json/BooleanJsonSchema.d.ts +7 -0
- package/json/BooleanJsonSchema.d.ts.map +1 -0
- package/json/BooleanJsonSchema.js +2 -0
- package/json/BooleanJsonSchema.js.map +1 -0
- package/json/DateJsonSchema.d.ts +7 -0
- package/json/DateJsonSchema.d.ts.map +1 -0
- package/json/DateJsonSchema.js +2 -0
- package/json/DateJsonSchema.js.map +1 -0
- package/json/EnumJsonSchema.d.ts +6 -0
- package/json/EnumJsonSchema.d.ts.map +1 -0
- package/json/EnumJsonSchema.js +2 -0
- package/json/EnumJsonSchema.js.map +1 -0
- package/json/EnumJsonSchemaOf.d.ts +6 -0
- package/json/EnumJsonSchemaOf.d.ts.map +1 -0
- package/json/EnumJsonSchemaOf.js +2 -0
- package/json/EnumJsonSchemaOf.js.map +1 -0
- package/json/ExclusiveJsonSchema.d.ts +15 -0
- package/json/ExclusiveJsonSchema.d.ts.map +1 -0
- package/json/ExclusiveJsonSchema.js +2 -0
- package/json/ExclusiveJsonSchema.js.map +1 -0
- package/json/FromJsonSchema.d.ts +12 -0
- package/json/FromJsonSchema.d.ts.map +1 -0
- package/json/FromJsonSchema.js +2 -0
- package/json/FromJsonSchema.js.map +1 -0
- package/json/FromObjectJsonSchema.d.ts +5 -0
- package/json/FromObjectJsonSchema.d.ts.map +1 -0
- package/json/FromObjectJsonSchema.js +2 -0
- package/json/FromObjectJsonSchema.js.map +1 -0
- package/json/FromPropertySchemasJson.d.ts +6 -0
- package/json/FromPropertySchemasJson.d.ts.map +1 -0
- package/json/FromPropertySchemasJson.js +2 -0
- package/json/FromPropertySchemasJson.js.map +1 -0
- package/json/IntegerJsonSchema.d.ts +5 -0
- package/json/IntegerJsonSchema.d.ts.map +1 -0
- package/json/IntegerJsonSchema.js +2 -0
- package/json/IntegerJsonSchema.js.map +1 -0
- package/json/IntersectionJsonSchema.d.ts +9 -0
- package/json/IntersectionJsonSchema.d.ts.map +1 -0
- package/json/IntersectionJsonSchema.js +2 -0
- package/json/IntersectionJsonSchema.js.map +1 -0
- package/json/JsonSchema.d.ts +13 -0
- package/json/JsonSchema.d.ts.map +1 -0
- package/json/JsonSchema.js +2 -0
- package/json/JsonSchema.js.map +1 -0
- package/json/JsonSchemaOrPrimitive.d.ts +4 -0
- package/json/JsonSchemaOrPrimitive.d.ts.map +1 -0
- package/json/JsonSchemaOrPrimitive.js +2 -0
- package/json/JsonSchemaOrPrimitive.js.map +1 -0
- package/json/MapJsonSchema.d.ts +25 -0
- package/json/MapJsonSchema.d.ts.map +1 -0
- package/json/MapJsonSchema.js +2 -0
- package/json/MapJsonSchema.js.map +1 -0
- package/json/NumberJsonSchema.d.ts +12 -0
- package/json/NumberJsonSchema.d.ts.map +1 -0
- package/json/NumberJsonSchema.js +2 -0
- package/json/NumberJsonSchema.js.map +1 -0
- package/json/ObjectIdJsonSchema.d.ts +3 -0
- package/json/ObjectIdJsonSchema.d.ts.map +1 -0
- package/json/ObjectIdJsonSchema.js +2 -0
- package/json/ObjectIdJsonSchema.js.map +1 -0
- package/json/ObjectJsonSchema.d.ts +16 -0
- package/json/ObjectJsonSchema.d.ts.map +1 -0
- package/json/ObjectJsonSchema.js +2 -0
- package/json/ObjectJsonSchema.js.map +1 -0
- package/json/OneOfJsonSchema.d.ts +9 -0
- package/json/OneOfJsonSchema.d.ts.map +1 -0
- package/json/OneOfJsonSchema.js +2 -0
- package/json/OneOfJsonSchema.js.map +1 -0
- package/json/OnlyOptionalJson.d.ts +5 -0
- package/json/OnlyOptionalJson.d.ts.map +1 -0
- package/json/OnlyOptionalJson.js +2 -0
- package/json/OnlyOptionalJson.js.map +1 -0
- package/json/OnlyRequiredJson.d.ts +5 -0
- package/json/OnlyRequiredJson.d.ts.map +1 -0
- package/json/OnlyRequiredJson.js +2 -0
- package/json/OnlyRequiredJson.js.map +1 -0
- package/json/PrimitiveOrFromJsonSchema.d.ts +5 -0
- package/json/PrimitiveOrFromJsonSchema.d.ts.map +1 -0
- package/json/PrimitiveOrFromJsonSchema.js +2 -0
- package/json/PrimitiveOrFromJsonSchema.js.map +1 -0
- package/json/RequiredPropOfJson.d.ts +3 -0
- package/json/RequiredPropOfJson.d.ts.map +1 -0
- package/json/RequiredPropOfJson.js +2 -0
- package/json/RequiredPropOfJson.js.map +1 -0
- package/json/StringJsonSchema.d.ts +10 -0
- package/json/StringJsonSchema.d.ts.map +1 -0
- package/json/StringJsonSchema.js +2 -0
- package/json/StringJsonSchema.js.map +1 -0
- package/json/UidJsonSchema.d.ts +5 -0
- package/json/UidJsonSchema.d.ts.map +1 -0
- package/json/UidJsonSchema.js +2 -0
- package/json/UidJsonSchema.js.map +1 -0
- package/json/UnionJsonSchema.d.ts +9 -0
- package/json/UnionJsonSchema.d.ts.map +1 -0
- package/json/UnionJsonSchema.js +2 -0
- package/json/UnionJsonSchema.js.map +1 -0
- package/json/UuidV4JsonSchema.d.ts +5 -0
- package/json/UuidV4JsonSchema.d.ts.map +1 -0
- package/json/UuidV4JsonSchema.js +2 -0
- package/json/UuidV4JsonSchema.js.map +1 -0
- package/json/UuidV5JsonSchema.d.ts +5 -0
- package/json/UuidV5JsonSchema.d.ts.map +1 -0
- package/json/UuidV5JsonSchema.js +2 -0
- package/json/UuidV5JsonSchema.js.map +1 -0
- package/json/WholeNumberSchema.d.ts +5 -0
- package/json/WholeNumberSchema.d.ts.map +1 -0
- package/json/WholeNumberSchema.js +2 -0
- package/json/WholeNumberSchema.js.map +1 -0
- package/json/index.d.ts +28 -0
- package/json/index.d.ts.map +1 -0
- package/json/index.js +28 -0
- package/json/index.js.map +1 -0
- package/json/primitives.d.ts +50 -0
- package/json/primitives.d.ts.map +1 -0
- package/json/primitives.js +50 -0
- package/json/primitives.js.map +1 -0
- package/jsonToType/jsonToType.d.ts +3 -0
- package/jsonToType/jsonToType.d.ts.map +1 -0
- package/jsonToType/jsonToType.js +42 -0
- package/jsonToType/jsonToType.js.map +1 -0
- package/package.json +51 -0
- package/postgres/FromPostgresPropertySchemas.d.ts +6 -0
- package/postgres/FromPostgresPropertySchemas.d.ts.map +1 -0
- package/postgres/FromPostgresPropertySchemas.js +2 -0
- package/postgres/FromPostgresPropertySchemas.js.map +1 -0
- package/postgres/PostgresColumnBase.d.ts +13 -0
- package/postgres/PostgresColumnBase.d.ts.map +1 -0
- package/postgres/PostgresColumnBase.js +2 -0
- package/postgres/PostgresColumnBase.js.map +1 -0
- package/postgres/PostgresColumnModel.d.ts +5 -0
- package/postgres/PostgresColumnModel.d.ts.map +1 -0
- package/postgres/PostgresColumnModel.js +2 -0
- package/postgres/PostgresColumnModel.js.map +1 -0
- package/postgres/PostgresDatabaseModel.d.ts +8 -0
- package/postgres/PostgresDatabaseModel.d.ts.map +1 -0
- package/postgres/PostgresDatabaseModel.js +2 -0
- package/postgres/PostgresDatabaseModel.js.map +1 -0
- package/postgres/PostgresRecordModel.d.ts +20 -0
- package/postgres/PostgresRecordModel.d.ts.map +1 -0
- package/postgres/PostgresRecordModel.js +2 -0
- package/postgres/PostgresRecordModel.js.map +1 -0
- package/postgres/PostgresTableModel.d.ts +25 -0
- package/postgres/PostgresTableModel.d.ts.map +1 -0
- package/postgres/PostgresTableModel.js +2 -0
- package/postgres/PostgresTableModel.js.map +1 -0
- package/postgres/PostgresTriggerModel.d.ts +11 -0
- package/postgres/PostgresTriggerModel.d.ts.map +1 -0
- package/postgres/PostgresTriggerModel.js +2 -0
- package/postgres/PostgresTriggerModel.js.map +1 -0
- package/postgres/RequiredPropOf.d.ts +3 -0
- package/postgres/RequiredPropOf.d.ts.map +1 -0
- package/postgres/RequiredPropOf.js +2 -0
- package/postgres/RequiredPropOf.js.map +1 -0
- package/postgres/columns/Array.d.ts +9 -0
- package/postgres/columns/Array.d.ts.map +1 -0
- package/postgres/columns/Array.js +2 -0
- package/postgres/columns/Array.js.map +1 -0
- package/postgres/columns/Boolean.d.ts +7 -0
- package/postgres/columns/Boolean.d.ts.map +1 -0
- package/postgres/columns/Boolean.js +2 -0
- package/postgres/columns/Boolean.js.map +1 -0
- package/postgres/columns/Bytea.d.ts +5 -0
- package/postgres/columns/Bytea.d.ts.map +1 -0
- package/postgres/columns/Bytea.js +2 -0
- package/postgres/columns/Bytea.js.map +1 -0
- package/postgres/columns/Enum.d.ts +6 -0
- package/postgres/columns/Enum.d.ts.map +1 -0
- package/postgres/columns/Enum.js +2 -0
- package/postgres/columns/Enum.js.map +1 -0
- package/postgres/columns/Jsonb.d.ts +7 -0
- package/postgres/columns/Jsonb.d.ts.map +1 -0
- package/postgres/columns/Jsonb.js +2 -0
- package/postgres/columns/Jsonb.js.map +1 -0
- package/postgres/columns/geometric/index.d.ts +2 -0
- package/postgres/columns/geometric/index.d.ts.map +1 -0
- package/postgres/columns/geometric/index.js +2 -0
- package/postgres/columns/geometric/index.js.map +1 -0
- package/postgres/columns/geometric/point.d.ts +8 -0
- package/postgres/columns/geometric/point.d.ts.map +1 -0
- package/postgres/columns/geometric/point.js +2 -0
- package/postgres/columns/geometric/point.js.map +1 -0
- package/postgres/columns/index.d.ts +10 -0
- package/postgres/columns/index.d.ts.map +1 -0
- package/postgres/columns/index.js +10 -0
- package/postgres/columns/index.js.map +1 -0
- package/postgres/columns/numeric/BigInt.d.ts +5 -0
- package/postgres/columns/numeric/BigInt.d.ts.map +1 -0
- package/postgres/columns/numeric/BigInt.js +2 -0
- package/postgres/columns/numeric/BigInt.js.map +1 -0
- package/postgres/columns/numeric/BigSerial.d.ts +5 -0
- package/postgres/columns/numeric/BigSerial.d.ts.map +1 -0
- package/postgres/columns/numeric/BigSerial.js +2 -0
- package/postgres/columns/numeric/BigSerial.js.map +1 -0
- package/postgres/columns/numeric/Double.d.ts +5 -0
- package/postgres/columns/numeric/Double.d.ts.map +1 -0
- package/postgres/columns/numeric/Double.js +2 -0
- package/postgres/columns/numeric/Double.js.map +1 -0
- package/postgres/columns/numeric/Integer.d.ts +5 -0
- package/postgres/columns/numeric/Integer.d.ts.map +1 -0
- package/postgres/columns/numeric/Integer.js +2 -0
- package/postgres/columns/numeric/Integer.js.map +1 -0
- package/postgres/columns/numeric/Money.d.ts +5 -0
- package/postgres/columns/numeric/Money.d.ts.map +1 -0
- package/postgres/columns/numeric/Money.js +2 -0
- package/postgres/columns/numeric/Money.js.map +1 -0
- package/postgres/columns/numeric/NumberBase.d.ts +11 -0
- package/postgres/columns/numeric/NumberBase.d.ts.map +1 -0
- package/postgres/columns/numeric/NumberBase.js +2 -0
- package/postgres/columns/numeric/NumberBase.js.map +1 -0
- package/postgres/columns/numeric/Numeric.d.ts +7 -0
- package/postgres/columns/numeric/Numeric.d.ts.map +1 -0
- package/postgres/columns/numeric/Numeric.js +2 -0
- package/postgres/columns/numeric/Numeric.js.map +1 -0
- package/postgres/columns/numeric/Real.d.ts +5 -0
- package/postgres/columns/numeric/Real.d.ts.map +1 -0
- package/postgres/columns/numeric/Real.js +2 -0
- package/postgres/columns/numeric/Real.js.map +1 -0
- package/postgres/columns/numeric/Serial.d.ts +5 -0
- package/postgres/columns/numeric/Serial.d.ts.map +1 -0
- package/postgres/columns/numeric/Serial.js +2 -0
- package/postgres/columns/numeric/Serial.js.map +1 -0
- package/postgres/columns/numeric/SmallInt.d.ts +5 -0
- package/postgres/columns/numeric/SmallInt.d.ts.map +1 -0
- package/postgres/columns/numeric/SmallInt.js +2 -0
- package/postgres/columns/numeric/SmallInt.js.map +1 -0
- package/postgres/columns/numeric/SmallSerial.d.ts +5 -0
- package/postgres/columns/numeric/SmallSerial.d.ts.map +1 -0
- package/postgres/columns/numeric/SmallSerial.js +2 -0
- package/postgres/columns/numeric/SmallSerial.js.map +1 -0
- package/postgres/columns/numeric/index.d.ts +11 -0
- package/postgres/columns/numeric/index.d.ts.map +1 -0
- package/postgres/columns/numeric/index.js +11 -0
- package/postgres/columns/numeric/index.js.map +1 -0
- package/postgres/columns/temporal/Date.d.ts +5 -0
- package/postgres/columns/temporal/Date.d.ts.map +1 -0
- package/postgres/columns/temporal/Date.js +2 -0
- package/postgres/columns/temporal/Date.js.map +1 -0
- package/postgres/columns/temporal/Time.d.ts +7 -0
- package/postgres/columns/temporal/Time.d.ts.map +1 -0
- package/postgres/columns/temporal/Time.js +2 -0
- package/postgres/columns/temporal/Time.js.map +1 -0
- package/postgres/columns/temporal/Timestamp.d.ts +5 -0
- package/postgres/columns/temporal/Timestamp.d.ts.map +1 -0
- package/postgres/columns/temporal/Timestamp.js +2 -0
- package/postgres/columns/temporal/Timestamp.js.map +1 -0
- package/postgres/columns/temporal/TimestampBase.d.ts +13 -0
- package/postgres/columns/temporal/TimestampBase.d.ts.map +1 -0
- package/postgres/columns/temporal/TimestampBase.js +2 -0
- package/postgres/columns/temporal/TimestampBase.js.map +1 -0
- package/postgres/columns/temporal/Timestamptz.d.ts +5 -0
- package/postgres/columns/temporal/Timestamptz.d.ts.map +1 -0
- package/postgres/columns/temporal/Timestamptz.js +2 -0
- package/postgres/columns/temporal/Timestamptz.js.map +1 -0
- package/postgres/columns/temporal/index.d.ts +5 -0
- package/postgres/columns/temporal/index.d.ts.map +1 -0
- package/postgres/columns/temporal/index.js +5 -0
- package/postgres/columns/temporal/index.js.map +1 -0
- package/postgres/columns/textual/Char.d.ts +9 -0
- package/postgres/columns/textual/Char.d.ts.map +1 -0
- package/postgres/columns/textual/Char.js +2 -0
- package/postgres/columns/textual/Char.js.map +1 -0
- package/postgres/columns/textual/Text.d.ts +12 -0
- package/postgres/columns/textual/Text.d.ts.map +1 -0
- package/postgres/columns/textual/Text.js +2 -0
- package/postgres/columns/textual/Text.js.map +1 -0
- package/postgres/columns/textual/Varchar.d.ts +11 -0
- package/postgres/columns/textual/Varchar.d.ts.map +1 -0
- package/postgres/columns/textual/Varchar.js +2 -0
- package/postgres/columns/textual/Varchar.js.map +1 -0
- package/postgres/columns/textual/index.d.ts +4 -0
- package/postgres/columns/textual/index.d.ts.map +1 -0
- package/postgres/columns/textual/index.js +4 -0
- package/postgres/columns/textual/index.js.map +1 -0
- package/postgres/index.d.ts +9 -0
- package/postgres/index.d.ts.map +1 -0
- package/postgres/index.js +9 -0
- package/postgres/index.js.map +1 -0
- package/postgres/postgresColumnToJson.d.ts +4 -0
- package/postgres/postgresColumnToJson.d.ts.map +1 -0
- package/postgres/postgresColumnToJson.js +61 -0
- package/postgres/postgresColumnToJson.js.map +1 -0
- package/postgres/postgresColumnToTson.d.ts +4 -0
- package/postgres/postgresColumnToTson.d.ts.map +1 -0
- package/postgres/postgresColumnToTson.js +66 -0
- package/postgres/postgresColumnToTson.js.map +1 -0
- package/postgres/postgresRecordToTson.d.ts +4 -0
- package/postgres/postgresRecordToTson.d.ts.map +1 -0
- package/postgres/postgresRecordToTson.js +14 -0
- package/postgres/postgresRecordToTson.js.map +1 -0
- package/protobuf/tsonToProtobuf.d.ts +14 -0
- package/protobuf/tsonToProtobuf.d.ts.map +1 -0
- package/protobuf/tsonToProtobuf.js +115 -0
- package/protobuf/tsonToProtobuf.js.map +1 -0
- package/tson/ArrayTsonSchema.d.ts +12 -0
- package/tson/ArrayTsonSchema.d.ts.map +1 -0
- package/tson/ArrayTsonSchema.js +2 -0
- package/tson/ArrayTsonSchema.js.map +1 -0
- package/tson/BigIntTsonSchema.d.ts +16 -0
- package/tson/BigIntTsonSchema.d.ts.map +1 -0
- package/tson/BigIntTsonSchema.js +2 -0
- package/tson/BigIntTsonSchema.js.map +1 -0
- package/tson/BooleanTsonSchema.d.ts +14 -0
- package/tson/BooleanTsonSchema.d.ts.map +1 -0
- package/tson/BooleanTsonSchema.js +2 -0
- package/tson/BooleanTsonSchema.js.map +1 -0
- package/tson/DateTsonSchema.d.ts +14 -0
- package/tson/DateTsonSchema.d.ts.map +1 -0
- package/tson/DateTsonSchema.js +2 -0
- package/tson/DateTsonSchema.js.map +1 -0
- package/tson/EnumTsonSchema.d.ts +6 -0
- package/tson/EnumTsonSchema.d.ts.map +1 -0
- package/tson/EnumTsonSchema.js +2 -0
- package/tson/EnumTsonSchema.js.map +1 -0
- package/tson/EnumTsonSchemaOf.d.ts +6 -0
- package/tson/EnumTsonSchemaOf.d.ts.map +1 -0
- package/tson/EnumTsonSchemaOf.js +2 -0
- package/tson/EnumTsonSchemaOf.js.map +1 -0
- package/tson/ExclusiveTsonSchema.d.ts +15 -0
- package/tson/ExclusiveTsonSchema.d.ts.map +1 -0
- package/tson/ExclusiveTsonSchema.js +2 -0
- package/tson/ExclusiveTsonSchema.js.map +1 -0
- package/tson/FromObjectTsonSchema.d.ts +5 -0
- package/tson/FromObjectTsonSchema.d.ts.map +1 -0
- package/tson/FromObjectTsonSchema.js +2 -0
- package/tson/FromObjectTsonSchema.js.map +1 -0
- package/tson/FromPropertySchemasTson.d.ts +6 -0
- package/tson/FromPropertySchemasTson.d.ts.map +1 -0
- package/tson/FromPropertySchemasTson.js +2 -0
- package/tson/FromPropertySchemasTson.js.map +1 -0
- package/tson/FromTsonSchema.d.ts +12 -0
- package/tson/FromTsonSchema.d.ts.map +1 -0
- package/tson/FromTsonSchema.js +2 -0
- package/tson/FromTsonSchema.js.map +1 -0
- package/tson/IntersectionTsonSchema.d.ts +9 -0
- package/tson/IntersectionTsonSchema.d.ts.map +1 -0
- package/tson/IntersectionTsonSchema.js +2 -0
- package/tson/IntersectionTsonSchema.js.map +1 -0
- package/tson/MapTsonSchema.d.ts +25 -0
- package/tson/MapTsonSchema.d.ts.map +1 -0
- package/tson/MapTsonSchema.js +2 -0
- package/tson/MapTsonSchema.js.map +1 -0
- package/tson/NumberTsonSchema.d.ts +16 -0
- package/tson/NumberTsonSchema.d.ts.map +1 -0
- package/tson/NumberTsonSchema.js +2 -0
- package/tson/NumberTsonSchema.js.map +1 -0
- package/tson/ObjectTsonSchema.d.ts +17 -0
- package/tson/ObjectTsonSchema.d.ts.map +1 -0
- package/tson/ObjectTsonSchema.js +2 -0
- package/tson/ObjectTsonSchema.js.map +1 -0
- package/tson/OneOfTsonSchema.d.ts +9 -0
- package/tson/OneOfTsonSchema.d.ts.map +1 -0
- package/tson/OneOfTsonSchema.js +2 -0
- package/tson/OneOfTsonSchema.js.map +1 -0
- package/tson/OnlyOptionalTson.d.ts +5 -0
- package/tson/OnlyOptionalTson.d.ts.map +1 -0
- package/tson/OnlyOptionalTson.js +2 -0
- package/tson/OnlyOptionalTson.js.map +1 -0
- package/tson/OnlyRequiredTson.d.ts +5 -0
- package/tson/OnlyRequiredTson.d.ts.map +1 -0
- package/tson/OnlyRequiredTson.js +2 -0
- package/tson/OnlyRequiredTson.js.map +1 -0
- package/tson/PrimitiveOrFromTsonSchema.d.ts +5 -0
- package/tson/PrimitiveOrFromTsonSchema.d.ts.map +1 -0
- package/tson/PrimitiveOrFromTsonSchema.js +2 -0
- package/tson/PrimitiveOrFromTsonSchema.js.map +1 -0
- package/tson/RefTsonSchema.d.ts +4 -0
- package/tson/RefTsonSchema.d.ts.map +1 -0
- package/tson/RefTsonSchema.js +2 -0
- package/tson/RefTsonSchema.js.map +1 -0
- package/tson/RequiredPropOfTson.d.ts +3 -0
- package/tson/RequiredPropOfTson.d.ts.map +1 -0
- package/tson/RequiredPropOfTson.js +2 -0
- package/tson/RequiredPropOfTson.js.map +1 -0
- package/tson/StringFormats.d.ts +17 -0
- package/tson/StringFormats.d.ts.map +1 -0
- package/tson/StringFormats.js +20 -0
- package/tson/StringFormats.js.map +1 -0
- package/tson/StringTsonSchema.d.ts +17 -0
- package/tson/StringTsonSchema.d.ts.map +1 -0
- package/tson/StringTsonSchema.js +2 -0
- package/tson/StringTsonSchema.js.map +1 -0
- package/tson/TsonSchema.d.ts +15 -0
- package/tson/TsonSchema.d.ts.map +1 -0
- package/tson/TsonSchema.js +2 -0
- package/tson/TsonSchema.js.map +1 -0
- package/tson/TsonSchemaOrPrimitive.d.ts +4 -0
- package/tson/TsonSchemaOrPrimitive.d.ts.map +1 -0
- package/tson/TsonSchemaOrPrimitive.js +2 -0
- package/tson/TsonSchemaOrPrimitive.js.map +1 -0
- package/tson/UnionTsonSchema.d.ts +9 -0
- package/tson/UnionTsonSchema.d.ts.map +1 -0
- package/tson/UnionTsonSchema.js +2 -0
- package/tson/UnionTsonSchema.js.map +1 -0
- package/tson/index.d.ts +29 -0
- package/tson/index.d.ts.map +1 -0
- package/tson/index.js +29 -0
- package/tson/index.js.map +1 -0
- package/tson/isDate.d.ts +2 -0
- package/tson/isDate.d.ts.map +1 -0
- package/tson/isDate.js +2 -0
- package/tson/isDate.js.map +1 -0
- package/tson/parseBON.d.ts +8 -0
- package/tson/parseBON.d.ts.map +1 -0
- package/tson/parseBON.js +396 -0
- package/tson/parseBON.js.map +1 -0
- package/tson/parsePossibleBON.d.ts +2 -0
- package/tson/parsePossibleBON.d.ts.map +1 -0
- package/tson/parsePossibleBON.js +3 -0
- package/tson/parsePossibleBON.js.map +1 -0
- package/tson/primitives.d.ts +26 -0
- package/tson/primitives.d.ts.map +1 -0
- package/tson/primitives.js +26 -0
- package/tson/primitives.js.map +1 -0
- package/tson/stringifyBON.d.ts +11 -0
- package/tson/stringifyBON.d.ts.map +1 -0
- package/tson/stringifyBON.js +126 -0
- package/tson/stringifyBON.js.map +1 -0
- package/tsonToType.d.ts +3 -0
- package/tsonToType.d.ts.map +1 -0
- package/tsonToType.js +53 -0
- package/tsonToType.js.map +1 -0
- package/tsonValidator/ValidationError.d.ts +4 -0
- package/tsonValidator/ValidationError.d.ts.map +1 -0
- package/tsonValidator/ValidationError.js +7 -0
- package/tsonValidator/ValidationError.js.map +1 -0
- package/tsonValidator/buildArrayValidator.d.ts +7 -0
- package/tsonValidator/buildArrayValidator.d.ts.map +1 -0
- package/tsonValidator/buildArrayValidator.js +110 -0
- package/tsonValidator/buildArrayValidator.js.map +1 -0
- package/tsonValidator/buildBigintValidator.d.ts +7 -0
- package/tsonValidator/buildBigintValidator.d.ts.map +1 -0
- package/tsonValidator/buildBigintValidator.js +126 -0
- package/tsonValidator/buildBigintValidator.js.map +1 -0
- package/tsonValidator/buildBooleanValidator.d.ts +4 -0
- package/tsonValidator/buildBooleanValidator.d.ts.map +1 -0
- package/tsonValidator/buildBooleanValidator.js +43 -0
- package/tsonValidator/buildBooleanValidator.js.map +1 -0
- package/tsonValidator/buildDateValidator.d.ts +4 -0
- package/tsonValidator/buildDateValidator.d.ts.map +1 -0
- package/tsonValidator/buildDateValidator.js +69 -0
- package/tsonValidator/buildDateValidator.js.map +1 -0
- package/tsonValidator/buildEnumValidator.d.ts +4 -0
- package/tsonValidator/buildEnumValidator.d.ts.map +1 -0
- package/tsonValidator/buildEnumValidator.js +35 -0
- package/tsonValidator/buildEnumValidator.js.map +1 -0
- package/tsonValidator/buildNumberValidator.d.ts +7 -0
- package/tsonValidator/buildNumberValidator.d.ts.map +1 -0
- package/tsonValidator/buildNumberValidator.js +137 -0
- package/tsonValidator/buildNumberValidator.js.map +1 -0
- package/tsonValidator/buildObjectValidator.d.ts +4 -0
- package/tsonValidator/buildObjectValidator.d.ts.map +1 -0
- package/tsonValidator/buildObjectValidator.js +88 -0
- package/tsonValidator/buildObjectValidator.js.map +1 -0
- package/tsonValidator/buildOneOfValidator.d.ts +7 -0
- package/tsonValidator/buildOneOfValidator.d.ts.map +1 -0
- package/tsonValidator/buildOneOfValidator.js +62 -0
- package/tsonValidator/buildOneOfValidator.js.map +1 -0
- package/tsonValidator/buildStringValidator.d.ts +7 -0
- package/tsonValidator/buildStringValidator.d.ts.map +1 -0
- package/tsonValidator/buildStringValidator.js +93 -0
- package/tsonValidator/buildStringValidator.js.map +1 -0
- package/tsonValidator/buildValidator.d.ts +4 -0
- package/tsonValidator/buildValidator.d.ts.map +1 -0
- package/tsonValidator/buildValidator.js +75 -0
- package/tsonValidator/buildValidator.js.map +1 -0
- package/tsonValidator/index.d.ts +12 -0
- package/tsonValidator/index.d.ts.map +1 -0
- package/tsonValidator/index.js +12 -0
- package/tsonValidator/index.js.map +1 -0
- package/tsonValidator/testUtils.d.ts +8 -0
- package/tsonValidator/testUtils.d.ts.map +1 -0
- package/tsonValidator/testUtils.js +24 -0
- package/tsonValidator/testUtils.js.map +1 -0
- package/typeverters/bsonToType.d.ts +3 -0
- package/typeverters/bsonToType.d.ts.map +1 -0
- package/typeverters/bsonToType.js +48 -0
- package/typeverters/bsonToType.js.map +1 -0
- package/typeverters/postgresColumnToKysely.d.ts +3 -0
- package/typeverters/postgresColumnToKysely.d.ts.map +1 -0
- package/typeverters/postgresColumnToKysely.js +51 -0
- package/typeverters/postgresColumnToKysely.js.map +1 -0
- package/typeverters/postgresColumnToType.d.ts +3 -0
- package/typeverters/postgresColumnToType.d.ts.map +1 -0
- package/typeverters/postgresColumnToType.js +37 -0
- package/typeverters/postgresColumnToType.js.map +1 -0
- package/typeverters/postgresRecordToKysely.d.ts +3 -0
- package/typeverters/postgresRecordToKysely.d.ts.map +1 -0
- package/typeverters/postgresRecordToKysely.js +7 -0
- package/typeverters/postgresRecordToKysely.js.map +1 -0
- package/typeverters/postgresRecordToType.d.ts +3 -0
- package/typeverters/postgresRecordToType.d.ts.map +1 -0
- package/typeverters/postgresRecordToType.js +13 -0
- package/typeverters/postgresRecordToType.js.map +1 -0
package/LLMs.md
ADDED
|
@@ -0,0 +1,979 @@
|
|
|
1
|
+
# @lyku/lockstep-core — LLM Reference
|
|
2
|
+
|
|
3
|
+
This document is a complete mechanical reference for the `@lyku/lockstep-core` library. It contains exact type signatures, exhaustive enum values, mapping rules, generated output examples, and edge cases needed to correctly generate code that uses this framework.
|
|
4
|
+
|
|
5
|
+
## Pipeline overview
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pg-models (PostgresRecordModel)
|
|
9
|
+
↓ generateJsonModels
|
|
10
|
+
json-models (JSON schemas + TypeScript types + Insertable types)
|
|
11
|
+
↓ generateDbTypes
|
|
12
|
+
db-types (Kysely Database interface)
|
|
13
|
+
|
|
14
|
+
mapi-models (TsonHandlerModel)
|
|
15
|
+
↓ generateApiTypes
|
|
16
|
+
mapi-types (Request/Response TypeScript types)
|
|
17
|
+
↓ generateHandles
|
|
18
|
+
handles (Handler factories with validators)
|
|
19
|
+
↓ generateClient
|
|
20
|
+
monolith-ts-api (Type-safe HTTP + WebSocket client with MessagePack)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. PostgreSQL column types
|
|
26
|
+
|
|
27
|
+
### PostgresColumnBase (all columns inherit this)
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
type PostgresColumnBase = {
|
|
31
|
+
readonly unique?: boolean;
|
|
32
|
+
readonly primaryKey?: boolean;
|
|
33
|
+
readonly generated?: {
|
|
34
|
+
readonly always?: boolean;
|
|
35
|
+
readonly as: string;
|
|
36
|
+
readonly from?: string;
|
|
37
|
+
readonly stored?: boolean;
|
|
38
|
+
};
|
|
39
|
+
readonly checks?: string[];
|
|
40
|
+
readonly description?: string;
|
|
41
|
+
readonly title?: string;
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Complete column type list
|
|
46
|
+
|
|
47
|
+
Every column model extends `PostgresColumnBase`. The `type` field is the discriminant.
|
|
48
|
+
|
|
49
|
+
| Column model | `type` values | Extra fields | → Schema | → Kysely | → TypeScript |
|
|
50
|
+
| ------------------------ | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------- | ------------------- | ------------ |
|
|
51
|
+
| `BigIntColumnModel` | `'bigint'`, `'int8'` | `minimum?, maximum?, exclusiveMinimum?, exclusiveMaximum?, multipleOf?, default?, examples?` (all `bigint`) | `{ type: 'bigint' }` | `bigint` | `bigint` |
|
|
52
|
+
| `BigSerialColumnModel` | `'bigserial'`, `'serial8'` | same as BigInt | `{ type: 'bigint', default: -1n }` | `Generated<bigint>` | `bigint` |
|
|
53
|
+
| `IntegerColumnModel` | `'integer'`, `'int'`, `'int2'`, `'int4'` | `minimum?, maximum?, exclusiveMinimum?, exclusiveMaximum?, multipleOf?, default?, examples?` (all `number`) | `{ type: 'number' }` | `number` | `number` |
|
|
54
|
+
| `SmallIntColumnModel` | `'smallint'`, `'int2'` | same as Integer | `{ type: 'number' }` | `number` | `number` |
|
|
55
|
+
| `SerialColumnModel` | `'serial'`, `'serial4'` | same as Integer | `{ type: 'number', default: -1 }` | `Generated<number>` | `number` |
|
|
56
|
+
| `SmallSerialColumnModel` | `'smallserial'`, `'serial2'` | same as Integer | `{ type: 'number', default: -1 }` | `Generated<number>` | `number` |
|
|
57
|
+
| `RealColumnModel` | `'real'`, `'float4'` | same as Integer | `{ type: 'number' }` | `number` | `number` |
|
|
58
|
+
| `DoubleColumnModel` | `'double precision'`, `'float8'` | same as Integer | `{ type: 'number' }` | `number` | `number` |
|
|
59
|
+
| `NumericColumnModel` | `'numeric'` | same as Integer + `precision?, scale?` | `{ type: 'number' }` | `number` | `number` |
|
|
60
|
+
| `MoneyColumnModel` | `'money'` | same as Integer | `{ type: 'number' }` | `number` | `number` |
|
|
61
|
+
| `BooleanColumnModel` | `'boolean'`, `'bool'` | `default?: boolean, examples?` | `{ type: 'boolean' }` | `boolean` | `boolean` |
|
|
62
|
+
| `TextColumnModel` | `'text'` | `minLength?, maxLength?, pattern?, enum?, default?` | `{ type: 'string' }` | `string` | `string` |
|
|
63
|
+
| `VarcharColumnModel` | `'varchar'`, `'character varying'` | `minLength?, maxLength?, pattern?, enum?, default?` | `{ type: 'string' }` | `string` | `string` |
|
|
64
|
+
| `CharColumnModel` | `'char'`, `'character'`, `'bpchar'` | `length, pattern?, enum?` | `{ type: 'string' }` | `string` | `string` |
|
|
65
|
+
| `DateColumnModel` | `'date'` | `default?, minimum?, maximum?` | `{ type: 'date' }` | `Date` | `Date` |
|
|
66
|
+
| `Timestamp` | `'timestamp'` | `timezone?, precision?, default?, minimum?, maximum?` | `{ type: 'date' }` | `Date` | `Date` |
|
|
67
|
+
| `Timestamptz` | `'timestamptz'` | same as Timestamp | `{ type: 'date' }` | `Date` | `Date` |
|
|
68
|
+
| `TimeColumnModel` | `'time'` | `timezone?, precision?` | `{ type: 'date' }` | `Date` | `Date` |
|
|
69
|
+
| `EnumColumnModel` | `'enum'` | `enum: readonly string[]` | preserved | `string` | `string` |
|
|
70
|
+
| `ArrayColumnModel` | `'array'` | `items: PostgresColumnModel, minItems?, maxItems?` | `{ type: 'array', items: <recursive> }` | recursive | recursive |
|
|
71
|
+
| `JsonbColumnModel` | `'jsonb'` | `schema?: JsonSchema` | schema or `{ type: 'object' }` | `unknown` or typed | varies |
|
|
72
|
+
| `ByteaColumnModel` | `'bytea'` | none | — | `Buffer` | `Buffer` |
|
|
73
|
+
| `PointColumnModel` | `'point'` | none | — | — | — |
|
|
74
|
+
|
|
75
|
+
### PostgresColumnModel (union of all above)
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
type PostgresColumnModel = ArrayColumnModel | BigIntColumnModel | BigSerialColumnModel | BooleanColumnModel | ByteaColumnModel | CharColumnModel | DateColumnModel | DoubleColumnModel | EnumColumnModel | IntegerColumnModel | JsonbColumnModel | MoneyColumnModel | NumericColumnModel | PointColumnModel | RealColumnModel | SmallIntColumnModel | SmallSerialColumnModel | SerialColumnModel | TextColumnModel | TimeColumnModel | Timestamp | Timestamptz | VarcharColumnModel;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 2. PostgreSQL record and table models
|
|
84
|
+
|
|
85
|
+
### PostgresRecordModel
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
type PostgresRecordModel = PostgresRecordModelWithoutRequired | PostgresRecordModelWithRequired;
|
|
89
|
+
|
|
90
|
+
type PostgresRecordModelWithoutRequired = {
|
|
91
|
+
readonly properties: Record<string, PostgresColumnModel>;
|
|
92
|
+
readonly minProperties?: number;
|
|
93
|
+
readonly maxProperties?: number;
|
|
94
|
+
readonly default?: Record<string, unknown>;
|
|
95
|
+
readonly examples?: Record<string, unknown>[];
|
|
96
|
+
readonly additionalProperties?: false | PostgresColumnModel;
|
|
97
|
+
readonly description?: string;
|
|
98
|
+
readonly title?: string;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
type PostgresRecordModelWithRequired = PostgresRecordModelWithoutRequired & {
|
|
102
|
+
readonly required: readonly string[];
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Critical rule**: Properties listed in `required` become non-optional in the generated TypeScript type. Properties NOT in `required` become optional (`?`). If `required` is omitted entirely, ALL properties are optional.
|
|
107
|
+
|
|
108
|
+
### PostgresTableModel
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
type PostgresTableModel<S extends PostgresRecordModel> = {
|
|
112
|
+
readonly schema: S;
|
|
113
|
+
readonly indexes?: IndexesOf<S>;
|
|
114
|
+
readonly primaryKey?: keyof S['properties'] | readonly (keyof S['properties'])[];
|
|
115
|
+
readonly foreignKeys?: Partial<Record<keyof S['properties'], { readonly [key: string]: string }>>;
|
|
116
|
+
readonly triggers?: readonly PostgresTriggerModel[];
|
|
117
|
+
readonly unique?: keyof S['properties'] | readonly (keyof S['properties'])[];
|
|
118
|
+
readonly docs?: any[];
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Example: defining a pg-model
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import type { PostgresRecordModel } from '@lyku/lockstep-core';
|
|
126
|
+
|
|
127
|
+
export const friendship = {
|
|
128
|
+
properties: {
|
|
129
|
+
id: { type: 'bigserial' },
|
|
130
|
+
created: { type: 'timestamptz', default: { sql: 'CURRENT_TIMESTAMP' } },
|
|
131
|
+
users: { type: 'array', items: { type: 'bigint' }, minItems: 2, maxItems: 2 },
|
|
132
|
+
deleted: { type: 'timestamptz' },
|
|
133
|
+
},
|
|
134
|
+
required: ['created', 'id', 'users'],
|
|
135
|
+
} as const satisfies PostgresRecordModel;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Always use `as const satisfies PostgresRecordModel` — the `as const` preserves literal types needed by the generators.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 3. Schema types
|
|
143
|
+
|
|
144
|
+
The from-schema type system is the intermediate schema language used by API models and json-models.
|
|
145
|
+
|
|
146
|
+
### TsonSchema (union)
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
type TsonSchema = ArrayTsonSchema | BooleanTsonSchema | EnumTsonSchema | DateTsonSchema | MapTsonSchema | NumberTsonSchema | ObjectTsonSchema | StringTsonSchema | UnionTsonSchema | ExclusiveTsonSchema | IntersectionTsonSchema | BigIntTsonSchema | RefTsonSchema;
|
|
150
|
+
|
|
151
|
+
type TsonSchemaOrPrimitive = TsonSchema | string | number | boolean | bigint | string[];
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Individual schemas with all fields
|
|
155
|
+
|
|
156
|
+
**StringTsonSchema**:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
type StringTsonSchema = {
|
|
160
|
+
readonly type: 'string';
|
|
161
|
+
readonly format?: 'date' | 'time' | 'date-time' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'uuid' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex';
|
|
162
|
+
readonly minLength?: number;
|
|
163
|
+
readonly maxLength?: number;
|
|
164
|
+
readonly pattern?: string;
|
|
165
|
+
readonly const?: string; // If present, becomes a literal type
|
|
166
|
+
readonly examples?: string[];
|
|
167
|
+
readonly description?: string;
|
|
168
|
+
readonly title?: string;
|
|
169
|
+
};
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
→ TypeScript: `string` (or `"literal"` if `const` is set)
|
|
173
|
+
|
|
174
|
+
**NumberTsonSchema**:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
type NumberTsonSchema = {
|
|
178
|
+
readonly type: 'number' | 'integer'; // Both map to `number` in TS
|
|
179
|
+
readonly minimum?: number;
|
|
180
|
+
readonly maximum?: number;
|
|
181
|
+
readonly default?: number;
|
|
182
|
+
readonly const?: number;
|
|
183
|
+
readonly examples?: number[];
|
|
184
|
+
readonly description?: string;
|
|
185
|
+
readonly title?: string;
|
|
186
|
+
};
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
→ TypeScript: `number`
|
|
190
|
+
|
|
191
|
+
**BigIntTsonSchema**:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
type BigIntTsonSchema = {
|
|
195
|
+
readonly type: 'bigint';
|
|
196
|
+
readonly minimum?: bigint;
|
|
197
|
+
readonly maximum?: bigint;
|
|
198
|
+
readonly default?: bigint;
|
|
199
|
+
readonly const?: bigint;
|
|
200
|
+
readonly examples?: bigint[];
|
|
201
|
+
readonly description?: string;
|
|
202
|
+
readonly title?: string;
|
|
203
|
+
};
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
→ TypeScript: `bigint`
|
|
207
|
+
|
|
208
|
+
**BooleanTsonSchema**:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
type BooleanTsonSchema = {
|
|
212
|
+
readonly type: 'boolean';
|
|
213
|
+
readonly default?: boolean;
|
|
214
|
+
readonly const?: boolean;
|
|
215
|
+
readonly examples?: boolean[];
|
|
216
|
+
readonly description?: string;
|
|
217
|
+
readonly title?: string;
|
|
218
|
+
};
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
→ TypeScript: `boolean`
|
|
222
|
+
|
|
223
|
+
**DateTsonSchema**:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
type DateTsonSchema = {
|
|
227
|
+
readonly type: 'date';
|
|
228
|
+
readonly minimum?: Date;
|
|
229
|
+
readonly maximum?: Date;
|
|
230
|
+
readonly const?: Date;
|
|
231
|
+
readonly description?: string;
|
|
232
|
+
readonly title?: string;
|
|
233
|
+
};
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
→ TypeScript: `Date`
|
|
237
|
+
|
|
238
|
+
**ArrayTsonSchema**:
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
type ArrayTsonSchema = {
|
|
242
|
+
readonly type: 'array';
|
|
243
|
+
readonly items: TsonSchemaOrPrimitive;
|
|
244
|
+
readonly maxItems?: number;
|
|
245
|
+
readonly minItems?: number;
|
|
246
|
+
readonly uniqueItems?: boolean;
|
|
247
|
+
readonly default?: unknown[];
|
|
248
|
+
readonly examples?: unknown[][];
|
|
249
|
+
readonly description?: string;
|
|
250
|
+
readonly title?: string;
|
|
251
|
+
};
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
→ TypeScript: `Array<T>` where T is the items schema converted
|
|
255
|
+
|
|
256
|
+
**ObjectTsonSchema**:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
type ObjectTsonSchema = {
|
|
260
|
+
readonly type: 'object';
|
|
261
|
+
readonly properties?: Record<string, TsonSchemaOrPrimitive>;
|
|
262
|
+
readonly required?: readonly string[]; // ← CRITICAL: determines optional vs required
|
|
263
|
+
readonly minProperties?: number;
|
|
264
|
+
readonly maxProperties?: number;
|
|
265
|
+
readonly default?: Record<string, unknown>;
|
|
266
|
+
readonly examples?: Record<string, unknown>[];
|
|
267
|
+
readonly additionalProperties?: false | TsonSchemaOrPrimitive;
|
|
268
|
+
readonly patternProperties?: false | Record<string, TsonSchemaOrPrimitive>;
|
|
269
|
+
readonly description?: string;
|
|
270
|
+
readonly title?: string;
|
|
271
|
+
};
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
→ TypeScript: `{ key: Type; optionalKey?: Type; ... }`
|
|
275
|
+
|
|
276
|
+
**CRITICAL**: If `required` is omitted or empty, ALL properties become optional (`?`) in the generated type. This is the #1 source of type mismatches between handlers and generated types.
|
|
277
|
+
|
|
278
|
+
**EnumTsonSchema**:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
type EnumTsonSchema = {
|
|
282
|
+
readonly enum: readonly (string | number)[];
|
|
283
|
+
readonly description?: string;
|
|
284
|
+
readonly title?: string;
|
|
285
|
+
};
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
→ TypeScript: `'value1' | 'value2' | ...`
|
|
289
|
+
|
|
290
|
+
**UnionTsonSchema** (`anyOf`):
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
type UnionTsonSchema = {
|
|
294
|
+
readonly anyOf: readonly TsonSchemaOrPrimitive[];
|
|
295
|
+
readonly description?: string;
|
|
296
|
+
readonly default?: unknown;
|
|
297
|
+
};
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
→ TypeScript: `(A | B | C)`
|
|
301
|
+
|
|
302
|
+
**ExclusiveTsonSchema** (`oneOf`):
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
type ExclusiveTsonSchema = {
|
|
306
|
+
readonly oneOf: readonly TsonSchemaOrPrimitive[];
|
|
307
|
+
readonly description?: string;
|
|
308
|
+
readonly default?: unknown;
|
|
309
|
+
};
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
→ TypeScript: `(A | B | C)` (same as union at type level; validated differently at runtime)
|
|
313
|
+
|
|
314
|
+
**IntersectionTsonSchema** (`allOf`):
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
type IntersectionTsonSchema = {
|
|
318
|
+
readonly allOf: readonly TsonSchemaOrPrimitive[];
|
|
319
|
+
readonly description?: string;
|
|
320
|
+
readonly default?: unknown;
|
|
321
|
+
};
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
→ TypeScript: `(A & B & C)`
|
|
325
|
+
|
|
326
|
+
**MapTsonSchema**:
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
type MapTsonSchema = {
|
|
330
|
+
readonly type: 'map';
|
|
331
|
+
readonly keys: StringTsonSchema | EnumTsonSchemaOf<string>;
|
|
332
|
+
readonly values: TsonSchema;
|
|
333
|
+
readonly partial?: boolean;
|
|
334
|
+
readonly default?: Record<string, unknown>;
|
|
335
|
+
};
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
→ TypeScript: `Record<string, V>` or `Partial<Record<K, V>>`
|
|
339
|
+
|
|
340
|
+
**RefTsonSchema**:
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
type RefTsonSchema = { $ref: string };
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
→ TypeScript: `any` (work in progress)
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## 4. API handler models
|
|
351
|
+
|
|
352
|
+
### TsonHandlerModel (union)
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
type TsonHandlerModel = TsonHttpHandlerModel | TsonStreamHandlerModel;
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### TsonHttpHandlerModel
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
type TsonHttpHandlerModel = Readonly<
|
|
362
|
+
| GetHandlerModel // { method: 'GET' }
|
|
363
|
+
| PostHandlerModel // { method: 'POST', request?: TsonSchema }
|
|
364
|
+
| PutHandlerModel // { method: 'PUT', request?: TsonSchema }
|
|
365
|
+
| DeleteHandlerModel // { method: 'DELETE', request?: TsonSchema }
|
|
366
|
+
| PatchHandlerModel // { method: 'PATCH', request?: TsonSchema }
|
|
367
|
+
| OptionsHandlerModel // { method: 'OPTIONS' }
|
|
368
|
+
| HeadHandlerModel // { method: 'HEAD' }
|
|
369
|
+
| VagueHandlerModel // no method, { request?: TsonSchema }
|
|
370
|
+
>;
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Most endpoints in the codebase use `VagueHandlerModel` (no `method` field). The default HTTP method is POST.
|
|
374
|
+
|
|
375
|
+
### TsonStreamHandlerModel (WebSocket)
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
type TsonStreamHandlerModel = Readonly<
|
|
379
|
+
TsonHandlerBase & {
|
|
380
|
+
readonly stream:
|
|
381
|
+
| true
|
|
382
|
+
| {
|
|
383
|
+
readonly tweakRequest?: TsonSchema;
|
|
384
|
+
readonly tweakResponse?: TsonSchema;
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
>;
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
When `stream` is present, the generated handle uses `onOpen` instead of `execute`, and the context type is `SocketContext` instead of `HttpContext`.
|
|
391
|
+
|
|
392
|
+
### TsonHandlerBase (all fields)
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
type TsonHandlerBase = {
|
|
396
|
+
readonly response?: TsonSchema;
|
|
397
|
+
readonly authenticated: boolean; // ← determines Secure vs MaybeSecure context
|
|
398
|
+
readonly throws?: readonly number[];
|
|
399
|
+
readonly path?: string; // override URL path (default: kebab-case of export name)
|
|
400
|
+
|
|
401
|
+
// Documentation (all optional)
|
|
402
|
+
readonly title?: string;
|
|
403
|
+
readonly description?: string;
|
|
404
|
+
readonly category?: string;
|
|
405
|
+
readonly tags?: readonly string[];
|
|
406
|
+
readonly since?: string;
|
|
407
|
+
readonly examples?: readonly {
|
|
408
|
+
readonly title: string;
|
|
409
|
+
readonly description?: string;
|
|
410
|
+
readonly request?: unknown;
|
|
411
|
+
readonly response?: unknown;
|
|
412
|
+
readonly status?: number;
|
|
413
|
+
}[];
|
|
414
|
+
readonly notes?: readonly string[];
|
|
415
|
+
readonly errors?: readonly {
|
|
416
|
+
readonly code: number;
|
|
417
|
+
readonly title: string;
|
|
418
|
+
readonly description: string;
|
|
419
|
+
readonly example?: unknown;
|
|
420
|
+
readonly resolution?: string;
|
|
421
|
+
}[];
|
|
422
|
+
readonly relatedEndpoints?: readonly string[];
|
|
423
|
+
readonly deprecated?: {
|
|
424
|
+
readonly since: string;
|
|
425
|
+
readonly useInstead?: string;
|
|
426
|
+
readonly reason?: string;
|
|
427
|
+
};
|
|
428
|
+
readonly rateLimit?: {
|
|
429
|
+
readonly requests: number;
|
|
430
|
+
readonly period: string;
|
|
431
|
+
readonly scope?: 'user' | 'ip' | 'global';
|
|
432
|
+
};
|
|
433
|
+
readonly requiredPermissions?: readonly string[];
|
|
434
|
+
};
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Example: defining an HTTP endpoint
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
import type { TsonHandlerModel } from '@lyku/lockstep-core';
|
|
441
|
+
|
|
442
|
+
export const getServiceStatus = {
|
|
443
|
+
request: {
|
|
444
|
+
type: 'object',
|
|
445
|
+
properties: {
|
|
446
|
+
service: { type: 'string', maxLength: 50 },
|
|
447
|
+
},
|
|
448
|
+
required: ['service'],
|
|
449
|
+
},
|
|
450
|
+
response: {
|
|
451
|
+
type: 'object',
|
|
452
|
+
properties: {
|
|
453
|
+
name: { type: 'string' },
|
|
454
|
+
status: { type: 'string', enum: ['operational', 'degraded', 'outage'] },
|
|
455
|
+
uptime24h: { type: 'number' },
|
|
456
|
+
},
|
|
457
|
+
required: ['name', 'status', 'uptime24h'], // ← without this, all properties are optional
|
|
458
|
+
},
|
|
459
|
+
authenticated: false,
|
|
460
|
+
throws: [400, 404, 500],
|
|
461
|
+
title: 'Get Service Status',
|
|
462
|
+
category: 'Status',
|
|
463
|
+
since: '1.0.0',
|
|
464
|
+
} as const satisfies TsonHandlerModel;
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Example: defining a WebSocket endpoint
|
|
468
|
+
|
|
469
|
+
```typescript
|
|
470
|
+
export const listenForAchievementGrants = {
|
|
471
|
+
request: {
|
|
472
|
+
type: 'object',
|
|
473
|
+
properties: { game: { type: 'number' } },
|
|
474
|
+
required: [],
|
|
475
|
+
},
|
|
476
|
+
response: {
|
|
477
|
+
type: 'array',
|
|
478
|
+
items: {
|
|
479
|
+
type: 'object',
|
|
480
|
+
properties: {
|
|
481
|
+
achievement: { type: 'bigint' },
|
|
482
|
+
user: { type: 'bigint' },
|
|
483
|
+
granted: { type: 'date' },
|
|
484
|
+
},
|
|
485
|
+
required: ['achievement', 'user', 'granted'],
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
stream: true,
|
|
489
|
+
authenticated: true,
|
|
490
|
+
throws: [400, 401, 404, 500],
|
|
491
|
+
title: 'Listen for Achievement Grants',
|
|
492
|
+
category: 'Games',
|
|
493
|
+
since: '1.0.0',
|
|
494
|
+
} as const satisfies TsonHandlerModel;
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## 5. Handler contexts
|
|
500
|
+
|
|
501
|
+
When implementing a route handler, the second argument is a typed context object. The context type is determined by:
|
|
502
|
+
|
|
503
|
+
1. `authenticated: true` → `Secure*Context` (has `requester: bigint` and `session: string`)
|
|
504
|
+
2. `authenticated: false` → `MaybeSecure*Context` (requester/session are optional)
|
|
505
|
+
3. No `stream` field → `*HttpContext`
|
|
506
|
+
4. `stream` field present → `*SocketContext`
|
|
507
|
+
|
|
508
|
+
### Context type definitions
|
|
509
|
+
|
|
510
|
+
```typescript
|
|
511
|
+
type BaseContextFragment<Model extends TsonHandlerModel> = {
|
|
512
|
+
strings: Record<string, string>;
|
|
513
|
+
model: Model;
|
|
514
|
+
now: Date;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
type SecurityContextFragment = {
|
|
518
|
+
requester: bigint;
|
|
519
|
+
session: string;
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
type HttpContextFragment = {
|
|
523
|
+
request: Request;
|
|
524
|
+
responseHeaders: Headers;
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
type SocketContextFragment<Types extends StreamTypes> = {
|
|
528
|
+
emit: (data: Types['response'] | Uint8Array) => void;
|
|
529
|
+
onClose: (closer: () => void) => void;
|
|
530
|
+
onTweak: (handler: (data: ExtractTweakRequest<Types>) => void) => void;
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
// HTTP
|
|
534
|
+
type SecureHttpContext<Model> = BaseContextFragment<Model> & SecurityContextFragment & HttpContextFragment;
|
|
535
|
+
type MaybeSecureHttpContext<Model> = BaseContextFragment<Model> & Partial<SecurityContextFragment> & HttpContextFragment;
|
|
536
|
+
|
|
537
|
+
// Socket
|
|
538
|
+
type SecureSocketContext<Model, Types> = BaseContextFragment<Model> & SecurityContextFragment & SocketContextFragment<Types>;
|
|
539
|
+
type MaybeSecureSocketContext<Model, Types> = BaseContextFragment<Model> & Partial<SecurityContextFragment> & SocketContextFragment<Types>;
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
### Context fields reference
|
|
543
|
+
|
|
544
|
+
| Field | Type | Present in | Description |
|
|
545
|
+
| ----------------- | ------------------------ | -------------------- | --------------------------------- |
|
|
546
|
+
| `requester` | `bigint` | Secure contexts only | Authenticated user's ID |
|
|
547
|
+
| `session` | `string` | Secure contexts only | Session token |
|
|
548
|
+
| `request` | `Request` | HTTP contexts | Raw HTTP Request object |
|
|
549
|
+
| `responseHeaders` | `Headers` | HTTP contexts | Mutable response headers |
|
|
550
|
+
| `emit` | `(data) => void` | Socket contexts | Send data to the connected client |
|
|
551
|
+
| `onClose` | `(cb) => void` | Socket contexts | Register a disconnect callback |
|
|
552
|
+
| `onTweak` | `(handler) => void` | Socket contexts | Handle mid-stream request changes |
|
|
553
|
+
| `strings` | `Record<string, string>` | All | Localized strings |
|
|
554
|
+
| `model` | `TsonHandlerModel` | All | The endpoint's schema model |
|
|
555
|
+
| `now` | `Date` | All | Timestamp of the request |
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
## 6. Generated output (verbatim examples)
|
|
560
|
+
|
|
561
|
+
### generateJsonModels output
|
|
562
|
+
|
|
563
|
+
Input pg-model:
|
|
564
|
+
|
|
565
|
+
```typescript
|
|
566
|
+
export const accountDeletionRequest = {
|
|
567
|
+
properties: {
|
|
568
|
+
id: { type: 'bigserial' },
|
|
569
|
+
user: { type: 'bigint' },
|
|
570
|
+
requestedAt: { type: 'timestamptz', default: { sql: 'CURRENT_TIMESTAMP' } },
|
|
571
|
+
confirmationCode: { type: 'varchar', maxLength: 64 },
|
|
572
|
+
confirmedAt: { type: 'timestamptz' },
|
|
573
|
+
},
|
|
574
|
+
required: ['id', 'user', 'requestedAt', 'confirmationCode'],
|
|
575
|
+
} as const satisfies PostgresRecordModel;
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
Generated `.d.ts`:
|
|
579
|
+
|
|
580
|
+
```typescript
|
|
581
|
+
export declare const accountDeletionRequest: {
|
|
582
|
+
type: 'object';
|
|
583
|
+
properties: {
|
|
584
|
+
id: { type: 'bigint' };
|
|
585
|
+
user: { type: 'bigint' };
|
|
586
|
+
requestedAt: { type: 'date'; default: { sql: 'CURRENT_TIMESTAMP' } };
|
|
587
|
+
confirmationCode: { type: 'string'; maxLength: 64 };
|
|
588
|
+
confirmedAt: { type: 'date' };
|
|
589
|
+
};
|
|
590
|
+
required: ['id', 'user', 'requestedAt', 'confirmationCode'];
|
|
591
|
+
};
|
|
592
|
+
export type AccountDeletionRequest = {
|
|
593
|
+
id: bigint;
|
|
594
|
+
user: bigint;
|
|
595
|
+
requestedAt: Date;
|
|
596
|
+
confirmationCode: string;
|
|
597
|
+
confirmedAt?: Date; // ← not in required, so optional
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
export type InsertableAccountDeletionRequest = {
|
|
601
|
+
id?: bigint; // ← all optional for inserts
|
|
602
|
+
user?: bigint;
|
|
603
|
+
requestedAt?: Date;
|
|
604
|
+
confirmationCode?: string;
|
|
605
|
+
confirmedAt?: Date;
|
|
606
|
+
};
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
### generateDbTypes output
|
|
610
|
+
|
|
611
|
+
Generated Kysely types:
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
import { ColumnType, Generated, Insertable, JSONColumnType, Selectable, Updateable } from 'kysely';
|
|
615
|
+
|
|
616
|
+
export type AccountDeletionRequests = {
|
|
617
|
+
id: Generated<bigint>; // ← bigserial → Generated<bigint>
|
|
618
|
+
user: bigint;
|
|
619
|
+
requestedAt: Date;
|
|
620
|
+
confirmationCode: string;
|
|
621
|
+
confirmedAt?: Date;
|
|
622
|
+
scheduledFor?: Date;
|
|
623
|
+
processedAt?: Date;
|
|
624
|
+
cancelled?: Date;
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
export type Achievements = {
|
|
628
|
+
description?: string;
|
|
629
|
+
id: bigint;
|
|
630
|
+
icon: string;
|
|
631
|
+
name: string;
|
|
632
|
+
points: number;
|
|
633
|
+
tier?: 'tin' | 'bronze' | 'silver' | 'gold' | 'tritium'; // ← enum preserved
|
|
634
|
+
game?: number;
|
|
635
|
+
created: Date;
|
|
636
|
+
updated?: Date;
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
// ... all tables ...
|
|
640
|
+
|
|
641
|
+
export interface Database {
|
|
642
|
+
accountDeletionRequests: AccountDeletionRequests;
|
|
643
|
+
achievements: Achievements;
|
|
644
|
+
// ... all tables (pluralized names) ...
|
|
645
|
+
}
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
**Table naming**: The generator pluralizes table names in the Database interface. `friendship` → `friendships`, `canaryMetric` → `canaryMetrics`. When using `pg.selectFrom()`, use the pluralized name.
|
|
649
|
+
|
|
650
|
+
### generateApiTypes output
|
|
651
|
+
|
|
652
|
+
```typescript
|
|
653
|
+
export type AcceptFriendRequestRequest = bigint;
|
|
654
|
+
export type AcceptFriendRequestResponse = void;
|
|
655
|
+
|
|
656
|
+
export type CreateFriendRequestRequest = bigint;
|
|
657
|
+
export type CreateFriendRequestResponse = { id: bigint };
|
|
658
|
+
|
|
659
|
+
export type GetServiceStatusRequest = { service: string };
|
|
660
|
+
export type GetServiceStatusResponse = {
|
|
661
|
+
name: string;
|
|
662
|
+
status: 'operational' | 'degraded' | 'outage';
|
|
663
|
+
uptime24h: number;
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// Aggregate type map
|
|
667
|
+
export type MonolithTypes = {
|
|
668
|
+
acceptFriendRequest: {
|
|
669
|
+
request: AcceptFriendRequestRequest;
|
|
670
|
+
response: AcceptFriendRequestResponse;
|
|
671
|
+
};
|
|
672
|
+
createFriendRequest: {
|
|
673
|
+
request: CreateFriendRequestRequest;
|
|
674
|
+
response: CreateFriendRequestResponse;
|
|
675
|
+
};
|
|
676
|
+
getServiceStatus: {
|
|
677
|
+
request: GetServiceStatusRequest;
|
|
678
|
+
response: GetServiceStatusResponse;
|
|
679
|
+
};
|
|
680
|
+
// ... all endpoints ...
|
|
681
|
+
};
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
### generateHandles output
|
|
685
|
+
|
|
686
|
+
For an HTTP endpoint (`authenticated: true`, no `stream`):
|
|
687
|
+
|
|
688
|
+
**Generated `.d.ts`**:
|
|
689
|
+
|
|
690
|
+
```typescript
|
|
691
|
+
import { acceptFriendRequest } from '@lyku/mapi-models';
|
|
692
|
+
import type { AcceptFriendRequestRequest } from '@lyku/mapi-types';
|
|
693
|
+
import type { SecureHttpContext } from '@lyku/route-helpers';
|
|
694
|
+
|
|
695
|
+
export declare const handleAcceptFriendRequest: (handler: (request: AcceptFriendRequestRequest, context: SecureHttpContext<typeof acceptFriendRequest>) => void | Promise<void>) => {
|
|
696
|
+
readonly execute: (request: AcceptFriendRequestRequest, context: SecureHttpContext<typeof acceptFriendRequest>) => void | Promise<void>;
|
|
697
|
+
readonly validator: {
|
|
698
|
+
validate: (request: unknown) => string[];
|
|
699
|
+
validateOrThrow: (request: unknown) => void;
|
|
700
|
+
isValid: (request: unknown) => string | true;
|
|
701
|
+
};
|
|
702
|
+
readonly model: typeof acceptFriendRequest;
|
|
703
|
+
};
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
**Generated `.js`**:
|
|
707
|
+
|
|
708
|
+
```javascript
|
|
709
|
+
import { acceptFriendRequest } from '@lyku/mapi-models';
|
|
710
|
+
export const handleAcceptFriendRequest = (handler) => ({
|
|
711
|
+
execute: handler,
|
|
712
|
+
validator: {
|
|
713
|
+
validate: (request) => {
|
|
714
|
+
const allErrors = [];
|
|
715
|
+
let bigintValue = request;
|
|
716
|
+
if (typeof request === 'string') {
|
|
717
|
+
try {
|
|
718
|
+
bigintValue = BigInt(request);
|
|
719
|
+
} catch {
|
|
720
|
+
allErrors.push('Value must be a bigint');
|
|
721
|
+
}
|
|
722
|
+
} else if (typeof request !== 'bigint') {
|
|
723
|
+
allErrors.push('Value must be a bigint');
|
|
724
|
+
}
|
|
725
|
+
return allErrors;
|
|
726
|
+
},
|
|
727
|
+
validateOrThrow: (request) => {
|
|
728
|
+
let bigintValue = request;
|
|
729
|
+
if (typeof request === 'string') {
|
|
730
|
+
try {
|
|
731
|
+
bigintValue = BigInt(request);
|
|
732
|
+
} catch {
|
|
733
|
+
throw new Error('Value must be a bigint');
|
|
734
|
+
}
|
|
735
|
+
} else if (typeof request !== 'bigint') {
|
|
736
|
+
throw new Error('Value must be a bigint');
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
isValid: (request) => {
|
|
740
|
+
let bigintValue = request;
|
|
741
|
+
if (typeof request === 'string') {
|
|
742
|
+
try {
|
|
743
|
+
bigintValue = BigInt(request);
|
|
744
|
+
} catch {
|
|
745
|
+
return 'Value must be a bigint';
|
|
746
|
+
}
|
|
747
|
+
} else if (typeof request !== 'bigint') {
|
|
748
|
+
return 'Value must be a bigint';
|
|
749
|
+
}
|
|
750
|
+
return true;
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
model: {
|
|
754
|
+
/* full model object embedded via BON */
|
|
755
|
+
},
|
|
756
|
+
});
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
For a WebSocket endpoint (`stream: true`):
|
|
760
|
+
|
|
761
|
+
**Generated `.d.ts`**:
|
|
762
|
+
|
|
763
|
+
```typescript
|
|
764
|
+
import { listenForAchievementGrants } from '@lyku/mapi-models';
|
|
765
|
+
import type { MonolithTypes } from '@lyku/mapi-types';
|
|
766
|
+
import type { ListenForAchievementGrantsRequest } from '@lyku/mapi-types';
|
|
767
|
+
import type { SecureSocketContext } from '@lyku/route-helpers';
|
|
768
|
+
|
|
769
|
+
export declare const handleListenForAchievementGrants: (
|
|
770
|
+
handler: (
|
|
771
|
+
request: ListenForAchievementGrantsRequest,
|
|
772
|
+
context: SecureSocketContext<
|
|
773
|
+
typeof listenForAchievementGrants,
|
|
774
|
+
MonolithTypes['listenForAchievementGrants']
|
|
775
|
+
>,
|
|
776
|
+
) => void | Promise<void>,
|
|
777
|
+
) => {
|
|
778
|
+
readonly onOpen: ( // ← onOpen, not execute
|
|
779
|
+
request: ListenForAchievementGrantsRequest,
|
|
780
|
+
context: SecureSocketContext<
|
|
781
|
+
typeof listenForAchievementGrants,
|
|
782
|
+
MonolithTypes['listenForAchievementGrants']
|
|
783
|
+
>,
|
|
784
|
+
) => void | Promise<void>;
|
|
785
|
+
readonly validator: { ... };
|
|
786
|
+
readonly model: typeof listenForAchievementGrants;
|
|
787
|
+
};
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
**Key difference**: Stream handlers expose `onOpen` instead of `execute`.
|
|
791
|
+
|
|
792
|
+
---
|
|
793
|
+
|
|
794
|
+
## 7. Type conversion rules
|
|
795
|
+
|
|
796
|
+
### Schema → TypeScript (used by generateApiTypes)
|
|
797
|
+
|
|
798
|
+
| Schema | TypeScript output |
|
|
799
|
+
| ----------------------------------------------------------------- | ---------------------------------------- |
|
|
800
|
+
| `{ type: 'string' }` | `string` |
|
|
801
|
+
| `{ type: 'string', const: 'hello' }` | `"hello"` |
|
|
802
|
+
| `{ type: 'number' }` | `number` |
|
|
803
|
+
| `{ type: 'integer' }` | `number` |
|
|
804
|
+
| `{ type: 'bigint' }` | `bigint` |
|
|
805
|
+
| `{ type: 'boolean' }` | `boolean` |
|
|
806
|
+
| `{ type: 'date' }` | `Date` |
|
|
807
|
+
| `{ type: 'array', items: X }` | `Array<X>` |
|
|
808
|
+
| `{ type: 'object', properties: { a: X, b: Y }, required: ['a'] }` | `{ a: X; b?: Y }` |
|
|
809
|
+
| `{ type: 'object', properties: { a: X }, required: [] }` | `{ a?: X }` |
|
|
810
|
+
| `{ type: 'object', properties: { a: X } }` | `{ a?: X }` (no required = all optional) |
|
|
811
|
+
| `{ enum: ['a', 'b', 'c'] }` | `'a' \| 'b' \| 'c'` |
|
|
812
|
+
| `{ enum: [1, 2, 3] }` | `1 \| 2 \| 3` |
|
|
813
|
+
| `{ oneOf: [X, Y] }` | `(X \| Y)` |
|
|
814
|
+
| `{ anyOf: [X, Y] }` | `(X \| Y)` |
|
|
815
|
+
| `{ allOf: [X, Y] }` | `(X & Y)` |
|
|
816
|
+
| `{ type: 'map', keys: K, values: V }` | `Record<string, V>` |
|
|
817
|
+
| `{ $ref: '...' }` | `any` |
|
|
818
|
+
| primitive `'hello'` | `"hello"` |
|
|
819
|
+
| primitive `42` | `42` |
|
|
820
|
+
| primitive `true` | `true` |
|
|
821
|
+
| primitive `123n` | `123` |
|
|
822
|
+
| no response defined | `void` |
|
|
823
|
+
|
|
824
|
+
### PostgreSQL → Kysely type mapping
|
|
825
|
+
|
|
826
|
+
| PostgreSQL type | Kysely type | Notes |
|
|
827
|
+
| ------------------------------------------ | --------------------------------------- | -------------- |
|
|
828
|
+
| `bigint`, `int8` | `bigint` | |
|
|
829
|
+
| `bigserial`, `serial8` | `Generated<bigint>` | Auto-increment |
|
|
830
|
+
| `serial`, `serial4` | `Generated<number>` | Auto-increment |
|
|
831
|
+
| `smallserial`, `serial2` | `Generated<number>` | Auto-increment |
|
|
832
|
+
| `integer`, `int`, `int2`, `int4` | `number` | |
|
|
833
|
+
| `smallint` | `number` | |
|
|
834
|
+
| `real`, `float4` | `number` | |
|
|
835
|
+
| `double precision`, `float8` | `number` | |
|
|
836
|
+
| `numeric` | `number` | |
|
|
837
|
+
| `money` | `number` | |
|
|
838
|
+
| `boolean`, `bool` | `boolean` | |
|
|
839
|
+
| `text`, `varchar`, `char` | `string` | |
|
|
840
|
+
| `date`, `timestamp`, `timestamptz`, `time` | `Date` | |
|
|
841
|
+
| `enum` with values | `'val1' \| 'val2'` | Literal union |
|
|
842
|
+
| `array` with items | `T[]` | Recursive |
|
|
843
|
+
| `jsonb` | `unknown` (or typed if schema provided) | |
|
|
844
|
+
| `bytea` | `Buffer` | |
|
|
845
|
+
|
|
846
|
+
Columns with `default` or `generated` AND in `required`: still required in the full type, but optional in the Insertable type.
|
|
847
|
+
|
|
848
|
+
Columns with serial/bigserial types: wrapped in `Generated<T>` which makes them optional on insert.
|
|
849
|
+
|
|
850
|
+
---
|
|
851
|
+
|
|
852
|
+
## 8. Validation rules
|
|
853
|
+
|
|
854
|
+
Generated validators check these conditions per schema type:
|
|
855
|
+
|
|
856
|
+
| Schema type | Validations |
|
|
857
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
|
858
|
+
| `string` | `typeof === 'string'`, minLength, maxLength, pattern (regex), format (email/uuid/uri/ipv4/ipv6/hostname/date-time) |
|
|
859
|
+
| `number`/`integer` | `typeof === 'number'` (or coerced from string), min, max, exclusiveMin, exclusiveMax, integer check |
|
|
860
|
+
| `bigint` | `typeof === 'bigint'` (or coerced from string via `BigInt()`), min, max |
|
|
861
|
+
| `boolean` | `typeof === 'boolean'` |
|
|
862
|
+
| `date` | `instanceof Date`, min, max |
|
|
863
|
+
| `object` | `typeof === 'object' && !== null && !Array.isArray()`, required property presence, per-property validation (recursive) |
|
|
864
|
+
| `array` | `Array.isArray()`, minItems, maxItems, per-item validation |
|
|
865
|
+
| `enum` | membership check against allowed values |
|
|
866
|
+
| `oneOf` | validates against each schema, exactly one must pass |
|
|
867
|
+
|
|
868
|
+
**Coercion**: Validators accept string representations of numbers (`Number(str)`) and bigints (`BigInt(str)`) and attempt conversion before validation.
|
|
869
|
+
|
|
870
|
+
---
|
|
871
|
+
|
|
872
|
+
## 9. BON serialization
|
|
873
|
+
|
|
874
|
+
BON (Binary Object Notation) is JSON with BigInt support, used internally for embedding models in generated code.
|
|
875
|
+
|
|
876
|
+
### Format differences from JSON
|
|
877
|
+
|
|
878
|
+
| Value | JSON | BON |
|
|
879
|
+
| --------------- | ------------------ | ---------------------------- |
|
|
880
|
+
| `123n` (bigint) | Not supported | `123n` |
|
|
881
|
+
| `new Date(...)` | `"2025-01-01T..."` | `new Date("2025-01-01T...")` |
|
|
882
|
+
| `undefined` | Not supported | `undefined` |
|
|
883
|
+
| `NaN` | `null` | `NaN` |
|
|
884
|
+
| `Infinity` | `null` | `Infinity` |
|
|
885
|
+
|
|
886
|
+
### Security limits in parseBON
|
|
887
|
+
|
|
888
|
+
- Max nesting depth: 10,000
|
|
889
|
+
- Max string length: 100 MB
|
|
890
|
+
- Max input length: 100 MB
|
|
891
|
+
- Max object properties: 100,000
|
|
892
|
+
- Max array elements: 10,000,000
|
|
893
|
+
- Blocked property names: `__proto__`, `constructor`, `prototype`
|
|
894
|
+
|
|
895
|
+
---
|
|
896
|
+
|
|
897
|
+
## 10. filterHandlerModels
|
|
898
|
+
|
|
899
|
+
When generators process mapi-models exports, they filter to only valid handler models:
|
|
900
|
+
|
|
901
|
+
```typescript
|
|
902
|
+
function filterHandlerModels(models: Record<string, unknown>): Record<string, TsonHandlerModel> {
|
|
903
|
+
// Keeps entries where:
|
|
904
|
+
// typeof value === 'object' && value !== null
|
|
905
|
+
// && 'authenticated' in value
|
|
906
|
+
// && typeof value.authenticated === 'boolean'
|
|
907
|
+
// Discards everything else (helper constants, type re-exports, arrays, etc.)
|
|
908
|
+
}
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
This means non-handler exports (like `messageEventTypes`, `socialStreamTopics`, arrays, strings) are safely ignored.
|
|
912
|
+
|
|
913
|
+
---
|
|
914
|
+
|
|
915
|
+
## 11. CLI usage
|
|
916
|
+
|
|
917
|
+
```bash
|
|
918
|
+
# Generate JSON schemas + TS types from PostgreSQL models
|
|
919
|
+
from-schema generate json-models \
|
|
920
|
+
--models ./pg-models \
|
|
921
|
+
--output ./json-models \
|
|
922
|
+
--extras ./extras # optional: extra schemas to include
|
|
923
|
+
|
|
924
|
+
# Generate Kysely Database type
|
|
925
|
+
from-schema generate db-types \
|
|
926
|
+
--models ./pg-models \
|
|
927
|
+
--output ./db-types \
|
|
928
|
+
--file kysely.d.ts # optional: output filename (default: index.d.ts)
|
|
929
|
+
|
|
930
|
+
# Generate API request/response types
|
|
931
|
+
from-schema generate api-types \
|
|
932
|
+
--models ./mapi-models \
|
|
933
|
+
--output ./mapi-types \
|
|
934
|
+
--types-name MonolithTypes # optional: aggregate type name (default: ApiTypes)
|
|
935
|
+
|
|
936
|
+
# Generate handler factories
|
|
937
|
+
from-schema generate handles \
|
|
938
|
+
--models ./mapi-models \
|
|
939
|
+
--output ./handles \
|
|
940
|
+
--models-pkg @lyku/mapi-models \
|
|
941
|
+
--types-pkg @lyku/mapi-types \
|
|
942
|
+
--context-pkg @lyku/lockstep-core/contexts # optional
|
|
943
|
+
--types-name MonolithTypes # optional
|
|
944
|
+
|
|
945
|
+
# Generate API client
|
|
946
|
+
from-schema generate client \
|
|
947
|
+
--models ./mapi-models \
|
|
948
|
+
--output ./client \
|
|
949
|
+
--types-pkg @lyku/mapi-types \
|
|
950
|
+
--types-name MonolithTypes # optional
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
---
|
|
954
|
+
|
|
955
|
+
## 12. Common pitfalls
|
|
956
|
+
|
|
957
|
+
1. **Missing `required` in response schema**: If you define an object response without `required`, ALL properties become optional in the generated type. Your handler returning `{ name: 'foo' }` won't typecheck against `{ name?: string }` because the handler produces a required field but the type expects optional.
|
|
958
|
+
|
|
959
|
+
2. **Singular vs plural table names**: pg-models use singular names (`canaryMetric`), but the generated Kysely Database interface pluralizes them (`canaryMetrics`). Use the plural form in `pg.selectFrom('canaryMetrics')`.
|
|
960
|
+
|
|
961
|
+
3. **`as const satisfies`**: Always use `as const satisfies PostgresRecordModel` or `as const satisfies TsonHandlerModel`. Without `as const`, literal types are widened and generators produce wrong output.
|
|
962
|
+
|
|
963
|
+
4. **BigInt in validators**: Validators accept string inputs for bigint fields and attempt `BigInt(str)` coercion. This means `"123"` is valid input for a bigint field.
|
|
964
|
+
|
|
965
|
+
5. **Stream handlers use `onOpen`**: The generated handle for a `stream: true` model exposes `onOpen` (not `execute`). The context type is `SocketContext` (not `HttpContext`).
|
|
966
|
+
|
|
967
|
+
6. **`void` response**: If no `response` is defined in the model, the generated response type is `void`. The handler should not return a value.
|
|
968
|
+
|
|
969
|
+
7. **Enum columns vs enum schemas**: PostgreSQL `{ type: 'enum', enum: ['a', 'b'] }` columns generate Kysely types as `'a' | 'b'` (literal union), but the schema conversion loses the enum values — the generated schema just becomes `{ type: 'string' }`. Use enum schemas (`{ enum: ['a', 'b'] }` without `type`) in mapi-models to preserve literal types in API types.
|
|
970
|
+
|
|
971
|
+
---
|
|
972
|
+
|
|
973
|
+
## 13. Exports
|
|
974
|
+
|
|
975
|
+
```
|
|
976
|
+
@lyku/lockstep-core # All schema types, BON, type converters, validators
|
|
977
|
+
@lyku/lockstep-core/contexts # Handler context types (SecureHttpContext, etc.)
|
|
978
|
+
@lyku/lockstep-core/generators # Code generators (generateJsonModels, etc.)
|
|
979
|
+
```
|