rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61)
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Architecture Guardrails (push) Successful in 2m38s
CI / Assistant Split Regression (push) Successful in 3m33s
CI / Typecheck (push) Successful in 3m51s
CI / Lint (push) Successful in 5m2s
CI / E2E Tests (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / Release Images (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
rename(phase 1): CapaKraken → Nexus across code, UI, docs, CI (#61) Co-authored-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com> Co-committed-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
This commit was merged in pull request #61.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { FieldType, ResourceType } from "@capakraken/shared";
|
||||
import { FieldType, ResourceType } from "@nexus/shared";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
@@ -24,7 +24,9 @@ import {
|
||||
type ResourceReadContext,
|
||||
} from "../lib/resource-access.js";
|
||||
|
||||
function parseResourceCursor(cursor: string | undefined): { displayName: string; id: string } | null {
|
||||
function parseResourceCursor(
|
||||
cursor: string | undefined,
|
||||
): { displayName: string; id: string } | null {
|
||||
if (!cursor) return null;
|
||||
try {
|
||||
const decoded = JSON.parse(cursor) as { displayName?: string; id?: string };
|
||||
@@ -62,11 +64,15 @@ export const ResourceDirectoryQuerySchema = z.object({
|
||||
|
||||
export const ResourceListQuerySchema = ResourceDirectoryQuerySchema.extend({
|
||||
includeRoles: z.boolean().optional().default(false),
|
||||
customFieldFilters: z.array(z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
type: z.nativeEnum(FieldType),
|
||||
})).optional(),
|
||||
customFieldFilters: z
|
||||
.array(
|
||||
z.object({
|
||||
key: z.string(),
|
||||
value: z.string(),
|
||||
type: z.nativeEnum(FieldType),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export async function listStaffResources(
|
||||
@@ -95,15 +101,12 @@ export async function listStaffResources(
|
||||
} = input;
|
||||
const parsedCursor = parseResourceCursor(cursor);
|
||||
|
||||
const cfConditions = buildDynamicFieldWhereClauses(customFieldFilters).map((dynamicFields) => ({ dynamicFields }));
|
||||
const cfConditions = buildDynamicFieldWhereClauses(customFieldFilters).map((dynamicFields) => ({
|
||||
dynamicFields,
|
||||
}));
|
||||
type WhereClause = Record<string, unknown>;
|
||||
const andClauses: WhereClause[] = [];
|
||||
const chapterFilters = Array.from(
|
||||
new Set([
|
||||
...(chapter ? [chapter] : []),
|
||||
...(chapters ?? []),
|
||||
]),
|
||||
);
|
||||
const chapterFilters = Array.from(new Set([...(chapter ? [chapter] : []), ...(chapters ?? [])]));
|
||||
const directory = await getAnonymizationDirectory(ctx.db);
|
||||
|
||||
if (!eids) {
|
||||
@@ -201,28 +204,33 @@ export async function listStaffResources(
|
||||
if (eids && eids.length > 0 && requestedIds.length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (search && !anonymizeSearchMatches(
|
||||
{
|
||||
id: resource.id,
|
||||
eid: resource.eid,
|
||||
displayName: resource.displayName,
|
||||
email: resource.email,
|
||||
},
|
||||
alias,
|
||||
search,
|
||||
)) {
|
||||
if (
|
||||
search &&
|
||||
!anonymizeSearchMatches(
|
||||
{
|
||||
id: resource.id,
|
||||
eid: resource.eid,
|
||||
displayName: resource.displayName,
|
||||
email: resource.email,
|
||||
},
|
||||
alias,
|
||||
search,
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
const anonymizedResources = anonymizeResources(filteredResources, directory).sort((left, right) => {
|
||||
const displayNameCompare = left.displayName.localeCompare(right.displayName);
|
||||
if (displayNameCompare !== 0) {
|
||||
return displayNameCompare;
|
||||
}
|
||||
return left.id.localeCompare(right.id);
|
||||
});
|
||||
const anonymizedResources = anonymizeResources(filteredResources, directory).sort(
|
||||
(left, right) => {
|
||||
const displayNameCompare = left.displayName.localeCompare(right.displayName);
|
||||
if (displayNameCompare !== 0) {
|
||||
return displayNameCompare;
|
||||
}
|
||||
return left.id.localeCompare(right.id);
|
||||
},
|
||||
);
|
||||
|
||||
const total = anonymizedResources.length;
|
||||
const afterCursor = parsedCursor
|
||||
@@ -318,12 +326,7 @@ export async function listResourceDirectoryEntries(
|
||||
const parsedCursor = parseResourceCursor(cursor);
|
||||
type WhereClause = Record<string, unknown>;
|
||||
const andClauses: WhereClause[] = [];
|
||||
const chapterFilters = Array.from(
|
||||
new Set([
|
||||
...(chapter ? [chapter] : []),
|
||||
...(chapters ?? []),
|
||||
]),
|
||||
);
|
||||
const chapterFilters = Array.from(new Set([...(chapter ? [chapter] : []), ...(chapters ?? [])]));
|
||||
|
||||
if (!eids) {
|
||||
andClauses.push({ isActive });
|
||||
@@ -569,11 +572,7 @@ export async function resolveResourceIdentifierSnapshot(
|
||||
return { error: `Resource not found: ${identifier}` } as const;
|
||||
}
|
||||
|
||||
await assertCanReadResource(
|
||||
ctx,
|
||||
resource.id,
|
||||
forbiddenMessage,
|
||||
);
|
||||
await assertCanReadResource(ctx, resource.id, forbiddenMessage);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user