Skip to content

Commit

Permalink
Make CustomField singular
Browse files Browse the repository at this point in the history
  • Loading branch information
NSeydoux committed Dec 9, 2024
1 parent dadf724 commit 1b29687
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/common/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { DataFactory } from "n3";
import type { AccessGrantGConsent } from "../gConsent/type/AccessGrant";
import type { AccessModes } from "../type/AccessModes";
import { INHERIT, TYPE, XSD_BOOLEAN, acl, gc, ldp } from "./constants";
import type { CustomFields } from "../type/CustomFields";
import type { CustomField } from "../type/CustomFields";

Check failure on line 40 in src/common/getters.ts

View workflow job for this annotation

GitHub Actions / lint / lint

'CustomField' is defined but never used

const { namedNode, defaultGraph, quad, literal } = DataFactory;

Expand Down
4 changes: 2 additions & 2 deletions src/gConsent/manage/approveAccessRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ import { getBaseAccess } from "../util/getBaseAccessVerifiableCredential";
import { initializeGrantParameters } from "../util/initializeGrantParameters";
import { getGrantBody, issueAccessVc } from "../util/issueAccessVc";
import { toVcDataset } from "../../common/util/toVcDataset";
import type { CustomFields } from "../../type/CustomFields";
import type { CustomField } from "../../type/CustomFields";

export type ApproveAccessRequestOverrides = Omit<
Omit<AccessGrantParameters, "status">,
"expirationDate"
> & { expirationDate?: Date | null; customFields?: Set<CustomFields> };
> & { expirationDate?: Date | null; customFields?: Set<CustomField> };

/**
* Internal function. This is a stopgap until we have proper JSON-LD parsing.
Expand Down
12 changes: 6 additions & 6 deletions src/gConsent/request/issueAccessRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type {
IssueAccessRequestParameters,
} from "../type/IssueAccessRequestParameters";
import type { AccessRequest } from "../type/AccessRequest";
import { type CustomFields, toJson } from "../../type/CustomFields";
import { type CustomField, toJson } from "../../type/CustomFields";
import {
isAccessRequest,
isRdfjsAccessRequest,
Expand Down Expand Up @@ -86,7 +86,7 @@ async function issueAccessRequest(
params: IssueAccessRequestParameters,
options: AccessBaseOptions & {
returnLegacyJsonld: false;
customFields?: Set<CustomFields>;
customFields?: Set<CustomField>;
},
): Promise<DatasetWithId>;
/**
Expand All @@ -102,7 +102,7 @@ async function issueAccessRequest(
params: IssueAccessRequestParameters,
options?: AccessBaseOptions & {
returnLegacyJsonld?: true;
customFields?: Set<CustomFields>;
customFields?: Set<CustomField>;
},
): Promise<AccessRequest>;
/**
Expand All @@ -118,7 +118,7 @@ async function issueAccessRequest(
params: IssueAccessRequestParameters,
options?: AccessBaseOptions & {
returnLegacyJsonld?: boolean;
customFields?: Set<CustomFields>;
customFields?: Set<CustomField>;
},
): Promise<DatasetWithId>;
/**
Expand All @@ -128,13 +128,13 @@ async function issueAccessRequest(
params: DeprecatedAccessRequestParameters,
options?: AccessBaseOptions & {
returnLegacyJsonld?: boolean;
customFields?: Set<CustomFields>;
customFields?: Set<CustomField>;
},
): Promise<AccessRequest>;
async function issueAccessRequest(
params: IssueAccessRequestParameters,
options: AccessBaseOptions & {
customFields?: Set<CustomFields>;
customFields?: Set<CustomField>;
returnLegacyJsonld?: boolean;
} = {},
): Promise<DatasetWithId> {
Expand Down
4 changes: 2 additions & 2 deletions src/gConsent/util/issueAccessVc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { getAccessApiEndpoint } from "../discover/getAccessApiEndpoint";
import { accessToResourceAccessModeArray } from "./accessToResourceAccessModeArray";
import { isBaseRequest } from "../guard/isBaseRequest";
import type { AccessCredentialType } from "../type/AccessCredentialType";
import type { CustomFields } from "../../type/CustomFields";
import type { CustomField } from "../../type/CustomFields";

function getGConsentAttributes(
params: AccessRequestParameters,
Expand Down Expand Up @@ -147,7 +147,7 @@ function getBaseBody(

export function getRequestBody(
params: AccessRequestParameters,
options?: Partial<{ customFields: Record<string, CustomFields["value"]> }>,
options?: Partial<{ customFields: Record<string, CustomField["value"]> }>,
): AccessRequestBody {
const base = getBaseBody(params, "BaseRequestBody") as AccessRequestBody;
if (typeof options?.customFields === "object") {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type { AccessParameters } from "./gConsent/manage/getAccessGrantAll";

export type { AccessGrantAny } from "./type/AccessGrant";
export type { AccessModes } from "./type/AccessModes";
export type { CustomFields } from "./type/CustomFields";
export type { CustomField as CustomFields } from "./type/CustomFields";
export type { FetchOptions } from "./type/FetchOptions";
export type { RedirectOptions } from "./type/RedirectOptions";

Expand Down
8 changes: 4 additions & 4 deletions src/type/CustomFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

export type CustomFields = {
export type CustomField = {
/* The custom field name (this must be a URL). */
key: URL;
/* The custom field value (this must be a literal). */
Expand All @@ -33,8 +33,8 @@ export type CustomFields = {
* @hidden
*/
export const toJson = (
c: Set<CustomFields> = new Set(),
): Record<string, CustomFields["value"]> => {
c: Set<CustomField> = new Set(),
): Record<string, CustomField["value"]> => {
return (
Array.from(c)
// Check that all the provided custom fields match the expected type,
Expand All @@ -50,7 +50,7 @@ export const toJson = (
// Collapse all the JSON object entries into a single object.
.reduce(
(acc, cur) => Object.assign(acc, cur),
{} as Record<string, CustomFields["value"]>,
{} as Record<string, CustomField["value"]>,
)
);
};

0 comments on commit 1b29687

Please sign in to comment.