Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove data api sdk base #1533

Open
wants to merge 203 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
889702c
Start pre mode
SferaDev Dec 19, 2023
e9c165d
Init version 1.0
SferaDev Dec 19, 2023
aaa332d
Make XataApiClient to use ES Proxies (#1287)
SferaDev Jan 9, 2024
fcb0e43
Remove cache implementation (#1368)
SferaDev Apr 9, 2024
86322d4
Update pgroll spec
SferaDev Feb 27, 2024
7c87f6f
Fix release in next channel
SferaDev Feb 27, 2024
a8e801d
Rename internal columns breaking change (#1370)
SferaDev Feb 28, 2024
c7d8a8f
Update test to allow postgres (#1396)
SferaDev Mar 6, 2024
30f7fe0
Fix drizzle tests in `next` (#1417)
SferaDev Mar 21, 2024
6f526c2
fix: generate data native types (#1412)
eemmiillyy Mar 22, 2024
47a1c5f
Wait for completion on `pgroll` migration push (#1434)
andrew-farries Apr 9, 2024
ba9204a
feat: pgroll cli edit (#1430)
eemmiillyy May 3, 2024
c44339e
Breaking changes to codegen (#1371)
SferaDev May 6, 2024
3c248a3
fix: next build (#1472)
eemmiillyy May 7, 2024
029c961
use new repo
eemmiillyy May 6, 2024
622491c
undo
eemmiillyy May 6, 2024
94ed5dd
wip
eemmiillyy May 6, 2024
95578c5
duplicate plugin
eemmiillyy May 7, 2024
5273c54
basic creates working
eemmiillyy May 8, 2024
6d4ede0
deletes
eemmiillyy May 8, 2024
a9fa95a
update and read
eemmiillyy May 8, 2024
987dfa7
wip
eemmiillyy May 13, 2024
d933edf
wip
eemmiillyy May 14, 2024
565ca72
ignore filters
eemmiillyy May 14, 2024
3c98c9e
feat: pgroll support import (#1470)
eemmiillyy May 14, 2024
7ee1aa9
offset pagination
eemmiillyy May 14, 2024
b1c2c9c
decode after for cursor offset
eemmiillyy May 14, 2024
67bf982
override
eemmiillyy May 14, 2024
99f9e0d
support after, before, start, end
eemmiillyy May 15, 2024
6ebf1c8
clean up
eemmiillyy May 15, 2024
f53ab57
unskip
eemmiillyy May 15, 2024
e43f065
clean up
eemmiillyy May 15, 2024
e87c53d
fix create transactions
eemmiillyy May 16, 2024
1687c5c
fix transactions for delete, createOrReplace, createOrUpdate, update
eemmiillyy May 16, 2024
bbc0736
fix record.replace
eemmiillyy May 16, 2024
c8790de
clean up
eemmiillyy May 16, 2024
0830756
Merge branch 'next' into feat/remove-data-api-sdk
eemmiillyy May 16, 2024
e954e1a
random sort
eemmiillyy May 16, 2024
c3795a3
upsert
eemmiillyy May 16, 2024
5ca2ccb
update numeric
eemmiillyy May 17, 2024
11a68f2
Start pre mode
SferaDev Dec 19, 2023
4c6bf38
Init version 1.0
SferaDev Dec 19, 2023
5e2bd00
Make XataApiClient to use ES Proxies (#1287)
SferaDev Jan 9, 2024
3086783
Remove cache implementation (#1368)
SferaDev Apr 9, 2024
b30861a
Update pgroll spec
SferaDev Feb 27, 2024
e7bf45b
Fix release in next channel
SferaDev Feb 27, 2024
1b8dc43
Rename internal columns breaking change (#1370)
SferaDev Feb 28, 2024
ef4a5be
Update test to allow postgres (#1396)
SferaDev Mar 6, 2024
df18a26
Fix drizzle tests in `next` (#1417)
SferaDev Mar 21, 2024
a5628d3
fix: generate data native types (#1412)
eemmiillyy Mar 22, 2024
c9d45dc
Wait for completion on `pgroll` migration push (#1434)
andrew-farries Apr 9, 2024
6782cf1
feat: pgroll cli edit (#1430)
eemmiillyy May 3, 2024
2e4f9ca
Breaking changes to codegen (#1371)
SferaDev May 6, 2024
ed9f27f
fix: next build (#1472)
eemmiillyy May 7, 2024
e109eee
feat: pgroll support import (#1470)
eemmiillyy May 14, 2024
bf42b87
basic query filtering
eemmiillyy May 21, 2024
7fe6a8a
more operations
eemmiillyy May 22, 2024
fc26bd0
all filters and new tests
eemmiillyy May 22, 2024
cfe048f
fix pagination
eemmiillyy May 22, 2024
b8fcb19
tests
eemmiillyy May 22, 2024
ac090ac
transaction
eemmiillyy May 22, 2024
4943200
fix types
eemmiillyy May 23, 2024
677cecd
Merge branch 'next' into feat/remove-data-api-sdk
eemmiillyy May 23, 2024
af38c4b
Add pagination support in `xata pull` (#1477)
SferaDev May 23, 2024
a15edf1
json filters
eemmiillyy May 23, 2024
213003c
simplify record ops
eemmiillyy May 23, 2024
620e2cd
fix json tests
eemmiillyy May 24, 2024
98b7085
new tests
eemmiillyy May 27, 2024
44f15e0
tests
eemmiillyy May 27, 2024
50eaa55
Merge branch 'next' into feat/remove-data-api-sdk
eemmiillyy May 27, 2024
1cda902
fix json tests
eemmiillyy May 27, 2024
36ac8dc
fix date test
eemmiillyy May 27, 2024
47158e6
fix iterator test
eemmiillyy May 27, 2024
8d4a24f
build
eemmiillyy May 27, 2024
d250e98
fix schema tests
eemmiillyy May 27, 2024
7c7c82d
fix all schema tests
eemmiillyy May 27, 2024
1d834aa
fix all tests
eemmiillyy May 28, 2024
a98e55c
fix shcema tests
eemmiillyy May 28, 2024
e8cc295
fix more
eemmiillyy May 28, 2024
0c43a3f
Start pre mode
SferaDev Dec 19, 2023
9479881
Init version 1.0
SferaDev Dec 19, 2023
20849f3
Make XataApiClient to use ES Proxies (#1287)
SferaDev Jan 9, 2024
1288968
Remove cache implementation (#1368)
SferaDev Apr 9, 2024
66f7c24
Update pgroll spec
SferaDev Feb 27, 2024
f0dee62
Fix release in next channel
SferaDev Feb 27, 2024
1c9c5c4
Rename internal columns breaking change (#1370)
SferaDev Feb 28, 2024
518dd50
Update test to allow postgres (#1396)
SferaDev Mar 6, 2024
0d4ef23
Fix drizzle tests in `next` (#1417)
SferaDev Mar 21, 2024
9487a6f
fix: generate data native types (#1412)
eemmiillyy Mar 22, 2024
bcbc9c8
Wait for completion on `pgroll` migration push (#1434)
andrew-farries Apr 9, 2024
82dad04
feat: pgroll cli edit (#1430)
eemmiillyy May 3, 2024
853e43b
Breaking changes to codegen (#1371)
SferaDev May 6, 2024
0f17dae
fix: next build (#1472)
eemmiillyy May 7, 2024
7f7f14e
feat: pgroll support import (#1470)
eemmiillyy May 14, 2024
5bc7e82
Add pagination support in `xata pull` (#1477)
SferaDev May 23, 2024
826f308
only map filters once
eemmiillyy May 29, 2024
9742b53
Merge branch 'next' into feat/remove-data-api-sdk
eemmiillyy May 29, 2024
0e7b22e
lock
eemmiillyy May 29, 2024
91790c1
delete revlinks
eemmiillyy May 29, 2024
c00119a
Start pre mode
SferaDev Dec 19, 2023
0a60b36
Init version 1.0
SferaDev Dec 19, 2023
1b0b1a0
Make XataApiClient to use ES Proxies (#1287)
SferaDev Jan 9, 2024
894a5d4
Remove cache implementation (#1368)
SferaDev Apr 9, 2024
88f8cd9
Update pgroll spec
SferaDev Feb 27, 2024
29ec8b7
Fix release in next channel
SferaDev Feb 27, 2024
df2aff7
Rename internal columns breaking change (#1370)
SferaDev Feb 28, 2024
a2dfacc
Update test to allow postgres (#1396)
SferaDev Mar 6, 2024
3a9fba5
Fix drizzle tests in `next` (#1417)
SferaDev Mar 21, 2024
205bae7
fix: generate data native types (#1412)
eemmiillyy Mar 22, 2024
f03f054
Wait for completion on `pgroll` migration push (#1434)
andrew-farries Apr 9, 2024
da29040
feat: pgroll cli edit (#1430)
eemmiillyy May 3, 2024
a2a75cf
Breaking changes to codegen (#1371)
SferaDev May 6, 2024
69defe4
fix: next build (#1472)
eemmiillyy May 7, 2024
e6714ee
feat: pgroll support import (#1470)
eemmiillyy May 14, 2024
0b9131e
Add pagination support in `xata pull` (#1477)
SferaDev May 23, 2024
071d798
Merge branch 'next' into HEAD
eemmiillyy May 29, 2024
89529ee
use real transactions sql endpoint
eemmiillyy May 29, 2024
03f45da
refactor: filters
eemmiillyy May 29, 2024
0684b0d
refactor: remove ifVersion for kysely
eemmiillyy May 29, 2024
45fcff2
clean warnings
eemmiillyy May 29, 2024
6b02b15
always sort
eemmiillyy May 30, 2024
6359923
always sort
eemmiillyy May 30, 2024
ab94955
update schema tests
eemmiillyy May 30, 2024
4cd23f6
more updating primarykey
eemmiillyy May 30, 2024
3ba9e5b
wait for promises before returning
eemmiillyy May 30, 2024
0a1c479
clean
eemmiillyy May 30, 2024
e04b6de
Move packages to be re-used
SferaDev May 30, 2024
16b5c66
Apply suggestions from code review
SferaDev May 30, 2024
4e67c94
Merge remote-tracking branch 'origin/packages-monorepo' into feat/rem…
eemmiillyy May 31, 2024
76be411
remove duplicated code
eemmiillyy May 31, 2024
ed6b4c3
pr changes
eemmiillyy May 31, 2024
b0ebefe
remove unused deps
eemmiillyy May 31, 2024
c2f813c
codegen snapshots
eemmiillyy May 31, 2024
327f0fc
remove revlinks
eemmiillyy Jun 3, 2024
f9406cc
replace BaseData with NewIdentifiable
eemmiillyy Jun 5, 2024
d8e3dd5
dynamic primary key types
eemmiillyy Jun 5, 2024
974ed18
make sure identifiable.spec runs
eemmiillyy Jun 5, 2024
66c9bc4
Add missing new identifier types
eemmiillyy Jun 6, 2024
f46ca7a
id as string or number
eemmiillyy Jun 6, 2024
1af1f22
Refactor schema types
SferaDev Jun 7, 2024
0c751fc
More refactor
SferaDev Jun 7, 2024
e5f6373
Update snapshots
SferaDev Jun 7, 2024
a2dd363
Updates
SferaDev Jun 7, 2024
af8bc72
Merge branch 'schema-types' into feat/remove-data-api-sdk
eemmiillyy Jun 10, 2024
1906bf3
fix types
eemmiillyy Jun 10, 2024
1b02a3c
use local client in importer
eemmiillyy Jun 11, 2024
efe95d4
fix tests
eemmiillyy Jun 11, 2024
33152cf
fake test
eemmiillyy Jun 11, 2024
e0fa2c3
update types
eemmiillyy Jun 11, 2024
463d167
fix link type
eemmiillyy Jun 11, 2024
c6a38c5
types
eemmiillyy Jun 11, 2024
cd172ea
wip links
eemmiillyy Jun 14, 2024
9168630
add support for querying links
eemmiillyy Jun 17, 2024
0b60cc1
link selection
eemmiillyy Jun 19, 2024
a41001c
remove console
eemmiillyy Jun 19, 2024
3f68e90
fix test
eemmiillyy Jun 19, 2024
3e3838f
wip link filtering
eemmiillyy Jun 20, 2024
0937462
fix json tests
eemmiillyy Jun 21, 2024
12c02a0
clean
eemmiillyy Jun 25, 2024
0997ed3
relevant filters fx
eemmiillyy Jul 3, 2024
e6ddfbc
tests
eemmiillyy Jul 4, 2024
8c93505
fix sql wrapper
eemmiillyy Jul 4, 2024
cbc5db7
Start pre mode
SferaDev Dec 19, 2023
8b79ea3
Init version 1.0
SferaDev Dec 19, 2023
6cbb2f8
Make XataApiClient to use ES Proxies (#1287)
SferaDev Jan 9, 2024
70642e5
Remove cache implementation (#1368)
SferaDev Apr 9, 2024
92cd4f1
Fix release in next channel
SferaDev Feb 27, 2024
e582cc7
Rename internal columns breaking change (#1370)
SferaDev Feb 28, 2024
d9cb581
Update test to allow postgres (#1396)
SferaDev Mar 6, 2024
a4e6823
fix: generate data native types (#1412)
eemmiillyy Mar 22, 2024
203c720
feat: pgroll cli edit (#1430)
eemmiillyy May 3, 2024
9b760aa
Breaking changes to codegen (#1371)
SferaDev May 6, 2024
ad3ed31
fix: next build (#1472)
eemmiillyy May 7, 2024
3a431b9
feat: pgroll support import (#1470)
eemmiillyy May 14, 2024
e16856e
Add pagination support in `xata pull` (#1477)
SferaDev May 23, 2024
e3cb734
Allow running tests against DC (#1519)
SferaDev Jul 1, 2024
0bff19e
Fix bad merge
SferaDev Jul 4, 2024
5438fee
clean
eemmiillyy Jul 5, 2024
e04dcb6
Merge branch 'next' into feat/remove-sdk-bkp
eemmiillyy Jul 8, 2024
702c622
kysely tests
eemmiillyy Jul 8, 2024
f4910a8
remove link code
eemmiillyy Jul 9, 2024
cb84122
Start pre mode
SferaDev Dec 19, 2023
9d6fe62
Init version 1.0
SferaDev Dec 19, 2023
8fb6c85
Make XataApiClient to use ES Proxies (#1287)
SferaDev Jan 9, 2024
80d194c
Remove cache implementation (#1368)
SferaDev Apr 9, 2024
01e047f
Fix release in next channel
SferaDev Feb 27, 2024
eadde21
Rename internal columns breaking change (#1370)
SferaDev Feb 28, 2024
f8a7773
Update test to allow postgres (#1396)
SferaDev Mar 6, 2024
19b682d
fix: generate data native types (#1412)
eemmiillyy Mar 22, 2024
7efc51d
feat: pgroll cli edit (#1430)
eemmiillyy May 3, 2024
451f814
Breaking changes to codegen (#1371)
SferaDev May 6, 2024
2818d51
fix: next build (#1472)
eemmiillyy May 7, 2024
22a2af2
Add pagination support in `xata pull` (#1477)
SferaDev May 23, 2024
01f5bcb
Allow running tests against DC (#1519)
SferaDev Jul 1, 2024
64f1028
Fix bad merge
SferaDev Jul 4, 2024
039a956
add column data to getPaginated response
eemmiillyy Aug 7, 2024
9808214
Merge branch 'next' into feat/remove-data-api-sdk-base
eemmiillyy Aug 7, 2024
eae0972
feat: add count (#1563)
eemmiillyy Aug 28, 2024
e2fa77e
Merge origin/next
SferaDev Sep 16, 2024
43c0886
Update imports
SferaDev Sep 17, 2024
118ef58
Remove ifVersion (#1589)
SferaDev Sep 19, 2024
ba38825
Fix offset based pagination
SferaDev Oct 1, 2024
15f4678
Merge remote-tracking branch 'origin/next' into feat/remove-data-api-…
SferaDev Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fast-dragons-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@xata.io/client": patch
---

Remove ifVersion
5 changes: 5 additions & 0 deletions .changeset/light-cycles-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xata.io/client': major
---

Make XataApiClient to use ES Proxies
2 changes: 1 addition & 1 deletion .changeset/sixty-points-tell.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@xata.io/cli": patch
'@xata.io/cli': patch
---

Do not prompt for update on pre release
23 changes: 13 additions & 10 deletions cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { reportBugURL } from './utils.js';
export class XataClient extends buildClient({
api: new XataApiPlugin(),
import: new XataImportPlugin()
}) {}
})<any> {}

export type APIKeyLocation = 'shell' | 'dotenv' | 'profile' | 'new';

Expand Down Expand Up @@ -212,15 +212,18 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
const databaseURL = flags.db ?? `${getHostUrl(host, 'workspaces')}/db/{database}`;
const branch = flags.branch ?? this.getCurrentBranchName();

this.#xataClient = new XataClient({
databaseURL,
branch,
apiKey,
fetch,
host,
clientName: 'cli',
xataAgentExtra: { cliCommandId: this.id ?? 'unknown' }
});
this.#xataClient = new XataClient(
{
databaseURL,
branch,
apiKey,
fetch,
host,
clientName: 'cli',
xataAgentExtra: { cliCommandId: this.id ?? 'unknown' }
},
{ tables: [] }
);

return this.#xataClient;
}
Expand Down
32 changes: 13 additions & 19 deletions cli/src/commands/import/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,30 +156,24 @@ export default class ImportCSV extends BaseCommand<typeof ImportCSV> {
if (!parseResults.success) {
throw new Error('Failed to parse CSV file');
}
const batchRows = () => {
if (this.#pgrollEnabled) {
const res = parseResults.data.map(({ data }) => {
const formattedRow: { [k: string]: any } = {};
const keys = Object.keys(data);
for (const key of keys) {
if (INTERNAL_COLUMNS_PGROLL.includes(key) && key !== 'xata_id') continue;
formattedRow[key] = data[key];
}
return formattedRow;
});
return res;
} else {
return parseResults.data.map(({ data }) => data);
const batchRows = parseResults.data.map(({ data }) => {
const formattedRow: { [k: string]: any } = {};
const keys = Object.keys(data);
for (const key of keys) {
if (INTERNAL_COLUMNS_PGROLL.includes(key) && key !== 'xata_id') continue;
formattedRow[key] = data[key];
}
};
return formattedRow;
});

const importResult = await xata.import.importBatch(
{ workspace, region, database, branch },
{
columns: this.#pgrollEnabled
? parseResults.columns.filter(({ name }) => name === 'xata_id' || !INTERNAL_COLUMNS_PGROLL.includes(name))
: parseResults.columns,
columns: parseResults.columns.filter(
({ name }) => name === 'xata_id' || !INTERNAL_COLUMNS_PGROLL.includes(name)
),
table,
batchRows: batchRows()
batchRows
}
);
await xata.import.importFiles(
Expand Down
48 changes: 24 additions & 24 deletions cli/src/commands/init/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ describe('xata init', () => {
XataRecord,
} from "@xata.io/client";

const tables = [
{ name: "table1", columns: [{ name: "a", type: "string" }] },
] as const;
const schema = {
tables: [{ name: "table1", columns: [{ name: "a", type: "string" }] }],
} as const;

export type SchemaTables = typeof tables;
export type SchemaTables = typeof schema.tables;
export type InferredTypes = SchemaInference<SchemaTables>;

export type Table1 = InferredTypes["table1"];
Expand All @@ -180,7 +180,7 @@ describe('xata init', () => {

const DatabaseClient = buildClient();

export class XataClient extends DatabaseClient<DatabaseSchema> {
export class XataClient extends DatabaseClient<typeof schema> {
constructor(options?: BaseClientOptions) {
super(
{
Expand All @@ -193,7 +193,7 @@ describe('xata init', () => {
"main",
...options,
},
tables
schema
);
}
}
Expand Down Expand Up @@ -247,11 +247,11 @@ describe('xata init', () => {
XataRecord,
} from "@xata.io/client";

const tables = [
{ name: "table1", columns: [{ name: "a", type: "string" }] },
] as const;
const schema = {
tables: [{ name: "table1", columns: [{ name: "a", type: "string" }] }],
} as const;

export type SchemaTables = typeof tables;
export type SchemaTables = typeof schema.tables;
export type InferredTypes = SchemaInference<SchemaTables>;

export type Table1 = InferredTypes["table1"];
Expand All @@ -263,7 +263,7 @@ describe('xata init', () => {

const DatabaseClient = buildClient();

export class XataClient extends DatabaseClient<DatabaseSchema> {
export class XataClient extends DatabaseClient<typeof schema> {
constructor(options?: BaseClientOptions) {
super(
{
Expand All @@ -276,7 +276,7 @@ describe('xata init', () => {
"main",
...options,
},
tables
schema
);
}
}
Expand Down Expand Up @@ -325,11 +325,11 @@ describe('xata init', () => {
XataRecord,
} from "npm:@xata.io/client@latest";

const tables = [
{ name: "table1", columns: [{ name: "a", type: "string" }] },
] as const;
const schema = {
tables: [{ name: "table1", columns: [{ name: "a", type: "string" }] }],
} as const;

export type SchemaTables = typeof tables;
export type SchemaTables = typeof schema.tables;
export type InferredTypes = SchemaInference<SchemaTables>;

export type Table1 = InferredTypes["table1"];
Expand All @@ -341,7 +341,7 @@ describe('xata init', () => {

const DatabaseClient = buildClient();

export class XataClient extends DatabaseClient<DatabaseSchema> {
export class XataClient extends DatabaseClient<typeof schema> {
constructor(options?: BaseClientOptions) {
super(
{
Expand All @@ -354,7 +354,7 @@ describe('xata init', () => {
"main",
...options,
},
tables
schema
);
}
}
Expand Down Expand Up @@ -404,11 +404,11 @@ describe('xata init', () => {
XataRecord,
} from "@xata.io/client";

const tables = [
{ name: "table1", columns: [{ name: "a", type: "string" }] },
] as const;
const schema = {
tables: [{ name: "table1", columns: [{ name: "a", type: "string" }] }],
} as const;

export type SchemaTables = typeof tables;
export type SchemaTables = typeof schema.tables;
export type InferredTypes = SchemaInference<SchemaTables>;

export type Table1 = InferredTypes["table1"];
Expand All @@ -420,7 +420,7 @@ describe('xata init', () => {

const DatabaseClient = buildClient();

export class XataClient extends DatabaseClient<DatabaseSchema> {
export class XataClient extends DatabaseClient<typeof schema> {
constructor(options?: BaseClientOptions) {
super(
{
Expand All @@ -433,7 +433,7 @@ describe('xata init', () => {
"main",
...options,
},
tables
schema
);
}
}
Expand Down
8 changes: 6 additions & 2 deletions cli/src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ export default class Init extends BaseCommand<typeof Init> {
this.log();

if (this.projectConfig?.codegen?.output) {
const hasTables = this.branchDetails.schema?.tables && this.branchDetails.schema?.tables.length > 0;
const hasColumns = this.branchDetails.schema?.tables.some((t) => t.columns.length > 0);
const { schema: currentSchema } = await (
await this.getXataClient()
).api.branch.getBranchDetails({ pathParams: { workspace, region, dbBranchName: `${database}:${branch}` } });

const hasTables = currentSchema?.tables && currentSchema?.tables.length > 0;
const hasColumns = currentSchema?.tables.some((t) => t.columns.length > 0);
const isSchemaSetup = hasTables && hasColumns;
if (shouldInstallPackage && !canInstallPackage) {
this.warn(
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/schema/edit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PgRollMigration } from '@xata.io/pgroll';
import { beforeEach, describe, expect, test } from 'vitest';
import EditSchemaNew, {
import EditSchema, {
AddColumnPayload,
AddTablePayload,
ColumnAdditions,
Expand Down Expand Up @@ -108,7 +108,7 @@ const createEdit = (column: ColumnData) => {
const runTest = (name: string, setup: () => void, expectation: any) => {
test(name, () => {
setup();
editCommand.currentMigration.operations = editsToMigrations(editCommand as EditSchemaNew);
editCommand.currentMigration.operations = editsToMigrations(editCommand as EditSchema);
expect(editCommand.currentMigration.operations).toEqual(expectation);
});
};
Expand Down
7 changes: 1 addition & 6 deletions cli/src/migrations/pgroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,7 @@ export async function waitForMigrationToFinish(
jobId: string
): Promise<void> {
const { status, error } = await api.migrations.getMigrationJobStatus({
pathParams: {
workspace: workspace,
region: region,
dbBranchName: `${database}:${branch}`,
jobId
}
pathParams: { workspace, region, dbBranchName: `${database}:${branch}`, jobId }
});
if (status === 'failed') {
throw new Error(`Migration failed, ${error}`);
Expand Down
7 changes: 6 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@
"bugs": {
"url": "https://github.com/xataio/client-ts/issues"
},
"homepage": "https://xata.io/docs/sdk/getting-started"
"homepage": "https://xata.io/docs/sdk/getting-started",
"dependencies": {
"kysely": "^0.27.3",
"@xata.io/sql": "workspace:*",
"@xata.io/kysely": "workspace:*"
}
}
31 changes: 12 additions & 19 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ApiExtraProps, HostProvider, Schemas } from './api';
import { ApiExtraProps, HostProvider } from './api';
import { FilesPlugin, FilesPluginResult } from './files';
import { XataPlugin, XataPluginOptions } from './plugins';
import { BaseSchema, SchemaPlugin, SchemaPluginResult, XataRecord } from './schema';
import { DatabaseSchema, SchemaInference, SchemaPlugin, SchemaPluginResult } from './schema';
import { defaultTrace, TraceFunction } from './schema/tracing';
import { SearchPlugin, SearchPluginResult } from './search';
import { SQLPlugin, SQLPluginResult } from './sql';
import { TransactionPlugin, TransactionPluginResult } from './transaction';
import { FetchImpl, getFetchImplementation } from './util/fetch';
import { AllRequired, StringKeys } from './util/types';
import { generateUUID } from './util/uuid';
Expand Down Expand Up @@ -33,35 +32,32 @@ export const buildClient = <Plugins extends Record<string, XataPlugin> = {}>(plu
class {
#options: SafeOptions;

schema: Schemas.Schema;
schema: DatabaseSchema;
db: SchemaPluginResult<any>;
search: SearchPluginResult<any>;
transactions: TransactionPluginResult<any>;
sql: SQLPluginResult;
files: FilesPluginResult<any>;

constructor(options: BaseClientOptions = {}, tables: Schemas.Table[]) {
constructor(options: BaseClientOptions = {}, schema: DatabaseSchema) {
const safeOptions = this.#parseOptions(options);
this.#options = safeOptions;

const pluginOptions: XataPluginOptions = {
...this.#getFetchProps(safeOptions),
host: safeOptions.host,
tables,
schema,
branch: safeOptions.branch
};

const db = new SchemaPlugin().build(pluginOptions);
const search = new SearchPlugin(db).build(pluginOptions);
const transactions = new TransactionPlugin().build(pluginOptions);
const sql = new SQLPlugin().build(pluginOptions);
const files = new FilesPlugin().build(pluginOptions);

// We assign the namespaces after creating in case the user overrides the db plugin
this.schema = { tables };
this.schema = schema;
this.db = db;
this.search = search;
this.transactions = transactions;
this.sql = sql;
this.files = files;

Expand Down Expand Up @@ -155,16 +151,13 @@ export const buildClient = <Plugins extends Record<string, XataPlugin> = {}>(plu
} as unknown as ClientConstructor<Plugins>;

export interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
new <Schemas extends Record<string, XataRecord> = {}>(
options?: Partial<BaseClientOptions>,
schemaTables?: readonly BaseSchema[]
): Omit<
new <Schema extends DatabaseSchema>(options: BaseClientOptions, schema: Schema): Omit<
{
db: Awaited<ReturnType<SchemaPlugin<Schemas>['build']>>;
search: Awaited<ReturnType<SearchPlugin<Schemas>['build']>>;
transactions: Awaited<ReturnType<TransactionPlugin<Schemas>['build']>>;
db: Awaited<ReturnType<SchemaPlugin<Schema>['build']>>;
search: Awaited<ReturnType<SearchPlugin<Schema>['build']>>;
sql: Awaited<ReturnType<SQLPlugin['build']>>;
files: Awaited<ReturnType<FilesPlugin<Schemas>['build']>>;
files: Awaited<ReturnType<FilesPlugin<SchemaInference<Schema['tables']>>['build']>>;
schema: Schema;
},
keyof Plugins
> & {
Expand All @@ -177,4 +170,4 @@ export interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
};
}

export class BaseClient extends buildClient()<Record<string, any>> {}
export class BaseClient extends buildClient()<DatabaseSchema> {}
4 changes: 2 additions & 2 deletions packages/client/src/files/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { deleteFileItem, getFileItem, putFileItem } from '../api';
import { FileResponse } from '../api/dataPlaneSchemas';
import { XataPlugin, XataPluginOptions } from '../plugins';
import { ColumnsByValue, XataArrayFile, XataFile } from '../schema';
import { BaseData, XataRecord } from '../schema/record';
import { BaseData } from '../schema/record';
import { isBlob } from '../util/lang';
import { GetArrayInnerType, StringKeys, Values } from '../util/types';

Expand Down Expand Up @@ -48,7 +48,7 @@ export type DownloadDestination<Schemas extends Record<string, BaseData>, Tables
};
}>;

export class FilesPlugin<Schemas extends Record<string, XataRecord>> extends XataPlugin {
export class FilesPlugin<Schemas extends Record<string, any>> extends XataPlugin {
build(pluginOptions: XataPluginOptions): FilesPluginResult<Schemas> {
return {
download: async (location: Record<string, string | undefined>) => {
Expand Down
Loading
Loading