Skip to content

Commit 29da432

Browse files
author
Mufti Azan Farooqi
committed
build: explicit file extensions for imports
microsoft/TypeScript#40878 (comment)
1 parent 36a26f0 commit 29da432

8 files changed

+38
-32
lines changed

src/client-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const DEFAULT_BASE_URL = "https://api.cryptlex.com/v3";
44
* Defines a set of options for the CryptlexWebApiClient.
55
* @constructor
66
*/
7-
export class CryptlexWebApiClientOptions {
7+
export default class CryptlexWebApiClientOptions {
88
/** The accessToken for accessing the Cryptlex Web API */
99
accessToken: string;
1010

src/client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import axios, { AxiosInstance } from "axios";
2-
import { CryptlexWebApiClientOptions } from "./client-options";
3-
import { ApiResponse } from "./services/api.types";
4-
import { LicenseService } from "./services/license.service";
2+
import CryptlexWebApiClientOptions from "./client-options.js";
3+
4+
import { ApiResponse } from "./services/api.types.js";
5+
import { LicenseService } from "./services/license.service.js";
56
import {
67
LicenseCreateRequest,
78
LicenseListQueryParameters,
89
LicenseResponse,
910
LicenseUpdateRequest,
10-
} from "./services/license.types";
11-
import { UserService } from "./services/user.service";
11+
} from "./services/license.types.js";
12+
import { UserService } from "./services/user.service.js";
1213
import {
1314
UserCreateRequest,
1415
UserListQueryParameters,
15-
UserPasswordUpdateRequest,
1616
UserResponse,
1717
UserUpdateRequest,
18-
} from "./services/user.types";
18+
} from "./services/user.types.js";
1919

2020
/**
2121
* The CryptlexWebApiClient class contains the functions to communicate with the Cryptlex Web API.
2222
* Creating instances of this class require passing a CryptlexWebApiClientOptions instance.
2323
*
2424
*/
25-
export class CryptlexWebApiClient {
25+
export default class CryptlexWebApiClient {
2626
/**
2727
* HttpClient to communicate with the Cryptlex Web API
2828
*/
@@ -174,7 +174,7 @@ export class CryptlexWebApiClient {
174174
* Generates the reset password token (url encoded) for users with 'user' role.
175175
* It should only be used for custom portals to implement password reset.
176176
*
177-
* @param id Unique identifier for the user
177+
* @param {string} id Unique identifier for the user
178178
* @returns {Promise<ApiResponse<any>>} Promise that resolves to the Web API response
179179
*/
180180
generateResetPasswordToken(id: string) {

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
export { CryptlexWebApiClient } from "./client";
2-
export { CryptlexWebApiClientOptions } from "./client-options";
1+
import CryptlexWebApiClient from "./client.js";
2+
import CryptlexWebApiClientOptions from "./client-options.js";
3+
4+
export { CryptlexWebApiClient, CryptlexWebApiClientOptions };

src/services/api.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { AxiosInstance } from "axios";
2-
import { ApiResponse } from "./api.types";
3-
import { QueryParmeters, RequestBody } from "./api.types";
2+
import { ApiResponse, QueryParmeters, RequestBody } from "./api.types.js";
43

54
/**
65
* Generic functions to create requests to the Cryptlex Web API. Functions from this class are not to be used directly by the end-user.
76
*/
8-
export class ApiService {
7+
export default class ApiService {
98
/**
109
* Get paginated data from the API
1110
* @param {AxiosInstance} httpClient AxiosInstance

src/services/license.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import {
33
LicenseCreateRequest,
44
LicenseListQueryParameters,
55
LicenseUpdateRequest,
6-
} from "./license.types";
7-
import { ApiResponse } from "./api.types";
6+
} from "./license.types.js";
7+
import { ApiResponse } from "./api.types.js";
88
import { AxiosInstance } from "axios";
9-
import { ApiService } from "./api.service";
9+
import ApiService from "./api.service.js";
1010

1111
/**
1212
* Function implementations for actions on Licenses. Not to be accessed directly by the end-user.

src/services/license.types.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { MetadataResponse, MetadataRequest } from "./metadata.types";
1+
import { MetadataResponse, MetadataRequest } from "./metadata.types.js";
22
import {
33
MeterAttributeResponse,
44
MeterAttributesRequest,
5-
} from "./meter-attribute.types";
6-
import { UserResponse } from "./user.types";
5+
} from "./meter-attribute.types.js";
6+
import { UserResponse } from "./user.types.js";
77

88
/**
99
* String literals defining license.fingerprintMatchingStrategy
@@ -117,7 +117,7 @@ export type LicenseResponse = {
117117
*/
118118
maxAllowedReleaseVersion?: string;
119119
/** List of tags. <= 5 items */
120-
tags: string[];
120+
tags?: string[];
121121

122122
/**
123123
* List of metdata key / value pairs.
@@ -181,7 +181,10 @@ type LicenseReadOnlyProperties =
181181
export type LicenseCreateRequest = Omit<
182182
LicenseResponse,
183183
LicenseReadOnlyProperties | "metadata" | "meterAttributes"
184-
> & { meterAttributes: MeterAttributesRequest[]; metadata: MetadataRequest[] };
184+
> & {
185+
meterAttributes?: MeterAttributesRequest[];
186+
metadata?: MetadataRequest[];
187+
};
185188

186189
/**
187190
* Request object schema for updating license.
@@ -198,7 +201,10 @@ export type LicenseUpdateRequest = Omit<
198201
| "validity"
199202
| "metadata"
200203
| "meterAttributes"
201-
> & { meterAttributes: MeterAttributesRequest[]; metadata: MetadataRequest[] };
204+
> & {
205+
meterAttributes?: MeterAttributesRequest[];
206+
metadata?: MetadataRequest[];
207+
};
202208

203209
/**
204210
* Supported query parameters for listing licenses

src/services/user.service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { AxiosInstance } from "axios";
2-
import { ApiResponse } from "./api.types";
3-
import { ApiService } from "./api.service";
2+
import ApiService from "./api.service.js";
3+
import { ApiResponse } from "./api.types.js";
44
import {
55
UserResponse,
66
UserListQueryParameters,
7-
UserPasswordUpdateRequest,
87
UserCreateRequest,
98
UserUpdateRequest,
10-
} from "./user.types";
9+
} from "./user.types.js";
1110

1211
/**
1312
* Function implementations for actions on Users. Not to be accessed directly by the end-user.

src/services/user.types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MetadataResponse, MetadataRequest } from "./metadata.types";
1+
import { MetadataResponse, MetadataRequest } from "./metadata.types.js";
22

33
/**
44
* Schema for User
@@ -25,9 +25,9 @@ export type UserResponse = {
2525
/** True if Google SSO is enabled for this user */
2626
googleSsoEnabled: boolean;
2727
/** True is user is allowed access to the Customer Portal */
28-
allowCustomerPortalAccess: boolean;
28+
allowCustomerPortalAccess?: boolean;
2929
/** Role of the user */
30-
role?: string;
30+
role: string;
3131
/** Date of last login */
3232
lastLoginAt?: string;
3333
/** Time when user was last active */
@@ -56,7 +56,7 @@ export type UserCreateRequest = Omit<
5656
> & {
5757
/** Password of the user */
5858
password: string;
59-
metadata: MetadataRequest[];
59+
metadata?: MetadataRequest[];
6060
};
6161

6262
export type UserUpdateRequest = Omit<UserCreateRequest, "password">;

0 commit comments

Comments
 (0)