@apounited/mac 0.1.1 → 1.0.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,12 +12,20 @@ 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
+ #### Bun
20
+
21
+ ```bash
22
+ bunx @apounited/mac@latest crawl customers --username demo --password demo
23
+ ```
24
+
25
+ #### Node
26
+
19
27
  ```bash
20
- bunx @apounited/mac crawl customers --username demo --password demo
28
+ npx -y @apounited/mac@latest crawl customers --username demo --password demo
21
29
  ```
22
30
 
23
31
  Available crawlers: `customers`, `orders`, `products`.
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 z=Object.defineProperty;var G=(n)=>n;function O(n,o){this[n]=G.bind(null,o)}var e=(n,o)=>{for(var t in o)z(n,t,{get:o[t],enumerable:!0,configurable:!0,set:O.bind(o,t)})};var j=(n,o)=>()=>(n&&(o=n(n=0)),o);function x({username:n,password:o}){return{auth:Buffer.from(`${n}:${o}`).toString("base64")}}function b({baseUrl:n="https://api.mauve.de",endpoint:o="/",limit:t=1000,offset:p=0}){return{id:o.split("/").filter(Boolean).join("-"),params:{limit:t,offset:p},req:function(m){let f=new URLSearchParams(m).toString();return`${n.replace(/\/$/,"")}/${o.replace(/^\//,"")}?${f}`}}}var $={};e($,{crawler:()=>J});import{BasicCrawler as F}from"@crawlee/basic";async function J({username:n,password:o,maxRequests:t}){let{auth:p}=x({username:n,password:o}),{id:c,params:i,req:l}=b({endpoint:"/customers"}),m=new F({maxConcurrency:1,maxRequestsPerCrawl:t,async requestHandler({sendRequest:f,addRequests:g,pushData:y,log:v}){let{body:s}=await f({responseType:"json",http2:!1,headers:{Authorization:`Basic ${p}`}}),r=s.customers;if(i.offset+=r.length,i.offset&&r.length===i.limit)await g([l(i)]);await y(r),v.info(`Fetched ${r.length} ${c} (total: ${i.offset})`)}});await m.run([l(i)]),await m.exportData(`storage/data/${n.toLowerCase()}/${c}.json`)}var I=()=>{};var L={};e(L,{crawler:()=>Q});import{BasicCrawler as K}from"@crawlee/basic";async function Q({username:n,password:o,maxRequests:t}){let{auth:p}=x({username:n,password:o}),{params:c,req:i}=b({endpoint:"/documents"}),l="orders",m=new K({maxConcurrency:1,maxRequestsPerCrawl:t,async requestHandler({sendRequest:f,addRequests:g,pushData:y,log:v}){let{body:s}=await f({responseType:"json",http2:!1,headers:{Authorization:`Basic ${p}`}}),r=s.documents;if(c.offset+=r.length,c.offset&&r.length===c.limit)await g([i({...c,documentTypes:"Bestellung"})]);await y(r),v.info(`Fetched ${r.length} orders (total: ${c.offset})`)}});await m.run([i({...c,documentTypes:"Bestellung"})]),await m.exportData(`storage/data/${n.toLowerCase()}/orders.json`)}var P=()=>{};var E={};e(E,{crawler:()=>W});import{BasicCrawler as V}from"@crawlee/basic";async function W({username:n,password:o,maxRequests:t}){let{auth:p}=x({username:n,password:o}),{id:c,params:i,req:l}=b({endpoint:"/products"}),m=new V({maxConcurrency:1,maxRequestsPerCrawl:t,async requestHandler({sendRequest:f,addRequests:g,pushData:y,log:v}){let{body:s}=await f({responseType:"json",http2:!1,headers:{Authorization:`Basic ${p}`}}),r=s.products;if(i.offset+=r.length,i.offset&&r.length===i.limit)await g([l(i)]);await y(r),v.info(`Fetched ${r.length} ${c} (total: ${i.offset})`)}});await m.run([l(i)]),await m.exportData(`storage/data/${n.toLowerCase()}/${c}.json`)}var M=()=>{};var N={};e(N,{clean:()=>Y});import{rimraf as X}from"rimraf";async function Y(){await X("storage")}var w=()=>{};import Z from"cac";var S={name:"@apounited/mac",version:"1.0.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:"bun scripts/publish.ts pre",postpublish:"bun scripts/publish.ts post",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 k=Z(S.name);k.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(n,o)=>{let{username:t,password:p,maxRequests:c}=o;if(!t||!p)console.error("Error: Username and password are required."),process.exit(1);let i={customers:()=>Promise.resolve().then(() => (I(),$)),orders:()=>Promise.resolve().then(() => (P(),L)),products:()=>Promise.resolve().then(() => (M(),E))},{crawler:l}=await i[n]();await l({username:t,password:p,maxRequests:c})});k.command("clean","Delete ./storage directory and all its contents").action(async()=>{let{clean:n}=await Promise.resolve().then(() => (w(),N));await n()});k.help();k.version(S.version);k.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apounited/mac",
3
- "version": "0.1.1",
3
+ "version": "1.0.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": "Sergej Samsonenko",
6
6
  "description": "Crawls and extracts data from the Mauve API.",
@@ -27,7 +27,8 @@
27
27
  "fmt": "bunx oxfmt",
28
28
  "clean": "bunx rimraf storage",
29
29
  "deps": "(bunx taze -r -w) && (bun i)",
30
- "postinstall": "bunx simple-git-hooks"
30
+ "prepublishOnly": "bun scripts/publish.ts pre",
31
+ "postpublish": "bun scripts/publish.ts post"
31
32
  },
32
33
  "dependencies": {
33
34
  "@crawlee/basic": "^3.16.0",
@@ -42,15 +43,14 @@
42
43
  },
43
44
  "simple-git-hooks": {
44
45
  "pre-commit": "bunx lint-staged",
45
- "commit-msg": "bunx @apounited/verify-commit-msg $1"
46
+ "commit-msg": "bunx @apounited/verify-commit-msg@latest $1"
46
47
  },
47
48
  "lint-staged": {
48
49
  "*.{js,ts}": [
49
50
  "bunx oxlint --fix"
50
51
  ],
51
52
  "*": [
52
- "bunx oxfmt --no-error-on-unmatched-pattern",
53
- "git add"
53
+ "bunx oxfmt --no-error-on-unmatched-pattern"
54
54
  ]
55
55
  }
56
56
  }