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.js CHANGED
@@ -21121,7 +21121,7 @@ var version;
21121
21121
  var init_version = __esm({
21122
21122
  "../drizzle-orm/dist/version.js"() {
21123
21123
  "use strict";
21124
- version = "0.36.2";
21124
+ version = "0.36.4";
21125
21125
  }
21126
21126
  });
21127
21127
 
@@ -24583,9 +24583,10 @@ var init_delete = __esm({
24583
24583
  constructor(table4, session, dialect4, withList) {
24584
24584
  super();
24585
24585
  __publicField(this, "config");
24586
+ __publicField(this, "authToken");
24586
24587
  __publicField(this, "execute", (placeholderValues) => {
24587
24588
  return tracer.startActiveSpan("drizzle.operation", () => {
24588
- return this._prepare().execute(placeholderValues);
24589
+ return this._prepare().execute(placeholderValues, this.authToken);
24589
24590
  });
24590
24591
  });
24591
24592
  this.session = session;
@@ -24646,6 +24647,11 @@ var init_delete = __esm({
24646
24647
  prepare(name2) {
24647
24648
  return this._prepare(name2);
24648
24649
  }
24650
+ /** @internal */
24651
+ setToken(token) {
24652
+ this.authToken = token;
24653
+ return this;
24654
+ }
24649
24655
  $dynamic() {
24650
24656
  return this;
24651
24657
  }
@@ -25057,7 +25063,7 @@ var init_dialect = __esm({
25057
25063
  const offsetSql = offset ? sql` offset ${offset}` : void 0;
25058
25064
  return sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
25059
25065
  }
25060
- buildInsertQuery({ table: table4, values: valuesOrSelect, onConflict, returning, withList, select }) {
25066
+ buildInsertQuery({ table: table4, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_ }) {
25061
25067
  const valuesSqlList = [];
25062
25068
  const columns = table4[Table2.Symbol.Columns];
25063
25069
  const colEntries = Object.entries(columns).filter(([_2, col]) => !col.shouldDisableInsert());
@@ -25104,7 +25110,8 @@ var init_dialect = __esm({
25104
25110
  const valuesSql = sql.join(valuesSqlList);
25105
25111
  const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
25106
25112
  const onConflictSql = onConflict ? sql` on conflict ${onConflict}` : void 0;
25107
- return sql`${withSql}insert into ${table4} ${insertOrder} ${valuesSql}${onConflictSql}${returningSql}`;
25113
+ const overridingSql = overridingSystemValue_ === true ? sql`overriding system value ` : void 0;
25114
+ return sql`${withSql}insert into ${table4} ${insertOrder} ${overridingSql}${valuesSql}${onConflictSql}${returningSql}`;
25108
25115
  }
25109
25116
  buildRefreshMaterializedViewQuery({ view: view4, concurrently, withNoData }) {
25110
25117
  const concurrentlySql = concurrently ? sql` concurrently` : void 0;
@@ -25985,6 +25992,7 @@ var init_select2 = __esm({
25985
25992
  __publicField(this, "dialect");
25986
25993
  __publicField(this, "withList", []);
25987
25994
  __publicField(this, "distinct");
25995
+ __publicField(this, "authToken");
25988
25996
  this.fields = config.fields;
25989
25997
  this.session = config.session;
25990
25998
  this.dialect = config.dialect;
@@ -25993,6 +26001,11 @@ var init_select2 = __esm({
25993
26001
  }
25994
26002
  this.distinct = config.distinct;
25995
26003
  }
26004
+ /** @internal */
26005
+ setToken(token) {
26006
+ this.authToken = token;
26007
+ return this;
26008
+ }
25996
26009
  /**
25997
26010
  * Specify the table, subquery, or other target that you're
25998
26011
  * building a select query against.
@@ -26023,7 +26036,7 @@ var init_select2 = __esm({
26023
26036
  dialect: this.dialect,
26024
26037
  withList: this.withList,
26025
26038
  distinct: this.distinct
26026
- });
26039
+ }).setToken(this.authToken);
26027
26040
  }
26028
26041
  };
26029
26042
  __publicField(PgSelectBuilder, _a130, "PgSelectBuilder");
@@ -26631,15 +26644,16 @@ var init_select2 = __esm({
26631
26644
  PgSelectBase = class extends (_b100 = PgSelectQueryBuilderBase, _a132 = entityKind, _b100) {
26632
26645
  constructor() {
26633
26646
  super(...arguments);
26647
+ __publicField(this, "authToken");
26634
26648
  __publicField(this, "execute", (placeholderValues) => {
26635
26649
  return tracer.startActiveSpan("drizzle.operation", () => {
26636
- return this._prepare().execute(placeholderValues);
26650
+ return this._prepare().execute(placeholderValues, this.authToken);
26637
26651
  });
26638
26652
  });
26639
26653
  }
26640
26654
  /** @internal */
26641
26655
  _prepare(name2) {
26642
- const { session, config, dialect: dialect4, joinsNotNullableMap } = this;
26656
+ const { session, config, dialect: dialect4, joinsNotNullableMap, authToken } = this;
26643
26657
  if (!session) {
26644
26658
  throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
26645
26659
  }
@@ -26647,7 +26661,7 @@ var init_select2 = __esm({
26647
26661
  const fieldsList = orderSelectedFields(config.fields);
26648
26662
  const query = session.prepareQuery(dialect4.sqlToQuery(this.getSQL()), fieldsList, name2, true);
26649
26663
  query.joinsNotNullableMap = joinsNotNullableMap;
26650
- return query;
26664
+ return query.setToken(authToken);
26651
26665
  });
26652
26666
  }
26653
26667
  /**
@@ -26660,6 +26674,11 @@ var init_select2 = __esm({
26660
26674
  prepare(name2) {
26661
26675
  return this._prepare(name2);
26662
26676
  }
26677
+ /** @internal */
26678
+ setToken(token) {
26679
+ this.authToken = token;
26680
+ return this;
26681
+ }
26663
26682
  };
26664
26683
  __publicField(PgSelectBase, _a132, "PgSelect");
26665
26684
  applyMixins(PgSelectBase, [QueryPromise]);
@@ -26789,11 +26808,22 @@ var init_insert = __esm({
26789
26808
  init_query_builder2();
26790
26809
  _a134 = entityKind;
26791
26810
  PgInsertBuilder = class {
26792
- constructor(table4, session, dialect4, withList) {
26811
+ constructor(table4, session, dialect4, withList, overridingSystemValue_) {
26812
+ __publicField(this, "authToken");
26793
26813
  this.table = table4;
26794
26814
  this.session = session;
26795
26815
  this.dialect = dialect4;
26796
26816
  this.withList = withList;
26817
+ this.overridingSystemValue_ = overridingSystemValue_;
26818
+ }
26819
+ /** @internal */
26820
+ setToken(token) {
26821
+ this.authToken = token;
26822
+ return this;
26823
+ }
26824
+ overridingSystemValue() {
26825
+ this.overridingSystemValue_ = true;
26826
+ return this;
26797
26827
  }
26798
26828
  values(values) {
26799
26829
  values = Array.isArray(values) ? values : [values];
@@ -26809,7 +26839,15 @@ var init_insert = __esm({
26809
26839
  }
26810
26840
  return result;
26811
26841
  });
26812
- return new PgInsertBase(this.table, mappedValues, this.session, this.dialect, this.withList);
26842
+ return new PgInsertBase(
26843
+ this.table,
26844
+ mappedValues,
26845
+ this.session,
26846
+ this.dialect,
26847
+ this.withList,
26848
+ false,
26849
+ this.overridingSystemValue_
26850
+ ).setToken(this.authToken);
26813
26851
  }
26814
26852
  select(selectQuery) {
26815
26853
  const select = typeof selectQuery === "function" ? selectQuery(new QueryBuilder()) : selectQuery;
@@ -26823,17 +26861,18 @@ var init_insert = __esm({
26823
26861
  };
26824
26862
  __publicField(PgInsertBuilder, _a134, "PgInsertBuilder");
26825
26863
  PgInsertBase = class extends (_b101 = QueryPromise, _a135 = entityKind, _b101) {
26826
- constructor(table4, values, session, dialect4, withList, select) {
26864
+ constructor(table4, values, session, dialect4, withList, select, overridingSystemValue_) {
26827
26865
  super();
26828
26866
  __publicField(this, "config");
26867
+ __publicField(this, "authToken");
26829
26868
  __publicField(this, "execute", (placeholderValues) => {
26830
26869
  return tracer.startActiveSpan("drizzle.operation", () => {
26831
- return this._prepare().execute(placeholderValues);
26870
+ return this._prepare().execute(placeholderValues, this.authToken);
26832
26871
  });
26833
26872
  });
26834
26873
  this.session = session;
26835
26874
  this.dialect = dialect4;
26836
- this.config = { table: table4, values, withList, select };
26875
+ this.config = { table: table4, values, withList, select, overridingSystemValue_ };
26837
26876
  }
26838
26877
  returning(fields = this.config.table[Table2.Symbol.Columns]) {
26839
26878
  this.config.returning = orderSelectedFields(fields);
@@ -26933,6 +26972,11 @@ var init_insert = __esm({
26933
26972
  prepare(name2) {
26934
26973
  return this._prepare(name2);
26935
26974
  }
26975
+ /** @internal */
26976
+ setToken(token) {
26977
+ this.authToken = token;
26978
+ return this;
26979
+ }
26936
26980
  $dynamic() {
26937
26981
  return this;
26938
26982
  }
@@ -26953,9 +26997,10 @@ var init_refresh_materialized_view = __esm({
26953
26997
  constructor(view4, session, dialect4) {
26954
26998
  super();
26955
26999
  __publicField(this, "config");
27000
+ __publicField(this, "authToken");
26956
27001
  __publicField(this, "execute", (placeholderValues) => {
26957
27002
  return tracer.startActiveSpan("drizzle.operation", () => {
26958
- return this._prepare().execute(placeholderValues);
27003
+ return this._prepare().execute(placeholderValues, this.authToken);
26959
27004
  });
26960
27005
  });
26961
27006
  this.session = session;
@@ -26993,6 +27038,11 @@ var init_refresh_materialized_view = __esm({
26993
27038
  prepare(name2) {
26994
27039
  return this._prepare(name2);
26995
27040
  }
27041
+ /** @internal */
27042
+ setToken(token) {
27043
+ this.authToken = token;
27044
+ return this;
27045
+ }
26996
27046
  };
26997
27047
  __publicField(PgRefreshMaterializedView, _a136, "PgRefreshMaterializedView");
26998
27048
  }
@@ -27022,11 +27072,16 @@ var init_update = __esm({
27022
27072
  _a137 = entityKind;
27023
27073
  PgUpdateBuilder = class {
27024
27074
  constructor(table4, session, dialect4, withList) {
27075
+ __publicField(this, "authToken");
27025
27076
  this.table = table4;
27026
27077
  this.session = session;
27027
27078
  this.dialect = dialect4;
27028
27079
  this.withList = withList;
27029
27080
  }
27081
+ setToken(token) {
27082
+ this.authToken = token;
27083
+ return this;
27084
+ }
27030
27085
  set(values) {
27031
27086
  return new PgUpdateBase(
27032
27087
  this.table,
@@ -27034,7 +27089,7 @@ var init_update = __esm({
27034
27089
  this.session,
27035
27090
  this.dialect,
27036
27091
  this.withList
27037
- );
27092
+ ).setToken(this.authToken);
27038
27093
  }
27039
27094
  };
27040
27095
  __publicField(PgUpdateBuilder, _a137, "PgUpdateBuilder");
@@ -27048,8 +27103,9 @@ var init_update = __esm({
27048
27103
  __publicField(this, "rightJoin", this.createJoin("right"));
27049
27104
  __publicField(this, "innerJoin", this.createJoin("inner"));
27050
27105
  __publicField(this, "fullJoin", this.createJoin("full"));
27106
+ __publicField(this, "authToken");
27051
27107
  __publicField(this, "execute", (placeholderValues) => {
27052
- return this._prepare().execute(placeholderValues);
27108
+ return this._prepare().execute(placeholderValues, this.authToken);
27053
27109
  });
27054
27110
  this.session = session;
27055
27111
  this.dialect = dialect4;
@@ -27197,6 +27253,11 @@ var init_update = __esm({
27197
27253
  prepare(name2) {
27198
27254
  return this._prepare(name2);
27199
27255
  }
27256
+ /** @internal */
27257
+ setToken(token) {
27258
+ this.authToken = token;
27259
+ return this;
27260
+ }
27200
27261
  $dynamic() {
27201
27262
  return this;
27202
27263
  }
@@ -27230,6 +27291,7 @@ var init_count = __esm({
27230
27291
  constructor(params) {
27231
27292
  super(_PgCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
27232
27293
  __publicField(this, "sql");
27294
+ __publicField(this, "token");
27233
27295
  __publicField(this, _a139, "PgCountBuilder");
27234
27296
  __publicField(this, "session");
27235
27297
  this.params = params;
@@ -27246,8 +27308,13 @@ var init_count = __esm({
27246
27308
  static buildCount(source, filters) {
27247
27309
  return sql`select count(*) as count from ${source}${sql.raw(" where ").if(filters)}${filters};`;
27248
27310
  }
27311
+ /** @intrnal */
27312
+ setToken(token) {
27313
+ this.token = token;
27314
+ return this;
27315
+ }
27249
27316
  then(onfulfilled, onrejected) {
27250
- return Promise.resolve(this.session.count(this.sql)).then(
27317
+ return Promise.resolve(this.session.count(this.sql, this.token)).then(
27251
27318
  onfulfilled,
27252
27319
  onrejected
27253
27320
  );
@@ -27324,6 +27391,7 @@ var init_query = __esm({
27324
27391
  PgRelationalQuery = class extends (_b105 = QueryPromise, _a141 = entityKind, _b105) {
27325
27392
  constructor(fullSchema, schema4, tableNamesMap, table4, tableConfig, dialect4, session, config, mode) {
27326
27393
  super();
27394
+ __publicField(this, "authToken");
27327
27395
  this.fullSchema = fullSchema;
27328
27396
  this.schema = schema4;
27329
27397
  this.tableNamesMap = tableNamesMap;
@@ -27381,9 +27449,14 @@ var init_query = __esm({
27381
27449
  toSQL() {
27382
27450
  return this._toSQL().builtQuery;
27383
27451
  }
27452
+ /** @internal */
27453
+ setToken(token) {
27454
+ this.authToken = token;
27455
+ return this;
27456
+ }
27384
27457
  execute() {
27385
27458
  return tracer.startActiveSpan("drizzle.operation", () => {
27386
- return this._prepare().execute();
27459
+ return this._prepare().execute(void 0, this.authToken);
27387
27460
  });
27388
27461
  }
27389
27462
  };
@@ -27446,6 +27519,7 @@ var init_db = __esm({
27446
27519
  PgDatabase = class {
27447
27520
  constructor(dialect4, session, schema4) {
27448
27521
  __publicField(this, "query");
27522
+ __publicField(this, "authToken");
27449
27523
  this.dialect = dialect4;
27450
27524
  this.session = session;
27451
27525
  this._ = schema4 ? {
@@ -27701,7 +27775,7 @@ var init_db = __esm({
27701
27775
  false
27702
27776
  );
27703
27777
  return new PgRaw(
27704
- () => prepared.execute(),
27778
+ () => prepared.execute(void 0, this.authToken),
27705
27779
  sequel,
27706
27780
  builtQuery,
27707
27781
  (result) => prepared.mapResult(result, true)
@@ -28246,6 +28320,7 @@ var init_session = __esm({
28246
28320
  _a159 = entityKind;
28247
28321
  PgPreparedQuery = class {
28248
28322
  constructor(query) {
28323
+ __publicField(this, "authToken");
28249
28324
  /** @internal */
28250
28325
  __publicField(this, "joinsNotNullableMap");
28251
28326
  this.query = query;
@@ -28256,6 +28331,11 @@ var init_session = __esm({
28256
28331
  mapResult(response, _isFromBatch) {
28257
28332
  return response;
28258
28333
  }
28334
+ /** @internal */
28335
+ setToken(token) {
28336
+ this.authToken = token;
28337
+ return this;
28338
+ }
28259
28339
  };
28260
28340
  __publicField(PgPreparedQuery, _a159, "PgPreparedQuery");
28261
28341
  _a160 = entityKind;
@@ -28263,7 +28343,8 @@ var init_session = __esm({
28263
28343
  constructor(dialect4) {
28264
28344
  this.dialect = dialect4;
28265
28345
  }
28266
- execute(query) {
28346
+ /** @internal */
28347
+ execute(query, token) {
28267
28348
  return tracer.startActiveSpan("drizzle.operation", () => {
28268
28349
  const prepared = tracer.startActiveSpan("drizzle.prepareQuery", () => {
28269
28350
  return this.prepareQuery(
@@ -28273,7 +28354,7 @@ var init_session = __esm({
28273
28354
  false
28274
28355
  );
28275
28356
  });
28276
- return prepared.execute();
28357
+ return prepared.setToken(token).execute(void 0, token);
28277
28358
  });
28278
28359
  }
28279
28360
  all(query) {
@@ -28284,8 +28365,9 @@ var init_session = __esm({
28284
28365
  false
28285
28366
  ).all();
28286
28367
  }
28287
- async count(sql2) {
28288
- const res = await this.execute(sql2);
28368
+ /** @internal */
28369
+ async count(sql2, token) {
28370
+ const res = await this.execute(sql2, token);
28289
28371
  return Number(
28290
28372
  res[0]["count"]
28291
28373
  );