@bisondesk/commons-sdk 1.0.587 → 1.0.589
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apis/picklists.d.ts.map +1 -1
- package/lib/apis/picklists.js +11 -3
- package/lib/apis/picklists.js.map +1 -1
- package/lib/date-utils.js.map +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/fetch.d.ts +1 -1
- package/lib/fetch.d.ts.map +1 -1
- package/lib/fetch.js.map +1 -1
- package/lib/formatting.js.map +1 -1
- package/lib/leasing.js.map +1 -1
- package/lib/location-utils.js.map +1 -1
- package/lib/money.js.map +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js.map +1 -1
- package/package.json +12 -8
- package/src/apis/picklists.ts +16 -8
- package/src/date-utils.ts +1 -1
- package/src/errors.ts +1 -1
- package/src/fetch.ts +4 -4
- package/src/formatting.ts +2 -2
- package/src/leasing.ts +1 -1
- package/src/location-utils.ts +4 -4
- package/src/money.ts +1 -1
- package/src/storage.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picklists.d.ts","sourceRoot":"/","sources":["apis/picklists.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"picklists.d.ts","sourceRoot":"/","sources":["apis/picklists.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,eAAO,MAAM,yBAAyB,GACpC,SAAS,oBAAoB,KAC5B,OAAO,CAAC,yBAAyB,CAUnC,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,SAAS,oBAAoB,KAC5B,OAAO,CAAC,mBAAmB,CAU7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,KAAK,sBAAsB,EAC3B,WAAW,MAAM,KAChB,OAAO,CAAC,MAAM,EAAE,CAmBlB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,0BAA0B,KAClC,OAAO,CAAC,aAAa,CAiBvB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,UAAU,oBAAoB,EAAE,EAChC,eAAe,MAAM,EACrB,YAAY,MAAM,KACjB,OAAO,CAAC,yBAAyB,CAyBnC,CAAC"}
|
package/lib/apis/picklists.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import fetch from 'node-fetch';
|
|
2
|
+
import { TENANT_ID_ADMIN_HEADER } from '../constants.js';
|
|
2
3
|
import { XError } from '../errors.js';
|
|
3
4
|
import { cleanHeaders, fetchJson, getAdminAuth } from '../fetch.js';
|
|
4
|
-
import { TENANT_ID_ADMIN_HEADER } from '../constants.js';
|
|
5
5
|
export const getMultiplePicklistValues = async (request) => {
|
|
6
6
|
const auth = await getAdminAuth();
|
|
7
|
-
return fetchJson(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`, {
|
|
7
|
+
return fetchJson(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`, {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
headers: { Authorization: auth, 'Content-Type': 'application/json' },
|
|
10
|
+
body: JSON.stringify(request),
|
|
11
|
+
});
|
|
8
12
|
};
|
|
9
13
|
export const getMultiplePicklistFullValues = async (request) => {
|
|
10
14
|
const auth = await getAdminAuth();
|
|
11
|
-
return fetchJson(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read/full`, {
|
|
15
|
+
return fetchJson(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read/full`, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: { Authorization: auth, 'Content-Type': 'application/json' },
|
|
18
|
+
body: JSON.stringify(request),
|
|
19
|
+
});
|
|
12
20
|
};
|
|
13
21
|
export const getPicklistOptions = async (req, tenantId) => {
|
|
14
22
|
const auth = await getAdminAuth();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picklists.js","sourceRoot":"/","sources":["apis/picklists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"picklists.js","sourceRoot":"/","sources":["apis/picklists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAC5C,OAA6B,EACO,EAAE;IACtC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;IAClC,OAAO,SAAS,CACd,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,0BAA0B,EACxD;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE;QACpE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,EAChD,OAA6B,EACC,EAAE;IAChC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;IAClC,OAAO,SAAS,CACd,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,+BAA+B,EAC7D;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,c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AAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC,IAAI,EAAS,CAAC;IAChC,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,EAC/C,QAAgC,EAChC,aAAqB,EACrB,UAAkB,EACkB,EAAE;IACtC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;IAElC,MAAM,GAAG,GAAyB;QAChC,aAAa;QACb,QAAQ;QACR,UAAU;KACX,CAAC;IAEF,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,0BAA0B,EAAE;QAC/F,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,YAAY,CAAC;YACpB,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,kBAAkB;SACnC,CAAC;QACF,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;KAC1B,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC,IAAI,EAAS,CAAC;IAChC,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEnC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC","sourcesContent":["import fetch, { Response } from 'node-fetch';\nimport { TENANT_ID_ADMIN_HEADER } from '../constants.js';\nimport { XError } from '../errors.js';\nimport { cleanHeaders, fetchJson, getAdminAuth } from '../fetch.js';\nimport {\n AdHocPicklistRequest,\n AdHocPicklistValueDisplay,\n AdHocPicklistValues,\n PicklistOptionsRequest,\n PicklistValue,\n PicklistValueRequest,\n PicklistValueUpdateRequest,\n} from '../picklists.js';\nimport { Option } from '../types.js';\n\nexport const getMultiplePicklistValues = async (\n request: AdHocPicklistRequest,\n): Promise<AdHocPicklistValueDisplay> => {\n const auth = await getAdminAuth();\n return fetchJson<AdHocPicklistValueDisplay>(\n `${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`,\n {\n method: 'POST',\n headers: { Authorization: auth, 'Content-Type': 'application/json' },\n body: JSON.stringify(request),\n },\n );\n};\n\nexport const getMultiplePicklistFullValues = async (\n request: AdHocPicklistRequest,\n): Promise<AdHocPicklistValues> => {\n const auth = await getAdminAuth();\n return fetchJson<AdHocPicklistValues>(\n `${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read/full`,\n {\n method: 'POST',\n headers: { Authorization: auth, 'Content-Type': 'application/json' },\n body: JSON.stringify(request),\n },\n );\n};\n\nexport const getPicklistOptions = async (\n req: PicklistOptionsRequest,\n tenantId?: string,\n): Promise<Option[]> => {\n const auth = await getAdminAuth();\n\n const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/options`, {\n method: 'POST',\n headers: cleanHeaders({\n Authorization: auth,\n 'Content-Type': 'application/json',\n [TENANT_ID_ADMIN_HEADER]: tenantId,\n }),\n body: JSON.stringify(req),\n });\n\n if (response.ok) {\n return response.json() as any;\n }\n\n const body = await response.text();\n throw new XError(response.statusText, { body, req });\n};\n\nexport const upsertPicklistValue = async (\n request: PicklistValueUpdateRequest,\n): Promise<PicklistValue> => {\n const auth = await getAdminAuth();\n const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/value`, {\n method: 'POST',\n headers: {\n Authorization: auth,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(request),\n });\n\n if (response.ok) {\n return response.json() as any;\n }\n\n const body = await response.text();\n throw new XError(response.statusText, { body });\n};\n\nexport const getAdhocPicklistDisplayValue = async (\n requests: PicklistValueRequest[],\n preferredLang: string,\n tenantLang: string,\n): Promise<AdHocPicklistValueDisplay> => {\n const auth = await getAdminAuth();\n\n const req: AdHocPicklistRequest = {\n preferredLang,\n requests,\n tenantLang,\n };\n\n const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`, {\n method: 'POST',\n headers: cleanHeaders({\n Authorization: auth,\n 'Content-Type': 'application/json',\n }),\n body: JSON.stringify(req),\n });\n\n if (response.ok) {\n return response.json() as any;\n }\n\n const body = await response.text();\n\n throw new XError(response.statusText, { body, req });\n};\n"]}
|
package/lib/date-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-utils.js","sourceRoot":"/","sources":["date-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAW,EAAE,SAAe,EAAW,EAAE,CACrE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAW,EAAE,SAAe,EAAW,EAAE,CACtE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAW,EAAE,cAAoB,EAAE,YAAkB,EAAW,EAAE,CAC1F,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAgC,IAAI,IAAI,EAAE,EAAE,EAAE,CACtE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAEhC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAA+B,EAC/B,QAAgB,EAChB,SAAiB,EACjB,EAAE;IACF,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IAGnC,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAGxF,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;IAGjE,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAC;IAGjE,OAAO,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAa,IAAI,IAAI,EAAE,EAAU,EAAE;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACxD,CAAC,CAAC","sourcesContent":["import { compareAsc, format, getISOWeek, isBefore } from 'date-fns';\n\nexport const isSameOrAfter = (value: Date, reference: Date): boolean =>\n compareAsc(value, reference) >= 0;\n\nexport const isSameOrBefore = (value: Date, reference: Date): boolean =>\n compareAsc(value, reference) <= 0;\n\nexport const isBetween = (value: Date, startInclusive: Date, endExclusive: Date): boolean =>\n isSameOrAfter(value, startInclusive) && isBefore(value, endExclusive);\n\nexport const isoString = (value: number | string | Date = new Date()) =>\n new Date(value).toISOString();\n\nexport const formatInTimeZone = (\n rawDate: number | string | Date,\n timezone: string,\n formatStr: string
|
|
1
|
+
{"version":3,"file":"date-utils.js","sourceRoot":"/","sources":["date-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,E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AU,EAAE;IACrE,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACxD,CAAC,CAAC","sourcesContent":["import { compareAsc, format, getISOWeek, isBefore } from 'date-fns';\n\nexport const isSameOrAfter = (value: Date, reference: Date): boolean =>\n compareAsc(value, reference) >= 0;\n\nexport const isSameOrBefore = (value: Date, reference: Date): boolean =>\n compareAsc(value, reference) <= 0;\n\nexport const isBetween = (value: Date, startInclusive: Date, endExclusive: Date): boolean =>\n isSameOrAfter(value, startInclusive) && isBefore(value, endExclusive);\n\nexport const isoString = (value: number | string | Date = new Date()) =>\n new Date(value).toISOString();\n\nexport const formatInTimeZone = (\n rawDate: number | string | Date,\n timezone: string,\n formatStr: string,\n) => {\n const baseDate = new Date(rawDate);\n\n // Convert date to the target timezone\n const offsetDate = new Date(baseDate.toLocaleString(undefined, { timeZone: timezone }));\n\n // Calculate the timezone difference in milliseconds\n const timezoneOffset = baseDate.getTime() - offsetDate.getTime();\n\n // Apply the offset to get the correct date in the target timezone\n const targetDate = new Date(baseDate.getTime() - timezoneOffset);\n\n // Format the date\n return format(targetDate, formatStr);\n};\n\n// Function to format date as YYYY-WWW\nexport const formatDateToISOWeek = (date: Date = new Date()): string => {\n const year = date.getFullYear();\n const week = getISOWeek(date);\n return `${year}-W${week.toString().padStart(2, '0')}`;\n};\n"]}
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"/","sources":["errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,MAAO,SAAQ,KAAK;IAC/B,QAAQ,CAAM;IACd,IAAI,CAAW;IAEf,YAAY,OAAgB,EAAE,QAAc,EAAE,IAAc;QAC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AAM;IAEd,YAAY,OAAgB,EAAE,MAA4B,EAAE,QAAc;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,gBAAgB,GAAG;gBACtB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CACxB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAA2B,EAAwB,EAAE,CAAC,CAAC;oBAC3E,OAAO;oBACP,IAAI;oBACJ,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;iBACzC,CAAC,CACH;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF","sourcesContent":["import Joi from 'joi';\n\nexport class XError extends Error {\n errorCtx: any;\n bail?: boolean;\n\n constructor(message?: string, errorCtx?: any, bail?: boolean) {\n super(message);\n this.name = 'XError';\n this.errorCtx = errorCtx;\n this.bail = bail;\n }\n}\n\nexport class WrappedError extends Error {\n errorCtx: any;\n\n constructor(err: Error, errorCtx?: any) {\n super(err.message);\n this.name = err.name;\n this.stack = err.stack;\n this.errorCtx = errorCtx;\n }\n}\n\nexport class AsyncStopError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = 'AsyncStopError';\n }\n}\n\nexport class ForbiddenError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = 'ForbiddenError';\n }\n}\n\nexport class EntryAlreadyExistsError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = 'EntryAlreadyExistsError';\n }\n}\n\nexport class NotFoundError extends XError {\n constructor(message?: string, errorCtx?: any) {\n super(message, errorCtx);\n this.name = 'NotFoundError';\n }\n}\n\ntype FieldValidationError = {\n message: string;\n path: Array<string | number>;\n type: string;\n};\nexport class InvalidArgumentsError extends Error {\n validationErrors?: { errors: FieldValidationError[] };\n isValidation = true;\n errorCtx: any;\n\n constructor(message?: string, errors?: Joi.ValidationError, errorCtx?: any) {\n super(message);\n this.name = 'InvalidArgumentsError';\n this.errorCtx = errorCtx;\n\n if (errors != null) {\n this.validationErrors = {\n errors: errors.details.map(\n ({ path, type, message }: Joi.ValidationErrorItem): FieldValidationError => ({\n message,\n path,\n type: type === 'custom' ? message : type,\n })
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"/","sources":["errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,MAAO,SAAQ,KAAK;IAC/B,QAAQ,CAAM;IACd,IAAI,CAAW;IAEf,YAAY,OAAgB,EAAE,QAAc,EAAE,IAAc;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAM;IAEd,YAAY,GAAU,EAAE,QAAc;QACpC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF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C,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF","sourcesContent":["import Joi from 'joi';\n\nexport class XError extends Error {\n errorCtx: any;\n bail?: boolean;\n\n constructor(message?: string, errorCtx?: any, bail?: boolean) {\n super(message);\n this.name = 'XError';\n this.errorCtx = errorCtx;\n this.bail = bail;\n }\n}\n\nexport class WrappedError extends Error {\n errorCtx: any;\n\n constructor(err: Error, errorCtx?: any) {\n super(err.message);\n this.name = err.name;\n this.stack = err.stack;\n this.errorCtx = errorCtx;\n }\n}\n\nexport class AsyncStopError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = 'AsyncStopError';\n }\n}\n\nexport class ForbiddenError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = 'ForbiddenError';\n }\n}\n\nexport class EntryAlreadyExistsError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = 'EntryAlreadyExistsError';\n }\n}\n\nexport class NotFoundError extends XError {\n constructor(message?: string, errorCtx?: any) {\n super(message, errorCtx);\n this.name = 'NotFoundError';\n }\n}\n\ntype FieldValidationError = {\n message: string;\n path: Array<string | number>;\n type: string;\n};\nexport class InvalidArgumentsError extends Error {\n validationErrors?: { errors: FieldValidationError[] };\n isValidation = true;\n errorCtx: any;\n\n constructor(message?: string, errors?: Joi.ValidationError, errorCtx?: any) {\n super(message);\n this.name = 'InvalidArgumentsError';\n this.errorCtx = errorCtx;\n\n if (errors != null) {\n this.validationErrors = {\n errors: errors.details.map(\n ({ path, type, message }: Joi.ValidationErrorItem): FieldValidationError => ({\n message,\n path,\n type: type === 'custom' ? message : type,\n }),\n ),\n };\n }\n }\n}\n\nexport class UnauthorizedError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = 'UnauthorizedError';\n }\n}\n"]}
|
package/lib/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HeadersInit, RequestInfo, RequestInit } from 'node-fetch';
|
|
2
1
|
import type { URL } from 'node:url';
|
|
2
|
+
import type { HeadersInit, RequestInfo, RequestInit } from 'node-fetch';
|
|
3
3
|
export declare function fetchJson<T>(url: URL | RequestInfo, init?: RequestInit, opts?: {
|
|
4
4
|
denyEmptyResponse?: true;
|
|
5
5
|
}): Promise<T>;
|
package/lib/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"/","sources":["fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"/","sources":["fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIxE,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,EAAE,GAAG,GAAG,WAAW,EACtB,IAAI,CAAC,EAAE,WAAW,EAClB,IAAI,CAAC,EAAE;IAAE,iBAAiB,CAAC,EAAE,IAAI,CAAA;CAAE,GAClC,OAAO,CAAC,CAAC,CAAC,CAAC;AAEd,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,EAAE,GAAG,GAAG,WAAW,EACtB,IAAI,CAAC,EAAE,WAAW,EAClB,IAAI,CAAC,EAAE;IAAE,iBAAiB,EAAE,KAAK,CAAA;CAAE,GAClC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AAqC1B,eAAO,MAAM,YAAY,QAAa,OAAO,CAAC,MAAM,CAMnD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,KAAG,MAOxE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,KAAG,WACF,CAAC"}
|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C,6BAA6B,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAA8C,EAAe,EAAE,CAC1F,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC","sourcesContent":["import type { URL } from 'node:url';\nimport type { HeadersInit, RequestInfo, RequestInit } from 'node-fetch';\nimport { TENANT_ID_ADMIN_HEADER } from './constants.js';\nimport { InvalidArgumentsError, XError } from './errors.js';\n\nexport function fetchJson<T>(\n url: URL | RequestInfo,\n init?: RequestInit,\n opts?: { denyEmptyResponse?: true },\n): Promise<T>;\n\nexport function fetchJson<T>(\n url: URL | RequestInfo,\n init?: RequestInit,\n opts?: { denyEmptyResponse: false },\n): Promise<T | undefined>;\n\nexport async function fetchJson<T>(\n url: URL | RequestInfo,\n init?: RequestInit,\n opts?: { denyEmptyResponse?: boolean },\n): Promise<T | undefined> {\n // sometimes the origin ends with a slash and when we append the path it gets a double slash\n url = url.toString().replace(/([^:]\\/)\\/+/g, '$1');\n\n const response = await fetch(url, init as any);\n\n if (!response.ok) {\n const body = await response.text();\n throw new XError(response.statusText, {\n method: init?.method,\n url,\n body: init?.body,\n response: body,\n status: response.status,\n });\n }\n\n if (!opts?.denyEmptyResponse && response.status === 204) {\n return undefined;\n } else if (response.status === 204 && opts?.denyEmptyResponse) {\n throw new XError('No content returned from the server', {\n method: init?.method,\n url,\n body: init?.body,\n status: response.status,\n });\n }\n\n return response.json() as Promise<T>;\n}\n\nexport const getAdminAuth = async (): Promise<string> => {\n if (!process.env.ADMIN_KEY) {\n return '';\n }\n\n return `AdminKey ${process.env.ADMIN_KEY}`;\n};\n\nexport const getTenantIdHeader = (headers: { [name: string]: unknown }): string => {\n const tenantId = headers[TENANT_ID_ADMIN_HEADER];\n if (!tenantId || typeof tenantId !== 'string') {\n throw new InvalidArgumentsError('Missing or invalid tenantId');\n }\n\n return tenantId;\n};\n\nexport const cleanHeaders = (headers: { [key: string]: string | undefined }): HeadersInit =>\n Object.entries(headers).filter((h): h is [string, string] => h[1] != null);\n"]}
|
package/lib/formatting.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.js","sourceRoot":"/","sources":["formatting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAA4C,EAC5C,EACE,SAAS,GAAG,iBAAiB,EAC7B,MAAM,GAAG,OAAO,MAC4C,EAAE,EAChE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAc,EACd,MAAM,GAAG,OAAO,EAChB,gBAAgB,GAAG,KAAK,EACxB,UAAoC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAC/C,EAAE;IACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACnC,qBAAqB,EAAE,QAAQ,CAAC,aAAa;QAC7C,qBAAqB,EAAE,QAAQ,CAAC,aAAa;QAC7C,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,IAAI;QACjB,GAAG,OAAO;KACX,CAAC;SACC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC9F,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { getCurrencySettings } from './money.js';\n\nexport const DEFAULT_SEPARATOR = ' • ';\n\nexport const joinWithSeparator = (\n text: (string | number | undefined | null)[],\n {\n separator = DEFAULT_SEPARATOR,\n filter = Boolean,\n }: { separator?: string; filter?: (value: any) => boolean } = {}
|
|
1
|
+
{"version":3,"file":"formatting.js","sourceRoot":"/","sources":["formatting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAA4C,EAC5C,EACE,SAAS,GAAG,iBAAiB,EAC7B,MAAM,GAAG,OAAO,MAC4C,EAAE,EAChE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAc,EACd,MAAM,GAAG,OAAO,EAChB,gBAAgB,GAAG,KAAK,EACxB,UAAoC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAC/C,EAAE;IACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACnC,qBAAqB,EAAE,QAAQ,CAAC,aAAa;QAC7C,qBAAqB,EAAE,QAAQ,CAAC,aAAa;QAC7C,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,IAAI;QACjB,GAAG,OAAO;KACX,CAAC;SACC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC9F,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC","sourcesContent":["import { getCurrencySettings } from './money.js';\n\nexport const DEFAULT_SEPARATOR = ' • ';\n\nexport const joinWithSeparator = (\n text: (string | number | undefined | null)[],\n {\n separator = DEFAULT_SEPARATOR,\n filter = Boolean,\n }: { separator?: string; filter?: (value: any) => boolean } = {},\n) => text.filter(filter).join(separator);\n\nexport const formatCurrency = (\n amount: string,\n locale = 'de-DE',\n showCurrencySign = false,\n options: Intl.NumberFormatOptions = { currency: 'EUR' },\n): string => {\n const settings = getCurrencySettings(options.currency);\n return new Intl.NumberFormat(locale, {\n minimumFractionDigits: settings.decimalPlaces,\n maximumFractionDigits: settings.decimalPlaces,\n style: 'currency',\n useGrouping: true,\n ...options,\n })\n .formatToParts(Number(amount))\n .map((p) => (showCurrencySign || (p.type != 'literal' && p.type != 'currency') ? p.value : ''))\n .join('');\n};\n"]}
|
package/lib/leasing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leasing.js","sourceRoot":"/","sources":["leasing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAWrC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,GAAW,EAAE,EAAE;IACxD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAC9B,EAAE,KAAK,EAAE,WAAW,EAA0C,EAC9D,UAAoC;IAOpC,MAAM,EAAE,OAAO,EAAE,YAAY,EA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B,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAE5E,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzD,WAAW,GAAG,CAAC,kBAAkB,GAAG,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE/E,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,gBAAgB,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,YAAoB,EAAU,EAAE,CAAC,YAAY,GAAG,EAAE,CAAC;AAG/E,MAAM,0BAA0B,GAAG,CAAC,YAAoB,EAAE,QAAgB,EAAU,EAAE,CACpF,CAAC,QAAQ,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;AAEjC,MAAM,qBAAqB,GAAG,CAAC,eAAuB,EAAE,QAAgB,EAAU,EAAE,CAClF,eAAe,GAAG,QAAQ,CAAC","sourcesContent":["import { Decimal } from 'decimal.js';\n\nexport type WebsiteLeasingConditions = {\n interestRate: number;\n deposit: number;\n residual: number;\n maxDuration: number;\n minDuration: number;\n maxVehicleAgeAtEndOfLease: number;\n};\n\nconst clamp = (min: number, value: number, max: number) => {\n return Math.min(Math.max(value, min), max);\n};\n\nexport function getLeasingAmount(\n { price, vehicleYear }: { price: number; vehicleYear: number },\n conditions: WebsiteLeasingConditions
|
|
1
|
+
{"version":3,"file":"leasing.js","sourceRoot":"/","sources":["leasing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAWrC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,GAAW,EAAE,EAAE;IACxD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAA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AEF,MAAM,eAAe,GAAG,CAAC,EACvB,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,eAAe,GAMhB,EAAU,EAAE;IACX,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IAC5E,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAE5E,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzD,WAAW,GAAG,CAAC,kBAAkB,GAAG,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE/E,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,gBAAgB,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,YAAoB,EAAU,EAAE,CAAC,YAAY,GAAG,EAAE,CAAC;AAG/E,MAAM,0BAA0B,GAAG,CAAC,YAAoB,EAAE,QAAgB,EAAU,EAAE,CACpF,CAAC,QAAQ,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC;AAEjC,MAAM,qBAAqB,GAAG,CAAC,eAAuB,EAAE,QAAgB,EAAU,EAAE,CAClF,eAAe,GAAG,QAAQ,CAAC","sourcesContent":["import { Decimal } from 'decimal.js';\n\nexport type WebsiteLeasingConditions = {\n interestRate: number;\n deposit: number;\n residual: number;\n maxDuration: number;\n minDuration: number;\n maxVehicleAgeAtEndOfLease: number;\n};\n\nconst clamp = (min: number, value: number, max: number) => {\n return Math.min(Math.max(value, min), max);\n};\n\nexport function getLeasingAmount(\n { price, vehicleYear }: { price: number; vehicleYear: number },\n conditions: WebsiteLeasingConditions,\n): {\n installment: number;\n duration: number;\n advance: string;\n residual: string;\n} {\n const { deposit, interestRate } = conditions;\n\n const financingAmount = price * (1 - deposit);\n\n const duration = maxLeasePeriod(vehicleYear, conditions);\n\n const installment = getInstallement({ duration, interestRate, residual: 0, financingAmount });\n\n const advance = new Decimal(price).mul(conditions.deposit).toString();\n const residual = new Decimal(price).mul(conditions.residual).toString();\n\n return { installment, duration, advance, residual };\n}\n\nconst maxLeasePeriod = (vehicleYear: number, conditions: WebsiteLeasingConditions): number => {\n const { maxVehicleAgeAtEndOfLease, minDuration, maxDuration } = conditions;\n\n const currentYear = new Date().getFullYear();\n\n const vehicleAge = currentYear - vehicleYear;\n const leaseLimit = (maxVehicleAgeAtEndOfLease - vehicleAge) * 12;\n\n return clamp(leaseLimit, minDuration, maxDuration);\n};\n\nconst getInstallement = ({\n duration,\n interestRate,\n residual,\n financingAmount,\n}: {\n duration: number;\n interestRate: number;\n residual: number;\n financingAmount: number;\n}): number => {\n const amortizationAmount = getAmortizationAmount(financingAmount, residual);\n const residualInterest = getResidualMonthlyInterest(interestRate, residual);\n\n let installment = 0;\n const interestRateMonth = getMonthlyInterest(interestRate);\n const irmPow = Math.pow(interestRateMonth + 1, duration);\n installment = (amortizationAmount * interestRateMonth * irmPow) / (irmPow - 1);\n\n return Math.round(installment + residualInterest);\n};\n\nconst getMonthlyInterest = (interestRate: number): number => interestRate / 12;\n\n// since the interest rate is per year, no need to consider the duration in this calculation\nconst getResidualMonthlyInterest = (interestRate: number, residual: number): number =>\n (residual * interestRate) / 12;\n\nconst getAmortizationAmount = (financingAmount: number, residual: number): number =>\n financingAmount - residual;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location-utils.js","sourceRoot":"/","sources":["location-utils.ts"],"names":[],"mappings":"AAEA,MAAM,uBAAuB,GAAG;IAC9B,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,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EvD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import { LocationValue } from './types.js';\n\nconst COUNTRY_TO_CUSTOMS_CODE = {\n RS: 'XS', // Serbia\n MC: 'FR', // Monaco\n SM: 'IT', // San Marino\n AD: 'ES', // Andorra\n GL: 'DK', // Greenland\n FO: 'DK', // Faroe Islands\n};\n\nconst getCountryCustomsCode = (country: string): string => {\n return COUNTRY_TO_CUSTOMS_CODE[country.toUpperCase()] ?? country.toUpperCase();\n};\n\nexport const getAddressText = (\n address: LocationValue,\n joinBy: string = '<br>'
|
|
1
|
+
{"version":3,"file":"location-utils.js","sourceRoot":"/","sources":["location-utils.ts"],"names":[],"mappings":"AAEA,MAAM,uBAAuB,GAAG;IAC9B,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACT,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAAU,EAAE;IACxD,OAAO,uBAAuB,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;AACjF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAAsB,EACtB,SAAiB,MAAM,EACH,EAAE;IACtB,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC;SACpE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAClB,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,MAAM,CACpF,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CACX,CAAC;IAEF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,OAAsB,EACtB,SAAiB,MAAM,EACH,EAAE;IACtB,MAAM,cAAc,GAAG;QACrB,GAAG,OAAO;QACV,OAAO,EAAE,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC;KAChD,CAAC;IAEF,OAAO,cAAc,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mCAAmC,GAAG,CACjD,QAAuB,EACH,EAAE;IACtB,MAAM,YAAY,GAAG,IAAI,CAAC;IAC1B,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAEvD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import { LocationValue } from './types.js';\n\nconst COUNTRY_TO_CUSTOMS_CODE = {\n RS: 'XS', // Serbia\n MC: 'FR', // Monaco\n SM: 'IT', // San Marino\n AD: 'ES', // Andorra\n GL: 'DK', // Greenland\n FO: 'DK', // Faroe Islands\n};\n\nconst getCountryCustomsCode = (country: string): string => {\n return COUNTRY_TO_CUSTOMS_CODE[country.toUpperCase()] ?? country.toUpperCase();\n};\n\nexport const getAddressText = (\n address: LocationValue,\n joinBy: string = '<br>',\n): string | undefined => {\n const regionLines = [address.postalCode, address.city, address.country]\n .filter((n) => !!n)\n .join(', ');\n\n const filteredParts = [address.addressLine1, address.addressLine2, regionLines].filter(\n (n) => !!n,\n );\n\n if (filteredParts.length === 0) {\n return undefined;\n }\n return filteredParts.join(joinBy);\n};\n\nexport const getCustomsAdressText = (\n address: LocationValue,\n joinBy: string = '<br>',\n): string | undefined => {\n const customsAddress = {\n ...address,\n country: getCountryCustomsCode(address.country),\n };\n\n return getAddressText(customsAddress, joinBy);\n};\n\nexport const getFormatedAddressFromLocationValue = (\n location: LocationValue,\n): string | undefined => {\n const PARTS_JOINER = ', ';\n const address = getAddressText(location, PARTS_JOINER);\n\n return address;\n};\n"]}
|
package/lib/money.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.js","sourceRoot":"/","sources":["money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,YAAY,GAAG;IACnB,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC,eAAe;IACvC,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC,eAAe;IACvC,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC,eAAe;IACvC,cAAc,EAAE,KAAK;CACtB,CAAC;AASF,MAAM,gBAAgB,GAAqC;IACzD,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,YAAY;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,WAAmB,KAAK,EAAoB,EAAE;IAChF,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAmB,KAAK,EAAE,KAAuB,EAAW,EAAE;IACvF,MAAM,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;AAC7F,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,WAAmB,KAAK,EACxB,OAAyB,EACzB,OAAyB,EACzB,SAAS,GAAG,GAAG,EACN,EAAE,CACX,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC;KAC1B,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,EAAE;KACL,iBAAiB,CAAC,SAAS,CAAC,CAAC","sourcesContent":["import { Decimal } from 'decimal.js';\n\nconst CFA_SETTINGS = {\n decimalPlaces: 0,\n roundingMethod: Decimal.ROUND_HALF_EVEN,\n currencySymbol: 'CFA',\n};\n\nconst EUR_SETTINGS = {\n decimalPlaces: 2,\n roundingMethod: Decimal.ROUND_HALF_EVEN,\n currencySymbol: 'EUR',\n};\n\nconst USD_SETTINGS = {\n decimalPlaces: 2,\n roundingMethod: Decimal.ROUND_HALF_EVEN,\n currencySymbol: 'USD',\n};\n\ntype CurrencySettings = {\n decimalPlaces: number;\n roundingMethod: typeof Decimal.ROUND_HALF_EVEN;\n thousandSeparator?: string;\n currencySymbol?: string;\n};\n\nconst currencySettings: Record<string, CurrencySettings> = {\n XOF: CFA_SETTINGS,\n CFA: CFA_SETTINGS,\n EUR: EUR_SETTINGS,\n USD: USD_SETTINGS,\n};\n\nexport const getCurrencySettings = (currency: string = 'EUR'): CurrencySettings => {\n return currencySettings[currency] || EUR_SETTINGS;\n};\n\nexport const roundMoney = (currency: string = 'EUR', value: Decimal | string): Decimal => {\n const settings = getCurrencySettings(currency);\n return new Decimal(value).toDecimalPlaces(settings.decimalPlaces, settings.roundingMethod);\n};\n\n// We tolerate a 10 cent rounding difference\nexport const isAmountWithinToleranceSame = (\n currency: string = 'EUR',\n amount1: Decimal | string,\n amount2: Decimal | string,\n tolerance = 0.1
|
|
1
|
+
{"version":3,"file":"money.js","sourceRoot":"/","sources":["money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MA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ETTINGS = {\n decimalPlaces: 0,\n roundingMethod: Decimal.ROUND_HALF_EVEN,\n currencySymbol: 'CFA',\n};\n\nconst EUR_SETTINGS = {\n decimalPlaces: 2,\n roundingMethod: Decimal.ROUND_HALF_EVEN,\n currencySymbol: 'EUR',\n};\n\nconst USD_SETTINGS = {\n decimalPlaces: 2,\n roundingMethod: Decimal.ROUND_HALF_EVEN,\n currencySymbol: 'USD',\n};\n\ntype CurrencySettings = {\n decimalPlaces: number;\n roundingMethod: typeof Decimal.ROUND_HALF_EVEN;\n thousandSeparator?: string;\n currencySymbol?: string;\n};\n\nconst currencySettings: Record<string, CurrencySettings> = {\n XOF: CFA_SETTINGS,\n CFA: CFA_SETTINGS,\n EUR: EUR_SETTINGS,\n USD: USD_SETTINGS,\n};\n\nexport const getCurrencySettings = (currency: string = 'EUR'): CurrencySettings => {\n return currencySettings[currency] || EUR_SETTINGS;\n};\n\nexport const roundMoney = (currency: string = 'EUR', value: Decimal | string): Decimal => {\n const settings = getCurrencySettings(currency);\n return new Decimal(value).toDecimalPlaces(settings.decimalPlaces, settings.roundingMethod);\n};\n\n// We tolerate a 10 cent rounding difference\nexport const isAmountWithinToleranceSame = (\n currency: string = 'EUR',\n amount1: Decimal | string,\n amount2: Decimal | string,\n tolerance = 0.1,\n): boolean =>\n roundMoney(currency, amount1)\n .minus(roundMoney(currency, amount2))\n .abs()\n .lessThanOrEqualTo(tolerance);\n"]}
|
package/lib/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"/","sources":["storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,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C,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACrF,aAAa,CACX,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC,GACzC,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;KACrC,GAAG,IAAI,eAAe,GAAG,cAAc;CACzC,CAAC;AAEF,oBAAY,qBAAqB;IAC/B,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC"}
|
package/lib/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"/","sources":["storage.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,4BAAS,CAAA;AACX,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAuCD,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,oCAAW,CAAA;IACX,sCAAa,CAAA;AACf,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC","sourcesContent":["import type Joi from 'joi';\nimport { Requester } from './types.js';\n\nexport type UploadInfo = {\n id: string;\n uploadUrl: string;\n downloadPath: string;\n method: 'POST' | 'PATCH' | 'PUT';\n headers?: {\n [name: string]: string;\n };\n};\n\nexport type VideoDownloadInfo = {\n url: string;\n quality: string;\n size: number;\n};\n\nexport type VideoInfo = {\n status: 'SUCCESS' | 'PROCESSING' | 'ERROR';\n downloads: VideoDownloadInfo[];\n id: string;\n};\n\nexport enum UploadProviders {\n Vimeo = 'vimeo',\n S3 = 's3',\n}\n\ntype BaseUploadUrlRequest = {\n contentType: string;\n};\n\nexport type VimeoUploadRequest = BaseUploadUrlRequest & {\n size: number;\n name: string;\n listed?: boolean; // will the video be listed in our public Vimeo library'\n};\n\nexport type S3UploadRequest = BaseUploadUrlRequest & {\n // is the file supposed to be shared by all tenants that need it, or will each tenant have its copy\n shared: boolean;\n fileName: string;\n businessEntityId: string;\n};\n\nexport type UploadUrlRequest<Provider extends UploadProviders> =\n Provider extends UploadProviders.Vimeo\n ? VimeoUploadRequest\n : Provider extends UploadProviders.S3\n
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"/","sources":["storage.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,4BAAS,CAAA;AACX,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAuCD,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,oCAAW,CAAA;IACX,sCAAa,CAAA;AACf,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC","sourcesContent":["import type Joi from 'joi';\nimport { Requester } from './types.js';\n\nexport type UploadInfo = {\n id: string;\n uploadUrl: string;\n downloadPath: string;\n method: 'POST' | 'PATCH' | 'PUT';\n headers?: {\n [name: string]: string;\n };\n};\n\nexport type VideoDownloadInfo = {\n url: string;\n quality: string;\n size: number;\n};\n\nexport type VideoInfo = {\n status: 'SUCCESS' | 'PROCESSING' | 'ERROR';\n downloads: VideoDownloadInfo[];\n id: string;\n};\n\nexport enum UploadProviders {\n Vimeo = 'vimeo',\n S3 = 's3',\n}\n\ntype BaseUploadUrlRequest = {\n contentType: string;\n};\n\nexport type VimeoUploadRequest = BaseUploadUrlRequest & {\n size: number;\n name: string;\n listed?: boolean; // will the video be listed in our public Vimeo library'\n};\n\nexport type S3UploadRequest = BaseUploadUrlRequest & {\n // is the file supposed to be shared by all tenants that need it, or will each tenant have its copy\n shared: boolean;\n fileName: string;\n businessEntityId: string;\n};\n\nexport type UploadUrlRequest<Provider extends UploadProviders> =\n Provider extends UploadProviders.Vimeo\n ? VimeoUploadRequest\n : Provider extends UploadProviders.S3\n ? S3UploadRequest\n : {};\n\nexport type UploadProvider = {\n validationSchema: Joi.ObjectSchema<any>;\n getVideoListInfo: (requester: Requester, videoIds: string[]) => Promise<VideoInfo[]>;\n getUploadInfo(\n requester: Requester,\n request: UploadUrlRequest<UploadProviders>,\n ): Promise<UploadInfo>;\n};\n\nexport type UploadProvidersDefinition = {\n [key in UploadProviders]: UploadProvider;\n};\n\nexport enum MediaExportResolution {\n Low = 'low',\n High = 'high',\n}\n\nexport type MediaExportRequest = {\n urls: string[];\n resolution?: MediaExportResolution;\n};\n\nexport type MediaExportEvent = {\n s3Keys: string[];\n outputId: string;\n tenantId: string;\n entityId: string;\n resolution: MediaExportResolution;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bisondesk/commons-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.589",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "npx tsc --build tsconfig.json",
|
|
7
|
-
"clean": "rm -rf lib *.tsbuildinfo",
|
|
8
|
-
"unittest": "echo \"No test specified\"",
|
|
9
|
-
"integrationtest": "echo \"No test specified\""
|
|
10
|
-
},
|
|
11
5
|
"dependencies": {
|
|
12
6
|
"@date-fns/utc": "1.1.1",
|
|
13
7
|
"date-fns": "3.2.0",
|
|
8
|
+
"decimal.js": "10.4.3",
|
|
14
9
|
"joi": "17.13.3",
|
|
15
10
|
"nanoid": "5.1.6"
|
|
16
11
|
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"node-fetch": "3.3.2"
|
|
14
|
+
},
|
|
17
15
|
"devDependencies": {
|
|
18
16
|
"@types/date-fns": "2.6.0",
|
|
19
17
|
"typescript": "5.9.3"
|
|
@@ -27,5 +25,11 @@
|
|
|
27
25
|
},
|
|
28
26
|
"exports": {
|
|
29
27
|
"./*": "./lib/*.js"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "npx tsc --build tsconfig.json",
|
|
31
|
+
"clean": "rm -rf lib *.tsbuildinfo",
|
|
32
|
+
"unittest": "echo \"No test specified\"",
|
|
33
|
+
"integrationtest": "echo \"No test specified\""
|
|
30
34
|
}
|
|
31
|
-
}
|
|
35
|
+
}
|
package/src/apis/picklists.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fetch, { Response } from 'node-fetch';
|
|
2
|
+
import { TENANT_ID_ADMIN_HEADER } from '../constants.js';
|
|
2
3
|
import { XError } from '../errors.js';
|
|
3
4
|
import { cleanHeaders, fetchJson, getAdminAuth } from '../fetch.js';
|
|
4
5
|
import {
|
|
@@ -11,31 +12,38 @@ import {
|
|
|
11
12
|
PicklistValueUpdateRequest,
|
|
12
13
|
} from '../picklists.js';
|
|
13
14
|
import { Option } from '../types.js';
|
|
14
|
-
import { TENANT_ID_ADMIN_HEADER } from '../constants.js';
|
|
15
15
|
|
|
16
16
|
export const getMultiplePicklistValues = async (
|
|
17
|
-
request: AdHocPicklistRequest
|
|
17
|
+
request: AdHocPicklistRequest,
|
|
18
18
|
): Promise<AdHocPicklistValueDisplay> => {
|
|
19
19
|
const auth = await getAdminAuth();
|
|
20
20
|
return fetchJson<AdHocPicklistValueDisplay>(
|
|
21
21
|
`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`,
|
|
22
|
-
{
|
|
22
|
+
{
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: { Authorization: auth, 'Content-Type': 'application/json' },
|
|
25
|
+
body: JSON.stringify(request),
|
|
26
|
+
},
|
|
23
27
|
);
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
export const getMultiplePicklistFullValues = async (
|
|
27
|
-
request: AdHocPicklistRequest
|
|
31
|
+
request: AdHocPicklistRequest,
|
|
28
32
|
): Promise<AdHocPicklistValues> => {
|
|
29
33
|
const auth = await getAdminAuth();
|
|
30
34
|
return fetchJson<AdHocPicklistValues>(
|
|
31
35
|
`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read/full`,
|
|
32
|
-
{
|
|
36
|
+
{
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: { Authorization: auth, 'Content-Type': 'application/json' },
|
|
39
|
+
body: JSON.stringify(request),
|
|
40
|
+
},
|
|
33
41
|
);
|
|
34
42
|
};
|
|
35
43
|
|
|
36
44
|
export const getPicklistOptions = async (
|
|
37
45
|
req: PicklistOptionsRequest,
|
|
38
|
-
tenantId?: string
|
|
46
|
+
tenantId?: string,
|
|
39
47
|
): Promise<Option[]> => {
|
|
40
48
|
const auth = await getAdminAuth();
|
|
41
49
|
|
|
@@ -58,7 +66,7 @@ export const getPicklistOptions = async (
|
|
|
58
66
|
};
|
|
59
67
|
|
|
60
68
|
export const upsertPicklistValue = async (
|
|
61
|
-
request: PicklistValueUpdateRequest
|
|
69
|
+
request: PicklistValueUpdateRequest,
|
|
62
70
|
): Promise<PicklistValue> => {
|
|
63
71
|
const auth = await getAdminAuth();
|
|
64
72
|
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/value`, {
|
|
@@ -81,7 +89,7 @@ export const upsertPicklistValue = async (
|
|
|
81
89
|
export const getAdhocPicklistDisplayValue = async (
|
|
82
90
|
requests: PicklistValueRequest[],
|
|
83
91
|
preferredLang: string,
|
|
84
|
-
tenantLang: string
|
|
92
|
+
tenantLang: string,
|
|
85
93
|
): Promise<AdHocPicklistValueDisplay> => {
|
|
86
94
|
const auth = await getAdminAuth();
|
|
87
95
|
|
package/src/date-utils.ts
CHANGED
|
@@ -15,7 +15,7 @@ export const isoString = (value: number | string | Date = new Date()) =>
|
|
|
15
15
|
export const formatInTimeZone = (
|
|
16
16
|
rawDate: number | string | Date,
|
|
17
17
|
timezone: string,
|
|
18
|
-
formatStr: string
|
|
18
|
+
formatStr: string,
|
|
19
19
|
) => {
|
|
20
20
|
const baseDate = new Date(rawDate);
|
|
21
21
|
|
package/src/errors.ts
CHANGED
package/src/fetch.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { HeadersInit, RequestInfo, RequestInit } from 'node-fetch';
|
|
2
1
|
import type { URL } from 'node:url';
|
|
2
|
+
import type { HeadersInit, RequestInfo, RequestInit } from 'node-fetch';
|
|
3
3
|
import { TENANT_ID_ADMIN_HEADER } from './constants.js';
|
|
4
4
|
import { InvalidArgumentsError, XError } from './errors.js';
|
|
5
5
|
|
|
6
6
|
export function fetchJson<T>(
|
|
7
7
|
url: URL | RequestInfo,
|
|
8
8
|
init?: RequestInit,
|
|
9
|
-
opts?: { denyEmptyResponse?: true }
|
|
9
|
+
opts?: { denyEmptyResponse?: true },
|
|
10
10
|
): Promise<T>;
|
|
11
11
|
|
|
12
12
|
export function fetchJson<T>(
|
|
13
13
|
url: URL | RequestInfo,
|
|
14
14
|
init?: RequestInit,
|
|
15
|
-
opts?: { denyEmptyResponse: false }
|
|
15
|
+
opts?: { denyEmptyResponse: false },
|
|
16
16
|
): Promise<T | undefined>;
|
|
17
17
|
|
|
18
18
|
export async function fetchJson<T>(
|
|
19
19
|
url: URL | RequestInfo,
|
|
20
20
|
init?: RequestInit,
|
|
21
|
-
opts?: { denyEmptyResponse?: boolean }
|
|
21
|
+
opts?: { denyEmptyResponse?: boolean },
|
|
22
22
|
): Promise<T | undefined> {
|
|
23
23
|
// sometimes the origin ends with a slash and when we append the path it gets a double slash
|
|
24
24
|
url = url.toString().replace(/([^:]\/)\/+/g, '$1');
|
package/src/formatting.ts
CHANGED
|
@@ -7,14 +7,14 @@ export const joinWithSeparator = (
|
|
|
7
7
|
{
|
|
8
8
|
separator = DEFAULT_SEPARATOR,
|
|
9
9
|
filter = Boolean,
|
|
10
|
-
}: { separator?: string; filter?: (value: any) => boolean } = {}
|
|
10
|
+
}: { separator?: string; filter?: (value: any) => boolean } = {},
|
|
11
11
|
) => text.filter(filter).join(separator);
|
|
12
12
|
|
|
13
13
|
export const formatCurrency = (
|
|
14
14
|
amount: string,
|
|
15
15
|
locale = 'de-DE',
|
|
16
16
|
showCurrencySign = false,
|
|
17
|
-
options: Intl.NumberFormatOptions = { currency: 'EUR' }
|
|
17
|
+
options: Intl.NumberFormatOptions = { currency: 'EUR' },
|
|
18
18
|
): string => {
|
|
19
19
|
const settings = getCurrencySettings(options.currency);
|
|
20
20
|
return new Intl.NumberFormat(locale, {
|
package/src/leasing.ts
CHANGED
|
@@ -15,7 +15,7 @@ const clamp = (min: number, value: number, max: number) => {
|
|
|
15
15
|
|
|
16
16
|
export function getLeasingAmount(
|
|
17
17
|
{ price, vehicleYear }: { price: number; vehicleYear: number },
|
|
18
|
-
conditions: WebsiteLeasingConditions
|
|
18
|
+
conditions: WebsiteLeasingConditions,
|
|
19
19
|
): {
|
|
20
20
|
installment: number;
|
|
21
21
|
duration: number;
|
package/src/location-utils.ts
CHANGED
|
@@ -15,14 +15,14 @@ const getCountryCustomsCode = (country: string): string => {
|
|
|
15
15
|
|
|
16
16
|
export const getAddressText = (
|
|
17
17
|
address: LocationValue,
|
|
18
|
-
joinBy: string = '<br>'
|
|
18
|
+
joinBy: string = '<br>',
|
|
19
19
|
): string | undefined => {
|
|
20
20
|
const regionLines = [address.postalCode, address.city, address.country]
|
|
21
21
|
.filter((n) => !!n)
|
|
22
22
|
.join(', ');
|
|
23
23
|
|
|
24
24
|
const filteredParts = [address.addressLine1, address.addressLine2, regionLines].filter(
|
|
25
|
-
(n) => !!n
|
|
25
|
+
(n) => !!n,
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
if (filteredParts.length === 0) {
|
|
@@ -33,7 +33,7 @@ export const getAddressText = (
|
|
|
33
33
|
|
|
34
34
|
export const getCustomsAdressText = (
|
|
35
35
|
address: LocationValue,
|
|
36
|
-
joinBy: string = '<br>'
|
|
36
|
+
joinBy: string = '<br>',
|
|
37
37
|
): string | undefined => {
|
|
38
38
|
const customsAddress = {
|
|
39
39
|
...address,
|
|
@@ -44,7 +44,7 @@ export const getCustomsAdressText = (
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export const getFormatedAddressFromLocationValue = (
|
|
47
|
-
location: LocationValue
|
|
47
|
+
location: LocationValue,
|
|
48
48
|
): string | undefined => {
|
|
49
49
|
const PARTS_JOINER = ', ';
|
|
50
50
|
const address = getAddressText(location, PARTS_JOINER);
|
package/src/money.ts
CHANGED
|
@@ -46,7 +46,7 @@ export const isAmountWithinToleranceSame = (
|
|
|
46
46
|
currency: string = 'EUR',
|
|
47
47
|
amount1: Decimal | string,
|
|
48
48
|
amount2: Decimal | string,
|
|
49
|
-
tolerance = 0.1
|
|
49
|
+
tolerance = 0.1,
|
|
50
50
|
): boolean =>
|
|
51
51
|
roundMoney(currency, amount1)
|
|
52
52
|
.minus(roundMoney(currency, amount2))
|
package/src/storage.ts
CHANGED
|
@@ -49,15 +49,15 @@ export type UploadUrlRequest<Provider extends UploadProviders> =
|
|
|
49
49
|
Provider extends UploadProviders.Vimeo
|
|
50
50
|
? VimeoUploadRequest
|
|
51
51
|
: Provider extends UploadProviders.S3
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
? S3UploadRequest
|
|
53
|
+
: {};
|
|
54
54
|
|
|
55
55
|
export type UploadProvider = {
|
|
56
56
|
validationSchema: Joi.ObjectSchema<any>;
|
|
57
57
|
getVideoListInfo: (requester: Requester, videoIds: string[]) => Promise<VideoInfo[]>;
|
|
58
58
|
getUploadInfo(
|
|
59
59
|
requester: Requester,
|
|
60
|
-
request: UploadUrlRequest<UploadProviders
|
|
60
|
+
request: UploadUrlRequest<UploadProviders>,
|
|
61
61
|
): Promise<UploadInfo>;
|
|
62
62
|
};
|
|
63
63
|
|