@apounited/mac 0.1.2 → 1.1.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 +20 -9
- package/dist/main.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,21 +12,32 @@ Crawls and extracts data from the [Mauve API](https://api.mauve.de)
|
|
|
12
12
|
|
|
13
13
|
### Crawl
|
|
14
14
|
|
|
15
|
-
The crawlers can be invoked via `bunx` or `npx` with `@apounited/mac`.
|
|
15
|
+
The crawlers can be invoked via `bunx`, `pnpx` or `npx` with `@apounited/mac`.
|
|
16
16
|
|
|
17
17
|
> Data is saved to `./storage` relative to the execution path.
|
|
18
18
|
|
|
19
|
+
> Pin to specific version with `@apounited/mac@1.0.0`.
|
|
20
|
+
|
|
21
|
+
#### Bun
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bunx @apounited/mac@latest crawl customers --username demo --password 'demo'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### Node
|
|
28
|
+
|
|
19
29
|
```bash
|
|
20
|
-
|
|
30
|
+
npx -y @apounited/mac@latest crawl customers --username demo --password 'demo'
|
|
21
31
|
```
|
|
22
32
|
|
|
23
|
-
Available
|
|
33
|
+
Available crawl endpoints: `categories`, `customers`, `documents`, `products`.
|
|
24
34
|
|
|
25
|
-
| Options | Short | Required | Values
|
|
26
|
-
| ---------------- | ----- | ---------- |
|
|
27
|
-
| `--username` | `-u` | `true` | `
|
|
28
|
-
| `--password` | `-p` | `true` | `
|
|
29
|
-
| `--
|
|
35
|
+
| Options | Short | Required | Values | Description |
|
|
36
|
+
| ---------------- | ----- | ---------- | ------------ | -------------------------------- |
|
|
37
|
+
| `--username` | `-u` | `true` | `string` | Mauve Customer ID |
|
|
38
|
+
| `--password` | `-p` | `true` | `string` | Mauve API Password |
|
|
39
|
+
| `--format` | `-f` | `optional` | `json` `csv` | Export file format |
|
|
40
|
+
| `--max-requests` | `-r` | `optional` | `number` | Maximum number of crawl requests |
|
|
30
41
|
|
|
31
42
|
### Clean
|
|
32
43
|
|
|
@@ -41,7 +52,7 @@ bunx @apounited/mac clean
|
|
|
41
52
|
Run the main CLI entry point without building:
|
|
42
53
|
|
|
43
54
|
```bash
|
|
44
|
-
bun dev
|
|
55
|
+
bun dev crawl customers --username demo --password 'demo'
|
|
45
56
|
```
|
|
46
57
|
|
|
47
58
|
## Production
|
package/dist/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var k=Object.defineProperty;var U=(e)=>e;function $(e,n){this[e]=U.bind(null,n)}var x=(e,n)=>{for(var t in n)k(e,t,{get:n[t],enumerable:!0,configurable:!0,set:$.bind(n,t)})};var g=(e,n)=>()=>(e&&(n=e(e=0)),n);function d({username:e,password:n}){return{auth:Buffer.from(`${e}:${n}`).toString("base64")}}function w({baseUrl:e="https://api.mauve.de",endpoint:n="/",limit:t=1000,offset:m=0}){return{params:{limit:t,offset:m},req:function(c){let o=new URLSearchParams(c).toString();return`${e.replace(/\/$/,"")}/${n.replace(/^\//,"")}?${o}`}}}var b={};x(b,{crawl:()=>I});import{BasicCrawler as E}from"@crawlee/basic";async function I(e){let{auth:n}=d({username:e.username,password:e.password}),{params:t,req:m}=w({endpoint:e.endpoint}),i=new E({maxConcurrency:1,maxRequestsPerCrawl:e.maxRequests,async requestHandler({sendRequest:f,addRequests:c,pushData:o,log:u}){let{ok:S,body:r}=await f({responseType:"json",http2:!1,headers:{Authorization:`Basic ${n}`}});if(S){let s="categories"in r&&r.categories||"customers"in r&&r.customers||"documents"in r&&r.documents||"products"in r&&r.products;if(s){if(t.offset+=s.length,t.offset&&s.length===t.limit)await c([m(t)]);await o(s),u.info(`Fetched ${s.length} ${e.endpoint} (total: ${t.offset})`)}else u.warning("Response might not contain valid keys"),await i.teardown(),process.exit()}else if("responseStatus"in r)u.error(`${r.responseStatus.errorCode}: ${r.responseStatus.message}`),await i.teardown(),process.exit()}});await i.run([m(t)]),await i.exportData(`storage/data/${e.username.toLowerCase()}/${e.endpoint}.${e.format?.toLowerCase()??"json"}`)}var v=()=>{};var h={};x(h,{clean:()=>P});import{rimraf as L}from"rimraf";async function P(){await L("storage")}var j=()=>{};import C from"cac";var p={name:"@apounited/mac",version:"1.1.0",license:"UNLICENSED",author:"Sergej Samsonenko",description:"Crawls and extracts data from the Mauve API.",type:"module",keywords:["mauve","api","crawler"],files:["dist"],publishConfig:{access:"public"},main:"./dist/main.js",bin:{mac:"./dist/main.js"},scripts:{build:"bun build.ts",dev:"bun src/main.ts",lint:"bunx oxlint",fmt:"bunx oxfmt",clean:"bunx rimraf storage",deps:"(bunx taze -r -w) && (bun i)",prepublishOnly:"bunx pinst -d",postpublish:"bunx pinst -e",postinstall:"bunx simple-git-hooks"},dependencies:{"@crawlee/basic":"^3.16.0",cac:"^7.0.0",rimraf:"^6.1.3"},devDependencies:{"@apify/tsconfig":"^0.1.2","@types/bun":"latest","oxlint-tsgolint":"^0.22.1",typescript:"^6.0.3"},"simple-git-hooks":{"pre-commit":"bunx lint-staged","commit-msg":"bunx @apounited/verify-commit-msg@latest $1"},"lint-staged":{"*.{js,ts}":["bunx oxlint --fix"],"*":["bunx oxfmt --no-error-on-unmatched-pattern"]}};var a=C(p.name);a.command("crawl <endpoint>","Specify the endpoint to crawl (categories, customers, documents, products)").option("-u, --username <username>","Username for authentication").option("-p, --password <password>","Password for authentication").option("-f, --format [format]","Export file format (json, csv)").option("-r, --max-requests [number]","Maximum number of requests to make").example("crawl customers --username demo --password 'demo' --format csv --max-requests 5").action(async(e,n)=>{if(!n.username||!n.password)console.error("Error: Username and password are required."),process.exit();let{crawl:t}=await Promise.resolve().then(() => (v(),b));await t({endpoint:e,...n})});a.command("clean","Delete ./storage directory and all its contents").action(async()=>{let{clean:e}=await Promise.resolve().then(() => (j(),h));await e()});a.help();a.version(p.version);a.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apounited/mac",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "Sergej Samsonenko",
|
|
6
6
|
"description": "Crawls and extracts data from the Mauve API.",
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
"fmt": "bunx oxfmt",
|
|
28
28
|
"clean": "bunx rimraf storage",
|
|
29
29
|
"deps": "(bunx taze -r -w) && (bun i)",
|
|
30
|
-
"prepublishOnly": "
|
|
31
|
-
"postpublish": "
|
|
30
|
+
"prepublishOnly": "bunx pinst -d",
|
|
31
|
+
"postpublish": "bunx pinst -e",
|
|
32
|
+
"_postinstall": "bunx simple-git-hooks"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@crawlee/basic": "^3.16.0",
|
|
@@ -43,15 +44,14 @@
|
|
|
43
44
|
},
|
|
44
45
|
"simple-git-hooks": {
|
|
45
46
|
"pre-commit": "bunx lint-staged",
|
|
46
|
-
"commit-msg": "bunx @apounited/verify-commit-msg $1"
|
|
47
|
+
"commit-msg": "bunx @apounited/verify-commit-msg@latest $1"
|
|
47
48
|
},
|
|
48
49
|
"lint-staged": {
|
|
49
50
|
"*.{js,ts}": [
|
|
50
51
|
"bunx oxlint --fix"
|
|
51
52
|
],
|
|
52
53
|
"*": [
|
|
53
|
-
"bunx oxfmt --no-error-on-unmatched-pattern"
|
|
54
|
-
"git add"
|
|
54
|
+
"bunx oxfmt --no-error-on-unmatched-pattern"
|
|
55
55
|
]
|
|
56
56
|
}
|
|
57
57
|
}
|