Skip to content

Commit

Permalink
build: explicit file extensions for imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Mufti Azan Farooqi committed Nov 29, 2022
1 parent 36a26f0 commit 29da432
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/client-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const DEFAULT_BASE_URL = "https://api.cryptlex.com/v3";
* Defines a set of options for the CryptlexWebApiClient.
* @constructor
*/
export class CryptlexWebApiClientOptions {
export default class CryptlexWebApiClientOptions {
/** The accessToken for accessing the Cryptlex Web API */
accessToken: string;

Expand Down
18 changes: 9 additions & 9 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import axios, { AxiosInstance } from "axios";
import { CryptlexWebApiClientOptions } from "./client-options";
import { ApiResponse } from "./services/api.types";
import { LicenseService } from "./services/license.service";
import CryptlexWebApiClientOptions from "./client-options.js";

import { ApiResponse } from "./services/api.types.js";
import { LicenseService } from "./services/license.service.js";
import {
LicenseCreateRequest,
LicenseListQueryParameters,
LicenseResponse,
LicenseUpdateRequest,
} from "./services/license.types";
import { UserService } from "./services/user.service";
} from "./services/license.types.js";
import { UserService } from "./services/user.service.js";
import {
UserCreateRequest,
UserListQueryParameters,
UserPasswordUpdateRequest,
UserResponse,
UserUpdateRequest,
} from "./services/user.types";
} from "./services/user.types.js";

/**
* The CryptlexWebApiClient class contains the functions to communicate with the Cryptlex Web API.
* Creating instances of this class require passing a CryptlexWebApiClientOptions instance.
*
*/
export class CryptlexWebApiClient {
export default class CryptlexWebApiClient {
/**
* HttpClient to communicate with the Cryptlex Web API
*/
Expand Down Expand Up @@ -174,7 +174,7 @@ export class CryptlexWebApiClient {
* Generates the reset password token (url encoded) for users with 'user' role.
* It should only be used for custom portals to implement password reset.
*
* @param id Unique identifier for the user
* @param {string} id Unique identifier for the user
* @returns {Promise<ApiResponse<any>>} Promise that resolves to the Web API response
*/
generateResetPasswordToken(id: string) {
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { CryptlexWebApiClient } from "./client";
export { CryptlexWebApiClientOptions } from "./client-options";
import CryptlexWebApiClient from "./client.js";
import CryptlexWebApiClientOptions from "./client-options.js";

export { CryptlexWebApiClient, CryptlexWebApiClientOptions };
5 changes: 2 additions & 3 deletions src/services/api.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { AxiosInstance } from "axios";
import { ApiResponse } from "./api.types";
import { QueryParmeters, RequestBody } from "./api.types";
import { ApiResponse, QueryParmeters, RequestBody } from "./api.types.js";

/**
* Generic functions to create requests to the Cryptlex Web API. Functions from this class are not to be used directly by the end-user.
*/
export class ApiService {
export default class ApiService {
/**
* Get paginated data from the API
* @param {AxiosInstance} httpClient AxiosInstance
Expand Down
6 changes: 3 additions & 3 deletions src/services/license.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {
LicenseCreateRequest,
LicenseListQueryParameters,
LicenseUpdateRequest,
} from "./license.types";
import { ApiResponse } from "./api.types";
} from "./license.types.js";
import { ApiResponse } from "./api.types.js";
import { AxiosInstance } from "axios";
import { ApiService } from "./api.service";
import ApiService from "./api.service.js";

/**
* Function implementations for actions on Licenses. Not to be accessed directly by the end-user.
Expand Down
18 changes: 12 additions & 6 deletions src/services/license.types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { MetadataResponse, MetadataRequest } from "./metadata.types";
import { MetadataResponse, MetadataRequest } from "./metadata.types.js";
import {
MeterAttributeResponse,
MeterAttributesRequest,
} from "./meter-attribute.types";
import { UserResponse } from "./user.types";
} from "./meter-attribute.types.js";
import { UserResponse } from "./user.types.js";

/**
* String literals defining license.fingerprintMatchingStrategy
Expand Down Expand Up @@ -117,7 +117,7 @@ export type LicenseResponse = {
*/
maxAllowedReleaseVersion?: string;
/** List of tags. <= 5 items */
tags: string[];
tags?: string[];

/**
* List of metdata key / value pairs.
Expand Down Expand Up @@ -181,7 +181,10 @@ type LicenseReadOnlyProperties =
export type LicenseCreateRequest = Omit<
LicenseResponse,
LicenseReadOnlyProperties | "metadata" | "meterAttributes"
> & { meterAttributes: MeterAttributesRequest[]; metadata: MetadataRequest[] };
> & {
meterAttributes?: MeterAttributesRequest[];
metadata?: MetadataRequest[];
};

/**
* Request object schema for updating license.
Expand All @@ -198,7 +201,10 @@ export type LicenseUpdateRequest = Omit<
| "validity"
| "metadata"
| "meterAttributes"
> & { meterAttributes: MeterAttributesRequest[]; metadata: MetadataRequest[] };
> & {
meterAttributes?: MeterAttributesRequest[];
metadata?: MetadataRequest[];
};

/**
* Supported query parameters for listing licenses
Expand Down
7 changes: 3 additions & 4 deletions src/services/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { AxiosInstance } from "axios";
import { ApiResponse } from "./api.types";
import { ApiService } from "./api.service";
import ApiService from "./api.service.js";
import { ApiResponse } from "./api.types.js";
import {
UserResponse,
UserListQueryParameters,
UserPasswordUpdateRequest,
UserCreateRequest,
UserUpdateRequest,
} from "./user.types";
} from "./user.types.js";

/**
* Function implementations for actions on Users. Not to be accessed directly by the end-user.
Expand Down
8 changes: 4 additions & 4 deletions src/services/user.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MetadataResponse, MetadataRequest } from "./metadata.types";
import { MetadataResponse, MetadataRequest } from "./metadata.types.js";

/**
* Schema for User
Expand All @@ -25,9 +25,9 @@ export type UserResponse = {
/** True if Google SSO is enabled for this user */
googleSsoEnabled: boolean;
/** True is user is allowed access to the Customer Portal */
allowCustomerPortalAccess: boolean;
allowCustomerPortalAccess?: boolean;
/** Role of the user */
role?: string;
role: string;
/** Date of last login */
lastLoginAt?: string;
/** Time when user was last active */
Expand Down Expand Up @@ -56,7 +56,7 @@ export type UserCreateRequest = Omit<
> & {
/** Password of the user */
password: string;
metadata: MetadataRequest[];
metadata?: MetadataRequest[];
};

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

0 comments on commit 29da432

Please sign in to comment.