@abloatai/ablo 0.22.1 → 0.24.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 +62 -0
- package/dist/BaseSyncedStore.js +15 -11
- package/dist/Database.js +3 -3
- package/dist/ObjectPool.js +14 -4
- package/dist/SyncClient.js +18 -4
- package/dist/agent/Agent.js +5 -3
- package/dist/agent/session.js +9 -6
- package/dist/ai-sdk/coordinated-tool.d.ts +101 -0
- package/dist/ai-sdk/coordinated-tool.js +129 -0
- package/dist/ai-sdk/index.d.ts +42 -0
- package/dist/ai-sdk/index.js +42 -0
- package/dist/cli.cjs +687 -498
- package/dist/client/Ablo.d.ts +14 -2
- package/dist/client/Ablo.js +23 -9
- package/dist/client/ApiClient.js +28 -6
- package/dist/client/createModelProxy.js +6 -1
- package/dist/client/httpClient.d.ts +6 -1
- package/dist/client/identity.js +1 -1
- package/dist/core/DatabaseManager.js +1 -1
- package/dist/core/StoreManager.js +5 -2
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/mutators/UndoManager.js +7 -6
- package/dist/query/client.js +19 -5
- package/dist/react/useMutators.js +6 -2
- package/dist/sync/BootstrapHelper.d.ts +16 -0
- package/dist/sync/BootstrapHelper.js +29 -2
- package/dist/sync/ConnectionManager.js +7 -7
- package/dist/sync/NetworkProbe.js +2 -2
- package/dist/sync/SyncWebSocket.js +2 -2
- package/dist/sync/schemas.d.ts +1 -0
- package/dist/sync/schemas.js +3 -0
- package/dist/transactions/TransactionQueue.js +37 -7
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -4850,8 +4850,8 @@ var require_typescript = __commonJS({
|
|
|
4850
4850
|
let count = 0;
|
|
4851
4851
|
if (array !== void 0) {
|
|
4852
4852
|
for (let i = 0; i < array.length; i++) {
|
|
4853
|
-
const
|
|
4854
|
-
if (predicate(
|
|
4853
|
+
const v2 = array[i];
|
|
4854
|
+
if (predicate(v2, i)) {
|
|
4855
4855
|
count++;
|
|
4856
4856
|
}
|
|
4857
4857
|
}
|
|
@@ -4926,12 +4926,12 @@ var require_typescript = __commonJS({
|
|
|
4926
4926
|
function flatten(array) {
|
|
4927
4927
|
const result = [];
|
|
4928
4928
|
for (let i = 0; i < array.length; i++) {
|
|
4929
|
-
const
|
|
4930
|
-
if (
|
|
4931
|
-
if (isArray(
|
|
4932
|
-
addRange(result,
|
|
4929
|
+
const v2 = array[i];
|
|
4930
|
+
if (v2) {
|
|
4931
|
+
if (isArray(v2)) {
|
|
4932
|
+
addRange(result, v2);
|
|
4933
4933
|
} else {
|
|
4934
|
-
result.push(
|
|
4934
|
+
result.push(v2);
|
|
4935
4935
|
}
|
|
4936
4936
|
}
|
|
4937
4937
|
}
|
|
@@ -4941,12 +4941,12 @@ var require_typescript = __commonJS({
|
|
|
4941
4941
|
let result;
|
|
4942
4942
|
if (array !== void 0) {
|
|
4943
4943
|
for (let i = 0; i < array.length; i++) {
|
|
4944
|
-
const
|
|
4945
|
-
if (
|
|
4946
|
-
if (isArray(
|
|
4947
|
-
result = addRange(result,
|
|
4944
|
+
const v2 = mapfn(array[i], i);
|
|
4945
|
+
if (v2) {
|
|
4946
|
+
if (isArray(v2)) {
|
|
4947
|
+
result = addRange(result, v2);
|
|
4948
4948
|
} else {
|
|
4949
|
-
result = append(result,
|
|
4949
|
+
result = append(result, v2);
|
|
4950
4950
|
}
|
|
4951
4951
|
}
|
|
4952
4952
|
}
|
|
@@ -4957,12 +4957,12 @@ var require_typescript = __commonJS({
|
|
|
4957
4957
|
const result = [];
|
|
4958
4958
|
if (array !== void 0) {
|
|
4959
4959
|
for (let i = 0; i < array.length; i++) {
|
|
4960
|
-
const
|
|
4961
|
-
if (
|
|
4962
|
-
if (isArray(
|
|
4963
|
-
addRange(result,
|
|
4960
|
+
const v2 = mapfn(array[i], i);
|
|
4961
|
+
if (v2) {
|
|
4962
|
+
if (isArray(v2)) {
|
|
4963
|
+
addRange(result, v2);
|
|
4964
4964
|
} else {
|
|
4965
|
-
result.push(
|
|
4965
|
+
result.push(v2);
|
|
4966
4966
|
}
|
|
4967
4967
|
}
|
|
4968
4968
|
}
|
|
@@ -5066,9 +5066,9 @@ var require_typescript = __commonJS({
|
|
|
5066
5066
|
pos++;
|
|
5067
5067
|
}
|
|
5068
5068
|
if (start < pos) {
|
|
5069
|
-
const
|
|
5070
|
-
if (
|
|
5071
|
-
result.push(
|
|
5069
|
+
const v2 = mapfn(array.slice(start, pos), previousKey, start, pos);
|
|
5070
|
+
if (v2) {
|
|
5071
|
+
result.push(v2);
|
|
5072
5072
|
}
|
|
5073
5073
|
start = pos;
|
|
5074
5074
|
}
|
|
@@ -5224,11 +5224,11 @@ var require_typescript = __commonJS({
|
|
|
5224
5224
|
let result;
|
|
5225
5225
|
if (array !== void 0) {
|
|
5226
5226
|
for (let i = 0; i < array.length; i++) {
|
|
5227
|
-
const
|
|
5228
|
-
if (result ?? !
|
|
5227
|
+
const v2 = array[i];
|
|
5228
|
+
if (result ?? !v2) {
|
|
5229
5229
|
result ?? (result = array.slice(0, i));
|
|
5230
|
-
if (
|
|
5231
|
-
result.push(
|
|
5230
|
+
if (v2) {
|
|
5231
|
+
result.push(v2);
|
|
5232
5232
|
}
|
|
5233
5233
|
}
|
|
5234
5234
|
}
|
|
@@ -6055,11 +6055,11 @@ var require_typescript = __commonJS({
|
|
|
6055
6055
|
let matchedValue;
|
|
6056
6056
|
let longestMatchPrefixLength = -1;
|
|
6057
6057
|
for (let i = 0; i < values2.length; i++) {
|
|
6058
|
-
const
|
|
6059
|
-
const pattern = getPattern(
|
|
6058
|
+
const v2 = values2[i];
|
|
6059
|
+
const pattern = getPattern(v2);
|
|
6060
6060
|
if (pattern.prefix.length > longestMatchPrefixLength && isPatternMatch(pattern, candidate)) {
|
|
6061
6061
|
longestMatchPrefixLength = pattern.prefix.length;
|
|
6062
|
-
matchedValue =
|
|
6062
|
+
matchedValue = v2;
|
|
6063
6063
|
}
|
|
6064
6064
|
}
|
|
6065
6065
|
return matchedValue;
|
|
@@ -6323,8 +6323,8 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
|
|
|
6323
6323
|
}
|
|
6324
6324
|
Debug2.checkDefined = checkDefined;
|
|
6325
6325
|
function assertEachIsDefined(value, message, stackCrawlMark) {
|
|
6326
|
-
for (const
|
|
6327
|
-
assertIsDefined(
|
|
6326
|
+
for (const v2 of value) {
|
|
6327
|
+
assertIsDefined(v2, message, stackCrawlMark || assertEachIsDefined);
|
|
6328
6328
|
}
|
|
6329
6329
|
}
|
|
6330
6330
|
Debug2.assertEachIsDefined = assertEachIsDefined;
|
|
@@ -7695,7 +7695,7 @@ ${lanes.join("\n")}
|
|
|
7695
7695
|
const meta = { cat: "__metadata", ph: "M", ts: 1e3 * timestamp(), pid: 1, tid: 1 };
|
|
7696
7696
|
fs2.writeSync(
|
|
7697
7697
|
traceFd,
|
|
7698
|
-
"[\n" + [{ name: "process_name", args: { name: "tsc" }, ...meta }, { name: "thread_name", args: { name: "Main" }, ...meta }, { name: "TracingStartedInBrowser", ...meta, cat: "disabled-by-default-devtools.timeline" }].map((
|
|
7698
|
+
"[\n" + [{ name: "process_name", args: { name: "tsc" }, ...meta }, { name: "thread_name", args: { name: "Main" }, ...meta }, { name: "TracingStartedInBrowser", ...meta, cat: "disabled-by-default-devtools.timeline" }].map((v2) => JSON.stringify(v2)).join(",\n")
|
|
7699
7699
|
);
|
|
7700
7700
|
}
|
|
7701
7701
|
tracingEnabled2.startTracing = startTracing2;
|
|
@@ -21820,8 +21820,8 @@ ${lanes.join("\n")}
|
|
|
21820
21820
|
function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
|
|
21821
21821
|
switch (node.kind) {
|
|
21822
21822
|
case 243:
|
|
21823
|
-
const
|
|
21824
|
-
return
|
|
21823
|
+
const v2 = getSingleVariableOfVariableStatement(node);
|
|
21824
|
+
return v2 && v2.initializer;
|
|
21825
21825
|
case 172:
|
|
21826
21826
|
return node.initializer;
|
|
21827
21827
|
case 303:
|
|
@@ -47572,14 +47572,14 @@ ${lanes.join("\n")}
|
|
|
47572
47572
|
const values2 = value.split(",");
|
|
47573
47573
|
switch (opt.element.type) {
|
|
47574
47574
|
case "number":
|
|
47575
|
-
return mapDefined(values2, (
|
|
47575
|
+
return mapDefined(values2, (v2) => validateJsonOptionValue(opt.element, parseInt(v2), errors));
|
|
47576
47576
|
case "string":
|
|
47577
|
-
return mapDefined(values2, (
|
|
47577
|
+
return mapDefined(values2, (v2) => validateJsonOptionValue(opt.element, v2 || "", errors));
|
|
47578
47578
|
case "boolean":
|
|
47579
47579
|
case "object":
|
|
47580
47580
|
return Debug.fail(`List of ${opt.element.type} is not yet supported.`);
|
|
47581
47581
|
default:
|
|
47582
|
-
return mapDefined(values2, (
|
|
47582
|
+
return mapDefined(values2, (v2) => parseCustomTypeOption(opt.element, v2, errors));
|
|
47583
47583
|
}
|
|
47584
47584
|
}
|
|
47585
47585
|
function getOptionName(option) {
|
|
@@ -48060,7 +48060,7 @@ ${lanes.join("\n")}
|
|
|
48060
48060
|
elements.forEach((element) => convertPropertyValueToJson(element, elementOption));
|
|
48061
48061
|
return void 0;
|
|
48062
48062
|
}
|
|
48063
|
-
return filter(elements.map((element) => convertPropertyValueToJson(element, elementOption)), (
|
|
48063
|
+
return filter(elements.map((element) => convertPropertyValueToJson(element, elementOption)), (v2) => v2 !== void 0);
|
|
48064
48064
|
}
|
|
48065
48065
|
function convertPropertyValueToJson(valueExpression, option) {
|
|
48066
48066
|
switch (valueExpression.kind) {
|
|
@@ -48255,7 +48255,7 @@ ${lanes.join("\n")}
|
|
|
48255
48255
|
if (pathOptions && optionDefinition.isFilePath) {
|
|
48256
48256
|
result.set(name, getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(value, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
|
|
48257
48257
|
} else if (pathOptions && optionDefinition.type === "list" && optionDefinition.element.isFilePath) {
|
|
48258
|
-
result.set(name, value.map((
|
|
48258
|
+
result.set(name, value.map((v2) => getRelativePathFromFile(pathOptions.configFilePath, getNormalizedAbsolutePath(v2, getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName)));
|
|
48259
48259
|
} else {
|
|
48260
48260
|
result.set(name, value);
|
|
48261
48261
|
}
|
|
@@ -49063,7 +49063,7 @@ ${lanes.join("\n")}
|
|
|
49063
49063
|
}
|
|
49064
49064
|
}
|
|
49065
49065
|
function convertJsonOptionOfListType(option, values2, basePath, errors, propertyAssignment, valueExpression, sourceFile) {
|
|
49066
|
-
return filter(map(values2, (
|
|
49066
|
+
return filter(map(values2, (v2, index) => convertJsonOption(option.element, v2, basePath, errors, propertyAssignment, valueExpression == null ? void 0 : valueExpression.elements[index], sourceFile)), (v2) => option.listPreserveFalsyValues ? true : !!v2);
|
|
49067
49067
|
}
|
|
49068
49068
|
var invalidTrailingRecursionPattern = /(?:^|\/)\*\*\/?$/;
|
|
49069
49069
|
var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
|
|
@@ -49325,7 +49325,7 @@ ${lanes.join("\n")}
|
|
|
49325
49325
|
// fall through to list
|
|
49326
49326
|
case "list":
|
|
49327
49327
|
const elementType = option.element;
|
|
49328
|
-
return isArray(value) ? mapDefined(value, (
|
|
49328
|
+
return isArray(value) ? mapDefined(value, (v2) => getOptionValueWithEmptyStrings(v2, elementType)) : "";
|
|
49329
49329
|
default:
|
|
49330
49330
|
return forEachEntry(option.type, (optionEnumValue, optionStringValue) => {
|
|
49331
49331
|
if (optionEnumValue === value) {
|
|
@@ -69653,9 +69653,9 @@ ${lanes.join("\n")}
|
|
|
69653
69653
|
return getBaseConstraint(getSubstitutionIntersection(t));
|
|
69654
69654
|
}
|
|
69655
69655
|
if (isGenericTupleType(t)) {
|
|
69656
|
-
const newElements = map(getElementTypes(t), (
|
|
69657
|
-
const constraint =
|
|
69658
|
-
return constraint !==
|
|
69656
|
+
const newElements = map(getElementTypes(t), (v2, i) => {
|
|
69657
|
+
const constraint = v2.flags & 262144 && t.target.elementFlags[i] & 8 && getBaseConstraint(v2) || v2;
|
|
69658
|
+
return constraint !== v2 && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v2;
|
|
69659
69659
|
});
|
|
69660
69660
|
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
|
|
69661
69661
|
}
|
|
@@ -77429,7 +77429,7 @@ ${lanes.join("\n")}
|
|
|
77429
77429
|
if (result2 = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors2, intersectionState2)) {
|
|
77430
77430
|
return result2;
|
|
77431
77431
|
}
|
|
77432
|
-
if (some(variances, (
|
|
77432
|
+
if (some(variances, (v2) => !!(v2 & 24))) {
|
|
77433
77433
|
originalErrorInfo = void 0;
|
|
77434
77434
|
resetErrorInfo(saveErrorInfo);
|
|
77435
77435
|
return void 0;
|
|
@@ -77439,7 +77439,7 @@ ${lanes.join("\n")}
|
|
|
77439
77439
|
if (variances !== emptyArray && !allowStructuralFallback) {
|
|
77440
77440
|
if (varianceCheckFailed && !(reportErrors2 && some(
|
|
77441
77441
|
variances,
|
|
77442
|
-
(
|
|
77442
|
+
(v2) => (v2 & 7) === 0
|
|
77443
77443
|
/* Invariant */
|
|
77444
77444
|
))) {
|
|
77445
77445
|
return 0;
|
|
@@ -140817,7 +140817,7 @@ ${lanes.join("\n")}
|
|
|
140817
140817
|
function createManyToManyPathMap() {
|
|
140818
140818
|
function create2(forward, reverse, deleted) {
|
|
140819
140819
|
const map2 = {
|
|
140820
|
-
getKeys: (
|
|
140820
|
+
getKeys: (v2) => reverse.get(v2),
|
|
140821
140821
|
getValues: (k3) => forward.get(k3),
|
|
140822
140822
|
keys: () => forward.keys(),
|
|
140823
140823
|
size: () => forward.size,
|
|
@@ -140827,7 +140827,7 @@ ${lanes.join("\n")}
|
|
|
140827
140827
|
if (!set) {
|
|
140828
140828
|
return false;
|
|
140829
140829
|
}
|
|
140830
|
-
set.forEach((
|
|
140830
|
+
set.forEach((v2) => deleteFromMultimap(reverse, v2, k3));
|
|
140831
140831
|
forward.delete(k3);
|
|
140832
140832
|
return true;
|
|
140833
140833
|
},
|
|
@@ -140835,14 +140835,14 @@ ${lanes.join("\n")}
|
|
|
140835
140835
|
deleted == null ? void 0 : deleted.delete(k3);
|
|
140836
140836
|
const existingVSet = forward.get(k3);
|
|
140837
140837
|
forward.set(k3, vSet);
|
|
140838
|
-
existingVSet == null ? void 0 : existingVSet.forEach((
|
|
140839
|
-
if (!vSet.has(
|
|
140840
|
-
deleteFromMultimap(reverse,
|
|
140838
|
+
existingVSet == null ? void 0 : existingVSet.forEach((v2) => {
|
|
140839
|
+
if (!vSet.has(v2)) {
|
|
140840
|
+
deleteFromMultimap(reverse, v2, k3);
|
|
140841
140841
|
}
|
|
140842
140842
|
});
|
|
140843
|
-
vSet.forEach((
|
|
140844
|
-
if (!(existingVSet == null ? void 0 : existingVSet.has(
|
|
140845
|
-
addToMultimap(reverse,
|
|
140843
|
+
vSet.forEach((v2) => {
|
|
140844
|
+
if (!(existingVSet == null ? void 0 : existingVSet.has(v2))) {
|
|
140845
|
+
addToMultimap(reverse, v2, k3);
|
|
140846
140846
|
}
|
|
140847
140847
|
});
|
|
140848
140848
|
return map2;
|
|
@@ -140858,17 +140858,17 @@ ${lanes.join("\n")}
|
|
|
140858
140858
|
);
|
|
140859
140859
|
}
|
|
140860
140860
|
BuilderState2.createManyToManyPathMap = createManyToManyPathMap;
|
|
140861
|
-
function addToMultimap(map2, k3,
|
|
140861
|
+
function addToMultimap(map2, k3, v2) {
|
|
140862
140862
|
let set = map2.get(k3);
|
|
140863
140863
|
if (!set) {
|
|
140864
140864
|
set = /* @__PURE__ */ new Set();
|
|
140865
140865
|
map2.set(k3, set);
|
|
140866
140866
|
}
|
|
140867
|
-
set.add(
|
|
140867
|
+
set.add(v2);
|
|
140868
140868
|
}
|
|
140869
|
-
function deleteFromMultimap(map2, k3,
|
|
140869
|
+
function deleteFromMultimap(map2, k3, v2) {
|
|
140870
140870
|
const set = map2.get(k3);
|
|
140871
|
-
if (set == null ? void 0 : set.delete(
|
|
140871
|
+
if (set == null ? void 0 : set.delete(v2)) {
|
|
140872
140872
|
if (!set.size) {
|
|
140873
140873
|
map2.delete(k3);
|
|
140874
140874
|
}
|
|
@@ -147186,7 +147186,7 @@ ${lanes.join("\n")}
|
|
|
147186
147186
|
return options.pretty;
|
|
147187
147187
|
}
|
|
147188
147188
|
function getOptionsForHelp(commandLine) {
|
|
147189
|
-
return !!commandLine.options.all ? toSorted(optionDeclarations.concat(tscBuildOption), (a, b4) => compareStringsCaseInsensitive(a.name, b4.name)) : filter(optionDeclarations.concat(tscBuildOption), (
|
|
147189
|
+
return !!commandLine.options.all ? toSorted(optionDeclarations.concat(tscBuildOption), (a, b4) => compareStringsCaseInsensitive(a.name, b4.name)) : filter(optionDeclarations.concat(tscBuildOption), (v2) => !!v2.showInSimplifiedHelpView);
|
|
147190
147190
|
}
|
|
147191
147191
|
function printVersion(sys2) {
|
|
147192
147192
|
sys2.write(getDiagnosticText(Diagnostics.Version_0, version) + sys2.newLine);
|
|
@@ -150589,8 +150589,8 @@ ${lanes.join("\n")}
|
|
|
150589
150589
|
default:
|
|
150590
150590
|
return "";
|
|
150591
150591
|
}
|
|
150592
|
-
function getKindOfVariableDeclaration(
|
|
150593
|
-
return isVarConst(
|
|
150592
|
+
function getKindOfVariableDeclaration(v2) {
|
|
150593
|
+
return isVarConst(v2) ? "const" : isLet(v2) ? "let" : "var";
|
|
150594
150594
|
}
|
|
150595
150595
|
}
|
|
150596
150596
|
function isThis(node) {
|
|
@@ -156679,7 +156679,7 @@ interface Symbol {
|
|
|
156679
156679
|
}
|
|
156680
156680
|
var commandLineOptionsStringToEnum;
|
|
156681
156681
|
function fixupCompilerOptions(options, diagnostics) {
|
|
156682
|
-
commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, (o2) => typeof o2.type === "object" && !forEachEntry(o2.type, (
|
|
156682
|
+
commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, (o2) => typeof o2.type === "object" && !forEachEntry(o2.type, (v2) => typeof v2 !== "number"));
|
|
156683
156683
|
options = cloneCompilerOptions(options);
|
|
156684
156684
|
for (const opt of commandLineOptionsStringToEnum) {
|
|
156685
156685
|
if (!hasProperty(options, opt.name)) {
|
|
@@ -156689,7 +156689,7 @@ interface Symbol {
|
|
|
156689
156689
|
if (isString(value)) {
|
|
156690
156690
|
options[opt.name] = parseCustomTypeOption(opt, value, diagnostics);
|
|
156691
156691
|
} else {
|
|
156692
|
-
if (!forEachEntry(opt.type, (
|
|
156692
|
+
if (!forEachEntry(opt.type, (v2) => v2 === value)) {
|
|
156693
156693
|
diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
|
156694
156694
|
}
|
|
156695
156695
|
}
|
|
@@ -162506,12 +162506,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
162506
162506
|
}
|
|
162507
162507
|
}
|
|
162508
162508
|
function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes) {
|
|
162509
|
-
const variableAssignments = map(exposedVariableDeclarations, (
|
|
162509
|
+
const variableAssignments = map(exposedVariableDeclarations, (v2) => factory.createShorthandPropertyAssignment(v2.symbol.name));
|
|
162510
162510
|
const writeAssignments = map(writes, (w2) => factory.createShorthandPropertyAssignment(w2.symbol.name));
|
|
162511
162511
|
return variableAssignments === void 0 ? writeAssignments : writeAssignments === void 0 ? variableAssignments : variableAssignments.concat(writeAssignments);
|
|
162512
162512
|
}
|
|
162513
|
-
function isReadonlyArray(
|
|
162514
|
-
return isArray(
|
|
162513
|
+
function isReadonlyArray(v2) {
|
|
162514
|
+
return isArray(v2);
|
|
162515
162515
|
}
|
|
162516
162516
|
function getEnclosingTextRange(targetRange, sourceFile) {
|
|
162517
162517
|
return isReadonlyArray(targetRange.range) ? { pos: first(targetRange.range).getStart(sourceFile), end: last(targetRange.range).getEnd() } : targetRange.range;
|
|
@@ -200579,19 +200579,19 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
200579
200579
|
}
|
|
200580
200580
|
const set = /* @__PURE__ */ new Map();
|
|
200581
200581
|
let unique = 0;
|
|
200582
|
-
for (const
|
|
200583
|
-
if (set.get(
|
|
200584
|
-
set.set(
|
|
200582
|
+
for (const v2 of arr1) {
|
|
200583
|
+
if (set.get(v2) !== true) {
|
|
200584
|
+
set.set(v2, true);
|
|
200585
200585
|
unique++;
|
|
200586
200586
|
}
|
|
200587
200587
|
}
|
|
200588
|
-
for (const
|
|
200589
|
-
const isSet = set.get(
|
|
200588
|
+
for (const v2 of arr2) {
|
|
200589
|
+
const isSet = set.get(v2);
|
|
200590
200590
|
if (isSet === void 0) {
|
|
200591
200591
|
return false;
|
|
200592
200592
|
}
|
|
200593
200593
|
if (isSet === true) {
|
|
200594
|
-
set.set(
|
|
200594
|
+
set.set(v2, false);
|
|
200595
200595
|
unique--;
|
|
200596
200596
|
}
|
|
200597
200597
|
}
|
|
@@ -211969,10 +211969,10 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
211969
211969
|
}
|
|
211970
211970
|
})({ get exports() {
|
|
211971
211971
|
return ts;
|
|
211972
|
-
}, set exports(
|
|
211973
|
-
ts =
|
|
211972
|
+
}, set exports(v2) {
|
|
211973
|
+
ts = v2;
|
|
211974
211974
|
if (typeof module2 !== "undefined" && module2.exports) {
|
|
211975
|
-
module2.exports =
|
|
211975
|
+
module2.exports = v2;
|
|
211976
211976
|
}
|
|
211977
211977
|
} });
|
|
211978
211978
|
}
|
|
@@ -214992,10 +214992,10 @@ var require_fill_range = __commonJS({
|
|
|
214992
214992
|
let negatives = "";
|
|
214993
214993
|
let result;
|
|
214994
214994
|
if (parts.positives.length) {
|
|
214995
|
-
positives = parts.positives.map((
|
|
214995
|
+
positives = parts.positives.map((v2) => toMaxLen(String(v2), maxLen)).join("|");
|
|
214996
214996
|
}
|
|
214997
214997
|
if (parts.negatives.length) {
|
|
214998
|
-
negatives = `-(${prefix2}${parts.negatives.map((
|
|
214998
|
+
negatives = `-(${prefix2}${parts.negatives.map((v2) => toMaxLen(String(v2), maxLen)).join("|")})`;
|
|
214999
214999
|
}
|
|
215000
215000
|
if (positives && negatives) {
|
|
215001
215001
|
result = `${positives}|${negatives}`;
|
|
@@ -216301,7 +216301,7 @@ var require_parse2 = __commonJS({
|
|
|
216301
216301
|
try {
|
|
216302
216302
|
new RegExp(value);
|
|
216303
216303
|
} catch (ex) {
|
|
216304
|
-
return args.map((
|
|
216304
|
+
return args.map((v2) => utils.escapeRegex(v2)).join("..");
|
|
216305
216305
|
}
|
|
216306
216306
|
return value;
|
|
216307
216307
|
};
|
|
@@ -217441,10 +217441,10 @@ var require_micromatch = __commonJS({
|
|
|
217441
217441
|
var braces = require_braces();
|
|
217442
217442
|
var picomatch = require_picomatch2();
|
|
217443
217443
|
var utils = require_utils2();
|
|
217444
|
-
var isEmptyString = (
|
|
217445
|
-
var hasBraces = (
|
|
217446
|
-
const index =
|
|
217447
|
-
return index > -1 &&
|
|
217444
|
+
var isEmptyString = (v2) => v2 === "" || v2 === "./";
|
|
217445
|
+
var hasBraces = (v2) => {
|
|
217446
|
+
const index = v2.indexOf("{");
|
|
217447
|
+
return index > -1 && v2.indexOf("}", index) > -1;
|
|
217448
217448
|
};
|
|
217449
217449
|
var micromatch = (list, patterns, options) => {
|
|
217450
217450
|
patterns = [].concat(patterns);
|
|
@@ -217564,7 +217564,7 @@ var require_micromatch = __commonJS({
|
|
|
217564
217564
|
let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
|
|
217565
217565
|
let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
|
|
217566
217566
|
if (match) {
|
|
217567
|
-
return match.slice(1).map((
|
|
217567
|
+
return match.slice(1).map((v2) => v2 === void 0 ? "" : v2);
|
|
217568
217568
|
}
|
|
217569
217569
|
};
|
|
217570
217570
|
micromatch.makeRe = (...args) => picomatch.makeRe(...args);
|
|
@@ -256143,7 +256143,7 @@ var require_ts_morph = __commonJS({
|
|
|
256143
256143
|
errors: result.errors.map((error) => new Diagnostic(void 0, error))
|
|
256144
256144
|
};
|
|
256145
256145
|
}
|
|
256146
|
-
var [tsMajor, tsMinor, tsPatch] = common.ts.version.split(".").map((
|
|
256146
|
+
var [tsMajor, tsMinor, tsPatch] = common.ts.version.split(".").map((v2) => parseInt(v2, 10));
|
|
256147
256147
|
var WriterUtils = class {
|
|
256148
256148
|
constructor() {
|
|
256149
256149
|
}
|
|
@@ -276124,6 +276124,7 @@ var import_node_process = require("process");
|
|
|
276124
276124
|
var g = __toESM(require("readline"), 1);
|
|
276125
276125
|
var import_node_readline = __toESM(require("readline"), 1);
|
|
276126
276126
|
var import_node_stream = require("stream");
|
|
276127
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
276127
276128
|
function DD({ onlyFirst: e2 = false } = {}) {
|
|
276128
276129
|
const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
|
|
276129
276130
|
return new RegExp(t, e2 ? void 0 : "g");
|
|
@@ -276492,10 +276493,26 @@ var LD = class extends x {
|
|
|
276492
276493
|
this.value = this._value.value;
|
|
276493
276494
|
}
|
|
276494
276495
|
};
|
|
276496
|
+
var RD = class extends x {
|
|
276497
|
+
get valueWithCursor() {
|
|
276498
|
+
if (this.state === "submit") return this.value;
|
|
276499
|
+
if (this.cursor >= this.value.length) return `${this.value}\u2588`;
|
|
276500
|
+
const u2 = this.value.slice(0, this.cursor), [t, ...F2] = this.value.slice(this.cursor);
|
|
276501
|
+
return `${u2}${import_picocolors.default.inverse(t)}${F2.join("")}`;
|
|
276502
|
+
}
|
|
276503
|
+
get cursor() {
|
|
276504
|
+
return this._cursor;
|
|
276505
|
+
}
|
|
276506
|
+
constructor(u2) {
|
|
276507
|
+
super(u2), this.on("finalize", () => {
|
|
276508
|
+
this.value || (this.value = u2.defaultValue);
|
|
276509
|
+
});
|
|
276510
|
+
}
|
|
276511
|
+
};
|
|
276495
276512
|
|
|
276496
276513
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
276497
276514
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
276498
|
-
var
|
|
276515
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
276499
276516
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
276500
276517
|
function ce() {
|
|
276501
276518
|
return import_node_process2.default.platform !== "win32" ? import_node_process2.default.env.TERM !== "linux" : !!import_node_process2.default.env.CI || !!import_node_process2.default.env.WT_SESSION || !!import_node_process2.default.env.TERMINUS_SUBLIME || import_node_process2.default.env.ConEmuTask === "{cmd::Cmder}" || import_node_process2.default.env.TERM_PROGRAM === "Terminus-Sublime" || import_node_process2.default.env.TERM_PROGRAM === "vscode" || import_node_process2.default.env.TERM === "xterm-256color" || import_node_process2.default.env.TERM === "alacritty" || import_node_process2.default.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
@@ -276527,13 +276544,13 @@ var b2 = (t) => {
|
|
|
276527
276544
|
switch (t) {
|
|
276528
276545
|
case "initial":
|
|
276529
276546
|
case "active":
|
|
276530
|
-
return
|
|
276547
|
+
return import_picocolors2.default.cyan(le);
|
|
276531
276548
|
case "cancel":
|
|
276532
|
-
return
|
|
276549
|
+
return import_picocolors2.default.red(L2);
|
|
276533
276550
|
case "error":
|
|
276534
|
-
return
|
|
276551
|
+
return import_picocolors2.default.yellow(W2);
|
|
276535
276552
|
case "submit":
|
|
276536
|
-
return
|
|
276553
|
+
return import_picocolors2.default.green(C);
|
|
276537
276554
|
}
|
|
276538
276555
|
};
|
|
276539
276556
|
var G2 = (t) => {
|
|
@@ -276541,26 +276558,47 @@ var G2 = (t) => {
|
|
|
276541
276558
|
let l2 = 0;
|
|
276542
276559
|
n >= l2 + a - 3 ? l2 = Math.max(Math.min(n - a + 3, r2.length - a), 0) : n < l2 + 2 && (l2 = Math.max(n - 2, 0));
|
|
276543
276560
|
const $2 = a < r2.length && l2 > 0, g2 = a < r2.length && l2 + a < r2.length;
|
|
276544
|
-
return r2.slice(l2, l2 + a).map((p2,
|
|
276545
|
-
const j2 =
|
|
276546
|
-
return j2 || E ?
|
|
276561
|
+
return r2.slice(l2, l2 + a).map((p2, v2, f) => {
|
|
276562
|
+
const j2 = v2 === 0 && $2, E = v2 === f.length - 1 && g2;
|
|
276563
|
+
return j2 || E ? import_picocolors2.default.dim("...") : i(p2, v2 + l2 === n);
|
|
276547
276564
|
});
|
|
276548
276565
|
};
|
|
276566
|
+
var he = (t) => new RD({ validate: t.validate, placeholder: t.placeholder, defaultValue: t.defaultValue, initialValue: t.initialValue, render() {
|
|
276567
|
+
const n = `${import_picocolors2.default.gray(o)}
|
|
276568
|
+
${b2(this.state)} ${t.message}
|
|
276569
|
+
`, r2 = t.placeholder ? import_picocolors2.default.inverse(t.placeholder[0]) + import_picocolors2.default.dim(t.placeholder.slice(1)) : import_picocolors2.default.inverse(import_picocolors2.default.hidden("_")), i = this.value ? this.valueWithCursor : r2;
|
|
276570
|
+
switch (this.state) {
|
|
276571
|
+
case "error":
|
|
276572
|
+
return `${n.trim()}
|
|
276573
|
+
${import_picocolors2.default.yellow(o)} ${i}
|
|
276574
|
+
${import_picocolors2.default.yellow(d2)} ${import_picocolors2.default.yellow(this.error)}
|
|
276575
|
+
`;
|
|
276576
|
+
case "submit":
|
|
276577
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(this.value || t.placeholder)}`;
|
|
276578
|
+
case "cancel":
|
|
276579
|
+
return `${n}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(this.value ?? ""))}${this.value?.trim() ? `
|
|
276580
|
+
${import_picocolors2.default.gray(o)}` : ""}`;
|
|
276581
|
+
default:
|
|
276582
|
+
return `${n}${import_picocolors2.default.cyan(o)} ${i}
|
|
276583
|
+
${import_picocolors2.default.cyan(d2)}
|
|
276584
|
+
`;
|
|
276585
|
+
}
|
|
276586
|
+
} }).prompt();
|
|
276549
276587
|
var ye = (t) => {
|
|
276550
276588
|
const n = t.active ?? "Yes", r2 = t.inactive ?? "No";
|
|
276551
276589
|
return new dD({ active: n, inactive: r2, initialValue: t.initialValue ?? true, render() {
|
|
276552
|
-
const i = `${
|
|
276590
|
+
const i = `${import_picocolors2.default.gray(o)}
|
|
276553
276591
|
${b2(this.state)} ${t.message}
|
|
276554
276592
|
`, s = this.value ? n : r2;
|
|
276555
276593
|
switch (this.state) {
|
|
276556
276594
|
case "submit":
|
|
276557
|
-
return `${i}${
|
|
276595
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(s)}`;
|
|
276558
276596
|
case "cancel":
|
|
276559
|
-
return `${i}${
|
|
276560
|
-
${
|
|
276597
|
+
return `${i}${import_picocolors2.default.gray(o)} ${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}
|
|
276598
|
+
${import_picocolors2.default.gray(o)}`;
|
|
276561
276599
|
default:
|
|
276562
|
-
return `${i}${
|
|
276563
|
-
${
|
|
276600
|
+
return `${i}${import_picocolors2.default.cyan(o)} ${this.value ? `${import_picocolors2.default.green(k2)} ${n}` : `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(n)}`} ${import_picocolors2.default.dim("/")} ${this.value ? `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(r2)}` : `${import_picocolors2.default.green(k2)} ${r2}`}
|
|
276601
|
+
${import_picocolors2.default.cyan(d2)}
|
|
276564
276602
|
`;
|
|
276565
276603
|
}
|
|
276566
276604
|
} }).prompt();
|
|
@@ -276570,29 +276608,29 @@ var ve = (t) => {
|
|
|
276570
276608
|
const s = r2.label ?? String(r2.value);
|
|
276571
276609
|
switch (i) {
|
|
276572
276610
|
case "selected":
|
|
276573
|
-
return `${
|
|
276611
|
+
return `${import_picocolors2.default.dim(s)}`;
|
|
276574
276612
|
case "active":
|
|
276575
|
-
return `${
|
|
276613
|
+
return `${import_picocolors2.default.green(k2)} ${s} ${r2.hint ? import_picocolors2.default.dim(`(${r2.hint})`) : ""}`;
|
|
276576
276614
|
case "cancelled":
|
|
276577
|
-
return `${
|
|
276615
|
+
return `${import_picocolors2.default.strikethrough(import_picocolors2.default.dim(s))}`;
|
|
276578
276616
|
default:
|
|
276579
|
-
return `${
|
|
276617
|
+
return `${import_picocolors2.default.dim(P2)} ${import_picocolors2.default.dim(s)}`;
|
|
276580
276618
|
}
|
|
276581
276619
|
};
|
|
276582
276620
|
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
276583
|
-
const r2 = `${
|
|
276621
|
+
const r2 = `${import_picocolors2.default.gray(o)}
|
|
276584
276622
|
${b2(this.state)} ${t.message}
|
|
276585
276623
|
`;
|
|
276586
276624
|
switch (this.state) {
|
|
276587
276625
|
case "submit":
|
|
276588
|
-
return `${r2}${
|
|
276626
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
276589
276627
|
case "cancel":
|
|
276590
|
-
return `${r2}${
|
|
276591
|
-
${
|
|
276628
|
+
return `${r2}${import_picocolors2.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
276629
|
+
${import_picocolors2.default.gray(o)}`;
|
|
276592
276630
|
default:
|
|
276593
|
-
return `${r2}${
|
|
276594
|
-
${
|
|
276595
|
-
${
|
|
276631
|
+
return `${r2}${import_picocolors2.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
|
|
276632
|
+
${import_picocolors2.default.cyan(o)} `)}
|
|
276633
|
+
${import_picocolors2.default.cyan(d2)}
|
|
276596
276634
|
`;
|
|
276597
276635
|
}
|
|
276598
276636
|
} }).prompt();
|
|
@@ -276604,63 +276642,63 @@ ${t}
|
|
|
276604
276642
|
`), i = (0, import_node_util.stripVTControlCharacters)(n).length, s = Math.max(r2.reduce((a, l2) => {
|
|
276605
276643
|
const $2 = (0, import_node_util.stripVTControlCharacters)(l2);
|
|
276606
276644
|
return $2.length > a ? $2.length : a;
|
|
276607
|
-
}, 0), i) + 2, c = r2.map((a) => `${
|
|
276645
|
+
}, 0), i) + 2, c = r2.map((a) => `${import_picocolors2.default.gray(o)} ${import_picocolors2.default.dim(a)}${" ".repeat(s - (0, import_node_util.stripVTControlCharacters)(a).length)}${import_picocolors2.default.gray(o)}`).join(`
|
|
276608
276646
|
`);
|
|
276609
|
-
process.stdout.write(`${
|
|
276610
|
-
${
|
|
276647
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
276648
|
+
${import_picocolors2.default.green(C)} ${import_picocolors2.default.reset(n)} ${import_picocolors2.default.gray(_2.repeat(Math.max(s - i - 1, 1)) + me)}
|
|
276611
276649
|
${c}
|
|
276612
|
-
${
|
|
276650
|
+
${import_picocolors2.default.gray(de + _2.repeat(s + 2) + pe)}
|
|
276613
276651
|
`);
|
|
276614
276652
|
};
|
|
276615
276653
|
var xe = (t = "") => {
|
|
276616
|
-
process.stdout.write(`${
|
|
276654
|
+
process.stdout.write(`${import_picocolors2.default.gray(d2)} ${import_picocolors2.default.red(t)}
|
|
276617
276655
|
|
|
276618
276656
|
`);
|
|
276619
276657
|
};
|
|
276620
276658
|
var Ie = (t = "") => {
|
|
276621
|
-
process.stdout.write(`${
|
|
276659
|
+
process.stdout.write(`${import_picocolors2.default.gray(ue)} ${t}
|
|
276622
276660
|
`);
|
|
276623
276661
|
};
|
|
276624
276662
|
var Se = (t = "") => {
|
|
276625
|
-
process.stdout.write(`${
|
|
276626
|
-
${
|
|
276663
|
+
process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
276664
|
+
${import_picocolors2.default.gray(d2)} ${t}
|
|
276627
276665
|
|
|
276628
276666
|
`);
|
|
276629
276667
|
};
|
|
276630
|
-
var M2 = { message: (t = "", { symbol: n =
|
|
276631
|
-
const r2 = [`${
|
|
276668
|
+
var M2 = { message: (t = "", { symbol: n = import_picocolors2.default.gray(o) } = {}) => {
|
|
276669
|
+
const r2 = [`${import_picocolors2.default.gray(o)}`];
|
|
276632
276670
|
if (t) {
|
|
276633
276671
|
const [i, ...s] = t.split(`
|
|
276634
276672
|
`);
|
|
276635
|
-
r2.push(`${n} ${i}`, ...s.map((c) => `${
|
|
276673
|
+
r2.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors2.default.gray(o)} ${c}`));
|
|
276636
276674
|
}
|
|
276637
276675
|
process.stdout.write(`${r2.join(`
|
|
276638
276676
|
`)}
|
|
276639
276677
|
`);
|
|
276640
276678
|
}, info: (t) => {
|
|
276641
|
-
M2.message(t, { symbol:
|
|
276679
|
+
M2.message(t, { symbol: import_picocolors2.default.blue(q) });
|
|
276642
276680
|
}, success: (t) => {
|
|
276643
|
-
M2.message(t, { symbol:
|
|
276681
|
+
M2.message(t, { symbol: import_picocolors2.default.green(D) });
|
|
276644
276682
|
}, step: (t) => {
|
|
276645
|
-
M2.message(t, { symbol:
|
|
276683
|
+
M2.message(t, { symbol: import_picocolors2.default.green(C) });
|
|
276646
276684
|
}, warn: (t) => {
|
|
276647
|
-
M2.message(t, { symbol:
|
|
276685
|
+
M2.message(t, { symbol: import_picocolors2.default.yellow(U) });
|
|
276648
276686
|
}, warning: (t) => {
|
|
276649
276687
|
M2.warn(t);
|
|
276650
276688
|
}, error: (t) => {
|
|
276651
|
-
M2.message(t, { symbol:
|
|
276689
|
+
M2.message(t, { symbol: import_picocolors2.default.red(K2) });
|
|
276652
276690
|
} };
|
|
276653
|
-
var J2 = `${
|
|
276691
|
+
var J2 = `${import_picocolors2.default.gray(o)} `;
|
|
276654
276692
|
var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
276655
276693
|
const n = V2 ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], r2 = V2 ? 80 : 120, i = process.env.CI === "true";
|
|
276656
276694
|
let s, c, a = false, l2 = "", $2, g2 = performance.now();
|
|
276657
276695
|
const p2 = (m2) => {
|
|
276658
276696
|
const h2 = m2 > 1 ? "Something went wrong" : "Canceled";
|
|
276659
276697
|
a && N2(h2, m2);
|
|
276660
|
-
},
|
|
276661
|
-
process.on("uncaughtExceptionMonitor",
|
|
276698
|
+
}, v2 = () => p2(2), f = () => p2(1), j2 = () => {
|
|
276699
|
+
process.on("uncaughtExceptionMonitor", v2), process.on("unhandledRejection", v2), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p2);
|
|
276662
276700
|
}, E = () => {
|
|
276663
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
276701
|
+
process.removeListener("uncaughtExceptionMonitor", v2), process.removeListener("unhandledRejection", v2), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p2);
|
|
276664
276702
|
}, B2 = () => {
|
|
276665
276703
|
if ($2 === void 0) return;
|
|
276666
276704
|
i && process.stdout.write(`
|
|
@@ -276672,13 +276710,13 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
276672
276710
|
const h2 = (performance.now() - m2) / 1e3, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
|
|
276673
276711
|
return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
|
|
276674
276712
|
}, H = (m2 = "") => {
|
|
276675
|
-
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${
|
|
276713
|
+
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors2.default.gray(o)}
|
|
276676
276714
|
`);
|
|
276677
276715
|
let h2 = 0, w2 = 0;
|
|
276678
276716
|
j2(), c = setInterval(() => {
|
|
276679
276717
|
if (i && l2 === $2) return;
|
|
276680
276718
|
B2(), $2 = l2;
|
|
276681
|
-
const I2 =
|
|
276719
|
+
const I2 = import_picocolors2.default.magenta(n[h2]);
|
|
276682
276720
|
if (i) process.stdout.write(`${I2} ${l2}...`);
|
|
276683
276721
|
else if (t === "timer") process.stdout.write(`${I2} ${l2} ${O2(g2)}`);
|
|
276684
276722
|
else {
|
|
@@ -276689,7 +276727,7 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
276689
276727
|
}, r2);
|
|
276690
276728
|
}, N2 = (m2 = "", h2 = 0) => {
|
|
276691
276729
|
a = false, clearInterval(c), B2();
|
|
276692
|
-
const w2 = h2 === 0 ?
|
|
276730
|
+
const w2 = h2 === 0 ? import_picocolors2.default.green(C) : h2 === 1 ? import_picocolors2.default.red(L2) : import_picocolors2.default.red(W2);
|
|
276693
276731
|
l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
|
|
276694
276732
|
`) : process.stdout.write(`${w2} ${l2}
|
|
276695
276733
|
`), E(), s();
|
|
@@ -276700,10 +276738,10 @@ var Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
|
276700
276738
|
};
|
|
276701
276739
|
|
|
276702
276740
|
// src/cli/index.ts
|
|
276703
|
-
var
|
|
276741
|
+
var import_picocolors20 = __toESM(require_picocolors(), 1);
|
|
276704
276742
|
var import_fs12 = require("fs");
|
|
276705
276743
|
var import_path7 = require("path");
|
|
276706
|
-
var
|
|
276744
|
+
var import_child_process3 = require("child_process");
|
|
276707
276745
|
|
|
276708
276746
|
// src/cli/migrate.ts
|
|
276709
276747
|
init_cjs_shims();
|
|
@@ -277411,7 +277449,7 @@ var ErrorBodyShapeSchema = import_zod4.z.object({
|
|
|
277411
277449
|
}).passthrough();
|
|
277412
277450
|
|
|
277413
277451
|
// src/cli/migrate.ts
|
|
277414
|
-
var
|
|
277452
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
277415
277453
|
var import_fs5 = require("fs");
|
|
277416
277454
|
|
|
277417
277455
|
// node_modules/postgres/src/index.js
|
|
@@ -277878,7 +277916,7 @@ var fromPascal = (x2) => (x2.slice(0, 1) + x2.slice(1).replace(/([A-Z])/g, "_$1"
|
|
|
277878
277916
|
var fromKebab = (x2) => x2.replace(/-/g, "_");
|
|
277879
277917
|
function createJsonTransform(fn) {
|
|
277880
277918
|
return function jsonTransform(x2, column) {
|
|
277881
|
-
return typeof x2 === "object" && x2 !== null && (column.type === 114 || column.type === 3802) ? Array.isArray(x2) ? x2.map((x3) => jsonTransform(x3, column)) : Object.entries(x2).reduce((acc, [k3,
|
|
277919
|
+
return typeof x2 === "object" && x2 !== null && (column.type === 114 || column.type === 3802) ? Array.isArray(x2) ? x2.map((x3) => jsonTransform(x3, column)) : Object.entries(x2).reduce((acc, [k3, v2]) => Object.assign(acc, { [fn(k3)]: jsonTransform(v2, column) }), {}) : x2;
|
|
277882
277920
|
};
|
|
277883
277921
|
}
|
|
277884
277922
|
toCamel.column = { from: toCamel };
|
|
@@ -277956,9 +277994,9 @@ init_cjs_shims();
|
|
|
277956
277994
|
var size = 256;
|
|
277957
277995
|
var buffer = Buffer.allocUnsafe(size);
|
|
277958
277996
|
var messages = "BCcDdEFfHPpQSX".split("").reduce((acc, x2) => {
|
|
277959
|
-
const
|
|
277997
|
+
const v2 = x2.charCodeAt(0);
|
|
277960
277998
|
acc[x2] = () => {
|
|
277961
|
-
buffer[0] =
|
|
277999
|
+
buffer[0] = v2;
|
|
277962
278000
|
b3.i = 5;
|
|
277963
278001
|
return b3;
|
|
277964
278002
|
};
|
|
@@ -278453,11 +278491,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
278453
278491
|
query.forEachFn ? query.forEachFn(transform.row.from ? transform.row.from(row) : row, result) : result[rows++] = transform.row.from ? transform.row.from(row) : row;
|
|
278454
278492
|
}
|
|
278455
278493
|
function ParameterStatus(x2) {
|
|
278456
|
-
const [k3,
|
|
278457
|
-
backendParameters[k3] =
|
|
278458
|
-
if (options.parameters[k3] !==
|
|
278459
|
-
options.parameters[k3] =
|
|
278460
|
-
onparameter && onparameter(k3,
|
|
278494
|
+
const [k3, v2] = x2.toString("utf8", 5, x2.length - 1).split(bytes_default.N);
|
|
278495
|
+
backendParameters[k3] = v2;
|
|
278496
|
+
if (options.parameters[k3] !== v2) {
|
|
278497
|
+
options.parameters[k3] = v2;
|
|
278498
|
+
onparameter && onparameter(k3, v2);
|
|
278461
278499
|
}
|
|
278462
278500
|
}
|
|
278463
278501
|
function ReadyForQuery(x2) {
|
|
@@ -278814,7 +278852,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
|
|
|
278814
278852
|
client_encoding: "UTF8"
|
|
278815
278853
|
},
|
|
278816
278854
|
options.connection
|
|
278817
|
-
)).filter(([,
|
|
278855
|
+
)).filter(([, v2]) => v2).map(([k3, v2]) => k3 + bytes_default.N + v2).join(bytes_default.N)
|
|
278818
278856
|
).z(2).end(0);
|
|
278819
278857
|
}
|
|
278820
278858
|
}
|
|
@@ -278979,7 +279017,7 @@ function Time(x2) {
|
|
|
278979
279017
|
return new Date(Date.UTC(2e3, 0, 1) + Number(x2 / BigInt(1e3)));
|
|
278980
279018
|
}
|
|
278981
279019
|
function parse(x2, state, parsers2, handle, transform) {
|
|
278982
|
-
const char = (acc, [k3,
|
|
279020
|
+
const char = (acc, [k3, v2]) => (acc[k3.charCodeAt(0)] = v2, acc);
|
|
278983
279021
|
Object.entries({
|
|
278984
279022
|
R: (x3) => {
|
|
278985
279023
|
let i = 1;
|
|
@@ -279476,7 +279514,7 @@ function parseOptions(a, b4) {
|
|
|
279476
279514
|
connection: {
|
|
279477
279515
|
application_name: env.PGAPPNAME || "postgres.js",
|
|
279478
279516
|
...o2.connection,
|
|
279479
|
-
...Object.entries(query).reduce((acc, [k3,
|
|
279517
|
+
...Object.entries(query).reduce((acc, [k3, v2]) => (k3 in defaults || (acc[k3] = v2), acc), {})
|
|
279480
279518
|
},
|
|
279481
279519
|
types: o2.types || {},
|
|
279482
279520
|
target_session_attrs: tsa(o2, url, env),
|
|
@@ -279580,7 +279618,7 @@ var import_source = require("@abloatai/ablo/source");
|
|
|
279580
279618
|
|
|
279581
279619
|
// src/cli/push.ts
|
|
279582
279620
|
init_cjs_shims();
|
|
279583
|
-
var
|
|
279621
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
279584
279622
|
|
|
279585
279623
|
// src/auth/credentialPolicy.ts
|
|
279586
279624
|
init_cjs_shims();
|
|
@@ -279600,6 +279638,7 @@ function classifyCredentialKind(value) {
|
|
|
279600
279638
|
// src/cli/push.ts
|
|
279601
279639
|
var import_fs4 = require("fs");
|
|
279602
279640
|
var import_path3 = require("path");
|
|
279641
|
+
var import_child_process = require("child_process");
|
|
279603
279642
|
var import_schema2 = require("@abloatai/ablo/schema");
|
|
279604
279643
|
|
|
279605
279644
|
// src/cli/config.ts
|
|
@@ -279630,17 +279669,17 @@ function asKeyEntry(value) {
|
|
|
279630
279669
|
}
|
|
279631
279670
|
function asProfileKeys(value) {
|
|
279632
279671
|
if (!value || typeof value !== "object") return void 0;
|
|
279633
|
-
const
|
|
279634
|
-
const sandbox = asKeyEntry(
|
|
279635
|
-
const production = asKeyEntry(
|
|
279672
|
+
const v2 = value;
|
|
279673
|
+
const sandbox = asKeyEntry(v2.sandbox);
|
|
279674
|
+
const production = asKeyEntry(v2.production);
|
|
279636
279675
|
if (!sandbox && !production) return void 0;
|
|
279637
279676
|
return { ...sandbox ? { sandbox } : {}, ...production ? { production } : {} };
|
|
279638
279677
|
}
|
|
279639
279678
|
function asProfileMap(value) {
|
|
279640
279679
|
if (!value || typeof value !== "object") return {};
|
|
279641
279680
|
const out = {};
|
|
279642
|
-
for (const [name,
|
|
279643
|
-
const keys = asProfileKeys(
|
|
279681
|
+
for (const [name, v2] of Object.entries(value)) {
|
|
279682
|
+
const keys = asProfileKeys(v2);
|
|
279644
279683
|
if (keys) out[name] = keys;
|
|
279645
279684
|
}
|
|
279646
279685
|
return out;
|
|
@@ -279656,8 +279695,8 @@ function readJson(path) {
|
|
|
279656
279695
|
}
|
|
279657
279696
|
function asActiveProject(value) {
|
|
279658
279697
|
if (value && typeof value === "object" && typeof value.id === "string" && typeof value.slug === "string") {
|
|
279659
|
-
const
|
|
279660
|
-
return { id:
|
|
279698
|
+
const v2 = value;
|
|
279699
|
+
return { id: v2.id, slug: v2.slug };
|
|
279661
279700
|
}
|
|
279662
279701
|
return void 0;
|
|
279663
279702
|
}
|
|
@@ -279841,6 +279880,19 @@ function resolvePushPlan() {
|
|
|
279841
279880
|
return { flow: mode2, apiKey, source: apiKey ? "stored" : null };
|
|
279842
279881
|
}
|
|
279843
279882
|
|
|
279883
|
+
// src/cli/theme.ts
|
|
279884
|
+
init_cjs_shims();
|
|
279885
|
+
var RESET = "\x1B[0m";
|
|
279886
|
+
var PAPER_BG = "\x1B[48;2;250;250;250m";
|
|
279887
|
+
var BLACK_FG = "\x1B[38;2;0;0;0m";
|
|
279888
|
+
function colorEnabled() {
|
|
279889
|
+
return Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
279890
|
+
}
|
|
279891
|
+
function brand(label = "ablo") {
|
|
279892
|
+
if (!colorEnabled()) return label;
|
|
279893
|
+
return `${PAPER_BG}${BLACK_FG} ${label} ${RESET}`;
|
|
279894
|
+
}
|
|
279895
|
+
|
|
279844
279896
|
// src/cli/push.ts
|
|
279845
279897
|
function coerceBackfill(raw) {
|
|
279846
279898
|
if (raw === "true") return true;
|
|
@@ -279854,14 +279906,14 @@ var DEFAULT_URL = "https://api.abloatai.com";
|
|
|
279854
279906
|
function fmtSignal(s) {
|
|
279855
279907
|
const sig = s;
|
|
279856
279908
|
const where = sig.field ? `${sig.model}.${sig.field}` : sig.model;
|
|
279857
|
-
let line = ` \u2022 ${
|
|
279909
|
+
let line = ` \u2022 ${import_picocolors3.default.bold(where ?? "?")} \u2014 ${sig.detail ?? ""}`;
|
|
279858
279910
|
if (sig.shadowed) {
|
|
279859
279911
|
const env = sig.shadowed.environment ?? "production";
|
|
279860
279912
|
const ver = sig.shadowed.version != null ? `v${sig.shadowed.version}` : "active";
|
|
279861
279913
|
const when = sig.shadowed.pushedAt ? new Date(sig.shadowed.pushedAt).toISOString().slice(0, 10) : "unknown date";
|
|
279862
279914
|
const by = sig.shadowed.pushedBy ? ` by ${sig.shadowed.pushedBy}` : "";
|
|
279863
279915
|
line += `
|
|
279864
|
-
${
|
|
279916
|
+
${import_picocolors3.default.dim(`\u21B3 baseline: ${env} ${ver}, pushed ${when}${by}`)}`;
|
|
279865
279917
|
}
|
|
279866
279918
|
return line;
|
|
279867
279919
|
}
|
|
@@ -279893,6 +279945,9 @@ function parsePushArgs(argv) {
|
|
|
279893
279945
|
let exportName = DEFAULT_EXPORT;
|
|
279894
279946
|
let url = process.env.ABLO_API_URL ?? DEFAULT_URL;
|
|
279895
279947
|
let force = false;
|
|
279948
|
+
let yes = false;
|
|
279949
|
+
let allowDirty = false;
|
|
279950
|
+
let dryRun = false;
|
|
279896
279951
|
const renames = [];
|
|
279897
279952
|
const backfills = [];
|
|
279898
279953
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -279910,6 +279965,17 @@ function parsePushArgs(argv) {
|
|
|
279910
279965
|
case "--force":
|
|
279911
279966
|
force = true;
|
|
279912
279967
|
break;
|
|
279968
|
+
case "--yes":
|
|
279969
|
+
case "-y":
|
|
279970
|
+
yes = true;
|
|
279971
|
+
break;
|
|
279972
|
+
case "--allow-dirty":
|
|
279973
|
+
allowDirty = true;
|
|
279974
|
+
break;
|
|
279975
|
+
case "--dry-run":
|
|
279976
|
+
case "--plan":
|
|
279977
|
+
dryRun = true;
|
|
279978
|
+
break;
|
|
279913
279979
|
case "--rename": {
|
|
279914
279980
|
const spec = argv[++i] ?? "";
|
|
279915
279981
|
const [from, to] = spec.split(":");
|
|
@@ -279938,13 +280004,13 @@ function parsePushArgs(argv) {
|
|
|
279938
280004
|
}
|
|
279939
280005
|
}
|
|
279940
280006
|
url = url.replace(/\/+$/, "");
|
|
279941
|
-
return { schemaPath, exportName, url, apiKey: process.env.ABLO_API_KEY, force, renames, backfills };
|
|
280007
|
+
return { schemaPath, exportName, url, apiKey: process.env.ABLO_API_KEY, force, renames, backfills, yes, allowDirty, dryRun };
|
|
279942
280008
|
}
|
|
279943
280009
|
async function loadSchema(schemaPath, exportName) {
|
|
279944
280010
|
const abs = (0, import_path3.resolve)(process.cwd(), schemaPath);
|
|
279945
280011
|
if (!(0, import_fs4.existsSync)(abs)) {
|
|
279946
280012
|
throw new AbloValidationError(
|
|
279947
|
-
`schema not found at ${
|
|
280013
|
+
`schema not found at ${import_picocolors3.default.bold(schemaPath)}. Run ${import_picocolors3.default.bold("npx ablo init")} or pass ${import_picocolors3.default.bold("--schema <path>")}.`,
|
|
279948
280014
|
{ code: "cli_invalid_arguments" }
|
|
279949
280015
|
);
|
|
279950
280016
|
}
|
|
@@ -279955,7 +280021,7 @@ async function loadSchema(schemaPath, exportName) {
|
|
|
279955
280021
|
const schema = mod[exportName] ?? nested?.[exportName];
|
|
279956
280022
|
if (!schema || typeof schema !== "object" || !("models" in schema)) {
|
|
279957
280023
|
throw new AbloValidationError(
|
|
279958
|
-
`${
|
|
280024
|
+
`${import_picocolors3.default.bold(schemaPath)} has no \`${exportName}\` export that looks like a Schema. Did you \`export const ${exportName} = defineSchema({ ... })\`?`,
|
|
279959
280025
|
{ code: "cli_invalid_arguments" }
|
|
279960
280026
|
);
|
|
279961
280027
|
}
|
|
@@ -279964,6 +280030,124 @@ async function loadSchema(schemaPath, exportName) {
|
|
|
279964
280030
|
function maskKey(key) {
|
|
279965
280031
|
return key ? `${key.slice(0, 12)}\u2026` : "(none)";
|
|
279966
280032
|
}
|
|
280033
|
+
function schemaGitState(schemaPath) {
|
|
280034
|
+
try {
|
|
280035
|
+
const out = (0, import_child_process.execFileSync)("git", ["status", "--porcelain", "--", schemaPath], {
|
|
280036
|
+
cwd: process.cwd(),
|
|
280037
|
+
encoding: "utf8",
|
|
280038
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
280039
|
+
}).trim();
|
|
280040
|
+
if (out === "") return { dirty: false, untracked: false };
|
|
280041
|
+
return { dirty: true, untracked: out.startsWith("??") };
|
|
280042
|
+
} catch {
|
|
280043
|
+
return null;
|
|
280044
|
+
}
|
|
280045
|
+
}
|
|
280046
|
+
async function fetchActiveSchema(url, apiKey) {
|
|
280047
|
+
const ctrl = new AbortController();
|
|
280048
|
+
const t = setTimeout(() => ctrl.abort(), 3e3);
|
|
280049
|
+
try {
|
|
280050
|
+
const res = await fetch(`${url}/api/schema`, {
|
|
280051
|
+
headers: { authorization: `Bearer ${apiKey}` },
|
|
280052
|
+
signal: ctrl.signal
|
|
280053
|
+
});
|
|
280054
|
+
if (!res.ok) return null;
|
|
280055
|
+
return await res.json();
|
|
280056
|
+
} catch {
|
|
280057
|
+
return null;
|
|
280058
|
+
} finally {
|
|
280059
|
+
clearTimeout(t);
|
|
280060
|
+
}
|
|
280061
|
+
}
|
|
280062
|
+
function conflictStr(c) {
|
|
280063
|
+
if (!c) return "";
|
|
280064
|
+
const parts = ["user", "agent", "system"].flatMap((k3) => c[k3] ? [`${k3}:${c[k3]}`] : []);
|
|
280065
|
+
return parts.length ? `{${parts.join(",")}}` : "";
|
|
280066
|
+
}
|
|
280067
|
+
function localModels(schema) {
|
|
280068
|
+
const json = JSON.parse((0, import_schema2.serializeSchema)(schema));
|
|
280069
|
+
const out = /* @__PURE__ */ new Map();
|
|
280070
|
+
for (const [key, def] of Object.entries(json.models)) out.set(key, conflictStr(def.conflict));
|
|
280071
|
+
return out;
|
|
280072
|
+
}
|
|
280073
|
+
function printPlan(local, remote) {
|
|
280074
|
+
if (!remote?.models) {
|
|
280075
|
+
console.log(` ${import_picocolors3.default.dim("plan")} ${import_picocolors3.default.dim("(deployed schema unavailable \u2014 the server computes the diff on apply)")}
|
|
280076
|
+
`);
|
|
280077
|
+
return;
|
|
280078
|
+
}
|
|
280079
|
+
const remoteMap = /* @__PURE__ */ new Map();
|
|
280080
|
+
for (const m2 of remote.models) remoteMap.set(m2.key, conflictStr(m2.conflict));
|
|
280081
|
+
const added = [...local.keys()].filter((k3) => !remoteMap.has(k3));
|
|
280082
|
+
const removed = [...remoteMap.keys()].filter((k3) => !local.has(k3));
|
|
280083
|
+
const changed = [...local.keys()].filter((k3) => remoteMap.has(k3) && remoteMap.get(k3) !== local.get(k3));
|
|
280084
|
+
const verLabel = remote.version != null ? `v${remote.version}` : "active";
|
|
280085
|
+
if (added.length === 0 && removed.length === 0 && changed.length === 0) {
|
|
280086
|
+
console.log(` ${import_picocolors3.default.dim("plan")} ${import_picocolors3.default.dim(`no model-level changes vs deployed ${verLabel} (any field changes apply on push)`)}
|
|
280087
|
+
`);
|
|
280088
|
+
return;
|
|
280089
|
+
}
|
|
280090
|
+
console.log(` ${import_picocolors3.default.dim("plan")} ${import_picocolors3.default.dim(`vs deployed ${verLabel}:`)}`);
|
|
280091
|
+
for (const k3 of added) console.log(` ${import_picocolors3.default.green(`+ ${k3}`)} ${import_picocolors3.default.dim("(new model)")}`);
|
|
280092
|
+
for (const k3 of changed)
|
|
280093
|
+
console.log(` ${import_picocolors3.default.yellow(`~ ${k3}`)} ${import_picocolors3.default.dim(`conflict ${remoteMap.get(k3) || "(default)"} \u2192 ${local.get(k3) || "(default)"}`)}`);
|
|
280094
|
+
for (const k3 of removed) console.log(` ${import_picocolors3.default.red(`- ${k3}`)} ${import_picocolors3.default.dim("(removed \u2014 destructive, needs --force)")}`);
|
|
280095
|
+
console.log("");
|
|
280096
|
+
}
|
|
280097
|
+
async function confirmPush(args, env) {
|
|
280098
|
+
const isProd = env === "production";
|
|
280099
|
+
const tty = Boolean(process.stdout.isTTY && process.stdin.isTTY);
|
|
280100
|
+
if (isProd && !args.yes) {
|
|
280101
|
+
const git = schemaGitState(args.schemaPath);
|
|
280102
|
+
if (git?.dirty && !args.allowDirty) {
|
|
280103
|
+
console.error(` ${import_picocolors3.default.red("\u2717")} Refusing to deploy uncommitted schema to ${import_picocolors3.default.red(import_picocolors3.default.bold("production"))}.`);
|
|
280104
|
+
console.error(import_picocolors3.default.dim(` Commit ${import_picocolors3.default.bold(args.schemaPath)} first, or pass ${import_picocolors3.default.bold("--allow-dirty")} to override.`));
|
|
280105
|
+
process.exit(1);
|
|
280106
|
+
}
|
|
280107
|
+
if (!tty) {
|
|
280108
|
+
console.error(` ${import_picocolors3.default.red("\u2717")} Refusing to deploy to ${import_picocolors3.default.red(import_picocolors3.default.bold("production"))} non-interactively without confirmation.`);
|
|
280109
|
+
console.error(import_picocolors3.default.dim(` Re-run with ${import_picocolors3.default.bold("--yes")} to confirm in CI/scripts.`));
|
|
280110
|
+
process.exit(1);
|
|
280111
|
+
}
|
|
280112
|
+
const project = getActiveProject();
|
|
280113
|
+
const expected = project?.slug ?? "production";
|
|
280114
|
+
const typed = await he({
|
|
280115
|
+
message: `This deploys to ${import_picocolors3.default.red(import_picocolors3.default.bold("PRODUCTION"))}. Type ${import_picocolors3.default.bold(expected)} to confirm:`,
|
|
280116
|
+
placeholder: expected
|
|
280117
|
+
});
|
|
280118
|
+
if (pD(typed) || String(typed).trim() !== expected) {
|
|
280119
|
+
xe("Aborted \u2014 confirmation did not match.");
|
|
280120
|
+
process.exit(1);
|
|
280121
|
+
}
|
|
280122
|
+
return;
|
|
280123
|
+
}
|
|
280124
|
+
if (!isProd && !args.yes && tty) {
|
|
280125
|
+
const ok = await ye({ message: `Apply to ${import_picocolors3.default.green("sandbox")}?` });
|
|
280126
|
+
if (pD(ok) || !ok) {
|
|
280127
|
+
xe("Aborted.");
|
|
280128
|
+
process.exit(1);
|
|
280129
|
+
}
|
|
280130
|
+
}
|
|
280131
|
+
}
|
|
280132
|
+
function printPushTarget(opts) {
|
|
280133
|
+
const env = modeFromKey(opts.apiKey);
|
|
280134
|
+
const envLabel = env === "production" ? import_picocolors3.default.red(import_picocolors3.default.bold("production")) : env === "sandbox" ? import_picocolors3.default.green("sandbox") : import_picocolors3.default.yellow("unknown env");
|
|
280135
|
+
const project = getActiveProject();
|
|
280136
|
+
const projectLabel = project ? `${import_picocolors3.default.bold(project.slug)} ${import_picocolors3.default.dim(`(${project.id})`)}` : `${import_picocolors3.default.bold("default")} ${import_picocolors3.default.dim("(org-default \u2014 `ablo projects use <slug>` to scope)")}`;
|
|
280137
|
+
const cliMode = getMode();
|
|
280138
|
+
const modeNote = env && env !== cliMode ? ` ${import_picocolors3.default.yellow(`(CLI mode is ${cliMode} \u2014 this key targets ${env})`)}` : "";
|
|
280139
|
+
console.log(`
|
|
280140
|
+
${brand("ablo")} ${import_picocolors3.default.dim("push")} ${import_picocolors3.default.dim("\u2192")} ${envLabel}${modeNote}`);
|
|
280141
|
+
console.log(` ${import_picocolors3.default.dim("project")} ${projectLabel}`);
|
|
280142
|
+
console.log(` ${import_picocolors3.default.dim("target")} ${import_picocolors3.default.dim(opts.url)}`);
|
|
280143
|
+
console.log(
|
|
280144
|
+
` ${import_picocolors3.default.dim("key")} ${maskKey(opts.apiKey)} ${import_picocolors3.default.dim(`(${describeKeySource(opts.keySource)})`)}`
|
|
280145
|
+
);
|
|
280146
|
+
console.log(
|
|
280147
|
+
` ${import_picocolors3.default.dim("schema")} ${import_picocolors3.default.bold(opts.schemaPath)} ${import_picocolors3.default.dim(`\xB7 ${opts.modelCount} models \xB7 hash ${opts.hash}`)}
|
|
280148
|
+
`
|
|
280149
|
+
);
|
|
280150
|
+
}
|
|
279967
280151
|
function describeKeySource(source) {
|
|
279968
280152
|
switch (source) {
|
|
279969
280153
|
case "env":
|
|
@@ -279981,7 +280165,7 @@ async function push(argv) {
|
|
|
279981
280165
|
try {
|
|
279982
280166
|
args = parsePushArgs(argv);
|
|
279983
280167
|
} catch (err) {
|
|
279984
|
-
console.error(
|
|
280168
|
+
console.error(import_picocolors3.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
279985
280169
|
process.exit(1);
|
|
279986
280170
|
}
|
|
279987
280171
|
let keySource = "env";
|
|
@@ -279997,26 +280181,44 @@ async function push(argv) {
|
|
|
279997
280181
|
}
|
|
279998
280182
|
if (!args.apiKey) {
|
|
279999
280183
|
console.error(
|
|
280000
|
-
|
|
280001
|
-
` Run ${
|
|
280184
|
+
import_picocolors3.default.red(` No API key.`) + import_picocolors3.default.dim(
|
|
280185
|
+
` Run ${import_picocolors3.default.bold("npx ablo login")} for the sandbox dev loop \u2014 or set ${import_picocolors3.default.bold("ABLO_API_KEY")} (${import_picocolors3.default.bold("sk_test_")} = sandbox; ${import_picocolors3.default.bold("sk_live_")} = deliberate production deploy). Mode is currently '${getMode()}'.`
|
|
280002
280186
|
)
|
|
280003
280187
|
);
|
|
280004
280188
|
process.exit(1);
|
|
280005
280189
|
}
|
|
280006
280190
|
const schema = await loadSchema(args.schemaPath, args.exportName);
|
|
280007
280191
|
const hash = (0, import_schema2.schemaHash)(schema);
|
|
280008
|
-
|
|
280009
|
-
|
|
280010
|
-
|
|
280192
|
+
printPushTarget({
|
|
280193
|
+
schemaPath: args.schemaPath,
|
|
280194
|
+
url: args.url,
|
|
280195
|
+
apiKey: args.apiKey,
|
|
280196
|
+
keySource,
|
|
280197
|
+
modelCount: Object.keys(schema.models).length,
|
|
280198
|
+
hash
|
|
280199
|
+
});
|
|
280200
|
+
const remote = await fetchActiveSchema(args.url, args.apiKey);
|
|
280201
|
+
printPlan(localModels(schema), remote);
|
|
280202
|
+
const git = schemaGitState(args.schemaPath);
|
|
280203
|
+
if (git?.dirty) {
|
|
280204
|
+
const what = git.untracked ? "is untracked (not committed)" : "has uncommitted changes";
|
|
280205
|
+
console.log(` ${import_picocolors3.default.yellow("\u26A0")} ${import_picocolors3.default.bold(args.schemaPath)} ${what} \u2014 this deploy won't match a git commit.
|
|
280206
|
+
`);
|
|
280207
|
+
}
|
|
280208
|
+
if (args.dryRun) {
|
|
280209
|
+
console.log(` ${import_picocolors3.default.dim("\u25CB")} dry run \u2014 nothing applied. Re-run without ${import_picocolors3.default.bold("--dry-run")} to deploy.`);
|
|
280210
|
+
return;
|
|
280211
|
+
}
|
|
280212
|
+
await confirmPush(args, modeFromKey(args.apiKey));
|
|
280011
280213
|
const { ok: resOk, status: status2, body, bodyText } = await pushSchema(schema, args);
|
|
280012
280214
|
if (resOk) {
|
|
280013
280215
|
if (body.unchanged) {
|
|
280014
|
-
console.log(` ${
|
|
280216
|
+
console.log(` ${import_picocolors3.default.dim("\u25CB")} No changes \u2014 schema already active (v${body.version}).`);
|
|
280015
280217
|
} else {
|
|
280016
|
-
console.log(` ${
|
|
280218
|
+
console.log(` ${import_picocolors3.default.green("\u2713")} Activated ${import_picocolors3.default.bold(`v${body.version}`)} ${import_picocolors3.default.dim(`(hash ${body.hash})`)}`);
|
|
280017
280219
|
if (Array.isArray(body.warnings) && body.warnings.length > 0) {
|
|
280018
|
-
console.log(
|
|
280019
|
-
for (const w2 of body.warnings) console.log(
|
|
280220
|
+
console.log(import_picocolors3.default.yellow(` Applied ${body.warnings.length} destructive change(s):`));
|
|
280221
|
+
for (const w2 of body.warnings) console.log(import_picocolors3.default.yellow(fmtSignal(w2)));
|
|
280020
280222
|
}
|
|
280021
280223
|
}
|
|
280022
280224
|
return;
|
|
@@ -280024,63 +280226,63 @@ async function push(argv) {
|
|
|
280024
280226
|
if (status2 === 409) {
|
|
280025
280227
|
const unexecutable = Array.isArray(body.unexecutable) ? body.unexecutable : [];
|
|
280026
280228
|
const warnings = Array.isArray(body.warnings) ? body.warnings : [];
|
|
280027
|
-
console.error(
|
|
280229
|
+
console.error(import_picocolors3.default.red(" Incompatible change \u2014 this push is not safe to apply as-is."));
|
|
280028
280230
|
if (unexecutable.length > 0) {
|
|
280029
|
-
console.error(
|
|
280030
|
-
for (const u2 of unexecutable) console.error(
|
|
280231
|
+
console.error(import_picocolors3.default.red(` Unexecutable (would fail on existing rows):`));
|
|
280232
|
+
for (const u2 of unexecutable) console.error(import_picocolors3.default.red(fmtSignal(u2)));
|
|
280031
280233
|
}
|
|
280032
280234
|
if (warnings.length > 0) {
|
|
280033
|
-
console.error(
|
|
280034
|
-
for (const w2 of warnings) console.error(
|
|
280235
|
+
console.error(import_picocolors3.default.yellow(` Destructive (data loss):`));
|
|
280236
|
+
for (const w2 of warnings) console.error(import_picocolors3.default.yellow(fmtSignal(w2)));
|
|
280035
280237
|
}
|
|
280036
280238
|
const hasShadowed = [...unexecutable, ...warnings].some(
|
|
280037
280239
|
(s) => s.shadowed != null
|
|
280038
280240
|
);
|
|
280039
280241
|
if (hasShadowed) {
|
|
280040
280242
|
console.error(
|
|
280041
|
-
|
|
280243
|
+
import_picocolors3.default.dim(
|
|
280042
280244
|
" These models exist in the baseline above but not in your push. Sandbox readers fall"
|
|
280043
280245
|
)
|
|
280044
280246
|
);
|
|
280045
280247
|
console.error(
|
|
280046
|
-
|
|
280248
|
+
import_picocolors3.default.dim(
|
|
280047
280249
|
" back to the production schema until you push your own, so applying this drops them."
|
|
280048
280250
|
)
|
|
280049
280251
|
);
|
|
280050
280252
|
}
|
|
280051
|
-
console.error(
|
|
280253
|
+
console.error(import_picocolors3.default.dim(` Re-push with ${import_picocolors3.default.bold("--force")} to override, or use ${import_picocolors3.default.bold("--rename old:new")} if you renamed a model.`));
|
|
280052
280254
|
} else if (status2 === 403) {
|
|
280053
280255
|
const code = body.code ?? body.reason;
|
|
280054
280256
|
const serverMsg = body.message ?? body.reason;
|
|
280055
|
-
console.error(
|
|
280056
|
-
console.error(
|
|
280257
|
+
console.error(import_picocolors3.default.red(` Forbidden${code ? ` [${code}]` : ""}: ${serverMsg ?? "permission denied"}`));
|
|
280258
|
+
console.error(import_picocolors3.default.dim(` Push used ${import_picocolors3.default.bold(maskKey(args.apiKey))} from ${describeKeySource(keySource)}.`));
|
|
280057
280259
|
if (code === "database_role_cannot_enforce_rls") {
|
|
280058
280260
|
console.error(
|
|
280059
|
-
|
|
280060
|
-
` Your database role bypasses row-level security. Run ${
|
|
280261
|
+
import_picocolors3.default.dim(
|
|
280262
|
+
` Your database role bypasses row-level security. Run ${import_picocolors3.default.bold("npx ablo migrate")} to create a scoped (NOBYPASSRLS) role and repoint DATABASE_URL, then re-push.`
|
|
280061
280263
|
)
|
|
280062
280264
|
);
|
|
280063
280265
|
} else if (code === "database_tables_unforced_rls") {
|
|
280064
280266
|
console.error(
|
|
280065
|
-
|
|
280066
|
-
` One or more synced tables don't have FORCE ROW LEVEL SECURITY. Run ${
|
|
280267
|
+
import_picocolors3.default.dim(
|
|
280268
|
+
` One or more synced tables don't have FORCE ROW LEVEL SECURITY. Run ${import_picocolors3.default.bold("npx ablo migrate")} to (re)apply the tenant policies, then re-push.`
|
|
280067
280269
|
)
|
|
280068
280270
|
);
|
|
280069
280271
|
} else if (args.apiKey != null && classifyCredentialKind(args.apiKey) === "restricted") {
|
|
280070
280272
|
console.error(
|
|
280071
|
-
|
|
280072
|
-
` Schema pushes need a SECRET key: ${
|
|
280273
|
+
import_picocolors3.default.dim(
|
|
280274
|
+
` Schema pushes need a SECRET key: ${import_picocolors3.default.bold("sk_test_")} (sandbox dev loop) or a dashboard ${import_picocolors3.default.bold("sk_live_")} (production deploy: ${import_picocolors3.default.bold("ABLO_API_KEY=sk_live_\u2026 npx ablo push")}).`
|
|
280073
280275
|
)
|
|
280074
280276
|
);
|
|
280075
280277
|
} else {
|
|
280076
280278
|
console.error(
|
|
280077
|
-
|
|
280078
|
-
` This key isn't authorized to push schema (needs ${
|
|
280279
|
+
import_picocolors3.default.dim(
|
|
280280
|
+
` This key isn't authorized to push schema (needs ${import_picocolors3.default.bold("schema:push")}). ` + (keySource === "login" ? `It's your stored ${import_picocolors3.default.bold("ablo login")} sandbox key \u2014 a key in ${import_picocolors3.default.bold(".env.local")} or ${import_picocolors3.default.bold("ABLO_API_KEY")} takes precedence, so put a schema:push key there (sandbox ${import_picocolors3.default.bold("sk_test_")} or production ${import_picocolors3.default.bold("sk_live_")}) and re-push. ` : `Use a schema:push key \u2014 a sandbox ${import_picocolors3.default.bold("sk_test_")} or production ${import_picocolors3.default.bold("sk_live_")}. `) + `Manage keys at https://abloatai.com`
|
|
280079
280281
|
)
|
|
280080
280282
|
);
|
|
280081
280283
|
}
|
|
280082
280284
|
} else {
|
|
280083
|
-
console.error(
|
|
280285
|
+
console.error(import_picocolors3.default.red(` Push failed (${status2}): ${body.message ?? body.reason ?? bodyText}`));
|
|
280084
280286
|
}
|
|
280085
280287
|
process.exit(1);
|
|
280086
280288
|
}
|
|
@@ -280140,8 +280342,8 @@ function planFor(schema, targetSchema = "public") {
|
|
|
280140
280342
|
}
|
|
280141
280343
|
var log = {
|
|
280142
280344
|
info: (msg, fields) => console.log(`[migrate] ${msg}`, fields),
|
|
280143
|
-
warn: (msg, fields) => console.warn(
|
|
280144
|
-
error: (msg, fields) => console.error(
|
|
280345
|
+
warn: (msg, fields) => console.warn(import_picocolors4.default.yellow(`[migrate] ${msg}`), fields),
|
|
280346
|
+
error: (msg, fields) => console.error(import_picocolors4.default.red(`[migrate] ${msg}`), fields)
|
|
280145
280347
|
};
|
|
280146
280348
|
var PG_LOCK_NOT_AVAILABLE = "55P03";
|
|
280147
280349
|
var LOCK_TIMEOUT = process.env.ABLO_SCHEMA_LOCK_TIMEOUT ?? process.env.ABLO_DDL_LOCK_TIMEOUT ?? "5s";
|
|
@@ -280216,7 +280418,7 @@ async function migrate(argv) {
|
|
|
280216
280418
|
try {
|
|
280217
280419
|
args = parseMigrateArgs(argv);
|
|
280218
280420
|
} catch (err) {
|
|
280219
|
-
console.error(
|
|
280421
|
+
console.error(import_picocolors4.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
280220
280422
|
process.exit(1);
|
|
280221
280423
|
}
|
|
280222
280424
|
const schema = await loadSchema(args.schemaPath, args.exportName);
|
|
@@ -280227,11 +280429,11 @@ async function migrate(argv) {
|
|
|
280227
280429
|
].join("\n");
|
|
280228
280430
|
const totalStatements = plan.statements.length + plan.concurrent.length;
|
|
280229
280431
|
console.log(
|
|
280230
|
-
` ${
|
|
280432
|
+
` ${import_picocolors4.default.dim("Schema")} ${import_picocolors4.default.bold(args.schemaPath)} \u2192 ${import_picocolors4.default.dim(`${Object.keys(schema.models).length} models, ${totalStatements} statements`)}`
|
|
280231
280433
|
);
|
|
280232
280434
|
if (args.outputFile) {
|
|
280233
280435
|
(0, import_fs5.writeFileSync)(args.outputFile, sql + "\n");
|
|
280234
|
-
console.log(` ${
|
|
280436
|
+
console.log(` ${import_picocolors4.default.green("\u2713")} SQL written to ${import_picocolors4.default.bold(args.outputFile)}`);
|
|
280235
280437
|
return;
|
|
280236
280438
|
}
|
|
280237
280439
|
if (args.dryRun) {
|
|
@@ -280241,7 +280443,7 @@ async function migrate(argv) {
|
|
|
280241
280443
|
const dbUrl = readProjectDatabaseUrl();
|
|
280242
280444
|
if (!dbUrl) {
|
|
280243
280445
|
console.error(
|
|
280244
|
-
|
|
280446
|
+
import_picocolors4.default.red(
|
|
280245
280447
|
" No DATABASE_URL found (checked process env, .env.local, .env). Set it to apply, or use --dry-run to preview."
|
|
280246
280448
|
)
|
|
280247
280449
|
);
|
|
@@ -280249,7 +280451,7 @@ async function migrate(argv) {
|
|
|
280249
280451
|
}
|
|
280250
280452
|
try {
|
|
280251
280453
|
await applyStatements(dbUrl, args.targetSchema, plan.statements, plan.concurrent);
|
|
280252
|
-
console.log(` ${
|
|
280454
|
+
console.log(` ${import_picocolors4.default.green("\u2713")} Migration complete`);
|
|
280253
280455
|
} catch {
|
|
280254
280456
|
process.exit(1);
|
|
280255
280457
|
}
|
|
@@ -280257,22 +280459,7 @@ async function migrate(argv) {
|
|
|
280257
280459
|
|
|
280258
280460
|
// src/cli/connect.ts
|
|
280259
280461
|
init_cjs_shims();
|
|
280260
|
-
var
|
|
280261
|
-
|
|
280262
|
-
// src/cli/theme.ts
|
|
280263
|
-
init_cjs_shims();
|
|
280264
|
-
var RESET = "\x1B[0m";
|
|
280265
|
-
var PAPER_BG = "\x1B[48;2;250;250;250m";
|
|
280266
|
-
var BLACK_FG = "\x1B[38;2;0;0;0m";
|
|
280267
|
-
function colorEnabled() {
|
|
280268
|
-
return Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
280269
|
-
}
|
|
280270
|
-
function brand(label = "ablo") {
|
|
280271
|
-
if (!colorEnabled()) return label;
|
|
280272
|
-
return `${PAPER_BG}${BLACK_FG} ${label} ${RESET}`;
|
|
280273
|
-
}
|
|
280274
|
-
|
|
280275
|
-
// src/cli/connect.ts
|
|
280462
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
280276
280463
|
var ABLO_PUBLICATION = "ablo_publication";
|
|
280277
280464
|
var ABLO_REPLICATION_ROLE = "ablo_replicator";
|
|
280278
280465
|
function parseConnectArgs(argv) {
|
|
@@ -280321,60 +280508,60 @@ function connectSetupSql(input) {
|
|
|
280321
280508
|
function printConnectRecipe(args) {
|
|
280322
280509
|
const sql = connectSetupSql({ tables: args.tables, role: args.role });
|
|
280323
280510
|
console.log(`
|
|
280324
|
-
${brand("ablo")} ${
|
|
280511
|
+
${brand("ablo")} ${import_picocolors5.default.dim("connect")} ${import_picocolors5.default.dim("logical replication \u2014 the one way to connect a real database")}
|
|
280325
280512
|
`);
|
|
280326
280513
|
console.log(
|
|
280327
|
-
` Ablo READS your write-ahead log (WAL) and ${
|
|
280514
|
+
` Ablo READS your write-ahead log (WAL) and ${import_picocolors5.default.bold("never")} runs DDL, owns, or migrates your
|
|
280328
280515
|
schema. Your app keeps writing through your own backend \u2014 Ablo only tails the changes.
|
|
280329
|
-
Run this once against your Postgres ${
|
|
280516
|
+
Run this once against your Postgres ${import_picocolors5.default.dim("(as a superuser / the DB owner)")}:
|
|
280330
280517
|
`
|
|
280331
280518
|
);
|
|
280332
|
-
console.log(` ${
|
|
280333
|
-
console.log(` ${
|
|
280519
|
+
console.log(` ${import_picocolors5.default.bold("1.")} Enable logical decoding ${import_picocolors5.default.dim("(then RESTART Postgres \u2014 wal_level is not reloadable)")}`);
|
|
280520
|
+
console.log(` ${import_picocolors5.default.cyan(sql[0])}`);
|
|
280334
280521
|
console.log(
|
|
280335
|
-
|
|
280336
|
-
` On Amazon RDS / Aurora you can't ALTER SYSTEM: set ${
|
|
280522
|
+
import_picocolors5.default.dim(
|
|
280523
|
+
` On Amazon RDS / Aurora you can't ALTER SYSTEM: set ${import_picocolors5.default.bold("rds.logical_replication = 1")} in the
|
|
280337
280524
|
instance's parameter group instead, then reboot.`
|
|
280338
280525
|
)
|
|
280339
280526
|
);
|
|
280340
280527
|
console.log(`
|
|
280341
|
-
${
|
|
280342
|
-
console.log(` ${
|
|
280528
|
+
${import_picocolors5.default.bold("2.")} Publish the tables Ablo should read`);
|
|
280529
|
+
console.log(` ${import_picocolors5.default.cyan(sql[1])}`);
|
|
280343
280530
|
if (args.tables.length === 0) {
|
|
280344
|
-
console.log(
|
|
280531
|
+
console.log(import_picocolors5.default.dim(` (Scope it with ${import_picocolors5.default.bold("ablo connect --tables a,b,c")} to publish a subset.)`));
|
|
280345
280532
|
}
|
|
280346
280533
|
console.log(`
|
|
280347
|
-
${
|
|
280348
|
-
console.log(` ${
|
|
280349
|
-
console.log(` ${
|
|
280350
|
-
console.log(` ${
|
|
280534
|
+
${import_picocolors5.default.bold("3.")} Create a least-privilege replication role ${import_picocolors5.default.dim("(pick your own password)")}`);
|
|
280535
|
+
console.log(` ${import_picocolors5.default.cyan(sql[2])}`);
|
|
280536
|
+
console.log(` ${import_picocolors5.default.cyan(sql[3])}`);
|
|
280537
|
+
console.log(` ${import_picocolors5.default.cyan(sql[4])}`);
|
|
280351
280538
|
console.log(
|
|
280352
|
-
|
|
280539
|
+
import_picocolors5.default.dim(
|
|
280353
280540
|
` On Amazon RDS, the REPLICATION attribute is granted, not set directly:
|
|
280354
|
-
${
|
|
280541
|
+
${import_picocolors5.default.bold(`GRANT rds_replication TO ${quoteIdent(args.role)};`)}`
|
|
280355
280542
|
)
|
|
280356
280543
|
);
|
|
280357
280544
|
console.log(
|
|
280358
280545
|
`
|
|
280359
|
-
${
|
|
280360
|
-
${
|
|
280546
|
+
${import_picocolors5.default.bold("4.")} Put the role's connection string in ${import_picocolors5.default.bold("DATABASE_URL")}, then verify:
|
|
280547
|
+
${import_picocolors5.default.cyan("npx ablo connect --check")}
|
|
280361
280548
|
`
|
|
280362
280549
|
);
|
|
280363
280550
|
console.log(
|
|
280364
|
-
|
|
280551
|
+
import_picocolors5.default.dim(
|
|
280365
280552
|
` Reminder: Ablo never writes to your database on this path. Provisioning tables with
|
|
280366
|
-
${
|
|
280553
|
+
${import_picocolors5.default.bold("ablo migrate")} is a separate, optional escape hatch \u2014 connecting a real database is this.`
|
|
280367
280554
|
)
|
|
280368
280555
|
);
|
|
280369
280556
|
console.log();
|
|
280370
280557
|
}
|
|
280371
280558
|
function printCheckItem(item) {
|
|
280372
280559
|
if (item.ok) {
|
|
280373
|
-
console.log(` ${
|
|
280560
|
+
console.log(` ${import_picocolors5.default.green("\u2713")} ${item.label}`);
|
|
280374
280561
|
} else {
|
|
280375
|
-
console.log(` ${
|
|
280562
|
+
console.log(` ${import_picocolors5.default.red("\u2717")} ${item.label}`);
|
|
280376
280563
|
if (item.fix) {
|
|
280377
|
-
for (const line of item.fix.split("\n")) console.log(` ${
|
|
280564
|
+
for (const line of item.fix.split("\n")) console.log(` ${import_picocolors5.default.red("\u2022")} ${line}`);
|
|
280378
280565
|
}
|
|
280379
280566
|
}
|
|
280380
280567
|
}
|
|
@@ -280384,9 +280571,9 @@ async function probeReadiness(sql, opts = {}) {
|
|
|
280384
280571
|
const walRows = await sql.unsafe(`SHOW wal_level`);
|
|
280385
280572
|
const walLevel = walRows[0]?.setting ?? "unknown";
|
|
280386
280573
|
items.push(
|
|
280387
|
-
walLevel === "logical" ? { ok: true, label: `wal_level is ${
|
|
280574
|
+
walLevel === "logical" ? { ok: true, label: `wal_level is ${import_picocolors5.default.bold("logical")}` } : {
|
|
280388
280575
|
ok: false,
|
|
280389
|
-
label: `wal_level is ${
|
|
280576
|
+
label: `wal_level is ${import_picocolors5.default.bold(walLevel)} (need ${import_picocolors5.default.bold("logical")})`,
|
|
280390
280577
|
fix: `ALTER SYSTEM SET wal_level = 'logical'; then RESTART Postgres.
|
|
280391
280578
|
On RDS/Aurora set rds.logical_replication = 1 in the parameter group, then reboot.`
|
|
280392
280579
|
}
|
|
@@ -280398,10 +280585,10 @@ On RDS/Aurora set rds.logical_replication = 1 in the parameter group, then reboo
|
|
|
280398
280585
|
items.push(
|
|
280399
280586
|
pubRows.length > 0 ? {
|
|
280400
280587
|
ok: true,
|
|
280401
|
-
label: `publication ${
|
|
280588
|
+
label: `publication ${import_picocolors5.default.bold(publication)} exists ${import_picocolors5.default.dim(pubRows[0].puballtables ? "(all tables)" : "(table subset)")}`
|
|
280402
280589
|
} : {
|
|
280403
280590
|
ok: false,
|
|
280404
|
-
label: `publication ${
|
|
280591
|
+
label: `publication ${import_picocolors5.default.bold(publication)} not found`,
|
|
280405
280592
|
fix: `CREATE PUBLICATION ${quoteIdent(publication)} FOR ALL TABLES;`
|
|
280406
280593
|
}
|
|
280407
280594
|
);
|
|
@@ -280411,9 +280598,9 @@ On RDS/Aurora set rds.logical_replication = 1 in the parameter group, then reboo
|
|
|
280411
280598
|
const role = roleRows[0];
|
|
280412
280599
|
const hasReplication = Boolean(role && (role.rolreplication || role.rolsuper));
|
|
280413
280600
|
items.push(
|
|
280414
|
-
hasReplication ? { ok: true, label: `DATABASE_URL role can stream replication ${
|
|
280601
|
+
hasReplication ? { ok: true, label: `DATABASE_URL role can stream replication ${import_picocolors5.default.dim("(REPLICATION)")}` } : {
|
|
280415
280602
|
ok: false,
|
|
280416
|
-
label: `DATABASE_URL role lacks the ${
|
|
280603
|
+
label: `DATABASE_URL role lacks the ${import_picocolors5.default.bold("REPLICATION")} attribute`,
|
|
280417
280604
|
fix: `ALTER ROLE current_user WITH REPLICATION;
|
|
280418
280605
|
On RDS: GRANT rds_replication TO <your_role>;`
|
|
280419
280606
|
}
|
|
@@ -280453,12 +280640,12 @@ async function runCheck() {
|
|
|
280453
280640
|
const dbUrl = readProjectDatabaseUrl();
|
|
280454
280641
|
if (!dbUrl) {
|
|
280455
280642
|
console.error(
|
|
280456
|
-
|
|
280643
|
+
import_picocolors5.default.red(" No DATABASE_URL found (checked process env, .env.local, .env).") + import_picocolors5.default.dim(` Set it to the Postgres you want Ablo to read, then re-run ${import_picocolors5.default.bold("ablo connect --check")}.`)
|
|
280457
280644
|
);
|
|
280458
280645
|
process.exit(1);
|
|
280459
280646
|
}
|
|
280460
280647
|
console.log(`
|
|
280461
|
-
${brand("ablo")} ${
|
|
280648
|
+
${brand("ablo")} ${import_picocolors5.default.dim("connect --check")} ${import_picocolors5.default.dim("logical-replication readiness")}
|
|
280462
280649
|
`);
|
|
280463
280650
|
const sql = src_default(dbUrl, { max: 1, prepare: false, onnotice: () => {
|
|
280464
280651
|
} });
|
|
@@ -280467,7 +280654,7 @@ async function runCheck() {
|
|
|
280467
280654
|
items = await probeReadiness(sql);
|
|
280468
280655
|
} catch (err) {
|
|
280469
280656
|
const pg = err ?? {};
|
|
280470
|
-
console.error(
|
|
280657
|
+
console.error(import_picocolors5.default.red(` Couldn't read the database: ${pg.message ?? String(err)}`));
|
|
280471
280658
|
await sql.end({ timeout: 2 });
|
|
280472
280659
|
process.exit(1);
|
|
280473
280660
|
}
|
|
@@ -280476,12 +280663,12 @@ async function runCheck() {
|
|
|
280476
280663
|
const failures = items.filter((i) => !i.ok).length;
|
|
280477
280664
|
console.log();
|
|
280478
280665
|
if (failures === 0) {
|
|
280479
|
-
console.log(` ${
|
|
280666
|
+
console.log(` ${import_picocolors5.default.green("\u2713")} Ready \u2014 Ablo can connect and tail this database's WAL.
|
|
280480
280667
|
`);
|
|
280481
280668
|
process.exit(0);
|
|
280482
280669
|
}
|
|
280483
280670
|
console.log(
|
|
280484
|
-
` ${
|
|
280671
|
+
` ${import_picocolors5.default.red(`${failures} item${failures === 1 ? "" : "s"} to fix`)} ${import_picocolors5.default.dim(`\u2014 apply the fixes above, then re-run ${import_picocolors5.default.bold("ablo connect --check")}.`)}
|
|
280485
280672
|
`
|
|
280486
280673
|
);
|
|
280487
280674
|
process.exit(1);
|
|
@@ -280491,7 +280678,7 @@ async function connect(argv) {
|
|
|
280491
280678
|
try {
|
|
280492
280679
|
args = parseConnectArgs(argv);
|
|
280493
280680
|
} catch (err) {
|
|
280494
|
-
console.error(
|
|
280681
|
+
console.error(import_picocolors5.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
280495
280682
|
process.exit(1);
|
|
280496
280683
|
}
|
|
280497
280684
|
if (args.check) {
|
|
@@ -280515,7 +280702,7 @@ var CONNECT_USAGE = ` ablo connect \u2014 connect a real database to Ablo via l
|
|
|
280515
280702
|
init_cjs_shims();
|
|
280516
280703
|
var import_fs6 = require("fs");
|
|
280517
280704
|
var import_path4 = require("path");
|
|
280518
|
-
var
|
|
280705
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
280519
280706
|
var import_schema4 = require("@abloatai/ablo/schema");
|
|
280520
280707
|
var DEFAULT_SCHEMA_PATH3 = "ablo/schema.ts";
|
|
280521
280708
|
var DEFAULT_EXPORT3 = "schema";
|
|
@@ -280547,7 +280734,7 @@ async function generate(argv) {
|
|
|
280547
280734
|
try {
|
|
280548
280735
|
args = parseGenerateArgs(argv);
|
|
280549
280736
|
} catch (err) {
|
|
280550
|
-
console.error(
|
|
280737
|
+
console.error(import_picocolors6.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
280551
280738
|
process.exit(1);
|
|
280552
280739
|
}
|
|
280553
280740
|
let source;
|
|
@@ -280556,18 +280743,18 @@ async function generate(argv) {
|
|
|
280556
280743
|
const schemaJson = JSON.parse((0, import_schema4.serializeSchema)(schema));
|
|
280557
280744
|
source = (0, import_schema4.generateTypes)(schemaJson);
|
|
280558
280745
|
} catch (err) {
|
|
280559
|
-
console.error(
|
|
280746
|
+
console.error(import_picocolors6.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
280560
280747
|
process.exit(1);
|
|
280561
280748
|
}
|
|
280562
280749
|
const abs = (0, import_path4.resolve)(process.cwd(), args.out);
|
|
280563
280750
|
(0, import_fs6.mkdirSync)((0, import_path4.dirname)(abs), { recursive: true });
|
|
280564
280751
|
(0, import_fs6.writeFileSync)(abs, source);
|
|
280565
|
-
console.log(` ${
|
|
280752
|
+
console.log(` ${import_picocolors6.default.green("\u2713")} Generated types \u2192 ${import_picocolors6.default.bold(args.out)}`);
|
|
280566
280753
|
}
|
|
280567
280754
|
|
|
280568
280755
|
// src/cli/dev.ts
|
|
280569
280756
|
init_cjs_shims();
|
|
280570
|
-
var
|
|
280757
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
280571
280758
|
var import_fs7 = require("fs");
|
|
280572
280759
|
var import_path5 = require("path");
|
|
280573
280760
|
var import_schema5 = require("@abloatai/ablo/schema");
|
|
@@ -280605,25 +280792,25 @@ function classifyKey(apiKey, activeMode) {
|
|
|
280605
280792
|
if (!apiKey) {
|
|
280606
280793
|
return {
|
|
280607
280794
|
ok: false,
|
|
280608
|
-
reason: `No API key. Run ${
|
|
280795
|
+
reason: `No API key. Run ${import_picocolors7.default.bold("npx ablo login")} for the sandbox dev loop \u2014 or set ${import_picocolors7.default.bold("ABLO_API_KEY")} (${import_picocolors7.default.bold("sk_test_")} = sandbox; ${import_picocolors7.default.bold("sk_live_")} = deliberate production deploy). ` + import_picocolors7.default.dim(`Mode is currently '${activeMode}'.`)
|
|
280609
280796
|
};
|
|
280610
280797
|
}
|
|
280611
280798
|
if (apiKey.startsWith("sk_test_")) return { ok: true };
|
|
280612
280799
|
if (apiKey.startsWith("sk_live_")) {
|
|
280613
280800
|
return {
|
|
280614
280801
|
ok: false,
|
|
280615
|
-
reason: `Production schema deploys run one-shot: ${
|
|
280802
|
+
reason: `Production schema deploys run one-shot: ${import_picocolors7.default.bold("ABLO_API_KEY=sk_live_\u2026 npx ablo push")} (or ${import_picocolors7.default.bold("ablo mode production")}). ${import_picocolors7.default.bold("--watch")} is sandbox-only.`
|
|
280616
280803
|
};
|
|
280617
280804
|
}
|
|
280618
280805
|
if (classifyCredentialKind(apiKey) === "restricted") {
|
|
280619
280806
|
return {
|
|
280620
280807
|
ok: false,
|
|
280621
|
-
reason: `Restricted (${
|
|
280808
|
+
reason: `Restricted (${import_picocolors7.default.bold("rk_")}) keys can't push schema. Use a secret key: ${import_picocolors7.default.bold("sk_test_")} for the sandbox dev loop, or ${import_picocolors7.default.bold("sk_live_")} with ${import_picocolors7.default.bold("npx ablo push")} for a production deploy.`
|
|
280622
280809
|
};
|
|
280623
280810
|
}
|
|
280624
280811
|
return {
|
|
280625
280812
|
ok: false,
|
|
280626
|
-
reason: `${
|
|
280813
|
+
reason: `${import_picocolors7.default.bold("ABLO_API_KEY")} is not an Ablo key \u2014 expected ${import_picocolors7.default.bold("sk_test_\u2026")} (sandbox) or ${import_picocolors7.default.bold("sk_live_\u2026")} (production deploy via ${import_picocolors7.default.bold("npx ablo push")}).`
|
|
280627
280814
|
};
|
|
280628
280815
|
}
|
|
280629
280816
|
function wireEnvLocal(apiKey, cwd = process.cwd()) {
|
|
@@ -280633,19 +280820,19 @@ function wireEnvLocal(apiKey, cwd = process.cwd()) {
|
|
|
280633
280820
|
if (!(0, import_fs7.existsSync)(envPath)) {
|
|
280634
280821
|
(0, import_fs7.writeFileSync)(envPath, `${line}
|
|
280635
280822
|
`, { mode: 384 });
|
|
280636
|
-
action = `Created ${
|
|
280823
|
+
action = `Created ${import_picocolors7.default.bold(".env.local")} with ${import_picocolors7.default.bold("ABLO_API_KEY")}`;
|
|
280637
280824
|
} else {
|
|
280638
280825
|
const content = (0, import_fs7.readFileSync)(envPath, "utf8");
|
|
280639
280826
|
const match = content.match(/^ABLO_API_KEY=(.*)$/m);
|
|
280640
280827
|
if (!match) {
|
|
280641
280828
|
(0, import_fs7.appendFileSync)(envPath, `${content.endsWith("\n") || content.length === 0 ? "" : "\n"}${line}
|
|
280642
280829
|
`);
|
|
280643
|
-
action = `Added ${
|
|
280830
|
+
action = `Added ${import_picocolors7.default.bold("ABLO_API_KEY")} to ${import_picocolors7.default.bold(".env.local")}`;
|
|
280644
280831
|
} else if (match[1] === apiKey) {
|
|
280645
|
-
action = `${
|
|
280832
|
+
action = `${import_picocolors7.default.bold(".env.local")} already has this key`;
|
|
280646
280833
|
} else {
|
|
280647
280834
|
(0, import_fs7.writeFileSync)(envPath, content.replace(/^ABLO_API_KEY=.*$/m, line));
|
|
280648
|
-
action = `Updated ${
|
|
280835
|
+
action = `Updated ${import_picocolors7.default.bold("ABLO_API_KEY")} in ${import_picocolors7.default.bold(".env.local")} ${import_picocolors7.default.dim(`(was ${match[1].slice(0, 12)}\u2026)`)}`;
|
|
280649
280836
|
}
|
|
280650
280837
|
}
|
|
280651
280838
|
const gitignorePath = (0, import_path5.resolve)(cwd, ".gitignore");
|
|
@@ -280659,7 +280846,7 @@ function wireEnvLocal(apiKey, cwd = process.cwd()) {
|
|
|
280659
280846
|
`}.env.local
|
|
280660
280847
|
`
|
|
280661
280848
|
);
|
|
280662
|
-
gitignoreNote = ` Added ${
|
|
280849
|
+
gitignoreNote = ` Added ${import_picocolors7.default.bold(".env.local")} to ${import_picocolors7.default.bold(".gitignore")} so the key can't be committed.`;
|
|
280663
280850
|
}
|
|
280664
280851
|
return `${action}.${gitignoreNote}`;
|
|
280665
280852
|
}
|
|
@@ -280674,7 +280861,7 @@ async function runPush(schema, args) {
|
|
|
280674
280861
|
if (ok) {
|
|
280675
280862
|
return {
|
|
280676
280863
|
ok: true,
|
|
280677
|
-
message: body.unchanged ? `schema unchanged ${
|
|
280864
|
+
message: body.unchanged ? `schema unchanged ${import_picocolors7.default.dim(`(v${body.version})`)}` : `schema pushed (sandbox) ${import_picocolors7.default.dim(`(v${body.version}, hash ${body.hash})`)}`
|
|
280678
280865
|
};
|
|
280679
280866
|
}
|
|
280680
280867
|
if (status2 === 409) {
|
|
@@ -280684,33 +280871,33 @@ async function runPush(schema, args) {
|
|
|
280684
280871
|
(s) => s.shadowed != null
|
|
280685
280872
|
);
|
|
280686
280873
|
const lines = [
|
|
280687
|
-
|
|
280874
|
+
import_picocolors7.default.bold("Incompatible schema change \u2014 not safe to apply as-is."),
|
|
280688
280875
|
"",
|
|
280689
|
-
...unexecutable.map((u2) =>
|
|
280690
|
-
...warnings.map((w2) =>
|
|
280876
|
+
...unexecutable.map((u2) => import_picocolors7.default.red(fmtSignal(u2))),
|
|
280877
|
+
...warnings.map((w2) => import_picocolors7.default.yellow(fmtSignal(w2))),
|
|
280691
280878
|
"",
|
|
280692
280879
|
...hasShadowed ? [
|
|
280693
|
-
|
|
280880
|
+
import_picocolors7.default.dim(
|
|
280694
280881
|
" These models exist in the baseline above but not in your push. Sandbox readers"
|
|
280695
280882
|
),
|
|
280696
|
-
|
|
280883
|
+
import_picocolors7.default.dim(
|
|
280697
280884
|
" fall back to the production schema until you push your own, so applying this drops them."
|
|
280698
280885
|
),
|
|
280699
280886
|
""
|
|
280700
280887
|
] : [],
|
|
280701
|
-
|
|
280702
|
-
` Fix: ${
|
|
280888
|
+
import_picocolors7.default.dim(
|
|
280889
|
+
` Fix: ${import_picocolors7.default.bold("ablo push --force")} to apply anyway, or ${import_picocolors7.default.bold("--rename old:new")} if you renamed a model.`
|
|
280703
280890
|
)
|
|
280704
280891
|
];
|
|
280705
280892
|
return { ok: false, message: lines.join("\n") };
|
|
280706
280893
|
}
|
|
280707
280894
|
if (status2 === 403) {
|
|
280708
280895
|
const serverSays = body.message ?? body.reason;
|
|
280709
|
-
const hint = body.code === "database_role_cannot_enforce_rls" ? `Run ${
|
|
280896
|
+
const hint = body.code === "database_role_cannot_enforce_rls" ? `Run ${import_picocolors7.default.bold("npx ablo migrate")} \u2014 it creates the scoped role for you (your DB credential never leaves this machine).` : `Schema authoring needs a ${import_picocolors7.default.bold("sandbox")} key with ${import_picocolors7.default.bold("schema:push")} \u2014 manage keys at ${import_picocolors7.default.cyan("https://abloatai.com")}.`;
|
|
280710
280897
|
return {
|
|
280711
280898
|
ok: false,
|
|
280712
280899
|
message: `${serverSays ?? "This key can't author schema (missing schema:push scope)."}
|
|
280713
|
-
` +
|
|
280900
|
+
` + import_picocolors7.default.dim(hint)
|
|
280714
280901
|
};
|
|
280715
280902
|
}
|
|
280716
280903
|
return { ok: false, message: `Push failed (${status2}): ${body.message ?? body.reason ?? bodyText}` };
|
|
@@ -280720,25 +280907,25 @@ async function dev(argv) {
|
|
|
280720
280907
|
try {
|
|
280721
280908
|
args = parseDevArgs(argv);
|
|
280722
280909
|
} catch (err) {
|
|
280723
|
-
console.error(
|
|
280910
|
+
console.error(import_picocolors7.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
280724
280911
|
process.exit(1);
|
|
280725
280912
|
}
|
|
280726
280913
|
if (!args.apiKey) args.apiKey = resolveApiKey("sandbox");
|
|
280727
280914
|
const key = classifyKey(args.apiKey, getMode());
|
|
280728
280915
|
if (!key.ok) {
|
|
280729
|
-
console.error(
|
|
280916
|
+
console.error(import_picocolors7.default.red(` ${key.reason}`));
|
|
280730
280917
|
process.exit(1);
|
|
280731
280918
|
}
|
|
280732
280919
|
console.log(`
|
|
280733
|
-
${brand("ablo")} ${
|
|
280920
|
+
${brand("ablo")} ${import_picocolors7.default.dim("push")} ${import_picocolors7.default.dim("(sandbox)")}
|
|
280734
280921
|
`);
|
|
280735
280922
|
const schema = await loadSchema(args.schemaPath, args.exportName);
|
|
280736
280923
|
const modelCount = Object.keys(schema.models).length;
|
|
280737
280924
|
console.log(
|
|
280738
|
-
` ${
|
|
280925
|
+
` ${import_picocolors7.default.dim("schema")} ${import_picocolors7.default.bold(args.schemaPath)} ${import_picocolors7.default.dim(`(${modelCount} models, hash ${(0, import_schema5.schemaHash)(schema)})`)}`
|
|
280739
280926
|
);
|
|
280740
|
-
console.log(` ${
|
|
280741
|
-
console.log(` ${
|
|
280927
|
+
console.log(` ${import_picocolors7.default.dim("key")} ${args.apiKey.slice(0, 12)}\u2026`);
|
|
280928
|
+
console.log(` ${import_picocolors7.default.dim("api")} ${args.url}
|
|
280742
280929
|
`);
|
|
280743
280930
|
const s = Y2();
|
|
280744
280931
|
s.start("Pushing schema definition (sandbox)");
|
|
@@ -280747,16 +280934,16 @@ async function dev(argv) {
|
|
|
280747
280934
|
if (!first.ok) process.exit(1);
|
|
280748
280935
|
if (process.env.ABLO_API_KEY) {
|
|
280749
280936
|
console.log(`
|
|
280750
|
-
${
|
|
280937
|
+
${import_picocolors7.default.green("\u2713")} ${import_picocolors7.default.bold("ABLO_API_KEY")} is set in this shell \u2014 the SDK reads it directly.`);
|
|
280751
280938
|
} else {
|
|
280752
280939
|
console.log(`
|
|
280753
|
-
${
|
|
280754
|
-
console.log(` ${
|
|
280940
|
+
${import_picocolors7.default.green("\u2713")} ${wireEnvLocal(args.apiKey)}`);
|
|
280941
|
+
console.log(` ${import_picocolors7.default.dim("Frameworks load it automatically; plain Node: node --env-file=.env.local app.ts")}`);
|
|
280755
280942
|
}
|
|
280756
280943
|
console.log(` Your app is wired for the sandbox.`);
|
|
280757
280944
|
if (!args.watch) return;
|
|
280758
280945
|
const abs = (0, import_path5.resolve)(process.cwd(), args.schemaPath);
|
|
280759
|
-
console.log(` ${
|
|
280946
|
+
console.log(` ${import_picocolors7.default.dim(`watching ${args.schemaPath} \u2026 (Ctrl-C to stop)`)}
|
|
280760
280947
|
`);
|
|
280761
280948
|
let timer2 = null;
|
|
280762
280949
|
let pushing = false;
|
|
@@ -280776,7 +280963,7 @@ async function dev(argv) {
|
|
|
280776
280963
|
const r2 = await runPush(next, args);
|
|
280777
280964
|
s2.stop(r2.message, r2.ok ? 0 : 1);
|
|
280778
280965
|
} catch (err) {
|
|
280779
|
-
s2.stop(
|
|
280966
|
+
s2.stop(import_picocolors7.default.red(`schema reload failed: ${err instanceof Error ? err.message : String(err)}`), 1);
|
|
280780
280967
|
} finally {
|
|
280781
280968
|
pushing = false;
|
|
280782
280969
|
}
|
|
@@ -280784,7 +280971,7 @@ async function dev(argv) {
|
|
|
280784
280971
|
const stop = () => {
|
|
280785
280972
|
watcher.close();
|
|
280786
280973
|
console.log(`
|
|
280787
|
-
${
|
|
280974
|
+
${import_picocolors7.default.dim("stopped.")}`);
|
|
280788
280975
|
process.exit(0);
|
|
280789
280976
|
};
|
|
280790
280977
|
process.on("SIGINT", stop);
|
|
@@ -280795,8 +280982,8 @@ async function dev(argv) {
|
|
|
280795
280982
|
|
|
280796
280983
|
// src/cli/login.ts
|
|
280797
280984
|
init_cjs_shims();
|
|
280798
|
-
var
|
|
280799
|
-
var
|
|
280985
|
+
var import_child_process2 = require("child_process");
|
|
280986
|
+
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
280800
280987
|
var CLIENT_ID = "ablo-cli";
|
|
280801
280988
|
var stripSlash = (u2) => u2.replace(/\/+$/, "");
|
|
280802
280989
|
var AUTH_URL = stripSlash(process.env.ABLO_AUTH_URL ?? "https://auth.abloatai.com");
|
|
@@ -280805,7 +280992,7 @@ var sleep = (ms) => new Promise((r2) => setTimeout(r2, ms));
|
|
|
280805
280992
|
function openBrowser(url) {
|
|
280806
280993
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
280807
280994
|
try {
|
|
280808
|
-
const child = (0,
|
|
280995
|
+
const child = (0, import_child_process2.spawn)(cmd, [url], { stdio: "ignore", detached: true, shell: process.platform === "win32" });
|
|
280809
280996
|
child.on("error", () => {
|
|
280810
280997
|
});
|
|
280811
280998
|
child.unref();
|
|
@@ -280854,9 +281041,9 @@ async function deviceLogin(argv, deps = {}) {
|
|
|
280854
281041
|
const code = await codeRes.json();
|
|
280855
281042
|
const approvePath = `/cli?user_code=${code.user_code}`;
|
|
280856
281043
|
const url = account === "signup" ? `${DASHBOARD_URL}/signup?next=${encodeURIComponent(approvePath)}` : `${DASHBOARD_URL}${approvePath}`;
|
|
280857
|
-
Me(`${
|
|
281044
|
+
Me(`${import_picocolors8.default.bold(code.user_code)}
|
|
280858
281045
|
|
|
280859
|
-
${
|
|
281046
|
+
${import_picocolors8.default.dim(url)}`, "Approve in your browser");
|
|
280860
281047
|
openUrl(url);
|
|
280861
281048
|
const s = Y2();
|
|
280862
281049
|
s.start("Waiting for approval\u2026");
|
|
@@ -280923,7 +281110,7 @@ ${import_picocolors7.default.dim(url)}`, "Approve in your browser");
|
|
|
280923
281110
|
if (reason) M2.error(reason);
|
|
280924
281111
|
else if (provRes) M2.error(`Key provisioning returned ${provRes.status} from ${DASHBOARD_URL}/api/cli/provision-key.`);
|
|
280925
281112
|
M2.error(
|
|
280926
|
-
`The browser approval succeeded but the key handoff failed. Try again, or grab a ${
|
|
281113
|
+
`The browser approval succeeded but the key handoff failed. Try again, or grab a ${import_picocolors8.default.bold("sk_test_")} key from the dashboard and set ${import_picocolors8.default.bold("ABLO_API_KEY")}.`
|
|
280927
281114
|
);
|
|
280928
281115
|
process.exit(1);
|
|
280929
281116
|
}
|
|
@@ -280943,9 +281130,9 @@ ${import_picocolors7.default.dim(url)}`, "Approve in your browser");
|
|
|
280943
281130
|
{ mode: "sandbox", activeProject: prov.project ?? void 0 }
|
|
280944
281131
|
);
|
|
280945
281132
|
s.stop(`Saved keys to ${path}`);
|
|
280946
|
-
const where = prov.project ? ` ${
|
|
281133
|
+
const where = prov.project ? ` ${import_picocolors8.default.dim(`(project ${prov.project.slug})`)}` : "";
|
|
280947
281134
|
Se(
|
|
280948
|
-
`${
|
|
281135
|
+
`${import_picocolors8.default.green("\u2713")} Logged in ${import_picocolors8.default.dim("(sandbox)")}${where}. Run ${import_picocolors8.default.bold("npx ablo push")} to push your schema.`
|
|
280949
281136
|
);
|
|
280950
281137
|
}
|
|
280951
281138
|
async function login(argv = [], deps = {}) {
|
|
@@ -280954,20 +281141,20 @@ async function login(argv = [], deps = {}) {
|
|
|
280954
281141
|
function logout() {
|
|
280955
281142
|
const removed = clearCredential();
|
|
280956
281143
|
if (removed) {
|
|
280957
|
-
console.log(` ${
|
|
281144
|
+
console.log(` ${import_picocolors8.default.green("\u2713")} Logged out ${import_picocolors8.default.dim(`(credentials removed from ${configDir()})`)}`);
|
|
280958
281145
|
} else {
|
|
280959
|
-
console.log(` ${
|
|
281146
|
+
console.log(` ${import_picocolors8.default.dim("\u25CB")} Not logged in \u2014 nothing to remove.`);
|
|
280960
281147
|
}
|
|
280961
281148
|
if (process.env.ABLO_API_KEY) {
|
|
280962
281149
|
console.log(
|
|
280963
|
-
|
|
281150
|
+
import_picocolors8.default.dim(` Note: ${import_picocolors8.default.bold("ABLO_API_KEY")} is still set in this shell and takes precedence.`)
|
|
280964
281151
|
);
|
|
280965
281152
|
}
|
|
280966
281153
|
}
|
|
280967
281154
|
|
|
280968
281155
|
// src/cli/mode.ts
|
|
280969
281156
|
init_cjs_shims();
|
|
280970
|
-
var
|
|
281157
|
+
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
280971
281158
|
var PREFIX = { sandbox: "sk_test_", production: "rk_live_" };
|
|
280972
281159
|
function hintFor(m2, current) {
|
|
280973
281160
|
const parts = [];
|
|
@@ -280977,10 +281164,10 @@ function hintFor(m2, current) {
|
|
|
280977
281164
|
}
|
|
280978
281165
|
function apply(m2) {
|
|
280979
281166
|
setMode(m2);
|
|
280980
|
-
console.log(` ${
|
|
281167
|
+
console.log(` ${import_picocolors9.default.green("\u2713")} now in ${import_picocolors9.default.bold(m2)}`);
|
|
280981
281168
|
if (!getKeyEntry(m2)) {
|
|
280982
281169
|
console.log(
|
|
280983
|
-
|
|
281170
|
+
import_picocolors9.default.dim(` No ${m2} key stored \u2014 run ${import_picocolors9.default.bold("ablo login")} or ${import_picocolors9.default.bold(`ablo login --api-key ${PREFIX[m2]}\u2026`)}.`)
|
|
280984
281171
|
);
|
|
280985
281172
|
}
|
|
280986
281173
|
}
|
|
@@ -280993,14 +281180,14 @@ async function mode(argv) {
|
|
|
280993
281180
|
}
|
|
280994
281181
|
if (arg) {
|
|
280995
281182
|
console.error(
|
|
280996
|
-
|
|
281183
|
+
import_picocolors9.default.red(` unknown mode: ${arg}`) + import_picocolors9.default.dim(` (expected ${import_picocolors9.default.bold("sandbox")} or ${import_picocolors9.default.bold("production")})`)
|
|
280997
281184
|
);
|
|
280998
281185
|
process.exit(1);
|
|
280999
281186
|
}
|
|
281000
281187
|
const current = getMode();
|
|
281001
281188
|
if (!process.stdin.isTTY || process.env.CI) {
|
|
281002
281189
|
console.error(
|
|
281003
|
-
|
|
281190
|
+
import_picocolors9.default.red(" `ablo mode` needs an argument without a TTY: ") + import_picocolors9.default.bold("ablo mode sandbox") + import_picocolors9.default.dim(" | ") + import_picocolors9.default.bold("ablo mode production") + import_picocolors9.default.dim(` (current: ${current})`)
|
|
281004
281191
|
);
|
|
281005
281192
|
process.exit(1);
|
|
281006
281193
|
}
|
|
@@ -281021,7 +281208,7 @@ async function mode(argv) {
|
|
|
281021
281208
|
|
|
281022
281209
|
// src/cli/projects.ts
|
|
281023
281210
|
init_cjs_shims();
|
|
281024
|
-
var
|
|
281211
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
281025
281212
|
function apiUrl() {
|
|
281026
281213
|
return (process.env.ABLO_API_URL ?? DEFAULT_URL).replace(/\/+$/, "");
|
|
281027
281214
|
}
|
|
@@ -281029,8 +281216,8 @@ function requireKey() {
|
|
|
281029
281216
|
const apiKey = resolveApiKey();
|
|
281030
281217
|
if (!apiKey) {
|
|
281031
281218
|
console.error(
|
|
281032
|
-
|
|
281033
|
-
` Run ${
|
|
281219
|
+
import_picocolors10.default.red(" No API key.") + import_picocolors10.default.dim(
|
|
281220
|
+
` Run ${import_picocolors10.default.bold("npx ablo login")} \u2014 or set ${import_picocolors10.default.bold("ABLO_API_KEY")} (${import_picocolors10.default.bold("sk_test_")} = sandbox; ${import_picocolors10.default.bold("sk_live_")} = production).`
|
|
281034
281221
|
)
|
|
281035
281222
|
);
|
|
281036
281223
|
process.exit(1);
|
|
@@ -281065,7 +281252,7 @@ async function listProjects(apiKey) {
|
|
|
281065
281252
|
async function fetchProjects() {
|
|
281066
281253
|
const all = await listProjects(requireKey());
|
|
281067
281254
|
if (!all) {
|
|
281068
|
-
console.error(
|
|
281255
|
+
console.error(import_picocolors10.default.red(" Could not list projects \u2014 is the API reachable and the key valid?"));
|
|
281069
281256
|
process.exit(1);
|
|
281070
281257
|
}
|
|
281071
281258
|
return all;
|
|
@@ -281105,10 +281292,10 @@ function printList(projects2) {
|
|
|
281105
281292
|
const active = getActiveProject();
|
|
281106
281293
|
for (const p2 of projects2) {
|
|
281107
281294
|
const isActive = active ? active.id === p2.id : p2.default;
|
|
281108
|
-
const marker = isActive ?
|
|
281109
|
-
const tags = [p2.default ?
|
|
281295
|
+
const marker = isActive ? import_picocolors10.default.green("\u25CF") : import_picocolors10.default.dim("\u25CB");
|
|
281296
|
+
const tags = [p2.default ? import_picocolors10.default.dim("default") : "", isActive ? import_picocolors10.default.green("active") : ""].filter(Boolean).join(import_picocolors10.default.dim(", "));
|
|
281110
281297
|
console.log(
|
|
281111
|
-
` ${marker} ${p2.slug.padEnd(20)} ${
|
|
281298
|
+
` ${marker} ${p2.slug.padEnd(20)} ${import_picocolors10.default.dim(p2.id)}${tags ? ` ${tags}` : ""}`
|
|
281112
281299
|
);
|
|
281113
281300
|
}
|
|
281114
281301
|
}
|
|
@@ -281116,7 +281303,7 @@ async function projects(argv) {
|
|
|
281116
281303
|
const sub = argv[0];
|
|
281117
281304
|
if (sub === "list" || sub === void 0) {
|
|
281118
281305
|
console.log(`
|
|
281119
|
-
${brand("ablo")} ${
|
|
281306
|
+
${brand("ablo")} ${import_picocolors10.default.dim("projects")}
|
|
281120
281307
|
`);
|
|
281121
281308
|
printList(await fetchProjects());
|
|
281122
281309
|
console.log();
|
|
@@ -281125,7 +281312,7 @@ async function projects(argv) {
|
|
|
281125
281312
|
if (sub === "create") {
|
|
281126
281313
|
const slug = argv[1];
|
|
281127
281314
|
if (!slug || slug.startsWith("-")) {
|
|
281128
|
-
console.error(
|
|
281315
|
+
console.error(import_picocolors10.default.red(' usage: ablo projects create <slug> [--name "Display Name"]'));
|
|
281129
281316
|
process.exit(1);
|
|
281130
281317
|
}
|
|
281131
281318
|
const nameIdx = argv.indexOf("--name");
|
|
@@ -281136,17 +281323,17 @@ async function projects(argv) {
|
|
|
281136
281323
|
});
|
|
281137
281324
|
if (status2 !== 201) {
|
|
281138
281325
|
console.error(
|
|
281139
|
-
|
|
281326
|
+
import_picocolors10.default.red(` Create failed (${status2}): ${String(body.message ?? body.code ?? "")}`)
|
|
281140
281327
|
);
|
|
281141
281328
|
if (body.code === "project_slug_taken") {
|
|
281142
|
-
console.error(
|
|
281329
|
+
console.error(import_picocolors10.default.dim(` Pick another slug, or switch to it: ${import_picocolors10.default.bold(`ablo projects use ${slug}`)}`));
|
|
281143
281330
|
}
|
|
281144
281331
|
process.exit(1);
|
|
281145
281332
|
}
|
|
281146
281333
|
const created = body;
|
|
281147
|
-
console.log(` ${
|
|
281334
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} Created project ${import_picocolors10.default.bold(created.slug)} ${import_picocolors10.default.dim(`(${created.id})`)}`);
|
|
281148
281335
|
console.log(
|
|
281149
|
-
|
|
281336
|
+
import_picocolors10.default.dim(` Make it active with ${import_picocolors10.default.bold(`ablo projects use ${created.slug}`)}; mint its keys in the dashboard.`)
|
|
281150
281337
|
);
|
|
281151
281338
|
return;
|
|
281152
281339
|
}
|
|
@@ -281154,17 +281341,17 @@ async function projects(argv) {
|
|
|
281154
281341
|
const ref = argv[1];
|
|
281155
281342
|
const name = argv.slice(2).join(" ").trim();
|
|
281156
281343
|
if (!ref || ref.startsWith("-") || !name) {
|
|
281157
|
-
console.error(
|
|
281344
|
+
console.error(import_picocolors10.default.red(" usage: ablo projects rename <slug|id> <new name>"));
|
|
281158
281345
|
process.exit(1);
|
|
281159
281346
|
}
|
|
281160
281347
|
const all = await fetchProjects();
|
|
281161
281348
|
const target = all.find((p2) => p2.slug === ref || p2.id === ref);
|
|
281162
281349
|
if (!target) {
|
|
281163
|
-
console.error(
|
|
281350
|
+
console.error(import_picocolors10.default.red(` No project "${ref}".`) + import_picocolors10.default.dim(" Run ablo projects list."));
|
|
281164
281351
|
process.exit(1);
|
|
281165
281352
|
}
|
|
281166
281353
|
if (target.default) {
|
|
281167
|
-
console.error(
|
|
281354
|
+
console.error(import_picocolors10.default.red(" The default project cannot be renamed."));
|
|
281168
281355
|
process.exit(1);
|
|
281169
281356
|
}
|
|
281170
281357
|
const { status: status2, body } = await request(`/api/v1/projects/${target.id}`, requireKey(), {
|
|
@@ -281173,47 +281360,47 @@ async function projects(argv) {
|
|
|
281173
281360
|
});
|
|
281174
281361
|
if (status2 !== 200) {
|
|
281175
281362
|
console.error(
|
|
281176
|
-
|
|
281363
|
+
import_picocolors10.default.red(` Rename failed (${status2}): ${String(body.message ?? body.code ?? "")}`)
|
|
281177
281364
|
);
|
|
281178
281365
|
process.exit(1);
|
|
281179
281366
|
}
|
|
281180
281367
|
const updated = body;
|
|
281181
281368
|
console.log(
|
|
281182
|
-
` ${
|
|
281369
|
+
` ${import_picocolors10.default.green("\u2713")} Renamed ${import_picocolors10.default.bold(updated.slug)} \u2192 ${import_picocolors10.default.bold(updated.name ?? updated.slug)} ${import_picocolors10.default.dim(`(${updated.id})`)}`
|
|
281183
281370
|
);
|
|
281184
281371
|
return;
|
|
281185
281372
|
}
|
|
281186
281373
|
if (sub === "use") {
|
|
281187
281374
|
const ref = argv[1];
|
|
281188
281375
|
if (!ref) {
|
|
281189
|
-
console.error(
|
|
281376
|
+
console.error(import_picocolors10.default.red(" usage: ablo projects use <slug|id|default>"));
|
|
281190
281377
|
process.exit(1);
|
|
281191
281378
|
}
|
|
281192
281379
|
const all = await fetchProjects();
|
|
281193
281380
|
const target = all.find((p2) => p2.slug === ref || p2.id === ref);
|
|
281194
281381
|
if (!target) {
|
|
281195
|
-
console.error(
|
|
281382
|
+
console.error(import_picocolors10.default.red(` No project "${ref}".`) + import_picocolors10.default.dim(" Run ablo projects list."));
|
|
281196
281383
|
process.exit(1);
|
|
281197
281384
|
}
|
|
281198
281385
|
if (target.default) {
|
|
281199
281386
|
setActiveProject(void 0);
|
|
281200
|
-
console.log(` ${
|
|
281387
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} now targeting the ${import_picocolors10.default.bold("default")} project`);
|
|
281201
281388
|
} else {
|
|
281202
281389
|
setActiveProject({ id: target.id, slug: target.slug });
|
|
281203
|
-
console.log(` ${
|
|
281390
|
+
console.log(` ${import_picocolors10.default.green("\u2713")} now targeting project ${import_picocolors10.default.bold(target.slug)} ${import_picocolors10.default.dim(`(${target.id})`)}`);
|
|
281204
281391
|
}
|
|
281205
281392
|
const guard = guardActiveProjectKey();
|
|
281206
281393
|
if (!guard.ok) {
|
|
281207
281394
|
const loginCmd = guard.activeProfile === DEFAULT_PROFILE ? "ablo login" : `ablo login --project ${guard.activeProfile}`;
|
|
281208
281395
|
console.log(
|
|
281209
|
-
|
|
281396
|
+
import_picocolors10.default.dim(` No key stored for this project yet \u2014 run ${import_picocolors10.default.bold(loginCmd)} to mint one.`)
|
|
281210
281397
|
);
|
|
281211
281398
|
}
|
|
281212
281399
|
return;
|
|
281213
281400
|
}
|
|
281214
281401
|
console.error(
|
|
281215
|
-
|
|
281216
|
-
` (expected ${
|
|
281402
|
+
import_picocolors10.default.red(` unknown subcommand: ${sub}`) + import_picocolors10.default.dim(
|
|
281403
|
+
` (expected ${import_picocolors10.default.bold("list")}, ${import_picocolors10.default.bold("create")}, ${import_picocolors10.default.bold("rename")}, or ${import_picocolors10.default.bold("use")})`
|
|
281217
281404
|
)
|
|
281218
281405
|
);
|
|
281219
281406
|
process.exit(1);
|
|
@@ -281221,13 +281408,13 @@ async function projects(argv) {
|
|
|
281221
281408
|
|
|
281222
281409
|
// src/cli/status.ts
|
|
281223
281410
|
init_cjs_shims();
|
|
281224
|
-
var
|
|
281411
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
281225
281412
|
function expiryLabel(iso) {
|
|
281226
281413
|
const ms = Date.parse(iso) - Date.now();
|
|
281227
281414
|
if (Number.isNaN(ms)) return "";
|
|
281228
|
-
if (ms <= 0) return
|
|
281415
|
+
if (ms <= 0) return import_picocolors11.default.red("expired");
|
|
281229
281416
|
const days = Math.floor(ms / (24 * 60 * 60 * 1e3));
|
|
281230
|
-
return
|
|
281417
|
+
return import_picocolors11.default.dim(days > 0 ? `expires in ${days}d` : "expires <1d");
|
|
281231
281418
|
}
|
|
281232
281419
|
async function ping(apiUrl2) {
|
|
281233
281420
|
const ctrl = new AbortController();
|
|
@@ -281309,59 +281496,59 @@ async function status(args = []) {
|
|
|
281309
281496
|
return;
|
|
281310
281497
|
}
|
|
281311
281498
|
console.log(`
|
|
281312
|
-
${brand("ablo")} ${
|
|
281499
|
+
${brand("ablo")} ${import_picocolors11.default.dim("status")}
|
|
281313
281500
|
`);
|
|
281314
281501
|
if (process.env.ABLO_API_KEY) {
|
|
281315
281502
|
console.log(
|
|
281316
|
-
` ${
|
|
281503
|
+
` ${import_picocolors11.default.dim("key")} ${process.env.ABLO_API_KEY.slice(0, 12)}\u2026 ${import_picocolors11.default.dim("(ABLO_API_KEY env \u2014 overrides stored)")}`
|
|
281317
281504
|
);
|
|
281318
281505
|
} else if (!cfg) {
|
|
281319
|
-
console.log(` ${
|
|
281506
|
+
console.log(` ${import_picocolors11.default.yellow("!")} Not logged in \u2014 run ${import_picocolors11.default.bold("ablo login")}.`);
|
|
281320
281507
|
}
|
|
281321
|
-
console.log(` ${
|
|
281508
|
+
console.log(` ${import_picocolors11.default.dim("mode")} ${import_picocolors11.default.bold(mode2)}`);
|
|
281322
281509
|
const activeEntry = getKeyEntry(mode2);
|
|
281323
281510
|
const key = describeEffectiveKey(mode2, process.env.ABLO_API_KEY, activeEntry);
|
|
281324
281511
|
if (key.keyMismatch) {
|
|
281325
|
-
console.log(` ${
|
|
281512
|
+
console.log(` ${import_picocolors11.default.yellow("!")} ${import_picocolors11.default.yellow(key.keyMismatch.message)}`);
|
|
281326
281513
|
}
|
|
281327
281514
|
const activeProject = getActiveProject();
|
|
281328
281515
|
console.log(
|
|
281329
|
-
` ${
|
|
281516
|
+
` ${import_picocolors11.default.dim("project")} ${activeProject ? `${import_picocolors11.default.bold(activeProject.slug)} ${import_picocolors11.default.dim(`(${activeProject.id})`)}` : import_picocolors11.default.bold("default")}`
|
|
281330
281517
|
);
|
|
281331
281518
|
for (const m2 of ["sandbox", "production"]) {
|
|
281332
281519
|
const entry = getKeyEntry(m2);
|
|
281333
|
-
const marker = m2 === mode2 ?
|
|
281520
|
+
const marker = m2 === mode2 ? import_picocolors11.default.green("\u25CF") : import_picocolors11.default.dim("\u25CB");
|
|
281334
281521
|
if (entry) {
|
|
281335
281522
|
const exp = entry.expiresAt ? ` ${expiryLabel(entry.expiresAt)}` : "";
|
|
281336
|
-
console.log(` ${marker} ${m2.padEnd(10)} ${
|
|
281523
|
+
console.log(` ${marker} ${m2.padEnd(10)} ${import_picocolors11.default.dim(`${entry.apiKey.slice(0, 12)}\u2026`)}${exp}`);
|
|
281337
281524
|
} else {
|
|
281338
|
-
console.log(` ${marker} ${m2.padEnd(10)} ${
|
|
281525
|
+
console.log(` ${marker} ${m2.padEnd(10)} ${import_picocolors11.default.dim("\u2014 no key")}`);
|
|
281339
281526
|
}
|
|
281340
281527
|
}
|
|
281341
281528
|
const org = activeEntry?.organizationId;
|
|
281342
|
-
if (org) console.log(` ${
|
|
281529
|
+
if (org) console.log(` ${import_picocolors11.default.dim("org")} ${org}`);
|
|
281343
281530
|
const plan = resolvePushPlan();
|
|
281344
281531
|
console.log(
|
|
281345
|
-
` ${
|
|
281532
|
+
` ${import_picocolors11.default.dim("push")} ${plan.apiKey ? `${import_picocolors11.default.bold(plan.flow)} ${import_picocolors11.default.dim(`with ${plan.apiKey.slice(0, 12)}\u2026 (${plan.source})`)}` : `${import_picocolors11.default.bold(plan.flow)} ${import_picocolors11.default.yellow("\u2014 no credential")} ${import_picocolors11.default.dim(`(run ${import_picocolors11.default.bold("ablo login")} or set ${import_picocolors11.default.bold("ABLO_API_KEY")})`)}`}`
|
|
281346
281533
|
);
|
|
281347
|
-
process.stdout.write(` ${
|
|
281534
|
+
process.stdout.write(` ${import_picocolors11.default.dim("api")} ${apiUrl2} `);
|
|
281348
281535
|
const reachable = await ping(apiUrl2);
|
|
281349
|
-
console.log(reachable ?
|
|
281536
|
+
console.log(reachable ? import_picocolors11.default.green("reachable") : import_picocolors11.default.red("unreachable"));
|
|
281350
281537
|
if (reachable) {
|
|
281351
281538
|
const introspectKey = process.env.ABLO_API_KEY ?? activeEntry?.apiKey;
|
|
281352
281539
|
const pushed = await fetchPushedSchema(apiUrl2, introspectKey);
|
|
281353
281540
|
if (pushed && pushed.active) {
|
|
281354
|
-
const when = pushed.pushedAt ? ` ${
|
|
281355
|
-
const ver = pushed.version != null ? ` ${
|
|
281356
|
-
console.log(` ${
|
|
281541
|
+
const when = pushed.pushedAt ? ` ${import_picocolors11.default.dim(`@ ${pushed.pushedAt.slice(0, 10)}`)}` : "";
|
|
281542
|
+
const ver = pushed.version != null ? ` ${import_picocolors11.default.dim(`(rev ${pushed.version})`)}` : "";
|
|
281543
|
+
console.log(` ${import_picocolors11.default.dim("schema")} ${import_picocolors11.default.bold(`${pushed.models.length} models pushed`)}${ver}${when}`);
|
|
281357
281544
|
for (const m2 of pushed.models) {
|
|
281358
|
-
const tn = m2.typename === m2.key ?
|
|
281545
|
+
const tn = m2.typename === m2.key ? import_picocolors11.default.dim(`typename=${m2.typename}`) : import_picocolors11.default.yellow(`typename=${m2.typename}`);
|
|
281359
281546
|
const conflict = formatConflict(m2.conflict);
|
|
281360
|
-
const
|
|
281361
|
-
console.log(` ${
|
|
281547
|
+
const conflictStr2 = conflict ? ` ${import_picocolors11.default.dim(`conflict=${conflict}`)}` : "";
|
|
281548
|
+
console.log(` ${import_picocolors11.default.dim("\u2022")} ${m2.key.padEnd(14)} ${tn}${conflictStr2}`);
|
|
281362
281549
|
}
|
|
281363
281550
|
} else if (pushed && !pushed.active) {
|
|
281364
|
-
console.log(` ${
|
|
281551
|
+
console.log(` ${import_picocolors11.default.dim("schema")} ${import_picocolors11.default.yellow("none pushed")} ${import_picocolors11.default.dim(`(run ${import_picocolors11.default.bold("ablo push")} or ${import_picocolors11.default.bold("ablo dev")})`)}`);
|
|
281365
281552
|
}
|
|
281366
281553
|
}
|
|
281367
281554
|
console.log();
|
|
@@ -281369,7 +281556,7 @@ async function status(args = []) {
|
|
|
281369
281556
|
|
|
281370
281557
|
// src/cli/logs.ts
|
|
281371
281558
|
init_cjs_shims();
|
|
281372
|
-
var
|
|
281559
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
281373
281560
|
function parseLogsArgs(argv) {
|
|
281374
281561
|
const args = {
|
|
281375
281562
|
follow: true,
|
|
@@ -281433,10 +281620,10 @@ function resolveSince(since) {
|
|
|
281433
281620
|
var sleep2 = (ms) => new Promise((r2) => setTimeout(r2, ms));
|
|
281434
281621
|
function colorOp(op) {
|
|
281435
281622
|
const label = op.padEnd(6);
|
|
281436
|
-
if (op === "create") return
|
|
281437
|
-
if (op === "update") return
|
|
281438
|
-
if (op === "delete") return
|
|
281439
|
-
return
|
|
281623
|
+
if (op === "create") return import_picocolors12.default.green(label);
|
|
281624
|
+
if (op === "update") return import_picocolors12.default.yellow(label);
|
|
281625
|
+
if (op === "delete") return import_picocolors12.default.red(label);
|
|
281626
|
+
return import_picocolors12.default.dim(label);
|
|
281440
281627
|
}
|
|
281441
281628
|
function render(e2, json) {
|
|
281442
281629
|
if (json) {
|
|
@@ -281445,21 +281632,21 @@ function render(e2, json) {
|
|
|
281445
281632
|
return;
|
|
281446
281633
|
}
|
|
281447
281634
|
const t = new Date(e2.at).toLocaleTimeString();
|
|
281448
|
-
const actor = e2.actor ?
|
|
281449
|
-
console.log(` ${
|
|
281635
|
+
const actor = e2.actor ? import_picocolors12.default.dim(` ${e2.actor}`) : "";
|
|
281636
|
+
console.log(` ${import_picocolors12.default.dim(t)} ${colorOp(e2.op)} ${import_picocolors12.default.bold(e2.model)} ${import_picocolors12.default.dim(e2.recordId)}${actor}`);
|
|
281450
281637
|
}
|
|
281451
281638
|
async function logs(argv) {
|
|
281452
281639
|
let args;
|
|
281453
281640
|
try {
|
|
281454
281641
|
args = parseLogsArgs(argv);
|
|
281455
281642
|
} catch (err) {
|
|
281456
|
-
console.error(
|
|
281643
|
+
console.error(import_picocolors12.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
281457
281644
|
process.exit(1);
|
|
281458
281645
|
}
|
|
281459
281646
|
const apiKey = resolveApiKey(args.mode);
|
|
281460
281647
|
if (!apiKey) {
|
|
281461
281648
|
console.error(
|
|
281462
|
-
|
|
281649
|
+
import_picocolors12.default.red(` No API key.`) + import_picocolors12.default.dim(` Run ${import_picocolors12.default.bold("ablo login")} or set ${import_picocolors12.default.bold("ABLO_API_KEY")}.`)
|
|
281463
281650
|
);
|
|
281464
281651
|
process.exit(1);
|
|
281465
281652
|
}
|
|
@@ -281473,7 +281660,7 @@ async function logs(argv) {
|
|
|
281473
281660
|
if (!res) return null;
|
|
281474
281661
|
if (!res.ok) {
|
|
281475
281662
|
const body = await res.json().catch(() => ({}));
|
|
281476
|
-
console.error(
|
|
281663
|
+
console.error(import_picocolors12.default.red(` logs failed (${res.status}): ${body.reason ?? body.message ?? ""}`));
|
|
281477
281664
|
process.exit(1);
|
|
281478
281665
|
}
|
|
281479
281666
|
const json = await res.json();
|
|
@@ -281484,7 +281671,7 @@ async function logs(argv) {
|
|
|
281484
281671
|
}
|
|
281485
281672
|
if (!args.json) {
|
|
281486
281673
|
console.log(`
|
|
281487
|
-
${brand("ablo")} ${
|
|
281674
|
+
${brand("ablo")} ${import_picocolors12.default.dim("logs")} ${import_picocolors12.default.dim(`(${args.mode ?? "active"} mode)`)}
|
|
281488
281675
|
`);
|
|
281489
281676
|
}
|
|
281490
281677
|
const initial = await fetchPage({
|
|
@@ -281494,13 +281681,13 @@ async function logs(argv) {
|
|
|
281494
281681
|
...args.op ? { op: args.op } : {}
|
|
281495
281682
|
});
|
|
281496
281683
|
if (!initial) {
|
|
281497
|
-
console.error(
|
|
281684
|
+
console.error(import_picocolors12.default.red(` Couldn't reach ${baseUrl2}.`));
|
|
281498
281685
|
process.exit(1);
|
|
281499
281686
|
}
|
|
281500
281687
|
for (const e2 of initial.events) render(e2, args.json);
|
|
281501
281688
|
let cursor = initial.cursor;
|
|
281502
281689
|
if (!args.follow) return;
|
|
281503
|
-
if (!args.json) console.log(` ${
|
|
281690
|
+
if (!args.json) console.log(` ${import_picocolors12.default.dim("watching for new activity \u2026 (Ctrl-C to stop)")}
|
|
281504
281691
|
`);
|
|
281505
281692
|
for (; ; ) {
|
|
281506
281693
|
await sleep2(1500);
|
|
@@ -281518,7 +281705,7 @@ async function logs(argv) {
|
|
|
281518
281705
|
// src/cli/webhooks.ts
|
|
281519
281706
|
init_cjs_shims();
|
|
281520
281707
|
var import_fs8 = require("fs");
|
|
281521
|
-
var
|
|
281708
|
+
var import_picocolors13 = __toESM(require_picocolors(), 1);
|
|
281522
281709
|
var ENV_KEY = "ABLO_WEBHOOK_SECRET";
|
|
281523
281710
|
function flag(args, name) {
|
|
281524
281711
|
const inline = args.find((a) => a.startsWith(`${name}=`));
|
|
@@ -281545,12 +281732,12 @@ function requireKey2(mode2) {
|
|
|
281545
281732
|
const apiKey = resolveApiKey(mode2);
|
|
281546
281733
|
if (!apiKey) {
|
|
281547
281734
|
console.error(
|
|
281548
|
-
|
|
281735
|
+
import_picocolors13.default.red(" No API key.") + import_picocolors13.default.dim(` Run ${import_picocolors13.default.bold("ablo login")} or set ${import_picocolors13.default.bold("ABLO_API_KEY")}.`)
|
|
281549
281736
|
);
|
|
281550
281737
|
process.exit(1);
|
|
281551
281738
|
}
|
|
281552
281739
|
if (classifyCredentialKind(apiKey) !== "secret") {
|
|
281553
|
-
console.error(
|
|
281740
|
+
console.error(import_picocolors13.default.red(" Managing webhooks requires a secret key ") + import_picocolors13.default.dim("(sk_test_ / sk_live_)."));
|
|
281554
281741
|
process.exit(1);
|
|
281555
281742
|
}
|
|
281556
281743
|
return apiKey;
|
|
@@ -281566,12 +281753,12 @@ async function api(apiKey, method, path, body) {
|
|
|
281566
281753
|
...body ? { body: JSON.stringify(body) } : {}
|
|
281567
281754
|
}).catch(() => null);
|
|
281568
281755
|
if (!res) {
|
|
281569
|
-
console.error(
|
|
281756
|
+
console.error(import_picocolors13.default.red(` Couldn't reach ${baseUrl()}.`));
|
|
281570
281757
|
process.exit(1);
|
|
281571
281758
|
}
|
|
281572
281759
|
if (!res.ok) {
|
|
281573
281760
|
const err = await res.json().catch(() => ({}));
|
|
281574
|
-
console.error(
|
|
281761
|
+
console.error(import_picocolors13.default.red(` Request failed (${res.status}): ${err.message ?? err.reason ?? ""}`));
|
|
281575
281762
|
process.exit(1);
|
|
281576
281763
|
}
|
|
281577
281764
|
return await res.json();
|
|
@@ -281593,11 +281780,11 @@ ${line}
|
|
|
281593
281780
|
return file;
|
|
281594
281781
|
}
|
|
281595
281782
|
function printEndpoint(e2) {
|
|
281596
|
-
const dot = e2.status === "enabled" ?
|
|
281597
|
-
const health = e2.last_error ?
|
|
281598
|
-
console.log(` ${dot} ${
|
|
281783
|
+
const dot = e2.status === "enabled" ? import_picocolors13.default.green("\u25CF") : import_picocolors13.default.red("\u25CF");
|
|
281784
|
+
const health = e2.last_error ? import_picocolors13.default.red(` last error: ${e2.last_error}`) : "";
|
|
281785
|
+
console.log(` ${dot} ${import_picocolors13.default.bold(e2.id)} ${e2.url}`);
|
|
281599
281786
|
console.log(
|
|
281600
|
-
|
|
281787
|
+
import_picocolors13.default.dim(
|
|
281601
281788
|
` ${e2.status} \xB7 ${e2.environment} \xB7 events ${e2.enabled_events.join(",")} \xB7 cursor ${e2.cursor ?? "\u2014"}${health}`
|
|
281602
281789
|
)
|
|
281603
281790
|
);
|
|
@@ -281609,7 +281796,7 @@ async function webhooks(argv) {
|
|
|
281609
281796
|
if (sub === "create") {
|
|
281610
281797
|
const url = positional(rest);
|
|
281611
281798
|
if (!url) {
|
|
281612
|
-
console.error(
|
|
281799
|
+
console.error(import_picocolors13.default.red(" Usage: ") + brand("ablo webhooks create <url>"));
|
|
281613
281800
|
process.exit(1);
|
|
281614
281801
|
}
|
|
281615
281802
|
const apiKey = requireKey2(mode2);
|
|
@@ -281621,8 +281808,8 @@ async function webhooks(argv) {
|
|
|
281621
281808
|
});
|
|
281622
281809
|
const file = writeSecretToEnv(created.secret);
|
|
281623
281810
|
console.log(`
|
|
281624
|
-
${
|
|
281625
|
-
console.log(` ${
|
|
281811
|
+
${import_picocolors13.default.green("\u2713")} Registered ${import_picocolors13.default.bold(created.id)} \u2192 ${created.url}`);
|
|
281812
|
+
console.log(` ${import_picocolors13.default.green("\u2713")} Wrote ${import_picocolors13.default.bold(ENV_KEY)} to ${import_picocolors13.default.bold(file)} ${import_picocolors13.default.dim("(shown once)")}
|
|
281626
281813
|
`);
|
|
281627
281814
|
return;
|
|
281628
281815
|
}
|
|
@@ -281630,7 +281817,7 @@ async function webhooks(argv) {
|
|
|
281630
281817
|
const apiKey = requireKey2(mode2);
|
|
281631
281818
|
const { data } = await api(apiKey, "GET", "");
|
|
281632
281819
|
if (data.length === 0) {
|
|
281633
|
-
console.log(
|
|
281820
|
+
console.log(import_picocolors13.default.dim(" No webhook endpoints. ") + brand("ablo webhooks create <url>"));
|
|
281634
281821
|
return;
|
|
281635
281822
|
}
|
|
281636
281823
|
console.log();
|
|
@@ -281641,40 +281828,40 @@ async function webhooks(argv) {
|
|
|
281641
281828
|
if (sub === "roll") {
|
|
281642
281829
|
const id = positional(rest);
|
|
281643
281830
|
if (!id) {
|
|
281644
|
-
console.error(
|
|
281831
|
+
console.error(import_picocolors13.default.red(" Usage: ") + brand("ablo webhooks roll <id>"));
|
|
281645
281832
|
process.exit(1);
|
|
281646
281833
|
}
|
|
281647
281834
|
const apiKey = requireKey2(mode2);
|
|
281648
281835
|
const rolled = await api(apiKey, "POST", `/${id}/roll_secret`);
|
|
281649
281836
|
const file = writeSecretToEnv(rolled.secret);
|
|
281650
281837
|
console.log(`
|
|
281651
|
-
${
|
|
281838
|
+
${import_picocolors13.default.green("\u2713")} Rolled secret for ${import_picocolors13.default.bold(id)} \u2192 ${import_picocolors13.default.bold(file)} ${import_picocolors13.default.dim("(old secret now invalid)")}
|
|
281652
281839
|
`);
|
|
281653
281840
|
return;
|
|
281654
281841
|
}
|
|
281655
281842
|
if (sub === "enable") {
|
|
281656
281843
|
const id = positional(rest);
|
|
281657
281844
|
if (!id) {
|
|
281658
|
-
console.error(
|
|
281845
|
+
console.error(import_picocolors13.default.red(" Usage: ") + brand("ablo webhooks enable <id>"));
|
|
281659
281846
|
process.exit(1);
|
|
281660
281847
|
}
|
|
281661
281848
|
const apiKey = requireKey2(mode2);
|
|
281662
281849
|
const e2 = await api(apiKey, "POST", `/${id}/enable`);
|
|
281663
|
-
console.log(` ${
|
|
281850
|
+
console.log(` ${import_picocolors13.default.green("\u2713")} Re-enabled ${import_picocolors13.default.bold(e2.id)}`);
|
|
281664
281851
|
return;
|
|
281665
281852
|
}
|
|
281666
281853
|
if (sub === "rm" || sub === "delete") {
|
|
281667
281854
|
const id = positional(rest);
|
|
281668
281855
|
if (!id) {
|
|
281669
|
-
console.error(
|
|
281856
|
+
console.error(import_picocolors13.default.red(" Usage: ") + brand("ablo webhooks rm <id>"));
|
|
281670
281857
|
process.exit(1);
|
|
281671
281858
|
}
|
|
281672
281859
|
const apiKey = requireKey2(mode2);
|
|
281673
281860
|
await api(apiKey, "DELETE", `/${id}`);
|
|
281674
|
-
console.log(` ${
|
|
281861
|
+
console.log(` ${import_picocolors13.default.green("\u2713")} Removed ${import_picocolors13.default.bold(id)}`);
|
|
281675
281862
|
return;
|
|
281676
281863
|
}
|
|
281677
|
-
console.log(` ${
|
|
281864
|
+
console.log(` ${import_picocolors13.default.bold("Usage:")}`);
|
|
281678
281865
|
console.log(` ${brand("ablo webhooks create <url>")} Register an endpoint; writes ${ENV_KEY}`);
|
|
281679
281866
|
console.log(` ${brand("ablo webhooks list")} List endpoints + delivery health`);
|
|
281680
281867
|
console.log(` ${brand("ablo webhooks roll <id>")} Mint a fresh signing secret`);
|
|
@@ -281685,7 +281872,7 @@ async function webhooks(argv) {
|
|
|
281685
281872
|
|
|
281686
281873
|
// src/cli/check.ts
|
|
281687
281874
|
init_cjs_shims();
|
|
281688
|
-
var
|
|
281875
|
+
var import_picocolors14 = __toESM(require_picocolors(), 1);
|
|
281689
281876
|
var import_schema6 = require("@abloatai/ablo/schema");
|
|
281690
281877
|
var DEFAULT_SCHEMA_PATH4 = "ablo/schema.ts";
|
|
281691
281878
|
var DEFAULT_EXPORT4 = "schema";
|
|
@@ -281720,13 +281907,13 @@ async function check(argv) {
|
|
|
281720
281907
|
try {
|
|
281721
281908
|
args = parseCheckArgs(argv);
|
|
281722
281909
|
} catch (err) {
|
|
281723
|
-
console.error(
|
|
281910
|
+
console.error(import_picocolors14.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
281724
281911
|
process.exit(1);
|
|
281725
281912
|
}
|
|
281726
281913
|
const dbUrl = process.env.DATABASE_URL ?? process.env.ABLO_DATABASE_URL;
|
|
281727
281914
|
if (!dbUrl) {
|
|
281728
281915
|
console.error(
|
|
281729
|
-
|
|
281916
|
+
import_picocolors14.default.red(` No database.`) + import_picocolors14.default.dim(` Set ${import_picocolors14.default.bold("DATABASE_URL")} to the Postgres you want Ablo to adopt.`)
|
|
281730
281917
|
);
|
|
281731
281918
|
process.exit(1);
|
|
281732
281919
|
}
|
|
@@ -281741,7 +281928,7 @@ async function check(argv) {
|
|
|
281741
281928
|
[args.appSchema]
|
|
281742
281929
|
);
|
|
281743
281930
|
} catch (err) {
|
|
281744
|
-
console.error(
|
|
281931
|
+
console.error(import_picocolors14.default.red(` Couldn't read the database: ${err instanceof Error ? err.message : String(err)}`));
|
|
281745
281932
|
await sql.end({ timeout: 2 });
|
|
281746
281933
|
process.exit(1);
|
|
281747
281934
|
}
|
|
@@ -281756,7 +281943,7 @@ async function check(argv) {
|
|
|
281756
281943
|
set.add(r2.column_name);
|
|
281757
281944
|
}
|
|
281758
281945
|
console.log(`
|
|
281759
|
-
${brand("ablo")} ${
|
|
281946
|
+
${brand("ablo")} ${import_picocolors14.default.dim("check")} ${import_picocolors14.default.dim(`schema "${args.appSchema}"`)}
|
|
281760
281947
|
`);
|
|
281761
281948
|
const declaredTables = /* @__PURE__ */ new Set();
|
|
281762
281949
|
let errors = 0;
|
|
@@ -281766,7 +281953,7 @@ async function check(argv) {
|
|
|
281766
281953
|
declaredTables.add(table);
|
|
281767
281954
|
const present = colsByTable.get(table);
|
|
281768
281955
|
if (!present) {
|
|
281769
|
-
console.log(` ${
|
|
281956
|
+
console.log(` ${import_picocolors14.default.red("\u2717")} ${import_picocolors14.default.bold(key)} ${import_picocolors14.default.dim("\u2192")} table ${import_picocolors14.default.bold(table)} ${import_picocolors14.default.red("not found")}`);
|
|
281770
281957
|
errors++;
|
|
281771
281958
|
continue;
|
|
281772
281959
|
}
|
|
@@ -281788,26 +281975,26 @@ async function check(argv) {
|
|
|
281788
281975
|
if (!present.has(col)) problems.push(`missing column "${col}" (field ${fieldName})`);
|
|
281789
281976
|
}
|
|
281790
281977
|
if (problems.length > 0) {
|
|
281791
|
-
console.log(` ${
|
|
281792
|
-
for (const p2 of problems) console.log(` ${
|
|
281793
|
-
for (const w2 of warns) console.log(` ${
|
|
281978
|
+
console.log(` ${import_picocolors14.default.red("\u2717")} ${import_picocolors14.default.bold(key)} ${import_picocolors14.default.dim("\u2192")} ${table}`);
|
|
281979
|
+
for (const p2 of problems) console.log(` ${import_picocolors14.default.red("\u2022")} ${p2}`);
|
|
281980
|
+
for (const w2 of warns) console.log(` ${import_picocolors14.default.yellow("\u2022")} ${w2}`);
|
|
281794
281981
|
errors++;
|
|
281795
281982
|
} else if (warns.length > 0) {
|
|
281796
|
-
console.log(` ${
|
|
281797
|
-
for (const w2 of warns) console.log(` ${
|
|
281983
|
+
console.log(` ${import_picocolors14.default.yellow("!")} ${import_picocolors14.default.bold(key)} ${import_picocolors14.default.dim("\u2192")} ${table}`);
|
|
281984
|
+
for (const w2 of warns) console.log(` ${import_picocolors14.default.yellow("\u2022")} ${w2}`);
|
|
281798
281985
|
warnings++;
|
|
281799
281986
|
} else {
|
|
281800
|
-
console.log(` ${
|
|
281987
|
+
console.log(` ${import_picocolors14.default.green("\u2713")} ${import_picocolors14.default.bold(key)} ${import_picocolors14.default.dim(`\u2192 ${table} (id, ${orgCol ?? "no org"} ok)`)}`);
|
|
281801
281988
|
}
|
|
281802
281989
|
}
|
|
281803
281990
|
const modelCount = Object.keys(schemaJson.models).length;
|
|
281804
281991
|
const ignored = [...colsByTable.keys()].filter((t) => !declaredTables.has(t)).length;
|
|
281805
281992
|
console.log(
|
|
281806
281993
|
`
|
|
281807
|
-
${modelCount} model${modelCount === 1 ? "" : "s"} \xB7 ${
|
|
281994
|
+
${modelCount} model${modelCount === 1 ? "" : "s"} \xB7 ${import_picocolors14.default.green(`${modelCount - errors - warnings} ok`)}` + (warnings ? ` \xB7 ${import_picocolors14.default.yellow(`${warnings} warning${warnings === 1 ? "" : "s"}`)}` : "") + (errors ? ` \xB7 ${import_picocolors14.default.red(`${errors} error${errors === 1 ? "" : "s"}`)}` : "")
|
|
281808
281995
|
);
|
|
281809
281996
|
if (ignored > 0) {
|
|
281810
|
-
console.log(` ${
|
|
281997
|
+
console.log(` ${import_picocolors14.default.dim(`${ignored} other table${ignored === 1 ? "" : "s"} in your database \u2014 ignored by Ablo`)}`);
|
|
281811
281998
|
}
|
|
281812
281999
|
console.log();
|
|
281813
282000
|
process.exit(errors > 0 ? 1 : 0);
|
|
@@ -281815,7 +282002,7 @@ async function check(argv) {
|
|
|
281815
282002
|
|
|
281816
282003
|
// src/cli/upgrade.ts
|
|
281817
282004
|
init_cjs_shims();
|
|
281818
|
-
var
|
|
282005
|
+
var import_picocolors15 = __toESM(require_picocolors(), 1);
|
|
281819
282006
|
var import_ts_morph = __toESM(require_ts_morph(), 1);
|
|
281820
282007
|
var DEFAULT_GLOBS = ["app/**/*.{ts,tsx}", "src/**/*.{ts,tsx}", "ablo/**/*.{ts,tsx}", "lib/**/*.{ts,tsx}"];
|
|
281821
282008
|
var VERB_ARGS = {
|
|
@@ -281893,7 +282080,7 @@ async function upgrade(argv) {
|
|
|
281893
282080
|
project.addSourceFilesAtPaths(globs.length > 0 ? globs : DEFAULT_GLOBS);
|
|
281894
282081
|
const files = project.getSourceFiles();
|
|
281895
282082
|
if (files.length === 0) {
|
|
281896
|
-
console.log(
|
|
282083
|
+
console.log(import_picocolors15.default.yellow(' No .ts/.tsx files found. Pass a glob, e.g. `ablo upgrade "src/**/*.tsx"`.'));
|
|
281897
282084
|
return;
|
|
281898
282085
|
}
|
|
281899
282086
|
const edits = [];
|
|
@@ -281967,38 +282154,38 @@ async function upgrade(argv) {
|
|
|
281967
282154
|
const rel = (f) => f.replace(cwd + "/", "");
|
|
281968
282155
|
console.log();
|
|
281969
282156
|
if (edits.length === 0 && manual.length === 0) {
|
|
281970
|
-
console.log(
|
|
282157
|
+
console.log(import_picocolors15.default.green(" \u2713 Nothing to migrate \u2014 your code is already on the current API."));
|
|
281971
282158
|
return;
|
|
281972
282159
|
}
|
|
281973
282160
|
if (edits.length > 0) {
|
|
281974
|
-
console.log(
|
|
282161
|
+
console.log(import_picocolors15.default.bold(` ${write ? "Applied" : "Would apply"} ${edits.length} change${edits.length === 1 ? "" : "s"}:`));
|
|
281975
282162
|
for (const e2 of edits) {
|
|
281976
|
-
console.log(` ${
|
|
281977
|
-
console.log(` ${
|
|
281978
|
-
console.log(` ${
|
|
282163
|
+
console.log(` ${import_picocolors15.default.dim(`${rel(e2.file)}:${e2.line}`)} ${import_picocolors15.default.cyan(e2.rule)}`);
|
|
282164
|
+
console.log(` ${import_picocolors15.default.red("-")} ${e2.before}`);
|
|
282165
|
+
console.log(` ${import_picocolors15.default.green("+")} ${e2.after}`);
|
|
281979
282166
|
}
|
|
281980
282167
|
}
|
|
281981
282168
|
if (manual.length > 0) {
|
|
281982
282169
|
console.log();
|
|
281983
|
-
console.log(
|
|
282170
|
+
console.log(import_picocolors15.default.bold(import_picocolors15.default.yellow(` ${manual.length} spot${manual.length === 1 ? "" : "s"} need manual review (structural):`)));
|
|
281984
282171
|
for (const m2 of manual) {
|
|
281985
|
-
console.log(` ${
|
|
281986
|
-
console.log(` ${
|
|
282172
|
+
console.log(` ${import_picocolors15.default.dim(`${rel(m2.file)}:${m2.line}`)} ${import_picocolors15.default.yellow(m2.rule)}`);
|
|
282173
|
+
console.log(` ${import_picocolors15.default.dim(m2.snippet)}`);
|
|
281987
282174
|
console.log(` \u2192 ${m2.hint}`);
|
|
281988
282175
|
}
|
|
281989
282176
|
}
|
|
281990
282177
|
console.log();
|
|
281991
282178
|
if (write) {
|
|
281992
282179
|
await project.save();
|
|
281993
|
-
console.log(
|
|
282180
|
+
console.log(import_picocolors15.default.green(` \u2713 Wrote ${edits.length} change${edits.length === 1 ? "" : "s"}. Review the diff, run your typecheck.`));
|
|
281994
282181
|
} else {
|
|
281995
|
-
console.log(
|
|
282182
|
+
console.log(import_picocolors15.default.dim(" Dry run. Re-run with `--write` to apply the auto-fixes above (manual items are never auto-written)."));
|
|
281996
282183
|
}
|
|
281997
282184
|
}
|
|
281998
282185
|
|
|
281999
282186
|
// src/cli/pull.ts
|
|
282000
282187
|
init_cjs_shims();
|
|
282001
|
-
var
|
|
282188
|
+
var import_picocolors16 = __toESM(require_picocolors(), 1);
|
|
282002
282189
|
var import_fs9 = require("fs");
|
|
282003
282190
|
var DEFAULT_OUT2 = "ablo/schema.ts";
|
|
282004
282191
|
var DEFAULT_IMPORT = "@abloatai/ablo/schema";
|
|
@@ -282110,52 +282297,52 @@ async function pull(argv) {
|
|
|
282110
282297
|
try {
|
|
282111
282298
|
args = parsePullArgs(argv);
|
|
282112
282299
|
} catch (err) {
|
|
282113
|
-
console.error(
|
|
282300
|
+
console.error(import_picocolors16.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
282114
282301
|
process.exit(1);
|
|
282115
282302
|
}
|
|
282116
282303
|
const dbUrl = process.env.DATABASE_URL ?? process.env.ABLO_DATABASE_URL;
|
|
282117
282304
|
if (!dbUrl) {
|
|
282118
|
-
console.error(
|
|
282305
|
+
console.error(import_picocolors16.default.red(` No database.`) + import_picocolors16.default.dim(` Set ${import_picocolors16.default.bold("DATABASE_URL")} to the Postgres to pull from.`));
|
|
282119
282306
|
process.exit(1);
|
|
282120
282307
|
}
|
|
282121
282308
|
if ((0, import_fs9.existsSync)(args.out) && !args.force) {
|
|
282122
282309
|
console.error(
|
|
282123
|
-
|
|
282310
|
+
import_picocolors16.default.red(` ${args.out} already exists.`) + import_picocolors16.default.dim(` Re-run with ${import_picocolors16.default.bold("--force")} to overwrite.`)
|
|
282124
282311
|
);
|
|
282125
282312
|
process.exit(1);
|
|
282126
282313
|
}
|
|
282127
282314
|
console.log(`
|
|
282128
|
-
${brand("ablo")} ${
|
|
282315
|
+
${brand("ablo")} ${import_picocolors16.default.dim("pull")} ${import_picocolors16.default.dim(`schema "${args.appSchema}"`)}
|
|
282129
282316
|
`);
|
|
282130
282317
|
let result;
|
|
282131
282318
|
try {
|
|
282132
282319
|
result = await buildSchemaSourceFromDb({ dbUrl, appSchema: args.appSchema, importPath: args.importPath });
|
|
282133
282320
|
} catch (err) {
|
|
282134
|
-
console.error(
|
|
282321
|
+
console.error(import_picocolors16.default.red(` Couldn't read the database: ${err instanceof Error ? err.message : String(err)}`));
|
|
282135
282322
|
process.exit(1);
|
|
282136
282323
|
}
|
|
282137
282324
|
if (result.models.length === 0) {
|
|
282138
282325
|
console.error(
|
|
282139
|
-
|
|
282326
|
+
import_picocolors16.default.yellow(` No adoptable tables found`) + import_picocolors16.default.dim(` (a model needs an ${import_picocolors16.default.bold("id")} + ${import_picocolors16.default.bold("organization_id")} column).`)
|
|
282140
282327
|
);
|
|
282141
282328
|
process.exit(1);
|
|
282142
282329
|
}
|
|
282143
282330
|
(0, import_fs9.writeFileSync)(args.out, result.source);
|
|
282144
|
-
console.log(` ${
|
|
282145
|
-
console.log(` ${
|
|
282331
|
+
console.log(` ${import_picocolors16.default.green("\u2713")} wrote ${import_picocolors16.default.bold(args.out)} ${import_picocolors16.default.dim(`(${result.models.length} models)`)}`);
|
|
282332
|
+
console.log(` ${import_picocolors16.default.dim(`models: ${result.models.join(", ")}`)}`);
|
|
282146
282333
|
if (result.skipped > 0) {
|
|
282147
|
-
console.log(` ${
|
|
282334
|
+
console.log(` ${import_picocolors16.default.dim(`${result.skipped} table(s) skipped \u2014 no id/organization_id`)}`);
|
|
282148
282335
|
}
|
|
282149
282336
|
console.log(
|
|
282150
282337
|
`
|
|
282151
|
-
${
|
|
282338
|
+
${import_picocolors16.default.dim("Introspection is lossy (enums, JSON shape, relations). Review the file, then")} ${import_picocolors16.default.bold("ablo check")}.
|
|
282152
282339
|
`
|
|
282153
282340
|
);
|
|
282154
282341
|
}
|
|
282155
282342
|
|
|
282156
282343
|
// src/cli/prisma-pull.ts
|
|
282157
282344
|
init_cjs_shims();
|
|
282158
|
-
var
|
|
282345
|
+
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
282159
282346
|
var import_fs10 = require("fs");
|
|
282160
282347
|
|
|
282161
282348
|
// src/cli/schema-ir.ts
|
|
@@ -282433,55 +282620,55 @@ async function prismaPull(argv) {
|
|
|
282433
282620
|
try {
|
|
282434
282621
|
args = parsePrismaPullArgs(argv);
|
|
282435
282622
|
} catch (err) {
|
|
282436
|
-
console.error(
|
|
282623
|
+
console.error(import_picocolors17.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
282437
282624
|
process.exit(1);
|
|
282438
282625
|
}
|
|
282439
282626
|
if (!(0, import_fs10.existsSync)(args.schema)) {
|
|
282440
282627
|
console.error(
|
|
282441
|
-
|
|
282628
|
+
import_picocolors17.default.red(` No Prisma schema at ${import_picocolors17.default.bold(args.schema)}.`) + import_picocolors17.default.dim(` Pass a path: ${import_picocolors17.default.bold("ablo pull prisma <path>")}.`)
|
|
282442
282629
|
);
|
|
282443
282630
|
process.exit(1);
|
|
282444
282631
|
}
|
|
282445
282632
|
if ((0, import_fs10.existsSync)(args.out) && !args.force) {
|
|
282446
282633
|
console.error(
|
|
282447
|
-
|
|
282634
|
+
import_picocolors17.default.red(` ${args.out} already exists.`) + import_picocolors17.default.dim(` Re-run with ${import_picocolors17.default.bold("--force")} to overwrite.`)
|
|
282448
282635
|
);
|
|
282449
282636
|
process.exit(1);
|
|
282450
282637
|
}
|
|
282451
282638
|
console.log(`
|
|
282452
|
-
${brand("ablo")} ${
|
|
282639
|
+
${brand("ablo")} ${import_picocolors17.default.dim("pull prisma")} ${import_picocolors17.default.dim(args.schema)}
|
|
282453
282640
|
`);
|
|
282454
282641
|
let result;
|
|
282455
282642
|
try {
|
|
282456
282643
|
const src = (0, import_fs10.readFileSync)(args.schema, "utf8");
|
|
282457
282644
|
result = buildSchemaSourceFromPrisma({ src, importPath: args.importPath });
|
|
282458
282645
|
} catch (err) {
|
|
282459
|
-
console.error(
|
|
282646
|
+
console.error(import_picocolors17.default.red(` Couldn't parse the schema: ${err instanceof Error ? err.message : String(err)}`));
|
|
282460
282647
|
process.exit(1);
|
|
282461
282648
|
}
|
|
282462
282649
|
if (result.models.length === 0) {
|
|
282463
282650
|
console.error(
|
|
282464
|
-
|
|
282651
|
+
import_picocolors17.default.yellow(` No adoptable models found`) + import_picocolors17.default.dim(` (a model needs an ${import_picocolors17.default.bold("id")} + ${import_picocolors17.default.bold("organizationId")} / ${import_picocolors17.default.bold("organization_id")}).`)
|
|
282465
282652
|
);
|
|
282466
282653
|
process.exit(1);
|
|
282467
282654
|
}
|
|
282468
282655
|
(0, import_fs10.writeFileSync)(args.out, result.source);
|
|
282469
|
-
console.log(` ${
|
|
282470
|
-
console.log(` ${
|
|
282656
|
+
console.log(` ${import_picocolors17.default.green("\u2713")} wrote ${import_picocolors17.default.bold(args.out)} ${import_picocolors17.default.dim(`(${result.models.length} models)`)}`);
|
|
282657
|
+
console.log(` ${import_picocolors17.default.dim(`models: ${result.models.join(", ")}`)}`);
|
|
282471
282658
|
if (result.skipped.length > 0) {
|
|
282472
|
-
console.log(` ${
|
|
282473
|
-
for (const s of result.skipped) console.log(` ${
|
|
282659
|
+
console.log(` ${import_picocolors17.default.dim(`${result.skipped.length} model(s) skipped:`)}`);
|
|
282660
|
+
for (const s of result.skipped) console.log(` ${import_picocolors17.default.dim(`- ${s.name}: ${s.reason}`)}`);
|
|
282474
282661
|
}
|
|
282475
282662
|
console.log(
|
|
282476
282663
|
`
|
|
282477
|
-
${
|
|
282664
|
+
${import_picocolors17.default.dim("Enums and relations were preserved. Review the file, then")} ${import_picocolors17.default.bold("ablo check")}.
|
|
282478
282665
|
`
|
|
282479
282666
|
);
|
|
282480
282667
|
}
|
|
282481
282668
|
|
|
282482
282669
|
// src/cli/drizzle-pull.ts
|
|
282483
282670
|
init_cjs_shims();
|
|
282484
|
-
var
|
|
282671
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
282485
282672
|
var import_fs11 = require("fs");
|
|
282486
282673
|
var import_path6 = require("path");
|
|
282487
282674
|
var DEFAULT_OUT4 = "ablo/schema.ts";
|
|
@@ -282530,7 +282717,7 @@ async function loadDrizzle() {
|
|
|
282530
282717
|
}
|
|
282531
282718
|
async function lowerDrizzleModule(mod) {
|
|
282532
282719
|
const { is, getTableName, getTableColumns, PgTable, getTableConfig } = await loadDrizzle();
|
|
282533
|
-
const tables = Object.values(mod).filter((
|
|
282720
|
+
const tables = Object.values(mod).filter((v2) => is(v2, PgTable));
|
|
282534
282721
|
const models = [];
|
|
282535
282722
|
const skipped = [];
|
|
282536
282723
|
for (const table of tables) {
|
|
@@ -282617,27 +282804,27 @@ async function drizzlePull(argv) {
|
|
|
282617
282804
|
try {
|
|
282618
282805
|
args = parseDrizzlePullArgs(argv);
|
|
282619
282806
|
} catch (err) {
|
|
282620
|
-
console.error(
|
|
282807
|
+
console.error(import_picocolors18.default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
282621
282808
|
process.exit(1);
|
|
282622
282809
|
}
|
|
282623
282810
|
if (!args.schema) {
|
|
282624
282811
|
console.error(
|
|
282625
|
-
|
|
282812
|
+
import_picocolors18.default.red(` No Drizzle schema given.`) + import_picocolors18.default.dim(` Pass the module: ${import_picocolors18.default.bold("ablo pull drizzle src/db/schema.ts")}.`)
|
|
282626
282813
|
);
|
|
282627
282814
|
process.exit(1);
|
|
282628
282815
|
}
|
|
282629
282816
|
if (!(0, import_fs11.existsSync)(args.schema)) {
|
|
282630
|
-
console.error(
|
|
282817
|
+
console.error(import_picocolors18.default.red(` No file at ${import_picocolors18.default.bold(args.schema)}.`));
|
|
282631
282818
|
process.exit(1);
|
|
282632
282819
|
}
|
|
282633
282820
|
if ((0, import_fs11.existsSync)(args.out) && !args.force) {
|
|
282634
282821
|
console.error(
|
|
282635
|
-
|
|
282822
|
+
import_picocolors18.default.red(` ${args.out} already exists.`) + import_picocolors18.default.dim(` Re-run with ${import_picocolors18.default.bold("--force")} to overwrite.`)
|
|
282636
282823
|
);
|
|
282637
282824
|
process.exit(1);
|
|
282638
282825
|
}
|
|
282639
282826
|
console.log(`
|
|
282640
|
-
${brand("ablo")} ${
|
|
282827
|
+
${brand("ablo")} ${import_picocolors18.default.dim("pull drizzle")} ${import_picocolors18.default.dim(args.schema)}
|
|
282641
282828
|
`);
|
|
282642
282829
|
let result;
|
|
282643
282830
|
try {
|
|
@@ -282645,33 +282832,33 @@ async function drizzlePull(argv) {
|
|
|
282645
282832
|
result = await buildSchemaSourceFromDrizzle({ mod, importPath: args.importPath });
|
|
282646
282833
|
} catch (err) {
|
|
282647
282834
|
const msg = err instanceof Error ? err.message : String(err);
|
|
282648
|
-
const hint = /Cannot find package 'drizzle-orm'/.test(msg) ?
|
|
282649
|
-
console.error(
|
|
282835
|
+
const hint = /Cannot find package 'drizzle-orm'/.test(msg) ? import_picocolors18.default.dim(` (install ${import_picocolors18.default.bold("drizzle-orm")} in this project)`) : "";
|
|
282836
|
+
console.error(import_picocolors18.default.red(` Couldn't load the schema: ${msg}`) + hint);
|
|
282650
282837
|
process.exit(1);
|
|
282651
282838
|
}
|
|
282652
282839
|
if (result.models.length === 0) {
|
|
282653
282840
|
console.error(
|
|
282654
|
-
|
|
282841
|
+
import_picocolors18.default.yellow(` No adoptable tables found`) + import_picocolors18.default.dim(` (a table needs an ${import_picocolors18.default.bold("id")} + ${import_picocolors18.default.bold("organization_id")} column).`)
|
|
282655
282842
|
);
|
|
282656
282843
|
process.exit(1);
|
|
282657
282844
|
}
|
|
282658
282845
|
(0, import_fs11.writeFileSync)(args.out, result.source);
|
|
282659
|
-
console.log(` ${
|
|
282660
|
-
console.log(` ${
|
|
282846
|
+
console.log(` ${import_picocolors18.default.green("\u2713")} wrote ${import_picocolors18.default.bold(args.out)} ${import_picocolors18.default.dim(`(${result.models.length} models)`)}`);
|
|
282847
|
+
console.log(` ${import_picocolors18.default.dim(`models: ${result.models.join(", ")}`)}`);
|
|
282661
282848
|
if (result.skipped.length > 0) {
|
|
282662
|
-
console.log(` ${
|
|
282663
|
-
for (const s of result.skipped) console.log(` ${
|
|
282849
|
+
console.log(` ${import_picocolors18.default.dim(`${result.skipped.length} table(s) skipped:`)}`);
|
|
282850
|
+
for (const s of result.skipped) console.log(` ${import_picocolors18.default.dim(`- ${s.name}: ${s.reason}`)}`);
|
|
282664
282851
|
}
|
|
282665
282852
|
console.log(
|
|
282666
282853
|
`
|
|
282667
|
-
${
|
|
282854
|
+
${import_picocolors18.default.dim("Enums and relations were preserved. Review the file, then")} ${import_picocolors18.default.bold("ablo check")}.
|
|
282668
282855
|
`
|
|
282669
282856
|
);
|
|
282670
282857
|
}
|
|
282671
282858
|
|
|
282672
282859
|
// src/cli/renderError.ts
|
|
282673
282860
|
init_cjs_shims();
|
|
282674
|
-
var
|
|
282861
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
282675
282862
|
var RECOVERY_HINT = {
|
|
282676
282863
|
transient: "This looks transient \u2014 retry in a moment.",
|
|
282677
282864
|
permission: "Your key isn't allowed to do this \u2014 check its scopes or role.",
|
|
@@ -282685,21 +282872,21 @@ function titleForType(type) {
|
|
|
282685
282872
|
if (!spaced) return "Error";
|
|
282686
282873
|
return /error$/i.test(spaced) ? spaced : `${spaced} error`;
|
|
282687
282874
|
}
|
|
282688
|
-
function isStringArray(
|
|
282689
|
-
return Array.isArray(
|
|
282875
|
+
function isStringArray(v2) {
|
|
282876
|
+
return Array.isArray(v2) && v2.every((x2) => typeof x2 === "string");
|
|
282690
282877
|
}
|
|
282691
282878
|
function renderKnownDetails(details, line) {
|
|
282692
282879
|
if (!details) return;
|
|
282693
282880
|
const { retryAfterSeconds, missingIds, requiredCapability, unexecutable, errors } = details;
|
|
282694
|
-
if (typeof retryAfterSeconds === "number") line(` ${
|
|
282881
|
+
if (typeof retryAfterSeconds === "number") line(` ${import_picocolors19.default.dim("retry")} after ${retryAfterSeconds}s`);
|
|
282695
282882
|
if (isStringArray(missingIds) && missingIds.length > 0) {
|
|
282696
282883
|
const shown = missingIds.slice(0, 5).join(", ");
|
|
282697
282884
|
const more = missingIds.length > 5 ? ` (+${missingIds.length - 5} more)` : "";
|
|
282698
|
-
line(` ${
|
|
282885
|
+
line(` ${import_picocolors19.default.dim("missing")} ${shown}${more}`);
|
|
282699
282886
|
}
|
|
282700
|
-
if (typeof requiredCapability === "string") line(` ${
|
|
282887
|
+
if (typeof requiredCapability === "string") line(` ${import_picocolors19.default.dim("needs")} ${requiredCapability}`);
|
|
282701
282888
|
if (Array.isArray(unexecutable) && unexecutable.length > 0) {
|
|
282702
|
-
line(` ${
|
|
282889
|
+
line(` ${import_picocolors19.default.dim("blocked")} ${unexecutable.length} change(s) can't be applied \u2014 see \`unexecutable\` (--verbose)`);
|
|
282703
282890
|
}
|
|
282704
282891
|
if (Array.isArray(errors)) {
|
|
282705
282892
|
for (const e2 of errors.slice(0, 8)) {
|
|
@@ -282707,7 +282894,7 @@ function renderKnownDetails(details, line) {
|
|
|
282707
282894
|
const rec = e2;
|
|
282708
282895
|
const where = typeof rec.param === "string" ? `${rec.param}: ` : "";
|
|
282709
282896
|
const msg = typeof rec.message === "string" ? rec.message : "";
|
|
282710
|
-
if (msg) line(` ${
|
|
282897
|
+
if (msg) line(` ${import_picocolors19.default.dim("\xB7")} ${where}${msg}`);
|
|
282711
282898
|
}
|
|
282712
282899
|
}
|
|
282713
282900
|
}
|
|
@@ -282716,22 +282903,22 @@ function renderCliError(err, opts = {}) {
|
|
|
282716
282903
|
const line = opts.write ?? ((l2) => console.error(l2));
|
|
282717
282904
|
const verbose = opts.verbose ?? (process.argv.includes("--verbose") || process.env.ABLO_VERBOSE === "1");
|
|
282718
282905
|
if (err instanceof AbloError) {
|
|
282719
|
-
const codeTag = err.code ? ` ${
|
|
282906
|
+
const codeTag = err.code ? ` ${import_picocolors19.default.dim(`[${err.code}]`)}` : "";
|
|
282720
282907
|
line("");
|
|
282721
|
-
line(` ${brand("ablo")} ${
|
|
282908
|
+
line(` ${brand("ablo")} ${import_picocolors19.default.red("\u2717")} ${import_picocolors19.default.bold(titleForType(err.type))}${codeTag}`);
|
|
282722
282909
|
line("");
|
|
282723
282910
|
line(` ${err.message}`);
|
|
282724
|
-
if (err.param) line(` ${
|
|
282911
|
+
if (err.param) line(` ${import_picocolors19.default.dim("field")} ${err.param}`);
|
|
282725
282912
|
renderKnownDetails(err.details, line);
|
|
282726
282913
|
const hint = err.code ? RECOVERY_HINT[classifyRecovery(err.code)] : void 0;
|
|
282727
|
-
if (hint) line(` ${
|
|
282728
|
-
if (err.docUrl) line(` ${
|
|
282729
|
-
if (err.requestId) line(` ${
|
|
282914
|
+
if (hint) line(` ${import_picocolors19.default.dim(hint)}`);
|
|
282915
|
+
if (err.docUrl) line(` ${import_picocolors19.default.dim("docs")} ${err.docUrl}`);
|
|
282916
|
+
if (err.requestId) line(` ${import_picocolors19.default.dim("ref")} ${err.requestId}`);
|
|
282730
282917
|
if (verbose) {
|
|
282731
282918
|
if (err.details && Object.keys(err.details).length > 0) {
|
|
282732
|
-
line(` ${
|
|
282919
|
+
line(` ${import_picocolors19.default.dim("details")} ${JSON.stringify(err.details)}`);
|
|
282733
282920
|
}
|
|
282734
|
-
if (err.stack) line(
|
|
282921
|
+
if (err.stack) line(import_picocolors19.default.dim(err.stack));
|
|
282735
282922
|
}
|
|
282736
282923
|
line("");
|
|
282737
282924
|
process.exitCode = 1;
|
|
@@ -282739,16 +282926,16 @@ function renderCliError(err, opts = {}) {
|
|
|
282739
282926
|
}
|
|
282740
282927
|
const message = err instanceof Error ? err.message : String(err);
|
|
282741
282928
|
line("");
|
|
282742
|
-
line(` ${brand("ablo")} ${
|
|
282743
|
-
if (verbose && err instanceof Error && err.stack) line(
|
|
282744
|
-
else line(` ${
|
|
282929
|
+
line(` ${brand("ablo")} ${import_picocolors19.default.red("\u2717")} ${message}`);
|
|
282930
|
+
if (verbose && err instanceof Error && err.stack) line(import_picocolors19.default.dim(err.stack));
|
|
282931
|
+
else line(` ${import_picocolors19.default.dim("Run with --verbose for the full error.")}`);
|
|
282745
282932
|
line("");
|
|
282746
282933
|
process.exitCode = 1;
|
|
282747
282934
|
}
|
|
282748
282935
|
|
|
282749
282936
|
// src/cli/index.ts
|
|
282750
282937
|
var LOGO = `
|
|
282751
|
-
${brand("ablo")} ${
|
|
282938
|
+
${brand("ablo")} ${import_picocolors20.default.dim("sync engine")}
|
|
282752
282939
|
`;
|
|
282753
282940
|
var SUBCOMMAND_USAGE = {
|
|
282754
282941
|
connect: CONNECT_USAGE,
|
|
@@ -282783,7 +282970,7 @@ async function main() {
|
|
|
282783
282970
|
const devArgs = process.argv.slice(3);
|
|
282784
282971
|
const oneShot = devArgs.includes("--no-watch");
|
|
282785
282972
|
console.log(
|
|
282786
|
-
|
|
282973
|
+
import_picocolors20.default.dim(
|
|
282787
282974
|
oneShot ? " `ablo dev --no-watch` is `ablo push` (push once, no watcher) \u2014 running that." : " `ablo dev` is now `ablo push --watch` \u2014 running that."
|
|
282788
282975
|
)
|
|
282789
282976
|
);
|
|
@@ -282805,19 +282992,21 @@ async function main() {
|
|
|
282805
282992
|
await migrate(process.argv.slice(3));
|
|
282806
282993
|
} else if (command === "push") {
|
|
282807
282994
|
const rest = process.argv.slice(3);
|
|
282808
|
-
const advanced = rest.some(
|
|
282995
|
+
const advanced = rest.some(
|
|
282996
|
+
(a) => ["--force", "--rename", "--backfill", "--url", "--dry-run", "--plan", "--yes", "-y", "--allow-dirty"].includes(a)
|
|
282997
|
+
);
|
|
282809
282998
|
const watching = rest.includes("--watch");
|
|
282810
282999
|
const guard = guardActiveProjectKey();
|
|
282811
283000
|
if (!guard.ok && guard.available.length > 0 && !rest.includes("--url")) {
|
|
282812
283001
|
console.error(
|
|
282813
|
-
` ${
|
|
283002
|
+
` ${import_picocolors20.default.yellow("\u26A0")} active project ${import_picocolors20.default.bold(guard.activeProfile)} has no stored key ${import_picocolors20.default.dim(
|
|
282814
283003
|
`(you have keys for: ${guard.available.join(", ")})`
|
|
282815
283004
|
)}`
|
|
282816
283005
|
);
|
|
282817
283006
|
const loginCmd = guard.activeProfile === "default" ? "ablo login" : `ablo login --project ${guard.activeProfile}`;
|
|
282818
283007
|
console.error(
|
|
282819
|
-
|
|
282820
|
-
` Mint one with ${
|
|
283008
|
+
import_picocolors20.default.dim(
|
|
283009
|
+
` Mint one with ${import_picocolors20.default.bold(loginCmd)}, or switch with ${import_picocolors20.default.bold("ablo projects use <slug>")}.`
|
|
282821
283010
|
)
|
|
282822
283011
|
);
|
|
282823
283012
|
process.exitCode = 1;
|
|
@@ -282835,13 +283024,13 @@ async function main() {
|
|
|
282835
283024
|
await generate(process.argv.slice(3));
|
|
282836
283025
|
} else if (command === "schema") {
|
|
282837
283026
|
console.error(
|
|
282838
|
-
` ${
|
|
283027
|
+
` ${import_picocolors20.default.red("\u2717")} \`ablo schema push\` was renamed to \`${brand("ablo push")}\`.`
|
|
282839
283028
|
);
|
|
282840
283029
|
console.error(` Run \`ablo push${process.argv.slice(4).join(" ") ? " " + process.argv.slice(4).join(" ") : ""}\` instead.`);
|
|
282841
283030
|
process.exitCode = 1;
|
|
282842
283031
|
} else {
|
|
282843
283032
|
console.log(LOGO);
|
|
282844
|
-
console.log(` ${
|
|
283033
|
+
console.log(` ${import_picocolors20.default.bold("Usage:")}`);
|
|
282845
283034
|
console.log(` npx ablo init Scaffold ablo/ directory + starter schema`);
|
|
282846
283035
|
console.log(` npx ablo init --yes [--framework nextjs] Non-interactive (agents/CI): no prompts, flag-driven`);
|
|
282847
283036
|
console.log(` [--auth apikey] [--storage direct|endpoint] [--project <slug>] [--no-project]`);
|
|
@@ -282876,10 +283065,10 @@ async function main() {
|
|
|
282876
283065
|
console.log(` npx ablo generate Emit TypeScript types from your schema`);
|
|
282877
283066
|
console.log(` npx ablo generate --out path.ts Write generated types to a path`);
|
|
282878
283067
|
console.log();
|
|
282879
|
-
console.log(` ${
|
|
283068
|
+
console.log(` ${import_picocolors20.default.bold("Schema workflow:")}`);
|
|
282880
283069
|
console.log(` The server holds its own copy of your schema \u2014 edit ${brand("ablo/schema.ts")}, then`);
|
|
282881
283070
|
console.log(` run ${brand("ablo push")} (or keep ${brand("ablo dev")} running) before the server will accept`);
|
|
282882
|
-
console.log(` writes to new or changed models. Skip it and writes fail with ${
|
|
283071
|
+
console.log(` writes to new or changed models. Skip it and writes fail with ${import_picocolors20.default.yellow("server_execute_unknown_model")}.`);
|
|
282883
283072
|
console.log();
|
|
282884
283073
|
}
|
|
282885
283074
|
}
|
|
@@ -282930,7 +283119,7 @@ async function ensureInitProject(opts) {
|
|
|
282930
283119
|
const ensured = await ensureProject(slug);
|
|
282931
283120
|
if (ensured) {
|
|
282932
283121
|
console.log(
|
|
282933
|
-
` ${
|
|
283122
|
+
` ${import_picocolors20.default.green("\u2713")} ${ensured.created ? "Created" : "Using"} project ${import_picocolors20.default.bold(ensured.slug)} ${import_picocolors20.default.dim(`(${ensured.id})`)} \u2014 keys you mint for it are isolated from the org's other apps.`
|
|
282934
283123
|
);
|
|
282935
283124
|
}
|
|
282936
283125
|
}
|
|
@@ -282972,7 +283161,7 @@ async function chooseBool(flagValue, fallback, interactive, prompt) {
|
|
|
282972
283161
|
async function init(args = []) {
|
|
282973
283162
|
const opts = parseInitArgs(args);
|
|
282974
283163
|
const interactive = Boolean(process.stdin.isTTY) && !opts.yes && !process.env.CI;
|
|
282975
|
-
Ie(`${brand("ablo")} ${
|
|
283164
|
+
Ie(`${brand("ablo")} ${import_picocolors20.default.dim("sync engine")}`);
|
|
282976
283165
|
if (!(0, import_fs12.existsSync)("package.json")) {
|
|
282977
283166
|
xe("No package.json found. Run this from your project root.");
|
|
282978
283167
|
process.exit(1);
|
|
@@ -283026,7 +283215,7 @@ async function init(args = []) {
|
|
|
283026
283215
|
if (storage === "direct") {
|
|
283027
283216
|
Me(
|
|
283028
283217
|
"`--storage direct` uses the deprecated databaseUrl connector. The signed Data\nSource endpoint is the supported path.",
|
|
283029
|
-
|
|
283218
|
+
import_picocolors20.default.yellow("Deprecated")
|
|
283030
283219
|
);
|
|
283031
283220
|
}
|
|
283032
283221
|
const agent = await chooseBool(
|
|
@@ -283056,7 +283245,7 @@ async function init(args = []) {
|
|
|
283056
283245
|
if (pullExisting) {
|
|
283057
283246
|
const dbUrl = process.env.DATABASE_URL ?? process.env.ABLO_DATABASE_URL;
|
|
283058
283247
|
if (!dbUrl) {
|
|
283059
|
-
schemaNote =
|
|
283248
|
+
schemaNote = import_picocolors20.default.dim(" (no DATABASE_URL \u2014 wrote starter; run `ablo pull` later)");
|
|
283060
283249
|
} else {
|
|
283061
283250
|
try {
|
|
283062
283251
|
const pulled = await buildSchemaSourceFromDb({
|
|
@@ -283066,12 +283255,12 @@ async function init(args = []) {
|
|
|
283066
283255
|
});
|
|
283067
283256
|
if (pulled.models.length > 0) {
|
|
283068
283257
|
schemaSource = pulled.source;
|
|
283069
|
-
schemaNote =
|
|
283258
|
+
schemaNote = import_picocolors20.default.dim(` (pulled ${pulled.models.length} models)`);
|
|
283070
283259
|
} else {
|
|
283071
|
-
schemaNote =
|
|
283260
|
+
schemaNote = import_picocolors20.default.dim(" (no adoptable tables \u2014 wrote starter)");
|
|
283072
283261
|
}
|
|
283073
283262
|
} catch {
|
|
283074
|
-
schemaNote =
|
|
283263
|
+
schemaNote = import_picocolors20.default.dim(" (pull failed \u2014 wrote starter)");
|
|
283075
283264
|
}
|
|
283076
283265
|
}
|
|
283077
283266
|
}
|
|
@@ -283097,14 +283286,14 @@ async function init(args = []) {
|
|
|
283097
283286
|
const existing = (0, import_fs12.readFileSync)(envFile, "utf-8");
|
|
283098
283287
|
if (!existing.includes("ABLO_")) {
|
|
283099
283288
|
(0, import_fs12.writeFileSync)(envFile, existing + "\n" + envBody);
|
|
283100
|
-
created.push(`${envFile} ${
|
|
283289
|
+
created.push(`${envFile} ${import_picocolors20.default.dim("(appended)")}`);
|
|
283101
283290
|
} else {
|
|
283102
|
-
created.push(`${envFile} ${
|
|
283291
|
+
created.push(`${envFile} ${import_picocolors20.default.dim("(already configured)")}`);
|
|
283103
283292
|
}
|
|
283104
283293
|
}
|
|
283105
283294
|
if (wireRealKey && resolvedKey) {
|
|
283106
283295
|
wireEnvLocal(resolvedKey);
|
|
283107
|
-
created.push(`.env.local ${
|
|
283296
|
+
created.push(`.env.local ${import_picocolors20.default.dim("(ABLO_API_KEY set from your login)")}`);
|
|
283108
283297
|
}
|
|
283109
283298
|
if (agent) {
|
|
283110
283299
|
(0, import_fs12.writeFileSync)((0, import_path7.join)(abloDir, "agent.ts"), generateAgent());
|
|
@@ -283119,64 +283308,64 @@ async function init(args = []) {
|
|
|
283119
283308
|
}
|
|
283120
283309
|
const providersPath = (0, import_path7.join)(layout.appBase, "providers.tsx");
|
|
283121
283310
|
(0, import_fs12.writeFileSync)(providersPath, generateProviders());
|
|
283122
|
-
created.push(`${providersPath} ${
|
|
283311
|
+
created.push(`${providersPath} ${import_picocolors20.default.dim(`(wrap ${(0, import_path7.join)(layout.appBase, "layout.tsx")} in <Providers>)`)}`);
|
|
283123
283312
|
const sessionDir = (0, import_path7.join)(layout.appBase, "api", "ablo-session");
|
|
283124
283313
|
(0, import_fs12.mkdirSync)(sessionDir, { recursive: true });
|
|
283125
283314
|
(0, import_fs12.writeFileSync)((0, import_path7.join)(sessionDir, "route.ts"), generateSessionRoute());
|
|
283126
|
-
created.push(`${(0, import_path7.join)(sessionDir, "route.ts")} ${
|
|
283315
|
+
created.push(`${(0, import_path7.join)(sessionDir, "route.ts")} ${import_picocolors20.default.dim("(wire your auth)")}`);
|
|
283127
283316
|
}
|
|
283128
283317
|
if (framework !== "vanilla") {
|
|
283129
283318
|
(0, import_fs12.writeFileSync)((0, import_path7.join)(abloDir, "TaskList.tsx"), generateComponent());
|
|
283130
283319
|
created.push(`${abloDir}/TaskList.tsx`);
|
|
283131
283320
|
}
|
|
283132
|
-
Me(created.map((f) => `${
|
|
283321
|
+
Me(created.map((f) => `${import_picocolors20.default.green("\u2713")} ${f}`).join("\n"), "Created");
|
|
283133
283322
|
const pm = detectPackageManager();
|
|
283134
283323
|
if (opts.install) {
|
|
283135
283324
|
const s = Y2();
|
|
283136
283325
|
s.start("Installing @abloatai/ablo");
|
|
283137
283326
|
try {
|
|
283138
|
-
(0,
|
|
283327
|
+
(0, import_child_process3.execSync)(`${pm} add @abloatai/ablo`, { stdio: "ignore" });
|
|
283139
283328
|
s.stop("Installed @abloatai/ablo");
|
|
283140
283329
|
} catch {
|
|
283141
|
-
s.stop(`${
|
|
283330
|
+
s.stop(`${import_picocolors20.default.yellow("!")} Couldn't auto-install \u2014 run ${import_picocolors20.default.bold(`${pm} install @abloatai/ablo`)}`);
|
|
283142
283331
|
}
|
|
283143
283332
|
}
|
|
283144
283333
|
const steps = [
|
|
283145
|
-
`Get a ${
|
|
283146
|
-
`Run ${
|
|
283147
|
-
`Set ${
|
|
283148
|
-
`Run ${
|
|
283334
|
+
`Get a ${import_picocolors20.default.bold("sk_test_")} key at ${import_picocolors20.default.cyan("https://abloatai.com")}`,
|
|
283335
|
+
`Run ${import_picocolors20.default.bold("npx ablo login")} (or add ${import_picocolors20.default.bold("ABLO_API_KEY")} to ${import_picocolors20.default.bold(envFile)})`,
|
|
283336
|
+
`Set ${import_picocolors20.default.bold("DATABASE_URL")} in ${import_picocolors20.default.bold(envFile)} \u2014 your Postgres is the system of record; rows live there, never with Ablo`,
|
|
283337
|
+
`Run ${import_picocolors20.default.bold("npx ablo dev")} \u2014 pushes your schema definition and watches for changes`,
|
|
283149
283338
|
...storage === "direct" ? [
|
|
283150
|
-
`Provision your DB: ${
|
|
283339
|
+
`Provision your DB: ${import_picocolors20.default.bold("npx ablo migrate")} (creates your synced-model tables with row-level security; keep your own migrations for everything else)`
|
|
283151
283340
|
] : [
|
|
283152
|
-
`Provision your DB: ${
|
|
283341
|
+
`Provision your DB: ${import_picocolors20.default.bold("npx ablo migrate")} (creates your Ablo-model tables + the adapter tables; keep your own migrations for everything else), then mount ${import_picocolors20.default.bold(`${abloDir}/data-source.ts`)} at ${import_picocolors20.default.bold("/api/ablo/source")}`
|
|
283153
283342
|
],
|
|
283154
283343
|
...framework === "nextjs" ? [
|
|
283155
|
-
`Wrap ${
|
|
283344
|
+
`Wrap ${import_picocolors20.default.bold((0, import_path7.join)(layout.appBase, "layout.tsx"))} in ${import_picocolors20.default.bold("<Providers>")} (${(0, import_path7.join)(layout.appBase, "providers.tsx")}) and add your auth to ${import_picocolors20.default.bold((0, import_path7.join)(layout.appBase, "api", "ablo-session", "route.ts"))}`
|
|
283156
283345
|
] : [],
|
|
283157
|
-
`Run ${
|
|
283346
|
+
`Run ${import_picocolors20.default.bold(`${pm} run dev`)} and open two browser tabs \u2014 changes sync in real-time`,
|
|
283158
283347
|
...agent ? [
|
|
283159
|
-
`Run ${
|
|
283160
|
-
`Run ${
|
|
283348
|
+
`Run ${import_picocolors20.default.bold(`npx tsx ${abloDir}/agent.ts`)} \u2014 an AI teammate edits the same tasks`,
|
|
283349
|
+
`Run ${import_picocolors20.default.bold("npx ablo logs")} to watch human + agent commits stream by`
|
|
283161
283350
|
] : []
|
|
283162
283351
|
];
|
|
283163
283352
|
Me(steps.map((s, i) => `${i + 1}. ${s}`).join("\n"), "Next steps");
|
|
283164
283353
|
const existingKey = resolveApiKey("sandbox");
|
|
283165
283354
|
if (existingKey) {
|
|
283166
283355
|
await ensureInitProject(opts);
|
|
283167
|
-
Se(`Already authorized ${
|
|
283356
|
+
Se(`Already authorized ${import_picocolors20.default.dim(`(${existingKey.slice(0, 11)}\u2026)`)} \u2014 run ${import_picocolors20.default.bold("npx ablo push")} next. ${import_picocolors20.default.dim("Docs:")} https://abloatai.com/docs`);
|
|
283168
283357
|
return;
|
|
283169
283358
|
}
|
|
283170
283359
|
if (interactive && opts.login) {
|
|
283171
283360
|
const loginNow = await ye({ message: "Log in now? (opens your browser)", initialValue: true });
|
|
283172
283361
|
if (!pD(loginNow) && loginNow) {
|
|
283173
|
-
Se(`${
|
|
283362
|
+
Se(`${import_picocolors20.default.dim("Docs:")} https://abloatai.com/docs`);
|
|
283174
283363
|
await login();
|
|
283175
283364
|
await ensureInitProject(opts);
|
|
283176
283365
|
return;
|
|
283177
283366
|
}
|
|
283178
283367
|
}
|
|
283179
|
-
Se(`Run ${
|
|
283368
|
+
Se(`Run ${import_picocolors20.default.bold("npx ablo login")} when ready. ${import_picocolors20.default.dim("Docs:")} https://abloatai.com/docs`);
|
|
283180
283369
|
}
|
|
283181
283370
|
function generateSchema() {
|
|
283182
283371
|
return `import { defineSchema, model, relation, z } from '@abloatai/ablo/schema';
|