Merge pull request #1 from StevanFreeborn/fix/import-issue

Fix: ESM Import Issue
This commit is contained in:
Stevan Freeborn
2023-02-21 13:39:27 -06:00
committed by GitHub
45 changed files with 397 additions and 368 deletions
+2 -1
View File
@@ -3,4 +3,5 @@
coverage/
dist/
node_modules/
.github/
.github/
scripts/
+10 -4
View File
@@ -3,7 +3,7 @@
"browser": true,
"es2021": true
},
"plugins": ["@typescript-eslint", "mocha"],
"plugins": ["@typescript-eslint", "mocha", "import"],
"extends": [
"standard-with-typescript",
"eslint:recommended",
@@ -13,11 +13,16 @@
],
"overrides": [
{
"files": ["tests/**/*.spec.ts", "integrationTests/**/*.spec.ts"],
"files": [
"tests/**/*.spec.ts",
"integrationTests/**/*.spec.ts",
"integrationTests/utils/**"
],
"rules": {
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"no-new": "off"
"no-new": "off",
"import/extensions": "off"
}
}
],
@@ -30,6 +35,7 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
"@typescript-eslint/no-useless-constructor": "off",
"@typescript-eslint/no-extraneous-class": "off"
"@typescript-eslint/no-extraneous-class": "off",
"import/extensions": ["error", "always", { "ignorePackages": true }]
}
}
+8 -5
View File
@@ -32,12 +32,15 @@
"License.txt",
"package.json"
],
"main": "dist/cjs/index.js",
"types": "dist/types/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"default": "./dist/cjs/index.js"
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
}
},
"scripts": {
"clean": "rimraf dist",
@@ -45,7 +48,7 @@
"lint-fix": "eslint --fix --ignore-path .eslintignore --ext .js,.ts . --max-warnings=0",
"format-staged": "pretty-quick --staged",
"format": "pretty-quick",
"build": "npm run tests && npm run clean && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json",
"build": "npm run tests && npm run clean && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json && node ./scripts/create_dist_package_json.js",
"test:unit": "mocha -r ts-node/register",
"test:integration": "mocha -r ts-node/register -r integrationTests/mochaRootHooks.ts",
"tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts",
+15
View File
@@ -0,0 +1,15 @@
const fs = require('fs');
const path = require('path');
const esmPackageJson = `{
"type": "module"
}`;
const cjsPackageJson = `{
"type": "commonjs"
}`;
const parentDir = path.resolve(__dirname, '..');
fs.writeFileSync(path.join(parentDir, 'dist/esm/package.json'), esmPackageJson);
fs.writeFileSync(path.join(parentDir, 'dist/cjs/package.json'), cjsPackageJson);
+64 -65
View File
@@ -1,73 +1,72 @@
// Models
import { ApiResponse } from './models/ApiResponse';
import { App } from './models/App';
import { Attachment } from './models/Attachment';
import { AttachmentListRecordValue } from './models/AttachmentListRecordValue';
import { CollectionResponse } from './models/CollectionResponse';
import { CreatedWithIdResponse } from './models/CreatedWithIdResponse';
import { DateRecordValue } from './models/DateRecordValue';
import { DecimalRecordValue } from './models/DecimalRecordValue';
import { Delegate } from './models/Delegate';
import { DelegateListRecordValue } from './models/DelegateListRecordValue';
import { EndpointFactory } from './models/EndpointFactory';
import { Field } from './models/Field';
import { File } from './models/File';
import { FileInfo } from './models/FileInfo';
import { FileListRecordValue } from './models/FileListRecordValue';
import { FormulaField } from './models/FormulaField';
import { GetPagedAppsResponse } from './models/GetPagedAppsResponse';
import { GetPagedFieldsResponse } from './models/GetPagedFieldsResponse';
import { GetPagedRecordsResponse } from './models/GetPagedRecordsResponse';
import { GetPagedReportsResponse } from './models/GetPagedReportsResponse';
import { GetRecordRequest } from './models/GetRecordRequest';
import { GetRecordsByAppIdRequest } from './models/GetRecordsByAppIdRequest';
import { GetRecordsRequest } from './models/GetRecordsRequest';
import { GuidListRecordValue } from './models/GuidListRecordValue';
import { GuidRecordValue } from './models/GuidRecordValue';
import { IntegerListRecordValue } from './models/IntegerListRecordValue';
import { IntegerRecordValue } from './models/IntegerRecordValue';
import { ListField } from './models/ListField';
import { ListItemRequest } from './models/ListItemRequest';
import { ListItemResponse } from './models/ListItemResponse';
import { ListValue } from './models/ListValue';
import { OnspringClient } from './models/OnspringClient';
import { PagedResponse } from './models/PagedResponse';
import { PagingRequest } from './models/PagingRequest';
import { QueryFilter } from './models/QueryFilter';
import { QueryRecordsRequest } from './models/QueryRecordsRequest';
import { Record } from './models/Record';
import { RecordValue } from './models/RecordValue';
import { ReferenceField } from './models/ReferenceField';
import { Report } from './models/Report';
import { ReportData } from './models/ReportData';
import { Row } from './models/Row';
import { SaveFileRequest } from './models/SaveFileRequest';
import { SaveRecordRequest } from './models/SaveRecordRequest';
import { SaveRecordResponse } from './models/SaveRecordResponse';
import { ScoringGroup } from './models/ScoringGroup';
import { ScoringGroupListRecordValue } from './models/ScoringGroupListRecordValue';
import { StringListRecordValue } from './models/StringListRecordValue';
import { StringRecordValue } from './models/StringRecordValue';
import { TimeSpanData } from './models/TimeSpanData';
import { TimeSpanRecordValue } from './models/TimeSpanRecordValue';
import { ApiResponse } from './models/ApiResponse.js';
import { App } from './models/App.js';
import { Attachment } from './models/Attachment.js';
import { AttachmentListRecordValue } from './models/AttachmentListRecordValue.js';
import { CollectionResponse } from './models/CollectionResponse.js';
import { CreatedWithIdResponse } from './models/CreatedWithIdResponse.js';
import { DateRecordValue } from './models/DateRecordValue.js';
import { DecimalRecordValue } from './models/DecimalRecordValue.js';
import { Delegate } from './models/Delegate.js';
import { DelegateListRecordValue } from './models/DelegateListRecordValue.js';
import { EndpointFactory } from './models/EndpointFactory.js';
import { Field } from './models/Field.js';
import { File } from './models/File.js';
import { FileInfo } from './models/FileInfo.js';
import { FileListRecordValue } from './models/FileListRecordValue.js';
import { FormulaField } from './models/FormulaField.js';
import { GetPagedAppsResponse } from './models/GetPagedAppsResponse.js';
import { GetPagedFieldsResponse } from './models/GetPagedFieldsResponse.js';
import { GetPagedRecordsResponse } from './models/GetPagedRecordsResponse.js';
import { GetPagedReportsResponse } from './models/GetPagedReportsResponse.js';
import { GetRecordRequest } from './models/GetRecordRequest.js';
import { GetRecordsByAppIdRequest } from './models/GetRecordsByAppIdRequest.js';
import { GetRecordsRequest } from './models/GetRecordsRequest.js';
import { GuidListRecordValue } from './models/GuidListRecordValue.js';
import { GuidRecordValue } from './models/GuidRecordValue.js';
import { IntegerListRecordValue } from './models/IntegerListRecordValue.js';
import { IntegerRecordValue } from './models/IntegerRecordValue.js';
import { ListField } from './models/ListField.js';
import { ListItemRequest } from './models/ListItemRequest.js';
import { ListItemResponse } from './models/ListItemResponse.js';
import { ListValue } from './models/ListValue.js';
import { OnspringClient } from './models/OnspringClient.js';
import { PagedResponse } from './models/PagedResponse.js';
import { PagingRequest } from './models/PagingRequest.js';
import { QueryFilter } from './models/QueryFilter.js';
import { QueryRecordsRequest } from './models/QueryRecordsRequest.js';
import { Record } from './models/Record.js';
import { RecordValue } from './models/RecordValue.js';
import { ReferenceField } from './models/ReferenceField.js';
import { Report } from './models/Report.js';
import { ReportData } from './models/ReportData.js';
import { Row } from './models/Row.js';
import { SaveFileRequest } from './models/SaveFileRequest.js';
import { SaveRecordRequest } from './models/SaveRecordRequest.js';
import { SaveRecordResponse } from './models/SaveRecordResponse.js';
import { ScoringGroup } from './models/ScoringGroup.js';
import { ScoringGroupListRecordValue } from './models/ScoringGroupListRecordValue.js';
import { StringListRecordValue } from './models/StringListRecordValue.js';
import { StringRecordValue } from './models/StringRecordValue.js';
import { TimeSpanData } from './models/TimeSpanData.js';
import { TimeSpanRecordValue } from './models/TimeSpanRecordValue.js';
// Enums
import { DataFormat } from './enums/DataFormat';
import { DelegateType } from './enums/DelegateType';
import { FieldStatus } from './enums/FieldStatus';
import { FieldType } from './enums/FieldType';
import { FileStorageSite } from './enums/FileStorageSite';
import { FilterOperators } from './enums/FilterOperators';
import { FormulaOutputType } from './enums/FormulaOutputType';
import { HttpStatusCode } from './enums/HttpStatusCode';
import { Multiplicity } from './enums/Multiplicity';
import { RecordValueType } from './enums/RecordValueType';
import { ReportDataType } from './enums/ReportDataType';
import { TimeSpanIncrement } from './enums/TimeSpanIncrement';
import { TimeSpanRecurrenceType } from './enums/TimeSpanRecurrenceType';
import { DataFormat } from './enums/DataFormat.js';
import { DelegateType } from './enums/DelegateType.js';
import { FieldStatus } from './enums/FieldStatus.js';
import { FieldType } from './enums/FieldType.js';
import { FileStorageSite } from './enums/FileStorageSite.js';
import { FilterOperators } from './enums/FilterOperators.js';
import { FormulaOutputType } from './enums/FormulaOutputType.js';
import { HttpStatusCode } from './enums/HttpStatusCode.js';
import { Multiplicity } from './enums/Multiplicity.js';
import { RecordValueType } from './enums/RecordValueType.js';
import { ReportDataType } from './enums/ReportDataType.js';
import { TimeSpanIncrement } from './enums/TimeSpanIncrement.js';
import { TimeSpanRecurrenceType } from './enums/TimeSpanRecurrenceType.js';
export {
// Models
ApiResponse,
App,
Attachment,
+57 -57
View File
@@ -1,51 +1,51 @@
import { type AxiosResponse } from 'axios';
import { DelegateType } from '../enums/DelegateType';
import { FieldStatus } from '../enums/FieldStatus';
import { FieldType } from '../enums/FieldType';
import { FileStorageSite } from '../enums/FileStorageSite';
import { FormulaOutputType } from '../enums/FormulaOutputType';
import { Multiplicity } from '../enums/Multiplicity';
import { RecordValueType } from '../enums/RecordValueType';
import { TimeSpanIncrement } from '../enums/TimeSpanIncrement';
import { TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType';
import { App } from './App';
import { Attachment } from './Attachment';
import { AttachmentListRecordValue } from './AttachmentListRecordValue';
import { CollectionResponse } from './CollectionResponse';
import { CreatedWithIdResponse } from './CreatedWithIdResponse';
import { DateRecordValue } from './DateRecordValue';
import { DecimalRecordValue } from './DecimalRecordValue';
import { Delegate } from './Delegate';
import { DelegateListRecordValue } from './DelegateListRecordValue';
import { Field } from './Field';
import { File } from './File';
import { FileInfo } from './FileInfo';
import { FileListRecordValue } from './FileListRecordValue';
import { FormulaField } from './FormulaField';
import { GetPagedAppsResponse } from './GetPagedAppsResponse';
import { GetPagedFieldsResponse } from './GetPagedFieldsResponse';
import { GetPagedRecordsResponse } from './GetPagedRecordsResponse';
import { GetPagedReportsResponse } from './GetPagedReportsResponse';
import { GuidListRecordValue } from './GuidListRecordValue';
import { GuidRecordValue } from './GuidRecordValue';
import { IntegerListRecordValue } from './IntegerListRecordValue';
import { IntegerRecordValue } from './IntegerRecordValue';
import { ListField } from './ListField';
import { ListItemResponse } from './ListItemResponse';
import { ListValue } from './ListValue';
import { Record } from './Record';
import { ReferenceField } from './ReferenceField';
import { Report } from './Report';
import { ReportData } from './ReportData';
import { Row } from './Row';
import { ScoringGroup } from './ScoringGroup';
import { ScoringGroupListRecordValue } from './ScoringGroupListRecordValue';
import { StringListRecordValue } from './StringListRecordValue';
import { StringRecordValue } from './StringRecordValue';
import { TimeSpanData } from './TimeSpanData';
import { TimeSpanRecordValue } from './TimeSpanRecordValue';
import { type RecordValue } from './RecordValue';
import { SaveRecordResponse } from './SaveRecordResponse';
import { DelegateType } from '../enums/DelegateType.js';
import { FieldStatus } from '../enums/FieldStatus.js';
import { FieldType } from '../enums/FieldType.js';
import { FileStorageSite } from '../enums/FileStorageSite.js';
import { FormulaOutputType } from '../enums/FormulaOutputType.js';
import { Multiplicity } from '../enums/Multiplicity.js';
import { RecordValueType } from '../enums/RecordValueType.js';
import { TimeSpanIncrement } from '../enums/TimeSpanIncrement.js';
import { TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType.js';
import { App } from './App.js';
import { Attachment } from './Attachment.js';
import { AttachmentListRecordValue } from './AttachmentListRecordValue.js';
import { CollectionResponse } from './CollectionResponse.js';
import { CreatedWithIdResponse } from './CreatedWithIdResponse.js';
import { DateRecordValue } from './DateRecordValue.js';
import { DecimalRecordValue } from './DecimalRecordValue.js';
import { Delegate } from './Delegate.js';
import { DelegateListRecordValue } from './DelegateListRecordValue.js';
import { Field } from './Field.js';
import { File } from './File.js';
import { FileInfo } from './FileInfo.js';
import { FileListRecordValue } from './FileListRecordValue.js';
import { FormulaField } from './FormulaField.js';
import { GetPagedAppsResponse } from './GetPagedAppsResponse.js';
import { GetPagedFieldsResponse } from './GetPagedFieldsResponse.js';
import { GetPagedRecordsResponse } from './GetPagedRecordsResponse.js';
import { GetPagedReportsResponse } from './GetPagedReportsResponse.js';
import { GuidListRecordValue } from './GuidListRecordValue.js';
import { GuidRecordValue } from './GuidRecordValue.js';
import { IntegerListRecordValue } from './IntegerListRecordValue.js';
import { IntegerRecordValue } from './IntegerRecordValue.js';
import { ListField } from './ListField.js';
import { ListItemResponse } from './ListItemResponse.js';
import { ListValue } from './ListValue.js';
import { Record } from './Record.js';
import { type RecordValue } from './RecordValue.js';
import { ReferenceField } from './ReferenceField.js';
import { Report } from './Report.js';
import { ReportData } from './ReportData.js';
import { Row } from './Row.js';
import { SaveRecordResponse } from './SaveRecordResponse.js';
import { ScoringGroup } from './ScoringGroup.js';
import { ScoringGroupListRecordValue } from './ScoringGroupListRecordValue.js';
import { StringListRecordValue } from './StringListRecordValue.js';
import { StringRecordValue } from './StringRecordValue.js';
import { TimeSpanData } from './TimeSpanData.js';
import { TimeSpanRecordValue } from './TimeSpanRecordValue.js';
/**
* @class ApiResponse - A generic response object for API requests.
@@ -92,17 +92,17 @@ export class ApiResponse<T> {
public asGetPagedAppsResponseType(): ApiResponse<GetPagedAppsResponse> {
const apiResponse = this as ApiResponse<any>;
const apps = apiResponse.data.items.map((item: any) => {
return new App(item.href, item.id, item.name);
});
const apps = apiResponse.data.items.map((item: any) => {
return new App(item.href, item.id, item.name);
});
const getAppsPagedResponse = new GetPagedAppsResponse(
apps,
apiResponse.data.pageNumber,
apiResponse.data.pageSize,
apiResponse.data.totalPages,
apiResponse.data.totalRecords
);
const getAppsPagedResponse = new GetPagedAppsResponse(
apps,
apiResponse.data.pageNumber,
apiResponse.data.pageSize,
apiResponse.data.totalPages,
apiResponse.data.totalRecords
);
return new ApiResponse<GetPagedAppsResponse>(
apiResponse.statusCode,
+2 -2
View File
@@ -1,7 +1,7 @@
import { type AxiosResponse } from 'axios';
import { HttpStatusCode } from '../enums/HttpStatusCode';
import { ApiResponse } from './ApiResponse';
import { type Readable } from 'stream';
import { HttpStatusCode } from '../enums/HttpStatusCode.js';
import { ApiResponse } from './ApiResponse.js';
/**
* @class ApiResponseFactory - Factory class for creating ApiResponse objects
+1 -1
View File
@@ -1,4 +1,4 @@
import { type FileStorageSite } from '../enums/FileStorageSite';
import { type FileStorageSite } from '../enums/FileStorageSite.js';
/**
* @class Attachment - Represents an attachment.
+3 -3
View File
@@ -1,6 +1,6 @@
import { RecordValueType } from '../enums/RecordValueType';
import { type Attachment } from './Attachment';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { type Attachment } from './Attachment.js';
import { RecordValue } from './RecordValue.js';
/**
* @class AttachmentListRecordValue - A record value represented by a list of attachments.
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
/**
* @class DateRecordValue - A value for a date field in a record.
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue.js';
import { RecordValueType } from '../enums/RecordValueType.js';
export class DecimalRecordValue extends RecordValue<number> {
constructor(fieldId: number, value: number) {
+54 -54
View File
@@ -1,54 +1,54 @@
import { type DelegateType } from '../enums/DelegateType';
/**
* @class Delegate - Represents a delegate.
*/
export class Delegate {
/**
* @property {DelegateType} delegateType - The type of delegate.
*/
public delegateType: DelegateType;
/**
* @property {string | null} name - The name of the delegate.
*/
public name: string | null;
/**
* @property {string} emailAddress - The email address of the delegate.
*/
public emailAddress: string;
/**
* @property {Date} delegationDateTime - The date and time the delegate was assigned.
*/
public delegationDateTime: Date;
/**
* @property {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
*/
public delegationCompletedDateTime: Date | null;
/**
* @constructor - Creates a new instance of Delegate.
* @param {DelegateType} delegateType - The type of delegate.
* @param {string | null} name - The name of the delegate.
* @param {string} emailAddress - The email address of the delegate.
* @param {Date} delegationDateTime - The date and time the delegate was assigned.
* @param {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
* @returns {Delegate} - A new instance of Delegate.
*/
constructor(
delegateType: DelegateType,
name: string | null,
emailAddress: string,
delegationDateTime: Date,
delegationCompletedDateTime: Date | null
) {
this.delegateType = delegateType;
this.name = name;
this.emailAddress = emailAddress;
this.delegationDateTime = delegationDateTime;
this.delegationCompletedDateTime = delegationCompletedDateTime;
}
}
import { type DelegateType } from '../enums/DelegateType.js';
/**
* @class Delegate - Represents a delegate.
*/
export class Delegate {
/**
* @property {DelegateType} delegateType - The type of delegate.
*/
public delegateType: DelegateType;
/**
* @property {string | null} name - The name of the delegate.
*/
public name: string | null;
/**
* @property {string} emailAddress - The email address of the delegate.
*/
public emailAddress: string;
/**
* @property {Date} delegationDateTime - The date and time the delegate was assigned.
*/
public delegationDateTime: Date;
/**
* @property {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
*/
public delegationCompletedDateTime: Date | null;
/**
* @constructor - Creates a new instance of Delegate.
* @param {DelegateType} delegateType - The type of delegate.
* @param {string | null} name - The name of the delegate.
* @param {string} emailAddress - The email address of the delegate.
* @param {Date} delegationDateTime - The date and time the delegate was assigned.
* @param {Date | null} delegationCompletedDateTime - The date and time the delegate completed the survey.
* @returns {Delegate} - A new instance of Delegate.
*/
constructor(
delegateType: DelegateType,
name: string | null,
emailAddress: string,
delegationDateTime: Date,
delegationCompletedDateTime: Date | null
) {
this.delegateType = delegateType;
this.name = name;
this.emailAddress = emailAddress;
this.delegationDateTime = delegationDateTime;
this.delegationCompletedDateTime = delegationCompletedDateTime;
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType';
import { type Delegate } from './Delegate';
import { RecordValueType } from '../enums/RecordValueType.js';
import { type Delegate } from './Delegate.js';
import { RecordValue } from './RecordValue.js';
export class DelegateListRecordValue extends RecordValue<Delegate[]> {
constructor(fieldId: number, value: Delegate[]) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { type FieldStatus } from '../enums/FieldStatus';
import { type FieldType } from '../enums/FieldType';
import { type FieldStatus } from '../enums/FieldStatus.js';
import { type FieldType } from '../enums/FieldType.js';
/**
* @class Field - Represents a Field.
+1 -1
View File
@@ -1,4 +1,4 @@
import { FieldType } from '../enums/FieldType';
import { FieldType } from '../enums/FieldType.js';
/**
* @class FileInfo - Represents a file info.
+3 -3
View File
@@ -1,6 +1,6 @@
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType';
import { type File } from './File';
import { RecordValueType } from '../enums/RecordValueType.js';
import { type File } from './File.js';
import { RecordValue } from './RecordValue.js';
export class FileListRecordValue extends RecordValue<File[]> {
constructor(fieldId: number, value: File[]) {
+5 -5
View File
@@ -1,8 +1,8 @@
import { type FieldStatus } from '../enums/FieldStatus';
import { type FieldType } from '../enums/FieldType';
import { type FormulaOutputType } from '../enums/FormulaOutputType';
import { Field } from './Field';
import { type ListValue } from './ListValue';
import { type FieldStatus } from '../enums/FieldStatus.js';
import { type FieldType } from '../enums/FieldType.js';
import { type FormulaOutputType } from '../enums/FormulaOutputType.js';
import { Field } from './Field.js';
import { type ListValue } from './ListValue.js';
/**
* @class FormulaField - Represents a formula field.
+2 -2
View File
@@ -1,5 +1,5 @@
import { PagedResponse } from './PagedResponse';
import { type App } from './App';
import { type App } from './App.js';
import { PagedResponse } from './PagedResponse.js';
/**
* @class GetPagedAppsResponse - A paged response model for the GetApps method.
+2 -2
View File
@@ -1,5 +1,5 @@
import { type Field } from './Field';
import { PagedResponse } from './PagedResponse';
import { type Field } from './Field.js';
import { PagedResponse } from './PagedResponse.js';
/**
* @class GetPagedFieldsResponse - A response containing a paged collection of fields.
+26 -26
View File
@@ -1,26 +1,26 @@
import { type Record } from './Record';
import { PagedResponse } from './PagedResponse';
/**
* @class GetPagedRecordsResponse - A response containing a paged collection of records.
*/
export class GetPagedRecordsResponse extends PagedResponse<Record> {
/**
* @constructor - Creates a new instance of the GetPagedRecordsResponse class.
* @param {Record[]} items - The items in the collection.
* @param {number} pageNumber - The page number of the response.
* @param {number} pageSize - The page size of the response.
* @param {number} totalPages - The total number of pages in the response.
* @param {number} totalRecords - The total number of records in the response.
* @returns {GetPagedRecordsResponse} - A new instance of the GetPagedRecordsResponse class.
*/
constructor(
items: Record[],
pageNumber: number,
pageSize: number,
totalPages: number,
totalRecords: number
) {
super(items, pageNumber, pageSize, totalPages, totalRecords);
}
}
import { PagedResponse } from './PagedResponse.js';
import { type Record } from './Record.js';
/**
* @class GetPagedRecordsResponse - A response containing a paged collection of records.
*/
export class GetPagedRecordsResponse extends PagedResponse<Record> {
/**
* @constructor - Creates a new instance of the GetPagedRecordsResponse class.
* @param {Record[]} items - The items in the collection.
* @param {number} pageNumber - The page number of the response.
* @param {number} pageSize - The page size of the response.
* @param {number} totalPages - The total number of pages in the response.
* @param {number} totalRecords - The total number of records in the response.
* @returns {GetPagedRecordsResponse} - A new instance of the GetPagedRecordsResponse class.
*/
constructor(
items: Record[],
pageNumber: number,
pageSize: number,
totalPages: number,
totalRecords: number
) {
super(items, pageNumber, pageSize, totalPages, totalRecords);
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { PagedResponse } from './PagedResponse';
import { type Report } from './Report';
import { PagedResponse } from './PagedResponse.js';
import { type Report } from './Report.js';
/**
* @class GetPagedReportsResponse - Represents a response containing a paged list of reports.
+1 -1
View File
@@ -1,4 +1,4 @@
import { DataFormat } from '../enums/DataFormat';
import { DataFormat } from '../enums/DataFormat.js';
/**
* @class GetRecordRequest - A request to get a record.
+2 -2
View File
@@ -1,5 +1,5 @@
import { DataFormat } from '../enums/DataFormat';
import { PagingRequest } from './PagingRequest';
import { DataFormat } from '../enums/DataFormat.js';
import { PagingRequest } from './PagingRequest.js';
export class GetRecordsByAppIdRequest {
/**
+45 -45
View File
@@ -1,45 +1,45 @@
import { DataFormat } from '../enums/DataFormat';
/**
* @class GetRecordsRequest - Request to get records by their ids
*/
export class GetRecordsRequest {
/**
* @property {number} appId - The id of the app the records belong to.
*/
appId: number;
/**
* @property {number[]} recordIds - The ids of the records to get.
*/
recordIds: number[];
/**
* @property {number[]} fieldIds - The ids of the fields to include in the response.
*/
fieldIds: number[];
/**
* @property {DataFormat} dataFormat - The format of the data in the response.
*/
dataFormat: DataFormat;
/**
* @constructor - Creates a new instance of GetRecordsRequest
* @param {number} appId - The id of the app the records belong to.
* @param {number[]} recordIds - The ids of the records to get.
* @param {number[]} fieldIds - The ids of the fields to include in the response.
* @param {DataFormat} dataFormat - The format of the data in the response.
*/
constructor(
appId: number,
recordIds: number[],
fieldIds: number[] = [],
dataFormat: DataFormat = DataFormat.Raw
) {
this.appId = appId;
this.recordIds = recordIds;
this.fieldIds = fieldIds;
this.dataFormat = dataFormat;
}
}
import { DataFormat } from '../enums/DataFormat.js';
/**
* @class GetRecordsRequest - Request to get records by their ids
*/
export class GetRecordsRequest {
/**
* @property {number} appId - The id of the app the records belong to.
*/
appId: number;
/**
* @property {number[]} recordIds - The ids of the records to get.
*/
recordIds: number[];
/**
* @property {number[]} fieldIds - The ids of the fields to include in the response.
*/
fieldIds: number[];
/**
* @property {DataFormat} dataFormat - The format of the data in the response.
*/
dataFormat: DataFormat;
/**
* @constructor - Creates a new instance of GetRecordsRequest
* @param {number} appId - The id of the app the records belong to.
* @param {number[]} recordIds - The ids of the records to get.
* @param {number[]} fieldIds - The ids of the fields to include in the response.
* @param {DataFormat} dataFormat - The format of the data in the response.
*/
constructor(
appId: number,
recordIds: number[],
fieldIds: number[] = [],
dataFormat: DataFormat = DataFormat.Raw
) {
this.appId = appId;
this.recordIds = recordIds;
this.fieldIds = fieldIds;
this.dataFormat = dataFormat;
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
export class GuidListRecordValue extends RecordValue<string[]> {
constructor(fieldId: number, value: string[]) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
export class GuidRecordValue extends RecordValue<string> {
constructor(fieldId: number, value: string) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
export class IntegerListRecordValue extends RecordValue<number[]> {
constructor(fieldId: number, value: number[]) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
/**
* @class IntegerRecordValue - A record value represented by an integer.
+5 -5
View File
@@ -1,8 +1,8 @@
import { type FieldStatus } from '../enums/FieldStatus';
import { type FieldType } from '../enums/FieldType';
import { type Multiplicity } from '../enums/Multiplicity';
import { Field } from './Field';
import { type ListValue } from './ListValue';
import { type FieldStatus } from '../enums/FieldStatus.js';
import { type FieldType } from '../enums/FieldType.js';
import { type Multiplicity } from '../enums/Multiplicity.js';
import { Field } from './Field.js';
import { type ListValue } from './ListValue.js';
/**
* @class ListField - Represents a list field.
+1 -1
View File
@@ -1,4 +1,4 @@
import { CreatedWithIdResponse } from './CreatedWithIdResponse';
import { CreatedWithIdResponse } from './CreatedWithIdResponse.js';
/**
* @class ListItemResponse - Represents a respons when a list item is created or updated.
*/
+34 -30
View File
@@ -1,36 +1,36 @@
import axios, {
type CreateAxiosDefaults,
type AxiosInstance,
type AxiosRequestConfig,
type CreateAxiosDefaults,
} from 'axios';
import { PagingRequest } from './PagingRequest';
import { ArgumentValidator } from './ArgumentValidator';
import { EndpointFactory } from './EndpointFactory';
import { ApiResponseFactory } from './ApiResponseFactory';
import { DataFormat } from '../enums/DataFormat';
import { ReportDataType } from '../enums/ReportDataType';
import { Record } from './Record';
import { type ApiResponse } from './ApiResponse';
import { type GetPagedAppsResponse } from './GetPagedAppsResponse';
import { type App } from './App';
import { type CollectionResponse } from './CollectionResponse';
import { type Field } from './Field';
import { type GetPagedFieldsResponse } from './GetPagedFieldsResponse';
import { type SaveFileRequest } from './SaveFileRequest';
import { type CreatedWithIdResponse } from './CreatedWithIdResponse';
import { type FileInfo } from './FileInfo';
import { type File } from './File';
import { type ListItemResponse } from './ListItemResponse';
import { type ListItemRequest } from './ListItemRequest';
import { type GetPagedReportsResponse } from './GetPagedReportsResponse';
import { type ReportData } from './ReportData';
import { type GetRecordRequest } from './GetRecordRequest';
import { type GetRecordsByAppIdRequest } from './GetRecordsByAppIdRequest';
import { type GetPagedRecordsResponse } from './GetPagedRecordsResponse';
import { type GetRecordsRequest } from './GetRecordsRequest';
import { type QueryRecordsRequest } from './QueryRecordsRequest';
import { type SaveRecordResponse } from './SaveRecordResponse';
import { type SaveRecordRequest } from './SaveRecordRequest';
import { DataFormat } from '../enums/DataFormat.js';
import { ReportDataType } from '../enums/ReportDataType.js';
import { type ApiResponse } from './ApiResponse.js';
import { ApiResponseFactory } from './ApiResponseFactory.js';
import { type App } from './App.js';
import { ArgumentValidator } from './ArgumentValidator.js';
import { type CollectionResponse } from './CollectionResponse.js';
import { type CreatedWithIdResponse } from './CreatedWithIdResponse.js';
import { EndpointFactory } from './EndpointFactory.js';
import { type Field } from './Field.js';
import { type File } from './File.js';
import { type FileInfo } from './FileInfo.js';
import { type GetPagedAppsResponse } from './GetPagedAppsResponse.js';
import { type GetPagedFieldsResponse } from './GetPagedFieldsResponse.js';
import { type GetPagedRecordsResponse } from './GetPagedRecordsResponse.js';
import { type GetPagedReportsResponse } from './GetPagedReportsResponse.js';
import { type GetRecordRequest } from './GetRecordRequest.js';
import { type GetRecordsByAppIdRequest } from './GetRecordsByAppIdRequest.js';
import { type GetRecordsRequest } from './GetRecordsRequest.js';
import { type ListItemRequest } from './ListItemRequest.js';
import { type ListItemResponse } from './ListItemResponse.js';
import { PagingRequest } from './PagingRequest.js';
import { type QueryRecordsRequest } from './QueryRecordsRequest.js';
import { Record } from './Record.js';
import { type ReportData } from './ReportData.js';
import { type SaveFileRequest } from './SaveFileRequest.js';
import { type SaveRecordRequest } from './SaveRecordRequest.js';
import { type SaveRecordResponse } from './SaveRecordResponse.js';
/**
* @class OnspringClient - A client that can communicate with the Onspring API.
@@ -49,7 +49,11 @@ export class OnspringClient {
* @throws {Error} - Thrown when the apiKey is null/undefined/empty/whitespace.
* @returns {OnspringClient} - A new instance of the OnspringClient class.
*/
constructor(baseUrl: string | undefined | null, apiKey: string | undefined | null, config: CreateAxiosDefaults = {}) {
constructor(
baseUrl: string | undefined | null,
apiKey: string | undefined | null,
config: CreateAxiosDefaults = {}
) {
if (ArgumentValidator.isValidUrl(baseUrl) === false || baseUrl === null) {
throw new Error('baseUrl must be an absolute and well-formed URI.');
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { ArgumentValidator } from './ArgumentValidator';
import { ArgumentValidator } from './ArgumentValidator.js';
/**
* @class PagingRequest - Paging request model
+1 -1
View File
@@ -1,4 +1,4 @@
import { FilterOperators } from '../enums/FilterOperators';
import { FilterOperators } from '../enums/FilterOperators.js';
export class QueryFilter {
public fieldId: number;
+3 -3
View File
@@ -1,6 +1,6 @@
import { DataFormat } from '../enums/DataFormat';
import { PagingRequest } from './PagingRequest';
import { type QueryFilter } from './QueryFilter';
import { DataFormat } from '../enums/DataFormat.js';
import { PagingRequest } from './PagingRequest.js';
import { type QueryFilter } from './QueryFilter.js';
/**
* @class QueryRecordsRequest - Request to query for records.
+2 -2
View File
@@ -1,5 +1,5 @@
import { type RecordValue } from './RecordValue';
import { SaveRecordRequest } from './SaveRecordRequest';
import { type RecordValue } from './RecordValue.js';
import { SaveRecordRequest } from './SaveRecordRequest.js';
/**
* @class Record - A record in an app.
+9 -9
View File
@@ -1,12 +1,12 @@
import { RecordValueType } from '../enums/RecordValueType';
import { type Attachment } from './Attachment';
import { type AttachmentListRecordValue } from './AttachmentListRecordValue';
import { type Delegate } from './Delegate';
import { type DelegateListRecordValue } from './DelegateListRecordValue';
import { type ScoringGroup } from './ScoringGroup';
import { type ScoringGroupListRecordValue } from './ScoringGroupListRecordValue';
import { type TimeSpanData } from './TimeSpanData';
import { type TimeSpanRecordValue } from './TimeSpanRecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { type Attachment } from './Attachment.js';
import { type AttachmentListRecordValue } from './AttachmentListRecordValue.js';
import { type Delegate } from './Delegate.js';
import { type DelegateListRecordValue } from './DelegateListRecordValue.js';
import { type ScoringGroup } from './ScoringGroup.js';
import { type ScoringGroupListRecordValue } from './ScoringGroupListRecordValue.js';
import { type TimeSpanData } from './TimeSpanData.js';
import { type TimeSpanRecordValue } from './TimeSpanRecordValue.js';
/**
* @class RecordValue - A value for a field in a record.
+4 -4
View File
@@ -1,7 +1,7 @@
import { type FieldStatus } from '../enums/FieldStatus';
import { type FieldType } from '../enums/FieldType';
import { type Multiplicity } from '../enums/Multiplicity';
import { Field } from './Field';
import { type FieldStatus } from '../enums/FieldStatus.js';
import { type FieldType } from '../enums/FieldType.js';
import { type Multiplicity } from '../enums/Multiplicity.js';
import { Field } from './Field.js';
/**
* @class ReferenceField - Represents a reference field.
+1 -1
View File
@@ -1,4 +1,4 @@
import { type Row } from './Row';
import { type Row } from './Row.js';
/**
* @class ReportData - Represents the data for a report.
+1 -1
View File
@@ -1,4 +1,4 @@
import { CreatedWithIdResponse } from './CreatedWithIdResponse';
import { CreatedWithIdResponse } from './CreatedWithIdResponse.js';
export class SaveRecordResponse extends CreatedWithIdResponse<number> {
public warnings: string[];
+3 -3
View File
@@ -1,6 +1,6 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { type ScoringGroup } from './ScoringGroup';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
import { type ScoringGroup } from './ScoringGroup.js';
export class ScoringGroupListRecordValue extends RecordValue<ScoringGroup[]> {
constructor(fieldId: number, value: ScoringGroup[]) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
export class StringListRecordValue extends RecordValue<string[]> {
constructor(fieldId: number, value: string[]) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
/**
* @class StringRecordValue - A record value represented by a string.
+2 -2
View File
@@ -1,5 +1,5 @@
import { type TimeSpanIncrement } from '../enums/TimeSpanIncrement';
import { type TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType';
import { type TimeSpanIncrement } from '../enums/TimeSpanIncrement.js';
import { type TimeSpanRecurrenceType } from '../enums/TimeSpanRecurrenceType.js';
export class TimeSpanData {
/**
+3 -3
View File
@@ -1,6 +1,6 @@
import { RecordValueType } from '../enums/RecordValueType';
import { RecordValue } from './RecordValue';
import { type TimeSpanData } from './TimeSpanData';
import { RecordValueType } from '../enums/RecordValueType.js';
import { RecordValue } from './RecordValue.js';
import { type TimeSpanData } from './TimeSpanData.js';
export class TimeSpanRecordValue extends RecordValue<TimeSpanData> {
constructor(fieldId: number, value: TimeSpanData) {
+1
View File
@@ -13,6 +13,7 @@
"module": "commonjs",
"target": "ES6"
},
"experimentalResolver": true,
"moduleTypes": {
"*.ts": "cjs"
}