prisma-sql 1.23.0 → 1.25.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.
@@ -56,7 +56,7 @@ var require_package = __commonJS({
56
56
  "package.json"(exports$1, module) {
57
57
  module.exports = {
58
58
  name: "prisma-sql",
59
- version: "1.23.0",
59
+ version: "1.25.0",
60
60
  description: "Convert Prisma queries to optimized SQL with type safety. 2-7x faster than Prisma Client.",
61
61
  main: "dist/index.cjs",
62
62
  module: "dist/index.js",
@@ -83,6 +83,9 @@ var require_package = __commonJS({
83
83
  ],
84
84
  scripts: {
85
85
  build: "tsup",
86
+ "docs:dev": "yarn --cwd docs-site dev",
87
+ "docs:build": "yarn --cwd docs-site build",
88
+ "docs:preview": "yarn --cwd docs-site preview",
86
89
  test: "vitest",
87
90
  "test:coverage": "vitest --coverage",
88
91
  "test:e2e": "vitest run tests/e2e",
@@ -124,16 +127,16 @@ var require_package = __commonJS({
124
127
  },
125
128
  devDependencies: {
126
129
  "@faker-js/faker": "^10.2.0",
127
- "@prisma/adapter-better-sqlite3": "^6.16.3",
128
- "@prisma/adapter-pg": "^6.16.3",
129
- "@prisma/client": "6.16.3",
130
+ "@prisma/adapter-better-sqlite3": "^7.2.0",
131
+ "@prisma/adapter-pg": "^7.2.0",
132
+ "@prisma/client": "7.2.0",
130
133
  "@types/better-sqlite3": "^7.6.13",
131
134
  "@types/node": "^20.0.0",
132
135
  "better-sqlite3": "^12.6.2",
133
136
  "drizzle-kit": "^0.31.8",
134
137
  "drizzle-orm": "^0.45.1",
135
138
  postgres: "^3.4.8",
136
- prisma: "6.16.3",
139
+ prisma: "7.2.0",
137
140
  tsup: "^8.5.1",
138
141
  tsx: "^4.7.0",
139
142
  typescript: "^5.3.3",
@@ -792,8 +795,140 @@ var NUL = String.fromCharCode(0);
792
795
  function containsControlChars(s) {
793
796
  return s.includes(NUL) || s.includes("\n") || s.includes("\r");
794
797
  }
795
- function containsUnsafeSqlFragmentChars(s) {
796
- return containsControlChars(s) || s.includes(";");
798
+ function assertNoControlChars(label, s) {
799
+ if (containsControlChars(s)) {
800
+ throw new Error(
801
+ `${label} contains invalid characters: ${JSON.stringify(s)}`
802
+ );
803
+ }
804
+ }
805
+ function isIdentCharCode(c) {
806
+ return c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95;
807
+ }
808
+ function isIdentStartCharCode(c) {
809
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95;
810
+ }
811
+ function parseQuotedPart(input, start) {
812
+ const n = input.length;
813
+ let i = start + 1;
814
+ let sawAny = false;
815
+ while (i < n) {
816
+ const c = input.charCodeAt(i);
817
+ if (c === 34) {
818
+ const next = i + 1;
819
+ if (next < n && input.charCodeAt(next) === 34) {
820
+ sawAny = true;
821
+ i += 2;
822
+ continue;
823
+ }
824
+ if (!sawAny) {
825
+ throw new Error(
826
+ `tableName/tableRef has empty quoted identifier part: ${JSON.stringify(input)}`
827
+ );
828
+ }
829
+ return i + 1;
830
+ }
831
+ if (c === 10 || c === 13 || c === 0) {
832
+ throw new Error(
833
+ `tableName/tableRef contains invalid characters: ${JSON.stringify(input)}`
834
+ );
835
+ }
836
+ sawAny = true;
837
+ i++;
838
+ }
839
+ throw new Error(
840
+ `tableName/tableRef has unterminated quoted identifier: ${JSON.stringify(input)}`
841
+ );
842
+ }
843
+ function parseUnquotedPart(input, start) {
844
+ const n = input.length;
845
+ let i = start;
846
+ if (i >= n) {
847
+ throw new Error(`tableName/tableRef is invalid: ${JSON.stringify(input)}`);
848
+ }
849
+ const c0 = input.charCodeAt(i);
850
+ if (!isIdentStartCharCode(c0)) {
851
+ throw new Error(
852
+ `tableName/tableRef must use identifiers (or quoted identifiers). Got: ${JSON.stringify(input)}`
853
+ );
854
+ }
855
+ i++;
856
+ while (i < n) {
857
+ const c = input.charCodeAt(i);
858
+ if (c === 46) break;
859
+ if (!isIdentCharCode(c)) {
860
+ throw new Error(
861
+ `tableName/tableRef contains invalid identifier characters: ${JSON.stringify(input)}`
862
+ );
863
+ }
864
+ i++;
865
+ }
866
+ return i;
867
+ }
868
+ function assertSafeQualifiedName(tableRef) {
869
+ const raw = String(tableRef);
870
+ const trimmed = raw.trim();
871
+ if (trimmed.length === 0) {
872
+ throw new Error("tableName/tableRef is required and cannot be empty");
873
+ }
874
+ if (raw !== trimmed) {
875
+ throw new Error(
876
+ `tableName/tableRef must not contain leading/trailing whitespace: ${JSON.stringify(raw)}`
877
+ );
878
+ }
879
+ assertNoControlChars("tableName/tableRef", trimmed);
880
+ for (let i2 = 0; i2 < trimmed.length; i2++) {
881
+ const c = trimmed.charCodeAt(i2);
882
+ if (c === 9 || c === 11 || c === 12 || c === 32) {
883
+ throw new Error(
884
+ `tableName/tableRef must not contain whitespace: ${JSON.stringify(trimmed)}`
885
+ );
886
+ }
887
+ if (c === 59) {
888
+ throw new Error(
889
+ `tableName/tableRef must not contain ';': ${JSON.stringify(trimmed)}`
890
+ );
891
+ }
892
+ if (c === 40 || c === 41) {
893
+ throw new Error(
894
+ `tableName/tableRef must not contain parentheses: ${JSON.stringify(trimmed)}`
895
+ );
896
+ }
897
+ }
898
+ let i = 0;
899
+ const n = trimmed.length;
900
+ let parts = 0;
901
+ while (i < n) {
902
+ const c = trimmed.charCodeAt(i);
903
+ if (c === 46) {
904
+ throw new Error(
905
+ `tableName/tableRef has empty identifier part: ${JSON.stringify(trimmed)}`
906
+ );
907
+ }
908
+ if (c === 34) {
909
+ i = parseQuotedPart(trimmed, i);
910
+ } else {
911
+ i = parseUnquotedPart(trimmed, i);
912
+ }
913
+ parts++;
914
+ if (parts > 2) {
915
+ throw new Error(
916
+ `tableName/tableRef must be 'table' or 'schema.table' (max 2 parts). Got: ${JSON.stringify(trimmed)}`
917
+ );
918
+ }
919
+ if (i === n) break;
920
+ if (trimmed.charCodeAt(i) !== 46) {
921
+ throw new Error(
922
+ `tableName/tableRef is invalid: ${JSON.stringify(trimmed)}`
923
+ );
924
+ }
925
+ i++;
926
+ if (i === n) {
927
+ throw new Error(
928
+ `tableName/tableRef cannot end with '.': ${JSON.stringify(trimmed)}`
929
+ );
930
+ }
931
+ }
797
932
  }
798
933
  function quote(id) {
799
934
  if (isEmptyString(id)) {
@@ -858,7 +993,7 @@ function assertSafeAlias(alias) {
858
993
  if (a.trim().length === 0) {
859
994
  throw new Error("alias is required and cannot be empty");
860
995
  }
861
- if (containsUnsafeSqlFragmentChars(a)) {
996
+ if (containsControlChars(a) || a.includes(";")) {
862
997
  throw new Error(`alias contains unsafe characters: ${JSON.stringify(a)}`);
863
998
  }
864
999
  if (!/^[A-Za-z_]\w*$/.test(a)) {
@@ -868,15 +1003,7 @@ function assertSafeAlias(alias) {
868
1003
  }
869
1004
  }
870
1005
  function assertSafeTableRef(tableRef) {
871
- const t = String(tableRef);
872
- if (t.trim().length === 0) {
873
- throw new Error("tableName/tableRef is required and cannot be empty");
874
- }
875
- if (containsUnsafeSqlFragmentChars(t)) {
876
- throw new Error(
877
- `tableName/tableRef contains unsafe characters: ${JSON.stringify(t)}`
878
- );
879
- }
1006
+ assertSafeQualifiedName(tableRef);
880
1007
  }
881
1008
  function normalizeKeyList(input) {
882
1009
  if (!isNotNullish(input)) return [];