@m1cro/server-sdk 0.1.1-beta.11 → 0.1.1-beta.12
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
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,73 @@
|
|
|
1
|
-
import { R as Router, H as HookEventMap, A as AppRole, E as EventHandler } from './log-
|
|
2
|
-
export {
|
|
1
|
+
import { F as FindQuery, a as FindOneQuery, I as InsertQuery, b as InsertOneQuery, U as UpdateQuery, c as UpdateOneQuery, R as RemoveQuery, d as RemoveOneQuery, e as Router, H as HookEventMap, A as AppRole, E as EventHandler } from './log-CxqFFE_w.js';
|
|
2
|
+
export { f as AppId, g as Artifacts, h as Auth, B as Bridge, i as Entity, L as LogLevel, M as Method, j as Middleware, N as Namespace, P as Provider, k as Providers, l as Request, m as RequestBuilder, n as RequestHandler, o as Response, p as ResponseBuilder, q as RouteOptions, S as StatusCode, r as Subject, T as Tenant, V as Visibility } from './log-CxqFFE_w.js';
|
|
3
3
|
import 'cookie';
|
|
4
4
|
|
|
5
|
+
type Filter = Record<string, unknown>;
|
|
6
|
+
type Sorting = Record<string, 'asc' | 'desc'>;
|
|
7
|
+
type GeneratedFields = {
|
|
8
|
+
id: string;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
};
|
|
12
|
+
type ReservedKeys = keyof GeneratedFields;
|
|
13
|
+
type HydratedDocument<S extends EntitySchema<any>> = Omit<InferInterface<S>, ReservedKeys> & GeneratedFields;
|
|
14
|
+
type InsertDocument<S extends EntitySchema<any>> = Omit<InferInterface<S>, ReservedKeys> & Partial<GeneratedFields>;
|
|
15
|
+
type ScalarConstructor = StringConstructor | NumberConstructor | BooleanConstructor | DateConstructor;
|
|
16
|
+
type FieldSpec = ScalarConstructor | {
|
|
17
|
+
type: ScalarConstructor;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type SchemaDefinition = Record<string, FieldSpec>;
|
|
21
|
+
type ConstructorToType<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends DateConstructor ? number : never;
|
|
22
|
+
type FieldType<F> = F extends {
|
|
23
|
+
type: infer C;
|
|
24
|
+
} ? ConstructorToType<C> : F extends ScalarConstructor ? ConstructorToType<F> : never;
|
|
25
|
+
type IsRequired<F> = F extends {
|
|
26
|
+
required: true;
|
|
27
|
+
} ? true : false;
|
|
28
|
+
type RequiredKeys<Def extends SchemaDefinition> = {
|
|
29
|
+
[K in keyof Def]-?: IsRequired<Def[K]> extends true ? K : never;
|
|
30
|
+
}[keyof Def];
|
|
31
|
+
type OptionalKeys<Def extends SchemaDefinition> = Exclude<keyof Def, RequiredKeys<Def>>;
|
|
32
|
+
type InferSchema<Def extends SchemaDefinition> = {
|
|
33
|
+
[K in RequiredKeys<Def>]: FieldType<Def[K]>;
|
|
34
|
+
} & {
|
|
35
|
+
[K in OptionalKeys<Def>]?: FieldType<Def[K]>;
|
|
36
|
+
};
|
|
37
|
+
type InferInterface<S extends EntitySchema<any>> = InferSchema<S['definition']>;
|
|
38
|
+
type AssertNoReservedKeys<Def extends SchemaDefinition> = Extract<keyof Def, ReservedKeys> extends never ? Def : never;
|
|
39
|
+
|
|
40
|
+
declare class EntitySchema<Def extends SchemaDefinition = SchemaDefinition> {
|
|
41
|
+
readonly definition: Def;
|
|
42
|
+
constructor(definition: Def);
|
|
43
|
+
}
|
|
44
|
+
declare function entitySchema<const Def extends SchemaDefinition>(def: AssertNoReservedKeys<Def>): EntitySchema<Def>;
|
|
45
|
+
declare class CompiledSchema {
|
|
46
|
+
constructor(schema: EntitySchema);
|
|
47
|
+
get shape(): unknown;
|
|
48
|
+
}
|
|
49
|
+
|
|
5
50
|
interface EntityModelRegistration {
|
|
6
51
|
get name(): string;
|
|
7
52
|
get schema(): {
|
|
8
53
|
get shape(): unknown;
|
|
9
54
|
};
|
|
10
55
|
}
|
|
56
|
+
declare class EntityModel<S extends EntitySchema<any>> implements EntityModelRegistration {
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly schemaDef: S;
|
|
59
|
+
schema: CompiledSchema;
|
|
60
|
+
constructor(name: string, schemaDef: S);
|
|
61
|
+
private entity;
|
|
62
|
+
find(filter?: Filter): FindQuery<HydratedDocument<S>>;
|
|
63
|
+
findOne(filter?: Filter): FindOneQuery<HydratedDocument<S>>;
|
|
64
|
+
insert(docs: InsertDocument<S>[]): InsertQuery<InsertDocument<S>, 'insertedIds'>;
|
|
65
|
+
insertOne(doc: InsertDocument<S>): InsertOneQuery<InsertDocument<S>, 'insertedId'>;
|
|
66
|
+
update(filter: Filter, update: Record<string, unknown>): UpdateQuery<InferInterface<S>, 'affectedRows'>;
|
|
67
|
+
updateOne(filter: Filter, update: Record<string, unknown>): UpdateOneQuery<InferInterface<S>, 'success'>;
|
|
68
|
+
remove(filter: Filter): RemoveQuery<InferInterface<S>, 'affectedRows'>;
|
|
69
|
+
removeOne(filter: Filter): RemoveOneQuery<InferInterface<S>, 'success'>;
|
|
70
|
+
}
|
|
11
71
|
|
|
12
72
|
type EntryPoint = (app: App) => unknown;
|
|
13
73
|
interface App {
|
|
@@ -246,4 +306,4 @@ declare namespace error {
|
|
|
246
306
|
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 };
|
|
247
307
|
}
|
|
248
308
|
|
|
249
|
-
export { type App, AppRole, type EntryPoint, EventHandler, Router, _default as cbor, error };
|
|
309
|
+
export { type App, AppRole, EntityModel, EntitySchema, type EntryPoint, EventHandler, type Filter, type HydratedDocument, type InferInterface, type InferSchema, type InsertDocument, Router, type Sorting, _default as cbor, entitySchema, error };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as o from'cbor2';var
|
|
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:()=>b,Locked:()=>w,LoopDetected:()=>X,MethodNotAllowed:()=>y,MisdirectedRequest:()=>M,NetworkAuthenticationRequired:()=>Z,NotAcceptable:()=>f,NotExtended:()=>Y,NotFound:()=>x,NotImplemented:()=>B,PaymentRequired:()=>m,PreconditionFailed:()=>_,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});}},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});}},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};
|
|
@@ -354,4 +354,4 @@ interface Bridge {
|
|
|
354
354
|
declare const logLevels: readonly ["trace", "debug", "info", "warn", "error", "none"];
|
|
355
355
|
type LogLevel = (typeof logLevels)[number];
|
|
356
356
|
|
|
357
|
-
export { type AppRole as A, type Bridge as B, type EventHandler as E, type HookEventMap as H, type LogLevel as L, type Method as M, type Namespace as N, Provider as P, type
|
|
357
|
+
export { type AppRole as A, type Bridge as B, type EventHandler as E, type FindQuery as F, type HookEventMap as H, type InsertQuery as I, type LogLevel as L, type Method as M, type Namespace as N, Provider as P, type RemoveQuery as R, StatusCode as S, type Tenant as T, type UpdateQuery as U, type Visibility as V, type FindOneQuery as a, type InsertOneQuery as b, type UpdateOneQuery as c, type RemoveOneQuery as d, type Router as e, AppId as f, type Artifacts as g, type Auth as h, type Entity as i, type Middleware as j, type Providers as k, type Request as l, type RequestBuilder as m, type RequestHandler as n, type Response as o, type ResponseBuilder as p, type RouteOptions as q, type Subject as r };
|