marcattacks 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/Dockerfile +23 -0
- package/LICENSE +21 -0
- package/README-docker.md +39 -0
- package/README.md +111 -0
- package/TYPESCRIPT.txt +6 -0
- package/data/output.rdf +12425 -0
- package/data/sample.xml +2 -0
- package/demo/demo.jsonata +44 -0
- package/dist/index.js +150 -0
- package/docker-compose.yaml +37 -0
- package/logo.jpg +0 -0
- package/package.json +46 -0
- package/plugin/demo.js +12 -0
- package/src/httpstream.ts +28 -0
- package/src/index.ts +177 -0
- package/src/input/alephseq.ts +83 -0
- package/src/input/json.ts +47 -0
- package/src/input/jsonl.ts +47 -0
- package/src/input/xml.ts +125 -0
- package/src/marcmap.ts +94 -0
- package/src/output/alephseq.ts +48 -0
- package/src/output/json.ts +38 -0
- package/src/output/jsonl.ts +23 -0
- package/src/output/rdf.ts +63 -0
- package/src/output/xml.ts +84 -0
- package/src/plugin-loader.ts +27 -0
- package/src/s3stream.ts +266 -0
- package/src/sftpstream.ts +114 -0
- package/src/slow-writable.ts +165 -0
- package/src/transform/json.ts +36 -0
- package/src/transform/rdf.ts +398 -0
- package/tsconfig.json +46 -0
package/Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
FROM node:20
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
COPY package*.json ./
|
|
6
|
+
|
|
7
|
+
RUN npm install
|
|
8
|
+
|
|
9
|
+
FROM node:20-alpine3.20
|
|
10
|
+
|
|
11
|
+
ENV NODE_ENV=production
|
|
12
|
+
|
|
13
|
+
WORKDIR /app
|
|
14
|
+
|
|
15
|
+
COPY package*.json ./
|
|
16
|
+
|
|
17
|
+
COPY --from=0 /app/node_modules /app/node_modules
|
|
18
|
+
|
|
19
|
+
COPY . .
|
|
20
|
+
|
|
21
|
+
ENTRYPOINT [ "node","dist/index.js" ]
|
|
22
|
+
|
|
23
|
+
CMD [ "--help"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Patrick Hochstenbach
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README-docker.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Docker
|
|
2
|
+
|
|
3
|
+
## Build marcattacks
|
|
4
|
+
|
|
5
|
+
Build a version of a docker image:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
docker build . -t hochstenbach/marcattacks:v0.0.1
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Run a docker image:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
docker run --rm -v `pwd`/data:/app/data -it hochstenbach/marcattacks:v0.0.1 --rdf data/sample.xml
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Push it to DockerHub:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
docker push hochstenbach/marcattacks:v0.0.1
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### S3 development
|
|
24
|
+
|
|
25
|
+
Start S3 service:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
docker compose up -d
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Stop everything:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
docker compose down
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Connect to the admin interface: http://localhost:3372/login
|
|
38
|
+
|
|
39
|
+
Username/password: minioadmin/minioadmin
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# marcattacks!
|
|
2
|
+
|
|
3
|
+
<img src="logo.jpg" width="10%">
|
|
4
|
+
|
|
5
|
+
Turn your MARC exports into something else.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Build
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
npm run build:ts
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm link
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Run
|
|
23
|
+
|
|
24
|
+
Generate JSON:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
marcattacks --to json <file>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Generate Aleph sequential:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
marcattacks --to alephseq <file>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Generate RDF:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
marcattacks --to rdf --map rdf <file>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Generate XML:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
marcattacks --to xml <file>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Transform the MARC input using a [JSONata](https://docs.jsonata.org/overview.html) expression or file:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
marcattacks <file> --fix ./demo/demo.jsonata
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Remote files
|
|
55
|
+
|
|
56
|
+
A remote SFTP path:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
marcattacks --key ~/.ssh/privatekey sftp://username@hostname:port/remote/path
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The latest XML file in a remote SFTP:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
marcattacks --key ~/.ssh/privatekey sftp://username@hostname:port/remote/path/@latest:xml
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
An HTTP path
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
marcattacks http://somewhere.org/data.xml
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
An S3 path
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
marcattacks s3://accessKey:secretKey@host:port/bucket/key
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
use `s3s://...` for using a SSL layer.
|
|
81
|
+
|
|
82
|
+
## Formats
|
|
83
|
+
|
|
84
|
+
### Input (--from)
|
|
85
|
+
|
|
86
|
+
- xml
|
|
87
|
+
- alephseq (Aleph sequential)
|
|
88
|
+
- json
|
|
89
|
+
- jsonl
|
|
90
|
+
|
|
91
|
+
### Output (--to)
|
|
92
|
+
|
|
93
|
+
- xml
|
|
94
|
+
- alephseq (Aleph sequential)
|
|
95
|
+
- json
|
|
96
|
+
- jsonl
|
|
97
|
+
- rdf
|
|
98
|
+
|
|
99
|
+
### Transform (--map)
|
|
100
|
+
|
|
101
|
+
- rdf
|
|
102
|
+
|
|
103
|
+
Provide your own transformers using JavaScript plugins. See: ./plugin/demo.js for an example.
|
|
104
|
+
|
|
105
|
+
### Writable (--out)
|
|
106
|
+
|
|
107
|
+
- _default_: stdout
|
|
108
|
+
- _file path_
|
|
109
|
+
- sftp://username@host:port/path
|
|
110
|
+
- s3://accessKey:secretKey@host:port/bucket/key (or s3s://)
|
|
111
|
+
|