@secondlayer/cli 5.2.1 → 5.4.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/dist/cli.js +313 -557
- package/dist/cli.js.map +8 -8
- package/package.json +3 -3
- package/templates/subscriptions/cloudflare/.env.example +1 -0
- package/templates/subscriptions/inngest/.env.example +2 -0
- package/templates/subscriptions/inngest/package.json +1 -1
- package/templates/subscriptions/node/README.md +3 -1
- package/templates/subscriptions/trigger/.env.example +2 -0
package/dist/cli.js
CHANGED
|
@@ -2537,9 +2537,6 @@ async function resolveActiveTenant(_opts = {}) {
|
|
|
2537
2537
|
fromEnv: false
|
|
2538
2538
|
};
|
|
2539
2539
|
}
|
|
2540
|
-
function isOssMode() {
|
|
2541
|
-
return !!process.env.SL_API_URL && !process.env.SL_SERVICE_KEY;
|
|
2542
|
-
}
|
|
2543
2540
|
var PLATFORM_API_URL2;
|
|
2544
2541
|
var init_resolve_tenant = __esm(() => {
|
|
2545
2542
|
init_session();
|
|
@@ -15629,8 +15626,8 @@ var require_fill_range = __commonJS((exports, module) => {
|
|
|
15629
15626
|
return typeof value === "number" || typeof value === "string" && value !== "";
|
|
15630
15627
|
};
|
|
15631
15628
|
var isNumber = (num) => Number.isInteger(+num);
|
|
15632
|
-
var zeros = (
|
|
15633
|
-
let value = `${
|
|
15629
|
+
var zeros = (input5) => {
|
|
15630
|
+
let value = `${input5}`;
|
|
15634
15631
|
let index = -1;
|
|
15635
15632
|
if (value[0] === "-")
|
|
15636
15633
|
value = value.slice(1);
|
|
@@ -15646,27 +15643,27 @@ var require_fill_range = __commonJS((exports, module) => {
|
|
|
15646
15643
|
}
|
|
15647
15644
|
return options2.stringify === true;
|
|
15648
15645
|
};
|
|
15649
|
-
var pad = (
|
|
15646
|
+
var pad = (input5, maxLength, toNumber) => {
|
|
15650
15647
|
if (maxLength > 0) {
|
|
15651
|
-
let dash =
|
|
15648
|
+
let dash = input5[0] === "-" ? "-" : "";
|
|
15652
15649
|
if (dash)
|
|
15653
|
-
|
|
15654
|
-
|
|
15650
|
+
input5 = input5.slice(1);
|
|
15651
|
+
input5 = dash + input5.padStart(dash ? maxLength - 1 : maxLength, "0");
|
|
15655
15652
|
}
|
|
15656
15653
|
if (toNumber === false) {
|
|
15657
|
-
return String(
|
|
15654
|
+
return String(input5);
|
|
15658
15655
|
}
|
|
15659
|
-
return
|
|
15656
|
+
return input5;
|
|
15660
15657
|
};
|
|
15661
|
-
var toMaxLen = (
|
|
15662
|
-
let negative =
|
|
15658
|
+
var toMaxLen = (input5, maxLength) => {
|
|
15659
|
+
let negative = input5[0] === "-" ? "-" : "";
|
|
15663
15660
|
if (negative) {
|
|
15664
|
-
|
|
15661
|
+
input5 = input5.slice(1);
|
|
15665
15662
|
maxLength--;
|
|
15666
15663
|
}
|
|
15667
|
-
while (
|
|
15668
|
-
|
|
15669
|
-
return negative ? "-" +
|
|
15664
|
+
while (input5.length < maxLength)
|
|
15665
|
+
input5 = "0" + input5;
|
|
15666
|
+
return negative ? "-" + input5 : input5;
|
|
15670
15667
|
};
|
|
15671
15668
|
var toSequence = (parts, options2, maxLen) => {
|
|
15672
15669
|
parts.negatives.sort((a, b2) => a < b2 ? -1 : a > b2 ? 1 : 0);
|
|
@@ -16035,25 +16032,25 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
16035
16032
|
CHAR_NO_BREAK_SPACE,
|
|
16036
16033
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
|
16037
16034
|
} = require_constants();
|
|
16038
|
-
var parse2 = (
|
|
16039
|
-
if (typeof
|
|
16035
|
+
var parse2 = (input5, options2 = {}) => {
|
|
16036
|
+
if (typeof input5 !== "string") {
|
|
16040
16037
|
throw new TypeError("Expected a string");
|
|
16041
16038
|
}
|
|
16042
16039
|
const opts = options2 || {};
|
|
16043
16040
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
16044
|
-
if (
|
|
16045
|
-
throw new SyntaxError(`Input length (${
|
|
16041
|
+
if (input5.length > max) {
|
|
16042
|
+
throw new SyntaxError(`Input length (${input5.length}), exceeds max characters (${max})`);
|
|
16046
16043
|
}
|
|
16047
|
-
const ast = { type: "root", input:
|
|
16044
|
+
const ast = { type: "root", input: input5, nodes: [] };
|
|
16048
16045
|
const stack = [ast];
|
|
16049
16046
|
let block = ast;
|
|
16050
16047
|
let prev = ast;
|
|
16051
16048
|
let brackets = 0;
|
|
16052
|
-
const length =
|
|
16049
|
+
const length = input5.length;
|
|
16053
16050
|
let index = 0;
|
|
16054
16051
|
let depth = 0;
|
|
16055
16052
|
let value;
|
|
16056
|
-
const advance = () =>
|
|
16053
|
+
const advance = () => input5[index++];
|
|
16057
16054
|
const push = (node) => {
|
|
16058
16055
|
if (node.type === "text" && prev.type === "dot") {
|
|
16059
16056
|
prev.type = "text";
|
|
@@ -16248,10 +16245,10 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
16248
16245
|
var compile = require_compile();
|
|
16249
16246
|
var expand = require_expand();
|
|
16250
16247
|
var parse2 = require_parse();
|
|
16251
|
-
var braces = (
|
|
16248
|
+
var braces = (input5, options2 = {}) => {
|
|
16252
16249
|
let output = [];
|
|
16253
|
-
if (Array.isArray(
|
|
16254
|
-
for (const pattern of
|
|
16250
|
+
if (Array.isArray(input5)) {
|
|
16251
|
+
for (const pattern of input5) {
|
|
16255
16252
|
const result = braces.create(pattern, options2);
|
|
16256
16253
|
if (Array.isArray(result)) {
|
|
16257
16254
|
output.push(...result);
|
|
@@ -16260,31 +16257,31 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
16260
16257
|
}
|
|
16261
16258
|
}
|
|
16262
16259
|
} else {
|
|
16263
|
-
output = [].concat(braces.create(
|
|
16260
|
+
output = [].concat(braces.create(input5, options2));
|
|
16264
16261
|
}
|
|
16265
16262
|
if (options2 && options2.expand === true && options2.nodupes === true) {
|
|
16266
16263
|
output = [...new Set(output)];
|
|
16267
16264
|
}
|
|
16268
16265
|
return output;
|
|
16269
16266
|
};
|
|
16270
|
-
braces.parse = (
|
|
16271
|
-
braces.stringify = (
|
|
16272
|
-
if (typeof
|
|
16273
|
-
return stringify2(braces.parse(
|
|
16267
|
+
braces.parse = (input5, options2 = {}) => parse2(input5, options2);
|
|
16268
|
+
braces.stringify = (input5, options2 = {}) => {
|
|
16269
|
+
if (typeof input5 === "string") {
|
|
16270
|
+
return stringify2(braces.parse(input5, options2), options2);
|
|
16274
16271
|
}
|
|
16275
|
-
return stringify2(
|
|
16272
|
+
return stringify2(input5, options2);
|
|
16276
16273
|
};
|
|
16277
|
-
braces.compile = (
|
|
16278
|
-
if (typeof
|
|
16279
|
-
|
|
16274
|
+
braces.compile = (input5, options2 = {}) => {
|
|
16275
|
+
if (typeof input5 === "string") {
|
|
16276
|
+
input5 = braces.parse(input5, options2);
|
|
16280
16277
|
}
|
|
16281
|
-
return compile(
|
|
16278
|
+
return compile(input5, options2);
|
|
16282
16279
|
};
|
|
16283
|
-
braces.expand = (
|
|
16284
|
-
if (typeof
|
|
16285
|
-
|
|
16280
|
+
braces.expand = (input5, options2 = {}) => {
|
|
16281
|
+
if (typeof input5 === "string") {
|
|
16282
|
+
input5 = braces.parse(input5, options2);
|
|
16286
16283
|
}
|
|
16287
|
-
let result = expand(
|
|
16284
|
+
let result = expand(input5, options2);
|
|
16288
16285
|
if (options2.noempty === true) {
|
|
16289
16286
|
result = result.filter(Boolean);
|
|
16290
16287
|
}
|
|
@@ -16293,11 +16290,11 @@ var require_braces = __commonJS((exports, module) => {
|
|
|
16293
16290
|
}
|
|
16294
16291
|
return result;
|
|
16295
16292
|
};
|
|
16296
|
-
braces.create = (
|
|
16297
|
-
if (
|
|
16298
|
-
return [
|
|
16293
|
+
braces.create = (input5, options2 = {}) => {
|
|
16294
|
+
if (input5 === "" || input5.length < 3) {
|
|
16295
|
+
return [input5];
|
|
16299
16296
|
}
|
|
16300
|
-
return options2.expand !== true ? braces.compile(
|
|
16297
|
+
return options2.expand !== true ? braces.compile(input5, options2) : braces.expand(input5, options2);
|
|
16301
16298
|
};
|
|
16302
16299
|
module.exports = braces;
|
|
16303
16300
|
});
|
|
@@ -16475,26 +16472,26 @@ var require_utils2 = __commonJS((exports) => {
|
|
|
16475
16472
|
}
|
|
16476
16473
|
return win32 === true || path2.sep === "\\";
|
|
16477
16474
|
};
|
|
16478
|
-
exports.escapeLast = (
|
|
16479
|
-
const idx =
|
|
16475
|
+
exports.escapeLast = (input5, char, lastIdx) => {
|
|
16476
|
+
const idx = input5.lastIndexOf(char, lastIdx);
|
|
16480
16477
|
if (idx === -1)
|
|
16481
|
-
return
|
|
16482
|
-
if (
|
|
16483
|
-
return exports.escapeLast(
|
|
16484
|
-
return `${
|
|
16478
|
+
return input5;
|
|
16479
|
+
if (input5[idx - 1] === "\\")
|
|
16480
|
+
return exports.escapeLast(input5, char, idx - 1);
|
|
16481
|
+
return `${input5.slice(0, idx)}\\${input5.slice(idx)}`;
|
|
16485
16482
|
};
|
|
16486
|
-
exports.removePrefix = (
|
|
16487
|
-
let output =
|
|
16483
|
+
exports.removePrefix = (input5, state = {}) => {
|
|
16484
|
+
let output = input5;
|
|
16488
16485
|
if (output.startsWith("./")) {
|
|
16489
16486
|
output = output.slice(2);
|
|
16490
16487
|
state.prefix = "./";
|
|
16491
16488
|
}
|
|
16492
16489
|
return output;
|
|
16493
16490
|
};
|
|
16494
|
-
exports.wrapOutput = (
|
|
16491
|
+
exports.wrapOutput = (input5, state = {}, options2 = {}) => {
|
|
16495
16492
|
const prepend = options2.contains ? "" : "^";
|
|
16496
16493
|
const append = options2.contains ? "" : "$";
|
|
16497
|
-
let output = `${prepend}(?:${
|
|
16494
|
+
let output = `${prepend}(?:${input5})${append}`;
|
|
16498
16495
|
if (state.negated === true) {
|
|
16499
16496
|
output = `(?:^(?!${output}).*$)`;
|
|
16500
16497
|
}
|
|
@@ -16530,14 +16527,14 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
16530
16527
|
token.depth = token.isGlobstar ? Infinity : 1;
|
|
16531
16528
|
}
|
|
16532
16529
|
};
|
|
16533
|
-
var scan = (
|
|
16530
|
+
var scan = (input5, options2) => {
|
|
16534
16531
|
const opts = options2 || {};
|
|
16535
|
-
const length =
|
|
16532
|
+
const length = input5.length - 1;
|
|
16536
16533
|
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
16537
16534
|
const slashes = [];
|
|
16538
16535
|
const tokens = [];
|
|
16539
16536
|
const parts = [];
|
|
16540
|
-
let str =
|
|
16537
|
+
let str = input5;
|
|
16541
16538
|
let index = -1;
|
|
16542
16539
|
let start = 0;
|
|
16543
16540
|
let lastIndex = 0;
|
|
@@ -16760,7 +16757,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
16760
16757
|
}
|
|
16761
16758
|
const state = {
|
|
16762
16759
|
prefix,
|
|
16763
|
-
input:
|
|
16760
|
+
input: input5,
|
|
16764
16761
|
start,
|
|
16765
16762
|
base,
|
|
16766
16763
|
glob,
|
|
@@ -16784,7 +16781,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
16784
16781
|
for (let idx = 0;idx < slashes.length; idx++) {
|
|
16785
16782
|
const n = prevIndex ? prevIndex + 1 : start;
|
|
16786
16783
|
const i = slashes[idx];
|
|
16787
|
-
const value =
|
|
16784
|
+
const value = input5.slice(n, i);
|
|
16788
16785
|
if (opts.tokens) {
|
|
16789
16786
|
if (idx === 0 && start !== 0) {
|
|
16790
16787
|
tokens[idx].isPrefix = true;
|
|
@@ -16800,8 +16797,8 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
16800
16797
|
}
|
|
16801
16798
|
prevIndex = i;
|
|
16802
16799
|
}
|
|
16803
|
-
if (prevIndex && prevIndex + 1 <
|
|
16804
|
-
const value =
|
|
16800
|
+
if (prevIndex && prevIndex + 1 < input5.length) {
|
|
16801
|
+
const value = input5.slice(prevIndex + 1);
|
|
16805
16802
|
parts.push(value);
|
|
16806
16803
|
if (opts.tokens) {
|
|
16807
16804
|
tokens[tokens.length - 1].value = value;
|
|
@@ -16844,14 +16841,14 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
16844
16841
|
var syntaxError = (type, char) => {
|
|
16845
16842
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
16846
16843
|
};
|
|
16847
|
-
var parse2 = (
|
|
16848
|
-
if (typeof
|
|
16844
|
+
var parse2 = (input5, options2) => {
|
|
16845
|
+
if (typeof input5 !== "string") {
|
|
16849
16846
|
throw new TypeError("Expected a string");
|
|
16850
16847
|
}
|
|
16851
|
-
|
|
16848
|
+
input5 = REPLACEMENTS[input5] || input5;
|
|
16852
16849
|
const opts = { ...options2 };
|
|
16853
16850
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
16854
|
-
let len =
|
|
16851
|
+
let len = input5.length;
|
|
16855
16852
|
if (len > max) {
|
|
16856
16853
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
16857
16854
|
}
|
|
@@ -16888,7 +16885,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
16888
16885
|
opts.noextglob = opts.noext;
|
|
16889
16886
|
}
|
|
16890
16887
|
const state = {
|
|
16891
|
-
input:
|
|
16888
|
+
input: input5,
|
|
16892
16889
|
index: -1,
|
|
16893
16890
|
start: 0,
|
|
16894
16891
|
dot: opts.dot === true,
|
|
@@ -16904,17 +16901,17 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
16904
16901
|
globstar: false,
|
|
16905
16902
|
tokens
|
|
16906
16903
|
};
|
|
16907
|
-
|
|
16908
|
-
len =
|
|
16904
|
+
input5 = utils.removePrefix(input5, state);
|
|
16905
|
+
len = input5.length;
|
|
16909
16906
|
const extglobs = [];
|
|
16910
16907
|
const braces = [];
|
|
16911
16908
|
const stack = [];
|
|
16912
16909
|
let prev = bos;
|
|
16913
16910
|
let value;
|
|
16914
16911
|
const eos = () => state.index === len - 1;
|
|
16915
|
-
const peek = state.peek = (n = 1) =>
|
|
16916
|
-
const advance = state.advance = () =>
|
|
16917
|
-
const remaining = () =>
|
|
16912
|
+
const peek = state.peek = (n = 1) => input5[state.index + n];
|
|
16913
|
+
const advance = state.advance = () => input5[++state.index] || "";
|
|
16914
|
+
const remaining = () => input5.slice(state.index + 1);
|
|
16918
16915
|
const consume = (value2 = "", num = 0) => {
|
|
16919
16916
|
state.consumed += value2;
|
|
16920
16917
|
state.index += num;
|
|
@@ -17004,9 +17001,9 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
17004
17001
|
push({ type: "paren", extglob: true, value, output });
|
|
17005
17002
|
decrement("parens");
|
|
17006
17003
|
};
|
|
17007
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(
|
|
17004
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input5)) {
|
|
17008
17005
|
let backslashes = false;
|
|
17009
|
-
let output =
|
|
17006
|
+
let output = input5.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
17010
17007
|
if (first === "\\") {
|
|
17011
17008
|
backslashes = true;
|
|
17012
17009
|
return m;
|
|
@@ -17040,8 +17037,8 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
17040
17037
|
});
|
|
17041
17038
|
}
|
|
17042
17039
|
}
|
|
17043
|
-
if (output ===
|
|
17044
|
-
state.output =
|
|
17040
|
+
if (output === input5 && opts.contains === true) {
|
|
17041
|
+
state.output = input5;
|
|
17045
17042
|
return state;
|
|
17046
17043
|
}
|
|
17047
17044
|
state.output = utils.wrapOutput(output, state, options2);
|
|
@@ -17400,7 +17397,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
17400
17397
|
continue;
|
|
17401
17398
|
}
|
|
17402
17399
|
while (rest.slice(0, 3) === "/**") {
|
|
17403
|
-
const after =
|
|
17400
|
+
const after = input5[state.index + 4];
|
|
17404
17401
|
if (after && after !== "/") {
|
|
17405
17402
|
break;
|
|
17406
17403
|
}
|
|
@@ -17523,14 +17520,14 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
17523
17520
|
}
|
|
17524
17521
|
return state;
|
|
17525
17522
|
};
|
|
17526
|
-
parse2.fastpaths = (
|
|
17523
|
+
parse2.fastpaths = (input5, options2) => {
|
|
17527
17524
|
const opts = { ...options2 };
|
|
17528
17525
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
17529
|
-
const len =
|
|
17526
|
+
const len = input5.length;
|
|
17530
17527
|
if (len > max) {
|
|
17531
17528
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
17532
17529
|
}
|
|
17533
|
-
|
|
17530
|
+
input5 = REPLACEMENTS[input5] || input5;
|
|
17534
17531
|
const win32 = utils.isWindows(options2);
|
|
17535
17532
|
const {
|
|
17536
17533
|
DOT_LITERAL,
|
|
@@ -17585,7 +17582,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
|
17585
17582
|
}
|
|
17586
17583
|
}
|
|
17587
17584
|
};
|
|
17588
|
-
const output = utils.removePrefix(
|
|
17585
|
+
const output = utils.removePrefix(input5, state);
|
|
17589
17586
|
let source = create2(output);
|
|
17590
17587
|
if (source && opts.strictSlashes !== true) {
|
|
17591
17588
|
source += `${SLASH_LITERAL}?`;
|
|
@@ -17605,7 +17602,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17605
17602
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
17606
17603
|
var picomatch = (glob, options2, returnState = false) => {
|
|
17607
17604
|
if (Array.isArray(glob)) {
|
|
17608
|
-
const fns = glob.map((
|
|
17605
|
+
const fns = glob.map((input5) => picomatch(input5, options2, returnState));
|
|
17609
17606
|
const arrayMatcher = (str) => {
|
|
17610
17607
|
for (const isMatch of fns) {
|
|
17611
17608
|
const state2 = isMatch(str);
|
|
@@ -17630,9 +17627,9 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17630
17627
|
const ignoreOpts = { ...options2, ignore: null, onMatch: null, onResult: null };
|
|
17631
17628
|
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
17632
17629
|
}
|
|
17633
|
-
const matcher = (
|
|
17634
|
-
const { isMatch, match, output } = picomatch.test(
|
|
17635
|
-
const result = { glob, state, regex, posix, input:
|
|
17630
|
+
const matcher = (input5, returnObject = false) => {
|
|
17631
|
+
const { isMatch, match, output } = picomatch.test(input5, regex, options2, { glob, posix });
|
|
17632
|
+
const result = { glob, state, regex, posix, input: input5, output, match, isMatch };
|
|
17636
17633
|
if (typeof opts.onResult === "function") {
|
|
17637
17634
|
opts.onResult(result);
|
|
17638
17635
|
}
|
|
@@ -17640,7 +17637,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17640
17637
|
result.isMatch = false;
|
|
17641
17638
|
return returnObject ? result : false;
|
|
17642
17639
|
}
|
|
17643
|
-
if (isIgnored(
|
|
17640
|
+
if (isIgnored(input5)) {
|
|
17644
17641
|
if (typeof opts.onIgnore === "function") {
|
|
17645
17642
|
opts.onIgnore(result);
|
|
17646
17643
|
}
|
|
@@ -17657,33 +17654,33 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17657
17654
|
}
|
|
17658
17655
|
return matcher;
|
|
17659
17656
|
};
|
|
17660
|
-
picomatch.test = (
|
|
17661
|
-
if (typeof
|
|
17657
|
+
picomatch.test = (input5, regex, options2, { glob, posix } = {}) => {
|
|
17658
|
+
if (typeof input5 !== "string") {
|
|
17662
17659
|
throw new TypeError("Expected input to be a string");
|
|
17663
17660
|
}
|
|
17664
|
-
if (
|
|
17661
|
+
if (input5 === "") {
|
|
17665
17662
|
return { isMatch: false, output: "" };
|
|
17666
17663
|
}
|
|
17667
17664
|
const opts = options2 || {};
|
|
17668
17665
|
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
17669
|
-
let match =
|
|
17670
|
-
let output = match && format ? format(
|
|
17666
|
+
let match = input5 === glob;
|
|
17667
|
+
let output = match && format ? format(input5) : input5;
|
|
17671
17668
|
if (match === false) {
|
|
17672
|
-
output = format ? format(
|
|
17669
|
+
output = format ? format(input5) : input5;
|
|
17673
17670
|
match = output === glob;
|
|
17674
17671
|
}
|
|
17675
17672
|
if (match === false || opts.capture === true) {
|
|
17676
17673
|
if (opts.matchBase === true || opts.basename === true) {
|
|
17677
|
-
match = picomatch.matchBase(
|
|
17674
|
+
match = picomatch.matchBase(input5, regex, options2, posix);
|
|
17678
17675
|
} else {
|
|
17679
17676
|
match = regex.exec(output);
|
|
17680
17677
|
}
|
|
17681
17678
|
}
|
|
17682
17679
|
return { isMatch: Boolean(match), match, output };
|
|
17683
17680
|
};
|
|
17684
|
-
picomatch.matchBase = (
|
|
17681
|
+
picomatch.matchBase = (input5, glob, options2, posix = utils.isWindows(options2)) => {
|
|
17685
17682
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options2);
|
|
17686
|
-
return regex.test(path2.basename(
|
|
17683
|
+
return regex.test(path2.basename(input5));
|
|
17687
17684
|
};
|
|
17688
17685
|
picomatch.isMatch = (str, patterns, options2) => picomatch(patterns, options2)(str);
|
|
17689
17686
|
picomatch.parse = (pattern, options2) => {
|
|
@@ -17691,7 +17688,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17691
17688
|
return pattern.map((p) => picomatch.parse(p, options2));
|
|
17692
17689
|
return parse2(pattern, { ...options2, fastpaths: false });
|
|
17693
17690
|
};
|
|
17694
|
-
picomatch.scan = (
|
|
17691
|
+
picomatch.scan = (input5, options2) => scan(input5, options2);
|
|
17695
17692
|
picomatch.compileRe = (state, options2, returnOutput = false, returnState = false) => {
|
|
17696
17693
|
if (returnOutput === true) {
|
|
17697
17694
|
return state.output;
|
|
@@ -17709,16 +17706,16 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
17709
17706
|
}
|
|
17710
17707
|
return regex;
|
|
17711
17708
|
};
|
|
17712
|
-
picomatch.makeRe = (
|
|
17713
|
-
if (!
|
|
17709
|
+
picomatch.makeRe = (input5, options2 = {}, returnOutput = false, returnState = false) => {
|
|
17710
|
+
if (!input5 || typeof input5 !== "string") {
|
|
17714
17711
|
throw new TypeError("Expected a non-empty string");
|
|
17715
17712
|
}
|
|
17716
17713
|
let parsed = { negated: false, fastpaths: true };
|
|
17717
|
-
if (options2.fastpaths !== false && (
|
|
17718
|
-
parsed.output = parse2.fastpaths(
|
|
17714
|
+
if (options2.fastpaths !== false && (input5[0] === "." || input5[0] === "*")) {
|
|
17715
|
+
parsed.output = parse2.fastpaths(input5, options2);
|
|
17719
17716
|
}
|
|
17720
17717
|
if (!parsed.output) {
|
|
17721
|
-
parsed = parse2(
|
|
17718
|
+
parsed = parse2(input5, options2);
|
|
17722
17719
|
}
|
|
17723
17720
|
return picomatch.compileRe(parsed, options2, returnOutput, returnState);
|
|
17724
17721
|
};
|
|
@@ -17864,10 +17861,10 @@ var require_micromatch = __commonJS((exports, module) => {
|
|
|
17864
17861
|
}
|
|
17865
17862
|
return [].concat(patterns).every((p) => picomatch(p, options2)(str));
|
|
17866
17863
|
};
|
|
17867
|
-
micromatch.capture = (glob,
|
|
17864
|
+
micromatch.capture = (glob, input5, options2) => {
|
|
17868
17865
|
let posix = utils.isWindows(options2);
|
|
17869
17866
|
let regex = picomatch.makeRe(String(glob), { ...options2, capture: true });
|
|
17870
|
-
let match = regex.exec(posix ? utils.toPosixSlashes(
|
|
17867
|
+
let match = regex.exec(posix ? utils.toPosixSlashes(input5) : input5);
|
|
17871
17868
|
if (match) {
|
|
17872
17869
|
return match.slice(1).map((v) => v === undefined ? "" : v);
|
|
17873
17870
|
}
|
|
@@ -18202,12 +18199,12 @@ var require_stream = __commonJS((exports) => {
|
|
|
18202
18199
|
var require_string = __commonJS((exports) => {
|
|
18203
18200
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18204
18201
|
exports.isEmpty = exports.isString = undefined;
|
|
18205
|
-
function isString(
|
|
18206
|
-
return typeof
|
|
18202
|
+
function isString(input5) {
|
|
18203
|
+
return typeof input5 === "string";
|
|
18207
18204
|
}
|
|
18208
18205
|
exports.isString = isString;
|
|
18209
|
-
function isEmpty(
|
|
18210
|
-
return
|
|
18206
|
+
function isEmpty(input5) {
|
|
18207
|
+
return input5 === "";
|
|
18211
18208
|
}
|
|
18212
18209
|
exports.isEmpty = isEmpty;
|
|
18213
18210
|
});
|
|
@@ -18237,8 +18234,8 @@ var require_tasks = __commonJS((exports) => {
|
|
|
18237
18234
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18238
18235
|
exports.convertPatternGroupToTask = exports.convertPatternGroupsToTasks = exports.groupPatternsByBaseDirectory = exports.getNegativePatternsAsPositive = exports.getPositivePatterns = exports.convertPatternsToTasks = exports.generate = undefined;
|
|
18239
18236
|
var utils = require_utils3();
|
|
18240
|
-
function generate(
|
|
18241
|
-
const patterns = processPatterns(
|
|
18237
|
+
function generate(input5, settings) {
|
|
18238
|
+
const patterns = processPatterns(input5, settings);
|
|
18242
18239
|
const ignore = processPatterns(settings.ignore, settings);
|
|
18243
18240
|
const positivePatterns = getPositivePatterns(patterns);
|
|
18244
18241
|
const negativePatterns = getNegativePatternsAsPositive(patterns, ignore);
|
|
@@ -18249,8 +18246,8 @@ var require_tasks = __commonJS((exports) => {
|
|
|
18249
18246
|
return staticTasks.concat(dynamicTasks);
|
|
18250
18247
|
}
|
|
18251
18248
|
exports.generate = generate;
|
|
18252
|
-
function processPatterns(
|
|
18253
|
-
let patterns =
|
|
18249
|
+
function processPatterns(input5, settings) {
|
|
18250
|
+
let patterns = input5;
|
|
18254
18251
|
if (settings.braceExpansion) {
|
|
18255
18252
|
patterns = utils.pattern.expandPatternsWithBraceExpansion(patterns);
|
|
18256
18253
|
}
|
|
@@ -20206,8 +20203,8 @@ var require_out4 = __commonJS((exports, module) => {
|
|
|
20206
20203
|
const provider = new _Provider(settings);
|
|
20207
20204
|
return tasks.map(provider.read, provider);
|
|
20208
20205
|
}
|
|
20209
|
-
function assertPatternsInput(
|
|
20210
|
-
const source = [].concat(
|
|
20206
|
+
function assertPatternsInput(input5) {
|
|
20207
|
+
const source = [].concat(input5);
|
|
20211
20208
|
const isValidSource = source.every((item) => utils.string.isString(item) && !utils.string.isEmpty(item));
|
|
20212
20209
|
if (!isValidSource) {
|
|
20213
20210
|
throw new TypeError("Patterns must be a string (non empty) or an array of strings");
|
|
@@ -22316,10 +22313,10 @@ function requireStyle() {
|
|
|
22316
22313
|
const c2 = requireKleur();
|
|
22317
22314
|
const figures = requireFigures();
|
|
22318
22315
|
const styles3 = Object.freeze({
|
|
22319
|
-
password: { scale: 1, render: (
|
|
22320
|
-
emoji: { scale: 2, render: (
|
|
22321
|
-
invisible: { scale: 0, render: (
|
|
22322
|
-
default: { scale: 1, render: (
|
|
22316
|
+
password: { scale: 1, render: (input5) => "*".repeat(input5.length) },
|
|
22317
|
+
emoji: { scale: 2, render: (input5) => "\uD83D\uDE03".repeat(input5.length) },
|
|
22318
|
+
invisible: { scale: 0, render: (input5) => "" },
|
|
22319
|
+
default: { scale: 1, render: (input5) => `${input5}` }
|
|
22323
22320
|
});
|
|
22324
22321
|
const render = (type) => styles3[type] || styles3.default;
|
|
22325
22322
|
const symbols = Object.freeze({
|
|
@@ -22659,7 +22656,7 @@ ${i2 ? " " : figures.pointerSmall} ${color.red().italic(l2)}`, ``);
|
|
|
22659
22656
|
}
|
|
22660
22657
|
function requireSelect() {
|
|
22661
22658
|
if (hasRequiredSelect)
|
|
22662
|
-
return
|
|
22659
|
+
return select4;
|
|
22663
22660
|
hasRequiredSelect = 1;
|
|
22664
22661
|
const color = requireKleur();
|
|
22665
22662
|
const Prompt = requirePrompt();
|
|
@@ -22805,8 +22802,8 @@ function requireSelect() {
|
|
|
22805
22802
|
this.out.write(this.outputText);
|
|
22806
22803
|
}
|
|
22807
22804
|
}
|
|
22808
|
-
|
|
22809
|
-
return
|
|
22805
|
+
select4 = SelectPrompt;
|
|
22806
|
+
return select4;
|
|
22810
22807
|
}
|
|
22811
22808
|
function requireToggle() {
|
|
22812
22809
|
if (hasRequiredToggle)
|
|
@@ -24178,7 +24175,7 @@ Filtered results for: ${this.inputValue ? this.inputValue : color.gray("Enter so
|
|
|
24178
24175
|
}
|
|
24179
24176
|
function requireConfirm() {
|
|
24180
24177
|
if (hasRequiredConfirm)
|
|
24181
|
-
return
|
|
24178
|
+
return confirm5;
|
|
24182
24179
|
hasRequiredConfirm = 1;
|
|
24183
24180
|
const color = requireKleur();
|
|
24184
24181
|
const Prompt = requirePrompt();
|
|
@@ -24251,8 +24248,8 @@ function requireConfirm() {
|
|
|
24251
24248
|
this.out.write(erase.line + cursor.to(0) + this.outputText);
|
|
24252
24249
|
}
|
|
24253
24250
|
}
|
|
24254
|
-
|
|
24255
|
-
return
|
|
24251
|
+
confirm5 = ConfirmPrompt;
|
|
24252
|
+
return confirm5;
|
|
24256
24253
|
}
|
|
24257
24254
|
function requireElements() {
|
|
24258
24255
|
if (hasRequiredElements)
|
|
@@ -24327,7 +24324,7 @@ function requirePrompts$1() {
|
|
|
24327
24324
|
onSubmit: toSelected
|
|
24328
24325
|
});
|
|
24329
24326
|
};
|
|
24330
|
-
const byTitle = (
|
|
24327
|
+
const byTitle = (input5, choices) => Promise.resolve(choices.filter((item) => item.title.slice(0, input5.length).toLowerCase() === input5.toLowerCase()));
|
|
24331
24328
|
$.autocomplete = (args) => {
|
|
24332
24329
|
args.suggest = args.suggest || byTitle;
|
|
24333
24330
|
args.choices = [].concat(args.choices || []);
|
|
@@ -24932,7 +24929,7 @@ async function detect2({ autoInstall, programmatic, cwd } = {}) {
|
|
|
24932
24929
|
}
|
|
24933
24930
|
return agent;
|
|
24934
24931
|
}
|
|
24935
|
-
var ini$1, hasRequiredIni, iniExports, prompts$2, kleur, hasRequiredKleur, action, hasRequiredAction, strip, hasRequiredStrip, src, hasRequiredSrc, clear, hasRequiredClear, figures_1, hasRequiredFigures, style, hasRequiredStyle, lines, hasRequiredLines, wrap, hasRequiredWrap, entriesToDisplay, hasRequiredEntriesToDisplay, util, hasRequiredUtil, prompt, hasRequiredPrompt, text, hasRequiredText,
|
|
24932
|
+
var ini$1, hasRequiredIni, iniExports, prompts$2, kleur, hasRequiredKleur, action, hasRequiredAction, strip, hasRequiredStrip, src, hasRequiredSrc, clear, hasRequiredClear, figures_1, hasRequiredFigures, style, hasRequiredStyle, lines, hasRequiredLines, wrap, hasRequiredWrap, entriesToDisplay, hasRequiredEntriesToDisplay, util, hasRequiredUtil, prompt, hasRequiredPrompt, text, hasRequiredText, select4, hasRequiredSelect, toggle, hasRequiredToggle, datepart, hasRequiredDatepart, meridiem, hasRequiredMeridiem, day, hasRequiredDay, hours, hasRequiredHours, milliseconds, hasRequiredMilliseconds, minutes, hasRequiredMinutes, month, hasRequiredMonth, seconds, hasRequiredSeconds, year, hasRequiredYear, dateparts, hasRequiredDateparts, date, hasRequiredDate, number, hasRequiredNumber, multiselect, hasRequiredMultiselect, autocomplete, hasRequiredAutocomplete, autocompleteMultiselect, hasRequiredAutocompleteMultiselect, confirm5, hasRequiredConfirm, elements, hasRequiredElements, hasRequiredPrompts$1, lib$1, hasRequiredLib$1, prompts$1, hasRequiredPrompts, promptsExports, prompts, isBrowser, platform, OSC = "\x1B]", BEL = "\x07", SEP = ";", link = (text2, url) => [
|
|
24936
24933
|
OSC,
|
|
24937
24934
|
"8",
|
|
24938
24935
|
SEP,
|
|
@@ -25616,12 +25613,12 @@ var init_figures = __esm(() => {
|
|
|
25616
25613
|
import tty2 from "node:tty";
|
|
25617
25614
|
var hasColors, format = (open, close) => {
|
|
25618
25615
|
if (!hasColors) {
|
|
25619
|
-
return (
|
|
25616
|
+
return (input5) => input5;
|
|
25620
25617
|
}
|
|
25621
25618
|
const openCode = `\x1B[${open}m`;
|
|
25622
25619
|
const closeCode = `\x1B[${close}m`;
|
|
25623
|
-
return (
|
|
25624
|
-
const string =
|
|
25620
|
+
return (input5) => {
|
|
25621
|
+
const string = input5 + "";
|
|
25625
25622
|
let index = string.indexOf(closeCode);
|
|
25626
25623
|
if (index === -1) {
|
|
25627
25624
|
return openCode + string + closeCode;
|
|
@@ -27730,16 +27727,16 @@ var init_options2 = __esm(() => {
|
|
|
27730
27727
|
var concatenateShell = (file, commandArguments, options3) => options3.shell && commandArguments.length > 0 ? [[file, ...commandArguments].join(" "), [], options3] : [file, commandArguments, options3];
|
|
27731
27728
|
|
|
27732
27729
|
// ../../node_modules/strip-final-newline/index.js
|
|
27733
|
-
function stripFinalNewline(
|
|
27734
|
-
if (typeof
|
|
27735
|
-
return stripFinalNewlineString(
|
|
27730
|
+
function stripFinalNewline(input5) {
|
|
27731
|
+
if (typeof input5 === "string") {
|
|
27732
|
+
return stripFinalNewlineString(input5);
|
|
27736
27733
|
}
|
|
27737
|
-
if (!(ArrayBuffer.isView(
|
|
27734
|
+
if (!(ArrayBuffer.isView(input5) && input5.BYTES_PER_ELEMENT === 1)) {
|
|
27738
27735
|
throw new Error("Input must be a string or a Uint8Array");
|
|
27739
27736
|
}
|
|
27740
|
-
return stripFinalNewlineBinary(
|
|
27737
|
+
return stripFinalNewlineBinary(input5);
|
|
27741
27738
|
}
|
|
27742
|
-
var stripFinalNewlineString = (
|
|
27739
|
+
var stripFinalNewlineString = (input5) => input5.at(-1) === LF ? input5.slice(0, input5.at(-2) === CR ? -2 : -1) : input5, stripFinalNewlineBinary = (input5) => input5.at(-1) === LF_BINARY ? input5.subarray(0, input5.at(-2) === CR_BINARY ? -2 : -1) : input5, LF = `
|
|
27743
27740
|
`, LF_BINARY, CR = "\r", CR_BINARY;
|
|
27744
27741
|
var init_strip_final_newline = __esm(() => {
|
|
27745
27742
|
LF_BINARY = LF.codePointAt(0);
|
|
@@ -28778,21 +28775,21 @@ var init_native = __esm(() => {
|
|
|
28778
28775
|
});
|
|
28779
28776
|
|
|
28780
28777
|
// ../../node_modules/execa/lib/stdio/input-option.js
|
|
28781
|
-
var handleInputOptions = ({ input:
|
|
28782
|
-
...handleInputOption(
|
|
28778
|
+
var handleInputOptions = ({ input: input5, inputFile }, fdNumber) => fdNumber === 0 ? [
|
|
28779
|
+
...handleInputOption(input5),
|
|
28783
28780
|
...handleInputFileOption(inputFile)
|
|
28784
|
-
] : [], handleInputOption = (
|
|
28785
|
-
type: getInputType(
|
|
28786
|
-
value:
|
|
28781
|
+
] : [], handleInputOption = (input5) => input5 === undefined ? [] : [{
|
|
28782
|
+
type: getInputType(input5),
|
|
28783
|
+
value: input5,
|
|
28787
28784
|
optionName: "input"
|
|
28788
|
-
}], getInputType = (
|
|
28789
|
-
if (isReadableStream(
|
|
28785
|
+
}], getInputType = (input5) => {
|
|
28786
|
+
if (isReadableStream(input5, { checkOpen: false })) {
|
|
28790
28787
|
return "nodeStream";
|
|
28791
28788
|
}
|
|
28792
|
-
if (typeof
|
|
28789
|
+
if (typeof input5 === "string") {
|
|
28793
28790
|
return "string";
|
|
28794
28791
|
}
|
|
28795
|
-
if (isUint8Array(
|
|
28792
|
+
if (isUint8Array(input5)) {
|
|
28796
28793
|
return "uint8Array";
|
|
28797
28794
|
}
|
|
28798
28795
|
throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.");
|
|
@@ -31908,7 +31905,7 @@ var init_command2 = __esm(() => {
|
|
|
31908
31905
|
var setScriptSync = (boundExeca, createNested, boundOptions) => {
|
|
31909
31906
|
boundExeca.sync = createNested(mapScriptSync, boundOptions);
|
|
31910
31907
|
boundExeca.s = boundExeca.sync;
|
|
31911
|
-
}, mapScriptAsync = ({ options: options3 }) => getScriptOptions(options3), mapScriptSync = ({ options: options3 }) => ({ ...getScriptOptions(options3), isSync: true }), getScriptOptions = (options3) => ({ options: { ...getScriptStdinOption(options3), ...options3 } }), getScriptStdinOption = ({ input:
|
|
31908
|
+
}, mapScriptAsync = ({ options: options3 }) => getScriptOptions(options3), mapScriptSync = ({ options: options3 }) => ({ ...getScriptOptions(options3), isSync: true }), getScriptOptions = (options3) => ({ options: { ...getScriptStdinOption(options3), ...options3 } }), getScriptStdinOption = ({ input: input5, inputFile, stdio }) => input5 === undefined && inputFile === undefined && stdio === undefined ? { stdin: "inherit" } : {}, deepScriptOptions;
|
|
31912
31909
|
var init_script = __esm(() => {
|
|
31913
31910
|
deepScriptOptions = { preferLocal: true };
|
|
31914
31911
|
});
|
|
@@ -32019,20 +32016,20 @@ __export(exports_generate, {
|
|
|
32019
32016
|
import path10 from "node:path";
|
|
32020
32017
|
import { getErrorMessage as getErrorMessage2 } from "@secondlayer/shared";
|
|
32021
32018
|
import { toCamelCase as toCamelCase8 } from "@secondlayer/stacks/clarity";
|
|
32022
|
-
function isContractAddress(
|
|
32019
|
+
function isContractAddress(input5) {
|
|
32023
32020
|
const contractIdPattern = /^(SP|ST|SM|SN)[A-Z0-9]{38,}\.[a-zA-Z][a-zA-Z0-9-]*$/;
|
|
32024
|
-
return contractIdPattern.test(
|
|
32021
|
+
return contractIdPattern.test(input5);
|
|
32025
32022
|
}
|
|
32026
32023
|
async function parseInputs(inputs) {
|
|
32027
32024
|
const files = [];
|
|
32028
32025
|
const contractIds = [];
|
|
32029
|
-
for (const
|
|
32030
|
-
if (isContractAddress(
|
|
32031
|
-
contractIds.push(
|
|
32026
|
+
for (const input5 of inputs) {
|
|
32027
|
+
if (isContractAddress(input5)) {
|
|
32028
|
+
contractIds.push(input5);
|
|
32032
32029
|
continue;
|
|
32033
32030
|
}
|
|
32034
|
-
if (
|
|
32035
|
-
const matches = await import_fast_glob.default(
|
|
32031
|
+
if (input5.includes("*") || input5.includes("?")) {
|
|
32032
|
+
const matches = await import_fast_glob.default(input5, { cwd: process.cwd(), absolute: true });
|
|
32036
32033
|
for (const file of matches) {
|
|
32037
32034
|
if (file.endsWith(".clar")) {
|
|
32038
32035
|
files.push(file);
|
|
@@ -32040,8 +32037,8 @@ async function parseInputs(inputs) {
|
|
|
32040
32037
|
}
|
|
32041
32038
|
continue;
|
|
32042
32039
|
}
|
|
32043
|
-
if (
|
|
32044
|
-
const absolutePath = path10.resolve(process.cwd(),
|
|
32040
|
+
if (input5.endsWith(".clar")) {
|
|
32041
|
+
const absolutePath = path10.resolve(process.cwd(), input5);
|
|
32045
32042
|
files.push(absolutePath);
|
|
32046
32043
|
}
|
|
32047
32044
|
}
|
|
@@ -32324,7 +32321,7 @@ var {
|
|
|
32324
32321
|
// package.json
|
|
32325
32322
|
var package_default = {
|
|
32326
32323
|
name: "@secondlayer/cli",
|
|
32327
|
-
version: "5.
|
|
32324
|
+
version: "5.4.0",
|
|
32328
32325
|
description: "CLI for subgraphs and blockchain indexing on Stacks",
|
|
32329
32326
|
type: "module",
|
|
32330
32327
|
bin: {
|
|
@@ -32368,9 +32365,9 @@ var package_default = {
|
|
|
32368
32365
|
"@inquirer/prompts": "^8.2.0",
|
|
32369
32366
|
"@secondlayer/bundler": "^0.3.5",
|
|
32370
32367
|
"@secondlayer/sdk": "^3.6.0",
|
|
32371
|
-
"@secondlayer/shared": "^6.
|
|
32368
|
+
"@secondlayer/shared": "^6.4.1",
|
|
32372
32369
|
"@secondlayer/stacks": "^2.2.0",
|
|
32373
|
-
"@secondlayer/subgraphs": "^2.0.
|
|
32370
|
+
"@secondlayer/subgraphs": "^2.0.2",
|
|
32374
32371
|
"@biomejs/js-api": "^0.7.0",
|
|
32375
32372
|
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
32376
32373
|
esbuild: "^0.19.0",
|
|
@@ -33098,6 +33095,21 @@ async function validateSubscriptionTargetFromApi(client, input) {
|
|
|
33098
33095
|
}
|
|
33099
33096
|
}
|
|
33100
33097
|
|
|
33098
|
+
// src/utils/urls.ts
|
|
33099
|
+
function deriveBaseUrl(apiUrl) {
|
|
33100
|
+
const override = process.env.SL_DASHBOARD_URL?.trim();
|
|
33101
|
+
if (override)
|
|
33102
|
+
return override.replace(/\/$/, "");
|
|
33103
|
+
try {
|
|
33104
|
+
const url = new URL(apiUrl);
|
|
33105
|
+
url.hostname = url.hostname.replace(/^api\./, "");
|
|
33106
|
+
url.pathname = "/";
|
|
33107
|
+
return url.toString().replace(/\/$/, "");
|
|
33108
|
+
} catch {
|
|
33109
|
+
return apiUrl.replace(/\/$/, "");
|
|
33110
|
+
}
|
|
33111
|
+
}
|
|
33112
|
+
|
|
33101
33113
|
// src/commands/create.ts
|
|
33102
33114
|
var RUNTIMES = ["inngest", "trigger", "cloudflare", "node"];
|
|
33103
33115
|
var FORMAT_BY_RUNTIME = {
|
|
@@ -33161,6 +33173,10 @@ function buildSubscriptionAuthConfig(authToken) {
|
|
|
33161
33173
|
return { authType: "bearer", token };
|
|
33162
33174
|
}
|
|
33163
33175
|
async function createSubscription(name, opts) {
|
|
33176
|
+
if (opts.runtime && !RUNTIMES.includes(opts.runtime)) {
|
|
33177
|
+
error(`Unknown --runtime "${opts.runtime}". Valid: ${RUNTIMES.join(", ")}`);
|
|
33178
|
+
process.exit(1);
|
|
33179
|
+
}
|
|
33164
33180
|
const { runtime, subgraph, table, url } = await promptFor(name, opts);
|
|
33165
33181
|
let filter;
|
|
33166
33182
|
let authConfig;
|
|
@@ -33223,31 +33239,52 @@ async function createSubscription(name, opts) {
|
|
|
33223
33239
|
info("Template copied, but the subscription was not created. Provision it in the dashboard, or remove the template directory and rerun this command after fixing the API error.");
|
|
33224
33240
|
}
|
|
33225
33241
|
}
|
|
33242
|
+
let subscriptionId;
|
|
33243
|
+
let subscriptionStatus;
|
|
33244
|
+
if (sl) {
|
|
33245
|
+
try {
|
|
33246
|
+
const list = await sl.subscriptions.list();
|
|
33247
|
+
const rows = list.data ?? [];
|
|
33248
|
+
const created = rows.find((s) => s.name === name);
|
|
33249
|
+
subscriptionId = created?.id;
|
|
33250
|
+
subscriptionStatus = created?.status;
|
|
33251
|
+
} catch {}
|
|
33252
|
+
}
|
|
33226
33253
|
if (signingSecret) {
|
|
33227
33254
|
const envTarget = join4(targetDir, ".env");
|
|
33228
33255
|
const envExample = join4(targetDir, ".env.example");
|
|
33229
33256
|
if (existsSync(envExample) && !existsSync(envTarget)) {
|
|
33230
33257
|
copyFileSync(envExample, envTarget);
|
|
33231
33258
|
}
|
|
33232
|
-
if (existsSync(envTarget)) {
|
|
33259
|
+
if (!existsSync(envTarget)) {
|
|
33260
|
+
writeFileSync(envTarget, `SIGNING_SECRET=${signingSecret}
|
|
33261
|
+
`);
|
|
33262
|
+
} else {
|
|
33233
33263
|
const cur = readFileSync(envTarget, "utf8");
|
|
33234
|
-
|
|
33235
|
-
writeFileSync(envTarget, next.includes("SIGNING_SECRET=") ? next : `${cur}
|
|
33264
|
+
writeFileSync(envTarget, cur.match(/^SIGNING_SECRET=/m) ? cur.replace(/^SIGNING_SECRET=.*/m, `SIGNING_SECRET=${signingSecret}`) : `${cur}
|
|
33236
33265
|
SIGNING_SECRET=${signingSecret}
|
|
33237
33266
|
`);
|
|
33238
|
-
success(`Signing secret written to ${relative(process.cwd(), envTarget)}`);
|
|
33239
|
-
} else {
|
|
33240
|
-
info(`Signing secret (copy this — won't be shown again):
|
|
33241
|
-
${dim(" ")}${signingSecret}`);
|
|
33242
33267
|
}
|
|
33268
|
+
success(`Signing secret written to ${relative(process.cwd(), envTarget)}`);
|
|
33243
33269
|
}
|
|
33244
33270
|
console.log();
|
|
33245
33271
|
if (provisioningFailed) {
|
|
33246
33272
|
error("Subscription was not created.");
|
|
33247
33273
|
process.exit(1);
|
|
33248
33274
|
}
|
|
33275
|
+
let dashboardLine = "";
|
|
33276
|
+
try {
|
|
33277
|
+
const { apiUrl } = await resolveActiveTenant();
|
|
33278
|
+
const base = deriveBaseUrl(apiUrl);
|
|
33279
|
+
dashboardLine = subscriptionId ? `Dashboard: ${base}/platform/subgraphs/${subgraph}/subscriptions/${subscriptionId}
|
|
33280
|
+
` : `Dashboard: ${base}/platform/subgraphs/${subgraph}/subscriptions
|
|
33281
|
+
`;
|
|
33282
|
+
} catch {}
|
|
33283
|
+
const pausedLine = subscriptionStatus === "paused" ? `Subscription is paused. Resume:
|
|
33284
|
+
sl subscriptions resume ${name}
|
|
33285
|
+
` : "";
|
|
33249
33286
|
success(`Done. Next:
|
|
33250
|
-
cd ${name}
|
|
33287
|
+
${dashboardLine}${pausedLine}cd ${name}
|
|
33251
33288
|
bun install
|
|
33252
33289
|
bun run dev`);
|
|
33253
33290
|
}
|
|
@@ -33488,6 +33525,7 @@ function printSubscriptionDetail(sub) {
|
|
|
33488
33525
|
["Circuit Opened", sub.circuitOpenedAt ?? "none"],
|
|
33489
33526
|
["Last Error", sub.lastError ?? "none"],
|
|
33490
33527
|
["Max Retries", String(sub.maxRetries)],
|
|
33528
|
+
["Backoff", "30s → 2m → 10m → 1h → 6h → 24h → 72h"],
|
|
33491
33529
|
["Timeout", `${sub.timeoutMs}ms`],
|
|
33492
33530
|
["Concurrency", String(sub.concurrency)],
|
|
33493
33531
|
["Created", sub.createdAt],
|
|
@@ -33794,7 +33832,22 @@ ${data.length} subscription(s) total`));
|
|
|
33794
33832
|
commonOptions(subscriptions.command("delete <idOrName>").description("Delete a subscription").option("-y, --yes", "Skip confirmation").option("--json", "Output as JSON")).action(async (idOrName, options) => {
|
|
33795
33833
|
try {
|
|
33796
33834
|
const client = await getSubscriptionClient(options);
|
|
33797
|
-
|
|
33835
|
+
let resolved = null;
|
|
33836
|
+
try {
|
|
33837
|
+
resolved = await resolveSubscriptionRef(client, idOrName);
|
|
33838
|
+
} catch (err) {
|
|
33839
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
33840
|
+
const status = err?.status;
|
|
33841
|
+
if (status === 404 || /not found/i.test(msg)) {
|
|
33842
|
+
if (options.json)
|
|
33843
|
+
printJson({ deleted: false, reason: "not_found" });
|
|
33844
|
+
else
|
|
33845
|
+
info(`Subscription "${idOrName}" not found (already deleted?)`);
|
|
33846
|
+
return;
|
|
33847
|
+
}
|
|
33848
|
+
throw err;
|
|
33849
|
+
}
|
|
33850
|
+
const { id, detail } = resolved;
|
|
33798
33851
|
const ok = await confirmOrExit(`Delete subscription "${detail.name}"? Pending outbox rows will be removed.`, options.yes);
|
|
33799
33852
|
if (!ok)
|
|
33800
33853
|
return;
|
|
@@ -34974,6 +35027,45 @@ function decodeBuffUtf8(value: unknown): string | null {
|
|
|
34974
35027
|
|
|
34975
35028
|
// src/commands/subgraphs.ts
|
|
34976
35029
|
init_api();
|
|
35030
|
+
init_resolve_tenant();
|
|
35031
|
+
async function loadSubgraphWithDepCheck(absPath) {
|
|
35032
|
+
try {
|
|
35033
|
+
return await import(absPath);
|
|
35034
|
+
} catch (err) {
|
|
35035
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
35036
|
+
const code = err?.code;
|
|
35037
|
+
const missingSdk = (code === "ERR_MODULE_NOT_FOUND" || msg.includes("ERR_MODULE_NOT_FOUND")) && msg.includes("@secondlayer/subgraphs");
|
|
35038
|
+
if (!missingSdk)
|
|
35039
|
+
throw err;
|
|
35040
|
+
warn("Missing dependency: @secondlayer/subgraphs");
|
|
35041
|
+
const install = await confirm3({
|
|
35042
|
+
message: "Install with `bun add @secondlayer/subgraphs`?",
|
|
35043
|
+
default: true
|
|
35044
|
+
});
|
|
35045
|
+
if (!install)
|
|
35046
|
+
throw err;
|
|
35047
|
+
await new Promise((res, rej) => {
|
|
35048
|
+
const child = spawn("bun", ["add", "@secondlayer/subgraphs"], {
|
|
35049
|
+
stdio: "inherit"
|
|
35050
|
+
});
|
|
35051
|
+
child.on("error", rej);
|
|
35052
|
+
child.on("exit", (c) => c === 0 ? res() : rej(new Error(`bun add exit ${c}`)));
|
|
35053
|
+
});
|
|
35054
|
+
return await import(absPath);
|
|
35055
|
+
}
|
|
35056
|
+
}
|
|
35057
|
+
async function typecheckHandler(absPath) {
|
|
35058
|
+
await new Promise((res, rej) => {
|
|
35059
|
+
const child = spawn("bunx", ["tsc", "--noEmit", "--allowJs", "--target", "es2022", absPath], { stdio: "inherit" });
|
|
35060
|
+
child.on("error", (err) => rej(new Error(`Failed to run tsc — install typescript (\`bun add -d typescript\`) or drop --strict. (${err.message})`)));
|
|
35061
|
+
child.on("exit", (code) => {
|
|
35062
|
+
if (code === 0)
|
|
35063
|
+
res();
|
|
35064
|
+
else
|
|
35065
|
+
rej(new Error(`Type-check failed (tsc exit ${code})`));
|
|
35066
|
+
});
|
|
35067
|
+
});
|
|
35068
|
+
}
|
|
34977
35069
|
function parseStartBlockOption(value) {
|
|
34978
35070
|
if (value === undefined)
|
|
34979
35071
|
return;
|
|
@@ -35293,7 +35385,7 @@ Stopped watching.`);
|
|
|
35293
35385
|
});
|
|
35294
35386
|
await new Promise(() => {});
|
|
35295
35387
|
});
|
|
35296
|
-
subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--version <semver>", "Explicit version (default: auto-increment patch)").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--dry-run", "Validate and preview deploy without writing changes").option("--preview", "Alias for --dry-run").option("--force", "Skip confirmation prompt for reindex operations").action(async (file, options2) => {
|
|
35388
|
+
subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--version <semver>", "Explicit version (default: auto-increment patch)").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--dry-run", "Validate and preview deploy without writing changes").option("--preview", "Alias for --dry-run").option("--force", "Skip confirmation prompt for reindex operations").option("--strict", "Run `tsc --noEmit` against the handler before deploy (slower; catches TS type errors)").action(async (file, options2) => {
|
|
35297
35389
|
try {
|
|
35298
35390
|
const absPath = resolve2(file);
|
|
35299
35391
|
const config = await loadConfig();
|
|
@@ -35305,8 +35397,12 @@ Stopped watching.`);
|
|
|
35305
35397
|
if (startBlock !== undefined) {
|
|
35306
35398
|
warn(`--start-block ${startBlock} overrides the definition's startBlock for this deploy.`);
|
|
35307
35399
|
}
|
|
35400
|
+
if (options2.strict) {
|
|
35401
|
+
info("Type-checking handler (tsc --noEmit)...");
|
|
35402
|
+
await typecheckHandler(absPath);
|
|
35403
|
+
}
|
|
35308
35404
|
info(`Loading subgraph from ${absPath}`);
|
|
35309
|
-
const mod = await
|
|
35405
|
+
const mod = await loadSubgraphWithDepCheck(absPath);
|
|
35310
35406
|
const def = mod.default ?? mod;
|
|
35311
35407
|
const effectiveDef = startBlock === undefined ? def : { ...def, startBlock };
|
|
35312
35408
|
const { validateSubgraphDefinition } = await import("@secondlayer/subgraphs/validate");
|
|
@@ -35341,10 +35437,23 @@ Stopped watching.`);
|
|
|
35341
35437
|
sourceCode: source,
|
|
35342
35438
|
...startBlock !== undefined ? { startBlock } : {}
|
|
35343
35439
|
});
|
|
35440
|
+
const printDeployFooter = async () => {
|
|
35441
|
+
try {
|
|
35442
|
+
const { apiUrl } = await resolveActiveTenant();
|
|
35443
|
+
const baseUrl = deriveBaseUrl(apiUrl);
|
|
35444
|
+
const firstTable = Object.keys(effectiveDef.schema ?? {})[0];
|
|
35445
|
+
info(` Dashboard: ${baseUrl}/platform/subgraphs/${effectiveDef.name}`);
|
|
35446
|
+
if (firstTable) {
|
|
35447
|
+
info(` REST: ${apiUrl}/api/subgraphs/${effectiveDef.name}/${firstTable}`);
|
|
35448
|
+
}
|
|
35449
|
+
info(` Watch: sl subgraphs status ${effectiveDef.name}`);
|
|
35450
|
+
} catch {}
|
|
35451
|
+
};
|
|
35344
35452
|
if (result.action === "unchanged") {
|
|
35345
35453
|
info(`Subgraph "${effectiveDef.name}" is up to date (v${result.version} — no changes)`);
|
|
35346
35454
|
} else if (result.action === "created") {
|
|
35347
35455
|
success(`Subgraph "${effectiveDef.name}" created → v${result.version}`);
|
|
35456
|
+
await printDeployFooter();
|
|
35348
35457
|
} else if (result.action === "reindexed") {
|
|
35349
35458
|
if (result.diff) {
|
|
35350
35459
|
const { addedTables, addedColumns, breakingChanges } = result.diff;
|
|
@@ -35367,6 +35476,7 @@ Stopped watching.`);
|
|
|
35367
35476
|
process.exit(0);
|
|
35368
35477
|
}
|
|
35369
35478
|
success(`Subgraph "${effectiveDef.name}" updated → v${result.version} (reindexing)`);
|
|
35479
|
+
await printDeployFooter();
|
|
35370
35480
|
} else {
|
|
35371
35481
|
if (result.diff) {
|
|
35372
35482
|
const { addedTables, addedColumns } = result.diff;
|
|
@@ -35377,6 +35487,7 @@ Stopped watching.`);
|
|
|
35377
35487
|
}
|
|
35378
35488
|
}
|
|
35379
35489
|
success(`Subgraph "${effectiveDef.name}" updated → v${result.version}`);
|
|
35490
|
+
await printDeployFooter();
|
|
35380
35491
|
}
|
|
35381
35492
|
} else {
|
|
35382
35493
|
if (dryRun) {
|
|
@@ -35441,8 +35552,8 @@ ${data.length} subgraph(s) total`));
|
|
|
35441
35552
|
handleApiError(err, "list subgraphs");
|
|
35442
35553
|
}
|
|
35443
35554
|
});
|
|
35444
|
-
subgraphs.command("status <name>").description("Show detailed subgraph status").action(async (name) => {
|
|
35445
|
-
|
|
35555
|
+
subgraphs.command("status <name>").description("Show detailed subgraph status").option("-w, --watch", "Refresh every 2s until synced or Ctrl-C").action(async (name, options2) => {
|
|
35556
|
+
const renderOnce = async () => {
|
|
35446
35557
|
const subgraph = await getSubgraphApi(name);
|
|
35447
35558
|
const rowCounts = Object.entries(subgraph.tables).map(([t, info2]) => `${t}: ${info2.rowCount}`).join(", ") || "N/A";
|
|
35448
35559
|
const totalRows = Object.values(subgraph.tables).reduce((sum, info2) => sum + info2.rowCount, 0);
|
|
@@ -35485,6 +35596,23 @@ Table endpoints:`));
|
|
|
35485
35596
|
console.log(dim(` ${info2.endpoint}`));
|
|
35486
35597
|
}
|
|
35487
35598
|
}
|
|
35599
|
+
return subgraph;
|
|
35600
|
+
};
|
|
35601
|
+
try {
|
|
35602
|
+
if (!options2.watch) {
|
|
35603
|
+
await renderOnce();
|
|
35604
|
+
return;
|
|
35605
|
+
}
|
|
35606
|
+
while (true) {
|
|
35607
|
+
process.stdout.write("\x1Bc");
|
|
35608
|
+
const sg = await renderOnce();
|
|
35609
|
+
if (sg && sg.status === "synced") {
|
|
35610
|
+
console.log(dim(`
|
|
35611
|
+
Synced — exiting watch.`));
|
|
35612
|
+
return;
|
|
35613
|
+
}
|
|
35614
|
+
await new Promise((res) => setTimeout(res, 2000));
|
|
35615
|
+
}
|
|
35488
35616
|
} catch (err) {
|
|
35489
35617
|
handleApiError(err, "get subgraph status");
|
|
35490
35618
|
}
|
|
@@ -35674,9 +35802,19 @@ ${rows.length} row(s)`));
|
|
|
35674
35802
|
try {
|
|
35675
35803
|
if (!options2.yes && !options2.force) {
|
|
35676
35804
|
const { confirm: confirm4 } = await import("@inquirer/prompts");
|
|
35677
|
-
|
|
35678
|
-
|
|
35679
|
-
|
|
35805
|
+
let ok = false;
|
|
35806
|
+
try {
|
|
35807
|
+
ok = await confirm4({
|
|
35808
|
+
message: `Delete subgraph "${name}" and all its data? This cannot be undone.`
|
|
35809
|
+
});
|
|
35810
|
+
} catch (promptErr) {
|
|
35811
|
+
const m = promptErr instanceof Error ? promptErr.message : String(promptErr);
|
|
35812
|
+
if (m.includes("ExitPromptError") || m.includes("force closed")) {
|
|
35813
|
+
error("Interactive prompt unavailable. Re-run with -y to skip confirmation.");
|
|
35814
|
+
process.exit(1);
|
|
35815
|
+
}
|
|
35816
|
+
throw promptErr;
|
|
35817
|
+
}
|
|
35680
35818
|
if (!ok) {
|
|
35681
35819
|
info("Cancelled");
|
|
35682
35820
|
return;
|
|
@@ -36815,395 +36953,14 @@ function registerLogoutCommand(program2) {
|
|
|
36815
36953
|
success("Logged out.");
|
|
36816
36954
|
});
|
|
36817
36955
|
}
|
|
36818
|
-
// src/commands/instance.ts
|
|
36819
|
-
init_config();
|
|
36820
|
-
import { confirm as confirm5, input as input4, select as select4 } from "@inquirer/prompts";
|
|
36821
|
-
init_output();
|
|
36822
|
-
init_resolve_tenant();
|
|
36823
|
-
var INSTANCE_CREATE_TIMEOUT_MS = 180000;
|
|
36824
|
-
function registerInstanceCommand(program2) {
|
|
36825
|
-
const instance = program2.command("instance", { hidden: true }).description("Manage your dedicated Secondlayer instance");
|
|
36826
|
-
instance.command("create").description("Provision a new dedicated instance for the active project").option("--plan <plan>", "Plan: launch | scale", "launch").action(async (opts) => {
|
|
36827
|
-
guardOssMode();
|
|
36828
|
-
const activeSlug = await requireActiveProject();
|
|
36829
|
-
const plan = opts.plan;
|
|
36830
|
-
if (!["launch", "scale"].includes(plan)) {
|
|
36831
|
-
error(`Invalid plan: ${plan} (expected launch or scale)`);
|
|
36832
|
-
process.exit(1);
|
|
36833
|
-
}
|
|
36834
|
-
const spinner = createSpinner("Provisioning your instance (~60s; safe to interrupt — instance will still be created; check `sl instance info`)");
|
|
36835
|
-
try {
|
|
36836
|
-
const res = await httpPlatform(`/api/projects/${encodeURIComponent(activeSlug)}/instance`, {
|
|
36837
|
-
method: "POST",
|
|
36838
|
-
body: { plan },
|
|
36839
|
-
timeoutMs: INSTANCE_CREATE_TIMEOUT_MS
|
|
36840
|
-
});
|
|
36841
|
-
spinner.succeed(`Instance provisioned: ${res.tenant.slug}`);
|
|
36842
|
-
printKeyReveal(res.tenant, res.credentials);
|
|
36843
|
-
} catch (err) {
|
|
36844
|
-
if (isTimeoutError(err)) {
|
|
36845
|
-
spinner.fail("Provision request timed out after 3 minutes.");
|
|
36846
|
-
error("Provisioning may still finish server-side. Run `sl instance info` to check before retrying.");
|
|
36847
|
-
process.exit(1);
|
|
36848
|
-
}
|
|
36849
|
-
if (err instanceof CliHttpError && err.code === "SUBSCRIPTION_REQUIRED") {
|
|
36850
|
-
spinner.fail("Trial required before provisioning.");
|
|
36851
|
-
await printTrialCheckoutUrl(plan);
|
|
36852
|
-
process.exit(1);
|
|
36853
|
-
}
|
|
36854
|
-
spinner.fail("Provision failed.");
|
|
36855
|
-
handleInstanceError(err, "provision instance");
|
|
36856
|
-
}
|
|
36857
|
-
});
|
|
36858
|
-
instance.command("info").description("Show the active project's instance").action(async () => {
|
|
36859
|
-
guardOssMode();
|
|
36860
|
-
await renderInstanceInfo();
|
|
36861
|
-
});
|
|
36862
|
-
instance.command("resize").description("Change your instance plan (brief downtime)").option("--plan <plan>", "Target plan: launch | scale").option("--yes", "Skip confirm").action(async (opts) => {
|
|
36863
|
-
guardOssMode();
|
|
36864
|
-
let target = opts.plan;
|
|
36865
|
-
if (!target) {
|
|
36866
|
-
const answer = await select4({
|
|
36867
|
-
message: "Target plan",
|
|
36868
|
-
choices: [
|
|
36869
|
-
{
|
|
36870
|
-
value: "launch",
|
|
36871
|
-
name: "Launch — $99/mo (2 vCPU · 6 GB · 100 GB)"
|
|
36872
|
-
},
|
|
36873
|
-
{
|
|
36874
|
-
value: "scale",
|
|
36875
|
-
name: "Scale — $299/mo (8 vCPU · 24 GB · 500 GB)"
|
|
36876
|
-
}
|
|
36877
|
-
]
|
|
36878
|
-
});
|
|
36879
|
-
target = answer;
|
|
36880
|
-
}
|
|
36881
|
-
if (!["launch", "scale"].includes(target)) {
|
|
36882
|
-
error(`Invalid plan: ${target} (expected launch or scale)`);
|
|
36883
|
-
process.exit(1);
|
|
36884
|
-
}
|
|
36885
|
-
if (!opts.yes) {
|
|
36886
|
-
const ok = await confirm5({
|
|
36887
|
-
message: `Resize to ${target}? ~30s downtime while containers recreate. Data preserved.`,
|
|
36888
|
-
default: false
|
|
36889
|
-
});
|
|
36890
|
-
if (!ok) {
|
|
36891
|
-
info("Cancelled.");
|
|
36892
|
-
return;
|
|
36893
|
-
}
|
|
36894
|
-
}
|
|
36895
|
-
try {
|
|
36896
|
-
await httpPlatform("/api/tenants/me/resize", {
|
|
36897
|
-
method: "POST",
|
|
36898
|
-
body: { plan: target }
|
|
36899
|
-
});
|
|
36900
|
-
success(`Resized to ${target}.`);
|
|
36901
|
-
} catch (err) {
|
|
36902
|
-
handleInstanceError(err, "resize");
|
|
36903
|
-
}
|
|
36904
|
-
});
|
|
36905
|
-
instance.command("suspend").description("Stop your instance (data preserved)").action(async () => {
|
|
36906
|
-
guardOssMode();
|
|
36907
|
-
try {
|
|
36908
|
-
await httpPlatform("/api/tenants/me/suspend", { method: "POST" });
|
|
36909
|
-
success("Instance suspended.");
|
|
36910
|
-
} catch (err) {
|
|
36911
|
-
handleInstanceError(err, "suspend");
|
|
36912
|
-
}
|
|
36913
|
-
});
|
|
36914
|
-
instance.command("resume").description("Start a suspended instance").action(async () => {
|
|
36915
|
-
guardOssMode();
|
|
36916
|
-
try {
|
|
36917
|
-
await httpPlatform("/api/tenants/me/resume", { method: "POST" });
|
|
36918
|
-
success("Instance resumed.");
|
|
36919
|
-
} catch (err) {
|
|
36920
|
-
handleInstanceError(err, "resume");
|
|
36921
|
-
}
|
|
36922
|
-
});
|
|
36923
|
-
instance.command("delete").description("Permanently delete your instance + all data").option("--yes", "Skip typed-slug confirm").action(async (opts) => {
|
|
36924
|
-
guardOssMode();
|
|
36925
|
-
const tenant = await fetchCurrentTenant();
|
|
36926
|
-
if (!tenant) {
|
|
36927
|
-
warn("No instance to delete.");
|
|
36928
|
-
return;
|
|
36929
|
-
}
|
|
36930
|
-
const slug = tenant.slug;
|
|
36931
|
-
if (!opts.yes) {
|
|
36932
|
-
if (!process.stdin.isTTY) {
|
|
36933
|
-
error(`Refusing to prompt in a non-interactive terminal. Re-run with --yes to delete instance "${slug}".`);
|
|
36934
|
-
process.exit(1);
|
|
36935
|
-
}
|
|
36936
|
-
const typed = await input4({
|
|
36937
|
-
message: `Type the slug "${slug}" to confirm permanent deletion`,
|
|
36938
|
-
validate: (v) => v === slug ? true : "Slug must match exactly"
|
|
36939
|
-
});
|
|
36940
|
-
if (typed !== slug)
|
|
36941
|
-
return;
|
|
36942
|
-
}
|
|
36943
|
-
try {
|
|
36944
|
-
await httpPlatform("/api/tenants/me", { method: "DELETE" });
|
|
36945
|
-
success("Instance deleted.");
|
|
36946
|
-
} catch (err) {
|
|
36947
|
-
const afterDelete = await fetchCurrentTenant().catch(() => {
|
|
36948
|
-
return;
|
|
36949
|
-
});
|
|
36950
|
-
if (afterDelete === null) {
|
|
36951
|
-
success("Instance deleted.");
|
|
36952
|
-
return;
|
|
36953
|
-
}
|
|
36954
|
-
handleInstanceError(err, "delete");
|
|
36955
|
-
}
|
|
36956
|
-
});
|
|
36957
|
-
const keys = instance.command("keys").description("Rotate long-lived keys (service, anon)");
|
|
36958
|
-
keys.command("rotate").description("Rotate one or both keys").option("--service", "Rotate the service key").option("--anon", "Rotate the anon key").option("--both", "Rotate both keys (nuclear)").action(async (opts) => {
|
|
36959
|
-
guardOssMode();
|
|
36960
|
-
let type;
|
|
36961
|
-
if (opts.both || opts.service && opts.anon)
|
|
36962
|
-
type = "both";
|
|
36963
|
-
else if (opts.service)
|
|
36964
|
-
type = "service";
|
|
36965
|
-
else if (opts.anon)
|
|
36966
|
-
type = "anon";
|
|
36967
|
-
else {
|
|
36968
|
-
const answer = await select4({
|
|
36969
|
-
message: "Which key(s) to rotate?",
|
|
36970
|
-
choices: [
|
|
36971
|
-
{
|
|
36972
|
-
value: "service",
|
|
36973
|
-
name: "Service key (full access, server-side)"
|
|
36974
|
-
},
|
|
36975
|
-
{ value: "anon", name: "Anon key (read-only, client-safe)" },
|
|
36976
|
-
{
|
|
36977
|
-
value: "both",
|
|
36978
|
-
name: "Both (nuclear — offboarding/leak response)"
|
|
36979
|
-
}
|
|
36980
|
-
]
|
|
36981
|
-
});
|
|
36982
|
-
type = answer;
|
|
36983
|
-
}
|
|
36984
|
-
try {
|
|
36985
|
-
const res = await httpPlatform("/api/tenants/me/keys/rotate", {
|
|
36986
|
-
method: "POST",
|
|
36987
|
-
body: { type }
|
|
36988
|
-
});
|
|
36989
|
-
success(`${type === "both" ? "Keys" : `${type} key`} rotated.`);
|
|
36990
|
-
const rows = [];
|
|
36991
|
-
if (res.rotated.serviceKey)
|
|
36992
|
-
rows.push(["New service key", res.rotated.serviceKey]);
|
|
36993
|
-
if (res.rotated.anonKey)
|
|
36994
|
-
rows.push(["New anon key", res.rotated.anonKey]);
|
|
36995
|
-
console.log("");
|
|
36996
|
-
console.log(warn_box("⚠ Shown once. Save these now — we can't retrieve them later."));
|
|
36997
|
-
console.log("");
|
|
36998
|
-
console.log(formatKeyValue(rows));
|
|
36999
|
-
console.log("");
|
|
37000
|
-
} catch (err) {
|
|
37001
|
-
handleInstanceError(err, "rotate keys");
|
|
37002
|
-
}
|
|
37003
|
-
});
|
|
37004
|
-
const db = instance.command("db").description("Get a DATABASE_URL for direct Postgres access (via SSH tunnel)");
|
|
37005
|
-
db.command("info", { isDefault: true }).description("Print SSH tunnel command + DATABASE_URL for the instance").action(async () => {
|
|
37006
|
-
guardOssMode();
|
|
37007
|
-
try {
|
|
37008
|
-
const res = await httpPlatform("/api/tenants/me/db-access");
|
|
37009
|
-
console.log("");
|
|
37010
|
-
console.log(dim("1. Upload your public key (one time):"));
|
|
37011
|
-
console.log(dim(" sl instance db add-key ~/.ssh/id_ed25519.pub"));
|
|
37012
|
-
console.log("");
|
|
37013
|
-
console.log(dim("2. Open the SSH tunnel in a separate terminal:"));
|
|
37014
|
-
console.log(green(` ${res.sshCommand}`));
|
|
37015
|
-
console.log("");
|
|
37016
|
-
console.log(dim("3. Use this DATABASE_URL while the tunnel is open:"));
|
|
37017
|
-
console.log(green(` ${res.databaseUrl}`));
|
|
37018
|
-
console.log("");
|
|
37019
|
-
} catch (err) {
|
|
37020
|
-
handleInstanceError(err, "fetch db access info");
|
|
37021
|
-
}
|
|
37022
|
-
});
|
|
37023
|
-
db.command("add-key <path>").description("Upload an SSH public key to the bastion for this instance").action(async (path2) => {
|
|
37024
|
-
guardOssMode();
|
|
37025
|
-
let publicKey;
|
|
37026
|
-
try {
|
|
37027
|
-
publicKey = (await Bun.file(path2).text()).trim();
|
|
37028
|
-
} catch (err) {
|
|
37029
|
-
error(`Could not read ${path2}: ${err instanceof Error ? err.message : String(err)}`);
|
|
37030
|
-
process.exit(1);
|
|
37031
|
-
}
|
|
37032
|
-
if (!publicKey) {
|
|
37033
|
-
error(`${path2} is empty`);
|
|
37034
|
-
process.exit(1);
|
|
37035
|
-
}
|
|
37036
|
-
try {
|
|
37037
|
-
await httpPlatform("/api/tenants/me/db-access/key", { method: "POST", body: { publicKey } });
|
|
37038
|
-
success("Bastion key installed. You can now open the SSH tunnel.");
|
|
37039
|
-
} catch (err) {
|
|
37040
|
-
handleInstanceError(err, "upload bastion key");
|
|
37041
|
-
}
|
|
37042
|
-
});
|
|
37043
|
-
db.command("revoke-key").description("Revoke bastion access for this instance").option("-y, --yes", "Skip confirmation").action(async (opts) => {
|
|
37044
|
-
guardOssMode();
|
|
37045
|
-
if (!opts.yes) {
|
|
37046
|
-
const ok = await confirm5({
|
|
37047
|
-
message: "Revoke bastion access for this instance?",
|
|
37048
|
-
default: false
|
|
37049
|
-
});
|
|
37050
|
-
if (!ok)
|
|
37051
|
-
return;
|
|
37052
|
-
}
|
|
37053
|
-
try {
|
|
37054
|
-
await httpPlatform("/api/tenants/me/db-access/key", { method: "DELETE" });
|
|
37055
|
-
success("Bastion access revoked.");
|
|
37056
|
-
} catch (err) {
|
|
37057
|
-
handleInstanceError(err, "revoke bastion key");
|
|
37058
|
-
}
|
|
37059
|
-
});
|
|
37060
|
-
}
|
|
37061
|
-
async function printTrialCheckoutUrl(plan) {
|
|
37062
|
-
const res = await httpPlatform("/api/billing/upgrade", {
|
|
37063
|
-
method: "POST",
|
|
37064
|
-
body: { tier: plan }
|
|
37065
|
-
});
|
|
37066
|
-
if (!res.url) {
|
|
37067
|
-
error("No checkout URL returned. Open Billing in the dashboard.");
|
|
37068
|
-
return;
|
|
37069
|
-
}
|
|
37070
|
-
info("Start your 30-day trial, then rerun this command:");
|
|
37071
|
-
console.log(green(res.url));
|
|
37072
|
-
}
|
|
37073
|
-
function guardOssMode() {
|
|
37074
|
-
if (isOssMode()) {
|
|
37075
|
-
error("`sl instance` commands are for hosted deployments. For OSS use `sl local` / `sl stack` or your own provisioning.");
|
|
37076
|
-
process.exit(1);
|
|
37077
|
-
}
|
|
37078
|
-
}
|
|
37079
|
-
async function requireActiveProject() {
|
|
37080
|
-
const config = await loadConfig();
|
|
37081
|
-
const active = await readActiveProject(process.cwd(), config.defaultProject);
|
|
37082
|
-
if (!active) {
|
|
37083
|
-
error("No active project — run `sl project create <name>` or `sl project use <slug>` first.");
|
|
37084
|
-
process.exit(1);
|
|
37085
|
-
}
|
|
37086
|
-
return active.slug;
|
|
37087
|
-
}
|
|
37088
|
-
async function fetchCurrentTenant() {
|
|
37089
|
-
try {
|
|
37090
|
-
const res = await httpPlatform("/api/tenants/me");
|
|
37091
|
-
return res.tenant;
|
|
37092
|
-
} catch (err) {
|
|
37093
|
-
if (err instanceof CliHttpError && err.status === 404) {
|
|
37094
|
-
return null;
|
|
37095
|
-
}
|
|
37096
|
-
throw err;
|
|
37097
|
-
}
|
|
37098
|
-
}
|
|
37099
|
-
async function renderInstanceInfo() {
|
|
37100
|
-
try {
|
|
37101
|
-
const tenant = await fetchCurrentTenant();
|
|
37102
|
-
if (!tenant) {
|
|
37103
|
-
info("No instance for the active project. Run `sl instance create --plan launch`.");
|
|
37104
|
-
return;
|
|
37105
|
-
}
|
|
37106
|
-
console.log(formatKeyValue([
|
|
37107
|
-
["URL", tenant.apiUrl],
|
|
37108
|
-
["Plan", tenant.plan],
|
|
37109
|
-
["Status", tenant.status],
|
|
37110
|
-
["Created", new Date(tenant.createdAt).toLocaleString()]
|
|
37111
|
-
]));
|
|
37112
|
-
} catch (err) {
|
|
37113
|
-
handleInstanceError(err, "fetch instance");
|
|
37114
|
-
}
|
|
37115
|
-
}
|
|
37116
|
-
function printKeyReveal(tenant, creds) {
|
|
37117
|
-
console.log("");
|
|
37118
|
-
console.log(blue("━".repeat(60)));
|
|
37119
|
-
console.log(blue(" Save your keys — shown once. Can't retrieve later."));
|
|
37120
|
-
console.log(blue("━".repeat(60)));
|
|
37121
|
-
console.log("");
|
|
37122
|
-
console.log(formatKeyValue([
|
|
37123
|
-
["URL", creds.apiUrl],
|
|
37124
|
-
["Plan", tenant.plan],
|
|
37125
|
-
["Service key", green(creds.serviceKey)],
|
|
37126
|
-
["Anon key", green(creds.anonKey)]
|
|
37127
|
-
]));
|
|
37128
|
-
console.log("");
|
|
37129
|
-
console.log(dim("Run `sl subgraphs deploy <file>` to deploy your first subgraph."));
|
|
37130
|
-
console.log("");
|
|
37131
|
-
}
|
|
37132
|
-
function createSpinner(message) {
|
|
37133
|
-
if (!process.stderr.isTTY) {
|
|
37134
|
-
info(message);
|
|
37135
|
-
return {
|
|
37136
|
-
succeed: success,
|
|
37137
|
-
fail: error
|
|
37138
|
-
};
|
|
37139
|
-
}
|
|
37140
|
-
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
37141
|
-
let index = 0;
|
|
37142
|
-
const render = () => {
|
|
37143
|
-
const frame = frames[index % frames.length] ?? frames[0];
|
|
37144
|
-
index += 1;
|
|
37145
|
-
process.stderr.write(`\r${blue(frame)} ${message}`);
|
|
37146
|
-
};
|
|
37147
|
-
const clear = () => {
|
|
37148
|
-
clearInterval(timer3);
|
|
37149
|
-
process.stderr.write("\r\x1B[2K");
|
|
37150
|
-
};
|
|
37151
|
-
const timer3 = setInterval(render, 80);
|
|
37152
|
-
render();
|
|
37153
|
-
return {
|
|
37154
|
-
succeed(message2) {
|
|
37155
|
-
clear();
|
|
37156
|
-
success(message2);
|
|
37157
|
-
},
|
|
37158
|
-
fail(message2) {
|
|
37159
|
-
clear();
|
|
37160
|
-
error(message2);
|
|
37161
|
-
}
|
|
37162
|
-
};
|
|
37163
|
-
}
|
|
37164
|
-
function isTimeoutError(err) {
|
|
37165
|
-
if (!(err instanceof Error))
|
|
37166
|
-
return false;
|
|
37167
|
-
return err.name === "TimeoutError" || err.name === "AbortError" || err.message.toLowerCase().includes("timeout");
|
|
37168
|
-
}
|
|
37169
|
-
function warn_box(message) {
|
|
37170
|
-
return `${"━".repeat(message.length + 4)}
|
|
37171
|
-
${message}
|
|
37172
|
-
${"━".repeat(message.length + 4)}`;
|
|
37173
|
-
}
|
|
37174
|
-
function handleInstanceError(err, action) {
|
|
37175
|
-
if (err instanceof CliHttpError) {
|
|
37176
|
-
if (err.code === "SESSION_EXPIRED") {
|
|
37177
|
-
error("Session expired. Run: sl login");
|
|
37178
|
-
process.exit(1);
|
|
37179
|
-
}
|
|
37180
|
-
if (err.code === "TENANT_SUSPENDED") {
|
|
37181
|
-
error("Instance is suspended. Run: sl instance resume");
|
|
37182
|
-
process.exit(1);
|
|
37183
|
-
}
|
|
37184
|
-
if (err.code === "INSTANCE_EXISTS") {
|
|
37185
|
-
error("This project already has an instance. Run `sl instance info` to see it.");
|
|
37186
|
-
process.exit(1);
|
|
37187
|
-
}
|
|
37188
|
-
if (err.code === "PROVISIONER_REJECTED" || err.code === "INSTANCE_RECORD_FAILED" || err.code === "INSTANCE_PROVISION_FAILED") {
|
|
37189
|
-
error(err.message || `Failed to ${action}.`);
|
|
37190
|
-
error("Run: sl instance info before retrying.");
|
|
37191
|
-
process.exit(1);
|
|
37192
|
-
}
|
|
37193
|
-
error(err.message || `Failed to ${action}.`);
|
|
37194
|
-
process.exit(1);
|
|
37195
|
-
}
|
|
37196
|
-
error(`Failed to ${action}: ${err instanceof Error ? err.message || "Unknown error" : String(err)}`);
|
|
37197
|
-
process.exit(1);
|
|
37198
|
-
}
|
|
37199
36956
|
// src/commands/project.ts
|
|
37200
36957
|
init_config();
|
|
37201
|
-
import { input as
|
|
36958
|
+
import { input as input4 } from "@inquirer/prompts";
|
|
37202
36959
|
init_output();
|
|
37203
36960
|
function registerProjectCommand(program2) {
|
|
37204
36961
|
const project = program2.command("project").description("Manage Secondlayer projects");
|
|
37205
36962
|
project.command("create [name]").description("Create a new project").option("--slug <slug>", "Project URL identifier").action(async (nameArg, options2 = {}) => {
|
|
37206
|
-
const name = nameArg ?? await
|
|
36963
|
+
const name = nameArg ?? await input4({
|
|
37207
36964
|
message: "Project name",
|
|
37208
36965
|
validate: (v) => v.length >= 2 ? true : "Name must be at least 2 characters"
|
|
37209
36966
|
});
|
|
@@ -37325,7 +37082,6 @@ registerLoginCommand(program);
|
|
|
37325
37082
|
registerLogoutCommand(program);
|
|
37326
37083
|
registerWhoamiCommand(program);
|
|
37327
37084
|
registerProjectCommand(program);
|
|
37328
|
-
registerInstanceCommand(program);
|
|
37329
37085
|
registerSubgraphsCommand(program);
|
|
37330
37086
|
registerCreateCommand(program);
|
|
37331
37087
|
registerSubscriptionsCommand(program);
|
|
@@ -37340,5 +37096,5 @@ registerAccountCommand(program);
|
|
|
37340
37096
|
registerBillingCommand(program);
|
|
37341
37097
|
program.parse();
|
|
37342
37098
|
|
|
37343
|
-
//# debugId=
|
|
37099
|
+
//# debugId=7D07B6242D81B6A564756E2164756E21
|
|
37344
37100
|
//# sourceMappingURL=cli.js.map
|