@anthonyalayo/drizzle-kit 1.1.0 → 1.2.1

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/api.d.mts CHANGED
@@ -375,7 +375,9 @@ type Config = {
375
375
  prefix?: Prefix;
376
376
  };
377
377
  introspect?: {
378
- casing: 'camel' | 'preserve';
378
+ casing?: 'camel' | 'preserve';
379
+ /** postgres pull: set to `false` to name schema-scoped entities `userRole` instead of `userRoleInApp` */
380
+ schemaSuffix?: boolean;
379
381
  };
380
382
  entities?: {
381
383
  roles?: boolean | {
package/api.d.ts CHANGED
@@ -375,7 +375,9 @@ type Config = {
375
375
  prefix?: Prefix;
376
376
  };
377
377
  introspect?: {
378
- casing: 'camel' | 'preserve';
378
+ casing?: 'camel' | 'preserve';
379
+ /** postgres pull: set to `false` to name schema-scoped entities `userRole` instead of `userRoleInApp` */
380
+ schemaSuffix?: boolean;
379
381
  };
380
382
  entities?: {
381
383
  roles?: boolean | {
package/api.js CHANGED
@@ -24379,6 +24379,127 @@ var init_selector_ui = __esm({
24379
24379
  }
24380
24380
  });
24381
24381
 
24382
+ // ../node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
24383
+ function camelCase(input, options) {
24384
+ if (!(typeof input === "string" || Array.isArray(input))) {
24385
+ throw new TypeError("Expected the input to be `string | string[]`");
24386
+ }
24387
+ options = {
24388
+ pascalCase: false,
24389
+ preserveConsecutiveUppercase: false,
24390
+ ...options
24391
+ };
24392
+ if (Array.isArray(input)) {
24393
+ input = input.map((x5) => x5.trim()).filter((x5) => x5.length).join("-");
24394
+ } else {
24395
+ input = input.trim();
24396
+ }
24397
+ if (input.length === 0) {
24398
+ return "";
24399
+ }
24400
+ const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
24401
+ const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
24402
+ if (input.length === 1) {
24403
+ if (SEPARATORS.test(input)) {
24404
+ return "";
24405
+ }
24406
+ return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
24407
+ }
24408
+ const hasUpperCase = input !== toLowerCase(input);
24409
+ if (hasUpperCase) {
24410
+ input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
24411
+ }
24412
+ input = input.replace(LEADING_SEPARATORS, "");
24413
+ input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
24414
+ if (options.pascalCase) {
24415
+ input = toUpperCase(input.charAt(0)) + input.slice(1);
24416
+ }
24417
+ return postProcess(input, toUpperCase);
24418
+ }
24419
+ var UPPERCASE, LOWERCASE, LEADING_CAPITAL, IDENTIFIER, SEPARATORS, LEADING_SEPARATORS, SEPARATORS_AND_IDENTIFIER, NUMBERS_AND_IDENTIFIER, preserveCamelCase, preserveConsecutiveUppercase, postProcess;
24420
+ var init_camelcase = __esm({
24421
+ "../node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js"() {
24422
+ "use strict";
24423
+ UPPERCASE = /[\p{Lu}]/u;
24424
+ LOWERCASE = /[\p{Ll}]/u;
24425
+ LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
24426
+ IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
24427
+ SEPARATORS = /[_.\- ]+/;
24428
+ LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
24429
+ SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
24430
+ NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
24431
+ preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
24432
+ let isLastCharLower = false;
24433
+ let isLastCharUpper = false;
24434
+ let isLastLastCharUpper = false;
24435
+ let isLastLastCharPreserved = false;
24436
+ for (let index6 = 0; index6 < string.length; index6++) {
24437
+ const character = string[index6];
24438
+ isLastLastCharPreserved = index6 > 2 ? string[index6 - 3] === "-" : true;
24439
+ if (isLastCharLower && UPPERCASE.test(character)) {
24440
+ string = string.slice(0, index6) + "-" + string.slice(index6);
24441
+ isLastCharLower = false;
24442
+ isLastLastCharUpper = isLastCharUpper;
24443
+ isLastCharUpper = true;
24444
+ index6++;
24445
+ } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
24446
+ string = string.slice(0, index6 - 1) + "-" + string.slice(index6 - 1);
24447
+ isLastLastCharUpper = isLastCharUpper;
24448
+ isLastCharUpper = false;
24449
+ isLastCharLower = true;
24450
+ } else {
24451
+ isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
24452
+ isLastLastCharUpper = isLastCharUpper;
24453
+ isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
24454
+ }
24455
+ }
24456
+ return string;
24457
+ };
24458
+ preserveConsecutiveUppercase = (input, toLowerCase) => {
24459
+ LEADING_CAPITAL.lastIndex = 0;
24460
+ return input.replace(LEADING_CAPITAL, (m1) => toLowerCase(m1));
24461
+ };
24462
+ postProcess = (input, toUpperCase) => {
24463
+ SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
24464
+ NUMBERS_AND_IDENTIFIER.lastIndex = 0;
24465
+ return input.replace(SEPARATORS_AND_IDENTIFIER, (_3, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m6) => toUpperCase(m6));
24466
+ };
24467
+ }
24468
+ });
24469
+
24470
+ // src/@types/utils.ts
24471
+ var init_utils3 = __esm({
24472
+ "src/@types/utils.ts"() {
24473
+ "use strict";
24474
+ init_camelcase();
24475
+ String.prototype.trimChar = function(char) {
24476
+ let start = 0;
24477
+ let end = this.length;
24478
+ while (start < end && this[start] === char) ++start;
24479
+ while (end > start && this[end - 1] === char) --end;
24480
+ return start > 0 || end < this.length ? this.substring(start, end) : this.toString();
24481
+ };
24482
+ String.prototype.squashSpaces = function() {
24483
+ return this.replace(/ +/g, " ").trim();
24484
+ };
24485
+ String.prototype.camelCase = function() {
24486
+ return camelCase(String(this));
24487
+ };
24488
+ String.prototype.capitalise = function() {
24489
+ return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
24490
+ };
24491
+ String.prototype.concatIf = function(it, condition) {
24492
+ return condition ? `${this}${it}` : String(this);
24493
+ };
24494
+ String.prototype.snake_case = function() {
24495
+ return this && this.length > 0 ? `${this.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)}` : String(this);
24496
+ };
24497
+ Array.prototype.random = function() {
24498
+ return this[~~(Math.random() * this.length)];
24499
+ };
24500
+ }
24501
+ });
24502
+
24382
24503
  // src/serializer/sqliteSerializer.ts
24383
24504
  function mapSqlToSqliteType(sqlType) {
24384
24505
  const lowered = sqlType.toLowerCase();
@@ -25876,6 +25997,7 @@ var init_cli = __esm({
25876
25997
  schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
25877
25998
  extensionsFilters: literalType("postgis").array().optional(),
25878
25999
  casing,
26000
+ schemaSuffix: booleanType().optional(),
25879
26001
  breakpoints: booleanType().optional().default(true),
25880
26002
  migrations: objectType({
25881
26003
  prefix: prefix.optional().default("index")
@@ -26164,7 +26286,7 @@ var init_es5 = __esm({
26164
26286
 
26165
26287
  // src/cli/commands/utils.ts
26166
26288
  var import_hanji7, assertES5, InMemoryMutex, registerMutex, tsxRegistered, ensureTsxRegistered, safeRegister, migrateConfig;
26167
- var init_utils3 = __esm({
26289
+ var init_utils4 = __esm({
26168
26290
  "src/cli/commands/utils.ts"() {
26169
26291
  "use strict";
26170
26292
  import_hanji7 = __toESM(require_hanji());
@@ -26260,7 +26382,7 @@ var init_pgImports = __esm({
26260
26382
  import_drizzle_orm4 = require("drizzle-orm");
26261
26383
  import_pg_core2 = require("drizzle-orm/pg-core");
26262
26384
  import_relations = require("drizzle-orm/relations");
26263
- init_utils3();
26385
+ init_utils4();
26264
26386
  prepareFromExports = (exports2) => {
26265
26387
  const tables = [];
26266
26388
  const domains = [];
@@ -41517,7 +41639,7 @@ var require_semver2 = __commonJS({
41517
41639
 
41518
41640
  // src/cli/utils.ts
41519
41641
  var import_semver, checkPackage, assertPackages;
41520
- var init_utils4 = __esm({
41642
+ var init_utils5 = __esm({
41521
41643
  "src/cli/utils.ts"() {
41522
41644
  "use strict";
41523
41645
  import_semver = __toESM(require_semver2());
@@ -45721,7 +45843,7 @@ var init_evaluateRules = __esm({
45721
45843
  });
45722
45844
 
45723
45845
  // ../node_modules/.pnpm/@smithy+util-endpoints@3.0.6/node_modules/@smithy/util-endpoints/dist-es/utils/index.js
45724
- var init_utils5 = __esm({
45846
+ var init_utils6 = __esm({
45725
45847
  "../node_modules/.pnpm/@smithy+util-endpoints@3.0.6/node_modules/@smithy/util-endpoints/dist-es/utils/index.js"() {
45726
45848
  "use strict";
45727
45849
  init_customEndpointFunctions();
@@ -45736,7 +45858,7 @@ var init_resolveEndpoint = __esm({
45736
45858
  "use strict";
45737
45859
  init_debug();
45738
45860
  init_types3();
45739
- init_utils5();
45861
+ init_utils6();
45740
45862
  resolveEndpoint = (ruleSetObject, options) => {
45741
45863
  const { endpointParams, logger: logger2 } = options;
45742
45864
  const { parameters, rules } = ruleSetObject;
@@ -46350,7 +46472,7 @@ var init_getUpdatedSystemClockOffset = __esm({
46350
46472
  });
46351
46473
 
46352
46474
  // ../node_modules/.pnpm/@aws-sdk+core@3.816.0/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/index.js
46353
- var init_utils6 = __esm({
46475
+ var init_utils7 = __esm({
46354
46476
  "../node_modules/.pnpm/@aws-sdk+core@3.816.0/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/utils/index.js"() {
46355
46477
  "use strict";
46356
46478
  init_getDateHeader();
@@ -46365,7 +46487,7 @@ var init_AwsSdkSigV4Signer = __esm({
46365
46487
  "../node_modules/.pnpm/@aws-sdk+core@3.816.0/node_modules/@aws-sdk/core/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js"() {
46366
46488
  "use strict";
46367
46489
  init_dist_es2();
46368
- init_utils6();
46490
+ init_utils7();
46369
46491
  throwSigningPropertyError = (name, property) => {
46370
46492
  if (!property) {
46371
46493
  throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`);
@@ -72710,7 +72832,7 @@ var init_connections = __esm({
72710
72832
  init_wrapper();
72711
72833
  init_global();
72712
72834
  init_utils();
72713
- init_utils4();
72835
+ init_utils5();
72714
72836
  init_outputs();
72715
72837
  preparePostgresDB = async (credentials2) => {
72716
72838
  if ("driver" in credentials2) {
@@ -73739,7 +73861,7 @@ var init_studio2 = __esm({
73739
73861
  import_node_https2 = require("https");
73740
73862
  init_global();
73741
73863
  init_esm();
73742
- init_utils3();
73864
+ init_utils4();
73743
73865
  init_serializer();
73744
73866
  init_utils2();
73745
73867
  preparePgSchema = async (path3) => {
@@ -74301,7 +74423,7 @@ var init_sqliteImports = __esm({
74301
74423
  "use strict";
74302
74424
  import_drizzle_orm7 = require("drizzle-orm");
74303
74425
  import_sqlite_core3 = require("drizzle-orm/sqlite-core");
74304
- init_utils3();
74426
+ init_utils4();
74305
74427
  prepareFromExports2 = (exports2) => {
74306
74428
  const tables = [];
74307
74429
  const views = [];
@@ -74345,7 +74467,7 @@ var init_mysqlImports = __esm({
74345
74467
  "use strict";
74346
74468
  import_drizzle_orm8 = require("drizzle-orm");
74347
74469
  import_mysql_core3 = require("drizzle-orm/mysql-core");
74348
- init_utils3();
74470
+ init_utils4();
74349
74471
  prepareFromExports3 = (exports2) => {
74350
74472
  const tables = [];
74351
74473
  const views = [];
@@ -74692,7 +74814,7 @@ var init_singlestoreImports = __esm({
74692
74814
  "use strict";
74693
74815
  import_drizzle_orm9 = require("drizzle-orm");
74694
74816
  import_singlestore_core3 = require("drizzle-orm/singlestore-core");
74695
- init_utils3();
74817
+ init_utils4();
74696
74818
  prepareFromExports4 = (exports2) => {
74697
74819
  const tables = [];
74698
74820
  const i0values = Object.values(exports2);
@@ -75434,117 +75556,7 @@ init_global();
75434
75556
 
75435
75557
  // src/introspect-sqlite.ts
75436
75558
  var import_casing2 = require("drizzle-orm/casing");
75437
-
75438
- // ../node_modules/.pnpm/camelcase@7.0.1/node_modules/camelcase/index.js
75439
- var UPPERCASE = /[\p{Lu}]/u;
75440
- var LOWERCASE = /[\p{Ll}]/u;
75441
- var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
75442
- var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
75443
- var SEPARATORS = /[_.\- ]+/;
75444
- var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
75445
- var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
75446
- var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
75447
- var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
75448
- let isLastCharLower = false;
75449
- let isLastCharUpper = false;
75450
- let isLastLastCharUpper = false;
75451
- let isLastLastCharPreserved = false;
75452
- for (let index6 = 0; index6 < string.length; index6++) {
75453
- const character = string[index6];
75454
- isLastLastCharPreserved = index6 > 2 ? string[index6 - 3] === "-" : true;
75455
- if (isLastCharLower && UPPERCASE.test(character)) {
75456
- string = string.slice(0, index6) + "-" + string.slice(index6);
75457
- isLastCharLower = false;
75458
- isLastLastCharUpper = isLastCharUpper;
75459
- isLastCharUpper = true;
75460
- index6++;
75461
- } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
75462
- string = string.slice(0, index6 - 1) + "-" + string.slice(index6 - 1);
75463
- isLastLastCharUpper = isLastCharUpper;
75464
- isLastCharUpper = false;
75465
- isLastCharLower = true;
75466
- } else {
75467
- isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
75468
- isLastLastCharUpper = isLastCharUpper;
75469
- isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
75470
- }
75471
- }
75472
- return string;
75473
- };
75474
- var preserveConsecutiveUppercase = (input, toLowerCase) => {
75475
- LEADING_CAPITAL.lastIndex = 0;
75476
- return input.replace(LEADING_CAPITAL, (m1) => toLowerCase(m1));
75477
- };
75478
- var postProcess = (input, toUpperCase) => {
75479
- SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
75480
- NUMBERS_AND_IDENTIFIER.lastIndex = 0;
75481
- return input.replace(SEPARATORS_AND_IDENTIFIER, (_3, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m6) => toUpperCase(m6));
75482
- };
75483
- function camelCase(input, options) {
75484
- if (!(typeof input === "string" || Array.isArray(input))) {
75485
- throw new TypeError("Expected the input to be `string | string[]`");
75486
- }
75487
- options = {
75488
- pascalCase: false,
75489
- preserveConsecutiveUppercase: false,
75490
- ...options
75491
- };
75492
- if (Array.isArray(input)) {
75493
- input = input.map((x5) => x5.trim()).filter((x5) => x5.length).join("-");
75494
- } else {
75495
- input = input.trim();
75496
- }
75497
- if (input.length === 0) {
75498
- return "";
75499
- }
75500
- const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
75501
- const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
75502
- if (input.length === 1) {
75503
- if (SEPARATORS.test(input)) {
75504
- return "";
75505
- }
75506
- return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
75507
- }
75508
- const hasUpperCase = input !== toLowerCase(input);
75509
- if (hasUpperCase) {
75510
- input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
75511
- }
75512
- input = input.replace(LEADING_SEPARATORS, "");
75513
- input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
75514
- if (options.pascalCase) {
75515
- input = toUpperCase(input.charAt(0)) + input.slice(1);
75516
- }
75517
- return postProcess(input, toUpperCase);
75518
- }
75519
-
75520
- // src/@types/utils.ts
75521
- String.prototype.trimChar = function(char) {
75522
- let start = 0;
75523
- let end = this.length;
75524
- while (start < end && this[start] === char) ++start;
75525
- while (end > start && this[end - 1] === char) --end;
75526
- return start > 0 || end < this.length ? this.substring(start, end) : this.toString();
75527
- };
75528
- String.prototype.squashSpaces = function() {
75529
- return this.replace(/ +/g, " ").trim();
75530
- };
75531
- String.prototype.camelCase = function() {
75532
- return camelCase(String(this));
75533
- };
75534
- String.prototype.capitalise = function() {
75535
- return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
75536
- };
75537
- String.prototype.concatIf = function(it, condition) {
75538
- return condition ? `${this}${it}` : String(this);
75539
- };
75540
- String.prototype.snake_case = function() {
75541
- return this && this.length > 0 ? `${this.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)}` : String(this);
75542
- };
75543
- Array.prototype.random = function() {
75544
- return this[~~(Math.random() * this.length)];
75545
- };
75546
-
75547
- // src/introspect-sqlite.ts
75559
+ init_utils3();
75548
75560
  init_global();
75549
75561
 
75550
75562
  // src/cli/commands/sqliteIntrospect.ts