@inploi/plugin-job-search 0.19.1 → 0.19.2

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.
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ const payPeriods = {
3
+ ANNUALLY: "per year",
4
+ DAILY: "per day",
5
+ HOURLY: "per hour",
6
+ MONTHLY: "per month",
7
+ WEEKLY: "per week"
8
+ };
9
+ const getSalaryAsText = (params) => {
10
+ const { salary, config } = params;
11
+ const numberFormatter = new Intl.NumberFormat(config.locales, {
12
+ style: "currency",
13
+ currency: salary.pay_currency,
14
+ // @ts-expect-error - it exists, but TS doesn't know it
15
+ trailingZeroDisplay: "stripIfInteger"
16
+ });
17
+ if (salary.pay_display === false)
18
+ return void 0;
19
+ if (salary.pay_mask)
20
+ return "Competitive";
21
+ if (salary.pay_max && isNaN(+salary.pay_max))
22
+ return "Invalid salary";
23
+ if (salary.pay_min && isNaN(+salary.pay_min))
24
+ return "Invalid salary";
25
+ if (salary.pay && isNaN(+salary.pay))
26
+ return "Invalid salary";
27
+ const period = salary.pay_type && salary.pay_type in payPeriods ? payPeriods[salary.pay_type] : void 0;
28
+ if (salary.pay)
29
+ return [numberFormatter.format(+salary.pay), period].filter(Boolean).join(" ");
30
+ if (salary.pay_max && salary.pay_min)
31
+ return [numberFormatter.formatRange(+salary.pay_min, +salary.pay_max), period].filter(Boolean).join(" ");
32
+ if (salary.pay_max)
33
+ return "Up to " + [numberFormatter.format(+salary.pay_max), period].filter(Boolean).join(" ");
34
+ if (salary.pay_min)
35
+ return "From " + [numberFormatter.format(+salary.pay_min), period].filter(Boolean).join(" ");
36
+ return "Invalid salary";
37
+ };
38
+ const DEFAULT_FORMATTER = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
39
+ const getRelativeTimeDifference = ({ from = /* @__PURE__ */ new Date(), to, formatter = DEFAULT_FORMATTER }) => {
40
+ const then = to instanceof Date ? to : new Date(to);
41
+ const diff = then.getTime() - from.getTime();
42
+ const diffIn = {
43
+ days: Math.round(diff / 1e3 / 60 / 60 / 24),
44
+ months: Math.round(diff / 1e3 / 60 / 60 / 24 / 30)
45
+ };
46
+ if (diffIn.days === 0)
47
+ return "today";
48
+ if (Math.abs(diffIn.days) < 30)
49
+ return formatter.format(diffIn.days, "days");
50
+ if (Math.abs(diffIn.days) < 3)
51
+ return formatter.format(diffIn.months, "months");
52
+ return diffIn.months < 0 ? "over 30 days ago" : "in over 30 days";
53
+ };
54
+ exports.getRelativeTimeDifference = getRelativeTimeDifference;
55
+ exports.getSalaryAsText = getSalaryAsText;
@@ -0,0 +1,56 @@
1
+ const payPeriods = {
2
+ ANNUALLY: "per year",
3
+ DAILY: "per day",
4
+ HOURLY: "per hour",
5
+ MONTHLY: "per month",
6
+ WEEKLY: "per week"
7
+ };
8
+ const getSalaryAsText = (params) => {
9
+ const { salary, config } = params;
10
+ const numberFormatter = new Intl.NumberFormat(config.locales, {
11
+ style: "currency",
12
+ currency: salary.pay_currency,
13
+ // @ts-expect-error - it exists, but TS doesn't know it
14
+ trailingZeroDisplay: "stripIfInteger"
15
+ });
16
+ if (salary.pay_display === false)
17
+ return void 0;
18
+ if (salary.pay_mask)
19
+ return "Competitive";
20
+ if (salary.pay_max && isNaN(+salary.pay_max))
21
+ return "Invalid salary";
22
+ if (salary.pay_min && isNaN(+salary.pay_min))
23
+ return "Invalid salary";
24
+ if (salary.pay && isNaN(+salary.pay))
25
+ return "Invalid salary";
26
+ const period = salary.pay_type && salary.pay_type in payPeriods ? payPeriods[salary.pay_type] : void 0;
27
+ if (salary.pay)
28
+ return [numberFormatter.format(+salary.pay), period].filter(Boolean).join(" ");
29
+ if (salary.pay_max && salary.pay_min)
30
+ return [numberFormatter.formatRange(+salary.pay_min, +salary.pay_max), period].filter(Boolean).join(" ");
31
+ if (salary.pay_max)
32
+ return "Up to " + [numberFormatter.format(+salary.pay_max), period].filter(Boolean).join(" ");
33
+ if (salary.pay_min)
34
+ return "From " + [numberFormatter.format(+salary.pay_min), period].filter(Boolean).join(" ");
35
+ return "Invalid salary";
36
+ };
37
+ const DEFAULT_FORMATTER = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
38
+ const getRelativeTimeDifference = ({ from = /* @__PURE__ */ new Date(), to, formatter = DEFAULT_FORMATTER }) => {
39
+ const then = to instanceof Date ? to : new Date(to);
40
+ const diff = then.getTime() - from.getTime();
41
+ const diffIn = {
42
+ days: Math.round(diff / 1e3 / 60 / 60 / 24),
43
+ months: Math.round(diff / 1e3 / 60 / 60 / 24 / 30)
44
+ };
45
+ if (diffIn.days === 0)
46
+ return "today";
47
+ if (Math.abs(diffIn.days) < 30)
48
+ return formatter.format(diffIn.days, "days");
49
+ if (Math.abs(diffIn.days) < 3)
50
+ return formatter.format(diffIn.months, "months");
51
+ return diffIn.months < 0 ? "over 30 days ago" : "in over 30 days";
52
+ };
53
+ export {
54
+ getRelativeTimeDifference as a,
55
+ getSalaryAsText as g
56
+ };
package/dist/index.cjs CHANGED
@@ -7,6 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  };
8
8
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  const sdk = require("@inploi/sdk");
10
+ const datetime = require("./datetime-5adbbd63.cjs");
10
11
  var exhaustive = (value) => {
11
12
  throw new Error(`Unhandled discriminated union member: ${JSON.stringify(value)}`);
12
13
  };
@@ -1478,58 +1479,6 @@ function url(message = "Invalid URL") {
1478
1479
  const JOB_SEARCH_ELEMENT_ID = "inploi-job-search";
1479
1480
  const JOB_SEARCH_SCOPE_ELEMENT_ID = "ijs";
1480
1481
  const PAGE_SIZE = 10;
1481
- const payPeriods = {
1482
- ANNUALLY: "per year",
1483
- DAILY: "per day",
1484
- HOURLY: "per hour",
1485
- MONTHLY: "per month",
1486
- WEEKLY: "per week"
1487
- };
1488
- const getSalaryAsText = (params) => {
1489
- const { salary, config } = params;
1490
- const numberFormatter = new Intl.NumberFormat(config.locales, {
1491
- style: "currency",
1492
- currency: salary.pay_currency,
1493
- // @ts-expect-error - it exists, but TS doesn't know it
1494
- trailingZeroDisplay: "stripIfInteger"
1495
- });
1496
- if (salary.pay_display === false)
1497
- return void 0;
1498
- if (salary.pay_mask)
1499
- return "Competitive";
1500
- if (salary.pay_max && isNaN(+salary.pay_max))
1501
- return "Invalid salary";
1502
- if (salary.pay_min && isNaN(+salary.pay_min))
1503
- return "Invalid salary";
1504
- if (salary.pay && isNaN(+salary.pay))
1505
- return "Invalid salary";
1506
- const period = salary.pay_type && salary.pay_type in payPeriods ? payPeriods[salary.pay_type] : void 0;
1507
- if (salary.pay)
1508
- return [numberFormatter.format(+salary.pay), period].filter(Boolean).join(" ");
1509
- if (salary.pay_max && salary.pay_min)
1510
- return [numberFormatter.formatRange(+salary.pay_min, +salary.pay_max), period].filter(Boolean).join(" ");
1511
- if (salary.pay_max)
1512
- return "Up to " + [numberFormatter.format(+salary.pay_max), period].filter(Boolean).join(" ");
1513
- if (salary.pay_min)
1514
- return "From " + [numberFormatter.format(+salary.pay_min), period].filter(Boolean).join(" ");
1515
- return "Invalid salary";
1516
- };
1517
- const DEFAULT_FORMATTER = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
1518
- const getRelativeTimeDifference = ({ from = /* @__PURE__ */ new Date(), to, formatter = DEFAULT_FORMATTER }) => {
1519
- const then = to instanceof Date ? to : new Date(to);
1520
- const diff = then.getTime() - from.getTime();
1521
- const diffIn = {
1522
- days: Math.round(diff / 1e3 / 60 / 60 / 24),
1523
- months: Math.round(diff / 1e3 / 60 / 60 / 24 / 30)
1524
- };
1525
- if (diffIn.days === 0)
1526
- return "today";
1527
- if (Math.abs(diffIn.days) < 30)
1528
- return formatter.format(diffIn.days, "days");
1529
- if (Math.abs(diffIn.days) < 3)
1530
- return formatter.format(diffIn.months, "months");
1531
- return diffIn.months < 0 ? "over 30 days ago" : "in over 30 days";
1532
- };
1533
1482
  const AvailablePropertiesSchema = record(
1534
1483
  array(object({ label: coerce(string(), String), value: coerce(string(), String), jobs: number() }))
1535
1484
  );
@@ -1586,12 +1535,12 @@ const JobSchema = transform(JobPayloadSchema, (schema) => {
1586
1535
  },
1587
1536
  employmentType: schema.employment_type,
1588
1537
  locationType: schema.location_type,
1589
- pay: getSalaryAsText({ salary: schema, config: { locales: void 0 } }),
1538
+ pay: datetime.getSalaryAsText({ salary: schema, config: { locales: void 0 } }),
1590
1539
  description: schema.description,
1591
1540
  title: schema.title,
1592
1541
  contractType: schema.contract_type,
1593
1542
  href: schema.href,
1594
- relativePostedDate: schema.created_at ? getRelativeTimeDifference({ to: new Date(schema.created_at) }) : "INVALID DATE",
1543
+ relativePostedDate: schema.created_at ? datetime.getRelativeTimeDifference({ to: new Date(schema.created_at) }) : "INVALID DATE",
1595
1544
  customData: schema.custom_data
1596
1545
  };
1597
1546
  });
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { createPlugin } from "@inploi/sdk";
8
+ import { g as getSalaryAsText, a as getRelativeTimeDifference } from "./datetime-ef341067.js";
8
9
  var exhaustive = (value) => {
9
10
  throw new Error(`Unhandled discriminated union member: ${JSON.stringify(value)}`);
10
11
  };
@@ -1476,58 +1477,6 @@ function url(message = "Invalid URL") {
1476
1477
  const JOB_SEARCH_ELEMENT_ID = "inploi-job-search";
1477
1478
  const JOB_SEARCH_SCOPE_ELEMENT_ID = "ijs";
1478
1479
  const PAGE_SIZE = 10;
1479
- const payPeriods = {
1480
- ANNUALLY: "per year",
1481
- DAILY: "per day",
1482
- HOURLY: "per hour",
1483
- MONTHLY: "per month",
1484
- WEEKLY: "per week"
1485
- };
1486
- const getSalaryAsText = (params) => {
1487
- const { salary, config } = params;
1488
- const numberFormatter = new Intl.NumberFormat(config.locales, {
1489
- style: "currency",
1490
- currency: salary.pay_currency,
1491
- // @ts-expect-error - it exists, but TS doesn't know it
1492
- trailingZeroDisplay: "stripIfInteger"
1493
- });
1494
- if (salary.pay_display === false)
1495
- return void 0;
1496
- if (salary.pay_mask)
1497
- return "Competitive";
1498
- if (salary.pay_max && isNaN(+salary.pay_max))
1499
- return "Invalid salary";
1500
- if (salary.pay_min && isNaN(+salary.pay_min))
1501
- return "Invalid salary";
1502
- if (salary.pay && isNaN(+salary.pay))
1503
- return "Invalid salary";
1504
- const period = salary.pay_type && salary.pay_type in payPeriods ? payPeriods[salary.pay_type] : void 0;
1505
- if (salary.pay)
1506
- return [numberFormatter.format(+salary.pay), period].filter(Boolean).join(" ");
1507
- if (salary.pay_max && salary.pay_min)
1508
- return [numberFormatter.formatRange(+salary.pay_min, +salary.pay_max), period].filter(Boolean).join(" ");
1509
- if (salary.pay_max)
1510
- return "Up to " + [numberFormatter.format(+salary.pay_max), period].filter(Boolean).join(" ");
1511
- if (salary.pay_min)
1512
- return "From " + [numberFormatter.format(+salary.pay_min), period].filter(Boolean).join(" ");
1513
- return "Invalid salary";
1514
- };
1515
- const DEFAULT_FORMATTER = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
1516
- const getRelativeTimeDifference = ({ from = /* @__PURE__ */ new Date(), to, formatter = DEFAULT_FORMATTER }) => {
1517
- const then = to instanceof Date ? to : new Date(to);
1518
- const diff = then.getTime() - from.getTime();
1519
- const diffIn = {
1520
- days: Math.round(diff / 1e3 / 60 / 60 / 24),
1521
- months: Math.round(diff / 1e3 / 60 / 60 / 24 / 30)
1522
- };
1523
- if (diffIn.days === 0)
1524
- return "today";
1525
- if (Math.abs(diffIn.days) < 30)
1526
- return formatter.format(diffIn.days, "days");
1527
- if (Math.abs(diffIn.days) < 3)
1528
- return formatter.format(diffIn.months, "months");
1529
- return diffIn.months < 0 ? "over 30 days ago" : "in over 30 days";
1530
- };
1531
1480
  const AvailablePropertiesSchema = record(
1532
1481
  array(object({ label: coerce(string(), String), value: coerce(string(), String), jobs: number() }))
1533
1482
  );
package/dist/utils.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const datetime = require("./datetime-5adbbd63.cjs");
3
4
  const getStatefulPropertiesFromSearchParams = (properties, searchParams) => {
4
5
  const newProperties = structuredClone(properties);
5
6
  newProperties.forEach((property) => {
@@ -12,4 +13,6 @@ const getStatefulPropertiesFromSearchParams = (properties, searchParams) => {
12
13
  });
13
14
  return newProperties;
14
15
  };
16
+ exports.getRelativeTimeDifference = datetime.getRelativeTimeDifference;
17
+ exports.getSalaryAsText = datetime.getSalaryAsText;
15
18
  exports.getStatefulPropertiesFromSearchParams = getStatefulPropertiesFromSearchParams;
package/dist/utils.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export { getStatefulPropertiesFromSearchParams } from './lib/utils';
2
+ export { getSalaryAsText } from './lib/currency';
3
+ export { getRelativeTimeDifference } from './lib/datetime';
package/dist/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { a, g } from "./datetime-ef341067.js";
1
2
  const getStatefulPropertiesFromSearchParams = (properties, searchParams) => {
2
3
  const newProperties = structuredClone(properties);
3
4
  newProperties.forEach((property) => {
@@ -11,5 +12,7 @@ const getStatefulPropertiesFromSearchParams = (properties, searchParams) => {
11
12
  return newProperties;
12
13
  };
13
14
  export {
15
+ a as getRelativeTimeDifference,
16
+ g as getSalaryAsText,
14
17
  getStatefulPropertiesFromSearchParams
15
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-job-search",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-job-search.js",
6
6
  "types": "dist/index.d.ts",