@lumerahq/cli 0.24.2-dev.0 → 0.24.3
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/dist/{auth-NI7JTMJM.js → auth-MJO5DFOF.js} +1 -1
- package/dist/{chunk-3ESHIPZH.js → chunk-7ZTCXKII.js} +2 -2
- package/dist/{chunk-HTPNRY3F.js → chunk-FHHWIV4C.js} +1 -1
- package/dist/{chunk-ZH3NVYEQ.js → chunk-JLVVHTBY.js} +27 -0
- package/dist/{chunk-I7QEYKS7.js → chunk-KBNM6R5X.js} +1 -1
- package/dist/{chunk-HU7RYLUF.js → chunk-VL5GDJKU.js} +1 -1
- package/dist/{deps-HWO6X5WM.js → deps-IYUORT55.js} +3 -3
- package/dist/{dev-VWHFYKGC.js → dev-N5CEEMFC.js} +4 -4
- package/dist/{flags-UZW4D2SO.js → flags-3KYOBHVA.js} +1 -1
- package/dist/index.js +25 -24
- package/dist/{init-RPJHBBWD.js → init-B4DXTC7L.js} +3 -3
- package/dist/{migrate-NCZKP7FM.js → migrate-NEG3HKH4.js} +1 -1
- package/dist/{register-OOU477QY.js → register-HRLBT4FI.js} +2 -2
- package/dist/{resources-7VQAR6F4.js → resources-CCVVK3H2.js} +51 -35
- package/dist/{run-DJXAXDD2.js → run-WHVUVIYB.js} +2 -2
- package/dist/{skills-REOKLNEF.js → skills-PXZHERAS.js} +2 -2
- package/dist/{status-X7WQYX2L.js → status-NPNIY3QP.js} +1 -1
- package/package.json +1 -1
- package/templates/default/_gitignore +0 -1
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
createApiClient,
|
|
6
6
|
isApiErrorStatus
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FHHWIV4C.js";
|
|
8
8
|
import {
|
|
9
9
|
findProjectRoot,
|
|
10
10
|
getAppName
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JLVVHTBY.js";
|
|
12
12
|
|
|
13
13
|
// src/commands/deps.ts
|
|
14
14
|
import pc from "picocolors";
|
|
@@ -14,6 +14,9 @@ __export(auth_exports, {
|
|
|
14
14
|
import { existsSync, readFileSync } from "fs";
|
|
15
15
|
import { homedir } from "os";
|
|
16
16
|
import { join } from "path";
|
|
17
|
+
function getRuntimeCredsPath() {
|
|
18
|
+
return process.env.LUMERA_CREDENTIALS_PATH?.trim() || null;
|
|
19
|
+
}
|
|
17
20
|
function getLocalCredsPath(cwd = process.cwd()) {
|
|
18
21
|
return join(cwd, ".lumera", "credentials.json");
|
|
19
22
|
}
|
|
@@ -21,6 +24,14 @@ function getToken(cwd = process.cwd()) {
|
|
|
21
24
|
if (process.env.LUMERA_TOKEN) {
|
|
22
25
|
return process.env.LUMERA_TOKEN;
|
|
23
26
|
}
|
|
27
|
+
const runtimeCredsPath = getRuntimeCredsPath();
|
|
28
|
+
if (runtimeCredsPath && existsSync(runtimeCredsPath)) {
|
|
29
|
+
try {
|
|
30
|
+
const creds = JSON.parse(readFileSync(runtimeCredsPath, "utf-8"));
|
|
31
|
+
if (creds.token) return creds.token;
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
}
|
|
24
35
|
const localCredsPath = getLocalCredsPath(cwd);
|
|
25
36
|
if (existsSync(localCredsPath)) {
|
|
26
37
|
try {
|
|
@@ -44,6 +55,14 @@ function getTokenSource(cwd = process.cwd()) {
|
|
|
44
55
|
if (process.env.LUMERA_TOKEN) {
|
|
45
56
|
return "environment (LUMERA_TOKEN)";
|
|
46
57
|
}
|
|
58
|
+
const runtimeCredsPath = getRuntimeCredsPath();
|
|
59
|
+
if (runtimeCredsPath && existsSync(runtimeCredsPath)) {
|
|
60
|
+
try {
|
|
61
|
+
const creds = JSON.parse(readFileSync(runtimeCredsPath, "utf-8"));
|
|
62
|
+
if (creds.token) return `runtime (${runtimeCredsPath})`;
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
47
66
|
const localCredsPath = getLocalCredsPath(cwd);
|
|
48
67
|
if (existsSync(localCredsPath)) {
|
|
49
68
|
try {
|
|
@@ -62,6 +81,14 @@ function getTokenSource(cwd = process.cwd()) {
|
|
|
62
81
|
return null;
|
|
63
82
|
}
|
|
64
83
|
function getCredentials(cwd = process.cwd()) {
|
|
84
|
+
const runtimeCredsPath = getRuntimeCredsPath();
|
|
85
|
+
if (runtimeCredsPath && existsSync(runtimeCredsPath)) {
|
|
86
|
+
try {
|
|
87
|
+
const creds = JSON.parse(readFileSync(runtimeCredsPath, "utf-8"));
|
|
88
|
+
if (creds.token) return creds;
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
65
92
|
const localCredsPath = getLocalCredsPath(cwd);
|
|
66
93
|
if (existsSync(localCredsPath)) {
|
|
67
94
|
try {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deps,
|
|
3
3
|
syncDeps
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7ZTCXKII.js";
|
|
5
5
|
import "./chunk-2CR762KB.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-FHHWIV4C.js";
|
|
7
|
+
import "./chunk-JLVVHTBY.js";
|
|
8
8
|
import "./chunk-FJFIWC7G.js";
|
|
9
9
|
import "./chunk-PNKVD2UK.js";
|
|
10
10
|
export {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dev
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KBNM6R5X.js";
|
|
4
4
|
import {
|
|
5
5
|
syncDeps
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7ZTCXKII.js";
|
|
7
7
|
import {
|
|
8
8
|
loadEnv
|
|
9
9
|
} from "./chunk-2CR762KB.js";
|
|
10
10
|
import {
|
|
11
11
|
createApiClient
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FHHWIV4C.js";
|
|
13
13
|
import {
|
|
14
14
|
findProjectRoot,
|
|
15
15
|
getApiUrl,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
getAppTitle,
|
|
18
18
|
getToken,
|
|
19
19
|
init_auth
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-JLVVHTBY.js";
|
|
21
21
|
import "./chunk-FJFIWC7G.js";
|
|
22
22
|
import "./chunk-PNKVD2UK.js";
|
|
23
23
|
|
|
@@ -6,7 +6,7 @@ import pc from "picocolors";
|
|
|
6
6
|
// src/lib/flags.ts
|
|
7
7
|
import { readFileSync, statSync } from "fs";
|
|
8
8
|
var ENV_PATH = "LUMERA_FEATURE_FLAGS_PATH";
|
|
9
|
-
var DEFAULT_PATH = "/
|
|
9
|
+
var DEFAULT_PATH = "/lumera_state/feature-flags/flags.json";
|
|
10
10
|
function flagsPath() {
|
|
11
11
|
return process.env[ENV_PATH] || DEFAULT_PATH;
|
|
12
12
|
}
|
package/dist/index.js
CHANGED
|
@@ -6,17 +6,18 @@ import "./chunk-PNKVD2UK.js";
|
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
import { readFileSync as readFileSync2 } from "fs";
|
|
9
|
-
import { dirname, join as join2 } from "path";
|
|
9
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import pc from "picocolors";
|
|
12
12
|
|
|
13
13
|
// src/lib/update-check.ts
|
|
14
14
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
15
15
|
import { homedir } from "os";
|
|
16
|
-
import { join } from "path";
|
|
16
|
+
import { dirname, join } from "path";
|
|
17
17
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
18
18
|
function getCachePath() {
|
|
19
|
-
|
|
19
|
+
const stateRoot = process.env.LUMERA_STATE_DIR?.trim();
|
|
20
|
+
return stateRoot ? join(stateRoot, "cli", "update-check.json") : join(homedir(), ".lumera", "update-check.json");
|
|
20
21
|
}
|
|
21
22
|
function readCache() {
|
|
22
23
|
const cachePath = getCachePath();
|
|
@@ -28,7 +29,7 @@ function readCache() {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
function writeCache(data) {
|
|
31
|
-
const dir =
|
|
32
|
+
const dir = dirname(getCachePath());
|
|
32
33
|
mkdirSync(dir, { recursive: true });
|
|
33
34
|
writeFileSync(getCachePath(), JSON.stringify(data));
|
|
34
35
|
}
|
|
@@ -69,7 +70,7 @@ async function checkForUpdate(currentVersion) {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// src/index.ts
|
|
72
|
-
var __dirname =
|
|
73
|
+
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
73
74
|
var pkg = JSON.parse(readFileSync2(join2(__dirname, "..", "package.json"), "utf-8"));
|
|
74
75
|
var VERSION = pkg.version;
|
|
75
76
|
var rawArgs = process.argv.slice(2);
|
|
@@ -226,70 +227,70 @@ async function main() {
|
|
|
226
227
|
switch (command) {
|
|
227
228
|
// Resource commands
|
|
228
229
|
case "plan":
|
|
229
|
-
await import("./resources-
|
|
230
|
+
await import("./resources-CCVVK3H2.js").then((m) => m.plan(args.slice(1)));
|
|
230
231
|
break;
|
|
231
232
|
case "apply":
|
|
232
|
-
await import("./resources-
|
|
233
|
+
await import("./resources-CCVVK3H2.js").then((m) => m.apply(args.slice(1)));
|
|
233
234
|
break;
|
|
234
235
|
case "pull":
|
|
235
|
-
await import("./resources-
|
|
236
|
+
await import("./resources-CCVVK3H2.js").then((m) => m.pull(args.slice(1)));
|
|
236
237
|
break;
|
|
237
238
|
case "destroy":
|
|
238
|
-
await import("./resources-
|
|
239
|
+
await import("./resources-CCVVK3H2.js").then((m) => m.destroy(args.slice(1)));
|
|
239
240
|
break;
|
|
240
241
|
case "list":
|
|
241
|
-
await import("./resources-
|
|
242
|
+
await import("./resources-CCVVK3H2.js").then((m) => m.list(args.slice(1)));
|
|
242
243
|
break;
|
|
243
244
|
case "show":
|
|
244
|
-
await import("./resources-
|
|
245
|
+
await import("./resources-CCVVK3H2.js").then((m) => m.show(args.slice(1)));
|
|
245
246
|
break;
|
|
246
247
|
case "diff":
|
|
247
|
-
await import("./resources-
|
|
248
|
+
await import("./resources-CCVVK3H2.js").then((m) => m.diff(args.slice(1)));
|
|
248
249
|
break;
|
|
249
250
|
// Development
|
|
250
251
|
case "dev":
|
|
251
|
-
await import("./dev-
|
|
252
|
+
await import("./dev-N5CEEMFC.js").then((m) => m.dev(args.slice(1)));
|
|
252
253
|
break;
|
|
253
254
|
case "run":
|
|
254
|
-
await import("./run-
|
|
255
|
+
await import("./run-WHVUVIYB.js").then((m) => m.run(args.slice(1)));
|
|
255
256
|
break;
|
|
256
257
|
// Project
|
|
257
258
|
case "init":
|
|
258
|
-
await import("./init-
|
|
259
|
+
await import("./init-B4DXTC7L.js").then((m) => m.init(args.slice(1)));
|
|
259
260
|
break;
|
|
260
261
|
case "register":
|
|
261
|
-
await import("./register-
|
|
262
|
+
await import("./register-HRLBT4FI.js").then((m) => m.register(args.slice(1)));
|
|
262
263
|
break;
|
|
263
264
|
case "templates":
|
|
264
265
|
await import("./templates-LNUOTNLN.js").then((m) => m.templates(subcommand, args.slice(2)));
|
|
265
266
|
break;
|
|
266
267
|
case "status":
|
|
267
|
-
await import("./status-
|
|
268
|
+
await import("./status-NPNIY3QP.js").then((m) => m.status(args.slice(1)));
|
|
268
269
|
break;
|
|
269
270
|
case "migrate":
|
|
270
|
-
await import("./migrate-
|
|
271
|
+
await import("./migrate-NEG3HKH4.js").then((m) => m.migrate(args.slice(1)));
|
|
271
272
|
break;
|
|
272
273
|
// Skills
|
|
273
274
|
case "skills":
|
|
274
|
-
await import("./skills-
|
|
275
|
+
await import("./skills-PXZHERAS.js").then((m) => m.skills(subcommand, args.slice(2)));
|
|
275
276
|
break;
|
|
276
277
|
// Dependencies
|
|
277
278
|
case "deps":
|
|
278
|
-
await import("./deps-
|
|
279
|
+
await import("./deps-IYUORT55.js").then((m) => m.deps(args.slice(1)));
|
|
279
280
|
break;
|
|
280
281
|
// Feature flags (read the in-sandbox snapshot)
|
|
281
282
|
case "flags":
|
|
282
|
-
await import("./flags-
|
|
283
|
+
await import("./flags-3KYOBHVA.js").then((m) => m.flags(subcommand, args.slice(2)));
|
|
283
284
|
break;
|
|
284
285
|
// Auth
|
|
285
286
|
case "login":
|
|
286
|
-
await import("./auth-
|
|
287
|
+
await import("./auth-MJO5DFOF.js").then((m) => m.login(args.slice(1)));
|
|
287
288
|
break;
|
|
288
289
|
case "logout":
|
|
289
|
-
await import("./auth-
|
|
290
|
+
await import("./auth-MJO5DFOF.js").then((m) => m.logout(args.slice(1)));
|
|
290
291
|
break;
|
|
291
292
|
case "whoami":
|
|
292
|
-
await import("./auth-
|
|
293
|
+
await import("./auth-MJO5DFOF.js").then((m) => m.whoami());
|
|
293
294
|
break;
|
|
294
295
|
// Convenience aliases
|
|
295
296
|
case "help":
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
installAllSkills,
|
|
3
3
|
syncClaudeMd
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VL5GDJKU.js";
|
|
5
5
|
import {
|
|
6
6
|
spinner
|
|
7
7
|
} from "./chunk-BHYDYR75.js";
|
|
8
8
|
import {
|
|
9
9
|
createApiClient,
|
|
10
10
|
validateProjectNameLength
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FHHWIV4C.js";
|
|
12
12
|
import {
|
|
13
13
|
getToken,
|
|
14
14
|
init_auth,
|
|
15
15
|
setProjectId
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JLVVHTBY.js";
|
|
17
17
|
import "./chunk-FJFIWC7G.js";
|
|
18
18
|
import {
|
|
19
19
|
listAllTemplates,
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
createApiClient,
|
|
9
9
|
validateProjectExternalId
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FHHWIV4C.js";
|
|
11
11
|
import {
|
|
12
12
|
findProjectRoot,
|
|
13
13
|
getAppName,
|
|
14
14
|
getProjectId,
|
|
15
15
|
setProjectId
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JLVVHTBY.js";
|
|
17
17
|
import "./chunk-FJFIWC7G.js";
|
|
18
18
|
import "./chunk-PNKVD2UK.js";
|
|
19
19
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deploy
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KBNM6R5X.js";
|
|
4
4
|
import {
|
|
5
5
|
syncDeps
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7ZTCXKII.js";
|
|
7
7
|
import {
|
|
8
8
|
loadEnv
|
|
9
9
|
} from "./chunk-2CR762KB.js";
|
|
10
10
|
import {
|
|
11
11
|
ApiError,
|
|
12
12
|
createApiClient,
|
|
13
|
+
isApiErrorStatus,
|
|
13
14
|
validateCollectionNameLength
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-FHHWIV4C.js";
|
|
15
16
|
import {
|
|
16
17
|
findProjectRoot,
|
|
17
18
|
getApiUrl,
|
|
@@ -20,7 +21,7 @@ import {
|
|
|
20
21
|
getProjectId,
|
|
21
22
|
getToken,
|
|
22
23
|
init_auth
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-JLVVHTBY.js";
|
|
24
25
|
import {
|
|
25
26
|
fetchWithRetry
|
|
26
27
|
} from "./chunk-FJFIWC7G.js";
|
|
@@ -182,14 +183,6 @@ var collectionSchemaRule = {
|
|
|
182
183
|
}
|
|
183
184
|
if (!Array.isArray(index.fields) || !index.fields.every((field) => typeof field === "string" && field.trim() !== "")) {
|
|
184
185
|
issues.push(error(target, `Index at index ${i} must include a non-empty string array "fields".`));
|
|
185
|
-
} else if (index.fields.length === 1) {
|
|
186
|
-
const fieldName = index.fields[0].trim().toLowerCase();
|
|
187
|
-
if (fieldName === "updated" || fieldName === "external_id") {
|
|
188
|
-
issues.push(error(
|
|
189
|
-
target,
|
|
190
|
-
`Index at index ${i} declares system field "${fieldName}" by itself; Lumera already manages that index. Remove the redundant declaration.`
|
|
191
|
-
));
|
|
192
|
-
}
|
|
193
186
|
}
|
|
194
187
|
}
|
|
195
188
|
}
|
|
@@ -905,13 +898,6 @@ function stripNamespacePrefix(name, appName) {
|
|
|
905
898
|
}
|
|
906
899
|
return name;
|
|
907
900
|
}
|
|
908
|
-
function buildIndexSql(local, idx, appName) {
|
|
909
|
-
const fields = idx.fields.join(", ");
|
|
910
|
-
const unique = idx.unique ? "UNIQUE " : "";
|
|
911
|
-
const physicalId = appName ? sanitizeSlugForCollectionName(appName) + NAMESPACE_SEPARATOR + local.id : local.id;
|
|
912
|
-
const indexName = `idx_${physicalId}_${idx.fields.join("_")}`;
|
|
913
|
-
return `CREATE ${unique}INDEX ${indexName} ON ${local.name} (${fields})`;
|
|
914
|
-
}
|
|
915
901
|
var AGENT_IDLE_REAP_TIMEOUT_MIN_SECONDS = 10;
|
|
916
902
|
var AGENT_IDLE_REAP_TIMEOUT_MAX_SECONDS = 900;
|
|
917
903
|
function buildCollectionIdMap(collections, appName) {
|
|
@@ -1530,7 +1516,7 @@ function loadLocalHooks(platformDir, filterName, appName) {
|
|
|
1530
1516
|
}
|
|
1531
1517
|
return hooks;
|
|
1532
1518
|
}
|
|
1533
|
-
function convertCollectionToApiFormat(local
|
|
1519
|
+
function convertCollectionToApiFormat(local) {
|
|
1534
1520
|
const schema = local.fields.map((field) => {
|
|
1535
1521
|
const apiField = {
|
|
1536
1522
|
name: field.name,
|
|
@@ -1559,7 +1545,12 @@ function convertCollectionToApiFormat(local, appName) {
|
|
|
1559
1545
|
}
|
|
1560
1546
|
return apiField;
|
|
1561
1547
|
});
|
|
1562
|
-
const indexes = local.indexes?.map((idx) =>
|
|
1548
|
+
const indexes = local.indexes?.map((idx) => {
|
|
1549
|
+
const fields = idx.fields.join(", ");
|
|
1550
|
+
const unique = idx.unique ? "UNIQUE " : "";
|
|
1551
|
+
const indexName = `idx_${local.id}_${idx.fields.join("_")}`;
|
|
1552
|
+
return `CREATE ${unique}INDEX ${indexName} ON ${local.name} (${fields})`;
|
|
1553
|
+
});
|
|
1563
1554
|
return {
|
|
1564
1555
|
id: local.id,
|
|
1565
1556
|
name: local.name,
|
|
@@ -1632,15 +1623,24 @@ function fieldsDiffer(local, remote) {
|
|
|
1632
1623
|
if (localMax !== remoteMax) return true;
|
|
1633
1624
|
return false;
|
|
1634
1625
|
}
|
|
1635
|
-
function localIndexesToSql(local
|
|
1626
|
+
function localIndexesToSql(local) {
|
|
1636
1627
|
if (!local.indexes || local.indexes.length === 0) return [];
|
|
1637
|
-
return local.indexes.map((idx) =>
|
|
1628
|
+
return local.indexes.map((idx) => {
|
|
1629
|
+
const fields = idx.fields.join(", ");
|
|
1630
|
+
const unique = idx.unique ? "UNIQUE " : "";
|
|
1631
|
+
const indexName = `idx_${local.id}_${idx.fields.join("_")}`;
|
|
1632
|
+
return `CREATE ${unique}INDEX ${indexName} ON ${local.name} (${fields})`;
|
|
1633
|
+
}).sort();
|
|
1638
1634
|
}
|
|
1639
1635
|
function normalizeRemoteIndexes(remoteIndexes) {
|
|
1640
|
-
return
|
|
1636
|
+
return remoteIndexes.filter((idx) => {
|
|
1637
|
+
const lower = idx.toLowerCase();
|
|
1638
|
+
if (lower.includes("external_id") || lower.includes("updated")) return false;
|
|
1639
|
+
return true;
|
|
1640
|
+
}).sort();
|
|
1641
1641
|
}
|
|
1642
|
-
function indexesDiffer(local, remoteIndexes
|
|
1643
|
-
const localSql = localIndexesToSql(local
|
|
1642
|
+
function indexesDiffer(local, remoteIndexes) {
|
|
1643
|
+
const localSql = localIndexesToSql(local);
|
|
1644
1644
|
const remoteSql = normalizeRemoteIndexes(remoteIndexes);
|
|
1645
1645
|
if (localSql.length !== remoteSql.length) return true;
|
|
1646
1646
|
for (let i = 0; i < localSql.length; i++) {
|
|
@@ -1668,12 +1668,27 @@ function normalizeCollectionSearch(search) {
|
|
|
1668
1668
|
} : {}
|
|
1669
1669
|
});
|
|
1670
1670
|
}
|
|
1671
|
-
async function planCollections(api, localCollections
|
|
1671
|
+
async function planCollections(api, localCollections) {
|
|
1672
1672
|
const changes = [];
|
|
1673
1673
|
const remoteCollections = await api.listCollections();
|
|
1674
1674
|
const remoteById = new Map(remoteCollections.map((c) => [c.id, c]));
|
|
1675
1675
|
for (const local of localCollections) {
|
|
1676
|
-
|
|
1676
|
+
let remote = remoteById.get(local.id);
|
|
1677
|
+
if (!remote) {
|
|
1678
|
+
const refs = [.../* @__PURE__ */ new Set([local.id, local.name])];
|
|
1679
|
+
for (const ref of refs) {
|
|
1680
|
+
try {
|
|
1681
|
+
const candidate = await api.getCollection(ref);
|
|
1682
|
+
const isExactLegacy = !candidate.managed && !candidate.project_id && (candidate.id === local.id || candidate.name === local.name);
|
|
1683
|
+
if (isExactLegacy) {
|
|
1684
|
+
remote = candidate;
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
} catch (error3) {
|
|
1688
|
+
if (!isApiErrorStatus(error3, 404)) throw error3;
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1677
1692
|
if (!remote) {
|
|
1678
1693
|
changes.push({
|
|
1679
1694
|
type: "create",
|
|
@@ -1707,11 +1722,12 @@ async function planCollections(api, localCollections, appName) {
|
|
|
1707
1722
|
modified.push(name);
|
|
1708
1723
|
}
|
|
1709
1724
|
}
|
|
1710
|
-
const indexesChanged = indexesDiffer(local, remote.indexes || []
|
|
1725
|
+
const indexesChanged = indexesDiffer(local, remote.indexes || []);
|
|
1711
1726
|
const searchChanged = normalizeCollectionSearch(local.search) !== normalizeCollectionSearch(remote.search);
|
|
1712
1727
|
const auditChanged = local.audit !== void 0 && local.audit !== remote.audit;
|
|
1713
1728
|
if (added.length > 0 || removed.length > 0 || modified.length > 0 || indexesChanged || searchChanged || auditChanged) {
|
|
1714
1729
|
const details = [];
|
|
1730
|
+
if (!remote.project_id) details.push("legacy unscoped collection");
|
|
1715
1731
|
if (added.length > 0) details.push(`+${added.length} field${added.length > 1 ? "s" : ""}`);
|
|
1716
1732
|
if (removed.length > 0) details.push(`-${removed.length} field${removed.length > 1 ? "s" : ""}`);
|
|
1717
1733
|
if (modified.length > 0) details.push(`~${modified.length} field${modified.length > 1 ? "s" : ""} (${modified.join(", ")})`);
|
|
@@ -1976,7 +1992,7 @@ async function planHooks(api, localHooks, collections, projectId) {
|
|
|
1976
1992
|
}
|
|
1977
1993
|
return changes;
|
|
1978
1994
|
}
|
|
1979
|
-
async function applyCollections(api, localCollections
|
|
1995
|
+
async function applyCollections(api, localCollections) {
|
|
1980
1996
|
let errors = 0;
|
|
1981
1997
|
const hasRelations = localCollections.some((c) => c.fields.some((f) => f.type === "relation"));
|
|
1982
1998
|
if (hasRelations) {
|
|
@@ -1993,7 +2009,7 @@ async function applyCollections(api, localCollections, appName) {
|
|
|
1993
2009
|
}
|
|
1994
2010
|
for (const local of localCollections) {
|
|
1995
2011
|
if (pass1Failed.has(local.name)) continue;
|
|
1996
|
-
const apiFormat = convertCollectionToApiFormat(local
|
|
2012
|
+
const apiFormat = convertCollectionToApiFormat(local);
|
|
1997
2013
|
try {
|
|
1998
2014
|
await api.ensureCollection(local.name, apiFormat);
|
|
1999
2015
|
console.log(pc2.green(" \u2713"), `${local.name} (schema)`);
|
|
@@ -2004,7 +2020,7 @@ async function applyCollections(api, localCollections, appName) {
|
|
|
2004
2020
|
}
|
|
2005
2021
|
} else {
|
|
2006
2022
|
for (const local of localCollections) {
|
|
2007
|
-
const apiFormat = convertCollectionToApiFormat(local
|
|
2023
|
+
const apiFormat = convertCollectionToApiFormat(local);
|
|
2008
2024
|
try {
|
|
2009
2025
|
await api.ensureCollection(local.name, apiFormat);
|
|
2010
2026
|
console.log(pc2.green(" \u2713"), `${local.name}`);
|
|
@@ -3266,7 +3282,7 @@ async function plan(args) {
|
|
|
3266
3282
|
if (!type || type === "collections") {
|
|
3267
3283
|
const localCollections = loadLocalCollections(platformDir, name || void 0);
|
|
3268
3284
|
if (localCollections.length > 0) {
|
|
3269
|
-
const changes = await planCollections(api, localCollections
|
|
3285
|
+
const changes = await planCollections(api, localCollections);
|
|
3270
3286
|
allChanges.push(...changes);
|
|
3271
3287
|
}
|
|
3272
3288
|
}
|
|
@@ -3413,7 +3429,7 @@ async function apply(args) {
|
|
|
3413
3429
|
const localHooks = !type || type === "hooks" ? loadLocalHooks(platformDir, name || void 0, appName) : [];
|
|
3414
3430
|
const localAgents = !type || type === "agents" ? loadLocalAgents(platformDir, name || void 0, appName) : [];
|
|
3415
3431
|
const localMailboxes = !type || type === "mailboxes" ? loadLocalMailboxes(platformDir, name || void 0) : [];
|
|
3416
|
-
if (localCollections.length > 0) allChanges.push(...await planCollections(api, localCollections
|
|
3432
|
+
if (localCollections.length > 0) allChanges.push(...await planCollections(api, localCollections));
|
|
3417
3433
|
if (localAutomations.length > 0) allChanges.push(...await planAutomations(api, localAutomations, projectId));
|
|
3418
3434
|
if (localHooks.length > 0) allChanges.push(...await planHooks(api, localHooks, collections, projectId));
|
|
3419
3435
|
if (localAgents.length > 0) allChanges.push(...await planAgents(api, localAgents, projectId));
|
|
@@ -3488,7 +3504,7 @@ async function apply(args) {
|
|
|
3488
3504
|
let totalSkipped = 0;
|
|
3489
3505
|
if (localCollections.length > 0) {
|
|
3490
3506
|
console.log(pc2.bold(" Collections:"));
|
|
3491
|
-
totalErrors += await applyCollections(api, localCollections
|
|
3507
|
+
totalErrors += await applyCollections(api, localCollections);
|
|
3492
3508
|
console.log();
|
|
3493
3509
|
}
|
|
3494
3510
|
try {
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "./chunk-2CR762KB.js";
|
|
4
4
|
import {
|
|
5
5
|
createApiClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FHHWIV4C.js";
|
|
7
7
|
import {
|
|
8
8
|
findProjectRoot,
|
|
9
9
|
getApiUrl,
|
|
10
10
|
getAppName,
|
|
11
11
|
getToken,
|
|
12
12
|
init_auth
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JLVVHTBY.js";
|
|
14
14
|
import {
|
|
15
15
|
fetchWithRetry
|
|
16
16
|
} from "./chunk-FJFIWC7G.js";
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
slugToDirName,
|
|
9
9
|
slugToFilename,
|
|
10
10
|
syncClaudeMd
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-VL5GDJKU.js";
|
|
12
|
+
import "./chunk-JLVVHTBY.js";
|
|
13
13
|
import "./chunk-FJFIWC7G.js";
|
|
14
14
|
import "./chunk-PNKVD2UK.js";
|
|
15
15
|
|
package/package.json
CHANGED