@m1cro/server-sdk 0.1.1-beta.14 → 0.1.1-beta.16

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/globals.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as Bridge, L as LogLevel } from './log-CXvNR3D3.js';
1
+ import { B as Bridge, L as LogLevel } from './log-CxYm-dm1.js';
2
2
  import * as console from 'node:console';
3
3
  import 'cookie';
4
4
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { E as EntitySchema, C as CompiledSchema, F as Filter, a as FindQuery, H as HydratedDocument, b as FindOneQuery, I as InsertDocument, c as InsertQuery, d as InsertOneQuery, U as UpdateQuery, e as InferInterface, f as UpdateOneQuery, R as RemoveQuery, g as RemoveOneQuery, h as Router, i as HookEventMap, A as AppRole, j as EventHandler } from './log-CXvNR3D3.js';
2
- export { k as AppId, l as Artifacts, m as Auth, B as Bridge, n as Entity, o as InferSchema, L as LogLevel, M as Method, p as Middleware, N as Namespace, P as Provider, q as Providers, r as Request, s as RequestBuilder, t as RequestHandler, u as Response, v as ResponseBuilder, w as RouteOptions, S as Sorting, x as StatusCode, y as Subject, T as Tenant, V as Visibility, z as entitySchema } from './log-CXvNR3D3.js';
1
+ import { E as EntitySchema, G as GeneratedFields, C as CompiledSchema, F as Filter, a as FindQuery, H as HydratedDocument, b as FindOneQuery, I as InsertDocument, c as InsertQuery, d as InsertOneQuery, U as UpdateQuery, e as InferInterface, f as UpdateOneQuery, R as RemoveQuery, g as RemoveOneQuery, h as Router, i as HookEventMap, A as AppRole, j as EventHandler } from './log-CxYm-dm1.js';
2
+ export { k as AppId, l as Artifacts, m as Auth, B as Bridge, n as Entity, o as InferSchema, L as LogLevel, M as Method, p as Middleware, N as Namespace, P as Provider, q as Providers, r as Request, s as RequestBuilder, t as RequestHandler, u as Response, v as ResponseBuilder, w as RouteOptions, S as Sorting, x as StatusCode, y as Subject, T as Tenant, V as Visibility, z as entitySchema } from './log-CxYm-dm1.js';
3
3
  import 'cookie';
4
4
 
5
+ declare function entityModel<S extends EntitySchema<any>>(name: string, schemaDef: S, options?: EntityModelOptions<S>): EntityModel<S>;
5
6
  interface EntityModelRegistration {
6
7
  get name(): string;
7
8
  get schema(): {
@@ -11,8 +12,9 @@ interface EntityModelRegistration {
11
12
  declare class EntityModel<S extends EntitySchema<any>> implements EntityModelRegistration {
12
13
  readonly name: string;
13
14
  readonly schemaDef: S;
15
+ readonly options?: EntityModelOptions<S> | undefined;
14
16
  schema: CompiledSchema;
15
- constructor(name: string, schemaDef: S);
17
+ constructor(name: string, schemaDef: S, options?: EntityModelOptions<S> | undefined);
16
18
  private entity;
17
19
  find(filter?: Filter): FindQuery<HydratedDocument<S>>;
18
20
  findOne(filter?: Filter): FindOneQuery<HydratedDocument<S>>;
@@ -23,6 +25,13 @@ declare class EntityModel<S extends EntitySchema<any>> implements EntityModelReg
23
25
  remove(filter: Filter): RemoveQuery<InferInterface<S>, 'affectedRows'>;
24
26
  removeOne(filter: Filter): RemoveOneQuery<InferInterface<S>, 'success'>;
25
27
  }
28
+ interface EntityModelOptions<S extends EntitySchema<any>> {
29
+ indexes?: EntityIndexManifest<S>[];
30
+ }
31
+ interface EntityIndexManifest<S extends EntitySchema<any>> {
32
+ fields: Array<keyof GeneratedFields | keyof S['definition']>;
33
+ unique?: boolean | undefined;
34
+ }
26
35
 
27
36
  type EntryPoint = (app: App) => unknown;
28
37
  interface App {
@@ -261,4 +270,4 @@ declare namespace error {
261
270
  export { error_BadGateway as BadGateway, error_BadRequest as BadRequest, error_Base as Base, error_Conflict as Conflict, error_ContentTooLarge as ContentTooLarge, error_ExpectationFailed as ExpectationFailed, error_FailedDependency as FailedDependency, error_Forbidden as Forbidden, error_GatewayTimeout as GatewayTimeout, error_Gone as Gone, error_HTTPVersionNotSupported as HTTPVersionNotSupported, error_ImATeapot as ImATeapot, error_InsufficientStorage as InsufficientStorage, error_InternalServerError as InternalServerError, error_LengthRequired as LengthRequired, error_Locked as Locked, error_LoopDetected as LoopDetected, error_MethodNotAllowed as MethodNotAllowed, error_MisdirectedRequest as MisdirectedRequest, error_NetworkAuthenticationRequired as NetworkAuthenticationRequired, error_NotAcceptable as NotAcceptable, error_NotExtended as NotExtended, error_NotFound as NotFound, error_NotImplemented as NotImplemented, error_PaymentRequired as PaymentRequired, error_PreconditionFailed as PreconditionFailed, error_PreconditionRequired as PreconditionRequired, error_ProxyAuthenticationRequired as ProxyAuthenticationRequired, error_RangeNotSatisfiable as RangeNotSatisfiable, error_RequestHeaderFieldsTooLarge as RequestHeaderFieldsTooLarge, error_RequestTimeout as RequestTimeout, error_ServiceUnavailable as ServiceUnavailable, error_TooEarly as TooEarly, error_TooManyRequests as TooManyRequests, error_URITooLong as URITooLong, error_Unauthorized as Unauthorized, error_UnavailableForLegalReasons as UnavailableForLegalReasons, error_UnprocessableEntity as UnprocessableEntity, error_UnsupportedMediaType as UnsupportedMediaType, error_UpgradeRequired as UpgradeRequired, error_VariantAlsoNegotiates as VariantAlsoNegotiates };
262
271
  }
263
272
 
264
- export { type App, AppRole, EntityModel, EntitySchema, type EntryPoint, EventHandler, Filter, HydratedDocument, InferInterface, InsertDocument, Router, _default as cbor, error };
273
+ export { type App, AppRole, type EntityIndexManifest, EntityModel, type EntityModelOptions, EntitySchema, type EntryPoint, EventHandler, Filter, HydratedDocument, InferInterface, InsertDocument, Router, _default as cbor, entityModel, error };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import*as o from'cbor2';var S=Object.defineProperty;var C=(r,t)=>{for(var s in t)S(r,s,{get:t[s],enumerable:true});};var ee={encode(r){return o.encode(r)},decode(r){return o.decode(r)}};var c=class{constructor(t){this.definition=t;}};function te(r){return new c(r)}var i=class{constructor(t){}get shape(){return {}}};var a=class{constructor(t,s){this.name=t;this.schemaDef=s;this.schema=new i(s);}schema;entity(){return globalThis.Bridge.entity(this.name)}find(t){return this.entity().find(t)}findOne(t){return this.entity().findOne(t)}insert(t){return this.entity().insert(t)}insertOne(t){return this.entity().insertOne(t)}update(t,s){return this.entity().update(t,s)}updateOne(t,s){return this.entity().updateOne(t,s)}remove(t){return this.entity().remove(t)}removeOne(t){return this.entity().removeOne(t)}};var $={};C($,{BadGateway:()=>V,BadRequest:()=>l,Base:()=>n,Conflict:()=>v,ContentTooLarge:()=>P,ExpectationFailed:()=>O,FailedDependency:()=>H,Forbidden:()=>g,GatewayTimeout:()=>G,Gone:()=>I,HTTPVersionNotSupported:()=>z,ImATeapot:()=>D,InsufficientStorage:()=>W,InternalServerError:()=>L,LengthRequired:()=>_,Locked:()=>w,LoopDetected:()=>X,MethodNotAllowed:()=>y,MisdirectedRequest:()=>M,NetworkAuthenticationRequired:()=>Z,NotAcceptable:()=>f,NotExtended:()=>Y,NotFound:()=>x,NotImplemented:()=>B,PaymentRequired:()=>m,PreconditionFailed:()=>b,PreconditionRequired:()=>F,ProxyAuthenticationRequired:()=>h,RangeNotSatisfiable:()=>T,RequestHeaderFieldsTooLarge:()=>N,RequestTimeout:()=>R,ServiceUnavailable:()=>K,TooEarly:()=>U,TooManyRequests:()=>Q,URITooLong:()=>q,Unauthorized:()=>u,UnavailableForLegalReasons:()=>j,UnprocessableEntity:()=>k,UnsupportedMediaType:()=>A,UpgradeRequired:()=>E,VariantAlsoNegotiates:()=>J});var d=(e=>(e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.EarlyHints=103]="EarlyHints",e[e.OK=200]="OK",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.IMUsed=226]="IMUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.ContentTooLarge=413]="ContentTooLarge",e[e.URITooLong=414]="URITooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HTTPVersionNotSupported=505]="HTTPVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e))(d||{});var n=class extends Error{constructor(s){super(s.msg);this.payload=s;}status(s){return this.payload.status=s,this}code(s){return this.payload.code=s,this}msg(s){return this.payload.msg=s,this}},l=class extends n{constructor(t){super({status:400,code:"bad_request",msg:t});}},u=class extends n{constructor(t){super({status:401,code:"unauthorized",msg:t});}},m=class extends n{constructor(t){super({status:402,code:"payment_required",msg:t});}},g=class extends n{constructor(t){super({status:403,code:"forbidden",msg:t});}},x=class extends n{constructor(t){super({status:404,code:"not_found",msg:t});}},y=class extends n{constructor(t){super({status:405,code:"method_not_allowed",msg:t});}},f=class extends n{constructor(t){super({status:406,code:"not_acceptable",msg:t});}},h=class extends n{constructor(t){super({status:407,code:"proxy_authentication_required",msg:t});}},R=class extends n{constructor(t){super({status:408,code:"request_timeout",msg:t});}},v=class extends n{constructor(t){super({status:409,code:"conflict",msg:t});}},I=class extends n{constructor(t){super({status:410,code:"gone",msg:t});}},_=class extends n{constructor(t){super({status:411,code:"length_required",msg:t});}},b=class extends n{constructor(t){super({status:412,code:"precondition_failed",msg:t});}},P=class extends n{constructor(t){super({status:413,code:"content_too_large",msg:t});}},q=class extends n{constructor(t){super({status:414,code:"uri_too_long",msg:t});}},A=class extends n{constructor(t){super({status:415,code:"unsupported_media_type",msg:t});}},T=class extends n{constructor(t){super({status:416,code:"range_not_satisfiable",msg:t});}},O=class extends n{constructor(t){super({status:417,code:"expectation_failed",msg:t});}},D=class extends n{constructor(t){super({status:418,code:"im_a_teapot",msg:t});}},M=class extends n{constructor(t){super({status:421,code:"misdirected_request",msg:t});}},k=class extends n{constructor(t){super({status:422,code:"unprocessable_entity",msg:t});}},w=class extends n{constructor(t){super({status:423,code:"locked",msg:t});}},H=class extends n{constructor(t){super({status:424,code:"failed_dependency",msg:t});}},U=class extends n{constructor(t){super({status:425,code:"too_early",msg:t});}},E=class extends n{constructor(t){super({status:426,code:"upgrade_required",msg:t});}},F=class extends n{constructor(t){super({status:428,code:"precondition_required",msg:t});}},Q=class extends n{constructor(t){super({status:429,code:"too_many_requests",msg:t});}},N=class extends n{constructor(t){super({status:431,code:"request_header_fields_too_large",msg:t});}},j=class extends n{constructor(t){super({status:451,code:"unavailable_for_legal_reasons",msg:t});}},L=class extends n{constructor(t){super({status:500,code:"internal_server_error",msg:t});}},B=class extends n{constructor(t){super({status:501,code:"not_implemented",msg:t});}},V=class extends n{constructor(t){super({status:502,code:"bad_gateway",msg:t});}},K=class extends n{constructor(t){super({status:503,code:"service_unavailable",msg:t});}},G=class extends n{constructor(t){super({status:504,code:"gateway_timeout",msg:t});}},z=class extends n{constructor(t){super({status:505,code:"http_version_not_supported",msg:t});}},J=class extends n{constructor(t){super({status:506,code:"variant_also_negotiates",msg:t});}},W=class extends n{constructor(t){super({status:507,code:"insufficient_storage",msg:t});}},X=class extends n{constructor(t){super({status:508,code:"loop_detected",msg:t});}},Y=class extends n{constructor(t){super({status:510,code:"not_extended",msg:t});}},Z=class extends n{constructor(t){super({status:511,code:"network_authentication_required",msg:t});}};var p={get instance(){return globalThis.__M1CRO__.internals}};var re={fromId(r){return p.instance.providerFromId(r)}};var ne={parse(r){return p.instance.parseAppId(r)}};export{ne as AppId,a as EntityModel,re as Provider,d as StatusCode,ee as cbor,te as entitySchema,$ as error};
1
+ import*as o from'cbor2';var S=Object.defineProperty;var C=(r,t)=>{for(var s in t)S(r,s,{get:t[s],enumerable:true});};var ee={encode(r){return o.encode(r)},decode(r){return o.decode(r)}};function te(r){return new i(r)}var i=class{constructor(t){this.definition=t;}},p=class{constructor(t){}get shape(){return {}}};function re(r,t,s){return new c(r,t,s)}var c=class{constructor(t,s,oe){this.name=t;this.schemaDef=s;this.options=oe;this.schema=new p(s);}schema;entity(){return globalThis.Bridge.entity(this.name)}find(t){return this.entity().find(t)}findOne(t){return this.entity().findOne(t)}insert(t){return this.entity().insert(t)}insertOne(t){return this.entity().insertOne(t)}update(t,s){return this.entity().update(t,s)}updateOne(t,s){return this.entity().updateOne(t,s)}remove(t){return this.entity().remove(t)}removeOne(t){return this.entity().removeOne(t)}};var $={};C($,{BadGateway:()=>V,BadRequest:()=>l,Base:()=>n,Conflict:()=>I,ContentTooLarge:()=>q,ExpectationFailed:()=>M,FailedDependency:()=>w,Forbidden:()=>y,GatewayTimeout:()=>G,Gone:()=>v,HTTPVersionNotSupported:()=>z,ImATeapot:()=>O,InsufficientStorage:()=>W,InternalServerError:()=>L,LengthRequired:()=>b,Locked:()=>k,LoopDetected:()=>X,MethodNotAllowed:()=>g,MisdirectedRequest:()=>E,NetworkAuthenticationRequired:()=>Z,NotAcceptable:()=>f,NotExtended:()=>Y,NotFound:()=>x,NotImplemented:()=>B,PaymentRequired:()=>m,PreconditionFailed:()=>_,PreconditionRequired:()=>U,ProxyAuthenticationRequired:()=>h,RangeNotSatisfiable:()=>T,RequestHeaderFieldsTooLarge:()=>N,RequestTimeout:()=>R,ServiceUnavailable:()=>K,TooEarly:()=>F,TooManyRequests:()=>Q,URITooLong:()=>A,Unauthorized:()=>u,UnavailableForLegalReasons:()=>j,UnprocessableEntity:()=>D,UnsupportedMediaType:()=>P,UpgradeRequired:()=>H,VariantAlsoNegotiates:()=>J});var d=(e=>(e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.EarlyHints=103]="EarlyHints",e[e.OK=200]="OK",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultiStatus=207]="MultiStatus",e[e.AlreadyReported=208]="AlreadyReported",e[e.IMUsed=226]="IMUsed",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.LengthRequired=411]="LengthRequired",e[e.PreconditionFailed=412]="PreconditionFailed",e[e.ContentTooLarge=413]="ContentTooLarge",e[e.URITooLong=414]="URITooLong",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.RangeNotSatisfiable=416]="RangeNotSatisfiable",e[e.ExpectationFailed=417]="ExpectationFailed",e[e.ImATeapot=418]="ImATeapot",e[e.MisdirectedRequest=421]="MisdirectedRequest",e[e.UnprocessableEntity=422]="UnprocessableEntity",e[e.Locked=423]="Locked",e[e.FailedDependency=424]="FailedDependency",e[e.TooEarly=425]="TooEarly",e[e.UpgradeRequired=426]="UpgradeRequired",e[e.PreconditionRequired=428]="PreconditionRequired",e[e.TooManyRequests=429]="TooManyRequests",e[e.RequestHeaderFieldsTooLarge=431]="RequestHeaderFieldsTooLarge",e[e.UnavailableForLegalReasons=451]="UnavailableForLegalReasons",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout",e[e.HTTPVersionNotSupported=505]="HTTPVersionNotSupported",e[e.VariantAlsoNegotiates=506]="VariantAlsoNegotiates",e[e.InsufficientStorage=507]="InsufficientStorage",e[e.LoopDetected=508]="LoopDetected",e[e.NotExtended=510]="NotExtended",e[e.NetworkAuthenticationRequired=511]="NetworkAuthenticationRequired",e))(d||{});var n=class extends Error{constructor(s){super(s.msg);this.payload=s;}status(s){return this.payload.status=s,this}code(s){return this.payload.code=s,this}msg(s){return this.payload.msg=s,this}},l=class extends n{constructor(t){super({status:400,code:"bad_request",msg:t});}},u=class extends n{constructor(t){super({status:401,code:"unauthorized",msg:t});}},m=class extends n{constructor(t){super({status:402,code:"payment_required",msg:t});}},y=class extends n{constructor(t){super({status:403,code:"forbidden",msg:t});}},x=class extends n{constructor(t){super({status:404,code:"not_found",msg:t});}},g=class extends n{constructor(t){super({status:405,code:"method_not_allowed",msg:t});}},f=class extends n{constructor(t){super({status:406,code:"not_acceptable",msg:t});}},h=class extends n{constructor(t){super({status:407,code:"proxy_authentication_required",msg:t});}},R=class extends n{constructor(t){super({status:408,code:"request_timeout",msg:t});}},I=class extends n{constructor(t){super({status:409,code:"conflict",msg:t});}},v=class extends n{constructor(t){super({status:410,code:"gone",msg:t});}},b=class extends n{constructor(t){super({status:411,code:"length_required",msg:t});}},_=class extends n{constructor(t){super({status:412,code:"precondition_failed",msg:t});}},q=class extends n{constructor(t){super({status:413,code:"content_too_large",msg:t});}},A=class extends n{constructor(t){super({status:414,code:"uri_too_long",msg:t});}},P=class extends n{constructor(t){super({status:415,code:"unsupported_media_type",msg:t});}},T=class extends n{constructor(t){super({status:416,code:"range_not_satisfiable",msg:t});}},M=class extends n{constructor(t){super({status:417,code:"expectation_failed",msg:t});}},O=class extends n{constructor(t){super({status:418,code:"im_a_teapot",msg:t});}},E=class extends n{constructor(t){super({status:421,code:"misdirected_request",msg:t});}},D=class extends n{constructor(t){super({status:422,code:"unprocessable_entity",msg:t});}},k=class extends n{constructor(t){super({status:423,code:"locked",msg:t});}},w=class extends n{constructor(t){super({status:424,code:"failed_dependency",msg:t});}},F=class extends n{constructor(t){super({status:425,code:"too_early",msg:t});}},H=class extends n{constructor(t){super({status:426,code:"upgrade_required",msg:t});}},U=class extends n{constructor(t){super({status:428,code:"precondition_required",msg:t});}},Q=class extends n{constructor(t){super({status:429,code:"too_many_requests",msg:t});}},N=class extends n{constructor(t){super({status:431,code:"request_header_fields_too_large",msg:t});}},j=class extends n{constructor(t){super({status:451,code:"unavailable_for_legal_reasons",msg:t});}},L=class extends n{constructor(t){super({status:500,code:"internal_server_error",msg:t});}},B=class extends n{constructor(t){super({status:501,code:"not_implemented",msg:t});}},V=class extends n{constructor(t){super({status:502,code:"bad_gateway",msg:t});}},K=class extends n{constructor(t){super({status:503,code:"service_unavailable",msg:t});}},G=class extends n{constructor(t){super({status:504,code:"gateway_timeout",msg:t});}},z=class extends n{constructor(t){super({status:505,code:"http_version_not_supported",msg:t});}},J=class extends n{constructor(t){super({status:506,code:"variant_also_negotiates",msg:t});}},W=class extends n{constructor(t){super({status:507,code:"insufficient_storage",msg:t});}},X=class extends n{constructor(t){super({status:508,code:"loop_detected",msg:t});}},Y=class extends n{constructor(t){super({status:510,code:"not_extended",msg:t});}},Z=class extends n{constructor(t){super({status:511,code:"network_authentication_required",msg:t});}};var a={get instance(){return globalThis.__M1CRO__.internals}};var ne={fromId(r){return a.instance.providerFromId(r)}};var se={parse(r){return a.instance.parseAppId(r)}};export{se as AppId,c as EntityModel,i as EntitySchema,ne as Provider,d as StatusCode,ee as cbor,re as entityModel,te as entitySchema,$ as error};
@@ -21,11 +21,11 @@ interface SchemaDefinition {
21
21
  [key: string]: FieldSpec;
22
22
  }
23
23
  type ConstructorToType<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends DateConstructor ? number : T extends ObjectConstructor ? Record<string, unknown> : never;
24
- type IsRequired<F> = F extends {
25
- required: true;
26
- } ? true : false;
24
+ type IsOptional<F> = F extends {
25
+ required: false;
26
+ } ? false : true;
27
27
  type RequiredKeys<Def extends SchemaDefinition> = {
28
- [K in keyof Def]-?: IsRequired<Def[K]> extends true ? K : never;
28
+ [K in keyof Def]-?: IsOptional<Def[K]> extends false ? K : never;
29
29
  }[keyof Def];
30
30
  type OptionalKeys<Def extends SchemaDefinition> = Exclude<keyof Def, RequiredKeys<Def>>;
31
31
  type InferInterface<S extends EntitySchema<any>> = InferSchema<S['definition']>;
@@ -36,16 +36,16 @@ type Unwrap<F> = F extends {
36
36
  type InferInner<I> = I extends ScalarConstructor ? ConstructorToType<I> : I extends readonly [infer U] ? U extends FieldSpec ? Array<InferField<U>> : never : I extends SchemaDefinition ? InferSchema<I> : never;
37
37
  type InferField<F extends FieldSpec> = InferInner<Unwrap<F>>;
38
38
  type InferSchema<Def extends SchemaDefinition> = {
39
- [K in RequiredKeys<Def>]: InferField<Def[K]>;
39
+ [K in OptionalKeys<Def>]?: InferField<Def[K]> | undefined;
40
40
  } & {
41
- [K in OptionalKeys<Def>]?: InferField<Def[K]>;
41
+ [K in RequiredKeys<Def>]: InferField<Def[K]>;
42
42
  };
43
43
 
44
+ declare function entitySchema<const Def extends SchemaDefinition>(def: AssertNoReservedKeys<Def>): EntitySchema<Def>;
44
45
  declare class EntitySchema<Def extends SchemaDefinition = SchemaDefinition> {
45
46
  readonly definition: Def;
46
47
  constructor(definition: Def);
47
48
  }
48
- declare function entitySchema<const Def extends SchemaDefinition>(def: AssertNoReservedKeys<Def>): EntitySchema<Def>;
49
49
  declare class CompiledSchema {
50
50
  constructor(schema: EntitySchema);
51
51
  get shape(): unknown;
@@ -402,4 +402,4 @@ interface Bridge {
402
402
  declare const logLevels: readonly ["trace", "debug", "info", "warn", "error", "none"];
403
403
  type LogLevel = (typeof logLevels)[number];
404
404
 
405
- export { type AppRole as A, type Bridge as B, CompiledSchema as C, EntitySchema as E, type Filter as F, type HydratedDocument as H, type InsertDocument as I, type LogLevel as L, type Method as M, type Namespace as N, Provider as P, type RemoveQuery as R, type Sorting$1 as S, type Tenant as T, type UpdateQuery as U, type Visibility as V, type FindQuery as a, type FindOneQuery as b, type InsertQuery as c, type InsertOneQuery as d, type InferInterface as e, type UpdateOneQuery as f, type RemoveOneQuery as g, type Router as h, type HookEventMap as i, type EventHandler as j, AppId as k, type Artifacts as l, type Auth as m, type Entity as n, type InferSchema as o, type Middleware as p, type Providers as q, type Request as r, type RequestBuilder as s, type RequestHandler as t, type Response as u, type ResponseBuilder as v, type RouteOptions as w, StatusCode as x, type Subject as y, entitySchema as z };
405
+ export { type AppRole as A, type Bridge as B, CompiledSchema as C, EntitySchema as E, type Filter as F, type GeneratedFields as G, type HydratedDocument as H, type InsertDocument as I, type LogLevel as L, type Method as M, type Namespace as N, Provider as P, type RemoveQuery as R, type Sorting$1 as S, type Tenant as T, type UpdateQuery as U, type Visibility as V, type FindQuery as a, type FindOneQuery as b, type InsertQuery as c, type InsertOneQuery as d, type InferInterface as e, type UpdateOneQuery as f, type RemoveOneQuery as g, type Router as h, type HookEventMap as i, type EventHandler as j, AppId as k, type Artifacts as l, type Auth as m, type Entity as n, type InferSchema as o, type Middleware as p, type Providers as q, type Request as r, type RequestBuilder as s, type RequestHandler as t, type Response as u, type ResponseBuilder as v, type RouteOptions as w, StatusCode as x, type Subject as y, entitySchema as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m1cro/server-sdk",
3
- "version": "0.1.1-beta.14",
3
+ "version": "0.1.1-beta.16",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"