@abloatai/cli 0.59.2 → 0.60.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.
Files changed (2) hide show
  1. package/dist/cli.cjs +102 -143
  2. package/package.json +3 -3
package/dist/cli.cjs CHANGED
@@ -1443,6 +1443,7 @@ var init_bytes = __esm({
1443
1443
  // ../../node_modules/postgres/src/connection.js
1444
1444
  function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose = noop } = {}) {
1445
1445
  const {
1446
+ sslnegotiation,
1446
1447
  ssl,
1447
1448
  max,
1448
1449
  user,
@@ -1460,7 +1461,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1460
1461
  target_session_attrs
1461
1462
  } = options;
1462
1463
  const sent = queue_default(), id = uid++, backend = { pid: null, secret: null }, idleTimer = timer(end, options.idle_timeout), lifeTimer = timer(end, options.max_lifetime), connectTimer = timer(connectTimedOut, options.connect_timeout);
1463
- let socket = null, cancelMessage, result = new Result(), incoming = Buffer.alloc(0), needsTypes = options.fetch_types, backendParameters = {}, statements = {}, statementId = Math.random().toString(36).slice(2), statementCount = 1, closedDate = 0, remaining = 0, hostIndex = 0, retries = 0, length = 0, delay = 0, rows = 0, serverSignature = null, nextWriteTimer = null, terminated = false, incomings = null, results = null, initial = null, ending = null, stream = null, chunk = null, ended = null, nonce = null, query = null, final = null;
1464
+ let socket = null, cancelMessage, errorResponse = null, result = new Result(), incoming = Buffer.alloc(0), needsTypes = options.fetch_types, backendParameters = {}, statements = {}, statementId = Math.random().toString(36).slice(2), statementCount = 1, closedTime = 0, remaining = 0, hostIndex = 0, retries = 0, length = 0, delay = 0, rows = 0, serverSignature = null, nextWriteTimer = null, terminated = false, incomings = null, results = null, initial = null, ending = null, stream = null, chunk = null, ended = null, nonce = null, query = null, final = null;
1464
1465
  const connection2 = {
1465
1466
  queue: queues.closed,
1466
1467
  idleTimer,
@@ -1503,6 +1504,8 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1503
1504
  function execute(q2) {
1504
1505
  if (terminated)
1505
1506
  return queryError(q2, Errors.connection("CONNECTION_DESTROYED", options));
1507
+ if (stream)
1508
+ return queryError(q2, Errors.generic("COPY_IN_PROGRESS", "You cannot execute queries during copy"));
1506
1509
  if (q2.cancelled)
1507
1510
  return;
1508
1511
  try {
@@ -1572,16 +1575,24 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1572
1575
  socket.destroy();
1573
1576
  }
1574
1577
  async function secure() {
1575
- write(SSLRequest);
1576
- const canSSL = await new Promise((r2) => socket.once("data", (x2) => r2(x2[0] === 83)));
1577
- if (!canSSL && ssl === "prefer")
1578
- return connected();
1579
- socket.removeAllListeners();
1580
- socket = import_tls.default.connect({
1578
+ if (sslnegotiation !== "direct") {
1579
+ write(SSLRequest);
1580
+ const canSSL = await new Promise((r2) => socket.once("data", (x2) => r2(x2[0] === 83)));
1581
+ if (!canSSL && ssl === "prefer")
1582
+ return connected();
1583
+ }
1584
+ const options2 = {
1581
1585
  socket,
1582
- servername: import_net.default.isIP(socket.host) ? void 0 : socket.host,
1583
- ...ssl === "require" || ssl === "allow" || ssl === "prefer" ? { rejectUnauthorized: false } : ssl === "verify-full" ? {} : typeof ssl === "object" ? ssl : {}
1584
- });
1586
+ servername: import_net.default.isIP(socket.host) ? void 0 : socket.host
1587
+ };
1588
+ if (sslnegotiation === "direct")
1589
+ options2.ALPNProtocols = ["postgresql"];
1590
+ if (ssl === "require" || ssl === "allow" || ssl === "prefer")
1591
+ options2.rejectUnauthorized = false;
1592
+ else if (typeof ssl === "object")
1593
+ Object.assign(options2, ssl);
1594
+ socket.removeAllListeners();
1595
+ socket = import_tls.default.connect(options2);
1585
1596
  socket.on("secureConnect", connected);
1586
1597
  socket.on("error", error);
1587
1598
  socket.on("close", closed);
@@ -1635,7 +1646,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1635
1646
  hostIndex = (hostIndex + 1) % port.length;
1636
1647
  }
1637
1648
  function reconnect() {
1638
- setTimeout(connect2, closedDate ? closedDate + delay - import_perf_hooks.performance.now() : 0);
1649
+ setTimeout(connect2, closedTime ? Math.max(0, closedTime + delay - import_perf_hooks.performance.now()) : 0);
1639
1650
  }
1640
1651
  function connected() {
1641
1652
  try {
@@ -1708,7 +1719,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1708
1719
  if (initial)
1709
1720
  return reconnect();
1710
1721
  !hadError && (query || sent.length) && error(Errors.connection("CONNECTION_CLOSED", options, socket));
1711
- closedDate = import_perf_hooks.performance.now();
1722
+ closedTime = import_perf_hooks.performance.now();
1712
1723
  hadError && options.shared.retries++;
1713
1724
  delay = (typeof backoff2 === "function" ? backoff2(options.shared.retries) : backoff2) * 1e3;
1714
1725
  onclose(connection2, Errors.connection("CONNECTION_CLOSED", options, socket));
@@ -1813,8 +1824,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1813
1824
  }
1814
1825
  }
1815
1826
  function ReadyForQuery(x2) {
1816
- query && query.options.simple && query.resolve(results || result);
1817
- query = results = null;
1827
+ if (query) {
1828
+ if (errorResponse) {
1829
+ query.retried ? errored(query.retried) : query.prepared && retryRoutines.has(errorResponse.routine) ? retry(query, errorResponse) : errored(errorResponse);
1830
+ } else {
1831
+ query.resolve(results || result);
1832
+ }
1833
+ } else if (errorResponse) {
1834
+ errored(errorResponse);
1835
+ }
1836
+ query = results = errorResponse = null;
1818
1837
  result = new Result();
1819
1838
  connectTimer.cancel();
1820
1839
  if (initial) {
@@ -1859,7 +1878,6 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
1859
1878
  result.count && query.cursorFn(result);
1860
1879
  write(Sync);
1861
1880
  }
1862
- query.resolve(result);
1863
1881
  }
1864
1882
  function ParseComplete() {
1865
1883
  query.parsing = false;
@@ -2007,9 +2025,12 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
2007
2025
  query2.execute();
2008
2026
  }
2009
2027
  function ErrorResponse(x2) {
2010
- query && (query.cursorFn || query.describeFirst) && write(Sync);
2011
- const error2 = Errors.postgres(parseError(x2));
2012
- query && query.retried ? errored(query.retried) : query && query.prepared && retryRoutines.has(error2.routine) ? retry(query, error2) : errored(error2);
2028
+ if (query) {
2029
+ (query.cursorFn || query.describeFirst) && write(Sync);
2030
+ errorResponse = Errors.postgres(parseError(x2));
2031
+ } else {
2032
+ errored(Errors.postgres(parseError(x2)));
2033
+ }
2013
2034
  }
2014
2035
  function retry(q2, error2) {
2015
2036
  delete statements[q2.signature];
@@ -2054,6 +2075,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
2054
2075
  final(callback) {
2055
2076
  socket.write(bytes_default().c().end());
2056
2077
  final = callback;
2078
+ stream = null;
2057
2079
  }
2058
2080
  });
2059
2081
  query.resolve(stream);
@@ -2846,8 +2868,9 @@ function parseOptions(a, b4) {
2846
2868
  query.sslrootcert === "system" && (query.ssl = "verify-full");
2847
2869
  const ints = ["idle_timeout", "connect_timeout", "max_lifetime", "max_pipeline", "backoff", "keep_alive"];
2848
2870
  const defaults = {
2849
- max: 10,
2871
+ max: globalThis.Cloudflare ? 3 : 10,
2850
2872
  ssl: false,
2873
+ sslnegotiation: null,
2851
2874
  idle_timeout: null,
2852
2875
  connect_timeout: 30,
2853
2876
  max_lifetime,
@@ -3953,7 +3976,7 @@ var init_observeCliError = __esm({
3953
3976
  import_errorObservation = require("@abloatai/transaction/errorObservation");
3954
3977
  import_errors5 = require("@abloatai/transaction/errors");
3955
3978
  dsn = process.env.ABLO_CLI_SENTRY_DSN ?? "https://1ac154bff10b06836e1ea9de9e0d92f0@o4510928209772544.ingest.de.sentry.io/4511660691423312" ?? "";
3956
- release = process.env.ABLO_CLI_RELEASE ?? "@abloatai/cli@0.59.2";
3979
+ release = process.env.ABLO_CLI_RELEASE ?? "@abloatai/cli@0.60.0";
3957
3980
  initialized = false;
3958
3981
  nativeProcessExit = process.exit.bind(process);
3959
3982
  exitBoundaryInstalled = false;
@@ -4288,7 +4311,7 @@ var init_src2 = __esm({
4288
4311
 
4289
4312
  // src/cliEnvironment.ts
4290
4313
  function cliVersion() {
4291
- return "0.59.2";
4314
+ return "0.60.0";
4292
4315
  }
4293
4316
  function cliOs() {
4294
4317
  const value = (0, import_node_os.platform)();
@@ -219892,9 +219915,9 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
219892
219915
  }
219893
219916
  });
219894
219917
 
219895
- // ../../node_modules/@ts-morph/common/node_modules/balanced-match/dist/commonjs/index.js
219918
+ // ../../node_modules/balanced-match/dist/commonjs/index.js
219896
219919
  var require_commonjs = __commonJS({
219897
- "../../node_modules/@ts-morph/common/node_modules/balanced-match/dist/commonjs/index.js"(exports2) {
219920
+ "../../node_modules/balanced-match/dist/commonjs/index.js"(exports2) {
219898
219921
  "use strict";
219899
219922
  init_cjs_shims();
219900
219923
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -219955,9 +219978,9 @@ var require_commonjs = __commonJS({
219955
219978
  }
219956
219979
  });
219957
219980
 
219958
- // ../../node_modules/@ts-morph/common/node_modules/brace-expansion/dist/commonjs/index.js
219981
+ // ../../node_modules/brace-expansion/dist/commonjs/index.js
219959
219982
  var require_commonjs2 = __commonJS({
219960
- "../../node_modules/@ts-morph/common/node_modules/brace-expansion/dist/commonjs/index.js"(exports2) {
219983
+ "../../node_modules/brace-expansion/dist/commonjs/index.js"(exports2) {
219961
219984
  "use strict";
219962
219985
  init_cjs_shims();
219963
219986
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -220051,7 +220074,7 @@ var require_commonjs2 = __commonJS({
220051
220074
  }
220052
220075
  return out;
220053
220076
  }
220054
- function expandSequence(body, isAlphaSequence, max, maxLength) {
220077
+ function expandSequence(body, isAlphaSequence, max) {
220055
220078
  const n = body.split(/\.\./);
220056
220079
  const N2 = [];
220057
220080
  if (n[0] === void 0 || n[1] === void 0) {
@@ -220068,7 +220091,6 @@ var require_commonjs2 = __commonJS({
220068
220091
  test = gte;
220069
220092
  }
220070
220093
  const pad2 = n.some(isPadded);
220071
- let length = 0;
220072
220094
  for (let i = x2; test(i, y3) && N2.length < max; i += incr) {
220073
220095
  let c;
220074
220096
  if (isAlphaSequence) {
@@ -220090,10 +220112,7 @@ var require_commonjs2 = __commonJS({
220090
220112
  }
220091
220113
  }
220092
220114
  }
220093
- if (length + c.length > maxLength)
220094
- break;
220095
220115
  N2.push(c);
220096
- length += c.length;
220097
220116
  }
220098
220117
  return N2;
220099
220118
  }
@@ -220133,7 +220152,7 @@ var require_commonjs2 = __commonJS({
220133
220152
  }
220134
220153
  let values2;
220135
220154
  if (isSequence) {
220136
- values2 = expandSequence(m2.body, isAlphaSequence, max, maxLength);
220155
+ values2 = expandSequence(m2.body, isAlphaSequence, max);
220137
220156
  } else {
220138
220157
  let n = parseCommaParts(m2.body);
220139
220158
  if (n.length === 1 && n[0] !== void 0) {
@@ -220146,26 +220165,9 @@ var require_commonjs2 = __commonJS({
220146
220165
  continue;
220147
220166
  }
220148
220167
  }
220149
- let dropsEmpties = dropEmpties && !m2.post.length && !pre;
220150
- for (let d3 = 0; dropsEmpties && d3 < acc.length; d3++) {
220151
- if (acc[d3]) {
220152
- dropsEmpties = false;
220153
- }
220154
- }
220155
220168
  values2 = [];
220156
- let valuesLength = 0;
220157
- outer: for (let j2 = 0; j2 < n.length; j2++) {
220158
- const expanded = expand_(n[j2], max, maxLength, false);
220159
- for (let k3 = 0; k3 < expanded.length; k3++) {
220160
- const v2 = expanded[k3];
220161
- if (dropsEmpties && !v2)
220162
- continue;
220163
- if (values2.length >= max || valuesLength + v2.length > maxLength) {
220164
- break outer;
220165
- }
220166
- values2.push(v2);
220167
- valuesLength += v2.length;
220168
- }
220169
+ for (let j2 = 0; j2 < n.length; j2++) {
220170
+ values2.push.apply(values2, expand_(n[j2], max, maxLength, false));
220169
220171
  }
220170
220172
  }
220171
220173
  acc = combine(acc, pre, values2, max, maxLength, dropEmpties && !m2.post.length);
@@ -220178,9 +220180,9 @@ var require_commonjs2 = __commonJS({
220178
220180
  }
220179
220181
  });
220180
220182
 
220181
- // ../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js
220183
+ // ../../node_modules/minimatch/dist/commonjs/assert-valid-pattern.js
220182
220184
  var require_assert_valid_pattern = __commonJS({
220183
- "../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js"(exports2) {
220185
+ "../../node_modules/minimatch/dist/commonjs/assert-valid-pattern.js"(exports2) {
220184
220186
  "use strict";
220185
220187
  init_cjs_shims();
220186
220188
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -220198,9 +220200,9 @@ var require_assert_valid_pattern = __commonJS({
220198
220200
  }
220199
220201
  });
220200
220202
 
220201
- // ../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/brace-expressions.js
220203
+ // ../../node_modules/minimatch/dist/commonjs/brace-expressions.js
220202
220204
  var require_brace_expressions = __commonJS({
220203
- "../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/brace-expressions.js"(exports2) {
220205
+ "../../node_modules/minimatch/dist/commonjs/brace-expressions.js"(exports2) {
220204
220206
  "use strict";
220205
220207
  init_cjs_shims();
220206
220208
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -220316,9 +220318,9 @@ var require_brace_expressions = __commonJS({
220316
220318
  }
220317
220319
  });
220318
220320
 
220319
- // ../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/unescape.js
220321
+ // ../../node_modules/minimatch/dist/commonjs/unescape.js
220320
220322
  var require_unescape = __commonJS({
220321
- "../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/unescape.js"(exports2) {
220323
+ "../../node_modules/minimatch/dist/commonjs/unescape.js"(exports2) {
220322
220324
  "use strict";
220323
220325
  init_cjs_shims();
220324
220326
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -220333,9 +220335,9 @@ var require_unescape = __commonJS({
220333
220335
  }
220334
220336
  });
220335
220337
 
220336
- // ../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/ast.js
220338
+ // ../../node_modules/minimatch/dist/commonjs/ast.js
220337
220339
  var require_ast = __commonJS({
220338
- "../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/ast.js"(exports2) {
220340
+ "../../node_modules/minimatch/dist/commonjs/ast.js"(exports2) {
220339
220341
  "use strict";
220340
220342
  init_cjs_shims();
220341
220343
  var _a;
@@ -220988,9 +220990,9 @@ var require_ast = __commonJS({
220988
220990
  }
220989
220991
  });
220990
220992
 
220991
- // ../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/escape.js
220993
+ // ../../node_modules/minimatch/dist/commonjs/escape.js
220992
220994
  var require_escape = __commonJS({
220993
- "../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/escape.js"(exports2) {
220995
+ "../../node_modules/minimatch/dist/commonjs/escape.js"(exports2) {
220994
220996
  "use strict";
220995
220997
  init_cjs_shims();
220996
220998
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -221005,9 +221007,9 @@ var require_escape = __commonJS({
221005
221007
  }
221006
221008
  });
221007
221009
 
221008
- // ../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/index.js
221010
+ // ../../node_modules/minimatch/dist/commonjs/index.js
221009
221011
  var require_commonjs3 = __commonJS({
221010
- "../../node_modules/@ts-morph/common/node_modules/minimatch/dist/commonjs/index.js"(exports2) {
221012
+ "../../node_modules/minimatch/dist/commonjs/index.js"(exports2) {
221011
221013
  "use strict";
221012
221014
  init_cjs_shims();
221013
221015
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -222528,9 +222530,9 @@ var require_is_glob = __commonJS({
222528
222530
  }
222529
222531
  });
222530
222532
 
222531
- // ../../node_modules/glob-parent/index.js
222533
+ // ../../node_modules/fast-glob/node_modules/glob-parent/index.js
222532
222534
  var require_glob_parent = __commonJS({
222533
- "../../node_modules/glob-parent/index.js"(exports2, module2) {
222535
+ "../../node_modules/fast-glob/node_modules/glob-parent/index.js"(exports2, module2) {
222534
222536
  "use strict";
222535
222537
  init_cjs_shims();
222536
222538
  var isGlob = require_is_glob();
@@ -223650,9 +223652,9 @@ var require_braces = __commonJS({
223650
223652
  }
223651
223653
  });
223652
223654
 
223653
- // ../../node_modules/picomatch/lib/constants.js
223655
+ // ../../node_modules/micromatch/node_modules/picomatch/lib/constants.js
223654
223656
  var require_constants2 = __commonJS({
223655
- "../../node_modules/picomatch/lib/constants.js"(exports2, module2) {
223657
+ "../../node_modules/micromatch/node_modules/picomatch/lib/constants.js"(exports2, module2) {
223656
223658
  "use strict";
223657
223659
  init_cjs_shims();
223658
223660
  var path = require("path");
@@ -223852,9 +223854,9 @@ var require_constants2 = __commonJS({
223852
223854
  }
223853
223855
  });
223854
223856
 
223855
- // ../../node_modules/picomatch/lib/utils.js
223857
+ // ../../node_modules/micromatch/node_modules/picomatch/lib/utils.js
223856
223858
  var require_utils2 = __commonJS({
223857
- "../../node_modules/picomatch/lib/utils.js"(exports2) {
223859
+ "../../node_modules/micromatch/node_modules/picomatch/lib/utils.js"(exports2) {
223858
223860
  "use strict";
223859
223861
  init_cjs_shims();
223860
223862
  var path = require("path");
@@ -223914,9 +223916,9 @@ var require_utils2 = __commonJS({
223914
223916
  }
223915
223917
  });
223916
223918
 
223917
- // ../../node_modules/picomatch/lib/scan.js
223919
+ // ../../node_modules/micromatch/node_modules/picomatch/lib/scan.js
223918
223920
  var require_scan = __commonJS({
223919
- "../../node_modules/picomatch/lib/scan.js"(exports2, module2) {
223921
+ "../../node_modules/micromatch/node_modules/picomatch/lib/scan.js"(exports2, module2) {
223920
223922
  "use strict";
223921
223923
  init_cjs_shims();
223922
223924
  var utils = require_utils2();
@@ -224245,9 +224247,9 @@ var require_scan = __commonJS({
224245
224247
  }
224246
224248
  });
224247
224249
 
224248
- // ../../node_modules/picomatch/lib/parse.js
224250
+ // ../../node_modules/micromatch/node_modules/picomatch/lib/parse.js
224249
224251
  var require_parse2 = __commonJS({
224250
- "../../node_modules/picomatch/lib/parse.js"(exports2, module2) {
224252
+ "../../node_modules/micromatch/node_modules/picomatch/lib/parse.js"(exports2, module2) {
224251
224253
  "use strict";
224252
224254
  init_cjs_shims();
224253
224255
  var constants = require_constants2();
@@ -225248,9 +225250,9 @@ var require_parse2 = __commonJS({
225248
225250
  }
225249
225251
  });
225250
225252
 
225251
- // ../../node_modules/picomatch/lib/picomatch.js
225253
+ // ../../node_modules/micromatch/node_modules/picomatch/lib/picomatch.js
225252
225254
  var require_picomatch = __commonJS({
225253
- "../../node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
225255
+ "../../node_modules/micromatch/node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
225254
225256
  "use strict";
225255
225257
  init_cjs_shims();
225256
225258
  var path = require("path");
@@ -225390,9 +225392,9 @@ var require_picomatch = __commonJS({
225390
225392
  }
225391
225393
  });
225392
225394
 
225393
- // ../../node_modules/picomatch/index.js
225395
+ // ../../node_modules/micromatch/node_modules/picomatch/index.js
225394
225396
  var require_picomatch2 = __commonJS({
225395
- "../../node_modules/picomatch/index.js"(exports2, module2) {
225397
+ "../../node_modules/micromatch/node_modules/picomatch/index.js"(exports2, module2) {
225396
225398
  "use strict";
225397
225399
  init_cjs_shims();
225398
225400
  module2.exports = require_picomatch();
@@ -289579,7 +289581,7 @@ async function upgrade(argv) {
289579
289581
  const stale = jsx.getAttributes().some(
289580
289582
  (a) => import_ts_morph.Node.isJsxAttribute(a) && ["schema", "teamIds", "authEndpoint", "scope", "apiKey"].includes(a.getNameNode().getText())
289581
289583
  );
289582
- if (stale) flag2(jsx, "<AbloProvider> props", "AbloProvider takes only `client` (+ userId/fallback/onError). Build `const ablo = Ablo({ schema, authEndpoint })` and pass `client={ablo}`.");
289584
+ if (stale) flag2(jsx, "<AbloProvider> props", "AbloProvider takes only `client` (+ userId/fallback/onError). Build `const ablo = Ablo({ schema, session: { endpoint } })` and pass `client={ablo}`.");
289583
289585
  }
289584
289586
  }
289585
289587
  const cwd = process.cwd();
@@ -290407,7 +290409,7 @@ import Ablo from '@abloatai/ablo';
290407
290409
  import { AbloProvider } from '@abloatai/ablo/react';
290408
290410
  import { schema } from '@/ablo/schema';
290409
290411
 
290410
- const ablo = Ablo({ schema, authEndpoint: '/api/ablo-session' });
290412
+ const ablo = Ablo({ schema, session: { endpoint: '/api/ablo-session' } });
290411
290413
 
290412
290414
  export function Providers({ children }: { children: React.ReactNode }) {
290413
290415
  return <AbloProvider client={ablo}>{children}</AbloProvider>;
@@ -290416,77 +290418,34 @@ export function Providers({ children }: { children: React.ReactNode }) {
290416
290418
  }
290417
290419
  function generateSessionRoute() {
290418
290420
  return `import { headers } from 'next/headers';
290419
- import {
290420
- credentialEndpointErrorSchema,
290421
- credentialEndpointSuccessSchema,
290422
- } from '@abloatai/ablo/auth';
290423
- import { sync } from '@/ablo';
290421
+ import Sessions from '@abloatai/ablo/sessions';
290422
+ import { schema } from '@/ablo/schema';
290424
290423
  import { auth } from '@/lib/auth';
290425
290424
 
290426
- const noStore = { 'Cache-Control': 'no-store' };
290425
+ const sessions = Sessions({ schema, apiKey: process.env.ABLO_API_KEY });
290427
290426
 
290428
- export async function POST(request: Request): Promise<Response> {
290429
- if (!(await isSameOrigin(request))) {
290430
- return Response.json(
290431
- credentialEndpointErrorSchema.parse({
290432
- error: { code: 'origin_mismatch', message: 'Cross-origin mint rejected' },
290433
- }),
290434
- { status: 403, headers: noStore },
290435
- );
290436
- }
290437
-
290438
- const user = await getCurrentUser();
290439
- if (!user) {
290440
- return Response.json(
290441
- credentialEndpointErrorSchema.parse({
290442
- error: { code: 'session_expired', message: 'Sign in again' },
290443
- }),
290444
- { status: 401, headers: noStore },
290445
- );
290446
- }
290447
-
290448
- const authorizedScope = await authorizeActiveWorkspace(user.id);
290449
- if (!authorizedScope) {
290450
- return Response.json(
290451
- credentialEndpointErrorSchema.parse({
290452
- error: { code: 'policy_denied', message: 'Workspace membership is stale or revoked' },
290453
- }),
290454
- { status: 403, headers: noStore },
290455
- );
290456
- }
290457
-
290458
- const { token, expiresAt } = await sync.sessions.create({
290459
- user: { id: user.id },
290460
- // These ids came from the server-side membership lookup below. Never take
290461
- // organization, workspace, team, or group ids from the request body.
290462
- syncGroups: authorizedScope.syncGroups,
290463
- can: { records: ['read', 'create', 'update'] },
290464
- });
290465
- return Response.json(
290466
- credentialEndpointSuccessSchema.parse({
290467
- token,
290468
- expiresAt,
290469
- credentialKind: 'ephemeral',
290470
- }),
290471
- { headers: noStore },
290472
- );
290473
- }
290474
-
290475
- async function isSameOrigin(request: Request): Promise<boolean> {
290476
- const origin = request.headers.get('origin');
290477
- if (!origin) return request.headers.get('sec-fetch-site') !== 'cross-site';
290478
- const host = (await headers()).get('host');
290479
- return host !== null && new URL(origin).host === host;
290480
- }
290427
+ export const POST = sessions.handler({
290428
+ async authenticate() {
290429
+ const session = await auth.api.getSession({ headers: await headers() });
290430
+ return session?.user ?? null;
290431
+ },
290432
+ async grant({ principal: user }) {
290433
+ const authorizedScope = await authorizeActiveWorkspace(user.id);
290434
+ if (!authorizedScope) return null;
290481
290435
 
290482
- async function getCurrentUser(): Promise<{ id: string } | null> {
290483
- const session = await auth.api.getSession({ headers: await headers() });
290484
- return session?.user ? { id: session.user.id } : null;
290485
- }
290436
+ return {
290437
+ user: { id: user.id },
290438
+ // These ids came from the server-side membership lookup below. Never take
290439
+ // organization, workspace, team, or group ids from the request body.
290440
+ groups: authorizedScope.groups,
290441
+ can: { records: ['read', 'create', 'update'] },
290442
+ };
290443
+ },
290444
+ });
290486
290445
 
290487
290446
  type AuthorizedWorkspace = {
290488
290447
  workspaceId: string;
290489
- syncGroups: readonly [\`workspace:\${string}\`, ...\`\${string}:\${string}\`[]];
290448
+ groups: readonly [\`workspace:\${string}\`, ...\`\${string}:\${string}\`[]];
290490
290449
  };
290491
290450
 
290492
290451
  async function authorizeActiveWorkspace(userId: string): Promise<AuthorizedWorkspace | null> {
@@ -290500,7 +290459,7 @@ async function authorizeActiveWorkspace(userId: string): Promise<AuthorizedWorks
290500
290459
  // Example after your membership query:
290501
290460
  // return {
290502
290461
  // workspaceId: membership.workspaceId,
290503
- // syncGroups: [\`workspace:\${membership.workspaceId}\`],
290462
+ // groups: [\`workspace:\${membership.workspaceId}\`],
290504
290463
  // };
290505
290464
  return null;
290506
290465
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abloatai/cli",
3
- "version": "0.59.2",
3
+ "version": "0.60.0",
4
4
  "description": "The ablo command line: set up Ablo, connect your database, and push your schema from the terminal.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.abloatai.com/cli",
@@ -41,10 +41,10 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@sentry/node": "^10.18.0",
44
- "@abloatai/transaction": "^0.59.2",
44
+ "@abloatai/transaction": "^0.60.0",
45
45
  "jiti": "^2.7.0",
46
46
  "zod": "^4.4.3",
47
- "@abloatai/humans": "^0.59.2"
47
+ "@abloatai/humans": "^0.60.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@ablo/product-analytics": "file:../product-analytics",