@m1cro/server-sdk 0.1.1-beta.21 → 0.1.1-beta.23

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-BiuB_mLm.js';
1
+ import { B as Bridge, L as LogLevel } from './log-DK4k_SQB.js';
2
2
  import * as console from 'node:console';
3
3
  import 'cookie';
4
4
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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-BiuB_mLm.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-BiuB_mLm.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-DK4k_SQB.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-DK4k_SQB.js';
3
3
  import 'cookie';
4
4
 
5
5
  declare function entityModel<S extends EntitySchema<any>>(name: string, schemaDef: S, options?: EntityModelOptions<S>): EntityModel<S>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import*as o from'cbor2';var $={encode(r){return o.encode(r)},decode(r){return o.decode(r)}};function S(r){return new i(r)}var i=class{constructor(t){this.definition=t;}},p=class{constructor(t){}get shape(){return {}}};function C(r,t,s){return new a(r,t,s)}var a=class{constructor(t,s,re){this.name=t;this.schemaDef=s;this.options=re;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 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});}},g=class extends n{constructor(t){super({status:404,code:"not_found",msg:t});}},x=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});}},b=class extends n{constructor(t){super({status:410,code:"gone",msg:t});}},v=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});}},T=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});}},P=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});}},E=class extends n{constructor(t){super({status:418,code:"im_a_teapot",msg:t});}},O=class extends n{constructor(t){super({status:421,code:"misdirected_request",msg:t});}},F=class extends n{constructor(t){super({status:422,code:"unprocessable_entity",msg:t});}},U=class extends n{constructor(t){super({status:423,code:"locked",msg:t});}},D=class extends n{constructor(t){super({status:424,code:"failed_dependency",msg:t});}},w=class extends n{constructor(t){super({status:425,code:"too_early",msg:t});}},k=class extends n{constructor(t){super({status:426,code:"upgrade_required",msg:t});}},H=class extends n{constructor(t){super({status:428,code:"precondition_required",msg:t});}},N=class extends n{constructor(t){super({status:429,code:"too_many_requests",msg:t});}},Q=class extends n{constructor(t){super({status:431,code:"request_header_fields_too_large",msg:t});}},L=class extends n{constructor(t){super({status:451,code:"unavailable_for_legal_reasons",msg:t});}},j=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});}},G=class extends n{constructor(t){super({status:503,code:"service_unavailable",msg:t});}},K=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 c={get instance(){return globalThis.__M1CRO__.internals}};var ee={fromId(r){return c.instance.providerFromId(r)}};var te={parse(r){return c.instance.parseAppId(r)}};export{te as AppId,V as BadGatewayError,l as BadRequestError,n as BaseError,I as ConflictError,q as ContentTooLargeError,a as EntityModel,i as EntitySchema,M as ExpectationFailedError,D as FailedDependencyError,y as ForbiddenError,K as GatewayTimeoutError,b as GoneError,z as HTTPVersionNotSupportedError,E as ImATeapotError,W as InsufficientStorageError,j as InternalServerError,v as LengthRequiredError,U as LockedError,X as LoopDetectedError,x as MethodNotAllowedError,O as MisdirectedRequestError,Z as NetworkAuthenticationRequiredError,f as NotAcceptableError,Y as NotExtendedError,g as NotFoundError,B as NotImplementedError,m as PaymentRequiredError,_ as PreconditionFailedError,H as PreconditionRequiredError,ee as Provider,h as ProxyAuthenticationRequiredError,P as RangeNotSatisfiableError,Q as RequestHeaderFieldsTooLargeError,R as RequestTimeoutError,G as ServiceUnavailableError,d as StatusCode,w as TooEarlyError,N as TooManyRequestsError,T as URITooLongError,u as UnauthorizedError,L as UnavailableForLegalReasonsError,F as UnprocessableEntityError,A as UnsupportedMediaTypeError,k as UpgradeRequiredError,J as VariantAlsoNegotiatesError,$ as cbor,C as entityModel,S as entitySchema};
1
+ import*as s from'cbor2';var $={encode(r){return s.encode(r)},decode(r){return s.decode(r)}};function S(r){return new i(r)}var i=class{constructor(t){this.definition=t;}},p=class{constructor(t){}get shape(){return {}}};function C(r,t,o){return new a(r,t,o)}var a=class{constructor(t,o,re){this.name=t;this.schemaDef=o;this.options=re;this.schema=new p(o);}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,o){return this.entity().update(t,o)}updateOne(t,o){return this.entity().updateOne(t,o)}remove(t){return this.entity().remove(t)}removeOne(t){return this.entity().removeOne(t)}};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(o){super(o.msg);this.payload=o;}status(o){return this.payload.status=o,this}code(o){return this.payload.code=o,this}msg(o){return this.payload.msg=o,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});}},y=class extends n{constructor(t){super({status:402,code:"payment_required",msg:t});}},m=class extends n{constructor(t){super({status:403,code:"forbidden",msg:t});}},g=class extends n{constructor(t){super({status:404,code:"not_found",msg:t});}},x=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});}},b=class extends n{constructor(t){super({status:410,code:"gone",msg:t});}},v=class extends n{constructor(t){super({status:411,code:"length_required",msg:t});}},T=class extends n{constructor(t){super({status:412,code:"precondition_failed",msg:t});}},_=class extends n{constructor(t){super({status:413,code:"content_too_large",msg:t});}},P=class extends n{constructor(t){super({status:414,code:"uri_too_long",msg:t});}},q=class extends n{constructor(t){super({status:415,code:"unsupported_media_type",msg:t});}},A=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});}},E=class extends n{constructor(t){super({status:418,code:"im_a_teapot",msg:t});}},O=class extends n{constructor(t){super({status:421,code:"misdirected_request",msg:t});}},w=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});}},F=class extends n{constructor(t){super({status:424,code:"failed_dependency",msg:t});}},D=class extends n{constructor(t){super({status:425,code:"too_early",msg:t});}},U=class extends n{constructor(t){super({status:426,code:"upgrade_required",msg:t});}},H=class extends n{constructor(t){super({status:428,code:"precondition_required",msg:t});}},N=class extends n{constructor(t){super({status:429,code:"too_many_requests",msg:t});}},Q=class extends n{constructor(t){super({status:431,code:"request_header_fields_too_large",msg:t});}},L=class extends n{constructor(t){super({status:451,code:"unavailable_for_legal_reasons",msg:t});}},B=class extends n{constructor(t){super({status:500,code:"internal_server_error",msg:t});}},j=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});}},G=class extends n{constructor(t){super({status:503,code:"service_unavailable",msg:t});}},K=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 c={get instance(){return globalThis.__M1CRO__.internals}};var ee={fromId(r){return c.instance.providerFromId(r)}};var te={parse(r){return c.instance.parseAppId(r)}};export{te as AppId,V as BadGatewayError,l as BadRequestError,n as BaseError,I as ConflictError,_ as ContentTooLargeError,a as EntityModel,i as EntitySchema,M as ExpectationFailedError,F as FailedDependencyError,m as ForbiddenError,K as GatewayTimeoutError,b as GoneError,z as HTTPVersionNotSupportedError,E as ImATeapotError,W as InsufficientStorageError,B as InternalServerError,v as LengthRequiredError,k as LockedError,X as LoopDetectedError,x as MethodNotAllowedError,O as MisdirectedRequestError,Z as NetworkAuthenticationRequiredError,f as NotAcceptableError,Y as NotExtendedError,g as NotFoundError,j as NotImplementedError,y as PaymentRequiredError,T as PreconditionFailedError,H as PreconditionRequiredError,ee as Provider,h as ProxyAuthenticationRequiredError,A as RangeNotSatisfiableError,Q as RequestHeaderFieldsTooLargeError,R as RequestTimeoutError,G as ServiceUnavailableError,d as StatusCode,D as TooEarlyError,N as TooManyRequestsError,P as URITooLongError,u as UnauthorizedError,L as UnavailableForLegalReasonsError,w as UnprocessableEntityError,q as UnsupportedMediaTypeError,U as UpgradeRequiredError,J as VariantAlsoNegotiatesError,$ as cbor,C as entityModel,S as entitySchema};
@@ -276,6 +276,7 @@ interface MiddlewareOptions {
276
276
  path?: string;
277
277
  priority?: number;
278
278
  }
279
+ type PayloadType = 'bytes' | 'json' | 'cbor' | 'text';
279
280
  interface Request {
280
281
  get artifacts(): Artifacts;
281
282
  get method(): Method;
@@ -283,9 +284,11 @@ interface Request {
283
284
  get params(): Record<string, string>;
284
285
  get headers(): Headers;
285
286
  cookie(name: string): string | undefined;
286
- body(): Promise<Uint8Array>;
287
- text(): Promise<string>;
288
- json<T>(): Promise<T>;
287
+ payload<T = any>(): Promise<T>;
288
+ payload<T = any>(type: 'json' | 'cbor'): Promise<T>;
289
+ payload(type: 'bytes'): Promise<Uint8Array>;
290
+ payload(type: 'text'): Promise<string>;
291
+ payload(type?: PayloadType): Promise<unknown>;
289
292
  }
290
293
  interface RequestBuilder {
291
294
  method(method: Method): this;
@@ -293,26 +296,24 @@ interface RequestBuilder {
293
296
  header(name: string, value: string): this;
294
297
  headers(headers: HeadersInit): this;
295
298
  cookie(name: string, value: string): this;
296
- body(bytes: Uint8Array): this;
297
- text(text: string): this;
298
- json<T>(json: T): this;
299
+ payload<T = unknown>(payload: T, type?: PayloadType): this;
299
300
  }
300
301
  interface Response {
301
302
  get status(): number;
302
303
  get headers(): Headers;
303
304
  cookie(name: string): SetCookie | undefined;
304
- body(): Promise<Uint8Array>;
305
- text(): Promise<string>;
306
- json<T>(): Promise<T>;
305
+ payload<T = any>(): Promise<T>;
306
+ payload<T = any>(type: 'json' | 'cbor'): Promise<T>;
307
+ payload(type: 'bytes'): Promise<Uint8Array>;
308
+ payload(type: 'text'): Promise<string>;
309
+ payload(type?: PayloadType): Promise<unknown>;
307
310
  }
308
311
  interface ResponseBuilder {
309
312
  status(status: number): this;
310
313
  header(name: string, value: string): this;
311
314
  headers(headers: HeadersInit): this;
312
315
  cookie(name: string, value?: string, options?: SetCookieOptions): this;
313
- body(bytes: Uint8Array): this;
314
- text(text: string): this;
315
- json<T>(json: T): this;
316
+ payload<T = unknown>(payload: T, type?: PayloadType): this;
316
317
  }
317
318
  interface SetCookieOptions {
318
319
  encode?: (s: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m1cro/server-sdk",
3
- "version": "0.1.1-beta.21",
3
+ "version": "0.1.1-beta.23",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"