@m1cro/server-sdk 1.0.0-beta.1 → 1.0.0-beta.10

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,6 +1,5 @@
1
- import { B as Bridge, L as LogLevel } from './log-DK4k_SQB.js';
1
+ import { B as Bridge, L as LogLevel } from './log-CAh1biS4.js';
2
2
  import * as console from 'node:console';
3
- import 'cookie';
4
3
 
5
4
  declare global {
6
5
  var Bridge: Bridge;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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
- import 'cookie';
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, J as JobHandler, k as JobOptions } from './log-CAh1biS4.js';
2
+ export { l as AppId, m as Artifacts, n as Auth, B as Bridge, o as Entity, p as InferSchema, L as LogLevel, M as Method, q as Middleware, N as Namespace, P as Provider, r as Providers, s as Request, t as RequestBuilder, u as RequestHandler, v as Response, w as ResponseBuilder, x as RouteOptions, S as Sorting, y as StatusCode, z as Subject, T as Tenant, V as Visibility, D as entitySchema } from './log-CAh1biS4.js';
3
+ import util from 'node:util';
4
4
 
5
5
  declare function entityModel<S extends EntitySchema<any>>(name: string, schemaDef: S, options?: EntityModelOptions<S>): EntityModel<S>;
6
6
  interface EntityModelRegistration {
@@ -27,6 +27,7 @@ declare class EntityModel<S extends EntitySchema<any>> implements EntityModelReg
27
27
  }
28
28
  interface EntityModelOptions<S extends EntitySchema<any>> {
29
29
  indexes?: EntityIndexManifest<S>[];
30
+ global?: boolean;
30
31
  }
31
32
  interface EntityIndexManifest<S extends EntitySchema<any>> {
32
33
  fields: Array<keyof GeneratedFields | keyof S['definition']>;
@@ -44,24 +45,28 @@ interface App {
44
45
  }): App;
45
46
  entity(model: EntityModelRegistration): App;
46
47
  subscribe(pattern: string, handler: EventHandler): App;
48
+ job(name: string, handler: JobHandler, options?: JobOptions): App;
47
49
  }
48
50
 
49
- declare const _default: {
50
- encode<T>(data: T): Uint8Array;
51
- decode<T>(data: Uint8Array): T;
52
- };
53
-
54
51
  interface ErrorPayload {
55
52
  status: number;
56
53
  code: string;
57
54
  msg?: string | undefined;
58
55
  }
59
56
  declare class BaseError extends Error {
60
- protected payload: ErrorPayload;
61
- constructor(payload: ErrorPayload);
62
- status(status: number): this;
63
- code(code: string): this;
64
- msg(msg: string): this;
57
+ payload: ErrorPayload;
58
+ constructor(status: number, code: string, msg?: string);
59
+ get status(): number;
60
+ set status(status: number);
61
+ get code(): string;
62
+ set code(code: string);
63
+ get msg(): string | undefined;
64
+ set msg(msg: string | undefined);
65
+ [util.inspect.custom](): {
66
+ status: number;
67
+ code: string;
68
+ msg: string | undefined;
69
+ };
65
70
  }
66
71
  declare class BadRequestError extends BaseError {
67
72
  constructor(msg?: string);
@@ -184,4 +189,4 @@ declare class NetworkAuthenticationRequiredError extends BaseError {
184
189
  constructor(msg?: string);
185
190
  }
186
191
 
187
- export { type App, AppRole, BadGatewayError, BadRequestError, BaseError, ConflictError, ContentTooLargeError, type EntityIndexManifest, EntityModel, type EntityModelOptions, EntitySchema, type EntryPoint, EventHandler, ExpectationFailedError, FailedDependencyError, Filter, ForbiddenError, GatewayTimeoutError, GoneError, HTTPVersionNotSupportedError, HydratedDocument, ImATeapotError, InferInterface, InsertDocument, InsufficientStorageError, InternalServerError, LengthRequiredError, LockedError, LoopDetectedError, MethodNotAllowedError, MisdirectedRequestError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, RequestHeaderFieldsTooLargeError, RequestTimeoutError, Router, ServiceUnavailableError, TooEarlyError, TooManyRequestsError, URITooLongError, UnauthorizedError, UnavailableForLegalReasonsError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, VariantAlsoNegotiatesError, _default as cbor, entityModel };
192
+ export { type App, AppRole, BadGatewayError, BadRequestError, BaseError, ConflictError, ContentTooLargeError, type EntityIndexManifest, EntityModel, type EntityModelOptions, EntitySchema, type EntryPoint, EventHandler, ExpectationFailedError, FailedDependencyError, Filter, ForbiddenError, GatewayTimeoutError, GoneError, HTTPVersionNotSupportedError, HydratedDocument, ImATeapotError, InferInterface, InsertDocument, InsufficientStorageError, InternalServerError, JobOptions, LengthRequiredError, LockedError, LoopDetectedError, MethodNotAllowedError, MisdirectedRequestError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, RequestHeaderFieldsTooLargeError, RequestTimeoutError, Router, ServiceUnavailableError, TooEarlyError, TooManyRequestsError, URITooLongError, UnauthorizedError, UnavailableForLegalReasonsError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, VariantAlsoNegotiatesError, entityModel };
package/dist/index.js CHANGED
@@ -1 +1 @@
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};
1
+ import S from'util';function Z(t){return new i(t)}var i=class{constructor(r){this.definition=r;}definition},s=class{constructor(r){}get shape(){return {}}};function $(t,r,o){return new p(t,r,o)}var p=class{constructor(r,o,a){this.name=r;this.schemaDef=o;this.options=a;this.schema=new s(o);}name;schemaDef;options;schema;entity(){return globalThis.Bridge.entity(this.name)}find(r){return this.entity().find(r)}findOne(r){return this.entity().findOne(r)}insert(r){return this.entity().insert(r)}insertOne(r){return this.entity().insertOne(r)}update(r,o){return this.entity().update(r,o)}updateOne(r,o){return this.entity().updateOne(r,o)}remove(r){return this.entity().remove(r)}removeOne(r){return this.entity().removeOne(r)}};var c=(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))(c||{});var n=class extends Error{payload;constructor(r,o,a){super(a||o),this.payload={status:r,code:o,msg:a};}get status(){return this.payload.status}set status(r){this.payload.status=r;}get code(){return this.payload.code}set code(r){this.payload.code=r;}get msg(){return this.payload.msg}set msg(r){this.payload.msg=r;}[S.inspect.custom](){return {status:this.status,code:this.code,msg:this.msg}}},l=class extends n{constructor(r){super(400,"bad_request",r);}},d=class extends n{constructor(r){super(401,"unauthorized",r);}},y=class extends n{constructor(r){super(402,"payment_required",r);}},u=class extends n{constructor(r){super(403,"forbidden",r);}},m=class extends n{constructor(r){super(404,"not_found",r);}},x=class extends n{constructor(r){super(405,"method_not_allowed",r);}},g=class extends n{constructor(r){super(406,"not_acceptable",r);}},f=class extends n{constructor(r){super(407,"proxy_authentication_required",r);}},h=class extends n{constructor(r){super(408,"request_timeout",r);}},R=class extends n{constructor(r){super(409,"conflict",r);}},b=class extends n{constructor(r){super(410,"gone",r);}},I=class extends n{constructor(r){super(411,"length_required",r);}},T=class extends n{constructor(r){super(412,"precondition_failed",r);}},_=class extends n{constructor(r){super(413,"content_too_large",r);}},q=class extends n{constructor(r){super(414,"uri_too_long",r);}},v=class extends n{constructor(r){super(415,"unsupported_media_type",r);}},P=class extends n{constructor(r){super(416,"range_not_satisfiable",r);}},E=class extends n{constructor(r){super(417,"expectation_failed",r);}},A=class extends n{constructor(r){super(418,"im_a_teapot",r);}},M=class extends n{constructor(r){super(421,"misdirected_request",r);}},O=class extends n{constructor(r){super(422,"unprocessable_entity",r);}},w=class extends n{constructor(r){super(423,"locked",r);}},D=class extends n{constructor(r){super(424,"failed_dependency",r);}},F=class extends n{constructor(r){super(425,"too_early",r);}},U=class extends n{constructor(r){super(426,"upgrade_required",r);}},k=class extends n{constructor(r){super(428,"precondition_required",r);}},H=class extends n{constructor(r){super(429,"too_many_requests",r);}},N=class extends n{constructor(r){super(431,"request_header_fields_too_large",r);}},L=class extends n{constructor(r){super(451,"unavailable_for_legal_reasons",r);}},Q=class extends n{constructor(r){super(500,"internal_server_error",r);}},B=class extends n{constructor(r){super(501,"not_implemented",r);}},j=class extends n{constructor(r){super(502,"bad_gateway",r);}},G=class extends n{constructor(r){super(503,"service_unavailable",r);}},V=class extends n{constructor(r){super(504,"gateway_timeout",r);}},K=class extends n{constructor(r){super(505,"http_version_not_supported",r);}},z=class extends n{constructor(r){super(506,"variant_also_negotiates",r);}},J=class extends n{constructor(r){super(507,"insufficient_storage",r);}},W=class extends n{constructor(r){super(508,"loop_detected",r);}},X=class extends n{constructor(r){super(510,"not_extended",r);}},Y=class extends n{constructor(r){super(511,"network_authentication_required",r);}};var C={parse(t){return Bridge.utils.parseAppId(t)}};export{C as AppId,j as BadGatewayError,l as BadRequestError,n as BaseError,R as ConflictError,_ as ContentTooLargeError,p as EntityModel,i as EntitySchema,E as ExpectationFailedError,D as FailedDependencyError,u as ForbiddenError,V as GatewayTimeoutError,b as GoneError,K as HTTPVersionNotSupportedError,A as ImATeapotError,J as InsufficientStorageError,Q as InternalServerError,I as LengthRequiredError,w as LockedError,W as LoopDetectedError,x as MethodNotAllowedError,M as MisdirectedRequestError,Y as NetworkAuthenticationRequiredError,g as NotAcceptableError,X as NotExtendedError,m as NotFoundError,B as NotImplementedError,y as PaymentRequiredError,T as PreconditionFailedError,k as PreconditionRequiredError,f as ProxyAuthenticationRequiredError,P as RangeNotSatisfiableError,N as RequestHeaderFieldsTooLargeError,h as RequestTimeoutError,G as ServiceUnavailableError,c as StatusCode,F as TooEarlyError,H as TooManyRequestsError,q as URITooLongError,d as UnauthorizedError,L as UnavailableForLegalReasonsError,O as UnprocessableEntityError,v as UnsupportedMediaTypeError,U as UpgradeRequiredError,z as VariantAlsoNegotiatesError,$ as entityModel,Z as entitySchema};
@@ -1,5 +1,3 @@
1
- import { SetCookie } from 'cookie';
2
-
3
1
  type Filter = Record<string, unknown>;
4
2
  type Sorting$1 = Record<string, 'asc' | 'desc'>;
5
3
  type GeneratedFields = {
@@ -141,7 +139,6 @@ type Variant<K extends PropertyKey, T extends object> = {
141
139
  [Q in keyof U]: U[Q];
142
140
  } : never;
143
141
  }[keyof T];
144
- type EventHandler = <T>(event: string, data: T) => void | Promise<void>;
145
142
  type Visibility = 'private' | 'platform' | 'vendor' | 'public';
146
143
  interface Tenant {
147
144
  id: string;
@@ -182,6 +179,11 @@ interface HookEventMap {
182
179
  install: [];
183
180
  }
184
181
 
182
+ type EventHandler = <T>(event: string, data: T) => void | Promise<void>;
183
+ interface EventEmitter {
184
+ publish<T extends object>(event: string, payload: T, visibility?: Visibility[]): Promise<void>;
185
+ }
186
+
185
187
  interface Artifacts {
186
188
  get<T>(key: string): T | undefined;
187
189
  set<T>(key: string, value: T): void;
@@ -189,7 +191,7 @@ interface Artifacts {
189
191
  get auth(): Auth | undefined;
190
192
  }
191
193
 
192
- type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
194
+ type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
193
195
  declare enum StatusCode {
194
196
  Continue = 100,
195
197
  SwitchingProtocols = 101,
@@ -255,7 +257,7 @@ declare enum StatusCode {
255
257
  NetworkAuthenticationRequired = 511
256
258
  }
257
259
  type RequestHandler = (req: Request, res: ResponseBuilder) => void | Promise<void>;
258
- type Middleware = (req: Request, res: ResponseBuilder, next: () => Promise<void>) => void | Promise<void>;
260
+ type Middleware = (req: Request, res: ResponseBuilder, next: () => Promise<void>) => Promise<void>;
259
261
  interface Router {
260
262
  scope(path: string): Router;
261
263
  route(method: Method, path: string, handler: RequestHandler, options?: RouteOptions): Router;
@@ -301,7 +303,6 @@ interface RequestBuilder {
301
303
  interface Response {
302
304
  get status(): number;
303
305
  get headers(): Headers;
304
- cookie(name: string): SetCookie | undefined;
305
306
  payload<T = any>(): Promise<T>;
306
307
  payload<T = any>(type: 'json' | 'cbor'): Promise<T>;
307
308
  payload(type: 'bytes'): Promise<Uint8Array>;
@@ -312,11 +313,11 @@ interface ResponseBuilder {
312
313
  status(status: number): this;
313
314
  header(name: string, value: string): this;
314
315
  headers(headers: HeadersInit): this;
315
- cookie(name: string, value?: string, options?: SetCookieOptions): this;
316
+ cookie(name: string, cookie?: SetCookie): this;
316
317
  payload<T = unknown>(payload: T, type?: PayloadType): this;
317
318
  }
318
- interface SetCookieOptions {
319
- encode?: (s: string) => string;
319
+ interface SetCookie {
320
+ value?: string;
320
321
  maxAge?: number;
321
322
  expires?: Date;
322
323
  domain?: string;
@@ -328,6 +329,15 @@ interface SetCookieOptions {
328
329
  sameSite?: boolean | 'lax' | 'strict' | 'none';
329
330
  }
330
331
 
332
+ interface Jobs {
333
+ schedule(name: string, when?: Date): void;
334
+ }
335
+ type JobHandler = (data?: unknown) => void | Promise<void>;
336
+ interface JobOptions {
337
+ schedule?: string;
338
+ timeoutMs?: number;
339
+ }
340
+
331
341
  interface Crypto {
332
342
  deriveKey(seed: string, length: number): Uint8Array;
333
343
  aesGcmEncrypt<T>(data: T): Uint8Array;
@@ -348,14 +358,14 @@ interface SetOptions {
348
358
  existenceCheck?: 'nx' | 'xx';
349
359
  }
350
360
  interface KeyValueStore {
351
- get<T>(key: string): Promise<T>;
352
- getDel<T>(key: string): Promise<T>;
361
+ get<T>(key: string): Promise<T | undefined>;
362
+ getDel<T>(key: string): Promise<T | undefined>;
353
363
  set<T>(key: string, value: T, options?: SetOptions): Promise<void>;
354
364
  delete(key: string): Promise<void>;
355
365
  }
356
366
 
357
367
  interface RPC {
358
- call(url: string, method: Method): Call;
368
+ call(method: Method, url: string): Call;
359
369
  get(url: string): Call;
360
370
  post(url: string): Call;
361
371
  put(url: string): Call;
@@ -366,41 +376,43 @@ interface Call extends RequestBuilder, PromiseLike<Response> {
366
376
  }
367
377
 
368
378
  interface Providers {
369
- list(group: string): Provider[];
379
+ list(group: string): Promise<Provider[]>;
380
+ createFromId(id: string): Provider;
370
381
  }
371
382
  interface Provider {
372
383
  get app(): AppId;
373
384
  get group(): string;
374
385
  get id(): string;
375
- call(path: string, method: Method): Call;
386
+ call(method: Method, path: string): Call;
376
387
  get(path: string): Call;
377
388
  post(path: string): Call;
378
389
  put(path: string): Call;
379
390
  patch(path: string): Call;
380
391
  delete(path: string): Call;
381
392
  }
382
- declare const Provider: {
383
- fromId(id: string): Provider;
384
- };
385
393
 
386
394
  interface SSE {
387
395
  push<T>(event: T, targets: string[]): Promise<void>;
388
396
  }
389
397
 
390
398
  interface Bridge {
399
+ get utils(): Utils;
391
400
  get tenant(): Tenant;
392
401
  get providers(): Providers;
402
+ get jobs(): Jobs;
393
403
  settings<T>(): T | undefined;
394
- crd<T>(key: string): T | undefined;
395
404
  get rpc(): RPC;
396
405
  get kv(): KeyValueStore;
397
406
  get sse(): SSE;
398
407
  get crypto(): Crypto;
408
+ get event(): EventEmitter;
399
409
  entity<T extends object>(name: string): Entity<T>;
400
- publish<T extends object>(event: string, payload: T, visibility?: Visibility[]): void;
410
+ }
411
+ interface Utils {
412
+ parseAppId(input: string): AppId;
401
413
  }
402
414
 
403
415
  declare const logLevels: readonly ["trace", "debug", "info", "warn", "error", "none"];
404
416
  type LogLevel = (typeof logLevels)[number];
405
417
 
406
- 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 };
418
+ export { type AppRole as A, type Bridge as B, CompiledSchema as C, entitySchema as D, EntitySchema as E, type Filter as F, type GeneratedFields as G, type HydratedDocument as H, type InsertDocument as I, type JobHandler as J, type LogLevel as L, type Method as M, type Namespace as N, type 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, type JobOptions as k, AppId as l, type Artifacts as m, type Auth as n, type Entity as o, type InferSchema as p, type Middleware as q, type Providers as r, type Request as s, type RequestBuilder as t, type RequestHandler as u, type Response as v, type ResponseBuilder as w, type RouteOptions as x, StatusCode as y, type Subject as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m1cro/server-sdk",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@eslint/js": "^9.39.2",
38
38
  "@stylistic/eslint-plugin": "^5.7.1",
39
- "@types/node": "^25.3.0",
39
+ "@types/node": "^25.5.2",
40
40
  "eslint": "^9.39.2",
41
41
  "eslint-config-prettier": "^10.1.8",
42
42
  "eslint-plugin-prettier": "^5.5.5",