@ductape/cli 0.2.23 → 0.3.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/CHANGELOG.md +7 -0
- package/README.md +7 -0
- package/dist/commands/migrate-codebase.d.ts +176 -0
- package/dist/commands/migrate-codebase.js +753 -0
- package/dist/commands/migration-artifact.d.ts +32 -0
- package/dist/commands/migration-artifact.js +48 -0
- package/dist/commands/migration-assurance.d.ts +10 -0
- package/dist/commands/migration-assurance.js +120 -0
- package/dist/commands/migration-database.d.ts +21 -0
- package/dist/commands/migration-database.js +162 -0
- package/dist/commands/migration-e2e.d.ts +68 -0
- package/dist/commands/migration-e2e.js +189 -0
- package/dist/commands/migration-environments.d.ts +20 -0
- package/dist/commands/migration-environments.js +58 -0
- package/dist/commands/migration-generated.d.ts +68 -0
- package/dist/commands/migration-generated.js +217 -0
- package/dist/commands/migration-portfolio.d.ts +88 -0
- package/dist/commands/migration-portfolio.js +223 -0
- package/dist/commands/migration-products.d.ts +23 -0
- package/dist/commands/migration-products.js +88 -0
- package/dist/commands/migration-review.d.ts +248 -0
- package/dist/commands/migration-review.js +624 -0
- package/dist/commands/migration-secrets.d.ts +24 -0
- package/dist/commands/migration-secrets.js +93 -0
- package/dist/commands/migration-slice.d.ts +132 -0
- package/dist/commands/migration-slice.js +266 -0
- package/dist/commands/migration-verification.d.ts +12 -0
- package/dist/commands/migration-verification.js +194 -0
- package/dist/commands/products.d.ts +1 -0
- package/dist/commands/products.js +33 -1
- package/dist/commands/secrets.d.ts +8 -0
- package/dist/commands/secrets.js +44 -0
- package/dist/index.js +354 -2
- package/dist/lib/migration-artifact.d.ts +13 -0
- package/dist/lib/migration-artifact.js +103 -0
- package/package.json +8 -1
- package/API_PARITY.md +0 -58
- package/DB_MIGRATE_PLAN.md +0 -223
- package/ductape.example.ts +0 -18
- package/src/commands/apply.ts +0 -153
- package/src/commands/apps-import.ts +0 -43
- package/src/commands/apps.ts +0 -92
- package/src/commands/cloud.ts +0 -68
- package/src/commands/completion.ts +0 -119
- package/src/commands/db-migrate.ts +0 -209
- package/src/commands/db-schema.ts +0 -429
- package/src/commands/db.ts +0 -63
- package/src/commands/generate.ts +0 -74
- package/src/commands/graph.ts +0 -51
- package/src/commands/init.ts +0 -39
- package/src/commands/install.ts +0 -76
- package/src/commands/link.ts +0 -84
- package/src/commands/login.ts +0 -145
- package/src/commands/logout.ts +0 -7
- package/src/commands/platform.ts +0 -123
- package/src/commands/products.ts +0 -228
- package/src/commands/profiles.ts +0 -23
- package/src/commands/resources.ts +0 -213
- package/src/commands/secrets.ts +0 -46
- package/src/commands/unlink.ts +0 -15
- package/src/commands/whoami.ts +0 -27
- package/src/commands/workspaces.ts +0 -98
- package/src/index.ts +0 -523
- package/src/lib/api-client.ts +0 -88
- package/src/lib/app-import.ts +0 -82
- package/src/lib/apply-loaders.ts +0 -30
- package/src/lib/config.ts +0 -230
- package/src/lib/context-store.ts +0 -77
- package/src/lib/db-methods.ts +0 -56
- package/src/lib/db-types.ts +0 -104
- package/src/lib/encryption.ts +0 -12
- package/src/lib/forms/enums.ts +0 -52
- package/src/lib/forms/index.ts +0 -8
- package/src/lib/forms/prompt.ts +0 -209
- package/src/lib/forms/schemas.ts +0 -288
- package/src/lib/forms/types.ts +0 -27
- package/src/lib/http.ts +0 -76
- package/src/lib/integrations.ts +0 -110
- package/src/lib/interactive-opts.ts +0 -13
- package/src/lib/migration-files.ts +0 -58
- package/src/lib/output.ts +0 -39
- package/src/lib/platform-api.ts +0 -209
- package/src/lib/proxy/context.ts +0 -94
- package/src/lib/proxy/db-proxy.ts +0 -40
- package/src/lib/proxy/graph-proxy.ts +0 -64
- package/src/lib/proxy/sdk-proxy.ts +0 -58
- package/src/lib/read-body.ts +0 -57
- package/src/lib/resources.ts +0 -160
- package/src/lib/schema-loader.ts +0 -152
- package/src/lib/snippets.ts +0 -165
- package/src/lib/templates.ts +0 -157
- package/src/lib/workspace-context.ts +0 -43
- package/src/lib/workspaces.ts +0 -283
- package/test/apply-loaders.test.ts +0 -40
- package/test/encryption.test.ts +0 -20
- package/test/forms.test.ts +0 -25
- package/test/http.test.ts +0 -15
- package/test/platform-api.test.ts +0 -42
- package/test/resources.test.ts +0 -23
- package/test/workspace-resolve.test.ts +0 -29
- package/tsconfig.json +0 -15
package/src/lib/apply-loaders.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { PROJECT_CONFIG_DIR } from './config.js';
|
|
4
|
-
|
|
5
|
-
export type ApplyItem = Record<string, unknown> & { tag: string };
|
|
6
|
-
|
|
7
|
-
function loadArrayFile(filePath: string): ApplyItem[] | null {
|
|
8
|
-
if (!fs.existsSync(filePath)) return null;
|
|
9
|
-
const raw = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;
|
|
10
|
-
if (!Array.isArray(raw)) {
|
|
11
|
-
throw new Error(`${path.basename(filePath)} must be a JSON array.`);
|
|
12
|
-
}
|
|
13
|
-
return raw as ApplyItem[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function declarationPath(projectDir: string, filename: string): string {
|
|
17
|
-
return path.join(projectDir, PROJECT_CONFIG_DIR, filename);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function loadSessions(projectDir: string): ApplyItem[] | null {
|
|
21
|
-
return loadArrayFile(declarationPath(projectDir, 'sessions.json'));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function loadNotifications(projectDir: string): ApplyItem[] | null {
|
|
25
|
-
return loadArrayFile(declarationPath(projectDir, 'notifications.json'));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function loadEvents(projectDir: string): ApplyItem[] | null {
|
|
29
|
-
return loadArrayFile(declarationPath(projectDir, 'events.json'));
|
|
30
|
-
}
|
package/src/lib/config.ts
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
|
|
8
|
-
export const GLOBAL_DIR = path.join(os.homedir(), '.ductape');
|
|
9
|
-
export const CREDENTIALS_PATH = path.join(GLOBAL_DIR, 'credentials.json');
|
|
10
|
-
export const GLOBAL_CONFIG_PATH = path.join(GLOBAL_DIR, 'config.json');
|
|
11
|
-
export const HUB_PLATFORM_DIR = path.join(GLOBAL_DIR, 'platform');
|
|
12
|
-
export const PROJECT_CONFIG_DIR = 'ductape';
|
|
13
|
-
export const PROJECT_CONFIG_PATH = path.join(PROJECT_CONFIG_DIR, 'config.json');
|
|
14
|
-
|
|
15
|
-
export interface Credentials {
|
|
16
|
-
user_id: string;
|
|
17
|
-
email: string;
|
|
18
|
-
auth_token: string;
|
|
19
|
-
public_key: string;
|
|
20
|
-
firstname?: string;
|
|
21
|
-
lastname?: string;
|
|
22
|
-
workspaces?: Array<{
|
|
23
|
-
workspace_id?: string;
|
|
24
|
-
workspace_name?: string;
|
|
25
|
-
_id?: string;
|
|
26
|
-
name?: string;
|
|
27
|
-
tag?: string;
|
|
28
|
-
default?: boolean;
|
|
29
|
-
}>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface Profile {
|
|
33
|
-
api_url: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface GlobalConfig {
|
|
37
|
-
default_profile: string;
|
|
38
|
-
profiles: Record<string, Profile>;
|
|
39
|
-
/** Set at login or via `ductape workspaces use` */
|
|
40
|
-
active_workspace_id?: string;
|
|
41
|
-
active_workspace_name?: string;
|
|
42
|
-
active_workspace_tag?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Linked project config — use workspace_tag (human-readable); workspace_id is resolved by the CLI. */
|
|
46
|
-
export interface ProjectConfig {
|
|
47
|
-
workspace_tag?: string;
|
|
48
|
-
/** Resolved automatically; do not edit unless debugging */
|
|
49
|
-
workspace_id?: string;
|
|
50
|
-
product_tag: string;
|
|
51
|
-
env_slug: string;
|
|
52
|
-
linked_profile?: string;
|
|
53
|
-
project_id?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface ResolvedProjectConfig extends ProjectConfig {
|
|
57
|
-
workspace_id: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const DEFAULT_GLOBAL: GlobalConfig = {
|
|
61
|
-
default_profile: 'cloud',
|
|
62
|
-
profiles: {
|
|
63
|
-
/** Production gateway — paths are /users/v1/…, /proxy/v1/… (no /api prefix). */
|
|
64
|
-
cloud: { api_url: 'https://api.ductape.app' },
|
|
65
|
-
/** Local docker api-gateway — paths are /api/users/v1/…, /api/proxy/v1/… */
|
|
66
|
-
local: { api_url: 'http://localhost:4311/api' },
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
function readJson<T>(filePath: string): T | null {
|
|
71
|
-
if (!fs.existsSync(filePath)) return null;
|
|
72
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf8')) as T;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function writeJson(filePath: string, data: unknown, mode = 0o644): void {
|
|
76
|
-
const dir = path.dirname(filePath);
|
|
77
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
78
|
-
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', { mode });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function ensureGlobalDir(): void {
|
|
82
|
-
fs.mkdirSync(GLOBAL_DIR, { recursive: true });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function loadCredentials(): Credentials | null {
|
|
86
|
-
return readJson<Credentials>(CREDENTIALS_PATH);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function saveCredentials(creds: Credentials): void {
|
|
90
|
-
ensureGlobalDir();
|
|
91
|
-
writeJson(CREDENTIALS_PATH, creds, 0o600);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function clearCredentials(): void {
|
|
95
|
-
if (fs.existsSync(CREDENTIALS_PATH)) fs.unlinkSync(CREDENTIALS_PATH);
|
|
96
|
-
const global = loadGlobalConfig();
|
|
97
|
-
delete global.active_workspace_id;
|
|
98
|
-
delete global.active_workspace_name;
|
|
99
|
-
delete global.active_workspace_tag;
|
|
100
|
-
saveGlobalConfig(global);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function getActiveWorkspaceId(): string | null {
|
|
104
|
-
const global = loadGlobalConfig();
|
|
105
|
-
return global.active_workspace_id ?? null;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function loadGlobalConfig(): GlobalConfig {
|
|
109
|
-
const cfg = readJson<GlobalConfig>(GLOBAL_CONFIG_PATH) ?? {
|
|
110
|
-
...DEFAULT_GLOBAL,
|
|
111
|
-
profiles: { ...DEFAULT_GLOBAL.profiles },
|
|
112
|
-
};
|
|
113
|
-
// Migrate older configs that used /api on production (returns HTML 404).
|
|
114
|
-
if (cfg.profiles.cloud?.api_url?.replace(/\/$/, '') === 'https://api.ductape.app/api') {
|
|
115
|
-
cfg.profiles.cloud.api_url = DEFAULT_GLOBAL.profiles.cloud.api_url;
|
|
116
|
-
}
|
|
117
|
-
return cfg;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function saveGlobalConfig(config: GlobalConfig): void {
|
|
121
|
-
ensureGlobalDir();
|
|
122
|
-
writeJson(GLOBAL_CONFIG_PATH, config);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function getActiveProfileName(project?: ProjectConfig | null): string {
|
|
126
|
-
if (project?.linked_profile) return project.linked_profile;
|
|
127
|
-
return loadGlobalConfig().default_profile;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function getApiUrl(profileName?: string): string {
|
|
131
|
-
const global = loadGlobalConfig();
|
|
132
|
-
const name = profileName ?? global.default_profile;
|
|
133
|
-
const profile = global.profiles[name];
|
|
134
|
-
if (!profile) {
|
|
135
|
-
throw new Error(`Unknown profile "${name}". Run: ductape profiles list`);
|
|
136
|
-
}
|
|
137
|
-
return profile.api_url.replace(/\/$/, '');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function matchWorkspaceFromCredentials(
|
|
141
|
-
workspaces: NonNullable<Credentials['workspaces']>,
|
|
142
|
-
selector: string,
|
|
143
|
-
): string | null {
|
|
144
|
-
const trimmed = selector.trim();
|
|
145
|
-
const idx = Number(trimmed);
|
|
146
|
-
if (!Number.isNaN(idx) && workspaces[idx]) {
|
|
147
|
-
const w = workspaces[idx];
|
|
148
|
-
return w.workspace_id ?? w._id ?? null;
|
|
149
|
-
}
|
|
150
|
-
for (const w of workspaces) {
|
|
151
|
-
const id = w.workspace_id ?? w._id;
|
|
152
|
-
const name = w.workspace_name ?? w.name ?? '';
|
|
153
|
-
const tag = w.tag ?? '';
|
|
154
|
-
if (
|
|
155
|
-
id === trimmed ||
|
|
156
|
-
name.toLowerCase() === trimmed.toLowerCase() ||
|
|
157
|
-
tag.toLowerCase() === trimmed.toLowerCase()
|
|
158
|
-
) {
|
|
159
|
-
return id ?? null;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** Resolve workspace_id from tag (cached workspaces), explicit id, or global active workspace. */
|
|
166
|
-
export function resolveWorkspaceId(cfg: ProjectConfig, creds?: Credentials | null): string | null {
|
|
167
|
-
if (cfg.workspace_id?.trim()) return cfg.workspace_id.trim();
|
|
168
|
-
if (cfg.workspace_tag?.trim() && creds?.workspaces?.length) {
|
|
169
|
-
const id = matchWorkspaceFromCredentials(creds.workspaces, cfg.workspace_tag);
|
|
170
|
-
if (id) return id;
|
|
171
|
-
}
|
|
172
|
-
return getActiveWorkspaceId();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export function findProjectConfig(startDir = process.cwd()): { dir: string; config: ProjectConfig } | null {
|
|
176
|
-
let dir = startDir;
|
|
177
|
-
const root = path.parse(dir).root;
|
|
178
|
-
while (true) {
|
|
179
|
-
const candidate = path.join(dir, PROJECT_CONFIG_PATH);
|
|
180
|
-
const cfg = readJson<ProjectConfig>(candidate);
|
|
181
|
-
if (cfg?.product_tag && (cfg.workspace_tag || cfg.workspace_id)) {
|
|
182
|
-
return { dir, config: cfg };
|
|
183
|
-
}
|
|
184
|
-
if (dir === root) break;
|
|
185
|
-
dir = path.dirname(dir);
|
|
186
|
-
}
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function loadProjectConfig(): ResolvedProjectConfig {
|
|
191
|
-
const found = findProjectConfig();
|
|
192
|
-
if (!found) {
|
|
193
|
-
throw new Error(
|
|
194
|
-
'No linked project. Run `ductape link` from your project directory (or `ductape init`).',
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
const creds = loadCredentials();
|
|
198
|
-
const cfg = { ...found.config };
|
|
199
|
-
const workspace_id = resolveWorkspaceId(cfg, creds);
|
|
200
|
-
if (!workspace_id) {
|
|
201
|
-
throw new Error(
|
|
202
|
-
'No workspace resolved. Set workspace_tag in ductape/config.json or run `ductape workspaces use`.',
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
return { ...cfg, workspace_id };
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export function saveProjectConfig(dir: string, config: ProjectConfig): void {
|
|
209
|
-
const configDir = path.join(dir, PROJECT_CONFIG_DIR);
|
|
210
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
211
|
-
writeJson(path.join(configDir, 'config.json'), config);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function resolvePlatformDir(): string {
|
|
215
|
-
if (process.env.DUCTAPE_PLATFORM_DIR) {
|
|
216
|
-
return path.resolve(process.env.DUCTAPE_PLATFORM_DIR);
|
|
217
|
-
}
|
|
218
|
-
// Hub install: ~/.ductape/platform/ (written by `ductape install`)
|
|
219
|
-
if (fs.existsSync(path.join(HUB_PLATFORM_DIR, 'docker-compose.yml'))) {
|
|
220
|
-
return HUB_PLATFORM_DIR;
|
|
221
|
-
}
|
|
222
|
-
// Dev/monorepo: cli/ -> repo root -> platform/
|
|
223
|
-
const fromPackage = path.resolve(__dirname, '../../../platform');
|
|
224
|
-
if (fs.existsSync(path.join(fromPackage, 'docker-compose.yml'))) {
|
|
225
|
-
return fromPackage;
|
|
226
|
-
}
|
|
227
|
-
throw new Error(
|
|
228
|
-
'Platform not installed. Run `ductape install` to pull the platform from Docker Hub.',
|
|
229
|
-
);
|
|
230
|
-
}
|
package/src/lib/context-store.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { GLOBAL_DIR } from './config.js';
|
|
4
|
-
import type { GraphContext } from './proxy/graph-proxy.js';
|
|
5
|
-
|
|
6
|
-
export interface DatabaseContext {
|
|
7
|
-
database: string;
|
|
8
|
-
env: string;
|
|
9
|
-
product: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ProjectRuntimeContext {
|
|
13
|
-
workspace_id: string;
|
|
14
|
-
product_tag: string;
|
|
15
|
-
env_slug: string;
|
|
16
|
-
database_context?: DatabaseContext | null;
|
|
17
|
-
graph_context?: GraphContext | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const RUNTIME_PATH = path.join(GLOBAL_DIR, 'runtime-context.json');
|
|
21
|
-
|
|
22
|
-
function readAll(): Record<string, ProjectRuntimeContext> {
|
|
23
|
-
if (!fs.existsSync(RUNTIME_PATH)) return {};
|
|
24
|
-
return JSON.parse(fs.readFileSync(RUNTIME_PATH, 'utf8')) as Record<string, ProjectRuntimeContext>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function writeAll(data: Record<string, ProjectRuntimeContext>): void {
|
|
28
|
-
fs.mkdirSync(GLOBAL_DIR, { recursive: true });
|
|
29
|
-
fs.writeFileSync(RUNTIME_PATH, JSON.stringify(data, null, 2) + '\n', { mode: 0o600 });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function projectKey(workspaceId: string, productTag: string): string {
|
|
33
|
-
return `${workspaceId}:${productTag}`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function loadRuntimeContext(workspaceId: string, productTag: string): ProjectRuntimeContext | null {
|
|
37
|
-
const all = readAll();
|
|
38
|
-
return all[projectKey(workspaceId, productTag)] ?? null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function saveRuntimeContext(ctx: ProjectRuntimeContext): void {
|
|
42
|
-
const all = readAll();
|
|
43
|
-
all[projectKey(ctx.workspace_id, ctx.product_tag)] = ctx;
|
|
44
|
-
writeAll(all);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function setDatabaseContext(
|
|
48
|
-
workspaceId: string,
|
|
49
|
-
productTag: string,
|
|
50
|
-
envSlug: string,
|
|
51
|
-
db: DatabaseContext | null,
|
|
52
|
-
): void {
|
|
53
|
-
const existing =
|
|
54
|
-
loadRuntimeContext(workspaceId, productTag) ?? {
|
|
55
|
-
workspace_id: workspaceId,
|
|
56
|
-
product_tag: productTag,
|
|
57
|
-
env_slug: envSlug,
|
|
58
|
-
};
|
|
59
|
-
existing.database_context = db;
|
|
60
|
-
saveRuntimeContext(existing);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function setGraphContext(
|
|
64
|
-
workspaceId: string,
|
|
65
|
-
productTag: string,
|
|
66
|
-
envSlug: string,
|
|
67
|
-
graph: GraphContext | null,
|
|
68
|
-
): void {
|
|
69
|
-
const existing =
|
|
70
|
-
loadRuntimeContext(workspaceId, productTag) ?? {
|
|
71
|
-
workspace_id: workspaceId,
|
|
72
|
-
product_tag: productTag,
|
|
73
|
-
env_slug: envSlug,
|
|
74
|
-
};
|
|
75
|
-
existing.graph_context = graph;
|
|
76
|
-
saveRuntimeContext(existing);
|
|
77
|
-
}
|
package/src/lib/db-methods.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** db-proxy methods (runtime). Dot notation supported: schema.list */
|
|
2
|
-
export const DB_PROXY_METHODS = [
|
|
3
|
-
'connect',
|
|
4
|
-
'disconnect',
|
|
5
|
-
'closeAll',
|
|
6
|
-
'testConnection',
|
|
7
|
-
'getCurrentContext',
|
|
8
|
-
'connection',
|
|
9
|
-
'query',
|
|
10
|
-
'execute',
|
|
11
|
-
'insert',
|
|
12
|
-
'update',
|
|
13
|
-
'delete',
|
|
14
|
-
'upsert',
|
|
15
|
-
'count',
|
|
16
|
-
'sum',
|
|
17
|
-
'avg',
|
|
18
|
-
'min',
|
|
19
|
-
'max',
|
|
20
|
-
'aggregate',
|
|
21
|
-
'listTables',
|
|
22
|
-
'listTablesWithInfo',
|
|
23
|
-
'describe',
|
|
24
|
-
'getSchema',
|
|
25
|
-
'beginTransaction',
|
|
26
|
-
'schema.create',
|
|
27
|
-
'schema.drop',
|
|
28
|
-
'schema.list',
|
|
29
|
-
'schema.describe',
|
|
30
|
-
'schema.addField',
|
|
31
|
-
'schema.dropField',
|
|
32
|
-
'migration.list',
|
|
33
|
-
'migration.run',
|
|
34
|
-
] as const;
|
|
35
|
-
|
|
36
|
-
export const GRAPH_PROXY_METHODS = [
|
|
37
|
-
'connect',
|
|
38
|
-
'disconnect',
|
|
39
|
-
'disconnectAll',
|
|
40
|
-
'testConnection',
|
|
41
|
-
'getCurrentContext',
|
|
42
|
-
'create',
|
|
43
|
-
'fetchAll',
|
|
44
|
-
'fetch',
|
|
45
|
-
'update',
|
|
46
|
-
'delete',
|
|
47
|
-
'createNode',
|
|
48
|
-
'findNodes',
|
|
49
|
-
'query',
|
|
50
|
-
'traverse',
|
|
51
|
-
'shortestPath',
|
|
52
|
-
'countNodes',
|
|
53
|
-
'dispatch',
|
|
54
|
-
'execute',
|
|
55
|
-
'executeTransaction',
|
|
56
|
-
] as const;
|
package/src/lib/db-types.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
export type FieldType =
|
|
2
|
-
| 'string'
|
|
3
|
-
| 'text'
|
|
4
|
-
| 'integer'
|
|
5
|
-
| 'bigint'
|
|
6
|
-
| 'smallint'
|
|
7
|
-
| 'decimal'
|
|
8
|
-
| 'float'
|
|
9
|
-
| 'double'
|
|
10
|
-
| 'uuid'
|
|
11
|
-
| 'boolean'
|
|
12
|
-
| 'date'
|
|
13
|
-
| 'time'
|
|
14
|
-
| 'datetime'
|
|
15
|
-
| 'timestamp'
|
|
16
|
-
| 'binary'
|
|
17
|
-
| 'blob'
|
|
18
|
-
| 'json'
|
|
19
|
-
| 'object'
|
|
20
|
-
| 'array'
|
|
21
|
-
| 'enum';
|
|
22
|
-
|
|
23
|
-
export interface IFieldDefinition {
|
|
24
|
-
name: string;
|
|
25
|
-
type: FieldType;
|
|
26
|
-
nullable?: boolean;
|
|
27
|
-
unique?: boolean;
|
|
28
|
-
primaryKey?: boolean;
|
|
29
|
-
autoGenerate?: boolean;
|
|
30
|
-
defaultValue?: unknown;
|
|
31
|
-
maxLength?: number;
|
|
32
|
-
precision?: number;
|
|
33
|
-
scale?: number;
|
|
34
|
-
enumValues?: string[];
|
|
35
|
-
arrayElementType?: FieldType;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface ICreateCollectionOp {
|
|
39
|
-
type: 'createCollection';
|
|
40
|
-
name: string;
|
|
41
|
-
fields: IFieldDefinition[];
|
|
42
|
-
ifNotExists?: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface IDropCollectionOp {
|
|
46
|
-
type: 'dropCollection';
|
|
47
|
-
name: string;
|
|
48
|
-
ifExists?: boolean;
|
|
49
|
-
cascade?: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface IAddFieldOp {
|
|
53
|
-
type: 'addField';
|
|
54
|
-
collection: string;
|
|
55
|
-
field: IFieldDefinition;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface IDropFieldOp {
|
|
59
|
-
type: 'dropField';
|
|
60
|
-
collection: string;
|
|
61
|
-
fieldName: string;
|
|
62
|
-
cascade?: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface ICreateIndexOp {
|
|
66
|
-
type: 'createIndex';
|
|
67
|
-
collection: string;
|
|
68
|
-
name: string;
|
|
69
|
-
fields: Array<{ name: string; order?: 'asc' | 'desc' }>;
|
|
70
|
-
unique?: boolean;
|
|
71
|
-
ifNotExists?: boolean;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface IDropIndexOp {
|
|
75
|
-
type: 'dropIndex';
|
|
76
|
-
collection: string;
|
|
77
|
-
name: string;
|
|
78
|
-
ifExists?: boolean;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type IMigrationOperation =
|
|
82
|
-
| ICreateCollectionOp
|
|
83
|
-
| IDropCollectionOp
|
|
84
|
-
| IAddFieldOp
|
|
85
|
-
| IDropFieldOp
|
|
86
|
-
| ICreateIndexOp
|
|
87
|
-
| IDropIndexOp;
|
|
88
|
-
|
|
89
|
-
export interface IMigration {
|
|
90
|
-
tag: string;
|
|
91
|
-
name: string;
|
|
92
|
-
description?: string;
|
|
93
|
-
up: IMigrationOperation[];
|
|
94
|
-
down: IMigrationOperation[];
|
|
95
|
-
dependencies?: string[];
|
|
96
|
-
createdAt?: string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface IMigrationHistory {
|
|
100
|
-
tag: string;
|
|
101
|
-
name: string;
|
|
102
|
-
checksum?: string;
|
|
103
|
-
appliedAt?: string;
|
|
104
|
-
}
|
package/src/lib/encryption.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Proxy payload encryption — matches platform/workbench/src/utils/proxyEncryption.ts
|
|
3
|
-
*/
|
|
4
|
-
import CryptoJS from 'crypto-js';
|
|
5
|
-
|
|
6
|
-
export function encryptProxyPayload(data: object, publicKey: string): string {
|
|
7
|
-
const jsonString = JSON.stringify(data);
|
|
8
|
-
const iv = CryptoJS.lib.WordArray.random(16);
|
|
9
|
-
const hashedKey = CryptoJS.SHA256(publicKey);
|
|
10
|
-
const encrypted = CryptoJS.AES.encrypt(jsonString, hashedKey, { iv });
|
|
11
|
-
return iv.toString(CryptoJS.enc.Hex) + ':' + encrypted.toString();
|
|
12
|
-
}
|
package/src/lib/forms/enums.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/** Enum values aligned with @ductape/sdk — used for CLI dropdowns */
|
|
2
|
-
|
|
3
|
-
export const STORAGE_PROVIDERS = ['aws', 'gcp', 'azure'] as const;
|
|
4
|
-
|
|
5
|
-
export const DATABASE_TYPES = ['postgresql', 'mongodb', 'mysql'] as const;
|
|
6
|
-
|
|
7
|
-
export const GRAPH_TYPES = ['neo4j', 'neptune', 'arangodb', 'memgraph'] as const;
|
|
8
|
-
|
|
9
|
-
export const VECTOR_DB_TYPES = [
|
|
10
|
-
'pinecone',
|
|
11
|
-
'qdrant',
|
|
12
|
-
'weaviate',
|
|
13
|
-
'chroma',
|
|
14
|
-
'milvus',
|
|
15
|
-
'pgvector',
|
|
16
|
-
'memory',
|
|
17
|
-
] as const;
|
|
18
|
-
|
|
19
|
-
export const VECTOR_DISTANCE_METRICS = ['cosine', 'euclidean', 'dotproduct'] as const;
|
|
20
|
-
|
|
21
|
-
export const MESSAGE_BROKER_TYPES = [
|
|
22
|
-
'rabbitmq',
|
|
23
|
-
'kafka',
|
|
24
|
-
'aws_sqs',
|
|
25
|
-
'redis',
|
|
26
|
-
'google_pubsub',
|
|
27
|
-
'nats',
|
|
28
|
-
] as const;
|
|
29
|
-
|
|
30
|
-
export const JOB_EVENT_TYPES = [
|
|
31
|
-
'action',
|
|
32
|
-
'notification',
|
|
33
|
-
'database_action',
|
|
34
|
-
'database_operation',
|
|
35
|
-
'graph_action',
|
|
36
|
-
'graph_operation',
|
|
37
|
-
'workflow',
|
|
38
|
-
'storage',
|
|
39
|
-
] as const;
|
|
40
|
-
|
|
41
|
-
export const DATABASE_ACTION_TYPES = [
|
|
42
|
-
'read',
|
|
43
|
-
'count',
|
|
44
|
-
'create',
|
|
45
|
-
'update',
|
|
46
|
-
'delete',
|
|
47
|
-
'aggregate',
|
|
48
|
-
] as const;
|
|
49
|
-
|
|
50
|
-
export const HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] as const;
|
|
51
|
-
|
|
52
|
-
export const NOTIFIERS = ['email', 'sms', 'push', 'callback'] as const;
|
package/src/lib/forms/index.ts
DELETED