speexjs 0.3.0 → 0.5.0
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/cli/index.js +52 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/{index-CMkhSDh7.d.ts → index-C4xilc_E.d.ts} +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2706 -2344
- package/dist/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +2 -1
- package/dist/server/cache/index.d.ts +2 -1
- package/dist/server/controller/index.d.ts +2 -1
- package/dist/server/database/index.d.ts +14 -2
- package/dist/server/database/index.js +123 -15
- package/dist/server/database/index.js.map +1 -1
- package/dist/server/gate/index.d.ts +2 -1
- package/dist/server/index.d.ts +56 -3
- package/dist/server/index.js +1940 -1578
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware/index.d.ts +2 -1
- package/dist/server/middleware/index.js +32 -1
- package/dist/server/middleware/index.js.map +1 -1
- package/dist/server/router/index.d.ts +2 -1
- package/dist/server/router/index.js.map +1 -1
- package/package.json +143 -141
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { A as AuthUser, S as SessionGuard } from '../../session-guard-CZeN87L9.js';
|
|
2
2
|
export { a as SessionGuardConfig, U as UserProvider } from '../../session-guard-CZeN87L9.js';
|
|
3
|
-
import { M as Middleware } from '../../index-
|
|
3
|
+
import { M as Middleware } from '../../index-C4xilc_E.js';
|
|
4
4
|
import '../../response-Ca8KWK5_.js';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import 'node:stream';
|
|
7
7
|
import '../container/index.js';
|
|
8
|
+
import '../../types-aW38f63o.js';
|
|
8
9
|
|
|
9
10
|
interface TokenProvider {
|
|
10
11
|
create(userId: string | number, tokenHash: string, name?: string, abilities?: string[]): Promise<void>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { M as Middleware } from '../../index-
|
|
1
|
+
import { M as Middleware } from '../../index-C4xilc_E.js';
|
|
2
2
|
import '../container/index.js';
|
|
3
3
|
import '../../response-Ca8KWK5_.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
import 'node:stream';
|
|
6
|
+
import '../../types-aW38f63o.js';
|
|
6
7
|
|
|
7
8
|
interface CacheConfig {
|
|
8
9
|
store?: "memory" | "file";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { R as RouteContext } from '../../index-
|
|
1
|
+
import { R as RouteContext } from '../../index-C4xilc_E.js';
|
|
2
2
|
import { Container } from '../container/index.js';
|
|
3
3
|
import { S as SuperRequest, a as SuperResponse, b as Schema } from '../../response-Ca8KWK5_.js';
|
|
4
|
+
import '../../types-aW38f63o.js';
|
|
4
5
|
import 'node:http';
|
|
5
6
|
import 'node:stream';
|
|
6
7
|
|
|
@@ -459,12 +459,25 @@ declare class Seeder {
|
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
declare class Model {
|
|
462
|
+
/** Primary key */
|
|
462
463
|
id?: number | string;
|
|
464
|
+
/** Dynamic properties from database */
|
|
465
|
+
[key: string]: unknown;
|
|
463
466
|
static table: string;
|
|
464
467
|
static connection: QueryRunner | null;
|
|
465
468
|
protected static queryRunner: QueryRunner | null;
|
|
469
|
+
private static relationDefs;
|
|
470
|
+
private static eagerLoads;
|
|
471
|
+
/** @internal cache for loaded relations on instances */
|
|
472
|
+
_relations: Record<string, unknown>;
|
|
466
473
|
static setConnection(conn: QueryRunner): void;
|
|
467
474
|
static query<T extends typeof Model>(this: T): QueryBuilder;
|
|
475
|
+
static hasOne(relatedModel: typeof Model, foreignKey?: string, localKey?: string): void;
|
|
476
|
+
static hasMany(relatedModel: typeof Model, foreignKey?: string, localKey?: string): void;
|
|
477
|
+
static belongsTo(relatedModel: typeof Model, foreignKey?: string, ownerKey?: string): void;
|
|
478
|
+
static belongsToMany(relatedModel: typeof Model, pivotTable?: string, foreignPivotKey?: string, relatedPivotKey?: string): void;
|
|
479
|
+
static morphMany(relatedModel: typeof Model, morphName: string): void;
|
|
480
|
+
static with(...relations: string[]): void;
|
|
468
481
|
static all<T extends typeof Model>(this: T): Promise<InstanceType<T>[]>;
|
|
469
482
|
static find<T extends typeof Model>(this: T, id: number | string): Promise<InstanceType<T> | null>;
|
|
470
483
|
static where<T extends typeof Model>(this: T, column: string, value: any): Promise<QueryBuilder>;
|
|
@@ -472,8 +485,7 @@ declare class Model {
|
|
|
472
485
|
static updateOrCreate<T extends typeof Model>(this: T, attributes: Record<string, any>, values?: Record<string, any>): Promise<InstanceType<T>>;
|
|
473
486
|
save(): Promise<void>;
|
|
474
487
|
delete(): Promise<void>;
|
|
475
|
-
static
|
|
476
|
-
static hasMany<T extends typeof Model>(this: T, relatedModel: typeof Model, foreignKey?: string, localKey?: string): any;
|
|
488
|
+
private static loadRelations;
|
|
477
489
|
private static hydrate;
|
|
478
490
|
private getData;
|
|
479
491
|
}
|
|
@@ -2813,10 +2813,15 @@ var Seeder = class {
|
|
|
2813
2813
|
|
|
2814
2814
|
// src/server/database/model.ts
|
|
2815
2815
|
var Model = class {
|
|
2816
|
+
/** Primary key */
|
|
2816
2817
|
id;
|
|
2817
2818
|
static table = "";
|
|
2818
2819
|
static connection = null;
|
|
2819
2820
|
static queryRunner = null;
|
|
2821
|
+
static relationDefs = /* @__PURE__ */ new Map();
|
|
2822
|
+
static eagerLoads = /* @__PURE__ */ new Map();
|
|
2823
|
+
/** @internal cache for loaded relations on instances */
|
|
2824
|
+
_relations = {};
|
|
2820
2825
|
static setConnection(conn) {
|
|
2821
2826
|
this.connection = conn;
|
|
2822
2827
|
this.queryRunner = conn;
|
|
@@ -2827,14 +2832,74 @@ var Model = class {
|
|
|
2827
2832
|
}
|
|
2828
2833
|
return new QueryBuilder(this.queryRunner, this.table);
|
|
2829
2834
|
}
|
|
2835
|
+
// ─── Relations Definition ──────────────────────────────────
|
|
2836
|
+
static hasOne(relatedModel, foreignKey, localKey) {
|
|
2837
|
+
const key = `hasOne:${relatedModel.table}`;
|
|
2838
|
+
this.relationDefs.set(key, {
|
|
2839
|
+
type: "hasOne",
|
|
2840
|
+
relatedModel,
|
|
2841
|
+
foreignKey: foreignKey ?? `${this.table}_id`,
|
|
2842
|
+
localKey: localKey ?? "id"
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
static hasMany(relatedModel, foreignKey, localKey) {
|
|
2846
|
+
const key = `hasMany:${relatedModel.table}`;
|
|
2847
|
+
this.relationDefs.set(key, {
|
|
2848
|
+
type: "hasMany",
|
|
2849
|
+
relatedModel,
|
|
2850
|
+
foreignKey: foreignKey ?? `${this.table}_id`,
|
|
2851
|
+
localKey: localKey ?? "id"
|
|
2852
|
+
});
|
|
2853
|
+
}
|
|
2854
|
+
static belongsTo(relatedModel, foreignKey, ownerKey) {
|
|
2855
|
+
const key = `belongsTo:${relatedModel.table}`;
|
|
2856
|
+
this.relationDefs.set(key, {
|
|
2857
|
+
type: "belongsTo",
|
|
2858
|
+
relatedModel,
|
|
2859
|
+
foreignKey: foreignKey ?? `${relatedModel.table}_id`,
|
|
2860
|
+
localKey: ownerKey ?? "id"
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
static belongsToMany(relatedModel, pivotTable, foreignPivotKey, relatedPivotKey) {
|
|
2864
|
+
const tables = [this.table, relatedModel.table].sort();
|
|
2865
|
+
const key = `belongsToMany:${relatedModel.table}`;
|
|
2866
|
+
this.relationDefs.set(key, {
|
|
2867
|
+
type: "belongsToMany",
|
|
2868
|
+
relatedModel,
|
|
2869
|
+
foreignKey: foreignPivotKey ?? `${this.table}_id`,
|
|
2870
|
+
localKey: relatedPivotKey ?? `${relatedModel.table}_id`,
|
|
2871
|
+
pivotTable: pivotTable ?? `${tables[0]}_${tables[1]}`
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
static morphMany(relatedModel, morphName) {
|
|
2875
|
+
const key = `morphMany:${morphName}`;
|
|
2876
|
+
this.relationDefs.set(key, {
|
|
2877
|
+
type: "morphMany",
|
|
2878
|
+
relatedModel,
|
|
2879
|
+
foreignKey: `${morphName}_id`,
|
|
2880
|
+
localKey: "id",
|
|
2881
|
+
morphName
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
// ─── Eager Loading ─────────────────────────────────────────
|
|
2885
|
+
static with(...relations) {
|
|
2886
|
+
for (const rel of relations) {
|
|
2887
|
+
this.eagerLoads.set(rel, true);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
// ─── Query Shortcuts ───────────────────────────────────────
|
|
2830
2891
|
static async all() {
|
|
2831
2892
|
const rows = await this.query().get();
|
|
2832
|
-
|
|
2893
|
+
const instances = rows.map((row) => this.hydrate(row));
|
|
2894
|
+
await this.loadRelations(instances);
|
|
2895
|
+
return instances;
|
|
2833
2896
|
}
|
|
2834
2897
|
static async find(id) {
|
|
2835
2898
|
const row = await this.query().find(id);
|
|
2836
2899
|
if (!row) return null;
|
|
2837
|
-
|
|
2900
|
+
const instance = this.hydrate(row);
|
|
2901
|
+
await this.loadRelations([instance]);
|
|
2902
|
+
return instance;
|
|
2838
2903
|
}
|
|
2839
2904
|
static async where(column, value) {
|
|
2840
2905
|
return this.query().where(column, value);
|
|
@@ -2861,6 +2926,7 @@ var Model = class {
|
|
|
2861
2926
|
}
|
|
2862
2927
|
return this.create({ ...attributes, ...values });
|
|
2863
2928
|
}
|
|
2929
|
+
// ─── Instance Methods ──────────────────────────────────────
|
|
2864
2930
|
async save() {
|
|
2865
2931
|
const ModelClass = this.constructor;
|
|
2866
2932
|
const id = this.id;
|
|
@@ -2878,22 +2944,64 @@ var Model = class {
|
|
|
2878
2944
|
await ModelClass.query().where("id", id).delete();
|
|
2879
2945
|
}
|
|
2880
2946
|
}
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
const
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2947
|
+
// ─── Relation Loader ───────────────────────────────────────
|
|
2948
|
+
static async loadRelations(instances) {
|
|
2949
|
+
if (instances.length === 0) return;
|
|
2950
|
+
for (const [key, def] of this.relationDefs) {
|
|
2951
|
+
const shouldLoad = this.eagerLoads.size === 0 || this.eagerLoads.has(key.split(":")[1] ?? key);
|
|
2952
|
+
if (!shouldLoad) continue;
|
|
2953
|
+
const localIds = instances.map((i) => i[def.localKey]).filter(Boolean);
|
|
2954
|
+
if (def.type === "belongsTo") {
|
|
2955
|
+
if (!def.relatedModel.queryRunner) def.relatedModel.setConnection(this.queryRunner);
|
|
2956
|
+
const related = await def.relatedModel.query().whereIn(def.localKey, localIds).get();
|
|
2957
|
+
for (const inst of instances) {
|
|
2958
|
+
inst._relations[key] = related.find((r) => r[def.localKey] === inst[def.foreignKey]) ?? null;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
if (def.type === "hasMany") {
|
|
2962
|
+
if (!def.relatedModel.queryRunner) def.relatedModel.setConnection(this.queryRunner);
|
|
2963
|
+
const related = await def.relatedModel.query().whereIn(def.foreignKey, localIds).get();
|
|
2964
|
+
for (const inst of instances) {
|
|
2965
|
+
inst._relations[key] = related.filter((r) => r[def.foreignKey] === inst[def.localKey]);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
if (def.type === "hasOne") {
|
|
2969
|
+
if (!def.relatedModel.queryRunner) def.relatedModel.setConnection(this.queryRunner);
|
|
2970
|
+
const related = await def.relatedModel.query().whereIn(def.foreignKey, localIds).get();
|
|
2971
|
+
for (const inst of instances) {
|
|
2972
|
+
inst._relations[key] = related.find((r) => r[def.foreignKey] === inst[def.localKey]) ?? null;
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
if (def.type === "belongsToMany" && def.pivotTable) {
|
|
2976
|
+
if (!def.relatedModel.queryRunner) def.relatedModel.setConnection(this.queryRunner);
|
|
2977
|
+
const pivotQb = new QueryBuilder(this.queryRunner, def.pivotTable);
|
|
2978
|
+
const pivotRows = await pivotQb.whereIn(def.foreignKey, localIds).get();
|
|
2979
|
+
const relatedIds = pivotRows.map((r) => r[def.localKey]);
|
|
2980
|
+
if (relatedIds.length > 0) {
|
|
2981
|
+
const related = await def.relatedModel.query().whereIn("id", relatedIds).get();
|
|
2982
|
+
for (const inst of instances) {
|
|
2983
|
+
const pivots = pivotRows.filter((p) => p[def.foreignKey] === inst[def.localKey]);
|
|
2984
|
+
inst._relations[key] = pivots.map((p) => related.find((r) => r.id === p[def.localKey])).filter(Boolean);
|
|
2985
|
+
}
|
|
2986
|
+
} else {
|
|
2987
|
+
for (const inst of instances) {
|
|
2988
|
+
inst._relations[key] = [];
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
if (def.type === "morphMany" && def.morphName) {
|
|
2993
|
+
if (!def.relatedModel.queryRunner) def.relatedModel.setConnection(this.queryRunner);
|
|
2994
|
+
const related = await def.relatedModel.query().where(`${def.morphName}_type`, this.name).whereIn(`${def.morphName}_id`, localIds).get();
|
|
2995
|
+
for (const inst of instances) {
|
|
2996
|
+
inst._relations[key] = related.filter((r) => r[`${def.morphName}_id`] === inst[def.localKey]);
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
2892
3000
|
}
|
|
3001
|
+
// ─── Internal Helpers ──────────────────────────────────────
|
|
2893
3002
|
static hydrate(data) {
|
|
2894
3003
|
const instance = new this();
|
|
2895
3004
|
for (const [key, value] of Object.entries(data)) {
|
|
2896
|
-
;
|
|
2897
3005
|
instance[key] = value;
|
|
2898
3006
|
}
|
|
2899
3007
|
return instance;
|
|
@@ -2913,7 +3021,7 @@ var Model = class {
|
|
|
2913
3021
|
"getData"
|
|
2914
3022
|
]);
|
|
2915
3023
|
for (const key of ownKeys) {
|
|
2916
|
-
if (typeof key === "string" && !classKeys.has(key) && key !== "constructor") {
|
|
3024
|
+
if (typeof key === "string" && !classKeys.has(key) && key !== "constructor" && !key.startsWith("_")) {
|
|
2917
3025
|
data[key] = instance[key];
|
|
2918
3026
|
}
|
|
2919
3027
|
}
|