CLI (packages/inkreach-cli):
- new src/lib/field-normalize.ts: type aliases (sel/num/text/mul/…),
select string-choices -> {name}, compact --fields 'Name:type:choices'
expansion, smart type inference from --options shape / --name
(--type now optional), name->ID resolution for foreignTableName /
linkFieldName / lookupFieldName (incl. link-field foreignTableId
backfill + unknown-key stripping), rating/number/button required-
option defaults
- field create: +--description/--lookup-options/--is-lookup
- field update --options + table create --fields route through the
normalizer; DEFAULT_ENDPOINT :3000 -> :3003
- 20 unit tests (field-normalize.spec.ts, vitest); live-verified:
string choices, alias, foreignTableName, lookup-by-names, compact
format, inference (priority->singleSelect, max:5->rating)
Skill docs (.agents/skills/inkreach-teable):
- ports :3000 -> :3003 everywhere (backend real port; :3000 is an
unrelated container on this host)
- remove dead hr_admin account; note throwaway signup + real admin
- plugin register: actual URL-based flags; document plugin csp
list/set; view/dashboard install requires config enable first
- field-types.md marked verified-2026-08 (aliases/inference/name
resolution now implemented + tested)
- development.md: webpack dist/index.js cache trap; PGPASSWORD
placeholder instead of wrong literal
74 lines
2.9 KiB
JavaScript
74 lines
2.9 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.configPath = exports.resolveConfig = exports.writeConfigFile = exports.readConfigFile = exports.DEFAULT_ENDPOINT = void 0;
|
|
/**
|
|
* Config storage for inkreach-teable CLI.
|
|
*
|
|
* Stores endpoint + token at ~/.inkreach-teable/config.json, with environment variable
|
|
* overrides INKREACH_TEABLE_ENDPOINT / INKREACH_TEABLE_TOKEN. The --endpoint / --token / --base-id
|
|
* global flags take the highest precedence (handled by resolveOptions()).
|
|
*/
|
|
const fs = __importStar(require("node:fs"));
|
|
const path = __importStar(require("node:path"));
|
|
const os = __importStar(require("node:os"));
|
|
const CONFIG_DIR = path.join(os.homedir(), '.inkreach-teable');
|
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
exports.DEFAULT_ENDPOINT = 'http://localhost:3003';
|
|
function readConfigFile() {
|
|
try {
|
|
const raw = fs.readFileSync(CONFIG_FILE, 'utf8');
|
|
return JSON.parse(raw);
|
|
}
|
|
catch {
|
|
return {};
|
|
}
|
|
}
|
|
exports.readConfigFile = readConfigFile;
|
|
function writeConfigFile(cfg) {
|
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
}
|
|
const merged = { ...readConfigFile(), ...cfg };
|
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2) + '\n', { mode: 0o600 });
|
|
}
|
|
exports.writeConfigFile = writeConfigFile;
|
|
function resolveConfig(overrides) {
|
|
const file = readConfigFile();
|
|
return {
|
|
endpoint: overrides?.endpoint ||
|
|
process.env.INKREACH_TEABLE_ENDPOINT ||
|
|
file.endpoint ||
|
|
exports.DEFAULT_ENDPOINT,
|
|
token: overrides?.token || process.env.INKREACH_TEABLE_TOKEN || file.token || '',
|
|
baseId: overrides?.baseId || process.env.INKREACH_TEABLE_BASE_ID || file.baseId,
|
|
};
|
|
}
|
|
exports.resolveConfig = resolveConfig;
|
|
function configPath() {
|
|
return CONFIG_FILE;
|
|
}
|
|
exports.configPath = configPath;
|