xscrape 1.1.1 → 1.3.0
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/README.md +1 -1
- package/dist/index.cjs +15 -0
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +14 -0
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Effect Schema, allowing you to use your preferred validation tool.
|
|
|
20
20
|
| Schema Library | Status | Notes |
|
|
21
21
|
| ---------------------------------------------------- | ------------------- | ------------------------------------------------------------------ |
|
|
22
22
|
| [Zod](https://github.com/colinhacks/zod) | ✅ Supported | Default schema tool for `xscrape` |
|
|
23
|
-
| [Effect/Schema](https://github.com/Effect-TS/
|
|
23
|
+
| [Effect/Schema](https://github.com/Effect-TS/effect) | ✅ Supported | Support for Effect/Schema for additional flexibility |
|
|
24
24
|
| [Joi](https://github.com/sideway/joi) | 🚧 Planned | Support for Joi for those familiar with server-side validation |
|
|
25
25
|
| [Yup](https://github.com/jquense/yup) | 🚧 Planned | Adding Yup support for schema validation in front-end applications |
|
|
26
26
|
| Others... | 🔄 In Consideration | Potential support for other schema tools as per user feedback |
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
EffectValidator: () => EffectValidator,
|
|
33
34
|
ZodValidator: () => ZodValidator,
|
|
34
35
|
createScraper: () => createScraper
|
|
35
36
|
});
|
|
@@ -81,6 +82,19 @@ var createScraper = ({
|
|
|
81
82
|
};
|
|
82
83
|
};
|
|
83
84
|
|
|
85
|
+
// src/validators/effect.ts
|
|
86
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
87
|
+
var import_effect = require("effect");
|
|
88
|
+
var EffectValidator = class {
|
|
89
|
+
constructor(schema) {
|
|
90
|
+
this.schema = schema;
|
|
91
|
+
}
|
|
92
|
+
validate(data) {
|
|
93
|
+
const result = Schema.decodeUnknown(this.schema)(data);
|
|
94
|
+
return import_effect.Effect.runSync(result);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
84
98
|
// src/validators/zod.ts
|
|
85
99
|
var import_zod = require("zod");
|
|
86
100
|
var ZodValidator = class {
|
|
@@ -93,6 +107,7 @@ var ZodValidator = class {
|
|
|
93
107
|
};
|
|
94
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
95
109
|
0 && (module.exports = {
|
|
110
|
+
EffectValidator,
|
|
96
111
|
ZodValidator,
|
|
97
112
|
createScraper
|
|
98
113
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as cheerio from 'cheerio';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
2
3
|
import { ZodSchema } from 'zod';
|
|
3
4
|
|
|
4
5
|
type ScrapeConfig<T> = {
|
|
@@ -24,10 +25,16 @@ interface SchemaValidator<T> {
|
|
|
24
25
|
|
|
25
26
|
declare const createScraper: <T>({ fields, validator, }: ScrapeConfig<T>) => ((html: cheerio.CheerioAPI | string) => T);
|
|
26
27
|
|
|
28
|
+
declare class EffectValidator<A, I = A> implements SchemaValidator<A> {
|
|
29
|
+
private schema;
|
|
30
|
+
constructor(schema: Schema.Schema<A, I>);
|
|
31
|
+
validate(data: unknown): A;
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
declare class ZodValidator<T> implements SchemaValidator<T> {
|
|
28
35
|
private schema;
|
|
29
36
|
constructor(schema: ZodSchema<T>);
|
|
30
37
|
validate(data: unknown): T;
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
export { type FieldDefinition, type SchemaFieldDefinitions, type SchemaValidator, type ScrapeConfig, ZodValidator, createScraper };
|
|
40
|
+
export { EffectValidator, type FieldDefinition, type SchemaFieldDefinitions, type SchemaValidator, type ScrapeConfig, ZodValidator, createScraper };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as cheerio from 'cheerio';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
2
3
|
import { ZodSchema } from 'zod';
|
|
3
4
|
|
|
4
5
|
type ScrapeConfig<T> = {
|
|
@@ -24,10 +25,16 @@ interface SchemaValidator<T> {
|
|
|
24
25
|
|
|
25
26
|
declare const createScraper: <T>({ fields, validator, }: ScrapeConfig<T>) => ((html: cheerio.CheerioAPI | string) => T);
|
|
26
27
|
|
|
28
|
+
declare class EffectValidator<A, I = A> implements SchemaValidator<A> {
|
|
29
|
+
private schema;
|
|
30
|
+
constructor(schema: Schema.Schema<A, I>);
|
|
31
|
+
validate(data: unknown): A;
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
declare class ZodValidator<T> implements SchemaValidator<T> {
|
|
28
35
|
private schema;
|
|
29
36
|
constructor(schema: ZodSchema<T>);
|
|
30
37
|
validate(data: unknown): T;
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
export { type FieldDefinition, type SchemaFieldDefinitions, type SchemaValidator, type ScrapeConfig, ZodValidator, createScraper };
|
|
40
|
+
export { EffectValidator, type FieldDefinition, type SchemaFieldDefinitions, type SchemaValidator, type ScrapeConfig, ZodValidator, createScraper };
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,19 @@ var createScraper = ({
|
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
// src/validators/effect.ts
|
|
48
|
+
import * as Schema from "effect/Schema";
|
|
49
|
+
import { Effect } from "effect";
|
|
50
|
+
var EffectValidator = class {
|
|
51
|
+
constructor(schema) {
|
|
52
|
+
this.schema = schema;
|
|
53
|
+
}
|
|
54
|
+
validate(data) {
|
|
55
|
+
const result = Schema.decodeUnknown(this.schema)(data);
|
|
56
|
+
return Effect.runSync(result);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
47
60
|
// src/validators/zod.ts
|
|
48
61
|
import "zod";
|
|
49
62
|
var ZodValidator = class {
|
|
@@ -55,6 +68,7 @@ var ZodValidator = class {
|
|
|
55
68
|
}
|
|
56
69
|
};
|
|
57
70
|
export {
|
|
71
|
+
EffectValidator,
|
|
58
72
|
ZodValidator,
|
|
59
73
|
createScraper
|
|
60
74
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xscrape",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A flexible and powerful library designed to extract and transform data from HTML documents using user-defined schemas",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -13,16 +13,6 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"type": "module",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsup",
|
|
18
|
-
"ci": "npm run build && npm run check-format && npm run check-exports && npm run lint && npm run test",
|
|
19
|
-
"lint": "tsc",
|
|
20
|
-
"test": "vitest run",
|
|
21
|
-
"format": "prettier --write .",
|
|
22
|
-
"check-format": "prettier --check .",
|
|
23
|
-
"check-exports": "attw --pack .",
|
|
24
|
-
"local-release": "npm run ci && changeset version && changeset publish"
|
|
25
|
-
},
|
|
26
16
|
"keywords": [
|
|
27
17
|
"web-scraping",
|
|
28
18
|
"data-extraction",
|
|
@@ -58,6 +48,17 @@
|
|
|
58
48
|
},
|
|
59
49
|
"dependencies": {
|
|
60
50
|
"cheerio": "^1.0.0",
|
|
51
|
+
"effect": "^3.10.4",
|
|
61
52
|
"zod": "^3.23.8"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"ci": "npm run build && npm run check-format && npm run check-exports && npm run lint && npm run test",
|
|
57
|
+
"lint": "tsc",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"format": "prettier --write ./src",
|
|
60
|
+
"check-format": "prettier --check ./src",
|
|
61
|
+
"check-exports": "attw --pack .",
|
|
62
|
+
"local-release": "npm run ci && changeset version && changeset publish"
|
|
62
63
|
}
|
|
63
|
-
}
|
|
64
|
+
}
|