@elaraai/east-node-io 0.0.1-beta.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/CLA.md +26 -0
- package/CONTRIBUTING.md +28 -0
- package/README.md +220 -0
- package/package.json +112 -0
package/CLA.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Contributor License Agreement
|
|
2
|
+
|
|
3
|
+
This Contributor License Agreement ("Agreement") is entered into between Elara AI Pty Ltd ("Company") and you (the "Contributor").
|
|
4
|
+
|
|
5
|
+
## Grant of Copyright License
|
|
6
|
+
|
|
7
|
+
You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, distribute, and use Your Contributions and such derivative works.
|
|
8
|
+
|
|
9
|
+
## Grant of Patent License
|
|
10
|
+
|
|
11
|
+
You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer Your Contributions.
|
|
12
|
+
|
|
13
|
+
## Relicensing Rights
|
|
14
|
+
|
|
15
|
+
You grant the Company the right to license Your Contributions under any license terms, including but not limited to commercial licenses, in addition to the open source license under which the project is distributed.
|
|
16
|
+
|
|
17
|
+
## Your Representations
|
|
18
|
+
|
|
19
|
+
You represent that:
|
|
20
|
+
- You are legally entitled to grant the above licenses
|
|
21
|
+
- Each of Your Contributions is Your original creation
|
|
22
|
+
- Your Contribution submissions include complete details of any third-party license or other restriction of which you are aware
|
|
23
|
+
|
|
24
|
+
## Agreement
|
|
25
|
+
|
|
26
|
+
By signing this Agreement through CLA Assistant or by submitting a Contribution, you accept and agree to the terms of this Agreement.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Contributing to East
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! We welcome contributions from the community.
|
|
4
|
+
|
|
5
|
+
## Contributor License Agreement (CLA)
|
|
6
|
+
|
|
7
|
+
Before we can accept your contribution, you must sign our Contributor License Agreement (CLA). This agreement gives Elara AI Pty Ltd the right to use and relicense your contributions, including under commercial licenses, while you retain ownership of your contribution.
|
|
8
|
+
|
|
9
|
+
**Why do we require a CLA?**
|
|
10
|
+
This project is dual-licensed under AGPL-3.0 and commercial licenses. The CLA allows us to offer commercial licenses to users who wish to use this software in proprietary applications.
|
|
11
|
+
|
|
12
|
+
### Signing the CLA
|
|
13
|
+
|
|
14
|
+
When you submit your first pull request, the CLA Assistant bot will automatically comment on your PR with a link to sign the CLA electronically. It only takes a minute, and you'll only need to sign it once.
|
|
15
|
+
|
|
16
|
+
## Contributing Process
|
|
17
|
+
|
|
18
|
+
1. Fork the repository
|
|
19
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
20
|
+
3. Make your changes
|
|
21
|
+
4. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
22
|
+
5. Push to the branch (`git push origin feature/amazing-feature`)
|
|
23
|
+
6. Open a Pull Request
|
|
24
|
+
7. Sign the CLA when the bot prompts you
|
|
25
|
+
|
|
26
|
+
## Questions?
|
|
27
|
+
|
|
28
|
+
Contact us at support@elara.ai
|
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# East Node IO
|
|
2
|
+
|
|
3
|
+
> I/O platform functions for the East language on Node.js
|
|
4
|
+
|
|
5
|
+
[](LICENSE.md)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
|
|
8
|
+
East Node IO provides type-safe I/O platform functions for [East](https://github.com/elaraai/east) programs running on Node.js, enabling database operations, cloud storage, file transfer, NoSQL operations, file format processing, and compression.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **SQL Databases**: SQLite, PostgreSQL, MySQL with connection pooling
|
|
13
|
+
- **Cloud Storage**: S3 and S3-compatible object storage (MinIO, etc.)
|
|
14
|
+
- **File Transfer**: FTP and SFTP for legacy system integration
|
|
15
|
+
- **NoSQL**: Redis caching and MongoDB document storage
|
|
16
|
+
- **File Formats**: XLSX (Excel), CSV, and XML parsing and serialization
|
|
17
|
+
- **Compression**: Gzip, Zip, and Tar compression and decompression
|
|
18
|
+
- **Type Safety**: Full East type system integration
|
|
19
|
+
- **Async I/O**: All operations use `implementAsync` for non-blocking I/O
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @elaraai/east-node-io
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### SQL Database Query
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { East, StringType, IntegerType, NullType } from "@elaraai/east";
|
|
33
|
+
import { SQL } from "@elaraai/east-node-io";
|
|
34
|
+
|
|
35
|
+
const getUserById = East.function([IntegerType], NullType, ($, userId) => {
|
|
36
|
+
const config = $.let({
|
|
37
|
+
host: "localhost",
|
|
38
|
+
port: 5432n,
|
|
39
|
+
database: "myapp",
|
|
40
|
+
user: "postgres",
|
|
41
|
+
password: "secret",
|
|
42
|
+
ssl: East.variant('none', null),
|
|
43
|
+
maxConnections: East.variant('none', null),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const conn = $.let(SQL.Postgres.connect(config));
|
|
47
|
+
$(SQL.Postgres.query(
|
|
48
|
+
conn,
|
|
49
|
+
"SELECT name FROM users WHERE id = $1",
|
|
50
|
+
[East.variant("Integer", userId)]
|
|
51
|
+
));
|
|
52
|
+
$(SQL.Postgres.close(conn));
|
|
53
|
+
|
|
54
|
+
return $.return(null);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const compiled = East.compileAsync(getUserById.toIR(), SQL.Postgres.Implementation);
|
|
58
|
+
await compiled(42n);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### S3 File Upload/Download
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { Storage } from "@elaraai/east-node-io";
|
|
65
|
+
import { East, StringType, BlobType } from "@elaraai/east";
|
|
66
|
+
|
|
67
|
+
const uploadFile = East.function([StringType, BlobType], StringType, ($, filename, data) => {
|
|
68
|
+
const config = $.let({
|
|
69
|
+
region: "us-east-1",
|
|
70
|
+
bucket: "my-bucket",
|
|
71
|
+
accessKeyId: East.variant('none', null),
|
|
72
|
+
secretAccessKey: East.variant('none', null),
|
|
73
|
+
endpoint: East.variant('none', null),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
$(Storage.S3.putObject(config, filename, data));
|
|
77
|
+
return Storage.S3.presignUrl(config, filename, 3600n);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const compiled = East.compileAsync(uploadFile.toIR(), Storage.S3.Implementation);
|
|
81
|
+
const url = await compiled("report.pdf", pdfBlob);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Redis Caching
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { East, StringType, OptionType } from "@elaraai/east";
|
|
88
|
+
import { NoSQL } from "@elaraai/east-node-io";
|
|
89
|
+
|
|
90
|
+
const cacheGet = East.function([StringType], OptionType(StringType), ($, key) => {
|
|
91
|
+
const config = $.let({
|
|
92
|
+
host: "localhost",
|
|
93
|
+
port: 6379n,
|
|
94
|
+
password: East.variant('none', null),
|
|
95
|
+
db: East.variant('none', null),
|
|
96
|
+
keyPrefix: East.variant('none', null),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const conn = $.let(NoSQL.Redis.connect(config));
|
|
100
|
+
const value = $.let(NoSQL.Redis.get(conn, key));
|
|
101
|
+
$(NoSQL.Redis.close(conn));
|
|
102
|
+
|
|
103
|
+
return $.return(value);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const compiled = East.compileAsync(cacheGet.toIR(), NoSQL.Redis.Implementation);
|
|
107
|
+
const cached = await compiled("user:42"); // some("...") or none
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### File Format Processing
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { Format } from "@elaraai/east-node-io";
|
|
114
|
+
import { East, BlobType, IntegerType } from "@elaraai/east";
|
|
115
|
+
|
|
116
|
+
// Read Excel files
|
|
117
|
+
const countRows = East.function([BlobType], IntegerType, ($, xlsxBlob) => {
|
|
118
|
+
const options = $.let({
|
|
119
|
+
sheetName: East.variant('none', null),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const sheet = $.let(Format.XLSX.read(xlsxBlob, options));
|
|
123
|
+
return $.return(sheet.size());
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const compiled = East.compile(countRows.toIR(), Format.XLSX.Implementation);
|
|
127
|
+
const rowCount = compiled(xlsxBlob); // 100n
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Platform Functions
|
|
131
|
+
|
|
132
|
+
### SQL
|
|
133
|
+
|
|
134
|
+
- **SQLite**: `connect`, `query`, `close`
|
|
135
|
+
- **PostgreSQL**: `connect`, `query`, `close`
|
|
136
|
+
- **MySQL**: `connect`, `query`, `close`
|
|
137
|
+
|
|
138
|
+
### Storage
|
|
139
|
+
|
|
140
|
+
- **S3**: `putObject`, `getObject`, `deleteObject`, `listObjects`, `presignUrl`
|
|
141
|
+
|
|
142
|
+
### Transfer
|
|
143
|
+
|
|
144
|
+
- **FTP**: `connect`, `put`, `get`, `list`, `delete`, `close`
|
|
145
|
+
- **SFTP**: `connect`, `put`, `get`, `list`, `delete`, `close`
|
|
146
|
+
|
|
147
|
+
### NoSQL
|
|
148
|
+
|
|
149
|
+
- **Redis**: `connect`, `get`, `set`, `setex`, `del`, `close`
|
|
150
|
+
- **MongoDB**: `connect`, `insertOne`, `findOne`, `find`, `updateOne`, `deleteOne`, `close`
|
|
151
|
+
|
|
152
|
+
### Format
|
|
153
|
+
|
|
154
|
+
- **XLSX**: `read`, `write`, `info` - Excel spreadsheet processing
|
|
155
|
+
- **CSV**: `parse`, `serialize` - Comma-separated values with header support
|
|
156
|
+
- **XML**: `parse`, `serialize` - XML document tree processing
|
|
157
|
+
|
|
158
|
+
### Compression
|
|
159
|
+
|
|
160
|
+
- **Gzip**: `compress`, `decompress` - Gzip compression (RFC 1952)
|
|
161
|
+
- **Zip**: `compress`, `decompress` - ZIP archive creation and extraction
|
|
162
|
+
- **Tar**: `create`, `extract` - TAR archive creation and extraction
|
|
163
|
+
|
|
164
|
+
## Development
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Install dependencies
|
|
168
|
+
npm install
|
|
169
|
+
|
|
170
|
+
# Build TypeScript
|
|
171
|
+
npm run build
|
|
172
|
+
|
|
173
|
+
# Run tests (requires Docker)
|
|
174
|
+
npm run test:integration
|
|
175
|
+
|
|
176
|
+
# Start Docker services for development
|
|
177
|
+
npm run dev:services
|
|
178
|
+
|
|
179
|
+
# Stop Docker services
|
|
180
|
+
npm run dev:services:down
|
|
181
|
+
|
|
182
|
+
# Lint code
|
|
183
|
+
npm run lint
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Testing
|
|
187
|
+
|
|
188
|
+
Integration tests require Docker for running real databases and services:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Start all services (PostgreSQL, MySQL, MongoDB, Redis, MinIO, FTP, SFTP)
|
|
192
|
+
npm run dev:services
|
|
193
|
+
|
|
194
|
+
# Run full integration test suite
|
|
195
|
+
npm run test:integration
|
|
196
|
+
|
|
197
|
+
# Stop all services
|
|
198
|
+
npm run dev:services:down
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Documentation
|
|
202
|
+
|
|
203
|
+
- [Usage Guide](USAGE.md)
|
|
204
|
+
- [Development Standards](STANDARDS.md)
|
|
205
|
+
- [Contributing Guidelines](CONTRIBUTING.md)
|
|
206
|
+
- [License](LICENSE.md)
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
Copyright (c) 2025 Elara AI Pty Ltd
|
|
211
|
+
|
|
212
|
+
This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details.
|
|
213
|
+
|
|
214
|
+
## Dependencies
|
|
215
|
+
|
|
216
|
+
- **SQL**: `better-sqlite3`, `pg`, `mysql2`
|
|
217
|
+
- **Storage**: `@aws-sdk/client-s3`, `@aws-sdk/s3-request-presigner`
|
|
218
|
+
- **Transfer**: `basic-ftp`, `ssh2-sftp-client`
|
|
219
|
+
- **NoSQL**: `ioredis`, `mongodb`
|
|
220
|
+
- **Format**: `xlsx` for Excel file processing
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elaraai/east-node-io",
|
|
3
|
+
"version": "0.0.1-beta.0",
|
|
4
|
+
"description": "I/O platform functions for the East language on Node.js",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/src",
|
|
15
|
+
"!dist/src/**/*.spec.*",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE.md",
|
|
18
|
+
"CONTRIBUTING.md",
|
|
19
|
+
"CLA.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"package": "npm run build && mkdir -p .package && npm pack --pack-destination .package",
|
|
24
|
+
"prepublishOnly": "npm run lint && npm run test",
|
|
25
|
+
"test": "npm run build && node --enable-source-maps --test 'dist/**/*.spec.js'",
|
|
26
|
+
"test:coverage": "npm run build && node --enable-source-maps --test --experimental-test-coverage 'dist/**/*.spec.js'",
|
|
27
|
+
"test:integration": "npm run test:docker:up && npm test && npm run test:docker:down",
|
|
28
|
+
"test:docker:up": "docker-compose up -d && npm run test:wait",
|
|
29
|
+
"test:docker:down": "docker-compose down -v",
|
|
30
|
+
"test:wait": "tsx scripts/wait-for-services.ts",
|
|
31
|
+
"dev:services": "docker-compose up -d",
|
|
32
|
+
"dev:services:down": "docker-compose down -v",
|
|
33
|
+
"extract-examples": "tsx scripts/extract-typedoc-examples.ts",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"lint:fix": "eslint . --fix",
|
|
36
|
+
"version:patch": "npm version patch -m 'chore: bump version to %s'",
|
|
37
|
+
"version:minor": "npm version minor -m 'chore: bump version to %s'",
|
|
38
|
+
"version:major": "npm version major -m 'chore: bump version to %s'",
|
|
39
|
+
"version:prepatch": "npm version prepatch --preid=beta -m 'chore: bump version to %s'",
|
|
40
|
+
"version:preminor": "npm version preminor --preid=beta -m 'chore: bump version to %s'",
|
|
41
|
+
"version:premajor": "npm version premajor --preid=beta -m 'chore: bump version to %s'",
|
|
42
|
+
"version:prerelease": "npm version prerelease --preid=beta -m 'chore: bump version to %s'",
|
|
43
|
+
"version:patch:dry": "npm version patch --no-git-tag-version",
|
|
44
|
+
"version:minor:dry": "npm version minor --no-git-tag-version",
|
|
45
|
+
"version:major:dry": "npm version major --no-git-tag-version",
|
|
46
|
+
"version:prepatch:dry": "npm version prepatch --preid=beta --no-git-tag-version",
|
|
47
|
+
"version:preminor:dry": "npm version preminor --preid=beta --no-git-tag-version",
|
|
48
|
+
"version:premajor:dry": "npm version premajor --preid=beta --no-git-tag-version",
|
|
49
|
+
"version:prerelease:dry": "npm version prerelease --preid=beta --no-git-tag-version",
|
|
50
|
+
"release:patch": "npm run version:patch && git push && git push --tags",
|
|
51
|
+
"release:minor": "npm run version:minor && git push && git push --tags",
|
|
52
|
+
"release:major": "npm run version:major && git push && git push --tags",
|
|
53
|
+
"release:prepatch": "npm run version:prepatch && git push && git push --tags",
|
|
54
|
+
"release:preminor": "npm run version:preminor && git push && git push --tags",
|
|
55
|
+
"release:premajor": "npm run version:premajor && git push && git push --tags",
|
|
56
|
+
"release:prerelease": "npm run version:prerelease && git push && git push --tags"
|
|
57
|
+
},
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "https://github.com/elaraai/east-node.git",
|
|
61
|
+
"directory": "packages/east-node-io"
|
|
62
|
+
},
|
|
63
|
+
"keywords": [
|
|
64
|
+
"east",
|
|
65
|
+
"elara",
|
|
66
|
+
"node",
|
|
67
|
+
"io",
|
|
68
|
+
"database",
|
|
69
|
+
"sql",
|
|
70
|
+
"nosql",
|
|
71
|
+
"s3",
|
|
72
|
+
"ftp",
|
|
73
|
+
"sftp",
|
|
74
|
+
"platform"
|
|
75
|
+
],
|
|
76
|
+
"author": "Elara AI Pty Ltd",
|
|
77
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
78
|
+
"type": "module",
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=22.0.0"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@elaraai/east-node-std": "*",
|
|
84
|
+
"@types/adm-zip": "^0.5.7",
|
|
85
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
86
|
+
"@types/node": "^22.18.1",
|
|
87
|
+
"@types/pg": "^8.11.10",
|
|
88
|
+
"@types/ssh2-sftp-client": "^9.0.5",
|
|
89
|
+
"@types/tar-stream": "^3.1.4",
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
91
|
+
"@typescript-eslint/parser": "^8.42.0",
|
|
92
|
+
"eslint": "^9.34.0",
|
|
93
|
+
"eslint-plugin-headers": "^1.3.3",
|
|
94
|
+
"tsx": "^4.19.2",
|
|
95
|
+
"typescript": "~5.9.2"
|
|
96
|
+
},
|
|
97
|
+
"dependencies": {
|
|
98
|
+
"@aws-sdk/client-s3": "^3.713.0",
|
|
99
|
+
"@aws-sdk/s3-request-presigner": "^3.713.0",
|
|
100
|
+
"@elaraai/east": "^0.0.1-beta.0",
|
|
101
|
+
"adm-zip": "^0.5.16",
|
|
102
|
+
"basic-ftp": "^5.0.5",
|
|
103
|
+
"better-sqlite3": "^11.0.0",
|
|
104
|
+
"ioredis": "^5.4.2",
|
|
105
|
+
"mongodb": "^6.11.0",
|
|
106
|
+
"mysql2": "^3.11.5",
|
|
107
|
+
"pg": "^8.13.1",
|
|
108
|
+
"ssh2-sftp-client": "^11.0.0",
|
|
109
|
+
"tar-stream": "^3.1.7",
|
|
110
|
+
"xlsx": "^0.18.5"
|
|
111
|
+
}
|
|
112
|
+
}
|