@8ms/helpers 2.2.9 → 2.2.12
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/.github/workflows/deploy_npmjs.yml +3 -0
- package/_class/BaseClass.js +43 -52
- package/_class/BaseNamespace.js +17 -20
- package/_class/index.js +2 -7
- package/adverity/getJobs.js +7 -11
- package/adverity/index.js +51 -54
- package/adverity/server.js +1 -5
- package/api/ApiResponseClass.js +84 -88
- package/api/functions.js +13 -22
- package/api/index.js +3 -19
- package/api/types.js +5 -9
- package/array/index.js +3 -11
- package/atInternet/index.js +10 -13
- package/aws/ec2/AwsEc2Namespace.js +34 -74
- package/aws/ec2/server.js +5 -9
- package/aws/ecs/AwsEcsNamespace.js +110 -150
- package/aws/ecs/server.js +5 -9
- package/aws/glue/AwsGlueNamespace.js +26 -66
- package/aws/glue/server.js +5 -9
- package/aws/isResponse200.js +3 -7
- package/aws/lambda/AwsLambdaNamespace.js +62 -102
- package/aws/lambda/server.js +6 -11
- package/aws/s3/AwsS3Namespace.js +347 -390
- package/aws/s3/payload.js +29 -32
- package/aws/s3/server.js +9 -14
- package/aws/server.js +5 -10
- package/aws/ses/AwsSesNamespace.js +36 -76
- package/aws/ses/SimpleEmail.js +267 -304
- package/aws/ses/server.js +6 -11
- package/aws/sqs/AwsSqsNamespace.js +49 -89
- package/aws/sqs/server.js +5 -9
- package/aws/ssm/AwsSsmNamespace.js +43 -79
- package/aws/ssm/server.js +5 -9
- package/axios/deleteRequest.js +8 -15
- package/axios/get.js +8 -15
- package/axios/index.js +3 -9
- package/axios/post.js +8 -15
- package/boolean/index.js +3 -10
- package/brightData/serpApi/buildGoogleSerpUrl.js +1 -5
- package/brightData/serpApi/buildGoogleTrendsUrl.js +1 -5
- package/brightData/serpApi/getAsyncRequestId.js +8 -12
- package/brightData/serpApi/getAsyncResults.js +8 -12
- package/brightData/serpApi/getRealtime.js +3 -7
- package/brightData/serpApi/server.js +6 -14
- package/brightData/server.js +2 -7
- package/brightData/webScraperIde/getBatch.js +3 -7
- package/brightData/webScraperIde/getRealtime.js +11 -15
- package/brightData/webScraperIde/server.js +2 -7
- package/cache/server.js +2 -7
- package/cache/test/cache.test.js +4 -6
- package/crud/index.js +1 -4
- package/crypto/getDecrypt.js +2 -39
- package/crypto/getEncrypt.js +2 -39
- package/crypto/getRandom.js +1 -5
- package/crypto/getSha256.js +4 -41
- package/crypto/index.js +4 -11
- package/date/calculation.js +70 -99
- package/date/financialYear.js +16 -23
- package/date/format.js +40 -61
- package/date/index.js +4 -20
- package/date/type.js +4 -7
- package/environment/index.js +15 -25
- package/eskimi/getAgeGroup.js +3 -7
- package/eskimi/getData.js +3 -7
- package/eskimi/getDevice.js +3 -7
- package/eskimi/getGender.js +3 -7
- package/eskimi/server.js +23 -26
- package/file/index.js +8 -46
- package/geo/countries.js +1 -4
- package/geo/index.js +2 -7
- package/geo/languages.js +1 -4
- package/google/bigQuery/GoogleBigQueryNamespace.js +108 -148
- package/google/bigQuery/loadData.js +1 -5
- package/google/bigQuery/server.js +8 -14
- package/google/server.js +1 -5
- package/google/sheets/GoogleSheetsNamespace.js +34 -74
- package/google/sheets/getAssociatedData.js +1 -5
- package/google/sheets/server.js +8 -14
- package/google/storage/GoogleCloudStorageNamespace.js +62 -102
- package/google/storage/server.js +6 -10
- package/googleAds/GoogleAdsNamespace.js +28 -68
- package/googleAds/keywordPlanner/server.js +32 -35
- package/googleAds/server.js +6 -10
- package/googlePageSpeed/GooglePageSpeedNamespace.js +21 -28
- package/googlePageSpeed/server.js +8 -12
- package/googleSearchIncidents/server.js +28 -32
- package/greenDomain/server.js +17 -21
- package/inngest/server.js +1 -4
- package/json/getJsonNewline.js +3 -7
- package/json/index.js +2 -7
- package/json/isJson.js +1 -5
- package/littleWarden/LittleWardenNamespace.js +24 -31
- package/littleWarden/getUrlStatus.js +3 -7
- package/littleWarden/server.js +14 -22
- package/lumar/api/buildRequest.js +14 -18
- package/lumar/api/getData.js +3 -7
- package/lumar/api/initClient.js +3 -7
- package/lumar/api/server.js +6 -12
- package/lumar/graphql/columns.js +1 -4
- package/lumar/graphql/getData.js +3 -7
- package/lumar/graphql/initClient.js +3 -7
- package/lumar/graphql/queries/crawl.js +1 -2
- package/lumar/graphql/queries/getCrawls.js +1 -3
- package/lumar/graphql/queries/getReportDifferences.js +3 -5
- package/lumar/graphql/queries/getRows.js +1 -3
- package/lumar/graphql/queries/getTotals.js +1 -3
- package/lumar/graphql/queries/row.js +1 -2
- package/lumar/graphql/reportTemplates.js +1 -4
- package/lumar/graphql/server.js +7 -15
- package/myTarget/server.js +3 -7
- package/nextAuth/index.js +2 -6
- package/nextAuth/isSessionReady.js +1 -5
- package/nextJs/client/LazyLoad.js +5 -12
- package/nextJs/client.js +1 -5
- package/nextJs/index.js +2 -7
- package/number/format.js +3 -7
- package/number/formatCurrency.js +1 -5
- package/number/getDecimal.js +3 -7
- package/number/getNumber.js +3 -7
- package/number/getPercentIncrease.js +4 -8
- package/number/getSafeDivide.js +6 -10
- package/number/index.js +6 -15
- package/object/index.js +1 -5
- package/object/replaceKeys.js +3 -7
- package/onePassword/OnePasswordNamespace.js +36 -76
- package/onePassword/server.js +3 -7
- package/openAi/OpenAiNamespace.js +32 -39
- package/openAi/server.js +6 -10
- package/package.json +224 -122
- package/prisma/PrismaNamespace.js +53 -93
- package/prisma/getDecimal.js +5 -12
- package/prisma/server.js +4 -9
- package/scripts/generate-exports.js +50 -0
- package/snapchat/SnapchatNamespace.js +20 -27
- package/snapchat/server.js +6 -10
- package/sorting/byNumberAscending.js +1 -5
- package/sorting/byNumberDescending.js +1 -5
- package/sorting/byStringAscending.js +1 -5
- package/sorting/byStringDescending.js +1 -5
- package/sorting/index.js +4 -11
- package/stream/server.js +1 -5
- package/stream/sort.js +1 -5
- package/string/getCapitalised.js +3 -7
- package/string/getClean.js +17 -21
- package/string/getFolder.js +3 -10
- package/string/getProperCase.js +4 -8
- package/string/getString.js +8 -15
- package/string/getStringFromStream.js +1 -5
- package/string/getUnescaped.js +3 -10
- package/string/getWithoutAccents.js +1 -5
- package/string/getWithoutHtmlTags.js +1 -5
- package/string/getWithoutPunctuation.js +1 -5
- package/string/getWithoutUnderscores.js +1 -5
- package/string/getWithoutWhitespaces.js +1 -5
- package/string/index.js +12 -27
- package/string/reservedWords.js +5 -9
- package/swr/index.js +9 -18
- package/upTimeRobot/UpTimeRobotNamespace.js +32 -42
- package/upTimeRobot/server.js +11 -15
- package/url/index.js +12 -23
- package/url/server.js +1 -5
- package/url/writeUrlContents.js +6 -46
- package/util/defaultTo.js +5 -12
- package/util/getBrotliCompressed.js +3 -10
- package/util/getBrotliDecompressed.js +3 -10
- package/util/getClean.js +5 -9
- package/util/getError.js +1 -5
- package/util/getGzipCompressed.js +3 -10
- package/util/getGzipDecompressed.js +3 -10
- package/util/getWithoutHash.js +1 -5
- package/util/getWithoutParameter.js +1 -5
- package/util/index.js +7 -17
- package/util/isUndefined.js +3 -7
- package/util/promiseChunks.js +6 -10
- package/util/server.js +4 -11
- package/util/sleep.js +1 -5
- package/webWorker/index.js +1 -4
- package/xml/getXml.js +3 -7
package/_class/BaseClass.js
CHANGED
|
@@ -1,53 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Shortcut to get a value, but default if the fields don't exist.
|
|
47
|
-
*/
|
|
48
|
-
this._get = (fields, defaultValue = null) => {
|
|
49
|
-
return (0, util_1.defaultTo)(this, fields, defaultValue);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
1
|
+
import isArray from "lodash/isArray";
|
|
2
|
+
import set from "lodash/set";
|
|
3
|
+
import { defaultTo } from "../util";
|
|
4
|
+
export class BaseClass {
|
|
5
|
+
/**
|
|
6
|
+
* Shortcut to set a value to an array and return the instance.
|
|
7
|
+
*/
|
|
8
|
+
_setArray = (fields, input) => {
|
|
9
|
+
if (isArray(input)) {
|
|
10
|
+
set(this, fields, input);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
set(this, fields, [input]);
|
|
14
|
+
}
|
|
15
|
+
return this;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Shortcut to set a value and return the instance.
|
|
19
|
+
*/
|
|
20
|
+
_setValue = (fields, input) => {
|
|
21
|
+
set(this, fields, input);
|
|
22
|
+
return this;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Shortcut to add a value to an existing array.
|
|
26
|
+
*/
|
|
27
|
+
_push = (fields, input) => {
|
|
28
|
+
let temp = this._get(fields, []);
|
|
29
|
+
if (isArray(input)) {
|
|
30
|
+
temp = temp.concat(input);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
temp = temp.push(input);
|
|
34
|
+
}
|
|
35
|
+
set(this, fields, temp);
|
|
36
|
+
return this;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Shortcut to get a value, but default if the fields don't exist.
|
|
40
|
+
*/
|
|
41
|
+
_get = (fields, defaultValue = null) => {
|
|
42
|
+
return defaultTo(this, fields, defaultValue);
|
|
43
|
+
};
|
|
52
44
|
}
|
|
53
|
-
exports.BaseClass = BaseClass;
|
package/_class/BaseNamespace.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { isServer } from "../environment";
|
|
2
|
+
export class BaseNamespace {
|
|
3
|
+
client = null;
|
|
4
|
+
key;
|
|
5
|
+
config = null;
|
|
6
6
|
constructor(key, config) {
|
|
7
|
-
|
|
8
|
-
this.config = null;
|
|
9
|
-
// To be superseded by child
|
|
10
|
-
this.ensureInit = async () => {
|
|
11
|
-
};
|
|
12
|
-
// Reset the client
|
|
13
|
-
this.reset = () => {
|
|
14
|
-
this.client = null;
|
|
15
|
-
};
|
|
16
|
-
// Return the raw client if needed
|
|
17
|
-
this.getClient = async () => {
|
|
18
|
-
return this.client();
|
|
19
|
-
};
|
|
20
|
-
if (!environment_1.isServer) {
|
|
7
|
+
if (!isServer) {
|
|
21
8
|
throw new Error("Server-side only class accessed from client");
|
|
22
9
|
}
|
|
23
10
|
this.key = key;
|
|
24
11
|
this.config = config;
|
|
25
12
|
}
|
|
13
|
+
// To be superseded by child
|
|
14
|
+
ensureInit = async () => {
|
|
15
|
+
};
|
|
16
|
+
// Reset the client
|
|
17
|
+
reset = () => {
|
|
18
|
+
this.client = null;
|
|
19
|
+
};
|
|
20
|
+
// Return the raw client if needed
|
|
21
|
+
getClient = async () => {
|
|
22
|
+
return this.client();
|
|
23
|
+
};
|
|
26
24
|
}
|
|
27
|
-
exports.BaseNamespace = BaseNamespace;
|
package/_class/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BaseNamespace = exports.BaseClass = void 0;
|
|
4
|
-
var BaseClass_1 = require("./BaseClass");
|
|
5
|
-
Object.defineProperty(exports, "BaseClass", { enumerable: true, get: function () { return BaseClass_1.BaseClass; } });
|
|
6
|
-
var BaseNamespace_1 = require("./BaseNamespace");
|
|
7
|
-
Object.defineProperty(exports, "BaseNamespace", { enumerable: true, get: function () { return BaseNamespace_1.BaseNamespace; } });
|
|
1
|
+
export { BaseClass } from "./BaseClass";
|
|
2
|
+
export { BaseNamespace } from "./BaseNamespace";
|
package/adverity/getJobs.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getJobs = void 0;
|
|
4
|
-
const date_1 = require("../date");
|
|
5
|
-
const axios_1 = require("../axios");
|
|
1
|
+
import { getDate, getToday, getYesterday, getYmdString } from "../date";
|
|
2
|
+
import { get } from "../axios";
|
|
6
3
|
/**
|
|
7
4
|
* Fetch all the jobs that ran yesterday by default.
|
|
8
5
|
* A job can either by in Fetch, Enrich or Transfer states, but all have different job ids. This makes it difficult to track and we would be reliant on the start/end time which could varu.
|
|
9
6
|
* As a result, we only store the Transfer jobs as this is when it gets moved into Bigquery. If it's not in Bigquery we cant use it anyway.
|
|
10
7
|
*/
|
|
11
|
-
const getJobs = async (apiKey, start, end, url) => {
|
|
12
|
-
const startYmd =
|
|
13
|
-
const endYmd =
|
|
8
|
+
export const getJobs = async (apiKey, start, end, url) => {
|
|
9
|
+
const startYmd = getYmdString(start ? getDate(start) : getYesterday());
|
|
10
|
+
const endYmd = getYmdString(end ? getDate(end) : getToday());
|
|
14
11
|
const finalUrl = "undefined" !== typeof url ? url : `https://8ms.datatap.adverity.com/api/jobs/?start=${startYmd}&end=${endYmd}&page_size=300`;
|
|
15
12
|
let response = [];
|
|
16
|
-
const apiResponse = await
|
|
13
|
+
const apiResponse = await get(finalUrl, {
|
|
17
14
|
headers: {
|
|
18
15
|
Authorization: `Bearer ${apiKey}`,
|
|
19
16
|
}
|
|
@@ -22,9 +19,8 @@ const getJobs = async (apiKey, start, end, url) => {
|
|
|
22
19
|
const apiResponseBody = apiResponse.getBody();
|
|
23
20
|
// Move to the next page
|
|
24
21
|
if (apiResponseBody.next) {
|
|
25
|
-
response = [...apiResponse.getBody(), await
|
|
22
|
+
response = [...apiResponse.getBody(), await getJobs(apiKey, start, end, apiResponseBody.next)];
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
return response;
|
|
29
26
|
};
|
|
30
|
-
exports.getJobs = getJobs;
|
package/adverity/index.js
CHANGED
|
@@ -1,61 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
isCreator: v4_1.z.boolean(),
|
|
17
|
-
isDatastreamManager: v4_1.z.boolean(),
|
|
18
|
-
isViewer: v4_1.z.boolean(),
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export const stackSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
uuid: z.string(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
slug: z.string(),
|
|
7
|
+
url: z.string(),
|
|
8
|
+
change_url: z.string(),
|
|
9
|
+
extracts_url: z.string(),
|
|
10
|
+
issues_url: z.string(),
|
|
11
|
+
overview_url: z.string(),
|
|
12
|
+
permissions: z.object({
|
|
13
|
+
isCreator: z.boolean(),
|
|
14
|
+
isDatastreamManager: z.boolean(),
|
|
15
|
+
isViewer: z.boolean(),
|
|
19
16
|
})
|
|
20
17
|
});
|
|
21
|
-
|
|
22
|
-
id:
|
|
23
|
-
stack:
|
|
24
|
-
stack_id:
|
|
25
|
-
name:
|
|
26
|
-
slug:
|
|
27
|
-
app_label:
|
|
28
|
-
absolute_url:
|
|
29
|
-
change_url:
|
|
30
|
-
extracts_url:
|
|
31
|
-
fetch_url:
|
|
32
|
-
overview_url:
|
|
33
|
-
schema_mapping_url:
|
|
34
|
-
enabled:
|
|
35
|
-
next_run:
|
|
36
|
-
url:
|
|
37
|
-
datastream_type_id:
|
|
38
|
-
logo_url:
|
|
39
|
-
extracts_stream_url:
|
|
40
|
-
supports_extended_intervals:
|
|
41
|
-
updated:
|
|
42
|
-
created:
|
|
43
|
-
creator:
|
|
44
|
-
can_be_fetched:
|
|
18
|
+
export const datastreamSchema = z.object({
|
|
19
|
+
id: z.number(),
|
|
20
|
+
stack: stackSchema,
|
|
21
|
+
stack_id: z.number(),
|
|
22
|
+
name: z.string(),
|
|
23
|
+
slug: z.string(),
|
|
24
|
+
app_label: z.string(),
|
|
25
|
+
absolute_url: z.string(),
|
|
26
|
+
change_url: z.string(),
|
|
27
|
+
extracts_url: z.string(),
|
|
28
|
+
fetch_url: z.string(),
|
|
29
|
+
overview_url: z.string(),
|
|
30
|
+
schema_mapping_url: z.string(),
|
|
31
|
+
enabled: z.bigint(),
|
|
32
|
+
next_run: z.union([z.string(), z.literal("Not Scheduled")]),
|
|
33
|
+
url: z.string(),
|
|
34
|
+
datastream_type_id: z.number(),
|
|
35
|
+
logo_url: z.string(),
|
|
36
|
+
extracts_stream_url: z.string(),
|
|
37
|
+
supports_extended_intervals: z.number(),
|
|
38
|
+
updated: z.string(),
|
|
39
|
+
created: z.string(),
|
|
40
|
+
creator: z.string(),
|
|
41
|
+
can_be_fetched: z.number(),
|
|
45
42
|
});
|
|
46
|
-
|
|
47
|
-
id:
|
|
48
|
-
url:
|
|
49
|
-
job_start:
|
|
43
|
+
export const jobSchema = z.object({
|
|
44
|
+
id: z.number(),
|
|
45
|
+
url: z.string(),
|
|
46
|
+
job_start: z.string()
|
|
50
47
|
.nullable(),
|
|
51
|
-
job_end:
|
|
48
|
+
job_end: z.string()
|
|
52
49
|
.nullable(),
|
|
53
|
-
progress:
|
|
54
|
-
state:
|
|
55
|
-
state_label:
|
|
56
|
-
state_color:
|
|
57
|
-
datastream:
|
|
58
|
-
issues:
|
|
50
|
+
progress: z.number(),
|
|
51
|
+
state: z.number(),
|
|
52
|
+
state_label: z.string(),
|
|
53
|
+
state_color: z.string(),
|
|
54
|
+
datastream: datastreamSchema,
|
|
55
|
+
issues: z.any()
|
|
59
56
|
.array(),
|
|
60
|
-
type:
|
|
57
|
+
type: z.union([z.string("Fetch"), z.string("Enrich"), z.string("Transfer")]),
|
|
61
58
|
});
|
package/adverity/server.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getJobs = void 0;
|
|
4
|
-
var getJobs_1 = require("./getJobs");
|
|
5
|
-
Object.defineProperty(exports, "getJobs", { enumerable: true, get: function () { return getJobs_1.getJobs; } });
|
|
1
|
+
export { getJobs } from "./getJobs";
|
package/api/ApiResponseClass.js
CHANGED
|
@@ -1,97 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ApiResponseClass = void 0;
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const types_1 = require("./types");
|
|
1
|
+
import { defaultTo } from "../util";
|
|
2
|
+
import { ApiState } from "./types";
|
|
6
3
|
/**
|
|
7
4
|
* Class version of the API to enable quicker instances.
|
|
8
5
|
*/
|
|
9
|
-
class ApiResponseClass {
|
|
6
|
+
export class ApiResponseClass {
|
|
7
|
+
state = ApiState.IDLE;
|
|
8
|
+
body = null;
|
|
9
|
+
error = null;
|
|
10
10
|
constructor({ body, error, state } = {}) {
|
|
11
|
-
this.state = types_1.ApiState.IDLE;
|
|
12
|
-
this.body = null;
|
|
13
|
-
this.error = null;
|
|
14
|
-
this.fromJson = (input) => {
|
|
15
|
-
this.body = input.body;
|
|
16
|
-
this.error = input.error;
|
|
17
|
-
this.state = input.state;
|
|
18
|
-
return this;
|
|
19
|
-
};
|
|
20
|
-
this.getBody = () => {
|
|
21
|
-
return this.body;
|
|
22
|
-
};
|
|
23
|
-
this.getBodyDefaultTo = (keys, defaultValue) => {
|
|
24
|
-
return (0, util_1.defaultTo)(this.body, keys, defaultValue);
|
|
25
|
-
};
|
|
26
|
-
this.getError = () => {
|
|
27
|
-
return this.error;
|
|
28
|
-
};
|
|
29
|
-
this.getJson = () => {
|
|
30
|
-
return {
|
|
31
|
-
body: this.body,
|
|
32
|
-
error: this.error,
|
|
33
|
-
state: this.state,
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
this.getApiState = () => {
|
|
37
|
-
return this.state;
|
|
38
|
-
};
|
|
39
|
-
this.isError = () => {
|
|
40
|
-
return this.state === types_1.ApiState.ERROR;
|
|
41
|
-
};
|
|
42
|
-
this.isIdle = () => {
|
|
43
|
-
return this.state === types_1.ApiState.IDLE;
|
|
44
|
-
};
|
|
45
|
-
this.isPending = () => {
|
|
46
|
-
return this.state === types_1.ApiState.PENDING;
|
|
47
|
-
};
|
|
48
|
-
this.isSuccess = () => {
|
|
49
|
-
return this.state === types_1.ApiState.SUCCESS;
|
|
50
|
-
};
|
|
51
|
-
this.setToIdle = () => {
|
|
52
|
-
this.state = types_1.ApiState.IDLE;
|
|
53
|
-
return this;
|
|
54
|
-
};
|
|
55
|
-
this.setToPending = () => {
|
|
56
|
-
this.state = types_1.ApiState.PENDING;
|
|
57
|
-
return this;
|
|
58
|
-
};
|
|
59
|
-
this.setToError = (error, body) => {
|
|
60
|
-
this.body = body || null;
|
|
61
|
-
this.error = error;
|
|
62
|
-
this.state = types_1.ApiState.ERROR;
|
|
63
|
-
return this;
|
|
64
|
-
};
|
|
65
|
-
this.setToSuccess = (body) => {
|
|
66
|
-
this.body = body;
|
|
67
|
-
this.state = types_1.ApiState.SUCCESS;
|
|
68
|
-
return this;
|
|
69
|
-
};
|
|
70
|
-
this.setBody = (body) => {
|
|
71
|
-
this.body = body;
|
|
72
|
-
return this;
|
|
73
|
-
};
|
|
74
|
-
this.setError = (error) => {
|
|
75
|
-
this.error = error;
|
|
76
|
-
return this;
|
|
77
|
-
};
|
|
78
|
-
this.setApiState = (state) => {
|
|
79
|
-
this.state = state;
|
|
80
|
-
return this;
|
|
81
|
-
};
|
|
82
|
-
this.validateZod = (schema) => {
|
|
83
|
-
try {
|
|
84
|
-
const validatedBody = schema.parse(this.body);
|
|
85
|
-
return new ApiResponseClass({ body: validatedBody, state: this.state });
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
return new ApiResponseClass({ error, state: types_1.ApiState.ERROR });
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
11
|
this.body = body || null;
|
|
92
12
|
this.error = error || null;
|
|
93
|
-
this.state = state ||
|
|
13
|
+
this.state = state || ApiState.IDLE;
|
|
94
14
|
return this;
|
|
95
15
|
}
|
|
16
|
+
fromJson = (input) => {
|
|
17
|
+
this.body = input.body;
|
|
18
|
+
this.error = input.error;
|
|
19
|
+
this.state = input.state;
|
|
20
|
+
return this;
|
|
21
|
+
};
|
|
22
|
+
getBody = () => {
|
|
23
|
+
return this.body;
|
|
24
|
+
};
|
|
25
|
+
getBodyDefaultTo = (keys, defaultValue) => {
|
|
26
|
+
return defaultTo(this.body, keys, defaultValue);
|
|
27
|
+
};
|
|
28
|
+
getError = () => {
|
|
29
|
+
return this.error;
|
|
30
|
+
};
|
|
31
|
+
getJson = () => {
|
|
32
|
+
return {
|
|
33
|
+
body: this.body,
|
|
34
|
+
error: this.error,
|
|
35
|
+
state: this.state,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
getApiState = () => {
|
|
39
|
+
return this.state;
|
|
40
|
+
};
|
|
41
|
+
isError = () => {
|
|
42
|
+
return this.state === ApiState.ERROR;
|
|
43
|
+
};
|
|
44
|
+
isIdle = () => {
|
|
45
|
+
return this.state === ApiState.IDLE;
|
|
46
|
+
};
|
|
47
|
+
isPending = () => {
|
|
48
|
+
return this.state === ApiState.PENDING;
|
|
49
|
+
};
|
|
50
|
+
isSuccess = () => {
|
|
51
|
+
return this.state === ApiState.SUCCESS;
|
|
52
|
+
};
|
|
53
|
+
setToIdle = () => {
|
|
54
|
+
this.state = ApiState.IDLE;
|
|
55
|
+
return this;
|
|
56
|
+
};
|
|
57
|
+
setToPending = () => {
|
|
58
|
+
this.state = ApiState.PENDING;
|
|
59
|
+
return this;
|
|
60
|
+
};
|
|
61
|
+
setToError = (error, body) => {
|
|
62
|
+
this.body = body || null;
|
|
63
|
+
this.error = error;
|
|
64
|
+
this.state = ApiState.ERROR;
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
setToSuccess = (body) => {
|
|
68
|
+
this.body = body;
|
|
69
|
+
this.state = ApiState.SUCCESS;
|
|
70
|
+
return this;
|
|
71
|
+
};
|
|
72
|
+
setBody = (body) => {
|
|
73
|
+
this.body = body;
|
|
74
|
+
return this;
|
|
75
|
+
};
|
|
76
|
+
setError = (error) => {
|
|
77
|
+
this.error = error;
|
|
78
|
+
return this;
|
|
79
|
+
};
|
|
80
|
+
setApiState = (state) => {
|
|
81
|
+
this.state = state;
|
|
82
|
+
return this;
|
|
83
|
+
};
|
|
84
|
+
validateZod = (schema) => {
|
|
85
|
+
try {
|
|
86
|
+
const validatedBody = schema.parse(this.body);
|
|
87
|
+
return new ApiResponseClass({ body: validatedBody, state: this.state });
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return new ApiResponseClass({ error, state: ApiState.ERROR });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
96
93
|
}
|
|
97
|
-
exports.ApiResponseClass = ApiResponseClass;
|
package/api/functions.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
const isCancelled = (apiResponse) => {
|
|
6
|
-
return types_1.ApiState.CANCELLED === apiResponse.state;
|
|
1
|
+
import { ApiState } from "./types";
|
|
2
|
+
export const isCancelled = (apiResponse) => {
|
|
3
|
+
return ApiState.CANCELLED === apiResponse.state;
|
|
7
4
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return types_1.ApiState.ERROR === apiResponse.state;
|
|
5
|
+
export const isError = (apiResponse) => {
|
|
6
|
+
return ApiState.ERROR === apiResponse.state;
|
|
11
7
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return types_1.ApiState.IDLE === apiResponse.state;
|
|
8
|
+
export const isIdle = (apiResponse) => {
|
|
9
|
+
return ApiState.IDLE === apiResponse.state;
|
|
15
10
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return types_1.ApiState.PENDING === apiResponse.state;
|
|
11
|
+
export const isPending = (apiResponse) => {
|
|
12
|
+
return ApiState.PENDING === apiResponse.state;
|
|
19
13
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return types_1.ApiState.SUCCESS === apiResponse.state;
|
|
14
|
+
export const isSuccess = (apiResponse) => {
|
|
15
|
+
return ApiState.SUCCESS === apiResponse.state;
|
|
23
16
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return types_1.ApiState.VALIDATION_ERROR === apiResponse.state;
|
|
17
|
+
export const isValidationError = (apiResponse) => {
|
|
18
|
+
return ApiState.VALIDATION_ERROR === apiResponse.state;
|
|
27
19
|
};
|
|
28
|
-
exports.isValidationError = isValidationError;
|
package/api/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./ApiResponseClass"), exports);
|
|
18
|
-
__exportStar(require("./functions"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export * from "./ApiResponseClass";
|
|
2
|
+
export * from "./functions";
|
|
3
|
+
export * from "./types";
|
package/api/types.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.unexpectedError = exports.defaultResponse = exports.ApiState = exports.ApiResponseClass = void 0;
|
|
4
|
-
var ApiResponseClass_1 = require("./ApiResponseClass");
|
|
5
|
-
Object.defineProperty(exports, "ApiResponseClass", { enumerable: true, get: function () { return ApiResponseClass_1.ApiResponseClass; } });
|
|
6
|
-
exports.ApiState = {
|
|
1
|
+
export { ApiResponseClass } from "./ApiResponseClass";
|
|
2
|
+
export const ApiState = {
|
|
7
3
|
CANCELLED: "CANCELLED",
|
|
8
4
|
ERROR: "ERROR",
|
|
9
5
|
IDLE: "IDLE",
|
|
@@ -11,9 +7,9 @@ exports.ApiState = {
|
|
|
11
7
|
SUCCESS: "SUCCESS",
|
|
12
8
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
13
9
|
};
|
|
14
|
-
|
|
10
|
+
export const defaultResponse = {
|
|
15
11
|
body: null,
|
|
16
12
|
error: null,
|
|
17
|
-
state:
|
|
13
|
+
state: ApiState.IDLE,
|
|
18
14
|
};
|
|
19
|
-
|
|
15
|
+
export const unexpectedError = "An unexpected error occurred, please try again.";
|
package/array/index.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
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.getArray = exports.contains = void 0;
|
|
7
|
-
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
1
|
+
import isArray from "lodash/isArray";
|
|
8
2
|
/**
|
|
9
3
|
* Shorthand to check if an array or string contains a needle.
|
|
10
4
|
*/
|
|
11
|
-
const contains = (haystack, needle) => -1 !== haystack.indexOf(needle);
|
|
12
|
-
exports.contains = contains;
|
|
5
|
+
export const contains = (haystack, needle) => -1 !== haystack.indexOf(needle);
|
|
13
6
|
/**
|
|
14
7
|
* Convert an array into an array or return if already an array.
|
|
15
8
|
*/
|
|
16
|
-
const getArray = (input) => (
|
|
17
|
-
exports.getArray = getArray;
|
|
9
|
+
export const getArray = (input) => isArray(input) ? input : [input];
|
package/atInternet/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requestSchema = void 0;
|
|
4
|
-
const v4_1 = require("zod/v4");
|
|
1
|
+
import { z } from "zod/v4";
|
|
5
2
|
/**
|
|
6
3
|
* The request in the structure required by AT Internet.
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
columns:
|
|
10
|
-
evo:
|
|
11
|
-
filter:
|
|
12
|
-
"max-results":
|
|
13
|
-
options:
|
|
14
|
-
"ignore_null_properties":
|
|
5
|
+
export const requestSchema = z.object({
|
|
6
|
+
columns: z.array(z.string()),
|
|
7
|
+
evo: z.object({}),
|
|
8
|
+
filter: z.object({}),
|
|
9
|
+
"max-results": z.number(),
|
|
10
|
+
options: z.object({
|
|
11
|
+
"ignore_null_properties": z.boolean(),
|
|
15
12
|
}),
|
|
16
|
-
"page-num":
|
|
17
|
-
period:
|
|
13
|
+
"page-num": z.number(),
|
|
14
|
+
period: z.object({}),
|
|
18
15
|
});
|