Skip to content

Commit b47812d

Browse files
authored
Merge pull request #3410 from SeedCompany/ts-5.8
2 parents 0d71a8b + 6fac407 commit b47812d

File tree

16 files changed

+69
-90
lines changed

16 files changed

+69
-90
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"ts-patch": "^3.0.2",
149149
"ts-transformer-keys": "^0.4.4",
150150
"type-fest": "^4.15.0",
151-
"typescript": "~5.2.2",
151+
"typescript": "~5.8.3",
152152
"typescript-transform-paths": "^3.4.6"
153153
},
154154
"resolutions": {
@@ -158,7 +158,7 @@
158158
"@nestjs/cli/fork-ts-checker-webpack-plugin": "npm:empty-npm-package@*",
159159
"@nestjs/cli/glob": "^11",
160160
"@nestjs/cli/webpack": "npm:empty-npm-package@*",
161-
"@nestjs/cli/typescript": "~5.2.2",
161+
"@nestjs/cli/typescript": "~5.8.3",
162162
"@whatwg-node/fetch@npm:^0.10.0": "patch:@whatwg-node/fetch@npm%3A0.10.6#~/.yarn/patches/@whatwg-node-fetch-npm-0.10.6-bca79028fb.patch",
163163
"@whatwg-node/fetch@npm:^0.10.1": "patch:@whatwg-node/fetch@npm%3A0.10.6#~/.yarn/patches/@whatwg-node-fetch-npm-0.10.6-bca79028fb.patch",
164164
"@whatwg-node/fetch@npm:^0.10.4": "patch:@whatwg-node/fetch@npm%3A0.10.6#~/.yarn/patches/@whatwg-node-fetch-npm-0.10.6-bca79028fb.patch",

src/common/db-sort.decorator.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { AbstractClassType } from './types';
2-
3-
const DbSortSymbol = Symbol('DbSortSymbol');
1+
import { createMetadataDecorator } from '@seedcompany/nest';
42

53
/**
64
* A function given a cypher variable will output cypher to transform it for sorting.
@@ -10,11 +8,7 @@ export type SortTransformer = (value: string) => string;
108
/**
119
* Customize the way this field is sorted upon.
1210
*/
13-
export const DbSort = (transformer: SortTransformer) =>
14-
Reflect.metadata(DbSortSymbol, transformer);
15-
16-
export const getDbSortTransformer = (
17-
type: AbstractClassType<unknown>,
18-
property: string,
19-
): SortTransformer | undefined =>
20-
Reflect.getMetadata(DbSortSymbol, type.prototype, property);
11+
export const DbSort = createMetadataDecorator({
12+
types: ['property'],
13+
setter: (transformer: SortTransformer) => transformer,
14+
});

src/common/db-unique.decorator.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1+
import { createMetadataDecorator } from '@seedcompany/nest';
12
import { startCase } from 'lodash';
23
import { DbLabel } from './db-label.decorator';
3-
import { AbstractClassType } from './types';
4-
5-
const DbUniqueSymbol = Symbol('DbUnique');
64

75
/**
8-
* This property value should have a unique constraint in database.
9-
* The property node needs a unique label, which can be given or will based on
6+
* This property value should have a unique constraint in the neo4j database.
7+
* The property node needs a unique label, which can be given or will be based on
108
* the resource & property name.
119
*/
12-
export const DbUnique =
13-
(label?: string): PropertyDecorator =>
14-
(target, propertyKey) => {
15-
if (typeof propertyKey === 'symbol') {
16-
throw new Error('DbUnique() cannot be used on symbol properties');
17-
}
18-
label ??= target.constructor.name + startCase(propertyKey);
19-
Reflect.defineMetadata(DbUniqueSymbol, label, target, propertyKey);
20-
DbLabel(label)(target, propertyKey);
21-
};
10+
export const DbUnique = (label?: string) => (target: object, key: string) => {
11+
label ??= target.constructor.name + startCase(key);
12+
DbUniqueInner(label)(target, key);
13+
DbLabel(label)(target, key);
14+
};
15+
16+
const DbUniqueInner = createMetadataDecorator({
17+
types: ['property'],
18+
setter: (label?: string) => label,
19+
});
2220

23-
export const getDbPropertyUnique = (
24-
type: AbstractClassType<unknown>,
25-
property: string,
26-
): string | undefined =>
27-
Reflect.getMetadata(DbUniqueSymbol, type.prototype, property);
21+
DbUnique.get = DbUniqueInner.get;

src/common/disabled.decorator.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
/* eslint-disable @seedcompany/no-unused-vars */
22

3-
import { FnLike } from '@seedcompany/common';
4-
5-
type Decorator =
6-
| ClassDecorator
7-
| PropertyDecorator
8-
| MethodDecorator
9-
| ParameterDecorator
10-
| FnLike;
11-
123
/**
134
* Mark the decorator is disabled and give a reason why.
145
* Allows to keep code versioned without being enabled
156
* without all wall of commented out text that can get outdated.
167
*/
178
export const Disabled =
18-
(why?: string) =>
19-
<T extends Decorator>(decorator: T): T =>
20-
// @ts-expect-error yeah all decorators can return void
21-
() => {
9+
(why: string, ...anything: unknown[]) =>
10+
(...decoratorArgs: unknown[]) => {
2211
// noop
2312
};

src/components/admin/admin.gel.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class AdminGelRepository {
2929
const rootAlias = e.select(e.Alias, () => ({
3030
filter_single: { name: RootUserAlias },
3131
}));
32-
const rootUser = e.select(rootAlias.target.is(e.User), (u) => ({
32+
const rootUser = e.select(e.User, (u) => ({
33+
filter: e.op(u, '=', rootAlias.target),
3334
id: true,
3435
email: true,
3536
hash: u['<user[is Auth::Identity]'].passwordHash,

src/components/authorization/policy/executor/all-permissions-view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const createAllPermissionsView = <
5353
propPerms[compatMap.backward[action]] = perm;
5454
return perm;
5555
},
56-
}),
56+
}) as any,
5757
});
5858

5959
export type AllPermissionsOfEdgeView<TAction extends string> = Record<

src/components/budget/handlers/update-project-current-budget-status.handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class UpdateProjectBudgetStatusHandler
4141
session,
4242
);
4343

44-
const budget = budgets.items.find((b) => b.status === change![0]);
44+
const budget = budgets.items.find((b) => b.status === change[0]);
4545
if (!budget) {
4646
return;
4747
}

src/components/engagement/engagement.gel.repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ const baseHydrate = e.shape(e.Engagement, (engagement) => ({
2525
step: true,
2626
type: true,
2727
},
28-
parent: e.tuple({
28+
parent: e.select({
2929
identity: engagement.project.id,
3030
labels: e.array_agg(e.set(engagement.project.__type__.name.slice(9, null))),
31-
properties: e.tuple({
31+
properties: e.select({
3232
id: engagement.project.id,
3333
createdAt: engagement.project.createdAt,
3434
}),

src/components/partnership/partnership.gel.repository.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export class PartnershipGelRepository
1515
partner: true,
1616
mou: true,
1717
agreement: true,
18-
parent: e.tuple({
18+
parent: e.select({
1919
identity: partnership.project.id,
2020
labels: e.array_agg(
2121
e.set(partnership.project.__type__.name.slice(9, null)),
2222
),
23-
properties: e.tuple({
23+
properties: e.select({
2424
id: partnership.project.id,
2525
createdAt: partnership.project.createdAt,
2626
}),
@@ -37,16 +37,17 @@ export class PartnershipGelRepository
3737
private readonly readManyByProjectAndPartnerQuery = e.params(
3838
{ input: e.array(e.tuple({ project: e.uuid, partner: e.uuid })) },
3939
({ input }) =>
40-
e.for(e.array_unpack(input), ({ project, partner }) =>
41-
e.select(e.Partnership, (partnership) => ({
42-
...this.hydrate(partnership),
43-
filter: e.op(
44-
e.op(partnership.project, '=', e.cast(e.Project, project)),
45-
'and',
46-
e.op(partnership.partner, '=', e.cast(e.Partner, partner)),
47-
),
48-
})),
49-
),
40+
e.select(e.Partnership, (partnership) => ({
41+
...this.hydrate(partnership),
42+
filter: e.op(
43+
e.tuple({
44+
project: partnership.project.id,
45+
partner: partnership.partner.id,
46+
}),
47+
'in',
48+
e.array_unpack(input),
49+
),
50+
})),
5051
);
5152

5253
async listAllByProjectId(project: ID) {

src/components/project/dto/project.dto.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,12 @@ class Project extends Interfaces {
197197
* Optimization for {@link ProjectResolver.engagements}.
198198
* This doesn't account for changesets or item filters.
199199
*/
200-
@Disabled(`
201-
I'm not convinced this wont have unintended consequences.
202-
it is still handled with the workflow condition currently and deletes are
203-
restricted, so this is a super edge case effectively.
204-
`)(
200+
@Disabled(
201+
`
202+
I'm not convinced this wont have unintended consequences.
203+
it is still handled with the workflow condition currently and deletes are
204+
restricted, so this is a super edge case effectively.
205+
`,
205206
RequiredWhenNotInDev({
206207
field: 'engagements',
207208
isMissing: (project) => project.engagementTotal === 0,

0 commit comments

Comments
 (0)