drizzle-kit 0.28.1-cadba24 → 0.28.1-ddb97ec

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 (4) hide show
  1. package/api.js +105 -23
  2. package/api.mjs +105 -23
  3. package/bin.cjs +673 -78
  4. package/package.json +1 -1
package/api.mjs CHANGED
@@ -21126,7 +21126,7 @@ var version;
21126
21126
  var init_version = __esm({
21127
21127
  "../drizzle-orm/dist/version.js"() {
21128
21128
  "use strict";
21129
- version = "0.36.2";
21129
+ version = "0.36.4";
21130
21130
  }
21131
21131
  });
21132
21132
 
@@ -24588,9 +24588,10 @@ var init_delete = __esm({
24588
24588
  constructor(table4, session, dialect4, withList) {
24589
24589
  super();
24590
24590
  __publicField(this, "config");
24591
+ __publicField(this, "authToken");
24591
24592
  __publicField(this, "execute", (placeholderValues) => {
24592
24593
  return tracer.startActiveSpan("drizzle.operation", () => {
24593
- return this._prepare().execute(placeholderValues);
24594
+ return this._prepare().execute(placeholderValues, this.authToken);
24594
24595
  });
24595
24596
  });
24596
24597
  this.session = session;
@@ -24651,6 +24652,11 @@ var init_delete = __esm({
24651
24652
  prepare(name2) {
24652
24653
  return this._prepare(name2);
24653
24654
  }
24655
+ /** @internal */
24656
+ setToken(token) {
24657
+ this.authToken = token;
24658
+ return this;
24659
+ }
24654
24660
  $dynamic() {
24655
24661
  return this;
24656
24662
  }
@@ -25062,7 +25068,7 @@ var init_dialect = __esm({
25062
25068
  const offsetSql = offset ? sql` offset ${offset}` : void 0;
25063
25069
  return sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
25064
25070
  }
25065
- buildInsertQuery({ table: table4, values: valuesOrSelect, onConflict, returning, withList, select }) {
25071
+ buildInsertQuery({ table: table4, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_ }) {
25066
25072
  const valuesSqlList = [];
25067
25073
  const columns = table4[Table2.Symbol.Columns];
25068
25074
  const colEntries = Object.entries(columns).filter(([_2, col]) => !col.shouldDisableInsert());
@@ -25109,7 +25115,8 @@ var init_dialect = __esm({
25109
25115
  const valuesSql = sql.join(valuesSqlList);
25110
25116
  const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
25111
25117
  const onConflictSql = onConflict ? sql` on conflict ${onConflict}` : void 0;
25112
- return sql`${withSql}insert into ${table4} ${insertOrder} ${valuesSql}${onConflictSql}${returningSql}`;
25118
+ const overridingSql = overridingSystemValue_ === true ? sql`overriding system value ` : void 0;
25119
+ return sql`${withSql}insert into ${table4} ${insertOrder} ${overridingSql}${valuesSql}${onConflictSql}${returningSql}`;
25113
25120
  }
25114
25121
  buildRefreshMaterializedViewQuery({ view: view4, concurrently, withNoData }) {
25115
25122
  const concurrentlySql = concurrently ? sql` concurrently` : void 0;
@@ -25990,6 +25997,7 @@ var init_select2 = __esm({
25990
25997
  __publicField(this, "dialect");
25991
25998
  __publicField(this, "withList", []);
25992
25999
  __publicField(this, "distinct");
26000
+ __publicField(this, "authToken");
25993
26001
  this.fields = config.fields;
25994
26002
  this.session = config.session;
25995
26003
  this.dialect = config.dialect;
@@ -25998,6 +26006,11 @@ var init_select2 = __esm({
25998
26006
  }
25999
26007
  this.distinct = config.distinct;
26000
26008
  }
26009
+ /** @internal */
26010
+ setToken(token) {
26011
+ this.authToken = token;
26012
+ return this;
26013
+ }
26001
26014
  /**
26002
26015
  * Specify the table, subquery, or other target that you're
26003
26016
  * building a select query against.
@@ -26028,7 +26041,7 @@ var init_select2 = __esm({
26028
26041
  dialect: this.dialect,
26029
26042
  withList: this.withList,
26030
26043
  distinct: this.distinct
26031
- });
26044
+ }).setToken(this.authToken);
26032
26045
  }
26033
26046
  };
26034
26047
  __publicField(PgSelectBuilder, _a130, "PgSelectBuilder");
@@ -26636,15 +26649,16 @@ var init_select2 = __esm({
26636
26649
  PgSelectBase = class extends (_b100 = PgSelectQueryBuilderBase, _a132 = entityKind, _b100) {
26637
26650
  constructor() {
26638
26651
  super(...arguments);
26652
+ __publicField(this, "authToken");
26639
26653
  __publicField(this, "execute", (placeholderValues) => {
26640
26654
  return tracer.startActiveSpan("drizzle.operation", () => {
26641
- return this._prepare().execute(placeholderValues);
26655
+ return this._prepare().execute(placeholderValues, this.authToken);
26642
26656
  });
26643
26657
  });
26644
26658
  }
26645
26659
  /** @internal */
26646
26660
  _prepare(name2) {
26647
- const { session, config, dialect: dialect4, joinsNotNullableMap } = this;
26661
+ const { session, config, dialect: dialect4, joinsNotNullableMap, authToken } = this;
26648
26662
  if (!session) {
26649
26663
  throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
26650
26664
  }
@@ -26652,7 +26666,7 @@ var init_select2 = __esm({
26652
26666
  const fieldsList = orderSelectedFields(config.fields);
26653
26667
  const query = session.prepareQuery(dialect4.sqlToQuery(this.getSQL()), fieldsList, name2, true);
26654
26668
  query.joinsNotNullableMap = joinsNotNullableMap;
26655
- return query;
26669
+ return query.setToken(authToken);
26656
26670
  });
26657
26671
  }
26658
26672
  /**
@@ -26665,6 +26679,11 @@ var init_select2 = __esm({
26665
26679
  prepare(name2) {
26666
26680
  return this._prepare(name2);
26667
26681
  }
26682
+ /** @internal */
26683
+ setToken(token) {
26684
+ this.authToken = token;
26685
+ return this;
26686
+ }
26668
26687
  };
26669
26688
  __publicField(PgSelectBase, _a132, "PgSelect");
26670
26689
  applyMixins(PgSelectBase, [QueryPromise]);
@@ -26794,11 +26813,22 @@ var init_insert = __esm({
26794
26813
  init_query_builder2();
26795
26814
  _a134 = entityKind;
26796
26815
  PgInsertBuilder = class {
26797
- constructor(table4, session, dialect4, withList) {
26816
+ constructor(table4, session, dialect4, withList, overridingSystemValue_) {
26817
+ __publicField(this, "authToken");
26798
26818
  this.table = table4;
26799
26819
  this.session = session;
26800
26820
  this.dialect = dialect4;
26801
26821
  this.withList = withList;
26822
+ this.overridingSystemValue_ = overridingSystemValue_;
26823
+ }
26824
+ /** @internal */
26825
+ setToken(token) {
26826
+ this.authToken = token;
26827
+ return this;
26828
+ }
26829
+ overridingSystemValue() {
26830
+ this.overridingSystemValue_ = true;
26831
+ return this;
26802
26832
  }
26803
26833
  values(values) {
26804
26834
  values = Array.isArray(values) ? values : [values];
@@ -26814,7 +26844,15 @@ var init_insert = __esm({
26814
26844
  }
26815
26845
  return result;
26816
26846
  });
26817
- return new PgInsertBase(this.table, mappedValues, this.session, this.dialect, this.withList);
26847
+ return new PgInsertBase(
26848
+ this.table,
26849
+ mappedValues,
26850
+ this.session,
26851
+ this.dialect,
26852
+ this.withList,
26853
+ false,
26854
+ this.overridingSystemValue_
26855
+ ).setToken(this.authToken);
26818
26856
  }
26819
26857
  select(selectQuery) {
26820
26858
  const select = typeof selectQuery === "function" ? selectQuery(new QueryBuilder()) : selectQuery;
@@ -26828,17 +26866,18 @@ var init_insert = __esm({
26828
26866
  };
26829
26867
  __publicField(PgInsertBuilder, _a134, "PgInsertBuilder");
26830
26868
  PgInsertBase = class extends (_b101 = QueryPromise, _a135 = entityKind, _b101) {
26831
- constructor(table4, values, session, dialect4, withList, select) {
26869
+ constructor(table4, values, session, dialect4, withList, select, overridingSystemValue_) {
26832
26870
  super();
26833
26871
  __publicField(this, "config");
26872
+ __publicField(this, "authToken");
26834
26873
  __publicField(this, "execute", (placeholderValues) => {
26835
26874
  return tracer.startActiveSpan("drizzle.operation", () => {
26836
- return this._prepare().execute(placeholderValues);
26875
+ return this._prepare().execute(placeholderValues, this.authToken);
26837
26876
  });
26838
26877
  });
26839
26878
  this.session = session;
26840
26879
  this.dialect = dialect4;
26841
- this.config = { table: table4, values, withList, select };
26880
+ this.config = { table: table4, values, withList, select, overridingSystemValue_ };
26842
26881
  }
26843
26882
  returning(fields = this.config.table[Table2.Symbol.Columns]) {
26844
26883
  this.config.returning = orderSelectedFields(fields);
@@ -26938,6 +26977,11 @@ var init_insert = __esm({
26938
26977
  prepare(name2) {
26939
26978
  return this._prepare(name2);
26940
26979
  }
26980
+ /** @internal */
26981
+ setToken(token) {
26982
+ this.authToken = token;
26983
+ return this;
26984
+ }
26941
26985
  $dynamic() {
26942
26986
  return this;
26943
26987
  }
@@ -26958,9 +27002,10 @@ var init_refresh_materialized_view = __esm({
26958
27002
  constructor(view4, session, dialect4) {
26959
27003
  super();
26960
27004
  __publicField(this, "config");
27005
+ __publicField(this, "authToken");
26961
27006
  __publicField(this, "execute", (placeholderValues) => {
26962
27007
  return tracer.startActiveSpan("drizzle.operation", () => {
26963
- return this._prepare().execute(placeholderValues);
27008
+ return this._prepare().execute(placeholderValues, this.authToken);
26964
27009
  });
26965
27010
  });
26966
27011
  this.session = session;
@@ -26998,6 +27043,11 @@ var init_refresh_materialized_view = __esm({
26998
27043
  prepare(name2) {
26999
27044
  return this._prepare(name2);
27000
27045
  }
27046
+ /** @internal */
27047
+ setToken(token) {
27048
+ this.authToken = token;
27049
+ return this;
27050
+ }
27001
27051
  };
27002
27052
  __publicField(PgRefreshMaterializedView, _a136, "PgRefreshMaterializedView");
27003
27053
  }
@@ -27027,11 +27077,16 @@ var init_update = __esm({
27027
27077
  _a137 = entityKind;
27028
27078
  PgUpdateBuilder = class {
27029
27079
  constructor(table4, session, dialect4, withList) {
27080
+ __publicField(this, "authToken");
27030
27081
  this.table = table4;
27031
27082
  this.session = session;
27032
27083
  this.dialect = dialect4;
27033
27084
  this.withList = withList;
27034
27085
  }
27086
+ setToken(token) {
27087
+ this.authToken = token;
27088
+ return this;
27089
+ }
27035
27090
  set(values) {
27036
27091
  return new PgUpdateBase(
27037
27092
  this.table,
@@ -27039,7 +27094,7 @@ var init_update = __esm({
27039
27094
  this.session,
27040
27095
  this.dialect,
27041
27096
  this.withList
27042
- );
27097
+ ).setToken(this.authToken);
27043
27098
  }
27044
27099
  };
27045
27100
  __publicField(PgUpdateBuilder, _a137, "PgUpdateBuilder");
@@ -27053,8 +27108,9 @@ var init_update = __esm({
27053
27108
  __publicField(this, "rightJoin", this.createJoin("right"));
27054
27109
  __publicField(this, "innerJoin", this.createJoin("inner"));
27055
27110
  __publicField(this, "fullJoin", this.createJoin("full"));
27111
+ __publicField(this, "authToken");
27056
27112
  __publicField(this, "execute", (placeholderValues) => {
27057
- return this._prepare().execute(placeholderValues);
27113
+ return this._prepare().execute(placeholderValues, this.authToken);
27058
27114
  });
27059
27115
  this.session = session;
27060
27116
  this.dialect = dialect4;
@@ -27202,6 +27258,11 @@ var init_update = __esm({
27202
27258
  prepare(name2) {
27203
27259
  return this._prepare(name2);
27204
27260
  }
27261
+ /** @internal */
27262
+ setToken(token) {
27263
+ this.authToken = token;
27264
+ return this;
27265
+ }
27205
27266
  $dynamic() {
27206
27267
  return this;
27207
27268
  }
@@ -27235,6 +27296,7 @@ var init_count = __esm({
27235
27296
  constructor(params) {
27236
27297
  super(_PgCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
27237
27298
  __publicField(this, "sql");
27299
+ __publicField(this, "token");
27238
27300
  __publicField(this, _a139, "PgCountBuilder");
27239
27301
  __publicField(this, "session");
27240
27302
  this.params = params;
@@ -27251,8 +27313,13 @@ var init_count = __esm({
27251
27313
  static buildCount(source, filters) {
27252
27314
  return sql`select count(*) as count from ${source}${sql.raw(" where ").if(filters)}${filters};`;
27253
27315
  }
27316
+ /** @intrnal */
27317
+ setToken(token) {
27318
+ this.token = token;
27319
+ return this;
27320
+ }
27254
27321
  then(onfulfilled, onrejected) {
27255
- return Promise.resolve(this.session.count(this.sql)).then(
27322
+ return Promise.resolve(this.session.count(this.sql, this.token)).then(
27256
27323
  onfulfilled,
27257
27324
  onrejected
27258
27325
  );
@@ -27329,6 +27396,7 @@ var init_query = __esm({
27329
27396
  PgRelationalQuery = class extends (_b105 = QueryPromise, _a141 = entityKind, _b105) {
27330
27397
  constructor(fullSchema, schema4, tableNamesMap, table4, tableConfig, dialect4, session, config, mode) {
27331
27398
  super();
27399
+ __publicField(this, "authToken");
27332
27400
  this.fullSchema = fullSchema;
27333
27401
  this.schema = schema4;
27334
27402
  this.tableNamesMap = tableNamesMap;
@@ -27386,9 +27454,14 @@ var init_query = __esm({
27386
27454
  toSQL() {
27387
27455
  return this._toSQL().builtQuery;
27388
27456
  }
27457
+ /** @internal */
27458
+ setToken(token) {
27459
+ this.authToken = token;
27460
+ return this;
27461
+ }
27389
27462
  execute() {
27390
27463
  return tracer.startActiveSpan("drizzle.operation", () => {
27391
- return this._prepare().execute();
27464
+ return this._prepare().execute(void 0, this.authToken);
27392
27465
  });
27393
27466
  }
27394
27467
  };
@@ -27451,6 +27524,7 @@ var init_db = __esm({
27451
27524
  PgDatabase = class {
27452
27525
  constructor(dialect4, session, schema4) {
27453
27526
  __publicField(this, "query");
27527
+ __publicField(this, "authToken");
27454
27528
  this.dialect = dialect4;
27455
27529
  this.session = session;
27456
27530
  this._ = schema4 ? {
@@ -27706,7 +27780,7 @@ var init_db = __esm({
27706
27780
  false
27707
27781
  );
27708
27782
  return new PgRaw(
27709
- () => prepared.execute(),
27783
+ () => prepared.execute(void 0, this.authToken),
27710
27784
  sequel,
27711
27785
  builtQuery,
27712
27786
  (result) => prepared.mapResult(result, true)
@@ -28251,6 +28325,7 @@ var init_session = __esm({
28251
28325
  _a159 = entityKind;
28252
28326
  PgPreparedQuery = class {
28253
28327
  constructor(query) {
28328
+ __publicField(this, "authToken");
28254
28329
  /** @internal */
28255
28330
  __publicField(this, "joinsNotNullableMap");
28256
28331
  this.query = query;
@@ -28261,6 +28336,11 @@ var init_session = __esm({
28261
28336
  mapResult(response, _isFromBatch) {
28262
28337
  return response;
28263
28338
  }
28339
+ /** @internal */
28340
+ setToken(token) {
28341
+ this.authToken = token;
28342
+ return this;
28343
+ }
28264
28344
  };
28265
28345
  __publicField(PgPreparedQuery, _a159, "PgPreparedQuery");
28266
28346
  _a160 = entityKind;
@@ -28268,7 +28348,8 @@ var init_session = __esm({
28268
28348
  constructor(dialect4) {
28269
28349
  this.dialect = dialect4;
28270
28350
  }
28271
- execute(query) {
28351
+ /** @internal */
28352
+ execute(query, token) {
28272
28353
  return tracer.startActiveSpan("drizzle.operation", () => {
28273
28354
  const prepared = tracer.startActiveSpan("drizzle.prepareQuery", () => {
28274
28355
  return this.prepareQuery(
@@ -28278,7 +28359,7 @@ var init_session = __esm({
28278
28359
  false
28279
28360
  );
28280
28361
  });
28281
- return prepared.execute();
28362
+ return prepared.setToken(token).execute(void 0, token);
28282
28363
  });
28283
28364
  }
28284
28365
  all(query) {
@@ -28289,8 +28370,9 @@ var init_session = __esm({
28289
28370
  false
28290
28371
  ).all();
28291
28372
  }
28292
- async count(sql2) {
28293
- const res = await this.execute(sql2);
28373
+ /** @internal */
28374
+ async count(sql2, token) {
28375
+ const res = await this.execute(sql2, token);
28294
28376
  return Number(
28295
28377
  res[0]["count"]
28296
28378
  );