@xata.io/client 0.0.0-alpha.vf71bb14 → 0.0.0-alpha.vf721f5c

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.
Files changed (71) hide show
  1. package/.eslintrc.cjs +1 -2
  2. package/CHANGELOG.md +277 -0
  3. package/README.md +273 -1
  4. package/Usage.md +451 -0
  5. package/dist/index.cjs +2742 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.ts +5824 -7
  8. package/dist/index.mjs +2592 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/package.json +16 -8
  11. package/rollup.config.js +29 -0
  12. package/tsconfig.json +6 -4
  13. package/dist/api/client.d.ts +0 -95
  14. package/dist/api/client.js +0 -251
  15. package/dist/api/components.d.ts +0 -1437
  16. package/dist/api/components.js +0 -998
  17. package/dist/api/fetcher.d.ts +0 -40
  18. package/dist/api/fetcher.js +0 -79
  19. package/dist/api/index.d.ts +0 -13
  20. package/dist/api/index.js +0 -40
  21. package/dist/api/parameters.d.ts +0 -16
  22. package/dist/api/parameters.js +0 -2
  23. package/dist/api/providers.d.ts +0 -8
  24. package/dist/api/providers.js +0 -30
  25. package/dist/api/responses.d.ts +0 -50
  26. package/dist/api/responses.js +0 -2
  27. package/dist/api/schemas.d.ts +0 -311
  28. package/dist/api/schemas.js +0 -2
  29. package/dist/client.d.ts +0 -27
  30. package/dist/client.js +0 -131
  31. package/dist/index.js +0 -30
  32. package/dist/plugins.d.ts +0 -7
  33. package/dist/plugins.js +0 -6
  34. package/dist/schema/filters.d.ts +0 -96
  35. package/dist/schema/filters.js +0 -2
  36. package/dist/schema/filters.spec.d.ts +0 -1
  37. package/dist/schema/filters.spec.js +0 -177
  38. package/dist/schema/index.d.ts +0 -24
  39. package/dist/schema/index.js +0 -60
  40. package/dist/schema/operators.d.ts +0 -74
  41. package/dist/schema/operators.js +0 -93
  42. package/dist/schema/pagination.d.ts +0 -83
  43. package/dist/schema/pagination.js +0 -93
  44. package/dist/schema/query.d.ts +0 -118
  45. package/dist/schema/query.js +0 -242
  46. package/dist/schema/record.d.ts +0 -66
  47. package/dist/schema/record.js +0 -13
  48. package/dist/schema/repository.d.ts +0 -135
  49. package/dist/schema/repository.js +0 -283
  50. package/dist/schema/selection.d.ts +0 -25
  51. package/dist/schema/selection.js +0 -2
  52. package/dist/schema/selection.spec.d.ts +0 -1
  53. package/dist/schema/selection.spec.js +0 -204
  54. package/dist/schema/sorting.d.ts +0 -22
  55. package/dist/schema/sorting.js +0 -35
  56. package/dist/schema/sorting.spec.d.ts +0 -1
  57. package/dist/schema/sorting.spec.js +0 -11
  58. package/dist/search/index.d.ts +0 -34
  59. package/dist/search/index.js +0 -55
  60. package/dist/util/branches.d.ts +0 -5
  61. package/dist/util/branches.js +0 -7
  62. package/dist/util/config.d.ts +0 -11
  63. package/dist/util/config.js +0 -121
  64. package/dist/util/environment.d.ts +0 -5
  65. package/dist/util/environment.js +0 -68
  66. package/dist/util/fetch.d.ts +0 -2
  67. package/dist/util/fetch.js +0 -13
  68. package/dist/util/lang.d.ts +0 -5
  69. package/dist/util/lang.js +0 -22
  70. package/dist/util/types.d.ts +0 -25
  71. package/dist/util/types.js +0 -2
package/.eslintrc.cjs CHANGED
@@ -6,8 +6,7 @@ module.exports = {
6
6
  project: 'packages/client/tsconfig.json'
7
7
  },
8
8
  rules: {
9
- '@typescript-eslint/no-explicit-any': 'off',
10
- '@typescript-eslint/ban-types': 'off',
11
9
  '@typescript-eslint/no-floating-promises': 'error',
10
+ "@typescript-eslint/strict-boolean-expressions": ["error", { allowNullableString: true, allowNullableObject: true }],
12
11
  }
13
12
  };
package/CHANGELOG.md CHANGED
@@ -1,5 +1,282 @@
1
1
  # @xata.io/client
2
2
 
3
+ ## 0.18.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#639](https://github.com/xataio/client-ts/pull/639) [`50fb3c0`](https://github.com/xataio/client-ts/commit/50fb3c0a1cffd03a16cc8b1b21454ea816f2edbb) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not return null for columns not selected
8
+
9
+ ## 0.18.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#635](https://github.com/xataio/client-ts/pull/635) [`713f9b2`](https://github.com/xataio/client-ts/commit/713f9b2773be99c17d3fcb663e24fe096fa3da48) Thanks [@SferaDev](https://github.com/SferaDev)! - [Search] Add target columns
14
+
15
+ ## 0.18.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [#627](https://github.com/xataio/client-ts/pull/627) [`ad0a5b4`](https://github.com/xataio/client-ts/commit/ad0a5b4bc87b82fdc10008a8ea324a8ca783e678) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix some cases where filters on link and multiple column types are not working
20
+
21
+ ## 0.18.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [#562](https://github.com/xataio/client-ts/pull/562) [`699beb4`](https://github.com/xataio/client-ts/commit/699beb4bbf21cffa001d3f88a03246980e30250b) Thanks [@SferaDev](https://github.com/SferaDev)! - Return null on nullable columns
26
+
27
+ ### Patch Changes
28
+
29
+ - [#583](https://github.com/xataio/client-ts/pull/583) [`330b076`](https://github.com/xataio/client-ts/commit/330b076a0781e3576c82afab76e3fb2a64f2e041) Thanks [@SferaDev](https://github.com/SferaDev)! - Add support for unique columns
30
+
31
+ - [#598](https://github.com/xataio/client-ts/pull/598) [`c3dfb4b`](https://github.com/xataio/client-ts/commit/c3dfb4babc990634b9e9747616ed93223178a2e7) Thanks [@SferaDev](https://github.com/SferaDev)! - API: Add patch database metadata endpoint
32
+
33
+ - [#602](https://github.com/xataio/client-ts/pull/602) [`74b17aa`](https://github.com/xataio/client-ts/commit/74b17aaedc0dbdd79bfdcb182b2e70b61f98f5a5) Thanks [@gimenete](https://github.com/gimenete)! - API: Make workspace slug optional on create
34
+
35
+ - [#615](https://github.com/xataio/client-ts/pull/615) [`83f20cd`](https://github.com/xataio/client-ts/commit/83f20cdbe53706c16016c4db3f318e679b24ec86) Thanks [@SferaDev](https://github.com/SferaDev)! - Make `getMany` return more items than max pagination size
36
+
37
+ - [#562](https://github.com/xataio/client-ts/pull/562) [`addfcc6`](https://github.com/xataio/client-ts/commit/addfcc67fca663defdd340111ea09c9188bad3ab) Thanks [@SferaDev](https://github.com/SferaDev)! - Add `orThrows` methods that instead of returning null, throw an exception.
38
+
39
+ - [#583](https://github.com/xataio/client-ts/pull/583) [`eb7ba59`](https://github.com/xataio/client-ts/commit/eb7ba594be2a1f0ab90956836bbeb912e188a46d) Thanks [@SferaDev](https://github.com/SferaDev)! - Add support for non nullable columns
40
+
41
+ - [#612](https://github.com/xataio/client-ts/pull/612) [`f1a0742`](https://github.com/xataio/client-ts/commit/f1a0742a04e1aefab14f46371a04a41069faec01) Thanks [@xata-bot](https://github.com/xata-bot)! - API: Add summarize table endpoint
42
+
43
+ ## 0.17.1
44
+
45
+ ### Patch Changes
46
+
47
+ - [#584](https://github.com/xataio/client-ts/pull/584) [`a305072`](https://github.com/xataio/client-ts/commit/a3050726517632b4975f2a2ed5f771dd247e51d5) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix issues with multiple filters
48
+
49
+ * [#249](https://github.com/xataio/client-ts/pull/249) [`7812a41`](https://github.com/xataio/client-ts/commit/7812a414b7d99e9515c0ce48a61ad7a8b84d65d0) Thanks [@xata-bot](https://github.com/xata-bot)! - API: Add first endpoints for migration requests and schema compare
50
+
51
+ - [#585](https://github.com/xataio/client-ts/pull/585) [`d4a8ced`](https://github.com/xataio/client-ts/commit/d4a8ced9c257058ed7f660e01ee5fd1da154c391) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix problem with some special characters not being URI encoded
52
+
53
+ * [#574](https://github.com/xataio/client-ts/pull/574) [`cf85b13`](https://github.com/xataio/client-ts/commit/cf85b13e1ca69e79100fd02f58d79d556012395d) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not allow unknown tables on codegen output
54
+
55
+ - [#576](https://github.com/xataio/client-ts/pull/576) [`2350739`](https://github.com/xataio/client-ts/commit/2350739d3f0a176b0f1fc77b0f4f597321349726) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow sending empty, undefined or conditional filters
56
+
57
+ * [#581](https://github.com/xataio/client-ts/pull/581) [`a336e61`](https://github.com/xataio/client-ts/commit/a336e6161be04a652e6f0f0a4c2edac10d50c99e) Thanks [@SferaDev](https://github.com/SferaDev)! - Update error codes in tracing
58
+
59
+ ## 0.17.0
60
+
61
+ ### Minor Changes
62
+
63
+ - [#563](https://github.com/xataio/client-ts/pull/563) [`26e91d1`](https://github.com/xataio/client-ts/commit/26e91d1d84df082dedd7159271fc7c27ec87fefe) Thanks [@SferaDev](https://github.com/SferaDev)! - Return nulls on operations that can fail
64
+
65
+ * [#563](https://github.com/xataio/client-ts/pull/563) [`3332d43`](https://github.com/xataio/client-ts/commit/3332d43121367f61c8d87dfb7da2af65bd1c278f) Thanks [@SferaDev](https://github.com/SferaDev)! - Return object on delete operation
66
+
67
+ ## 0.16.2
68
+
69
+ ### Patch Changes
70
+
71
+ - [#541](https://github.com/xataio/client-ts/pull/541) [`c74467c`](https://github.com/xataio/client-ts/commit/c74467caeff4e3d60d0981a173b462e970c6c1fc) Thanks [@SferaDev](https://github.com/SferaDev)! - Add tracing with open telemetry
72
+
73
+ * [#551](https://github.com/xataio/client-ts/pull/551) [`ee72bfe`](https://github.com/xataio/client-ts/commit/ee72bfef34765374ec66c7edaa6b5508c3f8e8dc) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix filter operators and dates
74
+
75
+ - [#552](https://github.com/xataio/client-ts/pull/552) [`e88effa`](https://github.com/xataio/client-ts/commit/e88effa00f8c2c0e24ec8cd60fb21859ac236191) Thanks [@SferaDev](https://github.com/SferaDev)! - Update error message for required settings
76
+
77
+ * [#551](https://github.com/xataio/client-ts/pull/551) [`33293b3`](https://github.com/xataio/client-ts/commit/33293b3509d984bb9b1af457c96260d43f398efe) Thanks [@SferaDev](https://github.com/SferaDev)! - Add aliases for some operators
78
+
79
+ - [#534](https://github.com/xataio/client-ts/pull/534) [`efc09b4`](https://github.com/xataio/client-ts/commit/efc09b420a25253b428662c2eec40ff3bc36ce79) Thanks [@SferaDev](https://github.com/SferaDev)! - Make sort direction optional
80
+
81
+ ## 0.16.1
82
+
83
+ ### Patch Changes
84
+
85
+ - [#531](https://github.com/xataio/client-ts/pull/531) [`e33d8fb`](https://github.com/xataio/client-ts/commit/e33d8fbca264d3ab1597ed698d5e79484dcba8a3) Thanks [@xata-bot](https://github.com/xata-bot)! - Add new method to list database metadata in the API client
86
+
87
+ * [#524](https://github.com/xataio/client-ts/pull/524) [`a3b1044`](https://github.com/xataio/client-ts/commit/a3b1044038c4ae73b4aacaa112818e69b7d380e1) Thanks [@SferaDev](https://github.com/SferaDev)! - Expose internal config information
88
+
89
+ - [#525](https://github.com/xataio/client-ts/pull/525) [`5f0f2c2`](https://github.com/xataio/client-ts/commit/5f0f2c2bb42da360e810f0a61ce360f8f8b07a04) Thanks [@xata-bot](https://github.com/xata-bot)! - Update dependencies
90
+
91
+ ## 0.16.0
92
+
93
+ ### Minor Changes
94
+
95
+ - [#485](https://github.com/xataio/client-ts/pull/485) [`a9cbb26`](https://github.com/xataio/client-ts/commit/a9cbb263fbca47cb91a827db252d95a5bb4079a6) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow selecting columns with record operations
96
+
97
+ * [#485](https://github.com/xataio/client-ts/pull/485) [`7e04a3d`](https://github.com/xataio/client-ts/commit/7e04a3d1c51958a44f687a0036ead8bb3f5a2dfb) Thanks [@SferaDev](https://github.com/SferaDev)! - Remove record cache
98
+
99
+ ### Patch Changes
100
+
101
+ - [#503](https://github.com/xataio/client-ts/pull/503) [`6a96ea5`](https://github.com/xataio/client-ts/commit/6a96ea5da4c5b7ca9a99b57ebbce8d6766b5d4d8) Thanks [@xata-bot](https://github.com/xata-bot)! - Update API response types for create of tables and branches
102
+
103
+ * [#421](https://github.com/xataio/client-ts/pull/421) [`43f2560`](https://github.com/xataio/client-ts/commit/43f25605ddd0d2fd514a1542a14389d28955c500) Thanks [@SferaDev](https://github.com/SferaDev)! - Add search boosters and allow prefix search
104
+
105
+ ## 0.15.0
106
+
107
+ ### Patch Changes
108
+
109
+ - [#496](https://github.com/xataio/client-ts/pull/496) [`e923d11`](https://github.com/xataio/client-ts/commit/e923d11fe357519dc4ca3ae722670e6e70ccd1c6) Thanks [@gimenete](https://github.com/gimenete)! - Ignore git output in Xata client
110
+
111
+ * [#481](https://github.com/xataio/client-ts/pull/481) [`599b52c`](https://github.com/xataio/client-ts/commit/599b52c3090222eedef85d1ad1e907874cd3e801) Thanks [@xata-bot](https://github.com/xata-bot)! - Add updateWorkspaceMemberInvite API method
112
+
113
+ ## 0.14.0
114
+
115
+ ### Minor Changes
116
+
117
+ - [#409](https://github.com/xataio/client-ts/pull/409) [`8812380`](https://github.com/xataio/client-ts/commit/881238062b5eeac2dc8b9ba156720e0acc22c5c5) Thanks [@SferaDev](https://github.com/SferaDev)! - Infer types from schema in codegen
118
+
119
+ * [#457](https://github.com/xataio/client-ts/pull/457) [`0584a5b`](https://github.com/xataio/client-ts/commit/0584a5b207a21dbc36ddc1d44b276f1d5bb60dc5) Thanks [@SferaDev](https://github.com/SferaDev)! - Load env variables so that code analysis detects them
120
+
121
+ - [#469](https://github.com/xataio/client-ts/pull/469) [`8d8a912`](https://github.com/xataio/client-ts/commit/8d8a9129e36452266c4c12fe35b421f66e572498) Thanks [@gimenete](https://github.com/gimenete)! - Treat branch name specified with third party env variables as git branches in the resolution algorithm
122
+
123
+ ### Patch Changes
124
+
125
+ - [#462](https://github.com/xataio/client-ts/pull/462) [`7547b7e`](https://github.com/xataio/client-ts/commit/7547b7edbc9a95c6620784cc5348316f27502c73) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix bug with RecordArray.map
126
+
127
+ * [#472](https://github.com/xataio/client-ts/pull/472) [`e99010c`](https://github.com/xataio/client-ts/commit/e99010c9ab9d355abadcfbcf98b5a3fcc80c307a) Thanks [@SferaDev](https://github.com/SferaDev)! - Add id as entity property
128
+
129
+ - [#443](https://github.com/xataio/client-ts/pull/443) [`c4be404`](https://github.com/xataio/client-ts/commit/c4be404a3ecb34df9b1ef4501c92f5bdc221f19c) Thanks [@SferaDev](https://github.com/SferaDev)! - Improve performance with `create([])` operation
130
+
131
+ ## 0.13.4
132
+
133
+ ### Patch Changes
134
+
135
+ - [#444](https://github.com/xataio/client-ts/pull/444) [`3c3a5af`](https://github.com/xataio/client-ts/commit/3c3a5afb1d5fb3295fd8cf6c2b66709a5c047507) Thanks [@SferaDev](https://github.com/SferaDev)! - Publish xata client on deno.land
136
+
137
+ ## 0.13.3
138
+
139
+ ### Patch Changes
140
+
141
+ - [#434](https://github.com/xataio/client-ts/pull/434) [`b82383d`](https://github.com/xataio/client-ts/commit/b82383d7541d19ae71ad7e047fd100901981f28b) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix problem with SSR `RecordArray` in Next.js
142
+
143
+ ## 0.13.2
144
+
145
+ ### Patch Changes
146
+
147
+ - [#431](https://github.com/xataio/client-ts/pull/431) [`8f62024`](https://github.com/xataio/client-ts/commit/8f62024101028b981dc31a68fb258e89110d45dc) Thanks [@SferaDev](https://github.com/SferaDev)! - Include request ids in the error response
148
+
149
+ * [#429](https://github.com/xataio/client-ts/pull/429) [`bb102b4`](https://github.com/xataio/client-ts/commit/bb102b46b722d0a61996c42cda991c9f0080e464) Thanks [@SferaDev](https://github.com/SferaDev)! - Avoid detection of `Buffer` in edge runtime middleware
150
+
151
+ - [#428](https://github.com/xataio/client-ts/pull/428) [`06740ca`](https://github.com/xataio/client-ts/commit/06740cad216831216f0be8cf9de7e354c0ef9191) Thanks [@SferaDev](https://github.com/SferaDev)! - Improve selection types to make them more readable
152
+
153
+ ## 0.13.1
154
+
155
+ ### Patch Changes
156
+
157
+ - [#417](https://github.com/xataio/client-ts/pull/417) [`86a14ec`](https://github.com/xataio/client-ts/commit/86a14eccbca94f572252327c9c0306577a1c3ebd) Thanks [@SferaDev](https://github.com/SferaDev)! - Update User-Agent
158
+
159
+ * [#422](https://github.com/xataio/client-ts/pull/422) [`2896418`](https://github.com/xataio/client-ts/commit/289641844e5b2752197dbbbf3a93ef6068b684e4) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow sending link as string id
160
+
161
+ - [#420](https://github.com/xataio/client-ts/pull/420) [`301b21f`](https://github.com/xataio/client-ts/commit/301b21f4784f755a8694ca21a0f2fd48e1b16df4) Thanks [@SferaDev](https://github.com/SferaDev)! - Exclude date internal columns in selection
162
+
163
+ * [#399](https://github.com/xataio/client-ts/pull/399) [`dd4b2ef`](https://github.com/xataio/client-ts/commit/dd4b2effed2251ac8afbfb2909c21a9deb35bef1) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow create many objects mixed some with ids others without
164
+
165
+ - [#425](https://github.com/xataio/client-ts/pull/425) [`00279ff`](https://github.com/xataio/client-ts/commit/00279ff985793020237f8098cba97dfec7738f82) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not send falsy values to query string
166
+
167
+ * [#399](https://github.com/xataio/client-ts/pull/399) [`8e66998`](https://github.com/xataio/client-ts/commit/8e6699867a1aa1968d12db4ced80c13d4b951f88) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow passing identifiable objects to `read()` operations
168
+
169
+ - [#425](https://github.com/xataio/client-ts/pull/425) [`8a4e019`](https://github.com/xataio/client-ts/commit/8a4e019031e678d946cf9dfb0e4803906fad9b5f) Thanks [@SferaDev](https://github.com/SferaDev)! - Add fallback branch to `api.databases.resolveBranch`
170
+
171
+ ## 0.13.0
172
+
173
+ ### Minor Changes
174
+
175
+ - [#375](https://github.com/xataio/client-ts/pull/375) [`c9f34ad`](https://github.com/xataio/client-ts/commit/c9f34ad37d75203083a1dec2fac2b03e096521af) Thanks [@SferaDev](https://github.com/SferaDev)! - Change default pagination size to 20
176
+
177
+ * [#375](https://github.com/xataio/client-ts/pull/375) [`5f82e43`](https://github.com/xataio/client-ts/commit/5f82e4394010f40dcbf3faf2d0bdb58a6fc1c37a) Thanks [@SferaDev](https://github.com/SferaDev)! - Return a paginable object in getPaginated
178
+
179
+ ## 0.12.0
180
+
181
+ ### Minor Changes
182
+
183
+ - [#376](https://github.com/xataio/client-ts/pull/376) [`db3c88e`](https://github.com/xataio/client-ts/commit/db3c88e1f2bee6d308afb8d6e95b7c090a87e7a7) Thanks [@SferaDev](https://github.com/SferaDev)! - Hide xata object and expose getMetadata method
184
+
185
+ ### Patch Changes
186
+
187
+ - [#364](https://github.com/xataio/client-ts/pull/364) [`1cde95f`](https://github.com/xataio/client-ts/commit/1cde95f05a6b9fbf0564ea05400140f0cef41a3a) Thanks [@SferaDev](https://github.com/SferaDev)! - Add peer dep of TS 4.5+
188
+
189
+ * [#362](https://github.com/xataio/client-ts/pull/362) [`57bf0e2`](https://github.com/xataio/client-ts/commit/57bf0e2e049ed0498683ff42d287983f295342b7) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not show error if date is not defined
190
+
191
+ ## 0.11.0
192
+
193
+ ### Minor Changes
194
+
195
+ - [#322](https://github.com/xataio/client-ts/pull/322) [`bc64c28`](https://github.com/xataio/client-ts/commit/bc64c28fbfbb000c7190ac8092e2ef6a261df86f) Thanks [@SferaDev](https://github.com/SferaDev)! - Add filter support for cross-table search operations
196
+
197
+ ### Patch Changes
198
+
199
+ - [#327](https://github.com/xataio/client-ts/pull/327) [`505257c`](https://github.com/xataio/client-ts/commit/505257c0c42ca0c8beaf5c0f638037c576dcc43c) Thanks [@SferaDev](https://github.com/SferaDev)! - Allow reading multiple uids at the same time
200
+
201
+ * [#346](https://github.com/xataio/client-ts/pull/346) [`ff7e5c6`](https://github.com/xataio/client-ts/commit/ff7e5c6f211913196d8c28600d7a7675ed261688) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix compat with TS 4.8
202
+
203
+ - [#345](https://github.com/xataio/client-ts/pull/345) [`bf64cb8`](https://github.com/xataio/client-ts/commit/bf64cb885d55a0271e966314384324f02ded084e) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix bug with nullable record filters inferred as never
204
+
205
+ * [#334](https://github.com/xataio/client-ts/pull/334) [`ce07601`](https://github.com/xataio/client-ts/commit/ce07601e4ddf9f75e20249d479dc04a63795ca96) Thanks [@SferaDev](https://github.com/SferaDev)! - Add support for TS 4.5
206
+
207
+ - [#325](https://github.com/xataio/client-ts/pull/325) [`12f1ce3`](https://github.com/xataio/client-ts/commit/12f1ce362f6cda27dfdb3afab0800282bddc8b5e) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix offset errors with operations that affect many rows
208
+
209
+ * [#345](https://github.com/xataio/client-ts/pull/345) [`a73a2a2`](https://github.com/xataio/client-ts/commit/a73a2a2014c44cf88eaef42196ba1dba9d516b4a) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix issue with Filter<T> not narrowing down type on object properties
210
+
211
+ ## 0.10.2
212
+
213
+ ### Patch Changes
214
+
215
+ - [#312](https://github.com/xataio/client-ts/pull/312) [`0edf1af`](https://github.com/xataio/client-ts/commit/0edf1af2205c4761d53a02c74ddaab3168d69775) Thanks [@SferaDev](https://github.com/SferaDev)! - Add filtering to search by table
216
+
217
+ * [#312](https://github.com/xataio/client-ts/pull/312) [`66ad7cc`](https://github.com/xataio/client-ts/commit/66ad7cc0365046c5d039c37117feac04428d8373) Thanks [@SferaDev](https://github.com/SferaDev)! - Add new API method for searching in a given table
218
+
219
+ ## 0.10.1
220
+
221
+ ### Patch Changes
222
+
223
+ - [#271](https://github.com/xataio/client-ts/pull/271) [`0bb17b8`](https://github.com/xataio/client-ts/commit/0bb17b88d49f1c8be32d2d6b0b3a5918890876cb) Thanks [@SferaDev](https://github.com/SferaDev)! - Link and resolve branches from git
224
+
225
+ ## 0.10.0
226
+
227
+ ### Minor Changes
228
+
229
+ - [#272](https://github.com/xataio/client-ts/pull/272) [`6d76275`](https://github.com/xataio/client-ts/commit/6d7627555a404a4c2da42f4187df6f8300f9a46f) Thanks [@SferaDev](https://github.com/SferaDev)! - Rename page options to pagination
230
+
231
+ * [#270](https://github.com/xataio/client-ts/pull/270) [`1864742`](https://github.com/xataio/client-ts/commit/18647428d8608841de514c3784fb711c39dccc6d) Thanks [@SferaDev](https://github.com/SferaDev)! - Move chunk to options object
232
+
233
+ ### Patch Changes
234
+
235
+ - [#281](https://github.com/xataio/client-ts/pull/281) [`d1ec0df`](https://github.com/xataio/client-ts/commit/d1ec0df14834088a816919bfc68216f3f9b2d9ef) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not send from param on undefined
236
+
237
+ * [#282](https://github.com/xataio/client-ts/pull/282) [`1af6f1a`](https://github.com/xataio/client-ts/commit/1af6f1aaa1123e77a895961581c87f06a88db698) Thanks [@SferaDev](https://github.com/SferaDev)! - Do not allow filter/sort with cursor navigation
238
+
239
+ - [#284](https://github.com/xataio/client-ts/pull/284) [`be4eda8`](https://github.com/xataio/client-ts/commit/be4eda8f73037d97fef7de28b56d7471dd867875) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix cache ttl with 0 value
240
+
241
+ * [#265](https://github.com/xataio/client-ts/pull/265) [`99be734`](https://github.com/xataio/client-ts/commit/99be734827576d888aa12a579ed1983a0a8a8e83) Thanks [@SferaDev](https://github.com/SferaDev)! - Add datetime field type support
242
+
243
+ ## 0.9.1
244
+
245
+ ### Patch Changes
246
+
247
+ - [#250](https://github.com/xataio/client-ts/pull/250) [`5d7c9e4`](https://github.com/xataio/client-ts/commit/5d7c9e4fa2799255e2bfc8b6fb12c89dc4e1f35e) Thanks [@xata-bot](https://github.com/xata-bot)! - Add branch resolution endpoints to api client
248
+
249
+ * [#261](https://github.com/xataio/client-ts/pull/261) [`e95f20a`](https://github.com/xataio/client-ts/commit/e95f20a7bce264936680353f816065fa379448fc) Thanks [@gimenete](https://github.com/gimenete)! - Fixes a compatibility error in CloudFlare workers with latest version of wrangler
250
+
251
+ ## 0.9.0
252
+
253
+ ### Minor Changes
254
+
255
+ - [#246](https://github.com/xataio/client-ts/pull/246) [`2848894`](https://github.com/xataio/client-ts/commit/284889446bbac5d6737086bf01a588d97b841730) Thanks [@SferaDev](https://github.com/SferaDev)! - Rename getOne to getFirst
256
+
257
+ ### Patch Changes
258
+
259
+ - [#254](https://github.com/xataio/client-ts/pull/254) [`2fc2788`](https://github.com/xataio/client-ts/commit/2fc2788e583c047ffb2cd693f053f60ce608149c) Thanks [@SferaDev](https://github.com/SferaDev)! - Deprecate XataApiClient
260
+
261
+ * [#230](https://github.com/xataio/client-ts/pull/230) [`a96da7c`](https://github.com/xataio/client-ts/commit/a96da7c8b548604ed25001390992531537675a44) Thanks [@SferaDev](https://github.com/SferaDev)! - Include tables in Proxy target for object introspection (shell)
262
+
263
+ - [#222](https://github.com/xataio/client-ts/pull/222) [`e8d595f`](https://github.com/xataio/client-ts/commit/e8d595f54efe126b39c78cc771a5d69c551f4fba) Thanks [@SferaDev](https://github.com/SferaDev)! - Add cache strategies
264
+
265
+ * [#244](https://github.com/xataio/client-ts/pull/244) [`c4dcd11`](https://github.com/xataio/client-ts/commit/c4dcd110d8f9dc3a7e4510f2f00257c9109e51fa) Thanks [@gimenete](https://github.com/gimenete)! - getCurrentBranchName never returns a Promise that resolves to undefined
266
+
267
+ ## 0.8.4
268
+
269
+ ### Patch Changes
270
+
271
+ - dd958a4: Fix search results return type
272
+ - f5ec686: Make XataApiClientOptions optional
273
+
274
+ ## 0.8.3
275
+
276
+ ### Patch Changes
277
+
278
+ - c660356: Export ESM and CJS bundles
279
+
3
280
  ## 0.8.2
4
281
 
5
282
  ### Patch Changes
package/README.md CHANGED
@@ -1 +1,273 @@
1
- Visit https://github.com/xataio/client-ts for more information.
1
+ # Xata SDK for TypeScript and JavaScript
2
+
3
+ This SDK has zero dependencies, so it can be used in many JavaScript runtimes including Node.js, Cloudflare workers, Deno, Electron, etc. It also works in browsers for the same reason. But this is strongly discouraged because you can easily leak your API keys from browsers.
4
+
5
+ ## Table of Contents
6
+
7
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
8
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
9
+
10
+ - [Installation](#installation)
11
+ - [Usage](#usage)
12
+ - [Schema-generated Client](#schema-generated-client)
13
+ - [Schema-less Client](#schema-less-client)
14
+ - [API Design](#api-design)
15
+ - [Creating Records](#creating-records)
16
+ - [Query a Single Record by its ID](#query-a-single-record-by-its-id)
17
+ - [Querying Multiple Records](#querying-multiple-records)
18
+ - [Updating Records](#updating-records)
19
+ - [Deleting Records](#deleting-records)
20
+ - [API Client](#api-client)
21
+ - [Deno support](#deno-support)
22
+
23
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install @xata.io/client
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ There are three ways to use the SDK:
34
+
35
+ - **Schema-generated Client**: SDK to create/read/update/delete records in a given database following a schema file (with type-safety).
36
+ - **Schema-less Client**: SDK to create/read/update/delete records in any database without schema validation (with partial type-safety).
37
+ - **API Client**: SDK to interact with the whole Xata API and all its endpoints.
38
+
39
+ ### Schema-generated Client
40
+
41
+ To use the schema-generated client, you need to run the code generator utility that comes with [our CLI](https://docs.xata.io/cli/getting-started).
42
+
43
+ To run it (and assuming you have configured the project with `xata init`):
44
+
45
+ ```bash
46
+ xata codegen
47
+ ```
48
+
49
+ In a TypeScript file, start using the generated code like this:
50
+
51
+ ```ts
52
+ import { XataClient } from './xata'; // or wherever you chose to generate the client
53
+
54
+ const xata = new XataClient();
55
+ ```
56
+
57
+ The import above will differ if you chose to generate the code in a different location.
58
+
59
+ The `XataClient` constructor accepts an object with configuration options, like the `fetch` parameter, which is required only if your runtime doesn't provide a global `fetch` function. There's also a `databaseURL` argument that by default will contain a URL pointing to your database (e.g. `https://myworkspace-123abc.xata.sh/db/databasename`). It can be specified in the constructor to overwrite that value if for whatever reason you need to connect to a different workspace or database.
60
+
61
+ The code generator will create two TypeScript types for each schema entity. The base one will be an `Identifiable` entity with the internal properties your entity has and the `Record` one will extend it with a set of operations (update, delete, etc...) and some schema metadata (xata version).
62
+
63
+ ```ts
64
+ interface User extends Identifiable {
65
+ email?: string | null;
66
+ }
67
+
68
+ type UserRecord = User & XataRecord;
69
+
70
+ async function initializeDatabase(admin: User): Promise<UserRecord> {
71
+ return xata.db.users.create(admin);
72
+ }
73
+
74
+ const admin = await initializeDatabase({ email: 'admin@example.com' });
75
+ await admin.update({ email: 'admin@foo.bar' });
76
+ await admin.delete();
77
+ ```
78
+
79
+ You will learn more about the available operations below, under the [`API Design`](#api-design) section.
80
+
81
+ ### Schema-less Client
82
+
83
+ If you don't have a schema file, or you are building a generic way to interact with Xata, you can use the `BaseClient` class without schema validation.
84
+
85
+ ```ts
86
+ import { BaseClient } from '@xata.io/client';
87
+
88
+ const xata = new BaseClient({
89
+ branch: 'branchname',
90
+ apiKey: 'xau_1234abcdef',
91
+ fetch: fetchImplementation // Required if your runtime doesn't provide a global `fetch` function.
92
+ });
93
+ ```
94
+
95
+ It works the same way as the code-generated `XataClient` but doesn't provide type-safety for your model.
96
+
97
+ You can read more on the methods available below, in the next section.
98
+
99
+ ### API Design
100
+
101
+ The Xata SDK to create/read/update/delete records follows the [repository pattern](https://lyz-code.github.io/blue-book/architecture/repository_pattern/). Each table will have a repository object available at `xata.db.[table-name]`.
102
+
103
+ For example if you have a `users` table, there'll be a repository at `xata.db.users`. If you're using the schema-less client, you can also use the `xata.db.[table-name]` syntax to access the repository but without TypeScript auto-completion.
104
+
105
+ #### Creating Records
106
+
107
+ Invoke the `create()` method in the repository. Example:
108
+
109
+ ```ts
110
+ const user = await xata.db.users.create({
111
+ fullName: 'John Smith'
112
+ });
113
+ ```
114
+
115
+ If you want to create a record with a specific ID, you can invoke `insert()`.
116
+
117
+ ```ts
118
+ const user = await xata.db.users.insert('user_admin', {
119
+ fullName: 'John Smith'
120
+ });
121
+ ```
122
+
123
+ And if you want to create or insert a record with a specific ID, you can invoke `updateOrInsert()`.
124
+
125
+ ```ts
126
+ const user = await xata.db.users.updateOrInsert('user_admin', {
127
+ fullName: 'John Smith'
128
+ });
129
+ ```
130
+
131
+ #### Query a Single Record by its ID
132
+
133
+ ```ts
134
+ // `user` will be null if the record cannot be found
135
+ const user = await xata.db.users.read('rec_1234abcdef');
136
+ ```
137
+
138
+ #### Querying Multiple Records
139
+
140
+ ```ts
141
+ // Query records selecting all fields.
142
+ const page = await xata.db.users.select().getPaginated();
143
+ const user = await xata.db.users.select().getFirst();
144
+
145
+ // You can also use `xata.db.users` directly, since it's an immutable Query too!
146
+ const page = await xata.db.users.getPaginated();
147
+ const user = await xata.db.users.getFirst();
148
+
149
+ // Query records selecting just one or more fields
150
+ const page = await xata.db.users.select('email', 'profile').getPaginated();
151
+
152
+ // Apply constraints
153
+ const page = await xata.db.users.filter('email', 'foo@example.com').getPaginated();
154
+
155
+ // Sorting
156
+ const page = await xata.db.users.sort('full_name', 'asc').getPaginated();
157
+ ```
158
+
159
+ Query operations (`select()`, `filter()`, `sort()`) return a `Query` object. These objects are immutable. You can add additional constraints, `sort`, etc. by calling their methods, and a new query will be returned. In order to finally make a query to the database you'll invoke `getPaginated()`, `getMany()`, `getAll()`, or `getFirst()`.
160
+
161
+ To learn the differences between these methods, see the [reference](https://docs.xata.io/sdk/reference#query).
162
+
163
+ ```ts
164
+ // Operators that combine multiple conditions can be deconstructed
165
+ const { filter, any, all, not, sort } = xata.db.users;
166
+ const query = filter('email', 'foo@example.com');
167
+
168
+ // Single-column operators are imported directly from the package
169
+ import { gt, includes, startsWith } from '@xata.io/client';
170
+ filter('email', startsWith('username')).not(filter('created_at', gt(somePastDate)));
171
+
172
+ // Queries are immutable objects. This is useful to derive queries from other queries
173
+ const admins = filter('admin', true);
174
+ const spaniardsAdmins = admins.filter('country', 'Spain');
175
+ await admins.getAll(); // still returns all admins
176
+
177
+ // Finally fetch the results of the query
178
+ const users = await query.getAll();
179
+ const firstUser = await query.getFirst();
180
+ ```
181
+
182
+ The `getPaginated()` method will return a `Page` object. It's a wrapper that internally uses cursor based pagination.
183
+
184
+ ```ts
185
+ page.records; // Array of records
186
+ page.hasNextPage(); // Boolean
187
+
188
+ const nextPage = await page.nextPage(); // Page object
189
+ const previousPage = await page.previousPage(); // Page object
190
+ const firstPage = await page.firstPage(); // Page object
191
+ const lastPage = await page.lastPage(); // Page object
192
+ ```
193
+
194
+ If you want to use an iterator, both the Repository and the Query classes implement an `AsyncIterable`. Alternatively you can use `getIterator()` and customize the batch size of the iterator:
195
+
196
+ ```ts
197
+ for await (const record of xata.db.users) {
198
+ console.log(record);
199
+ }
200
+
201
+ for await (const record of xata.db.users.filter('team.id', teamId)) {
202
+ console.log(record);
203
+ }
204
+
205
+ for await (const records of xata.db.users.getIterator({ batchSize: 100 })) {
206
+ console.log(records);
207
+ }
208
+ ```
209
+
210
+ #### Updating Records
211
+
212
+ Updating a record leaves the existing object unchanged, but returns a new object with the updated values.
213
+
214
+ ```ts
215
+ // Using an existing object
216
+ const updatedUser = await user.update({
217
+ fullName: 'John Smith Jr.'
218
+ });
219
+
220
+ // Using a record id
221
+ const updatedUser = await xata.db.users.update('rec_1234abcdef', {
222
+ fullName: 'John Smith Jr.'
223
+ });
224
+ ```
225
+
226
+ #### Deleting Records
227
+
228
+ ```ts
229
+ // Using an existing object
230
+ await user.delete();
231
+
232
+ // Using a record id
233
+ await xata.db.users.delete('rec_1234abcdef');
234
+ ```
235
+
236
+ ### API Client
237
+
238
+ One of the main features of the SDK is the ability to interact with the whole Xata API and perform administrative operations such as creating/reading/updating/deleting [workspaces](https://docs.xata.io/concepts/workspaces), databases, tables, branches...
239
+
240
+ To communicate with the SDK we provide a constructor called `XataApiClient` that accepts an API token and an optional fetch implementation method.
241
+
242
+ ```ts
243
+ const api = new XataApiClient({ apiKey: process.env.XATA_API_KEY });
244
+ ```
245
+
246
+ Once you have initialized the API client, the operations are organized following the same hiearchy as in the [official documentation](https://docs.xata.io). You have different namespaces for each entity (ie. `workspaces`, `databases`, `tables`, `branches`, `users`, `records`...).
247
+
248
+ ```ts
249
+ const { id: workspace } = await api.workspaces.createWorkspace({ name: 'example' });
250
+ const { databaseName } = await api.databases.createDatabase(workspace, 'database');
251
+
252
+ await api.branches.createBranch(workspace, databaseName, 'branch');
253
+ await api.tables.createTable(workspace, databaseName, 'branch', 'table');
254
+ await api.tables.setTableSchema(workspace, databaseName, 'branch', 'table', {
255
+ columns: [{ name: 'email', type: 'string' }]
256
+ });
257
+
258
+ const { id: recordId } = await api.records.insertRecord(workspace, databaseName, 'branch', 'table', {
259
+ email: 'example@foo.bar'
260
+ });
261
+
262
+ const record = await api.records.getRecord(workspace, databaseName, 'branch', 'table', recordId);
263
+
264
+ await api.workspaces.deleteWorkspace(workspace);
265
+ ```
266
+
267
+ ## Deno support
268
+
269
+ We publish the client on [deno.land](https://deno.land/x/xata). You can use it by changing the import in the auto-generated `xata.ts` file:
270
+
271
+ ```ts
272
+ import { buildClient, BaseClientOptions, XataRecord } from 'https://deno.land/x/xata/mod.ts';
273
+ ```