@8ms/helpers 2.0.23 → 2.0.25

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.
Binary file
package/README.md CHANGED
@@ -8,3 +8,7 @@ Luxon used for Date Time managing.
8
8
  Always using UTC, this means no day light savings to worry about.
9
9
  As Luxon DateTime instance can't be passed between server and client side, this needs to be reinitialized on client/server side.
10
10
 
11
+ # Queries
12
+
13
+ Query builder use:
14
+ https://github.com/kysely-org/kysely
@@ -25,7 +25,7 @@ export declare class ApiResponseClass<T = any, E = any> {
25
25
  isSuccess: () => boolean;
26
26
  setToIdle: () => this;
27
27
  setToPending: () => this;
28
- setToError: (body: any, error: any) => this;
28
+ setToError: (error: any, body: any) => this;
29
29
  setToSuccess: (body: any) => this;
30
30
  setBody: (body: any) => this;
31
31
  setError: (error: any) => this;
@@ -56,7 +56,7 @@ class ApiResponseClass {
56
56
  this.state = _1.ApiState.PENDING;
57
57
  return this;
58
58
  };
59
- this.setToError = (body, error) => {
59
+ this.setToError = (error, body) => {
60
60
  this.body = body || null;
61
61
  this.error = error;
62
62
  this.state = _1.ApiState.ERROR;
@@ -39,7 +39,7 @@ export declare const getDatesBetween: (start: InputDate, end: InputDate) => Date
39
39
  /**
40
40
  * Get an array of DateTime objects representing the 1st of each month between start and end dates.
41
41
  */
42
- export declare const getMonthlyDatesArray: (start: InputDate, end: InputDate) => DateTime<boolean>[];
42
+ export declare const getMonthsBetween: (start: InputDate, end: InputDate) => DateTime<boolean>[];
43
43
  /**
44
44
  * If a given date is beyond the maximum, return the maximum.
45
45
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLastWeek = exports.isThisWeek = exports.getYesterday = exports.getWeeksAgo = exports.getToday = exports.getTwoWeeksAgo = exports.getThisWeek = exports.getLastWeek = exports.getSunday = exports.getMonday = exports.getMin = exports.getMax = exports.getMonthlyDatesArray = exports.getDatesBetween = exports.differenceInBusinessDays = exports.differenceInMinutes = exports.isWeekend = exports.isSunday = exports.isSaturday = exports.isFriday = exports.isThursday = exports.isWednesday = exports.isTuesday = exports.isMonday = exports.getDate = exports.getUnix = void 0;
3
+ exports.isLastWeek = exports.isThisWeek = exports.getYesterday = exports.getWeeksAgo = exports.getToday = exports.getTwoWeeksAgo = exports.getThisWeek = exports.getLastWeek = exports.getSunday = exports.getMonday = exports.getMin = exports.getMax = exports.getMonthsBetween = exports.getDatesBetween = exports.differenceInBusinessDays = exports.differenceInMinutes = exports.isWeekend = exports.isSunday = exports.isSaturday = exports.isFriday = exports.isThursday = exports.isWednesday = exports.isTuesday = exports.isMonday = exports.getDate = exports.getUnix = void 0;
4
4
  const luxon_1 = require("luxon");
5
5
  const getUnix = (input) => {
6
6
  return (0, exports.getDate)(input)
@@ -133,7 +133,7 @@ exports.getDatesBetween = getDatesBetween;
133
133
  /**
134
134
  * Get an array of DateTime objects representing the 1st of each month between start and end dates.
135
135
  */
136
- const getMonthlyDatesArray = (start, end) => {
136
+ const getMonthsBetween = (start, end) => {
137
137
  const months = [];
138
138
  const endDate = (0, exports.getDate)(end)
139
139
  .startOf("month");
@@ -146,7 +146,7 @@ const getMonthlyDatesArray = (start, end) => {
146
146
  }
147
147
  return months;
148
148
  };
149
- exports.getMonthlyDatesArray = getMonthlyDatesArray;
149
+ exports.getMonthsBetween = getMonthsBetween;
150
150
  /**
151
151
  * If a given date is beyond the maximum, return the maximum.
152
152
  */
package/date/index.d.ts CHANGED
@@ -13,6 +13,9 @@ export type Timeframe = {
13
13
  end: DateTime;
14
14
  start: DateTime;
15
15
  };
16
+ export declare const defaultDate: "1901-01-01";
17
+ export declare const defaultDateNumber: 19010101;
18
+ export declare const defaultDateTime: "1901-01-01 00:00:00";
16
19
  /**
17
20
  * Used by Google Ads API.
18
21
  */
package/date/index.js CHANGED
@@ -14,7 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Month = void 0;
17
+ exports.Month = exports.defaultDateTime = exports.defaultDateNumber = exports.defaultDate = void 0;
18
+ exports.defaultDate = "1901-01-01";
19
+ exports.defaultDateNumber = 19010101;
20
+ exports.defaultDateTime = "1901-01-01 00:00:00";
18
21
  /**
19
22
  * Used by Google Ads API.
20
23
  */
@@ -0,0 +1,8 @@
1
+ import { type IntersectionOptions } from "react-intersection-observer";
2
+ import type { ReactNode } from "react";
3
+ import React from "react";
4
+ type LazyLoadProps = IntersectionOptions & {
5
+ children: ReactNode;
6
+ };
7
+ export declare const LazyLoad: (props: LazyLoadProps) => React.JSX.Element;
8
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LazyLoad = void 0;
7
+ const react_intersection_observer_1 = require("react-intersection-observer");
8
+ const react_1 = __importDefault(require("react"));
9
+ const LazyLoad = (props) => {
10
+ const { children, ...propsRest } = props;
11
+ const { ref, inView } = (0, react_intersection_observer_1.useInView)(propsRest);
12
+ return (react_1.default.createElement("div", { ref: ref }, inView && children));
13
+ };
14
+ exports.LazyLoad = LazyLoad;
@@ -0,0 +1 @@
1
+ export { LazyLoad } from "./client/LazyLoad";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LazyLoad = void 0;
4
+ var LazyLoad_1 = require("./client/LazyLoad");
5
+ Object.defineProperty(exports, "LazyLoad", { enumerable: true, get: function () { return LazyLoad_1.LazyLoad; } });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.0.23",
4
+ "version": "2.0.25",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -19,7 +19,7 @@
19
19
  "axios": "^1.9.0",
20
20
  "lodash": "^4.17.21",
21
21
  "luxon": "^3.6.1",
22
- "zod": "^3.25.63"
22
+ "zod": "^4.0.5"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@1password/sdk": "<1.0.0",
@@ -35,7 +35,7 @@
35
35
  "@aws-sdk/s3-request-presigner": "^3.0.0",
36
36
  "@google-cloud/bigquery": "^8.0.0",
37
37
  "@google-cloud/storage": "^7.0.0",
38
- "@googleapis/sheets": "^10.0.0",
38
+ "@googleapis/sheets": "^11.0.0",
39
39
  "@planetscale/database": "^1.0.0",
40
40
  "@prisma/adapter-planetscale": "^6.0.0",
41
41
  "@prisma/client": "^6.0.0",
@@ -44,7 +44,9 @@
44
44
  "crypto-js": "^4.0.0",
45
45
  "fs-extra": "^11.0.0",
46
46
  "google-ads-api": "^20.0.0",
47
+ "next": "^15.0.0",
47
48
  "react": "^19.0.0",
49
+ "react-intersection-observer": "^9.0.0",
48
50
  "stream-chain": "^3.0.0",
49
51
  "stream-json": "^1.0.0",
50
52
  "swr": "^2.0.0"
@@ -116,6 +118,9 @@
116
118
  "google-ads-api": {
117
119
  "optional": true
118
120
  },
121
+ "next": {
122
+ "optional": true
123
+ },
119
124
  "react": {
120
125
  "optional": true
121
126
  },
@@ -127,9 +132,6 @@
127
132
  },
128
133
  "swr": {
129
134
  "optional": true
130
- },
131
- "zod": {
132
- "optional": true
133
135
  }
134
136
  },
135
137
  "devDependencies": {
@@ -150,28 +152,30 @@
150
152
  "@babel/preset-typescript": "7.27.1",
151
153
  "@google-cloud/bigquery": "^8.0.0",
152
154
  "@google-cloud/storage": "^7.0.0",
153
- "@googleapis/sheets": "^10.0.0",
155
+ "@googleapis/sheets": "^11.0.0",
154
156
  "@planetscale/database": "^1.0.0",
155
157
  "@prisma/adapter-planetscale": "^6.0.0",
156
158
  "@prisma/client": "^6.0.0",
157
159
  "@types/babel__core": "7",
158
160
  "@types/crypto-js": "^4.0.0",
159
161
  "@types/fs-extra": "11.0.4",
160
- "@types/jest": "29.5.14",
161
- "@types/lodash": "4.17.17",
162
+ "@types/jest": "30.0.0",
163
+ "@types/lodash": "4.17.20",
162
164
  "@types/luxon": "3.6.2",
163
- "@types/node": "22.15.32",
165
+ "@types/node": "22.16.3",
164
166
  "@types/react": "19",
165
167
  "athena-express": "^7.0.0",
166
168
  "aws-sdk": "^2.0.0",
167
169
  "babel-jest": "30.0.0",
168
170
  "crypto-js": "^4.0.0",
169
- "dotenv": "^16.0.0",
171
+ "dotenv": "^17.0.0",
170
172
  "fs-extra": "11.3.0",
171
173
  "google-ads-api": "^20.0.0",
172
- "jest": "30.0.0",
174
+ "jest": "30.0.4",
175
+ "next": "^15.0.0",
173
176
  "node-fetch": "3.3.2",
174
177
  "react": "^19.0.0",
178
+ "react-intersection-observer": "^9.0.0",
175
179
  "stream-chain": "^3.0.0",
176
180
  "stream-json": "^1.9.0",
177
181
  "swr": "^2.0.0",