@leverstack/arcq 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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +361 -0
  3. package/dist/bin/arcq.d.ts +2 -0
  4. package/dist/bin/arcq.js +11 -0
  5. package/dist/bin/arcq.js.map +1 -0
  6. package/dist/index.d.ts +5 -0
  7. package/dist/index.js +85 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/lib/active-cmd.d.ts +1 -0
  10. package/dist/lib/active-cmd.js +16 -0
  11. package/dist/lib/active-cmd.js.map +1 -0
  12. package/dist/lib/arcgis-core.d.ts +5 -0
  13. package/dist/lib/arcgis-core.js +89 -0
  14. package/dist/lib/arcgis-core.js.map +1 -0
  15. package/dist/lib/cache-core.d.ts +4 -0
  16. package/dist/lib/cache-core.js +13 -0
  17. package/dist/lib/cache-core.js.map +1 -0
  18. package/dist/lib/config-core.d.ts +4 -0
  19. package/dist/lib/config-core.js +21 -0
  20. package/dist/lib/config-core.js.map +1 -0
  21. package/dist/lib/context-core.d.ts +3 -0
  22. package/dist/lib/context-core.js +13 -0
  23. package/dist/lib/context-core.js.map +1 -0
  24. package/dist/lib/errors.d.ts +5 -0
  25. package/dist/lib/errors.js +13 -0
  26. package/dist/lib/errors.js.map +1 -0
  27. package/dist/lib/fields-cmd.d.ts +1 -0
  28. package/dist/lib/fields-cmd.js +22 -0
  29. package/dist/lib/fields-cmd.js.map +1 -0
  30. package/dist/lib/help-cmd.d.ts +1 -0
  31. package/dist/lib/help-cmd.js +71 -0
  32. package/dist/lib/help-cmd.js.map +1 -0
  33. package/dist/lib/interactive-cmd.d.ts +1 -0
  34. package/dist/lib/interactive-cmd.js +90 -0
  35. package/dist/lib/interactive-cmd.js.map +1 -0
  36. package/dist/lib/layer-resolve.d.ts +6 -0
  37. package/dist/lib/layer-resolve.js +34 -0
  38. package/dist/lib/layer-resolve.js.map +1 -0
  39. package/dist/lib/layers-cmd.d.ts +1 -0
  40. package/dist/lib/layers-cmd.js +15 -0
  41. package/dist/lib/layers-cmd.js.map +1 -0
  42. package/dist/lib/list-cmd.d.ts +1 -0
  43. package/dist/lib/list-cmd.js +19 -0
  44. package/dist/lib/list-cmd.js.map +1 -0
  45. package/dist/lib/query-cmd.d.ts +1 -0
  46. package/dist/lib/query-cmd.js +130 -0
  47. package/dist/lib/query-cmd.js.map +1 -0
  48. package/dist/lib/refresh-cmd.d.ts +1 -0
  49. package/dist/lib/refresh-cmd.js +16 -0
  50. package/dist/lib/refresh-cmd.js.map +1 -0
  51. package/dist/lib/services-cmd.d.ts +1 -0
  52. package/dist/lib/services-cmd.js +20 -0
  53. package/dist/lib/services-cmd.js.map +1 -0
  54. package/dist/lib/sync-cmd.d.ts +1 -0
  55. package/dist/lib/sync-cmd.js +25 -0
  56. package/dist/lib/sync-cmd.js.map +1 -0
  57. package/dist/lib/tls-core.d.ts +4 -0
  58. package/dist/lib/tls-core.js +47 -0
  59. package/dist/lib/tls-core.js.map +1 -0
  60. package/dist/lib/token-cmd.d.ts +1 -0
  61. package/dist/lib/token-cmd.js +22 -0
  62. package/dist/lib/token-cmd.js.map +1 -0
  63. package/dist/lib/token-core.d.ts +3 -0
  64. package/dist/lib/token-core.js +18 -0
  65. package/dist/lib/token-core.js.map +1 -0
  66. package/dist/lib/types.d.ts +65 -0
  67. package/dist/lib/types.js +3 -0
  68. package/dist/lib/types.js.map +1 -0
  69. package/dist/lib/version-cmd.d.ts +2 -0
  70. package/dist/lib/version-cmd.js +22 -0
  71. package/dist/lib/version-cmd.js.map +1 -0
  72. package/package.json +65 -0
@@ -0,0 +1,47 @@
1
+ import https from 'https';
2
+ // Owns arcq's TLS decision. By default no custom agent is used, so axios
3
+ // performs full certificate verification. Insecure mode is opt-in and only
4
+ // ever scopes the relaxed agent to arcq's own requests - it never touches
5
+ // NODE_TLS_REJECT_UNAUTHORIZED (which would disable verification
6
+ // process-wide).
7
+ let insecureAgent;
8
+ export function setInsecureTls(enabled) {
9
+ insecureAgent = enabled
10
+ ? new https.Agent({ rejectUnauthorized: false })
11
+ : undefined;
12
+ }
13
+ // The agent arcgis-core should attach to a request, or undefined on the
14
+ // secure path (let axios use its verifying default).
15
+ export function getHttpsAgent() {
16
+ return insecureAgent;
17
+ }
18
+ // Node's TLS error codes for an untrusted/invalid server certificate.
19
+ const TLS_ERROR_CODES = new Set([
20
+ 'DEPTH_ZERO_SELF_SIGNED_CERT',
21
+ 'SELF_SIGNED_CERT_IN_CHAIN',
22
+ 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
23
+ 'UNABLE_TO_GET_ISSUER_CERT',
24
+ 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
25
+ 'CERT_UNTRUSTED',
26
+ 'CERT_NOT_YET_VALID',
27
+ 'CERT_HAS_EXPIRED',
28
+ 'ERR_TLS_CERT_ALTNAME_INVALID',
29
+ ]);
30
+ // If `error` is a TLS certificate failure, return a friendly message naming
31
+ // the host and the --insecure escape hatch; otherwise null (not a TLS error).
32
+ export function tlsErrorMessage(error, url) {
33
+ const code = error?.code;
34
+ if (!code || !TLS_ERROR_CODES.has(code))
35
+ return null;
36
+ let host = url;
37
+ try {
38
+ host = new URL(url).host;
39
+ }
40
+ catch {
41
+ // fall back to the raw url in the message
42
+ }
43
+ return (`TLS certificate verification failed for ${host}. If this is a ` +
44
+ `trusted server with a self-signed certificate, re-run with ` +
45
+ `--insecure or set "insecure": true in ~/.arcq.json.`);
46
+ }
47
+ //# sourceMappingURL=tls-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls-core.js","sourceRoot":"","sources":["../../lib/tls-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E;AAC1E,iEAAiE;AACjE,iBAAiB;AACjB,IAAI,aAAsC,CAAC;AAE3C,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,aAAa,GAAG,OAAO;QACrB,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;QAChD,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,wEAAwE;AACxE,qDAAqD;AACrD,MAAM,UAAU,aAAa;IAC3B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,sEAAsE;AACtE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,6BAA6B;IAC7B,2BAA2B;IAC3B,iCAAiC;IACjC,2BAA2B;IAC3B,mCAAmC;IACnC,gBAAgB;IAChB,oBAAoB;IACpB,kBAAkB;IAClB,8BAA8B;CAC/B,CAAC,CAAC;AAEH,4EAA4E;AAC5E,8EAA8E;AAC9E,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,GAAW;IACzD,MAAM,IAAI,GAAI,KAAkC,EAAE,IAAI,CAAC;IACvD,IAAI,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAErD,IAAI,IAAI,GAAG,GAAG,CAAC;IACf,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,0CAA0C;IAC5C,CAAC;IAED,OAAO,CACL,2CAA2C,IAAI,iBAAiB;QAChE,6DAA6D;QAC7D,qDAAqD,CACtD,CAAC;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export default function tokenCmd(args: string[]): void;
@@ -0,0 +1,22 @@
1
+ import { getToken, setTokenValue } from './token-core.js';
2
+ export default function tokenCmd(args) {
3
+ const sub = args[0];
4
+ if (sub === 'show') {
5
+ console.log(getToken() || 'No token set.');
6
+ return;
7
+ }
8
+ if (sub === 'set') {
9
+ const token = args[1];
10
+ if (!token) {
11
+ console.log('Usage: arcq token set <token>');
12
+ return;
13
+ }
14
+ setTokenValue(token);
15
+ console.log('Token saved.');
16
+ return;
17
+ }
18
+ console.log('Usage:');
19
+ console.log(' arcq token set <token>');
20
+ console.log(' arcq token show');
21
+ }
22
+ //# sourceMappingURL=token-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-cmd.js","sourceRoot":"","sources":["../../lib/token-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,IAAc;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,eAAe,CAAC,CAAC;QAC3C,OAAO;IACT,CAAC;IAED,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO;QACT,CAAC;QACD,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const tokenPath: string;
2
+ export declare function getToken(): string | null;
3
+ export declare function setTokenValue(token: string): void;
@@ -0,0 +1,18 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ export const tokenPath = path.join(os.homedir(), '.arcq-token');
5
+ export function getToken() {
6
+ if (fs.existsSync(tokenPath)) {
7
+ return fs.readFileSync(tokenPath, 'utf-8').trim();
8
+ }
9
+ return null;
10
+ }
11
+ export function setTokenValue(token) {
12
+ // The token is a secret: keep it readable only by the owner. writeFileSync's
13
+ // `mode` applies only when creating the file, so chmod afterwards to also
14
+ // tighten a pre-existing file written with looser permissions.
15
+ fs.writeFileSync(tokenPath, token.trim(), { mode: 0o600 });
16
+ fs.chmodSync(tokenPath, 0o600);
17
+ }
18
+ //# sourceMappingURL=token-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-core.js","sourceRoot":"","sources":["../../lib/token-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;AAEhE,MAAM,UAAU,QAAQ;IACtB,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,6EAA6E;IAC7E,0EAA0E;IAC1E,+DAA+D;IAC/D,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,65 @@
1
+ export interface Config {
2
+ services?: Record<string, string>;
3
+ layers?: Record<string, string>;
4
+ insecure?: boolean;
5
+ }
6
+ export interface Context {
7
+ service?: string;
8
+ layerId?: number;
9
+ name?: string;
10
+ url: string;
11
+ }
12
+ export interface CatalogLayer {
13
+ id: number;
14
+ name: string;
15
+ type: string;
16
+ url: string;
17
+ }
18
+ export type Cache = Record<string, CatalogLayer[]>;
19
+ export interface ArcGisError {
20
+ message: string;
21
+ code?: number;
22
+ }
23
+ export interface RawCatalogEntry {
24
+ id: number;
25
+ name: string;
26
+ type?: string;
27
+ }
28
+ export interface ServiceCatalogResponse {
29
+ layers?: RawCatalogEntry[];
30
+ tables?: RawCatalogEntry[];
31
+ error?: ArcGisError;
32
+ }
33
+ export interface ValidateResponse {
34
+ error?: ArcGisError;
35
+ }
36
+ export interface LayerField {
37
+ name: string;
38
+ type: string;
39
+ alias?: string;
40
+ length?: number;
41
+ }
42
+ export interface LayerMetadataResponse {
43
+ fields?: LayerField[];
44
+ error?: ArcGisError;
45
+ }
46
+ export interface Feature {
47
+ attributes: Record<string, unknown>;
48
+ }
49
+ export interface QueryResponse {
50
+ features?: Feature[];
51
+ exceededTransferLimit?: boolean;
52
+ count?: number;
53
+ error?: ArcGisError;
54
+ }
55
+ export interface QueryParams {
56
+ where?: string;
57
+ outFields?: string;
58
+ f?: string;
59
+ token?: string | null;
60
+ resultOffset?: number;
61
+ resultRecordCount?: number;
62
+ orderByFields?: string;
63
+ returnCountOnly?: boolean;
64
+ [key: string]: unknown;
65
+ }
@@ -0,0 +1,3 @@
1
+ // Shared data shapes passed between arcq's modules.
2
+ export {};
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,oDAAoD"}
@@ -0,0 +1,2 @@
1
+ export declare function getVersion(): string;
2
+ export default function versionCmd(): void;
@@ -0,0 +1,22 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ // Source (lib/ -> root) and compiled (dist/lib -> root) sit at different
4
+ // depths, so probe both; the name check rejects an unrelated package.json
5
+ // that happens to sit at the other depth.
6
+ export function getVersion() {
7
+ for (const rel of ['../package.json', '../../package.json']) {
8
+ try {
9
+ const pkg = require(rel);
10
+ if (pkg.name === '@leverstack/arcq' && pkg.version)
11
+ return pkg.version;
12
+ }
13
+ catch {
14
+ // keep probing
15
+ }
16
+ }
17
+ return 'unknown';
18
+ }
19
+ export default function versionCmd() {
20
+ console.log(getVersion());
21
+ }
22
+ //# sourceMappingURL=version-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-cmd.js","sourceRoot":"","sources":["../../lib/version-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,yEAAyE;AACzE,0EAA0E;AAC1E,0CAA0C;AAC1C,MAAM,UAAU,UAAU;IACxB,KAAK,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,EAAE,CAAC;QAC5D,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAwC,CAAC;YAChE,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,IAAI,GAAG,CAAC,OAAO;gBAAE,OAAO,GAAG,CAAC,OAAO,CAAC;QACzE,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,UAAU;IAChC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;AAC5B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@leverstack/arcq",
3
+ "version": "1.0.0",
4
+ "description": "CLI for querying ArcGIS feature services",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc -p tsconfig.build.json",
12
+ "typecheck": "tsc -p tsconfig.json --noEmit",
13
+ "prepare": "tsc -p tsconfig.build.json",
14
+ "lint": "eslint .",
15
+ "format": "npx prettier . --write",
16
+ "test": "mocha",
17
+ "bump": "scripts/bump-version.sh",
18
+ "release:tag": "scripts/release-tag.sh"
19
+ },
20
+ "keywords": [
21
+ "arcgis",
22
+ "cli",
23
+ "gis",
24
+ "esri",
25
+ "feature-service",
26
+ "arcgis-rest-api",
27
+ "agent",
28
+ "ai-agent"
29
+ ],
30
+ "author": "Leverstack LLC (https://leverstack.io)",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/jameseaster/arcq.git"
35
+ },
36
+ "bugs": "https://github.com/jameseaster/arcq/issues",
37
+ "homepage": "https://github.com/jameseaster/arcq#readme",
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "bin": {
42
+ "arcq": "./dist/bin/arcq.js"
43
+ },
44
+ "type": "module",
45
+ "dependencies": {
46
+ "axios": "^1.16.0"
47
+ },
48
+ "devDependencies": {
49
+ "@eslint/js": "^10.0.1",
50
+ "@types/chai": "^5.2.3",
51
+ "@types/mocha": "^10.0.10",
52
+ "@types/node": "^22.10.0",
53
+ "chai": "^6.2.2",
54
+ "eslint": "^10.3.0",
55
+ "globals": "^17.6.0",
56
+ "mocha": "^11.7.5",
57
+ "prettier": "3.8.3",
58
+ "tsx": "^4.19.2",
59
+ "typescript": "^5.7.2",
60
+ "typescript-eslint": "^8.18.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }