@based/functions 2.1.1 → 2.1.3
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/context.d.ts +3 -1
- package/dist/context.js.map +1 -1
- package/dist/functions.d.ts +4 -0
- package/dist/functions.js.map +1 -1
- package/package.json +1 -1
- package/src/context.ts +4 -1
- package/src/functions.ts +4 -0
package/dist/context.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type WebSocketSession = {
|
|
|
10
10
|
id: number;
|
|
11
11
|
method: string;
|
|
12
12
|
authState: AuthState;
|
|
13
|
+
origin: string;
|
|
13
14
|
obs: Set<number>;
|
|
14
15
|
unauthorizedObs?: Set<{
|
|
15
16
|
id: number;
|
|
@@ -32,6 +33,7 @@ export type BasedWebSocket = WebSocket<WebSocketSession>;
|
|
|
32
33
|
export type HttpSession = {
|
|
33
34
|
state?: any;
|
|
34
35
|
res: HttpResponse;
|
|
36
|
+
origin: string;
|
|
35
37
|
req: HttpRequest;
|
|
36
38
|
query?: string;
|
|
37
39
|
parsedQuery?: ReturnType<typeof parseQuery>;
|
|
@@ -40,7 +42,6 @@ export type HttpSession = {
|
|
|
40
42
|
id: number;
|
|
41
43
|
authState: AuthState;
|
|
42
44
|
method: string;
|
|
43
|
-
corsSend?: boolean;
|
|
44
45
|
rawBody?: string;
|
|
45
46
|
headers: {
|
|
46
47
|
'content-length'?: number;
|
|
@@ -83,6 +84,7 @@ export type MinimalExternalSession = {
|
|
|
83
84
|
};
|
|
84
85
|
};
|
|
85
86
|
export type Session = (WebSocketSession | HttpSession | InternalSession | MinimalExternalSession) & {
|
|
87
|
+
origin?: string;
|
|
86
88
|
/** Only available in Ws and Http contexts */
|
|
87
89
|
authState?: AuthState;
|
|
88
90
|
};
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AA0GO,MAAM,aAAa,GAAG,CAC3B,GAAqB,EACQ,EAAE;IAC/B,IAAI,KAAK,IAAI,GAAG,EAAE,OAAO,EAAE;QACzB,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAPY,QAAA,aAAa,iBAOzB;AAEM,MAAM,WAAW,GAAG,CACzB,GAAqB,EACa,EAAE;IACpC,IAAI,GAAG,CAAC,OAAO,IAAI,IAAA,mBAAW,EAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAC3C,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAPY,QAAA,WAAW,eAOvB;AAEM,MAAM,eAAe,GAAG,CAC7B,GAAqB,EAC2B,EAAE;IAClD,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,IAAA,mBAAW,EAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAA,qBAAa,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE;QAC3E,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAPY,QAAA,eAAe,mBAO3B;AAEM,MAAM,aAAa,GAAG,CAAC,OAAgB,EAA0B,EAAE;IACxE,IAAI,KAAK,IAAI,OAAO,EAAE;QACpB,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AALY,QAAA,aAAa,iBAKzB;AAEM,MAAM,WAAW,GAAG,CAAC,OAAgB,EAA+B,EAAE;IAC3E,IAAI,MAAM,IAAI,OAAO,EAAE;QACrB,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AALY,QAAA,WAAW,eAKvB"}
|
package/dist/functions.d.ts
CHANGED
|
@@ -113,6 +113,8 @@ type BasedChannelFunctionConfig = {
|
|
|
113
113
|
closeAfterIdleTime?: number;
|
|
114
114
|
/** Only for Publisher */
|
|
115
115
|
httpResponse?: HttpResponse;
|
|
116
|
+
/** Throttle amount of outgoing messages, in milliseconds */
|
|
117
|
+
throttle?: number;
|
|
116
118
|
};
|
|
117
119
|
type BasedCallFunctionConfig = {
|
|
118
120
|
/** Function type `channel, function, query, stream` */
|
|
@@ -127,6 +129,8 @@ type BasedQueryFunctionConfig = {
|
|
|
127
129
|
httpResponse?: HttpResponse;
|
|
128
130
|
/** How long should the query function remain active after all subscribers are gone, in ms */
|
|
129
131
|
closeAfterIdleTime?: number;
|
|
132
|
+
/** Throttle amount of outgoing messages, in milliseconds */
|
|
133
|
+
throttle?: number;
|
|
130
134
|
};
|
|
131
135
|
type BasedStreamFunctionConfig = {
|
|
132
136
|
/** Function type `channel, function, query, stream` */
|
package/dist/functions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;AA2QA,SAAgB,YAAY,CAC1B,IAAO,EACP,KAAU;IAEV,OAAO,CACL,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,IAAI,KAAK,IAAI;QACnB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAC/B,CAAA;AACH,CAAC;AAVD,oCAUC;AAED,SAAgB,eAAe,CAAC,KAAU;IACxC,OAAO,CACL,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;YACvB,KAAK,CAAC,IAAI,KAAK,OAAO;YACtB,KAAK,CAAC,IAAI,KAAK,UAAU;YACzB,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;QAC1B,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAC/B,CAAA;AACH,CAAC;AAVD,0CAUC;AAED,SAAgB,qBAAqB,CACnC,IAAO,EACP,MAAW;IAEX,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AACnC,CAAC;AALD,sDAKC;AAED,SAAgB,wBAAwB,CACtC,MAAW;IAEX,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC;AAJD,4DAIC"}
|
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type WebSocketSession = {
|
|
|
12
12
|
id: number // client-id
|
|
13
13
|
method: string
|
|
14
14
|
authState: AuthState
|
|
15
|
+
origin: string
|
|
15
16
|
obs: Set<number>
|
|
16
17
|
unauthorizedObs?: Set<{
|
|
17
18
|
id: number
|
|
@@ -36,6 +37,7 @@ export type HttpSession = {
|
|
|
36
37
|
// State can be used for anything - for us the based class instance
|
|
37
38
|
state?: any
|
|
38
39
|
res: HttpResponse
|
|
40
|
+
origin: string
|
|
39
41
|
req: HttpRequest
|
|
40
42
|
query?: string
|
|
41
43
|
parsedQuery?: ReturnType<typeof parseQuery>
|
|
@@ -44,7 +46,6 @@ export type HttpSession = {
|
|
|
44
46
|
id: number // client-id
|
|
45
47
|
authState: AuthState
|
|
46
48
|
method: string
|
|
47
|
-
corsSend?: boolean
|
|
48
49
|
rawBody?: string
|
|
49
50
|
headers: {
|
|
50
51
|
'content-length'?: number
|
|
@@ -93,6 +94,8 @@ export type Session = (
|
|
|
93
94
|
| InternalSession
|
|
94
95
|
| MinimalExternalSession
|
|
95
96
|
) & {
|
|
97
|
+
origin?: string
|
|
98
|
+
|
|
96
99
|
/** Only available in Ws and Http contexts */
|
|
97
100
|
authState?: AuthState
|
|
98
101
|
}
|
package/src/functions.ts
CHANGED
|
@@ -187,6 +187,8 @@ type BasedChannelFunctionConfig = {
|
|
|
187
187
|
closeAfterIdleTime?: number
|
|
188
188
|
/** Only for Publisher */
|
|
189
189
|
httpResponse?: HttpResponse
|
|
190
|
+
/** Throttle amount of outgoing messages, in milliseconds */
|
|
191
|
+
throttle?: number
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
type BasedCallFunctionConfig = {
|
|
@@ -203,6 +205,8 @@ type BasedQueryFunctionConfig = {
|
|
|
203
205
|
httpResponse?: HttpResponse
|
|
204
206
|
/** How long should the query function remain active after all subscribers are gone, in ms */
|
|
205
207
|
closeAfterIdleTime?: number
|
|
208
|
+
/** Throttle amount of outgoing messages, in milliseconds */
|
|
209
|
+
throttle?: number
|
|
206
210
|
}
|
|
207
211
|
|
|
208
212
|
type BasedStreamFunctionConfig = {
|