UNPKG

@salaxy/core

Version:

General plain JavaScript / TypeScript libraries for Salaxy API (Palkkaus.fi)

1 lines 3.2 MB
{"version":3,"file":"salaxy-lib-core.umd.cjs","sources":["../../../@salaxy/core/ts/logic/ConfigLogic.ts","../../../@salaxy/core/ts/logic/Configs.ts","../../../@salaxy/core/ts/util/Cookies.ts","../../../@salaxy/core/ts/api/infra/AjaxJQuery.ts","../../../@salaxy/core/ts/api/infra/AjaxXHR.ts","../../../@salaxy/core/ts/util/schema/FormHelpers.ts","../../../@salaxy/core/ts/model/oauth2.ts","../../../@salaxy/core/ts/model/v01.ts","../../../@salaxy/core/ts/model/irepr.ts","../../../@salaxy/core/ts/model/irpsr.ts","../../../@salaxy/core/ts/model/non-api/AuthorizationPdfType.ts","../../../@salaxy/core/ts/model/non-api/WebSiteAccountType.ts","../../../@salaxy/core/ts/model/non-api/TimesheetInputModification.ts","../../../@salaxy/core/ts/codegen/incomeTypeCodes.ts","../../../@salaxy/core/ts/util/Objects.ts","../../../@salaxy/core/ts/logic/TranslationsInstance.ts","../../../@salaxy/core/ts/logic/Translations.ts","../../../@salaxy/core/ts/logic/IncomeTypesLogic.ts","../../../@salaxy/core/ts/codegen/enumerations.ts","../../../@salaxy/core/ts/codegen/enumerationsIr.ts","../../../@salaxy/core/ts/logic/EnumerationsLogic.ts","../../../@salaxy/core/ts/logic/model/CalculationRowCategory.ts","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/dayjs.min.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/customParseFormat.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/advancedFormat.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/duration.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/isoWeek.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/isSameOrBefore.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/isSameOrAfter.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/utc.js","../../../node_modules/.pnpm/dayjs@1.11.10/node_modules/dayjs/plugin/quarterOfYear.js","../../../@salaxy/core/ts/codegen/yearlyHolidaysYears.ts","../../../@salaxy/core/ts/util/Dates.ts","../../../@salaxy/core/ts/codegen/accountProductDefaults.ts","../../../@salaxy/core/ts/codegen/vismaSignOriginalMethods.ts","../../../@salaxy/core/ts/codegen/yearlyChangingNumbersYears.ts","../../../@salaxy/core/ts/codegen/yearlyTaxFreeYears.ts","../../../@salaxy/core/ts/codegen/kevaEmploymentRegCodes.ts","../../../@salaxy/core/ts/util/Years.ts","../../../@salaxy/core/ts/logic/model/calcRowsMetadata.ts","../../../@salaxy/core/ts/logic/model/CalculationRowCategories.ts","../../../@salaxy/core/ts/logic/model/ExternalDialogData.ts","../../../@salaxy/core/ts/logic/model/SystemRole.ts","../../../@salaxy/core/ts/logic/model/ExpensesVatRate.ts","../../../@salaxy/core/ts/logic/CalcRowsLogic.ts","../../../@salaxy/core/ts/util/Numeric.ts","../../../@salaxy/core/ts/util/schema/JsonSchemaUtils.ts","../../../@salaxy/core/ts/util/schema/JsonSchemaCache.ts","../../../@salaxy/core/ts/util/Arrays.ts","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/Barcode.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE39/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/constants.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/CODE128.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/auto.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/CODE128_AUTO.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/CODE128A.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/CODE128B.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/CODE128C.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/CODE128/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/constants.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/encoder.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN13.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN8.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN5.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN2.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/UPC.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/UPCE.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/EAN_UPC/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/ITF/constants.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/ITF/ITF.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/ITF/ITF14.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/ITF/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/MSI/MSI.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/MSI/checksums.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/MSI/MSI10.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/MSI/MSI11.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/MSI/MSI1010.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/MSI/MSI1110.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/MSI/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/pharmacode/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/codabar/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/GenericBarcode/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/barcodes/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/help/merge.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/help/linearizeEncodings.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/help/fixOptions.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/help/optionsFromStrings.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/options/defaults.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/help/getOptionsFromElement.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/renderers/shared.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/renderers/canvas.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/renderers/svg.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/renderers/object.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/renderers/index.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/exceptions/exceptions.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/help/getRenderProperties.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/exceptions/ErrorHandler.js","../../../node_modules/.pnpm/jsbarcode@3.11.6/node_modules/jsbarcode/bin/JsBarcode.js","../../../@salaxy/core/ts/util/Barcodes.ts","../../../node_modules/.pnpm/js-base64@3.7.7/node_modules/js-base64/base64.mjs","../../../@salaxy/core/ts/util/Base64.ts","../../../@salaxy/core/ts/util/Brand.ts","../../../@salaxy/core/ts/util/DateTimes.ts","../../../@salaxy/core/ts/util/Iban.ts","../../../@salaxy/core/ts/util/OData.ts","../../../@salaxy/core/ts/util/Texts.ts","../../../@salaxy/core/ts/util/Token.ts","../../../@salaxy/core/ts/util/Validation.ts","../../../@salaxy/core/ts/util/Promises.ts","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/can-promise.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/utils.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/error-correction-level.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/bit-buffer.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/bit-matrix.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/alignment-pattern.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/finder-pattern.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/mask-pattern.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/error-correction-code.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/galois-field.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/polynomial.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/reed-solomon-encoder.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/version-check.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/regex.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/mode.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/version.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/format-info.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/numeric-data.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/alphanumeric-data.js","../../../node_modules/.pnpm/encode-utf8@1.0.3/node_modules/encode-utf8/index.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/byte-data.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/kanji-data.js","../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/segments.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/core/qrcode.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/renderer/utils.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/renderer/canvas.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/renderer/svg-tag.js","../../../node_modules/.pnpm/qrcode@1.5.3/node_modules/qrcode/lib/browser.js","../../../@salaxy/core/ts/util/QrCodes.ts","../../../@salaxy/core/ts/api/infra/CrudApiBase.ts","../../../@salaxy/core/ts/api/infra/OAuth2.ts","../../../@salaxy/core/ts/api/infra/SingleItemApiBase.ts","../../../@salaxy/core/ts/api/infra/AjaxFetch.ts","../../../@salaxy/core/ts/api/crud/Absences.ts","../../../@salaxy/core/ts/api/crud/AccountingTargets.ts","../../../@salaxy/core/ts/api/crud/AuthorizedAccounts.ts","../../../@salaxy/core/ts/logic/CalculatorLogic.ts","../../../@salaxy/core/ts/api/Calculator.ts","../../../@salaxy/core/ts/api/crud/Calculations.ts","../../../@salaxy/core/ts/api/crud/CalendarEvents.ts","../../../@salaxy/core/ts/api/crud/Certificates.ts","../../../@salaxy/core/ts/api/crud/Credentials.ts","../../../@salaxy/core/ts/api/crud/CustomerInvoices.ts","../../../@salaxy/core/ts/api/crud/Datasets.ts","../../../@salaxy/core/ts/logic/import/Culture.ts","../../../@salaxy/core/ts/logic/import/DataMapperMember.ts","../../../@salaxy/core/ts/logic/import/DataMapperSelector.ts","../../../@salaxy/core/ts/logic/import/DataMapper.ts","../../../@salaxy/core/ts/logic/import/DataMappersLogic.ts","../../../@salaxy/core/ts/logic/import/FileDelimiter.ts","../../../@salaxy/core/ts/logic/import/TableFormat.ts","../../../@salaxy/core/ts/logic/import/FileLogic.ts","../../../@salaxy/core/ts/logic/import/Tables.ts","../../../@salaxy/core/ts/logic/import/FileParser.ts","../../../@salaxy/core/ts/logic/PayrollLogic.ts","../../../@salaxy/core/ts/api/crud/Payrolls.ts","../../../@salaxy/core/ts/logic/ValidationHelper.ts","../../../@salaxy/core/ts/logic/import/HrSuuntiImportLogic.ts","../../../@salaxy/core/ts/logic/import/ImportBatch.ts","../../../@salaxy/core/ts/logic/import/ExportLogic.ts","../../../@salaxy/core/ts/logic/staging/model/WorktimeImportKnownUsecase.ts","../../../@salaxy/core/ts/logic/staging/model/WorktimeImportPreviewMetadata.ts","../../../@salaxy/core/ts/logic/staging/model/WorktimeImportStatus.ts","../../../@salaxy/core/ts/logic/staging/StagingApiConnector.ts","../../../@salaxy/core/ts/logic/staging/WorktimeApiConnector.ts","../../../@salaxy/core/ts/logic/AccountingTargetLogic.ts","../../../@salaxy/core/ts/logic/ApiLogic.ts","../../../@salaxy/core/ts/logic/CalculationResultLogic.ts","../../../@salaxy/core/ts/logic/ContractPartyLogic.ts","../../../@salaxy/core/ts/logic/EmploymentLogic.ts","../../../@salaxy/core/ts/logic/HolidaysLogic.ts","../../../@salaxy/core/ts/logic/InvoicesLogic.ts","../../../@salaxy/core/ts/logic/Occupations.ts","../../../@salaxy/core/ts/logic/OnboardingLogic.ts","../../../@salaxy/core/ts/logic/PaymentLogic.ts","../../../@salaxy/core/ts/logic/ReportsLogic.ts","../../../@salaxy/core/ts/logic/RoleLogic.ts","../../../@salaxy/core/ts/logic/SalaryDateLogic.ts","../../../@salaxy/core/ts/logic/SettingsLogic.ts","../../../@salaxy/core/ts/logic/StorageLogic.ts","../../../@salaxy/core/ts/logic/SxyFormsSettings.ts","../../../@salaxy/core/ts/logic/TaxCard2019Logic.ts","../../../@salaxy/core/ts/logic/TypedocLogic.ts","../../../@salaxy/core/ts/logic/BicHelper.ts","../../../@salaxy/core/ts/logic/UserDefinedRowLogic.ts","../../../@salaxy/core/ts/api/crud/Employments.ts","../../../@salaxy/core/ts/api/crud/Files.ts","../../../@salaxy/core/ts/api/crud/HolidayYears.ts","../../../@salaxy/core/ts/api/crud/Invoices.ts","../../../@salaxy/core/ts/api/crud/IrEarningsPayments.ts","../../../@salaxy/core/ts/api/crud/IrPayerSummaries.ts","../../../@salaxy/core/ts/api/crud/MessageThreads.ts","../../../@salaxy/core/ts/api/crud/PaymentChannelApi.ts","../../../@salaxy/core/ts/api/crud/Payrolls4.ts","../../../@salaxy/core/ts/api/crud/Taxcards.ts","../../../@salaxy/core/ts/api/crud/Workers.ts","../../../@salaxy/core/ts/api/crud/ServiceModels.ts","../../../@salaxy/core/ts/api/crud/Usecases.ts","../../../@salaxy/core/ts/api/crud/HouseholdYears.ts","../../../@salaxy/core/ts/api/crud/Records.ts","../../../@salaxy/core/ts/api/crud/ReferenceObjects.ts","../../../@salaxy/core/ts/api/Accounts.ts","../../../@salaxy/core/ts/api/Onboardings.ts","../../../@salaxy/core/ts/api/Reports.ts","../../../@salaxy/core/ts/api/Session.ts","../../../@salaxy/core/ts/api/Test.ts","../../../@salaxy/core/ts/api/depricated/Client.ts","../../../@salaxy/core/ts/api/settings/AccountSettings.ts","../../../@salaxy/core/ts/api/settings/BeneficialOwnersApi.ts","../../../@salaxy/core/ts/api/HelpCenter.ts","../../../@salaxy/core/ts/api/Overview.ts","../../../@salaxy/core/ts/api/PartnerServices.ts","../../../@salaxy/core/ts/api/ProApi.ts","../../../@salaxy/core/ts/api/Imports.ts","../../../@salaxy/core/ts/ui/CellRenderingLogic.ts","../../../@salaxy/core/ts/ui/SitemapVisibility.ts","../../../@salaxy/core/ts/usecases/household/householdUsecaseTree.ts","../../../@salaxy/core/ts/usecases/household/HouseholdUsecasesLogic.ts","../../../@salaxy/core/ts/usecases/BaseUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/AbsencePeriodUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/BicycleBenefitUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/BoardUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/CarBenefitUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/DailyAllowanceUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/DefaultUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/EmploymentTerminationUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/ExpensesUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/ForeclosureUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/HolidaysUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/HourlySalaryWithWorkingTimeCompensationUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/IrIncomeTypeUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/MealBenefitUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/MilageOwnCarUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/NonProfitOrgUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/OtherCompensationUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/PaidSickLeaveUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/RemunerationUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/SubsidisedCommuteUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/TaxAtSourceUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/TaxWithholdingUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/TotalWorkerPaymentUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/TrainingUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/UnionPaymentUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/rows/WorkingTimeCompensationUsecaseLogic.ts","../../../@salaxy/core/ts/usecases/RowUsecaseCalcData.ts","../../../@salaxy/core/ts/usecases/RowsUsecaseLogic.ts","../../../@salaxy/core/ts/ActionExecutor.ts"],"sourcesContent":["import type { Config } from \"./Config\";\r\n\r\n/** Extends the Config with logic */\r\nexport class ConfigLogic implements Config {\r\n\r\n /** The base address of the Salaxy http API server, e.g. https://secure.salaxy.com */\r\n apiServer?: string | null;\r\n\r\n /** The base address of the Palkkaus web site, e.g. https://www.palkkaus.fi */\r\n wwwServer?: string | null;\r\n\r\n /** A flag indicating if the current configuration is for test environment only. If true, the site is for testing only. */\r\n isTestData?: boolean | null;\r\n\r\n /** A flag indicating if the site sets a Salaxy cookie which persists over web sessions. If true, the cookie will be created. */\r\n useCookie?: boolean | null;\r\n\r\n /** A flag indicating if the API site uses credentials. If true, the credentials will be used. */\r\n useCredentials?: boolean | null;\r\n\r\n /** InstrumentationKey for Application Insight */\r\n instrumentationKey?: string | null;\r\n\r\n /** Partner id for site. This is required for example for onboarding with partner specific style. */\r\n partnerSite?: string | null;\r\n\r\n /** Pro server site address. e.g. https://pro.palkkaus.fi */\r\n proServer?: string | null;\r\n\r\n /** Report server url */\r\n reportServer?: string | null;\r\n\r\n /** Application id for invoicing. */\r\n applicationId?: string | null;\r\n\r\n /** The base address of the integrations server, e.g. https://integrations.salaxy.com */\r\n integrationsServer?: string | null;\r\n\r\n /**\r\n * Creates a new ConfigLogic based on a Config in env file.\r\n * @param config Raw config in env file.\r\n */\r\n constructor(config: Config) {\r\n Object.assign(this, config);\r\n }\r\n\r\n /** Gets the type of the environment. */\r\n public getEnv(): \"local\" | \"test\" | \"demo\" | \"prod\" | \"rc\" {\r\n if (this.apiServer?.indexOf(\"localhost\") > -1 ) {\r\n return \"local\";\r\n }\r\n if (this.apiServer?.indexOf(\"rc\") > -1 ) {\r\n return \"rc\";\r\n }\r\n if (this.integrationsServer?.indexOf(\"test\") > -1 ) {\r\n return \"test\";\r\n }\r\n if (!this.isTestData) {\r\n return \"prod\";\r\n }\r\n return \"demo\";\r\n }\r\n\r\n /** Gets the server address for the Omapalkka service based on environment. */\r\n public getOmapalkkaServer(): string {\r\n switch (this.getEnv()) {\r\n case \"prod\":\r\n return \"https://www.omapalkka.fi\";\r\n case \"local\":\r\n return \"http://localhost:3000\";\r\n case \"test\":\r\n return \"https://test-www.omapalkka.fi\";\r\n case \"rc\":\r\n case \"demo\":\r\n default:\r\n return \"https://demo-www.omapalkka.fi\";\r\n }\r\n }\r\n\r\n /** Gets the API server address for the Omapalkka service based on environment. */\r\n public getOmapalkkaApiServer(): string {\r\n switch (this.getEnv()) {\r\n case \"prod\":\r\n return \"https://secure.omapalkka.fi\";\r\n case \"local\":\r\n return \"https://localhost:7270\";\r\n case \"test\":\r\n return \"https://test-secure.omapalkka.fi\";\r\n case \"rc\":\r\n case \"demo\":\r\n default:\r\n return \"https://demo-secure.omapalkka.fi\";\r\n }\r\n }\r\n\r\n}","import { Config } from \"./Config\";\r\nimport { ConfigLogic } from \"./ConfigLogic\";\r\n\r\n/** This file assigns config to global salaxy namespace. */\r\ndeclare const globalThis;\r\n/** This file assigns config to global salaxy namespace. */\r\ndeclare const global;\r\n\r\n/**\r\n * Class for reading Environment specific configuration for Salaxy API's and JavaScript in general\r\n */\r\nexport class Configs {\r\n\r\n private static get defaultConfig() {\r\n return {\r\n wwwServer: \"https://test.palkkaus.fi\",\r\n apiServer: \"https://test-api.salaxy.com\",\r\n proServer: \"https://demo-pro.palkkaus.fi/server\",\r\n reportServer: \"https://test-reports.salaxy.com\",\r\n integrationsServer: \"https://test-integrations.salaxy.com\",\r\n isTestData: true,\r\n useCookie: true,\r\n };\r\n }\r\n\r\n private static getGlobalConfig(): Config {\r\n const g = this.getGlobal();\r\n return (g.salaxy && g.salaxy.config) ? g.salaxy.config : null;\r\n }\r\n\r\n private static setGlobalConfig(config: Config) {\r\n const g = this.getGlobal();\r\n g.salaxy = g.salaxy || {};\r\n g.salaxy.config = config;\r\n }\r\n\r\n private static getGlobal(): any {\r\n if (typeof globalThis !== \"undefined\") { return globalThis; }\r\n if (typeof self !== \"undefined\") { return self; }\r\n if (typeof window !== \"undefined\") { return window; }\r\n if (typeof global !== \"undefined\") { return global; }\r\n throw new Error(\"unable to locate global object\");\r\n }\r\n\r\n /**\r\n * Returns current configuration.\r\n * If global (salaxy.config) configuration is null, default config (demo) is returned\r\n */\r\n public static get current(): ConfigLogic {\r\n return new ConfigLogic(this.getGlobalConfig() ?? this.defaultConfig);\r\n }\r\n\r\n /**\r\n * Set current configuration.\r\n */\r\n public static set current(config: Config) {\r\n this.setGlobalConfig(config);\r\n }\r\n\r\n /** Get global, globalThis object */\r\n public static get global(): any {\r\n return this.getGlobal();\r\n }\r\n}\r\n","/**\r\n * Very simple cookie implementation - at the moment for token storage only.\r\n * Expand if needed for other use cases (see todo section in the docs).\r\n *\r\n * @todo Expand this class as necessary e.g. something like this: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework\r\n * or this https://github.com/Booyanach/cookie-wrapper ... which unfortunately cannot be used at the moment, because they are GPL license.\r\n */\r\nexport class Cookies {\r\n\r\n /**\r\n * Gets a cookie value by a key\r\n * @param key - CName / key to look for.\r\n */\r\n public get(key: string): string {\r\n const cookie = document.cookie;\r\n const cookieParts = cookie.split(\";\");\r\n for (const item of cookieParts) {\r\n const cookiePart = decodeURIComponent(item).trim();\r\n if (cookiePart.indexOf(key + \"=\") === 0) {\r\n return cookiePart.substring(key.length + 1);\r\n }\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Sets a cookie value for the specified CName\r\n * @param cname - CName for the cookie value. Name is uri encoded as a fallback, but generally, you should make sure this is a valid cname.\r\n * @param value - Value to set for the cookie. Value is uri encoded.\r\n * @param expirationDays - Days until the cookie expires.\r\n * Set this to null or 0 to not set the expiration date at all.\r\n * This defaults the behavior where cookie is deleted when browser is closed.\r\n */\r\n public setCookie(cname: string, value: string, expirationDays?: number): void {\r\n cname = encodeURIComponent(cname);\r\n value = encodeURIComponent(value);\r\n\r\n if (expirationDays && expirationDays > 0) {\r\n const d = new Date();\r\n d.setTime(d.getTime() + (expirationDays * 24 * 60 * 60 * 1000));\r\n const expires = \"expires=\" + d.toUTCString();\r\n document.cookie = cname + \"=\" + value + \";\" + expires + \";path=/\";\r\n } else {\r\n document.cookie = cname + \"=\" + value + \";path=/\";\r\n }\r\n }\r\n}\r\n","import { Configs } from \"../../logic/Configs\";\r\nimport { Cookies } from \"../../util/Cookies\";\r\nimport { Ajax } from \"./Ajax\";\r\n\r\n/**\r\n * Provides wrapper methods for communicating with the Palkkaus.fi API.\r\n * The raw Ajax-access to the server methods: GET, POST and DELETE\r\n * with different return types and authentication / error events.\r\n * This is the JQuery based ajax implementation.\r\n */\r\nexport class AjaxJQuery implements Ajax {\r\n\r\n /**\r\n * By default (true) the token is set to salaxy-token -cookie.\r\n * Disable cookies with this flag.\r\n */\r\n public useCookie = true;\r\n\r\n /**\r\n * By default credentials are not used in http-calls.\r\n * Enable credentials with this flag.\r\n */\r\n public useCredentials = false;\r\n\r\n /**\r\n * The server address - root of the server. This is settable field.\r\n * Will probably be changed to a configuration object in the final version.\r\n */\r\n public serverAddress = \"https://test-api.salaxy.com\";\r\n\r\n private token: string;\r\n\r\n /**\r\n * Creates a new instance of AjaxJQuery\r\n */\r\n constructor() {\r\n const config = Configs.current;\r\n if (config) {\r\n // apiServer\r\n if (config.apiServer) {\r\n this.serverAddress = config.apiServer;\r\n }\r\n\r\n // useCredentials\r\n if (config.useCredentials != null) {\r\n this.useCredentials = config.useCredentials;\r\n }\r\n\r\n // useCookie\r\n if (config.useCookie != null) {\r\n this.useCookie = config.useCookie;\r\n }\r\n }\r\n }\r\n\r\n /** Gets the API address with version information. E.g. 'https://test-api.salaxy.com/v03/api' */\r\n public getApiAddress(): string {\r\n return this.serverAddress + \"/v03/api\";\r\n }\r\n\r\n /** Gets the Server address that is used as bases to the HTML queries. E.g. 'https://test-api.salaxy.com' */\r\n public getServerAddress(): string {\r\n return this.serverAddress;\r\n }\r\n\r\n /**\r\n * Gets a JSON-message from server using the API\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n *\r\n * @returns A Promise with result data. Standard Promise rejection to be used for error handling.\r\n */\r\n public getJSON(method: string): Promise<any> {\r\n\r\n const token = this.getCurrentToken();\r\n return this.getJQuery().ajax({\r\n dataType: \"json\",\r\n url: this.getUrl(method),\r\n xhrFields: {\r\n withCredentials: (token) ? false : this.useCredentials,\r\n },\r\n beforeSend: (request) => {\r\n if (token) {\r\n request.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Gets a HTML-message from server using the API\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n *\r\n * @returns A Promise with result html. Standard Promise rejection to be used for error handling.\r\n */\r\n public getHTML(method: string): Promise<string> {\r\n const token = this.getCurrentToken();\r\n return this.getJQuery().ajax({\r\n dataType: \"html\",\r\n url: this.getUrl(method),\r\n xhrFields: {\r\n withCredentials: (token) ? false : this.useCredentials,\r\n },\r\n beforeSend: (request) => {\r\n if (token) {\r\n request.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * POSTS data to server and receives back a JSON-message.\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n * @param data - The data that is posted to the server.\r\n *\r\n * @returns A Promise with result data. Standard Promise rejection to be used for error handling.\r\n */\r\n public postJSON(method: string, data: any): Promise<any> {\r\n const token = this.getCurrentToken();\r\n return this.getJQuery().ajax({\r\n type: \"POST\",\r\n url: this.getUrl(method),\r\n data,\r\n dataType: \"json\",\r\n xhrFields: {\r\n withCredentials: (token) ? false : this.useCredentials,\r\n },\r\n beforeSend: (request) => {\r\n if (token) {\r\n request.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * POSTS data to server and receives back HTML.\r\n *\r\n * @param method - The API method is the url starting from api version, e.g. '/v03/api'. E.g. '/calculator/new'\r\n * @param data - The data that is posted to the server.\r\n *\r\n * @returns A Promise with result data. Standard Promise rejection to be used for error handling.\r\n */\r\n public postHTML(method: string, data: any): Promise<string> {\r\n const token = this.getCurrentToken();\r\n return this.getJQuery().ajax({\r\n type: \"POST\",\r\n url: this.getUrl(method),\r\n data,\r\n dataType: \"html\",\r\n xhrFields: {\r\n withCredentials: (token) ? false : this.useCredentials,\r\n },\r\n beforeSend: (request) => {\r\n if (token) {\r\n request.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Sends a DELETE-message to server using the API\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n *\r\n * @returns A Promise with result data. Standard Promise rejection to be used for error handling.\r\n */\r\n public remove(method: string): Promise<any> {\r\n const token = this.getCurrentToken();\r\n return this.getJQuery().ajax({\r\n type: \"DELETE\",\r\n url: this.getUrl(method),\r\n xhrFields: {\r\n withCredentials: (token) ? false : this.useCredentials,\r\n },\r\n beforeSend: (request) => {\r\n if (token) {\r\n request.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Gets the current token.\r\n * Will check the salaxy-token cookie if the token is persisted there\r\n */\r\n public getCurrentToken(): string {\r\n if (!this.token && this.useCookie) {\r\n this.token = new Cookies().get(\"salaxy-token\") || \"\";\r\n }\r\n return this.token;\r\n }\r\n\r\n /**\r\n * Sets the current token. The token is set to cookie called \"salaxy-token\" or\r\n * if the HTML page is running from local computer, it is set to local storage.\r\n *\r\n * @param token - the authentication token to store.\r\n */\r\n public setCurrentToken(token: string | null): void {\r\n if (this.useCookie) {\r\n new Cookies().setCookie(\"salaxy-token\", token || \"\");\r\n }\r\n this.token = token;\r\n }\r\n\r\n /**\r\n * Implements the OAuth2 \"Resource Owner Password Credentials Grant\" flow (RFC6749 4.3).\r\n * This method is not typically used in production web sites - use Implicit Grant instead for client side JavScript (SPAs).\r\n * However, it is very useful in development, testing, trusted helpers and server-side scenarios.\r\n */\r\n public resourceOwnerLogin(username: string, password: string): void {\r\n return this.getJQuery().ajax({\r\n type: \"POST\",\r\n url: this.getServerAddress() + \"/oauth2/token\",\r\n data: {\r\n grant_type: \"password\",\r\n username,\r\n password,\r\n },\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n success: (data, textStatus, request) => {\r\n this.setCurrentToken(data.access_token);\r\n },\r\n dataType: \"json\",\r\n });\r\n }\r\n\r\n private getJQuery() {\r\n const jQuery = Configs.global.jQuery;\r\n if (jQuery) {\r\n return jQuery;\r\n } else {\r\n throw new Error(\"ERROR: No jQuery. AjaxJQuery requires jQuery to be referenced.\");\r\n }\r\n }\r\n\r\n /** If missing, append the API server address to the given url method string */\r\n private getUrl(method: string): string {\r\n if (!method || method.trim() === \"\") {\r\n return null;\r\n }\r\n if (method.toLowerCase().startsWith(\"http\")) {\r\n return method;\r\n }\r\n if (method.toLowerCase().startsWith(\"/v\")) {\r\n return this.getServerAddress() + method;\r\n }\r\n return this.getApiAddress() + method;\r\n }\r\n}\r\n","import { Configs } from \"../../logic/Configs\";\r\nimport { Cookies } from \"../../util/Cookies\";\r\nimport { Ajax } from \"./Ajax\";\r\n\r\n/**\r\n * Reference to XDomainRequest for IE8/9.\r\n * @ignore\r\n */\r\ndeclare let XDomainRequest;\r\n\r\n/**\r\n * Provides wrapper methods for communicating with the Palkkaus.fi API.\r\n * The raw Ajax-access to the server methods: GET, POST and DELETE\r\n * with different return types and authentication / error events.\r\n * This is the XMLHttpRequest based Ajax implementation.\r\n */\r\nexport class AjaxXHR implements Ajax {\r\n\r\n /**\r\n * By default (true) the token is set to salaxy-token -cookie.\r\n * Disable cookies with this flag.\r\n */\r\n public useCookie = true;\r\n\r\n /**\r\n * By default credentials are not used in http-calls.\r\n * Enable credentials with this flag (force disabled when the token is set).\r\n */\r\n public useCredentials: boolean;\r\n\r\n /**\r\n * The server address - root of the server. This is settable field.\r\n * Will probably be changed to a configuration object in the final version.\r\n */\r\n public serverAddress = \"https://test-api.salaxy.com\";\r\n\r\n private token: string;\r\n\r\n /**\r\n * Creates a new instance of AjaxXHR\r\n */\r\n constructor() {\r\n\r\n const config = Configs.current;\r\n if (config) {\r\n // apiServer\r\n if (config.apiServer) {\r\n this.serverAddress = config.apiServer;\r\n }\r\n\r\n // useCredentials\r\n if (config.useCredentials != null) {\r\n this.useCredentials = config.useCredentials;\r\n }\r\n\r\n // useCookie\r\n if (config.useCookie != null) {\r\n this.useCookie = config.useCookie;\r\n }\r\n }\r\n }\r\n\r\n /** Gets the API address with version information. E.g. 'https://test-api.salaxy.com/v03/api' */\r\n public getApiAddress(): string {\r\n return this.serverAddress + \"/v03/api\";\r\n }\r\n\r\n /** Gets the Server address that is used as bases to the HTML queries. E.g. 'https://test-api.salaxy.com' */\r\n public getServerAddress(): string {\r\n return this.serverAddress;\r\n }\r\n\r\n /**\r\n * Gets a JSON-message from server using the API\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n *\r\n * @returns A Promise with result data. Standard Promise rejection to be used for error handling.\r\n */\r\n public getJSON(method: string): Promise<any> {\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n const xhr = this.createCORSRequest(\"GET\", this.getUrl(method));\r\n if (!xhr) {\r\n return reject(new Error(\"CORS not supported!\"));\r\n }\r\n\r\n xhr.setRequestHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\r\n xhr.setRequestHeader(\"Accept\", \"application/json; charset=UTF-8\");\r\n // xhr.setRequestHeader(\"Cache-Control\", \"max-age=0\");\r\n\r\n const token = this.getCurrentToken();\r\n if (token) {\r\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n xhr.withCredentials = (token) ? false : this.useCredentials;\r\n\r\n xhr.onreadystatechange = () => {\r\n if (xhr.readyState === XMLHttpRequest.DONE) {\r\n if (xhr.status === 200) {\r\n try {\r\n const response = JSON.parse(xhr.responseText);\r\n return resolve(response);\r\n } catch (error) {\r\n return reject(error);\r\n }\r\n } else {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n }\r\n }\r\n };\r\n xhr.onerror = () => {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n };\r\n\r\n xhr.send();\r\n });\r\n }\r\n\r\n /**\r\n * Gets a HTML-message from server using the API\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n *\r\n * @returns A Promise with result html. Standard Promise rejection to be used for error handling.\r\n */\r\n public getHTML(method: string): Promise<string> {\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n const xhr = this.createCORSRequest(\"GET\", this.getUrl(method));\r\n if (!xhr) {\r\n return reject(new Error(\"CORS not supported!\"));\r\n }\r\n\r\n xhr.setRequestHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\r\n xhr.setRequestHeader(\"Accept\", \"application/json; charset=UTF-8\");\r\n // xhr.setRequestHeader(\"Cache-Control\", \"max-age=0\");\r\n\r\n const token = this.getCurrentToken();\r\n if (token) {\r\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n xhr.withCredentials = (token) ? false : this.useCredentials;\r\n\r\n xhr.onreadystatechange = () => {\r\n if (xhr.readyState === XMLHttpRequest.DONE) {\r\n if (xhr.status === 200) {\r\n return resolve(xhr.responseText);\r\n } else {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n }\r\n }\r\n };\r\n xhr.onerror = () => {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n };\r\n\r\n xhr.send();\r\n });\r\n }\r\n\r\n /**\r\n * POSTS data to server and receives back a JSON-message.\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n * @param data - The data that is posted to the server.\r\n *\r\n * @returns A Promise with result. Standard Promise rejection to be used for error handling.\r\n */\r\n public postJSON(method: string, data: any): Promise<any> {\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n const xhr = this.createCORSRequest(\"POST\", this.getUrl(method));\r\n if (!xhr) {\r\n return reject(new Error(\"CORS not supported!\"));\r\n }\r\n\r\n xhr.setRequestHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\r\n xhr.setRequestHeader(\"Accept\", \"application/json; charset=UTF-8\");\r\n // xhr.setRequestHeader(\"Cache-Control\", \"max-age=0\");\r\n\r\n const token = this.getCurrentToken();\r\n if (token) {\r\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n xhr.withCredentials = (token) ? false : this.useCredentials;\r\n\r\n xhr.onreadystatechange = () => {\r\n if (xhr.readyState === XMLHttpRequest.DONE) {\r\n if (xhr.status === 200) {\r\n try {\r\n const response = JSON.parse(xhr.responseText);\r\n return resolve(response);\r\n } catch (error) {\r\n return reject(error);\r\n }\r\n } else {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n }\r\n }\r\n };\r\n xhr.onerror = () => {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n };\r\n\r\n const params = (!data || typeof data === \"string\") ? data : JSON.stringify(data);\r\n\r\n xhr.send(params);\r\n });\r\n }\r\n\r\n /**\r\n * POSTS data to server and receives back HTML.\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n * @param data - The data that is posted to the server.\r\n *\r\n * @returns A Promise with result. Standard Promise rejection to be used for error handling.\r\n */\r\n public postHTML(method: string, data: any): Promise<string> {\r\n\r\n return new Promise((resolve, reject) => {\r\n\r\n const xhr = this.createCORSRequest(\"POST\", this.getUrl(method));\r\n if (!xhr) {\r\n return reject(new Error(\"CORS not supported!\"));\r\n }\r\n\r\n xhr.setRequestHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\r\n xhr.setRequestHeader(\"Accept\", \"application/json; charset=UTF-8\");\r\n // xhr.setRequestHeader(\"Cache-Control\", \"max-age=0\");\r\n\r\n const token = this.getCurrentToken();\r\n if (token) {\r\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n xhr.withCredentials = (token) ? false : this.useCredentials;\r\n\r\n xhr.onreadystatechange = () => {\r\n if (xhr.readyState === XMLHttpRequest.DONE) {\r\n if (xhr.status === 200) {\r\n return resolve(xhr.responseText);\r\n } else {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n }\r\n }\r\n };\r\n xhr.onerror = () => {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n };\r\n\r\n const params = (!data || typeof data === \"string\") ? data : JSON.stringify(data);\r\n\r\n xhr.send(params);\r\n });\r\n }\r\n\r\n /**\r\n * Sends a DELETE-message to server using the API\r\n *\r\n * @param method - The API method is the url path after the api version segments (e.g. '/v03/api')\r\n * and starts with a forward slash, e.g. '/calculator/new', or a full URL address.\r\n *\r\n * @returns A Promise with result. Standard Promise rejection to be used for error handling.\r\n */\r\n public remove(method: string): Promise<any> {\r\n return new Promise((resolve, reject) => {\r\n\r\n const xhr = this.createCORSRequest(\"DELETE\", this.getUrl(method));\r\n if (!xhr) {\r\n return reject(new Error(\"CORS not supported!\"));\r\n }\r\n\r\n xhr.setRequestHeader(\"Content-Type\", \"application/json; charset=UTF-8\");\r\n xhr.setRequestHeader(\"Accept\", \"application/json; charset=UTF-8\");\r\n // xhr.setRequestHeader(\"Cache-Control\", \"max-age=0\");\r\n\r\n const token = this.getCurrentToken();\r\n if (token) {\r\n xhr.setRequestHeader(\"Authorization\", \"Bearer \" + token);\r\n }\r\n xhr.withCredentials = (token) ? false : this.useCredentials;\r\n\r\n xhr.onreadystatechange = () => {\r\n if (xhr.readyState === XMLHttpRequest.DONE) {\r\n if (xhr.status === 200) {\r\n try {\r\n const response = JSON.parse(xhr.responseText);\r\n return resolve(response);\r\n } catch (error) {\r\n return reject(error);\r\n }\r\n } else {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n }\r\n }\r\n };\r\n xhr.onerror = () => {\r\n return reject(new Error(\"There was a problem with the request.\"));\r\n };\r\n\r\n xhr.send();\r\n });\r\n }\r\n\r\n /**\r\n * Gets the current token.\r\n * Will check the salaxy-token cookie if the token is persisted there\r\n */\r\n public getCurrentToken(): string {\r\n if (!this.token && this.useCookie) {\r\n this.token = new Cookies().get(\"salaxy-token\") || \"\";\r\n }\r\n return this.token;\r\n }\r\n\r\n /**\r\n * Sets the current token. The token is set to cookie called \"salaxy-token\" or\r\n * if the HTML page is running from local computer, it is set to local storage.\r\n *\r\n * @param token - the authentication token to store.\r\n */\r\n public setCurrentToken(token: string | null): void {\r\n if (this.useCookie) {\r\n new Cookies().setCookie(\"salaxy-token\", token || \"\");\r\n }\r\n this.token = token;\r\n }\r\n\r\n /** If missing, append the API server address to the given url method string */\r\n private getUrl(method: string): string {\r\n if (!method || method.trim() === \"\") {\r\n return null;\r\n }\r\n if (method.toLowerCase().startsWith(\"http\")) {\r\n return method;\r\n }\r\n if (method.toLowerCase().startsWith(\"/v\")) {\r\n return this.getServerAddress() + method;\r\n }\r\n return this.getApiAddress() + method;\r\n }\r\n\r\n private createCORSRequest(method, url) {\r\n let xhr = new XMLHttpRequest();\r\n if (\"withCredentials\" in xhr) {\r\n // XHR for Chrome/Firefox/Opera/Safari.\r\n xhr.open(method, url, true);\r\n } else if (typeof XDomainRequest !== \"undefined\") {\r\n // XDomainRequest for IE8/9.\r\n xhr = new XDomainRequest();\r\n xhr.open(method, url);\r\n } else {\r\n // CORS not supported.\r\n xhr = null;\r\n }\r\n return xhr;\r\n }\r\n}\r\n","import { OpenAPIV3 } from \"../../@types\";\r\n\r\nimport { InputMetadata } from \"./InputMetadata\";\r\n\r\n/**\r\n * Provides framework independent helpers for creating HTML forms\r\n * based on JSON schema and other metadata.\r\n */\r\nexport class FormHelpers {\r\n\r\n /**\r\n * Gets a valid input type, format and other input properties from schema.\r\n * @param schema The property schema based on which the input is created.\r\n * @param propertyName Name of property or null if the input is not created from a property, but from model directly.\r\n * @param dataBindingPath Path for the data model.\r\n * Default is \"form\": The current form. Could be a a longer path e.g. \"form.result.employerCalc\"\r\n */\r\n public static getInputMetadata(schema: OpenAPIV3.SchemaObject, propertyName: string, dataBindingPath = \"form\"): InputMetadata {\r\n const result: InputMetadata = {\r\n name: propertyName,\r\n path: null,\r\n type: schema.type,\r\n format: schema.format,\r\n isEnum: false,\r\n };\r\n propertyName = propertyName || \"\";\r\n result.path = result.name ? (dataBindingPath ? (dataBindingPath + \".\" + result.name) : result.name) : dataBindingPath;\r\n switch (result.type) {\r\n case \"number\":\r\n case \"integer\": // TODO: Add enum support to numbers.\r\n case \"boolean\":\r\n case \"object\":\r\n case \"array\":\r\n break;\r\n case \"string\":\r\n result.isEnum = schema.enum?.length > 0;\r\n break;\r\n default:\r\n result.type = \"error\";\r\n result.content = `Unhandled data type '${result.type}', format '${result.format}' in '${propertyName || \"no property name\"}'.`;\r\n return result;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * Gets the necessary metadata for generating the inputs for the specified model of type \"object\".\r\n * If the schema is not of type \"object\", returns null.\r\n * @param schema Schema for which the user interface is generated.\r\n * @param dataBindingPath Path for the data model.\r\n * Default is \"form\": The current form. Could be a a longer path e.g. \"form.result.employerCalc\"\r\n */\r\n public static getInputsForObject(schema: OpenAPIV3.SchemaObject, dataBindingPath = \"form\"): InputMetadata[] {\r\n if (schema.type === \"object\") {\r\n return Object.keys(schema.properties).map((key) => this.getInputMetadata(schema, key, dataBindingPath));\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets input for the schema itself.\r\n * @param schema Schema for which the input component is generated.\r\n * @param propertyName Property name in relation to schema. This may be used in language versioning / texts.\r\n * @param dataBindingPath Path for the data binding within the form.\r\n */\r\n public static getInputForSelf(schema: OpenAPIV3.SchemaObject, propertyName: s