@m1cro/server-sdk 0.1.1-beta.12 → 0.1.1-beta.13
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 +1 -1
- package/dist/index.d.ts +3 -48
- package/dist/index.js +1 -1
- package/dist/{log-CxqFFE_w.d.ts → log-Br7AwYvF.d.ts} +110 -62
- package/package.json +1 -1
package/dist/globals.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,7 @@
|
|
|
1
|
-
import { F as
|
|
2
|
-
export {
|
|
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-Br7AwYvF.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-Br7AwYvF.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
|
-
|
|
50
5
|
interface EntityModelRegistration {
|
|
51
6
|
get name(): string;
|
|
52
7
|
get schema(): {
|
|
@@ -306,4 +261,4 @@ declare namespace error {
|
|
|
306
261
|
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 };
|
|
307
262
|
}
|
|
308
263
|
|
|
309
|
-
export { type App, AppRole, EntityModel, EntitySchema, type EntryPoint, EventHandler,
|
|
264
|
+
export { type App, AppRole, EntityModel, EntitySchema, type EntryPoint, EventHandler, Filter, HydratedDocument, InferInterface, InsertDocument, Router, _default as cbor, 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:()=>
|
|
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,66 +1,66 @@
|
|
|
1
1
|
import { SetCookie } from 'cookie';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type Variant<K extends PropertyKey, T extends object> = {
|
|
7
|
-
[P in keyof T]: {
|
|
8
|
-
[Q in K]: P;
|
|
9
|
-
} & T[P] extends infer U ? {
|
|
10
|
-
[Q in keyof U]: U[Q];
|
|
11
|
-
} : never;
|
|
12
|
-
}[keyof T];
|
|
13
|
-
type EventHandler = <T>(event: string, data: T) => void | Promise<void>;
|
|
14
|
-
type Visibility = 'private' | 'platform' | 'vendor' | 'public';
|
|
15
|
-
interface Tenant {
|
|
3
|
+
type Filter = Record<string, unknown>;
|
|
4
|
+
type Sorting$1 = Record<string, 'asc' | 'desc'>;
|
|
5
|
+
type GeneratedFields = {
|
|
16
6
|
id: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
interface AppId {
|
|
20
|
-
get name(): string;
|
|
21
|
-
get namespace(): Namespace;
|
|
22
|
-
toString(separator?: string): string;
|
|
23
|
-
}
|
|
24
|
-
declare const AppId: {
|
|
25
|
-
parse(input: string): AppId;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
updatedAt: number;
|
|
26
9
|
};
|
|
27
|
-
type
|
|
28
|
-
|
|
10
|
+
type ReservedKeys = keyof GeneratedFields;
|
|
11
|
+
type HydratedDocument<S extends EntitySchema<any>> = Omit<InferInterface<S>, ReservedKeys> & GeneratedFields;
|
|
12
|
+
type InsertDocument<S extends EntitySchema<any>> = Omit<InferInterface<S>, ReservedKeys> & Partial<GeneratedFields>;
|
|
13
|
+
type ScalarConstructor = StringConstructor | NumberConstructor | BooleanConstructor | DateConstructor;
|
|
14
|
+
type ArraySpec = readonly [FieldSpec];
|
|
15
|
+
type InnerSpec = ScalarConstructor | ArraySpec | SchemaDefinition;
|
|
16
|
+
type FieldSpec = InnerSpec | {
|
|
17
|
+
type: InnerSpec;
|
|
18
|
+
required?: boolean;
|
|
29
19
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
interface SchemaDefinition {
|
|
21
|
+
[key: string]: FieldSpec;
|
|
22
|
+
}
|
|
23
|
+
type ConstructorToType<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends DateConstructor ? number : never;
|
|
24
|
+
type IsRequired<F> = F extends {
|
|
25
|
+
required: true;
|
|
26
|
+
} ? true : false;
|
|
27
|
+
type RequiredKeys<Def extends SchemaDefinition> = {
|
|
28
|
+
[K in keyof Def]-?: IsRequired<Def[K]> extends true ? K : never;
|
|
29
|
+
}[keyof Def];
|
|
30
|
+
type OptionalKeys<Def extends SchemaDefinition> = Exclude<keyof Def, RequiredKeys<Def>>;
|
|
31
|
+
type InferInterface<S extends EntitySchema<any>> = InferSchema<S['definition']>;
|
|
32
|
+
type AssertNoReservedKeys<Def extends SchemaDefinition> = Extract<keyof Def, ReservedKeys> extends never ? Def : never;
|
|
33
|
+
type Unwrap<F> = F extends {
|
|
34
|
+
type: infer I;
|
|
35
|
+
} ? I : F;
|
|
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
|
+
type InferField<F extends FieldSpec> = InferInner<Unwrap<F>>;
|
|
38
|
+
type InferSchema<Def extends SchemaDefinition> = {
|
|
39
|
+
[K in RequiredKeys<Def>]: InferField<Def[K]>;
|
|
40
|
+
} & {
|
|
41
|
+
[K in OptionalKeys<Def>]?: InferField<Def[K]>;
|
|
36
42
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
interface Subject {
|
|
42
|
-
id: string;
|
|
43
|
-
email: string;
|
|
44
|
-
roles: string[];
|
|
43
|
+
|
|
44
|
+
declare class EntitySchema<Def extends SchemaDefinition = SchemaDefinition> {
|
|
45
|
+
readonly definition: Def;
|
|
46
|
+
constructor(definition: Def);
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
start: [];
|
|
51
|
-
install: [];
|
|
48
|
+
declare function entitySchema<const Def extends SchemaDefinition>(def: AssertNoReservedKeys<Def>): EntitySchema<Def>;
|
|
49
|
+
declare class CompiledSchema {
|
|
50
|
+
constructor(schema: EntitySchema);
|
|
51
|
+
get shape(): unknown;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
type InsertReturnMode = 'insertedIds' | 'documents';
|
|
55
|
-
type InsertReturnType<T extends Record
|
|
56
|
-
interface InsertQuery<T extends
|
|
55
|
+
type InsertReturnType<T extends object = Record<string, unknown>, R extends InsertReturnMode = 'insertedIds'> = R extends 'insertedIds' ? string[] : R extends 'documents' ? T[] : never;
|
|
56
|
+
interface InsertQuery<T extends object = Record<string, unknown>, R extends InsertReturnMode = 'insertedIds'> extends PromiseLike<InsertReturnType<T, R>> {
|
|
57
57
|
return(mode: 'insertedIds'): InsertQuery<T, 'insertedIds'>;
|
|
58
58
|
return(mode: 'documents'): InsertQuery<T, 'documents'>;
|
|
59
59
|
return(mode: InsertReturnMode): InsertQuery<T, typeof mode>;
|
|
60
60
|
}
|
|
61
61
|
type InsertOneReturnMode = 'insertedId' | 'document';
|
|
62
|
-
type InsertOneReturnType<T extends Record
|
|
63
|
-
interface InsertOneQuery<T extends
|
|
62
|
+
type InsertOneReturnType<T extends object = Record<string, unknown>, R extends InsertOneReturnMode = 'insertedId'> = R extends 'insertedId' ? string : R extends 'document' ? T : never;
|
|
63
|
+
interface InsertOneQuery<T extends object = Record<string, unknown>, R extends InsertOneReturnMode = 'insertedId'> extends PromiseLike<InsertOneReturnType<T, R>> {
|
|
64
64
|
return(mode: 'insertedId'): InsertOneQuery<T, 'insertedId'>;
|
|
65
65
|
return(mode: 'document'): InsertOneQuery<T, 'document'>;
|
|
66
66
|
return(mode: InsertOneReturnMode): InsertOneQuery<T, typeof mode>;
|
|
@@ -68,7 +68,7 @@ interface InsertOneQuery<T extends Record$1 = Record$1, R extends InsertOneRetur
|
|
|
68
68
|
|
|
69
69
|
type UpdateReturnMode = 'affectedRows' | 'oldDocuments' | 'newDocuments';
|
|
70
70
|
type UpdateReturnType<T, R extends UpdateReturnMode> = R extends 'affectedRows' ? bigint : R extends 'oldDocuments' | 'newDocuments' ? T[] : never;
|
|
71
|
-
interface UpdateQuery<T extends
|
|
71
|
+
interface UpdateQuery<T extends object = Record<string, unknown>, R extends UpdateReturnMode = 'affectedRows'> extends PromiseLike<UpdateReturnType<T, R>> {
|
|
72
72
|
limit(limit: number): this;
|
|
73
73
|
offset(offset: number): this;
|
|
74
74
|
sort(sort: Sorting): this;
|
|
@@ -79,7 +79,7 @@ interface UpdateQuery<T extends Record$1 = Record$1, R extends UpdateReturnMode
|
|
|
79
79
|
}
|
|
80
80
|
type UpdateOneReturnMode = 'success' | 'oldDocument' | 'newDocument';
|
|
81
81
|
type UpdateOneReturnType<T, R extends UpdateOneReturnMode> = R extends 'success' ? boolean : R extends 'oldDocument' | 'newDocument' ? T | undefined : never;
|
|
82
|
-
interface UpdateOneQuery<T extends
|
|
82
|
+
interface UpdateOneQuery<T extends object = Record<string, unknown>, R extends UpdateOneReturnMode = 'success'> extends PromiseLike<UpdateOneReturnType<T, R>> {
|
|
83
83
|
offset(offset: number): this;
|
|
84
84
|
sort(sort: Sorting): this;
|
|
85
85
|
upsert(upsert: boolean): this;
|
|
@@ -91,7 +91,7 @@ interface UpdateOneQuery<T extends Record$1 = Record$1, R extends UpdateOneRetur
|
|
|
91
91
|
|
|
92
92
|
type RemoveReturnMode = 'affectedRows' | 'documents';
|
|
93
93
|
type RemoveReturnType<T, R extends RemoveReturnMode> = R extends 'affectedRows' ? bigint : R extends 'documents' ? T[] : never;
|
|
94
|
-
interface RemoveQuery<T extends
|
|
94
|
+
interface RemoveQuery<T extends object = Record<string, unknown>, R extends RemoveReturnMode = 'affectedRows'> extends PromiseLike<RemoveReturnType<T, R>> {
|
|
95
95
|
limit(limit: number): this;
|
|
96
96
|
offset(offset: number): this;
|
|
97
97
|
sort(sort: Sorting): this;
|
|
@@ -101,7 +101,7 @@ interface RemoveQuery<T extends Record$1 = Record$1, R extends RemoveReturnMode
|
|
|
101
101
|
}
|
|
102
102
|
type RemoveOneReturnMode = 'success' | 'document';
|
|
103
103
|
type RemoveOneReturnType<T, R extends RemoveOneReturnMode> = R extends 'success' ? boolean : R extends 'document' ? T | undefined : never;
|
|
104
|
-
interface RemoveOneQuery<T extends
|
|
104
|
+
interface RemoveOneQuery<T extends object = Record<string, unknown>, R extends RemoveOneReturnMode = 'success'> extends PromiseLike<RemoveOneReturnType<T, R>> {
|
|
105
105
|
offset(offset: number): this;
|
|
106
106
|
sort(sort: Sorting): this;
|
|
107
107
|
return(mode: 'success'): RemoveOneQuery<T, 'success'>;
|
|
@@ -109,31 +109,79 @@ interface RemoveOneQuery<T extends Record$1 = Record$1, R extends RemoveOneRetur
|
|
|
109
109
|
return(mode: RemoveOneReturnMode): RemoveOneQuery<T, typeof mode>;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
interface Entity<T extends object = Record
|
|
112
|
+
interface Entity<T extends object = Record<string, unknown>> {
|
|
113
113
|
get name(): string;
|
|
114
|
-
find(
|
|
115
|
-
findOne(
|
|
114
|
+
find(filter?: Filter): FindQuery<T>;
|
|
115
|
+
findOne(filter?: Filter): FindOneQuery<T>;
|
|
116
116
|
insert(docs: T[]): InsertQuery<T>;
|
|
117
117
|
insertOne(doc: T): InsertOneQuery<T>;
|
|
118
|
-
update(
|
|
119
|
-
updateOne(
|
|
120
|
-
remove(
|
|
121
|
-
removeOne(
|
|
118
|
+
update(filter: Filter, update: Record<string, unknown>): UpdateQuery<T>;
|
|
119
|
+
updateOne(filter: Filter, update: Record<string, unknown>): UpdateOneQuery<T>;
|
|
120
|
+
remove(filter: Filter): RemoveQuery<T>;
|
|
121
|
+
removeOne(filter: Filter): RemoveOneQuery<T>;
|
|
122
122
|
}
|
|
123
123
|
interface Sorting {
|
|
124
124
|
[field: string]: 'asc' | 'desc';
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
interface FindQuery<T extends
|
|
127
|
+
interface FindQuery<T extends object = Record<string, unknown>> extends PromiseLike<T[]> {
|
|
128
128
|
limit(limit: number): this;
|
|
129
129
|
offset(offset: number): this;
|
|
130
130
|
sort(sort: Sorting): this;
|
|
131
131
|
}
|
|
132
|
-
interface FindOneQuery<T extends
|
|
132
|
+
interface FindOneQuery<T extends object = Record<string, unknown>> extends PromiseLike<T | undefined> {
|
|
133
133
|
offset(offset: number): this;
|
|
134
134
|
sort(sort: Sorting): this;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
type Variant<K extends PropertyKey, T extends object> = {
|
|
138
|
+
[P in keyof T]: {
|
|
139
|
+
[Q in K]: P;
|
|
140
|
+
} & T[P] extends infer U ? {
|
|
141
|
+
[Q in keyof U]: U[Q];
|
|
142
|
+
} : never;
|
|
143
|
+
}[keyof T];
|
|
144
|
+
type EventHandler = <T>(event: string, data: T) => void | Promise<void>;
|
|
145
|
+
type Visibility = 'private' | 'platform' | 'vendor' | 'public';
|
|
146
|
+
interface Tenant {
|
|
147
|
+
id: string;
|
|
148
|
+
host: string;
|
|
149
|
+
}
|
|
150
|
+
interface AppId {
|
|
151
|
+
get name(): string;
|
|
152
|
+
get namespace(): Namespace;
|
|
153
|
+
toString(separator?: string): string;
|
|
154
|
+
}
|
|
155
|
+
declare const AppId: {
|
|
156
|
+
parse(input: string): AppId;
|
|
157
|
+
};
|
|
158
|
+
type Namespace = 'system' | 'platform' | {
|
|
159
|
+
vendor: string;
|
|
160
|
+
};
|
|
161
|
+
type AppRole = Variant<'type', AppRoleData>;
|
|
162
|
+
type AppRoleData = {
|
|
163
|
+
provider: {
|
|
164
|
+
group: string;
|
|
165
|
+
};
|
|
166
|
+
test: void;
|
|
167
|
+
};
|
|
168
|
+
interface Auth {
|
|
169
|
+
subject: Subject;
|
|
170
|
+
permissions: Permissions;
|
|
171
|
+
}
|
|
172
|
+
interface Subject {
|
|
173
|
+
id: string;
|
|
174
|
+
email: string;
|
|
175
|
+
roles: string[];
|
|
176
|
+
}
|
|
177
|
+
interface Permissions {
|
|
178
|
+
[key: string]: string[];
|
|
179
|
+
}
|
|
180
|
+
interface HookEventMap {
|
|
181
|
+
start: [];
|
|
182
|
+
install: [];
|
|
183
|
+
}
|
|
184
|
+
|
|
137
185
|
interface Artifacts {
|
|
138
186
|
get<T>(key: string): T | undefined;
|
|
139
187
|
set<T>(key: string, value: T): void;
|
|
@@ -354,4 +402,4 @@ interface Bridge {
|
|
|
354
402
|
declare const logLevels: readonly ["trace", "debug", "info", "warn", "error", "none"];
|
|
355
403
|
type LogLevel = (typeof logLevels)[number];
|
|
356
404
|
|
|
357
|
-
export { type AppRole as A, type Bridge as B,
|
|
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 };
|