@xata.io/drizzle 0.0.0-alpha.ve565538 → 0.0.0-alpha.ve69ec6a

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/test/utils.ts ADDED
@@ -0,0 +1,5 @@
1
+ // shut up eslint you cannot possibly comprehend what's happening here
2
+ // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars
3
+ export function Expect<T extends true>() {}
4
+
5
+ export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
@@ -0,0 +1,149 @@
1
+ import { buildClient } from '@xata.io/client';
2
+ import type { BaseClientOptions, SchemaInference, XataRecord } from '@xata.io/client';
3
+
4
+ export const tables = [
5
+ {
6
+ name: 'users',
7
+ columns: [
8
+ { name: 'name', type: 'string', notNull: true, defaultValue: '' },
9
+ { name: 'verified', type: 'bool', notNull: true, defaultValue: 'false' },
10
+ { name: 'jsonb', type: 'json' },
11
+ {
12
+ name: 'created_at',
13
+ type: 'datetime',
14
+ notNull: true,
15
+ defaultValue: 'now'
16
+ }
17
+ ]
18
+ },
19
+ {
20
+ name: 'cities',
21
+ columns: [
22
+ { name: 'name', type: 'string', notNull: true, defaultValue: '' },
23
+ { name: 'state', type: 'string' }
24
+ ],
25
+ revLinks: [{ column: 'city_id', table: 'users2' }]
26
+ },
27
+ {
28
+ name: 'users2',
29
+ columns: [
30
+ { name: 'name', type: 'string', notNull: true, defaultValue: '' },
31
+ { name: 'city_id', type: 'link', link: { table: 'cities' } }
32
+ ]
33
+ },
34
+ {
35
+ name: 'courses',
36
+ columns: [
37
+ { name: 'name', type: 'string', notNull: true, defaultValue: '' },
38
+ {
39
+ name: 'category_id',
40
+ type: 'link',
41
+ link: { table: 'course_categories' }
42
+ }
43
+ ]
44
+ },
45
+ {
46
+ name: 'course_categories',
47
+ columns: [{ name: 'name', type: 'string', defaultValue: '' }],
48
+ revLinks: [{ column: 'category_id', table: 'courses' }]
49
+ },
50
+ {
51
+ name: 'orders',
52
+ columns: [
53
+ { name: 'region', type: 'string', notNull: true, defaultValue: '' },
54
+ { name: 'product', type: 'string', notNull: true, defaultValue: '' },
55
+ { name: 'amount', type: 'int', notNull: true, defaultValue: '0' },
56
+ { name: 'quantity', type: 'int', notNull: true, defaultValue: '0' }
57
+ ]
58
+ },
59
+ {
60
+ name: 'network_table',
61
+ columns: [
62
+ { name: 'inet', type: 'string', notNull: true, defaultValue: '' },
63
+ { name: 'cidr', type: 'string', notNull: true, defaultValue: '' },
64
+ { name: 'macaddr', type: 'string', notNull: true, defaultValue: '' },
65
+ { name: 'macaddr8', type: 'string', notNull: true, defaultValue: '' }
66
+ ]
67
+ },
68
+ {
69
+ name: 'sal_emp',
70
+ columns: [
71
+ { name: 'name', type: 'string' },
72
+ { name: 'pay_by_quarter', type: 'multiple' },
73
+ { name: 'schedule', type: 'multiple' }
74
+ ]
75
+ },
76
+ { name: 'tictactoe', columns: [{ name: 'squares', type: 'json' }] },
77
+ {
78
+ name: 'users12',
79
+ columns: [
80
+ { name: 'name', type: 'string', notNull: true, defaultValue: '' },
81
+ { name: 'email', type: 'email' }
82
+ ]
83
+ }
84
+ ] as const;
85
+
86
+ export type SchemaTables = typeof tables;
87
+ export type InferredTypes = SchemaInference<SchemaTables>;
88
+
89
+ export type Users = InferredTypes['users'];
90
+ export type UsersRecord = Users & XataRecord;
91
+
92
+ export type Cities = InferredTypes['cities'];
93
+ export type CitiesRecord = Cities & XataRecord;
94
+
95
+ export type Users2 = InferredTypes['users2'];
96
+ export type Users2Record = Users2 & XataRecord;
97
+
98
+ export type Courses = InferredTypes['courses'];
99
+ export type CoursesRecord = Courses & XataRecord;
100
+
101
+ export type CourseCategories = InferredTypes['course_categories'];
102
+ export type CourseCategoriesRecord = CourseCategories & XataRecord;
103
+
104
+ export type Orders = InferredTypes['orders'];
105
+ export type OrdersRecord = Orders & XataRecord;
106
+
107
+ export type NetworkTable = InferredTypes['network_table'];
108
+ export type NetworkTableRecord = NetworkTable & XataRecord;
109
+
110
+ export type SalEmp = InferredTypes['sal_emp'];
111
+ export type SalEmpRecord = SalEmp & XataRecord;
112
+
113
+ export type Tictactoe = InferredTypes['tictactoe'];
114
+ export type TictactoeRecord = Tictactoe & XataRecord;
115
+
116
+ export type Users12 = InferredTypes['users12'];
117
+ export type Users12Record = Users12 & XataRecord;
118
+
119
+ export type DatabaseSchema = {
120
+ users: UsersRecord;
121
+ cities: CitiesRecord;
122
+ users2: Users2Record;
123
+ courses: CoursesRecord;
124
+ course_categories: CourseCategoriesRecord;
125
+ orders: OrdersRecord;
126
+ network_table: NetworkTableRecord;
127
+ sal_emp: SalEmpRecord;
128
+ tictactoe: TictactoeRecord;
129
+ users12: Users12Record;
130
+ };
131
+
132
+ const DatabaseClient = buildClient();
133
+
134
+ const defaultOptions = {};
135
+
136
+ export class XataClient extends DatabaseClient<DatabaseSchema> {
137
+ constructor(options?: BaseClientOptions) {
138
+ super({ ...defaultOptions, ...options }, tables);
139
+ }
140
+ }
141
+
142
+ let instance: XataClient | undefined = undefined;
143
+
144
+ export const getXataClient = () => {
145
+ if (instance) return instance;
146
+
147
+ instance = new XataClient();
148
+ return instance;
149
+ };