@sneat/space-models 0.1.1
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/eslint.config.js +7 -0
- package/ng-package.json +7 -0
- package/package.json +14 -0
- package/project.json +38 -0
- package/src/index.ts +1 -0
- package/src/lib/dto-models.ts +13 -0
- package/src/lib/index.ts +5 -0
- package/src/lib/invite-models.ts +1 -0
- package/src/lib/member-context.ts +1 -0
- package/src/lib/models.ts +72 -0
- package/src/lib/sanity.spec.ts +5 -0
- package/src/lib/space-context.ts +71 -0
- package/src/lib/space-item-context.ts +21 -0
- package/src/lib/uimodels/index.ts +1 -0
- package/src/lib/uimodels/ui-models.ts +265 -0
- package/src/test-setup.ts +1 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +19 -0
- package/tsconfig.lib.prod.json +7 -0
- package/tsconfig.spec.json +31 -0
- package/vite.config.mts +10 -0
package/eslint.config.js
ADDED
package/ng-package.json
ADDED
package/package.json
ADDED
package/project.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "space-models",
|
|
3
|
+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"projectType": "library",
|
|
5
|
+
"sourceRoot": "libs/space/models/src",
|
|
6
|
+
"prefix": "sneat",
|
|
7
|
+
"targets": {
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "@nx/angular:ng-packagr-lite",
|
|
10
|
+
"outputs": [
|
|
11
|
+
"{workspaceRoot}/dist/libs/space/models"
|
|
12
|
+
],
|
|
13
|
+
"options": {
|
|
14
|
+
"project": "libs/space/models/ng-package.json",
|
|
15
|
+
"tsConfig": "libs/space/models/tsconfig.lib.json"
|
|
16
|
+
},
|
|
17
|
+
"configurations": {
|
|
18
|
+
"production": {
|
|
19
|
+
"tsConfig": "libs/space/models/tsconfig.lib.prod.json"
|
|
20
|
+
},
|
|
21
|
+
"development": {}
|
|
22
|
+
},
|
|
23
|
+
"defaultConfiguration": "production"
|
|
24
|
+
},
|
|
25
|
+
"test": {
|
|
26
|
+
"executor": "@nx/vitest:test",
|
|
27
|
+
"outputs": [
|
|
28
|
+
"{workspaceRoot}/coverage/libs/space/models"
|
|
29
|
+
],
|
|
30
|
+
"options": {
|
|
31
|
+
"tsConfig": "libs/space/models/tsconfig.spec.json"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"lint": {
|
|
35
|
+
"executor": "@nx/eslint:lint"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SpaceType } from '@sneat/core';
|
|
2
|
+
import { IRecord } from '@sneat/data';
|
|
3
|
+
import { ISpaceDbo } from '@sneat/dto';
|
|
4
|
+
|
|
5
|
+
export interface ICreateSpaceRequest {
|
|
6
|
+
type: SpaceType;
|
|
7
|
+
// memberType: MemberType;
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ICreateSpaceResponse {
|
|
12
|
+
space: IRecord<ISpaceDbo>;
|
|
13
|
+
}
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const empty = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const empty = {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SpaceType } from '@sneat/core';
|
|
2
|
+
import { ISpaceModuleItemRef } from '@sneat/dto';
|
|
3
|
+
|
|
4
|
+
export interface ISpaceRequest {
|
|
5
|
+
readonly spaceID: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ISpaceItemRequest extends ISpaceRequest {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ISpaceMemberRequest extends ISpaceRequest {
|
|
13
|
+
readonly memberID: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ILeaveSpaceRequest extends ISpaceRequest {
|
|
17
|
+
readonly message?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IAcceptInviteResponse {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IInviteSpace {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly type: SpaceType;
|
|
27
|
+
readonly title: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IRejectPersonalInviteRequest extends ISpaceRequest {
|
|
31
|
+
readonly inviteID: string;
|
|
32
|
+
readonly pin: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type SpaceMemberStatus = 'active' | 'archived';
|
|
36
|
+
|
|
37
|
+
export interface ITaskRequest extends ISpaceMemberRequest {
|
|
38
|
+
readonly type: string;
|
|
39
|
+
readonly task: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface IReorderTaskRequest extends ITaskRequest {
|
|
43
|
+
readonly len: number;
|
|
44
|
+
readonly from: number;
|
|
45
|
+
readonly to: number;
|
|
46
|
+
readonly after?: string;
|
|
47
|
+
readonly before?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IModuleCollectionRef {
|
|
51
|
+
readonly moduleID: string;
|
|
52
|
+
readonly collection: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IRelatedRolesRequest {
|
|
56
|
+
readonly rolesOfItem?: string[];
|
|
57
|
+
readonly rolesToItem?: string[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface IRelatedChange {
|
|
61
|
+
readonly add?: IRelatedRolesRequest;
|
|
62
|
+
readonly remove?: IRelatedRolesRequest;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface IRelatedItemChange extends IRelatedChange {
|
|
66
|
+
readonly itemRef: ISpaceModuleItemRef;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface IUpdateRelatedRequest
|
|
70
|
+
extends ISpaceItemRequest, IModuleCollectionRef {
|
|
71
|
+
readonly related?: IRelatedItemChange[];
|
|
72
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { computed, Signal } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
IIdAndBrief,
|
|
4
|
+
IIdAndBriefWithSpaceRef,
|
|
5
|
+
INavContext,
|
|
6
|
+
ISpaceRef,
|
|
7
|
+
} from '@sneat/core';
|
|
8
|
+
import { IShortSpaceInfo, ISpaceBrief, ISpaceDbo } from '@sneat/dto';
|
|
9
|
+
|
|
10
|
+
export function zipMapBriefsWithIDs<Brief>(
|
|
11
|
+
briefs?: Readonly<Record<string, Brief>>,
|
|
12
|
+
): readonly IIdAndBrief<Brief>[] {
|
|
13
|
+
return briefs
|
|
14
|
+
? Object.entries(briefs).map(([id, brief]) => ({ id, brief }))
|
|
15
|
+
: [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function zipMapBriefsWithIDsAndSpaceRef<Brief>(
|
|
19
|
+
space: ISpaceRef,
|
|
20
|
+
briefs?: Readonly<Record<string, Brief>>,
|
|
21
|
+
): readonly IIdAndBriefWithSpaceRef<Brief>[] {
|
|
22
|
+
return briefs
|
|
23
|
+
? Object.entries(briefs).map(([id, brief]) => ({ id, brief, space }))
|
|
24
|
+
: [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ISpaceContext
|
|
28
|
+
extends ISpaceRef, INavContext<ISpaceBrief, ISpaceDbo> {
|
|
29
|
+
// readonly type?: SpaceType;
|
|
30
|
+
// readonly assets?: IAssetContext[]; // TODO: this should not be here
|
|
31
|
+
// readonly contacts?: IContactContext[]; // TODO: this should not be here
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function computeSpaceRefFromSpaceContext(
|
|
35
|
+
$space: Signal<ISpaceContext | undefined>,
|
|
36
|
+
) {
|
|
37
|
+
return computed<ISpaceRef>(() => {
|
|
38
|
+
const space = $space();
|
|
39
|
+
return space?.type
|
|
40
|
+
? { type: space?.type, id: space.id }
|
|
41
|
+
: { id: space?.id || '' };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function computeSpaceIdFromSpaceRef($spaceRef: () => ISpaceRef) {
|
|
46
|
+
return computed<string>(() => $spaceRef().id);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const spaceContextFromBrief = (
|
|
50
|
+
id: string,
|
|
51
|
+
brief: ISpaceBrief,
|
|
52
|
+
): ISpaceContext => ({ id, type: brief.type, brief });
|
|
53
|
+
|
|
54
|
+
// export interface IContactContextWithBrief
|
|
55
|
+
// extends ITeamItemNavContext<IContactBrief, IContactDto> {
|
|
56
|
+
// brief: IContactBrief;
|
|
57
|
+
// parentContact?: IContactContext;
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
export function createShortSpaceInfoFromDbo(
|
|
61
|
+
space: ISpaceContext,
|
|
62
|
+
): IShortSpaceInfo {
|
|
63
|
+
if (!space.type) {
|
|
64
|
+
throw new Error('!team.type');
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
id: space.id,
|
|
68
|
+
type: space.type,
|
|
69
|
+
title: space?.dbo?.title || space.brief?.title,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IIdAndOptionalBriefAndOptionalDbo,
|
|
3
|
+
IIdAndOptionalDbo,
|
|
4
|
+
ISpaceRef,
|
|
5
|
+
} from '@sneat/core';
|
|
6
|
+
|
|
7
|
+
export interface ISpaceItemWithOptionalBriefAndOptionalDbo<
|
|
8
|
+
Brief,
|
|
9
|
+
Dbo extends Brief,
|
|
10
|
+
> extends IIdAndOptionalBriefAndOptionalDbo<Brief, Dbo> {
|
|
11
|
+
readonly space: ISpaceRef;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ISpaceItemWithOptionalDbo<Dbo> extends IIdAndOptionalDbo<Dbo> {
|
|
15
|
+
readonly space: ISpaceRef;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type ISpaceItemNavContext<
|
|
19
|
+
Brief,
|
|
20
|
+
Dbo extends Brief,
|
|
21
|
+
> = ISpaceItemWithOptionalBriefAndOptionalDbo<Brief, Dbo>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ui-models';
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { SpaceType } from '@sneat/core';
|
|
2
|
+
import { DtoTotal, DtoTotals, Period } from '@sneat/dto';
|
|
3
|
+
import { ISpaceContext } from '../space-context';
|
|
4
|
+
|
|
5
|
+
export class Total {
|
|
6
|
+
constructor(public readonly dto?: DtoTotal) {
|
|
7
|
+
if (!dto) {
|
|
8
|
+
this.dto = { count: 0 };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public get count(): number {
|
|
13
|
+
return this.dto ? this.dto.count : 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public per(period: Period): number {
|
|
17
|
+
switch (period) {
|
|
18
|
+
case 'month':
|
|
19
|
+
return this.perMonth();
|
|
20
|
+
case 'year':
|
|
21
|
+
return this.perYear();
|
|
22
|
+
case 'quarter':
|
|
23
|
+
return this.perQuarter();
|
|
24
|
+
case 'week':
|
|
25
|
+
return this.perWeek();
|
|
26
|
+
case 'day':
|
|
27
|
+
return this.perDay();
|
|
28
|
+
default:
|
|
29
|
+
throw new Error(`unknown period: ${period}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public perDay(): number {
|
|
34
|
+
if (!this.dto) {
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
let result = 0;
|
|
38
|
+
if (this.dto.day !== undefined) {
|
|
39
|
+
result += this.dto.day;
|
|
40
|
+
}
|
|
41
|
+
if (this.dto.week !== undefined) {
|
|
42
|
+
result += Math.round(this.dto.week / 7);
|
|
43
|
+
}
|
|
44
|
+
if (this.dto.month !== undefined) {
|
|
45
|
+
result += Math.round(this.dto.month / 30);
|
|
46
|
+
}
|
|
47
|
+
if (this.dto.quarter !== undefined) {
|
|
48
|
+
result += Math.round(this.dto.quarter / 61);
|
|
49
|
+
}
|
|
50
|
+
if (this.dto.year !== undefined) {
|
|
51
|
+
result += Math.round(this.dto.year / 365);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public perWeek(): number {
|
|
57
|
+
if (!this.dto) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
let result = 0;
|
|
61
|
+
if (this.dto.week !== undefined) {
|
|
62
|
+
result += this.dto.week;
|
|
63
|
+
}
|
|
64
|
+
if (this.dto.month !== undefined) {
|
|
65
|
+
result += Math.round(this.dto.month / 4.33);
|
|
66
|
+
}
|
|
67
|
+
if (this.dto.day !== undefined) {
|
|
68
|
+
result += this.dto.day * 7;
|
|
69
|
+
}
|
|
70
|
+
if (this.dto.quarter !== undefined) {
|
|
71
|
+
result += Math.round(this.dto.quarter / 13);
|
|
72
|
+
}
|
|
73
|
+
if (this.dto.year !== undefined) {
|
|
74
|
+
result += Math.round(this.dto.year / 52);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public perMonth(): number {
|
|
80
|
+
if (!this.dto) {
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
let result = 0;
|
|
84
|
+
if (this.dto.month !== undefined) {
|
|
85
|
+
result += this.dto.month;
|
|
86
|
+
}
|
|
87
|
+
if (this.dto.day !== undefined) {
|
|
88
|
+
result += this.dto.day * 30;
|
|
89
|
+
}
|
|
90
|
+
if (this.dto.week !== undefined) {
|
|
91
|
+
result += this.dto.week * 4.33;
|
|
92
|
+
}
|
|
93
|
+
if (this.dto.year !== undefined) {
|
|
94
|
+
result += Math.round(this.dto.year / 12);
|
|
95
|
+
}
|
|
96
|
+
if (this.dto.quarter !== undefined) {
|
|
97
|
+
result += Math.round(this.dto.quarter / 3);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public perQuarter(): number {
|
|
103
|
+
if (!this.dto) {
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
let result = 0;
|
|
107
|
+
if (this.dto.quarter !== undefined) {
|
|
108
|
+
result += this.dto.quarter;
|
|
109
|
+
}
|
|
110
|
+
if (this.dto.day !== undefined) {
|
|
111
|
+
result += this.dto.day * 61;
|
|
112
|
+
}
|
|
113
|
+
if (this.dto.week !== undefined) {
|
|
114
|
+
result += this.dto.week * 13;
|
|
115
|
+
}
|
|
116
|
+
if (this.dto.month !== undefined) {
|
|
117
|
+
result += this.dto.month * 3;
|
|
118
|
+
}
|
|
119
|
+
if (this.dto.year !== undefined) {
|
|
120
|
+
result += Math.round(this.dto.year / 4);
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public perYear(): number {
|
|
126
|
+
if (!this.dto) {
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
let result = 0;
|
|
130
|
+
if (this.dto.year !== undefined) {
|
|
131
|
+
result += this.dto.year;
|
|
132
|
+
}
|
|
133
|
+
if (this.dto.day !== undefined) {
|
|
134
|
+
result += this.dto.day * 365;
|
|
135
|
+
}
|
|
136
|
+
if (this.dto.week !== undefined) {
|
|
137
|
+
result += this.dto.week * 52;
|
|
138
|
+
}
|
|
139
|
+
if (this.dto.month !== undefined) {
|
|
140
|
+
result += this.dto.month * 12;
|
|
141
|
+
}
|
|
142
|
+
if (this.dto.quarter !== undefined) {
|
|
143
|
+
result += this.dto.quarter * 4;
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export class Totals {
|
|
150
|
+
readonly incomes: Total;
|
|
151
|
+
readonly expenses: Total;
|
|
152
|
+
|
|
153
|
+
constructor(dtoTotals?: DtoTotals) {
|
|
154
|
+
this.incomes = new Total(dtoTotals ? dtoTotals.incomes : undefined);
|
|
155
|
+
this.expenses = new Total(dtoTotals ? dtoTotals.expenses : undefined);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
get count(): number {
|
|
159
|
+
return this.incomes.count + this.expenses.count;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
isPositive(period: Period): boolean {
|
|
163
|
+
return this.per(period, true, true) > 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
isNegative(period: Period): boolean {
|
|
167
|
+
return this.per(period, true, true) < 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
per(period: Period, incomes = true, expense = true): number {
|
|
171
|
+
if (incomes && expense) {
|
|
172
|
+
return this.incomes.per(period) - this.expenses.per(period);
|
|
173
|
+
}
|
|
174
|
+
if (incomes) {
|
|
175
|
+
return this.incomes.per(period);
|
|
176
|
+
}
|
|
177
|
+
if (expense) {
|
|
178
|
+
return -this.expenses.per(period);
|
|
179
|
+
}
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
balance(per: 'month' | 'day'): number {
|
|
184
|
+
switch (per) {
|
|
185
|
+
case 'month':
|
|
186
|
+
return (
|
|
187
|
+
Math.round(
|
|
188
|
+
(this.incomes.perMonth() - this.expenses.perMonth()) * 100,
|
|
189
|
+
) / 100
|
|
190
|
+
);
|
|
191
|
+
case 'day':
|
|
192
|
+
return (
|
|
193
|
+
Math.round((this.incomes.perDay() - this.expenses.perDay()) * 100) /
|
|
194
|
+
100
|
|
195
|
+
);
|
|
196
|
+
default:
|
|
197
|
+
throw new Error(`Unknown parameter value: ${per}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export class Commune implements ISpaceContext {
|
|
203
|
+
public readonly totals: Totals;
|
|
204
|
+
|
|
205
|
+
constructor(
|
|
206
|
+
public readonly space: ISpaceContext,
|
|
207
|
+
public readonly shortId?: string,
|
|
208
|
+
) {
|
|
209
|
+
this.totals = new Totals(space.dbo?.totals);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public get id(): string {
|
|
213
|
+
return this.space.id;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public get type(): SpaceType | undefined {
|
|
217
|
+
return this.space.dbo?.type;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public get title(): string | undefined {
|
|
221
|
+
return this.space.dbo?.title;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// public get isSupportingMemberGroups(): boolean {
|
|
225
|
+
// const t = this.team.type;
|
|
226
|
+
// return t === 'educator' || t === 'sport_club' || t === 'cohabit';
|
|
227
|
+
// }
|
|
228
|
+
|
|
229
|
+
// public get numberOf(): TeamCounts {
|
|
230
|
+
// if (this.team.dto?.numberOf) {
|
|
231
|
+
// return this.team.dto.numberOf;
|
|
232
|
+
// }
|
|
233
|
+
// return newTeamCounts(this.team.dto?.numberOf);
|
|
234
|
+
// }
|
|
235
|
+
|
|
236
|
+
private _membersCountByRole?: { role: string; count: number }[];
|
|
237
|
+
|
|
238
|
+
public get membersCountByRole(): { role: string; count: number }[] {
|
|
239
|
+
throw new Error('Not implemented yet - disabled');
|
|
240
|
+
// if (!this._membersCountByRole) {
|
|
241
|
+
// const byRole = this.numberOf.membersByRole;
|
|
242
|
+
// if (!byRole) {
|
|
243
|
+
// return [];
|
|
244
|
+
// }
|
|
245
|
+
// this._membersCountByRole = Object.entries(byRole)
|
|
246
|
+
// .map(item => ({ role: item[0], count: item[1] as number }));
|
|
247
|
+
// }
|
|
248
|
+
// return this._membersCountByRole;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
public supports(v: 'staff' | 'pupils'): boolean {
|
|
252
|
+
if (!v) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
switch (v) {
|
|
256
|
+
case 'staff':
|
|
257
|
+
return this.type === 'educator' || this.type === 'realtor';
|
|
258
|
+
case 'pupils':
|
|
259
|
+
return this.type === 'educator';
|
|
260
|
+
default:
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@sneat/core/testing-light';
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.lib.base.json",
|
|
3
|
+
"exclude": [
|
|
4
|
+
"vite.config.ts",
|
|
5
|
+
"vite.config.mts",
|
|
6
|
+
"vitest.config.ts",
|
|
7
|
+
"vitest.config.mts",
|
|
8
|
+
"src/**/*.test.ts",
|
|
9
|
+
"src/**/*.spec.ts",
|
|
10
|
+
"src/**/*.test.tsx",
|
|
11
|
+
"src/**/*.spec.tsx",
|
|
12
|
+
"src/**/*.test.js",
|
|
13
|
+
"src/**/*.spec.js",
|
|
14
|
+
"src/**/*.test.jsx",
|
|
15
|
+
"src/**/*.spec.jsx",
|
|
16
|
+
"src/test-setup.ts",
|
|
17
|
+
"src/lib/testing/**/*"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../../dist/out-tsc",
|
|
5
|
+
"types": [
|
|
6
|
+
"vitest/globals",
|
|
7
|
+
"vitest/importMeta",
|
|
8
|
+
"vite/client",
|
|
9
|
+
"node",
|
|
10
|
+
"vitest"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"vite.config.ts",
|
|
15
|
+
"vite.config.mts",
|
|
16
|
+
"vitest.config.ts",
|
|
17
|
+
"vitest.config.mts",
|
|
18
|
+
"src/**/*.test.ts",
|
|
19
|
+
"src/**/*.spec.ts",
|
|
20
|
+
"src/**/*.test.tsx",
|
|
21
|
+
"src/**/*.spec.tsx",
|
|
22
|
+
"src/**/*.test.js",
|
|
23
|
+
"src/**/*.spec.js",
|
|
24
|
+
"src/**/*.test.jsx",
|
|
25
|
+
"src/**/*.spec.jsx",
|
|
26
|
+
"src/**/*.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"files": [
|
|
29
|
+
"src/test-setup.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
package/vite.config.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types='vitest' />
|
|
2
|
+
import { defineConfig } from 'vitest/config';
|
|
3
|
+
import { createBaseViteConfig } from '../../../vite.config.base';
|
|
4
|
+
|
|
5
|
+
export default defineConfig(() =>
|
|
6
|
+
createBaseViteConfig({
|
|
7
|
+
dirname: __dirname,
|
|
8
|
+
name: 'space-models',
|
|
9
|
+
}),
|
|
10
|
+
);
|