public-com-cli 0.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/LICENSE.md +21 -0
- package/README.md +273 -0
- package/dist/api/accounts.d.ts +12 -0
- package/dist/api/accounts.js +5 -0
- package/dist/api/accounts.js.map +1 -0
- package/dist/api/history.d.ts +31 -0
- package/dist/api/history.js +29 -0
- package/dist/api/history.js.map +1 -0
- package/dist/api/index.d.ts +9 -0
- package/dist/api/index.js +9 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/instruments.d.ts +22 -0
- package/dist/api/instruments.js +46 -0
- package/dist/api/instruments.js.map +1 -0
- package/dist/api/market-data.d.ts +48 -0
- package/dist/api/market-data.js +20 -0
- package/dist/api/market-data.js.map +1 -0
- package/dist/api/option-details.d.ts +17 -0
- package/dist/api/option-details.js +9 -0
- package/dist/api/option-details.js.map +1 -0
- package/dist/api/orders.d.ts +125 -0
- package/dist/api/orders.js +43 -0
- package/dist/api/orders.js.map +1 -0
- package/dist/api/portfolio.d.ts +81 -0
- package/dist/api/portfolio.js +19 -0
- package/dist/api/portfolio.js.map +1 -0
- package/dist/api/types.d.ts +12 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/authentication/keychain.d.ts +5 -0
- package/dist/authentication/keychain.js +17 -0
- package/dist/authentication/keychain.js.map +1 -0
- package/dist/authentication/token.d.ts +9 -0
- package/dist/authentication/token.js +35 -0
- package/dist/authentication/token.js.map +1 -0
- package/dist/commands/accounts.d.ts +3 -0
- package/dist/commands/accounts.js +42 -0
- package/dist/commands/accounts.js.map +1 -0
- package/dist/commands/authenticate.d.ts +3 -0
- package/dist/commands/authenticate.js +103 -0
- package/dist/commands/authenticate.js.map +1 -0
- package/dist/commands/completion.d.ts +3 -0
- package/dist/commands/completion.js +234 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.js +67 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/history.d.ts +3 -0
- package/dist/commands/history.js +91 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/instrument.d.ts +3 -0
- package/dist/commands/instrument.js +85 -0
- package/dist/commands/instrument.js.map +1 -0
- package/dist/commands/instruments.d.ts +3 -0
- package/dist/commands/instruments.js +118 -0
- package/dist/commands/instruments.js.map +1 -0
- package/dist/commands/option-greeks.d.ts +3 -0
- package/dist/commands/option-greeks.js +66 -0
- package/dist/commands/option-greeks.js.map +1 -0
- package/dist/commands/options-chain.d.ts +3 -0
- package/dist/commands/options-chain.js +110 -0
- package/dist/commands/options-chain.js.map +1 -0
- package/dist/commands/options-expirations.d.ts +3 -0
- package/dist/commands/options-expirations.js +54 -0
- package/dist/commands/options-expirations.js.map +1 -0
- package/dist/commands/order-cancel.d.ts +3 -0
- package/dist/commands/order-cancel.js +37 -0
- package/dist/commands/order-cancel.js.map +1 -0
- package/dist/commands/order-place.d.ts +3 -0
- package/dist/commands/order-place.js +104 -0
- package/dist/commands/order-place.js.map +1 -0
- package/dist/commands/order-preflight.d.ts +3 -0
- package/dist/commands/order-preflight.js +138 -0
- package/dist/commands/order-preflight.js.map +1 -0
- package/dist/commands/order.d.ts +3 -0
- package/dist/commands/order.js +108 -0
- package/dist/commands/order.js.map +1 -0
- package/dist/commands/portfolio.d.ts +3 -0
- package/dist/commands/portfolio.js +107 -0
- package/dist/commands/portfolio.js.map +1 -0
- package/dist/commands/quotes.d.ts +3 -0
- package/dist/commands/quotes.js +86 -0
- package/dist/commands/quotes.js.map +1 -0
- package/dist/helpers/api.d.ts +3 -0
- package/dist/helpers/api.js +5 -0
- package/dist/helpers/api.js.map +1 -0
- package/dist/helpers/config.d.ts +5 -0
- package/dist/helpers/config.js +40 -0
- package/dist/helpers/config.js.map +1 -0
- package/dist/helpers/fetch.d.ts +24 -0
- package/dist/helpers/fetch.js +202 -0
- package/dist/helpers/fetch.js.map +1 -0
- package/dist/helpers/output.d.ts +5 -0
- package/dist/helpers/output.js +13 -0
- package/dist/helpers/output.js.map +1 -0
- package/dist/helpers/validation.d.ts +2 -0
- package/dist/helpers/validation.js +14 -0
- package/dist/helpers/validation.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function success(message) {
|
|
2
|
+
console.log(`✓ ${message}`);
|
|
3
|
+
}
|
|
4
|
+
export function error(message) {
|
|
5
|
+
console.error(`✗ ${message}`);
|
|
6
|
+
}
|
|
7
|
+
export function info(message) {
|
|
8
|
+
console.log(`ℹ ${message}`);
|
|
9
|
+
}
|
|
10
|
+
export function warn(message) {
|
|
11
|
+
console.warn(`⚠ ${message}`);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/helpers/output.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function isValidApiKey(apiKey) {
|
|
2
|
+
if (!apiKey || typeof apiKey !== 'string') {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const trimmed = apiKey.trim();
|
|
6
|
+
if (trimmed.length === 0) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (trimmed.length < 16) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/helpers/validation.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAE9B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { createAuthenticateCommand } from './commands/authenticate.js';
|
|
4
|
+
import { createConfigCommand } from './commands/config.js';
|
|
5
|
+
import { createAccountsCommand } from './commands/accounts.js';
|
|
6
|
+
import { createPortfolioCommand } from './commands/portfolio.js';
|
|
7
|
+
import { createHistoryCommand } from './commands/history.js';
|
|
8
|
+
import { createInstrumentsCommand } from './commands/instruments.js';
|
|
9
|
+
import { createInstrumentCommand } from './commands/instrument.js';
|
|
10
|
+
import { createQuotesCommand } from './commands/quotes.js';
|
|
11
|
+
import { createOptionsExpirationsCommand } from './commands/options-expirations.js';
|
|
12
|
+
import { createOptionsChainCommand } from './commands/options-chain.js';
|
|
13
|
+
import { createOrderPreflightCommand } from './commands/order-preflight.js';
|
|
14
|
+
import { createOrderPlaceCommand } from './commands/order-place.js';
|
|
15
|
+
import { createOrderCommand } from './commands/order.js';
|
|
16
|
+
import { createOrderCancelCommand } from './commands/order-cancel.js';
|
|
17
|
+
import { createOptionGreeksCommand } from './commands/option-greeks.js';
|
|
18
|
+
import { createCompletionCommand } from './commands/completion.js';
|
|
19
|
+
import { setRetryEnabled } from './helpers/fetch.js';
|
|
20
|
+
const program = new Command();
|
|
21
|
+
program
|
|
22
|
+
.name('public-cli')
|
|
23
|
+
.description('CLI for interacting with Public.com API')
|
|
24
|
+
.version('0.1.0')
|
|
25
|
+
.option('--no-retry', 'Disable automatic retries on server errors')
|
|
26
|
+
.hook('preAction', () => {
|
|
27
|
+
const opts = program.opts();
|
|
28
|
+
if (opts.retry === false) {
|
|
29
|
+
setRetryEnabled(false);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
program.addCommand(createAuthenticateCommand());
|
|
33
|
+
program.addCommand(createConfigCommand());
|
|
34
|
+
program.addCommand(createAccountsCommand());
|
|
35
|
+
program.addCommand(createPortfolioCommand());
|
|
36
|
+
program.addCommand(createHistoryCommand());
|
|
37
|
+
program.addCommand(createInstrumentsCommand());
|
|
38
|
+
program.addCommand(createInstrumentCommand());
|
|
39
|
+
program.addCommand(createQuotesCommand());
|
|
40
|
+
program.addCommand(createOptionsExpirationsCommand());
|
|
41
|
+
program.addCommand(createOptionsChainCommand());
|
|
42
|
+
program.addCommand(createOrderPreflightCommand());
|
|
43
|
+
program.addCommand(createOrderPlaceCommand());
|
|
44
|
+
program.addCommand(createOrderCommand());
|
|
45
|
+
program.addCommand(createOrderCancelCommand());
|
|
46
|
+
program.addCommand(createOptionGreeksCommand());
|
|
47
|
+
program.addCommand(createCompletionCommand());
|
|
48
|
+
program.parse(process.argv);
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","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|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for Public.com API - trading, portfolio management, market data, and more",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"public-cli": "dist/index.js",
|
|
8
|
+
"public-com-cli": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**/*.js",
|
|
13
|
+
"dist/**/*.d.ts",
|
|
14
|
+
"dist/**/*.js.map",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"build:bundle": "npm run build && esbuild dist/index.js --bundle --platform=node --target=node18 --outfile=dist/bundle.cjs --format=cjs --external:keytar",
|
|
21
|
+
"build:binary": "npm run build:bundle && pkg dist/bundle.cjs --targets node18-macos-arm64,node18-macos-x64,node18-linux-x64,node18-win-x64 --out-path dist/bin --compress GZip",
|
|
22
|
+
"build:binary:current": "npm run build:bundle && pkg dist/bundle.cjs --targets host --output dist/public-com-cli --compress GZip",
|
|
23
|
+
"start": "node dist/index.js",
|
|
24
|
+
"dev": "tsx src/index.ts",
|
|
25
|
+
"format": "prettier --write .",
|
|
26
|
+
"format:check": "prettier --check .",
|
|
27
|
+
"lint": "eslint src/",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"prepublishOnly": "npm run build",
|
|
30
|
+
"prepare": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"pkg": {
|
|
33
|
+
"assets": [
|
|
34
|
+
"node_modules/keytar/**/*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": [
|
|
37
|
+
"dist/**/*.js"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/inlineblock/public-com-cli.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/inlineblock/public-com-cli/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/inlineblock/public-com-cli#readme",
|
|
48
|
+
"keywords": [
|
|
49
|
+
"public.com",
|
|
50
|
+
"public",
|
|
51
|
+
"cli",
|
|
52
|
+
"trading",
|
|
53
|
+
"stocks",
|
|
54
|
+
"options",
|
|
55
|
+
"crypto",
|
|
56
|
+
"portfolio",
|
|
57
|
+
"brokerage",
|
|
58
|
+
"api",
|
|
59
|
+
"finance"
|
|
60
|
+
],
|
|
61
|
+
"author": "",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"commander": "^12.1.0",
|
|
65
|
+
"keytar": "^7.9.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/node": "^22.10.0",
|
|
69
|
+
"@yao-pkg/pkg": "^5.15.0",
|
|
70
|
+
"esbuild": "^0.24.0",
|
|
71
|
+
"prettier": "^3.4.0",
|
|
72
|
+
"tsx": "^4.19.0",
|
|
73
|
+
"typescript": "^5.7.0"
|
|
74
|
+
},
|
|
75
|
+
"engines": {
|
|
76
|
+
"node": ">=18.0.0"
|
|
77
|
+
}
|
|
78
|
+
}
|