@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 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
- bunx @apounited/mac crawl customers --username demo --password demo
30
+ npx -y @apounited/mac@latest crawl customers --username demo --password 'demo'
21
31
  ```
22
32
 
23
- Available crawlers: `customers`, `orders`, `products`.
33
+ Available crawl endpoints: `categories`, `customers`, `documents`, `products`.
24
34
 
25
- | Options | Short | Required | Values | Description |
26
- | ---------------- | ----- | ---------- | ---------- | -------------------------------- |
27
- | `--username` | `-u` | `true` | `demo` | Mauve Customer ID |
28
- | `--password` | `-p` | `true` | `demo` | Mauve API Password |
29
- | `--max-requests` | `-r` | `optional` | `<NUMBER>` | Maximum number of crawl requests |
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 G=Object.defineProperty;var C=(o)=>o;function F(o,n){this[o]=C.bind(null,n)}var S=(o,n)=>{for(var t in n)G(o,t,{get:n[t],enumerable:!0,configurable:!0,set:F.bind(n,t)})};var U=(o,n)=>()=>(o&&(n=o(o=0)),n);function x({username:o,password:n}){return{auth:Buffer.from(`${o}:${n}`).toString("base64")}}function g({baseUrl:o="https://api.mauve.de",endpoint:n="/",limit:t=1000,offset:m=0}){return{id:n.split("/").filter(Boolean).join("-"),params:{limit:t,offset:m},req:function(f){let p=new URLSearchParams(f).toString();return`${o.replace(/\/$/,"")}/${n.replace(/^\//,"")}?${p}`}}}var I={};S(I,{crawler:()=>O});import{BasicCrawler as K}from"@crawlee/basic";async function O({username:o,password:n,maxRequests:t}){let{auth:m}=x({username:o,password:n}),{id:c,params:i,req:l}=g({endpoint:"/customers"}),f=new K({maxConcurrency:1,maxRequestsPerCrawl:t,async requestHandler({sendRequest:p,addRequests:y,pushData:v,log:b}){let{body:k}=await p({responseType:"json",http2:!1,headers:{Authorization:`Basic ${m}`}}),r=k.customers;if(i.offset+=r.length,i.offset&&r.length===i.limit)await y([l(i)]);await v(r),b.info(`Fetched ${r.length} ${c} (total: ${i.offset})`)}});await f.run([l(i)]),await f.exportData(`storage/data/${o.toLowerCase()}/${c}.json`)}var L=()=>{};var P={};S(P,{crawler:()=>V});import{BasicCrawler as Q}from"@crawlee/basic";async function V({username:o,password:n,maxRequests:t}){let{auth:m}=x({username:o,password:n}),{params:c,req:i}=g({endpoint:"/documents"}),l="orders",f=new Q({maxConcurrency:1,maxRequestsPerCrawl:t,async requestHandler({sendRequest:p,addRequests:y,pushData:v,log:b}){let{body:k}=await p({responseType:"json",http2:!1,headers:{Authorization:`Basic ${m}`}}),r=k.documents;if(c.offset+=r.length,c.offset&&r.length===c.limit)await y([i({...c,documentTypes:"Bestellung"})]);await v(r),b.info(`Fetched ${r.length} orders (total: ${c.offset})`)}});await f.run([i({...c,documentTypes:"Bestellung"})]),await f.exportData(`storage/data/${o.toLowerCase()}/orders.json`)}var E=()=>{};var M={};S(M,{crawler:()=>X});import{BasicCrawler as W}from"@crawlee/basic";async function X({username:o,password:n,maxRequests:t}){let{auth:m}=x({username:o,password:n}),{id:c,params:i,req:l}=g({endpoint:"/products"}),f=new W({maxConcurrency:1,maxRequestsPerCrawl:t,async requestHandler({sendRequest:p,addRequests:y,pushData:v,log:b}){let{body:k}=await p({responseType:"json",http2:!1,headers:{Authorization:`Basic ${m}`}}),r=k.products;if(i.offset+=r.length,i.offset&&r.length===i.limit)await y([l(i)]);await v(r),b.info(`Fetched ${r.length} ${c} (total: ${i.offset})`)}});await f.run([l(i)]),await f.exportData(`storage/data/${o.toLowerCase()}/${c}.json`)}var N=()=>{};var w={};S(w,{clean:()=>Z});import{rimraf as Y}from"rimraf";async function Z(){await Y("storage")}var z=()=>{};import _ from"cac";var $={name:"@apounited/mac",version:"0.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)",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 $1"},"lint-staged":{"*.{js,ts}":["bunx oxlint --fix"],"*":["bunx oxfmt --no-error-on-unmatched-pattern","git add"]}};var j=_($.name);j.command("crawl <value>","Specify the crawler to run (customers, orders, products)").option("-u, --username <username>","Username for authentication").option("-p, --password <password>","Password for authentication").option("-r, --max-requests [number]","Maximum number of requests to make").example("crawl customers --username demo --password demo --max-requests 5").action(async(o,n)=>{let{username:t,password:m,maxRequests:c}=n;if(!t||!m)console.error("Error: Username and password are required."),process.exit(1);let i={customers:()=>Promise.resolve().then(() => (L(),I)),orders:()=>Promise.resolve().then(() => (E(),P)),products:()=>Promise.resolve().then(() => (N(),M))},{crawler:l}=await i[o]();await l({username:t,password:m,maxRequests:c})});j.command("clean","Delete ./storage directory and all its contents").action(async()=>{let{clean:o}=await Promise.resolve().then(() => (z(),w));await o()});j.help();j.version($.version);j.parse();
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": "0.1.2",
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": "bun scripts/publish.ts pre",
31
- "postpublish": "bun scripts/publish.ts post"
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
  }