@prisma/studio-core 0.0.0-dev.202504232346 → 0.0.0-dev.202504240132

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.
@@ -1,6 +1,5 @@
1
- import { A as Adapter, g as AdapterInsertDetails, c as AdapterQueryDetails } from '../../adapter-CC0i4hSp.cjs';
2
- import { E as Executor, B as BuilderRequirements, Q as Query, a as QueryResult } from '../../executor-DbZM00RR.cjs';
3
- import '../../type-utils-u92OZz8n.cjs';
1
+ import { A as Adapter, T as Table, a as AdapterInsertDetails, b as AdapterQueryDetails, c as AdapterUpdateDetails } from '../../adapter-DaDiAEIc.cjs';
2
+ import { E as Executor, B as BuilderRequirements, Q as Query } from '../../index-BdmWpbSo.cjs';
4
3
  import 'kysely';
5
4
 
6
5
  interface PostgresAdapterRequirements {
@@ -8,6 +7,15 @@ interface PostgresAdapterRequirements {
8
7
  noParameters?: boolean;
9
8
  }
10
9
  declare function createPostgresAdapter(requirements: PostgresAdapterRequirements): Adapter;
10
+ /**
11
+ * For testing purposes.
12
+ */
13
+ declare function mockIntrospect(): {
14
+ schemas: { [K in "public"]: {
15
+ tables: { [T in "users"]: Table; };
16
+ }; };
17
+ timezone: "UTC";
18
+ };
11
19
 
12
20
  /**
13
21
  * `ctid` is a system column that represents the physical location of a row in a table.
@@ -39,7 +47,30 @@ declare function getSelectQuery(details: AdapterQueryDetails, requirements?: Omi
39
47
  /**
40
48
  * For testing purposes.
41
49
  */
42
- declare function mockSelectQuery(): QueryResult<typeof getSelectQuery>;
50
+ declare function mockSelectQuery(): [{
51
+ readonly created_at: Date;
52
+ readonly ctid: "(0,1)";
53
+ readonly deleted_at: null;
54
+ readonly id: 1;
55
+ readonly name: "John Doe";
56
+ readonly oid: "2";
57
+ readonly role: "admin";
58
+ }, {
59
+ readonly created_at: Date;
60
+ readonly ctid: "(0,2)";
61
+ readonly deleted_at: null;
62
+ readonly id: 2;
63
+ readonly name: "Jane Doe";
64
+ readonly oid: "2";
65
+ readonly role: "poweruser";
66
+ }];
67
+ /**
68
+ * Returns a query that updates a given row in a table with given changes.
69
+ */
70
+ declare function getUpdateQuery(details: AdapterUpdateDetails, requirements?: Omit<BuilderRequirements, "Adapter" | "QueryCompiler">): Query<{
71
+ [x: string]: unknown;
72
+ ctid: `(${number},${number})`;
73
+ }>;
43
74
 
44
75
  /**
45
76
  * Returns a query that returns metadata for all user-defined tables and views in the database.
@@ -56,13 +87,42 @@ declare function getTablesQuery(requirements?: Omit<BuilderRequirements, "Adapte
56
87
  /**
57
88
  * For testing purposes.
58
89
  */
59
- declare function mockTablesQuery(): QueryResult<typeof getTablesQuery>;
90
+ declare function mockTablesQuery(): [{
91
+ readonly schema: "public";
92
+ readonly name: "users";
93
+ readonly columns: [{
94
+ readonly name: "id";
95
+ readonly datatype: "bigint";
96
+ readonly pk: true;
97
+ }, {
98
+ readonly name: "name";
99
+ readonly datatype: "varchar";
100
+ readonly pk: false;
101
+ }, {
102
+ readonly name: "role";
103
+ readonly datatype: "varchar";
104
+ readonly pk: false;
105
+ }, {
106
+ readonly name: "created_at";
107
+ readonly datatype: "timestamptz";
108
+ readonly pk: false;
109
+ }, {
110
+ readonly name: "deleted_at";
111
+ readonly datatype: "timestamptz";
112
+ readonly pk: false;
113
+ }];
114
+ }];
60
115
  /**
61
116
  * Returns a query that returns the current timezone setting of the PostgreSQL database.
62
117
  */
63
118
  declare function getTimezoneQuery(): Query<{
64
119
  timezone: string;
65
120
  }>;
66
- declare function mockTimezoneQuery(): QueryResult<typeof getTimezoneQuery>;
121
+ /**
122
+ * For testing purposes.
123
+ */
124
+ declare function mockTimezoneQuery(): [{
125
+ readonly timezone: "UTC";
126
+ }];
67
127
 
68
- export { type CTIDasText, type PostgresAdapterRequirements, createPostgresAdapter, getInsertQuery, getSelectQuery, getTablesQuery, getTimezoneQuery, mockSelectQuery, mockTablesQuery, mockTimezoneQuery };
128
+ export { type CTIDasText, type PostgresAdapterRequirements, createPostgresAdapter, getInsertQuery, getSelectQuery, getTablesQuery, getTimezoneQuery, getUpdateQuery, mockIntrospect, mockSelectQuery, mockTablesQuery, mockTimezoneQuery };
@@ -1,6 +1,5 @@
1
- import { A as Adapter, g as AdapterInsertDetails, c as AdapterQueryDetails } from '../../adapter-nXopQslT.js';
2
- import { E as Executor, B as BuilderRequirements, Q as Query, a as QueryResult } from '../../executor-DI7JTcqO.js';
3
- import '../../type-utils-u92OZz8n.js';
1
+ import { A as Adapter, T as Table, a as AdapterInsertDetails, b as AdapterQueryDetails, c as AdapterUpdateDetails } from '../../adapter-DaDiAEIc.js';
2
+ import { E as Executor, B as BuilderRequirements, Q as Query } from '../../index-B9iKA_pF.js';
4
3
  import 'kysely';
5
4
 
6
5
  interface PostgresAdapterRequirements {
@@ -8,6 +7,15 @@ interface PostgresAdapterRequirements {
8
7
  noParameters?: boolean;
9
8
  }
10
9
  declare function createPostgresAdapter(requirements: PostgresAdapterRequirements): Adapter;
10
+ /**
11
+ * For testing purposes.
12
+ */
13
+ declare function mockIntrospect(): {
14
+ schemas: { [K in "public"]: {
15
+ tables: { [T in "users"]: Table; };
16
+ }; };
17
+ timezone: "UTC";
18
+ };
11
19
 
12
20
  /**
13
21
  * `ctid` is a system column that represents the physical location of a row in a table.
@@ -39,7 +47,30 @@ declare function getSelectQuery(details: AdapterQueryDetails, requirements?: Omi
39
47
  /**
40
48
  * For testing purposes.
41
49
  */
42
- declare function mockSelectQuery(): QueryResult<typeof getSelectQuery>;
50
+ declare function mockSelectQuery(): [{
51
+ readonly created_at: Date;
52
+ readonly ctid: "(0,1)";
53
+ readonly deleted_at: null;
54
+ readonly id: 1;
55
+ readonly name: "John Doe";
56
+ readonly oid: "2";
57
+ readonly role: "admin";
58
+ }, {
59
+ readonly created_at: Date;
60
+ readonly ctid: "(0,2)";
61
+ readonly deleted_at: null;
62
+ readonly id: 2;
63
+ readonly name: "Jane Doe";
64
+ readonly oid: "2";
65
+ readonly role: "poweruser";
66
+ }];
67
+ /**
68
+ * Returns a query that updates a given row in a table with given changes.
69
+ */
70
+ declare function getUpdateQuery(details: AdapterUpdateDetails, requirements?: Omit<BuilderRequirements, "Adapter" | "QueryCompiler">): Query<{
71
+ [x: string]: unknown;
72
+ ctid: `(${number},${number})`;
73
+ }>;
43
74
 
44
75
  /**
45
76
  * Returns a query that returns metadata for all user-defined tables and views in the database.
@@ -56,13 +87,42 @@ declare function getTablesQuery(requirements?: Omit<BuilderRequirements, "Adapte
56
87
  /**
57
88
  * For testing purposes.
58
89
  */
59
- declare function mockTablesQuery(): QueryResult<typeof getTablesQuery>;
90
+ declare function mockTablesQuery(): [{
91
+ readonly schema: "public";
92
+ readonly name: "users";
93
+ readonly columns: [{
94
+ readonly name: "id";
95
+ readonly datatype: "bigint";
96
+ readonly pk: true;
97
+ }, {
98
+ readonly name: "name";
99
+ readonly datatype: "varchar";
100
+ readonly pk: false;
101
+ }, {
102
+ readonly name: "role";
103
+ readonly datatype: "varchar";
104
+ readonly pk: false;
105
+ }, {
106
+ readonly name: "created_at";
107
+ readonly datatype: "timestamptz";
108
+ readonly pk: false;
109
+ }, {
110
+ readonly name: "deleted_at";
111
+ readonly datatype: "timestamptz";
112
+ readonly pk: false;
113
+ }];
114
+ }];
60
115
  /**
61
116
  * Returns a query that returns the current timezone setting of the PostgreSQL database.
62
117
  */
63
118
  declare function getTimezoneQuery(): Query<{
64
119
  timezone: string;
65
120
  }>;
66
- declare function mockTimezoneQuery(): QueryResult<typeof getTimezoneQuery>;
121
+ /**
122
+ * For testing purposes.
123
+ */
124
+ declare function mockTimezoneQuery(): [{
125
+ readonly timezone: "UTC";
126
+ }];
67
127
 
68
- export { type CTIDasText, type PostgresAdapterRequirements, createPostgresAdapter, getInsertQuery, getSelectQuery, getTablesQuery, getTimezoneQuery, mockSelectQuery, mockTablesQuery, mockTimezoneQuery };
128
+ export { type CTIDasText, type PostgresAdapterRequirements, createPostgresAdapter, getInsertQuery, getSelectQuery, getTablesQuery, getTimezoneQuery, getUpdateQuery, mockIntrospect, mockSelectQuery, mockTablesQuery, mockTimezoneQuery };
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"../../chunk-M25YHYR5.js";import"../../chunk-2FW6TKD6.js";export{h as createPostgresAdapter,a as getInsertQuery,b as getSelectQuery,d as getTablesQuery,f as getTimezoneQuery,c as mockSelectQuery,e as mockTablesQuery,g as mockTimezoneQuery};
1
+ import{a,b,c,d,e,f,g,h,i,j}from"../../chunk-O3FFLQK6.js";import"../../chunk-FM7CI5YG.js";import"../../chunk-2FW6TKD6.js";export{i as createPostgresAdapter,a as getInsertQuery,b as getSelectQuery,e as getTablesQuery,g as getTimezoneQuery,d as getUpdateQuery,j as mockIntrospect,c as mockSelectQuery,f as mockTablesQuery,h as mockTimezoneQuery};
@@ -1,5 +1,5 @@
1
- import { DialectAdapter, QueryCompiler } from 'kysely';
2
- import { E as Either } from './type-utils-u92OZz8n.cjs';
1
+ import { T as Table, E as Either } from './adapter-DaDiAEIc.js';
2
+ import { WhereInterface, DialectAdapter, QueryCompiler } from 'kysely';
3
3
 
4
4
  interface BuilderRequirements {
5
5
  Adapter: {
@@ -17,6 +17,12 @@ interface Query<T = unknown> {
17
17
  sql: string;
18
18
  }
19
19
  type QueryResult<T> = T extends Query<infer R> ? R[] : T extends (...args: any[]) => Query<infer R> ? R[] : never;
20
+ /**
21
+ * Applies a filter to the given row based on the primary key columns of the table.
22
+ *
23
+ * @example db.selectFrom("users").$call(applyInferredFilter(row, columns)).selectAll()
24
+ */
25
+ declare function applyInferredFilter(row: Record<string, unknown>, columns: Table["columns"]): <QB extends WhereInterface<any, any>>(qb: QB) => QB;
20
26
 
21
27
  interface Executor {
22
28
  execute<Q extends Query>(query: Q, options?: ExecuteOptions): Promise<Either<Error, QueryResult<Q>>>;
@@ -25,4 +31,4 @@ interface ExecuteOptions {
25
31
  abortSignal?: AbortSignal;
26
32
  }
27
33
 
28
- export type { BuilderRequirements as B, Executor as E, Query as Q, QueryResult as a, ExecuteOptions as b };
34
+ export { type BuilderRequirements as B, type Executor as E, type Query as Q, type ExecuteOptions as a, type QueryResult as b, applyInferredFilter as c };
@@ -1,5 +1,5 @@
1
- import { DialectAdapter, QueryCompiler } from 'kysely';
2
- import { E as Either } from './type-utils-u92OZz8n.js';
1
+ import { T as Table, E as Either } from './adapter-DaDiAEIc.cjs';
2
+ import { WhereInterface, DialectAdapter, QueryCompiler } from 'kysely';
3
3
 
4
4
  interface BuilderRequirements {
5
5
  Adapter: {
@@ -17,6 +17,12 @@ interface Query<T = unknown> {
17
17
  sql: string;
18
18
  }
19
19
  type QueryResult<T> = T extends Query<infer R> ? R[] : T extends (...args: any[]) => Query<infer R> ? R[] : never;
20
+ /**
21
+ * Applies a filter to the given row based on the primary key columns of the table.
22
+ *
23
+ * @example db.selectFrom("users").$call(applyInferredFilter(row, columns)).selectAll()
24
+ */
25
+ declare function applyInferredFilter(row: Record<string, unknown>, columns: Table["columns"]): <QB extends WhereInterface<any, any>>(qb: QB) => QB;
20
26
 
21
27
  interface Executor {
22
28
  execute<Q extends Query>(query: Q, options?: ExecuteOptions): Promise<Either<Error, QueryResult<Q>>>;
@@ -25,4 +31,4 @@ interface ExecuteOptions {
25
31
  abortSignal?: AbortSignal;
26
32
  }
27
33
 
28
- export type { BuilderRequirements as B, Executor as E, Query as Q, QueryResult as a, ExecuteOptions as b };
34
+ export { type BuilderRequirements as B, type Executor as E, type Query as Q, type ExecuteOptions as a, type QueryResult as b, applyInferredFilter as c };