@tmlmobilidade/interfaces 20250915.1142.45 → 20250915.1306.2
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.
|
@@ -49,7 +49,7 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
|
|
|
49
49
|
email_verified?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
|
|
50
50
|
first_name: string;
|
|
51
51
|
last_name: string;
|
|
52
|
-
|
|
52
|
+
organization_id?: string | null | undefined | undefined;
|
|
53
53
|
preferences?: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null | undefined;
|
|
54
54
|
role_ids: string[];
|
|
55
55
|
session_ids: string[];
|
|
@@ -80,7 +80,7 @@ declare class UsersClass extends MongoCollectionClass<User, CreateUserDto, Updat
|
|
|
80
80
|
email_verified?: import("@tmlmobilidade/types").UnixTimestamp | null | undefined;
|
|
81
81
|
first_name: string;
|
|
82
82
|
last_name: string;
|
|
83
|
-
|
|
83
|
+
organization_id?: string | null | undefined | undefined;
|
|
84
84
|
preferences?: Record<string, Record<string, string | number | boolean | string[] | number[]>> | null | undefined;
|
|
85
85
|
role_ids: string[];
|
|
86
86
|
session_ids: string[];
|
|
@@ -53,7 +53,7 @@ class UsersClass extends MongoCollectionClass {
|
|
|
53
53
|
* @returns A promise that resolves to the matching user documents or null if not found
|
|
54
54
|
*/
|
|
55
55
|
async findByOrganization(id, includePasswordHash = false) {
|
|
56
|
-
const users = await this.mongoCollection.find({
|
|
56
|
+
const users = await this.mongoCollection.find({ organization_id: { $in: [id] } }).toArray();
|
|
57
57
|
return includePasswordHash ? users : users.map(user => this.deletePasswordHash(user));
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MongoCollectionClass } from '../../mongo-collection.js';
|
|
2
2
|
import { CreateOrganizationDto, Organization, UpdateOrganizationDto } from '@tmlmobilidade/types';
|
|
3
|
-
import { IndexDescription } from 'mongodb';
|
|
3
|
+
import { Filter, FindOptions, IndexDescription } from 'mongodb';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
declare class OrganizationsClass extends MongoCollectionClass<Organization, CreateOrganizationDto, UpdateOrganizationDto> {
|
|
6
6
|
private static _instance;
|
|
@@ -9,12 +9,12 @@ declare class OrganizationsClass extends MongoCollectionClass<Organization, Crea
|
|
|
9
9
|
private constructor();
|
|
10
10
|
static getInstance(): Promise<OrganizationsClass>;
|
|
11
11
|
/**
|
|
12
|
-
* Finds
|
|
12
|
+
* Finds a document by its ID.
|
|
13
13
|
*
|
|
14
|
-
* @param
|
|
15
|
-
* @returns A promise that resolves to the matching
|
|
14
|
+
* @param id - The ID of the document to find
|
|
15
|
+
* @returns A promise that resolves to the matching document or null if not found
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
findById(id: string, options?: FindOptions<Organization>): Promise<{
|
|
18
18
|
_id: string;
|
|
19
19
|
created_at: number & {
|
|
20
20
|
__brand: "UnixTimestamp";
|
|
@@ -22,19 +22,16 @@ declare class OrganizationsClass extends MongoCollectionClass<Organization, Crea
|
|
|
22
22
|
updated_at: number & {
|
|
23
23
|
__brand: "UnixTimestamp";
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
home_links: string[];
|
|
26
|
+
home_wikis: string[];
|
|
27
|
+
longname: string;
|
|
28
|
+
shortname: string;
|
|
27
29
|
created_by?: string | undefined;
|
|
28
30
|
updated_by?: string | undefined;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @param code - The code of the organization to update
|
|
34
|
-
* @param fields - The fields to update
|
|
35
|
-
* @returns A promise that resolves to the result of the update operation
|
|
36
|
-
*/
|
|
37
|
-
updateByCode(code: string, fields: Partial<Organization>): Promise<import("mongodb").UpdateResult<{
|
|
31
|
+
logo?: string | null | undefined;
|
|
32
|
+
theme?: string | null | undefined;
|
|
33
|
+
} | null>;
|
|
34
|
+
findOne(filter: Filter<Organization>): Promise<import("mongodb").WithId<{
|
|
38
35
|
_id: string;
|
|
39
36
|
created_at: number & {
|
|
40
37
|
__brand: "UnixTimestamp";
|
|
@@ -42,13 +39,18 @@ declare class OrganizationsClass extends MongoCollectionClass<Organization, Crea
|
|
|
42
39
|
updated_at: number & {
|
|
43
40
|
__brand: "UnixTimestamp";
|
|
44
41
|
};
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
home_links: string[];
|
|
43
|
+
home_wikis: string[];
|
|
44
|
+
longname: string;
|
|
45
|
+
shortname: string;
|
|
47
46
|
created_by?: string | undefined;
|
|
48
47
|
updated_by?: string | undefined;
|
|
49
|
-
|
|
48
|
+
logo?: string | null | undefined;
|
|
49
|
+
theme?: string | null | undefined;
|
|
50
|
+
}> | null>;
|
|
50
51
|
protected getCollectionIndexes(): IndexDescription[];
|
|
51
52
|
protected getCollectionName(): string;
|
|
53
|
+
protected getCreateSchema(): z.ZodSchema;
|
|
52
54
|
protected getEnvName(): string;
|
|
53
55
|
}
|
|
54
56
|
export declare const organizations: OrganizationsClass;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* * */
|
|
2
2
|
import { MongoCollectionClass } from '../../mongo-collection.js';
|
|
3
|
-
import { OrganizationSchema, UpdateOrganizationSchema } from '@tmlmobilidade/types';
|
|
3
|
+
import { CreateOrganizationSchema, OrganizationSchema, UpdateOrganizationSchema } from '@tmlmobilidade/types';
|
|
4
4
|
import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
5
|
/* * */
|
|
6
6
|
class OrganizationsClass extends MongoCollectionClass {
|
|
7
7
|
static _instance;
|
|
8
|
-
createSchema =
|
|
8
|
+
createSchema = CreateOrganizationSchema;
|
|
9
9
|
updateSchema = UpdateOrganizationSchema;
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
@@ -19,23 +19,24 @@ class OrganizationsClass extends MongoCollectionClass {
|
|
|
19
19
|
return OrganizationsClass._instance;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Finds
|
|
22
|
+
* Finds a document by its ID.
|
|
23
23
|
*
|
|
24
|
-
* @param
|
|
25
|
-
* @returns A promise that resolves to the matching
|
|
24
|
+
* @param id - The ID of the document to find
|
|
25
|
+
* @returns A promise that resolves to the matching document or null if not found
|
|
26
26
|
*/
|
|
27
|
-
async
|
|
28
|
-
|
|
27
|
+
async findById(id, options) {
|
|
28
|
+
const organization = await this.mongoCollection.findOne({ _id: id }, options);
|
|
29
|
+
if (!organization) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return organization;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
async updateByCode(code, fields) {
|
|
38
|
-
return this.mongoCollection.updateOne({ code }, { $set: fields });
|
|
34
|
+
async findOne(filter) {
|
|
35
|
+
const organization = await this.mongoCollection.findOne(filter);
|
|
36
|
+
if (!organization) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return organization;
|
|
39
40
|
}
|
|
40
41
|
getCollectionIndexes() {
|
|
41
42
|
return [
|
|
@@ -45,8 +46,11 @@ class OrganizationsClass extends MongoCollectionClass {
|
|
|
45
46
|
getCollectionName() {
|
|
46
47
|
return 'organizations';
|
|
47
48
|
}
|
|
49
|
+
getCreateSchema() {
|
|
50
|
+
return OrganizationSchema;
|
|
51
|
+
}
|
|
48
52
|
getEnvName() {
|
|
49
|
-
return '
|
|
53
|
+
return 'DATABASE_URI';
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
export const organizations = AsyncSingletonProxy(OrganizationsClass);
|
package/package.json
CHANGED