Skip to content

Commit 5be104a

Browse files
authored
Fix types around Terms (#4674)
1 parent c93128e commit 5be104a

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/@types/partials.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,39 @@ export interface IUsageLimit {
6565
// eslint-disable-next-line camelcase
6666
admin_contact?: string;
6767
}
68+
69+
/**
70+
* A policy name & url in a specific internationalisation
71+
* @see https://spec.matrix.org/v1.13/identity-service-api/#get_matrixidentityv2terms_response-200_internationalised-policy
72+
*/
73+
export interface InternationalisedPolicy {
74+
name: string;
75+
url: string;
76+
}
77+
78+
/**
79+
* A versioned policy with internationalised variants
80+
* @see https://spec.matrix.org/v1.13/identity-service-api/#get_matrixidentityv2terms_response-200_policy-object
81+
*/
82+
export interface Policy {
83+
/**
84+
* The version for the policy.
85+
* There are no requirements on what this might be and could be “alpha”, semantically versioned, or arbitrary.
86+
*/
87+
version: string;
88+
/**
89+
* The policy information for the specified language.
90+
* @remarks the type has to include a union with string due to limitations in the type system.
91+
*/
92+
[lang: string]: InternationalisedPolicy | string;
93+
}
94+
95+
/**
96+
* Response from the Terms API for Identity servers
97+
* @see https://spec.matrix.org/v1.13/identity-service-api/#get_matrixidentityv2terms
98+
*/
99+
export interface Terms {
100+
policies: {
101+
[policyName: string]: Policy;
102+
};
103+
}

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ import {
157157
IdServerUnbindResult,
158158
JoinRule,
159159
Preset,
160+
Terms,
160161
Visibility,
161162
} from "./@types/partials.ts";
162163
import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper.ts";
@@ -10036,8 +10037,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
1003610037
return this.http.authedRequest(Method.Get, path, params);
1003710038
}
1003810039

10039-
public getTerms(serviceType: SERVICE_TYPES, baseUrl: string): Promise<any> {
10040-
// TODO: Types
10040+
public getTerms(serviceType: SERVICE_TYPES, baseUrl: string): Promise<Terms> {
1004110041
const url = this.termsUrlForService(serviceType, baseUrl);
1004210042
return this.http.requestOtherUrl(Method.Get, url);
1004310043
}

0 commit comments

Comments
 (0)