@based/functions
Advanced tools
Comparing version 2.3.0 to 3.0.0
@@ -1,4 +0,4 @@ | ||
import { BasedFunctionClient } from './client'; | ||
import { HttpRequest } from './uws'; | ||
import { Context, WebSocketSession, HttpSession } from './context'; | ||
import { BasedFunctionClient } from './client.js'; | ||
import { HttpRequest } from './uws.js'; | ||
import { Context, WebSocketSession, HttpSession } from './context.js'; | ||
export type AuthState = { | ||
@@ -16,2 +16,1 @@ token?: string; | ||
export type AuthorizeConnection = (based: BasedFunctionClient, req: HttpRequest, ip: string) => Promise<boolean>; | ||
//# sourceMappingURL=auth.d.ts.map |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=auth.js.map |
@@ -1,2 +0,2 @@ | ||
import { ChannelMessageFunction } from './functions'; | ||
import { ChannelMessageFunction } from './functions.js'; | ||
export declare abstract class BasedChannel<K = any> { | ||
@@ -6,2 +6,1 @@ abstract subscribe(onMessage: ChannelMessageFunction<K>, onError?: (err: any) => void): () => void; | ||
} | ||
//# sourceMappingURL=channel.d.ts.map |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BasedChannel = void 0; | ||
class BasedChannel { | ||
export class BasedChannel { | ||
} | ||
exports.BasedChannel = BasedChannel; | ||
//# sourceMappingURL=channel.js.map |
@@ -1,7 +0,7 @@ | ||
import { AuthState } from './auth'; | ||
import { BasedChannel } from './channel'; | ||
import { Context } from './context'; | ||
import { BasedQuery } from './query'; | ||
import { StreamFunctionOpts } from './stream'; | ||
import { Geo } from './geo'; | ||
import { AuthState } from './auth.js'; | ||
import { BasedChannel } from './channel.js'; | ||
import { Context } from './context.js'; | ||
import { BasedQuery } from './query.js'; | ||
import { StreamFunctionOpts } from './stream.js'; | ||
import { Geo } from './geo.js'; | ||
export declare abstract class BasedFunctionClient { | ||
@@ -24,2 +24,1 @@ server: any; | ||
}; | ||
//# sourceMappingURL=client.d.ts.map |
@@ -1,7 +0,7 @@ | ||
import { AuthState } from './auth'; | ||
import { BasedChannel } from './channel'; | ||
import { Context } from './context'; | ||
import { BasedQuery } from './query'; | ||
import { StreamFunctionOpts } from './stream'; | ||
import { Geo } from './geo'; | ||
import { AuthState } from './auth.js'; | ||
import { BasedChannel } from './channel.js'; | ||
import { Context } from './context.js'; | ||
import { BasedQuery } from './query.js'; | ||
import { StreamFunctionOpts } from './stream.js'; | ||
import { Geo } from './geo.js'; | ||
export declare abstract class BasedFunctionClient { | ||
@@ -24,2 +24,1 @@ server: any; | ||
}; | ||
//# sourceMappingURL=client.d.ts.map |
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BasedFunctionClient = void 0; | ||
class BasedFunctionClient { | ||
export class BasedFunctionClient { | ||
server; | ||
db; | ||
} | ||
exports.BasedFunctionClient = BasedFunctionClient; | ||
//# sourceMappingURL=client.js.map |
@@ -1,5 +0,5 @@ | ||
import { AuthState } from './auth'; | ||
import { WebSocket, HttpRequest, HttpResponse } from './uws'; | ||
import { parseQuery } from '@saulx/utils'; | ||
import { BasedFunctionClient } from './client'; | ||
import { AuthState } from './auth.js'; | ||
import { WebSocket, HttpRequest, HttpResponse } from './uws.js'; | ||
import { BasedFunctionClient } from './client.js'; | ||
export type WebSocketSession = { | ||
@@ -100,2 +100,1 @@ state?: any; | ||
export declare const isWsSession: (session: Session | undefined) => session is WebSocketSession; | ||
//# sourceMappingURL=context.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isWsSession = exports.isHttpSession = exports.isClientContext = exports.isWsContext = exports.isHttpContext = void 0; | ||
const isHttpContext = (ctx) => { | ||
export const isHttpContext = (ctx) => { | ||
if ('res' in ctx?.session) { | ||
@@ -10,5 +7,4 @@ return true; | ||
}; | ||
exports.isHttpContext = isHttpContext; | ||
const isWsContext = (ctx) => { | ||
if (ctx.session && (0, exports.isWsSession)(ctx.session)) { | ||
export const isWsContext = (ctx) => { | ||
if (ctx.session && isWsSession(ctx.session)) { | ||
return true; | ||
@@ -18,5 +14,4 @@ } | ||
}; | ||
exports.isWsContext = isWsContext; | ||
const isClientContext = (ctx) => { | ||
if (ctx.session && ((0, exports.isWsSession)(ctx.session) || (0, exports.isHttpSession)(ctx.session))) { | ||
export const isClientContext = (ctx) => { | ||
if (ctx.session && (isWsSession(ctx.session) || isHttpSession(ctx.session))) { | ||
return true; | ||
@@ -26,4 +21,3 @@ } | ||
}; | ||
exports.isClientContext = isClientContext; | ||
const isHttpSession = (session) => { | ||
export const isHttpSession = (session) => { | ||
if (session && 'res' in session) { | ||
@@ -34,4 +28,3 @@ return true; | ||
}; | ||
exports.isHttpSession = isHttpSession; | ||
const isWsSession = (session) => { | ||
export const isWsSession = (session) => { | ||
if (session && 'send' in session) { | ||
@@ -42,3 +35,2 @@ return true; | ||
}; | ||
exports.isWsSession = isWsSession; | ||
//# sourceMappingURL=context.js.map |
@@ -1,6 +0,6 @@ | ||
import { Context, HttpSession } from './context'; | ||
import { BasedFunctionClient } from './client'; | ||
import { BasedDataStream } from './stream'; | ||
import { Authorize } from './auth'; | ||
import type { Required } from 'utility-types'; | ||
import { Context, HttpSession } from './context.js'; | ||
import { BasedFunctionClient } from './client.js'; | ||
import { BasedDataStream } from './stream.js'; | ||
import { Authorize } from './auth.js'; | ||
export type ObservableUpdateFunction<K = any> = (data: K, checksum?: number, err?: any, cache?: Uint8Array, diff?: any, fromChecksum?: number, isDeflate?: boolean) => void; | ||
@@ -186,2 +186,1 @@ export type ObserveErrorListener = (err: any) => void; | ||
export {}; | ||
//# sourceMappingURL=functions.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isAnyBasedFunctionConfig = exports.isBasedFunctionConfig = exports.isAnyBasedRoute = exports.isBasedRoute = void 0; | ||
function isBasedRoute(type, route) { | ||
export function isBasedRoute(type, route) { | ||
return (route && | ||
@@ -10,4 +7,3 @@ typeof route === 'object' && | ||
} | ||
exports.isBasedRoute = isBasedRoute; | ||
function isAnyBasedRoute(route) { | ||
export function isAnyBasedRoute(route) { | ||
return (route && | ||
@@ -21,11 +17,8 @@ typeof route === 'object' && | ||
} | ||
exports.isAnyBasedRoute = isAnyBasedRoute; | ||
function isBasedFunctionConfig(type, config) { | ||
export function isBasedFunctionConfig(type, config) { | ||
return isBasedRoute(type, config); | ||
} | ||
exports.isBasedFunctionConfig = isBasedFunctionConfig; | ||
function isAnyBasedFunctionConfig(config) { | ||
export function isAnyBasedFunctionConfig(config) { | ||
return isAnyBasedRoute(config); | ||
} | ||
exports.isAnyBasedFunctionConfig = isAnyBasedFunctionConfig; | ||
//# sourceMappingURL=functions.js.map |
@@ -36,2 +36,1 @@ export type CountryCode = 'AF' | 'AL' | 'DZ' | 'AS' | 'AD' | 'AO' | 'AI' | 'AQ' | 'AG' | 'AR' | 'AM' | 'AW' | 'AU' | 'AT' | 'AZ' | 'BS' | 'BH' | 'BD' | 'BB' | 'BY' | 'BE' | 'BZ' | 'BJ' | 'BM' | 'BT' | 'BO' | 'BQ' | 'BA' | 'BW' | 'BV' | 'BR' | 'IO' | 'BN' | 'BG' | 'BF' | 'BI' | 'KH' | 'CM' | 'CA' | 'CV' | 'KY' | 'CF' | 'TD' | 'CL' | 'CN' | 'CX' | 'CC' | 'CO' | 'KM' | 'CG' | 'CD' | 'CK' | 'CR' | 'HR' | 'CU' | 'CW' | 'CY' | 'CZ' | 'CI' | 'DK' | 'DJ' | 'DM' | 'DO' | 'EC' | 'EG' | 'SV' | 'GQ' | 'ER' | 'EE' | 'ET' | 'FK' | 'FO' | 'FJ' | 'FI' | 'FR' | 'GF' | 'PF' | 'TF' | 'GA' | 'GM' | 'GE' | 'DE' | 'GH' | 'GI' | 'GR' | 'GL' | 'GD' | 'GP' | 'GU' | 'GT' | 'GG' | 'GN' | 'GW' | 'GY' | 'HT' | 'HM' | 'VA' | 'HN' | 'HK' | 'HU' | 'IS' | 'IN' | 'ID' | 'IR' | 'IQ' | 'IE' | 'IM' | 'IL' | 'IT' | 'JM' | 'JP' | 'JE' | 'JO' | 'KZ' | 'KE' | 'KI' | 'KP' | 'KR' | 'KW' | 'KG' | 'LA' | 'LV' | 'LB' | 'LS' | 'LR' | 'LY' | 'LI' | 'LT' | 'LU' | 'MO' | 'MK' | 'MG' | 'MW' | 'MY' | 'MV' | 'ML' | 'MT' | 'MH' | 'MQ' | 'MR' | 'MU' | 'YT' | 'MX' | 'FM' | 'MD' | 'MC' | 'MN' | 'ME' | 'MS' | 'MA' | 'MZ' | 'MM' | 'NA' | 'NR' | 'NP' | 'NL' | 'NC' | 'NZ' | 'NI' | 'NE' | 'NG' | 'NU' | 'NF' | 'MP' | 'NO' | 'OM' | 'PK' | 'PW' | 'PS' | 'PA' | 'PG' | 'PY' | 'PE' | 'PH' | 'PN' | 'PL' | 'PT' | 'PR' | 'QA' | 'RO' | 'RU' | 'RW' | 'RE' | 'BL' | 'SH' | 'KN' | 'LC' | 'MF' | 'PM' | 'VC' | 'WS' | 'SM' | 'ST' | 'SA' | 'SN' | 'RS' | 'SC' | 'SL' | 'SG' | 'SX' | 'SK' | 'SI' | 'SB' | 'SO' | 'ZA' | 'GS' | 'SS' | 'ES' | 'LK' | 'SD' | 'SR' | 'SJ' | 'SZ' | 'SE' | 'CH' | 'SY' | 'TW' | 'TJ' | 'TZ' | 'TH' | 'TL' | 'TG' | 'TK' | 'TO' | 'TT' | 'TN' | 'TR' | 'TM' | 'TC' | 'TV' | 'UG' | 'UA' | 'AE' | 'GB' | 'US' | 'UM' | 'UY' | 'UZ' | 'VU' | 'VE' | 'VN' | 'VG' | 'VI' | 'WF' | 'EH' | 'YE' | 'ZM' | 'ZW' | 'AX'; | ||
export {}; | ||
//# sourceMappingURL=geo.d.ts.map |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=geo.js.map |
@@ -1,9 +0,8 @@ | ||
export * from './context'; | ||
export * from './auth'; | ||
export * from './client'; | ||
export * from './functions'; | ||
export * from './query'; | ||
export * from './stream'; | ||
export * from './channel'; | ||
export * from './geo'; | ||
//# sourceMappingURL=index.d.ts.map | ||
export * from './context.js'; | ||
export * from './auth.js'; | ||
export * from './client.js'; | ||
export * from './functions.js'; | ||
export * from './query.js'; | ||
export * from './stream.js'; | ||
export * from './channel.js'; | ||
export * from './geo.js'; |
@@ -1,25 +0,9 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./context"), exports); | ||
__exportStar(require("./auth"), exports); | ||
__exportStar(require("./client"), exports); | ||
__exportStar(require("./functions"), exports); | ||
__exportStar(require("./query"), exports); | ||
__exportStar(require("./stream"), exports); | ||
__exportStar(require("./channel"), exports); | ||
__exportStar(require("./geo"), exports); | ||
export * from './context.js'; | ||
export * from './auth.js'; | ||
export * from './client.js'; | ||
export * from './functions.js'; | ||
export * from './query.js'; | ||
export * from './stream.js'; | ||
export * from './channel.js'; | ||
export * from './geo.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { ObservableUpdateFunction, ObserveErrorListener } from './functions'; | ||
import { ObservableUpdateFunction, ObserveErrorListener } from './functions.js'; | ||
export declare abstract class BasedQuery<K = any> { | ||
@@ -7,2 +7,1 @@ abstract subscribe(onData: ObservableUpdateFunction<K>, onError?: ObserveErrorListener): () => void; | ||
} | ||
//# sourceMappingURL=query.d.ts.map |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BasedQuery = void 0; | ||
class BasedQuery { | ||
export class BasedQuery { | ||
} | ||
exports.BasedQuery = BasedQuery; | ||
//# sourceMappingURL=query.js.map |
@@ -1,5 +0,5 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { Duplex, Readable } from 'stream'; | ||
@@ -40,2 +40,1 @@ import util from 'node:util'; | ||
export declare const isStreamFunctionOpts: (opts: StreamFunctionContents | StreamFunctionStream) => opts is StreamFunctionStream; | ||
//# sourceMappingURL=stream.d.ts.map |
@@ -1,15 +0,10 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isStreamFunctionOpts = exports.BasedDataStream = void 0; | ||
const stream_1 = require("stream"); | ||
const node_util_1 = __importDefault(require("node:util")); | ||
import { Duplex, Readable } from 'stream'; | ||
import util from 'node:util'; | ||
// prob want to move this to based functions | ||
class BasedDataStream extends stream_1.Duplex { | ||
export class BasedDataStream extends Duplex { | ||
size = 0; | ||
receivedBytes = 0; | ||
progessTimer; | ||
constructor(size) { | ||
super(); | ||
this.size = 0; | ||
this.receivedBytes = 0; | ||
this.size = size; | ||
@@ -45,3 +40,3 @@ this.emit('progress', 0); | ||
} | ||
[node_util_1.default.inspect.custom]() { | ||
[util.inspect.custom]() { | ||
if (this.size) { | ||
@@ -59,7 +54,5 @@ const rb = this.receivedBytes < 1000 | ||
} | ||
exports.BasedDataStream = BasedDataStream; | ||
const isStreamFunctionOpts = (opts) => { | ||
return opts.contents instanceof stream_1.Duplex || opts.contents instanceof stream_1.Readable; | ||
export const isStreamFunctionOpts = (opts) => { | ||
return opts.contents instanceof Duplex || opts.contents instanceof Readable; | ||
}; | ||
exports.isStreamFunctionOpts = isStreamFunctionOpts; | ||
//# sourceMappingURL=stream.js.map |
{ | ||
"name": "@based/functions", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"license": "MIT", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
@@ -14,3 +15,3 @@ "scripts": { | ||
"utility-types": "^3.10.0", | ||
"@saulx/utils": "^3.5.0" | ||
"@saulx/utils": "^4.1.0" | ||
}, | ||
@@ -17,0 +18,0 @@ "devDependencies": { |
@@ -1,4 +0,4 @@ | ||
import { BasedFunctionClient } from './client' | ||
import { HttpRequest } from './uws' | ||
import { Context, WebSocketSession, HttpSession } from './context' | ||
import { BasedFunctionClient } from './client.js' | ||
import { HttpRequest } from './uws.js' | ||
import { Context, WebSocketSession, HttpSession } from './context.js' | ||
@@ -5,0 +5,0 @@ export type AuthState = { |
@@ -1,2 +0,2 @@ | ||
import { ChannelMessageFunction } from './functions' | ||
import { ChannelMessageFunction } from './functions.js' | ||
@@ -3,0 +3,0 @@ export abstract class BasedChannel<K = any> { |
@@ -1,7 +0,7 @@ | ||
import { AuthState } from './auth' | ||
import { BasedChannel } from './channel' | ||
import { Context } from './context' | ||
import { BasedQuery } from './query' | ||
import { StreamFunctionOpts } from './stream' | ||
import { Geo } from './geo' | ||
import { AuthState } from './auth.js' | ||
import { BasedChannel } from './channel.js' | ||
import { Context } from './context.js' | ||
import { BasedQuery } from './query.js' | ||
import { StreamFunctionOpts } from './stream.js' | ||
import { Geo } from './geo.js' | ||
@@ -8,0 +8,0 @@ export abstract class BasedFunctionClient { |
@@ -1,5 +0,5 @@ | ||
import { AuthState } from './auth' | ||
import { WebSocket, HttpRequest, HttpResponse } from './uws' | ||
import { parseQuery } from '@saulx/utils' | ||
import { BasedFunctionClient } from './client' | ||
import { AuthState } from './auth.js' | ||
import { WebSocket, HttpRequest, HttpResponse } from './uws.js' | ||
import { BasedFunctionClient } from './client.js' | ||
@@ -6,0 +6,0 @@ export type WebSocketSession = { |
@@ -1,6 +0,6 @@ | ||
import { Context, HttpSession } from './context' | ||
import { BasedFunctionClient } from './client' | ||
import { BasedDataStream } from './stream' | ||
import { Authorize } from './auth' | ||
import type { Required } from 'utility-types' | ||
import { Context, HttpSession } from './context.js' | ||
import { BasedFunctionClient } from './client.js' | ||
import { BasedDataStream } from './stream.js' | ||
import { Authorize } from './auth.js' | ||
@@ -7,0 +7,0 @@ export type ObservableUpdateFunction<K = any> = ( |
@@ -1,8 +0,8 @@ | ||
export * from './context' | ||
export * from './auth' | ||
export * from './client' | ||
export * from './functions' | ||
export * from './query' | ||
export * from './stream' | ||
export * from './channel' | ||
export * from './geo' | ||
export * from './context.js' | ||
export * from './auth.js' | ||
export * from './client.js' | ||
export * from './functions.js' | ||
export * from './query.js' | ||
export * from './stream.js' | ||
export * from './channel.js' | ||
export * from './geo.js' |
@@ -1,2 +0,2 @@ | ||
import { ObservableUpdateFunction, ObserveErrorListener } from './functions' | ||
import { ObservableUpdateFunction, ObserveErrorListener } from './functions.js' | ||
@@ -3,0 +3,0 @@ export abstract class BasedQuery<K = any> { |
@@ -16,5 +16,5 @@ import { Duplex, Readable } from 'stream' | ||
_read() {} | ||
override _read() {} | ||
_write(chunk, encoding, callback) { | ||
override _write(chunk, encoding, callback) { | ||
this.receivedBytes += chunk.byteLength | ||
@@ -34,3 +34,3 @@ if (this.size && this.size > 20000) { | ||
_final() { | ||
override _final() { | ||
if (!this.size) { | ||
@@ -37,0 +37,0 @@ this.size = this.receivedBytes |
{ | ||
"extends": "../../tsconfig.json", | ||
"extends": "@saulx/tsconfig/default.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"declarationMap": true | ||
"esModuleInterop": true, | ||
"allowJs": true, | ||
"noPropertyAccessFromIndexSignature": false | ||
}, | ||
"include": ["src/**/*", "src/**/*.json"], | ||
"exclude": ["node_modules", "test", "dist", "tmp", "examples"] | ||
"include": ["./src"], | ||
"exclude": ["./dist"] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Yes
93489
42
2366
+ Added@saulx/hash@3.0.0(transitive)
+ Added@saulx/utils@4.3.2(transitive)
- Removed@saulx/hash@2.0.0(transitive)
- Removed@saulx/utils@3.5.3(transitive)
- Removedis-plain-obj@3.0.0(transitive)
Updated@saulx/utils@^4.1.0