@xata.io/client 0.0.0-alpha.fa684a0 → 0.0.0-beta.103e462
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/CHANGELOG.md +13 -0
- package/dist/api/client.d.ts +2 -0
- package/dist/api/client.js +6 -0
- package/dist/api/components.d.ts +24 -0
- package/dist/api/components.js +14 -1
- package/dist/api/parameters.d.ts +1 -0
- package/dist/api/schemas.d.ts +1 -1
- package/dist/schema/record.d.ts +7 -2
- package/dist/schema/repository.d.ts +11 -3
- package/dist/schema/repository.js +26 -17
- package/dist/schema/selection.d.ts +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# @xata.io/client
|
2
|
+
|
3
|
+
## 0.3.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- 1c0a454: Add API Client and internally use it
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- 122321c: Fix client in CF workers and Deno
|
12
|
+
- a2671b5: Allow cancel or resend workspace invites
|
13
|
+
- e73d470: Split insert and create
|
package/dist/api/client.d.ts
CHANGED
@@ -40,6 +40,8 @@ declare class WorkspaceApi {
|
|
40
40
|
updateWorkspaceMemberRole(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID, role: Schemas.Role): Promise<void>;
|
41
41
|
removeWorkspaceMember(workspaceId: Schemas.WorkspaceID, userId: Schemas.UserID): Promise<void>;
|
42
42
|
inviteWorkspaceMember(workspaceId: Schemas.WorkspaceID, email: string, role: Schemas.Role): Promise<Schemas.WorkspaceInvite>;
|
43
|
+
cancelWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteId: Schemas.InviteID): Promise<void>;
|
44
|
+
resendWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteId: Schemas.InviteID): Promise<void>;
|
43
45
|
acceptWorkspaceMemberInvite(workspaceId: Schemas.WorkspaceID, inviteKey: Schemas.InviteKey): Promise<void>;
|
44
46
|
}
|
45
47
|
declare class DatabaseApi {
|
package/dist/api/client.js
CHANGED
@@ -107,6 +107,12 @@ class WorkspaceApi {
|
|
107
107
|
inviteWorkspaceMember(workspaceId, email, role) {
|
108
108
|
return components_1.operationsByTag.workspaces.inviteWorkspaceMember(Object.assign({ pathParams: { workspaceId }, body: { email, role } }, this.extraProps));
|
109
109
|
}
|
110
|
+
cancelWorkspaceMemberInvite(workspaceId, inviteId) {
|
111
|
+
return components_1.operationsByTag.workspaces.cancelWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteId } }, this.extraProps));
|
112
|
+
}
|
113
|
+
resendWorkspaceMemberInvite(workspaceId, inviteId) {
|
114
|
+
return components_1.operationsByTag.workspaces.resendWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteId } }, this.extraProps));
|
115
|
+
}
|
110
116
|
acceptWorkspaceMemberInvite(workspaceId, inviteKey) {
|
111
117
|
return components_1.operationsByTag.workspaces.acceptWorkspaceMemberInvite(Object.assign({ pathParams: { workspaceId, inviteKey } }, this.extraProps));
|
112
118
|
}
|
package/dist/api/components.d.ts
CHANGED
@@ -161,6 +161,28 @@ export declare type InviteWorkspaceMemberVariables = {
|
|
161
161
|
* Invite some user to join the workspace with the given role
|
162
162
|
*/
|
163
163
|
export declare const inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<Schemas.WorkspaceInvite>;
|
164
|
+
export declare type CancelWorkspaceMemberInvitePathParams = {
|
165
|
+
workspaceId: Schemas.WorkspaceID;
|
166
|
+
inviteId: Schemas.InviteID;
|
167
|
+
};
|
168
|
+
export declare type CancelWorkspaceMemberInviteVariables = {
|
169
|
+
pathParams: CancelWorkspaceMemberInvitePathParams;
|
170
|
+
} & FetcherExtraProps;
|
171
|
+
/**
|
172
|
+
* This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
|
173
|
+
*/
|
174
|
+
export declare const cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
175
|
+
export declare type ResendWorkspaceMemberInvitePathParams = {
|
176
|
+
workspaceId: Schemas.WorkspaceID;
|
177
|
+
inviteId: Schemas.InviteID;
|
178
|
+
};
|
179
|
+
export declare type ResendWorkspaceMemberInviteVariables = {
|
180
|
+
pathParams: ResendWorkspaceMemberInvitePathParams;
|
181
|
+
} & FetcherExtraProps;
|
182
|
+
/**
|
183
|
+
* This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
|
184
|
+
*/
|
185
|
+
export declare const resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
164
186
|
export declare type AcceptWorkspaceMemberInvitePathParams = {
|
165
187
|
workspaceId: Schemas.WorkspaceID;
|
166
188
|
inviteKey: Schemas.InviteKey;
|
@@ -1371,6 +1393,8 @@ export declare const operationsByTag: {
|
|
1371
1393
|
updateWorkspaceMemberRole: (variables: UpdateWorkspaceMemberRoleVariables) => Promise<undefined>;
|
1372
1394
|
removeWorkspaceMember: (variables: RemoveWorkspaceMemberVariables) => Promise<undefined>;
|
1373
1395
|
inviteWorkspaceMember: (variables: InviteWorkspaceMemberVariables) => Promise<Schemas.WorkspaceInvite>;
|
1396
|
+
cancelWorkspaceMemberInvite: (variables: CancelWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1397
|
+
resendWorkspaceMemberInvite: (variables: ResendWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1374
1398
|
acceptWorkspaceMemberInvite: (variables: AcceptWorkspaceMemberInviteVariables) => Promise<undefined>;
|
1375
1399
|
};
|
1376
1400
|
database: {
|
package/dist/api/components.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.searchBranch = exports.queryTable = exports.bulkInsertTableRecords = exports.getRecord = exports.deleteRecord = exports.upsertRecordWithID = exports.updateRecordWithID = exports.insertRecordWithID = exports.insertRecord = exports.updateColumn = exports.deleteColumn = exports.getColumn = exports.addTableColumn = exports.getTableColumns = exports.setTableSchema = exports.getTableSchema = exports.updateTable = exports.deleteTable = exports.createTable = exports.getBranchStats = exports.getBranchMigrationPlan = exports.executeBranchMigrationPlan = exports.getBranchMigrationHistory = exports.getBranchMetadata = exports.updateBranchMetadata = exports.deleteBranch = exports.createBranch = exports.getBranchDetails = exports.deleteDatabase = exports.createDatabase = exports.getBranchList = exports.getDatabaseList = exports.acceptWorkspaceMemberInvite = exports.resendWorkspaceMemberInvite = exports.cancelWorkspaceMemberInvite = exports.inviteWorkspaceMember = exports.removeWorkspaceMember = exports.updateWorkspaceMemberRole = exports.getWorkspaceMembersList = exports.deleteWorkspace = exports.updateWorkspace = exports.getWorkspace = exports.getWorkspacesList = exports.createWorkspace = exports.deleteUserAPIKey = exports.createUserAPIKey = exports.getUserAPIKeys = exports.deleteUser = exports.updateUser = exports.getUser = void 0;
|
4
|
+
exports.operationsByTag = void 0;
|
4
5
|
/**
|
5
6
|
* Generated by @openapi-codegen
|
6
7
|
*
|
@@ -82,6 +83,16 @@ exports.removeWorkspaceMember = removeWorkspaceMember;
|
|
82
83
|
*/
|
83
84
|
const inviteWorkspaceMember = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites', method: 'post' }, variables));
|
84
85
|
exports.inviteWorkspaceMember = inviteWorkspaceMember;
|
86
|
+
/**
|
87
|
+
* This operation provides a way to cancel invites by deleting them. Already accepted invites cannot be deleted.
|
88
|
+
*/
|
89
|
+
const cancelWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}', method: 'delete' }, variables));
|
90
|
+
exports.cancelWorkspaceMemberInvite = cancelWorkspaceMemberInvite;
|
91
|
+
/**
|
92
|
+
* This operation provides a way to resend an Invite notification. Invite notifications can only be sent for Invites not yet accepted.
|
93
|
+
*/
|
94
|
+
const resendWorkspaceMemberInvite = (variables) => (0, fetcher_1.fetch)(Object.assign({ url: '/workspaces/{workspaceId}/invites/{inviteId}/resend', method: 'post' }, variables));
|
95
|
+
exports.resendWorkspaceMemberInvite = resendWorkspaceMemberInvite;
|
85
96
|
/**
|
86
97
|
* Accept the invitation to join a workspace. If the operation succeeds the user will be a member of the workspace
|
87
98
|
*/
|
@@ -947,6 +958,8 @@ exports.operationsByTag = {
|
|
947
958
|
updateWorkspaceMemberRole: exports.updateWorkspaceMemberRole,
|
948
959
|
removeWorkspaceMember: exports.removeWorkspaceMember,
|
949
960
|
inviteWorkspaceMember: exports.inviteWorkspaceMember,
|
961
|
+
cancelWorkspaceMemberInvite: exports.cancelWorkspaceMemberInvite,
|
962
|
+
resendWorkspaceMemberInvite: exports.resendWorkspaceMemberInvite,
|
950
963
|
acceptWorkspaceMemberInvite: exports.acceptWorkspaceMemberInvite
|
951
964
|
},
|
952
965
|
database: { getDatabaseList: exports.getDatabaseList, createDatabase: exports.createDatabase, deleteDatabase: exports.deleteDatabase },
|
package/dist/api/parameters.d.ts
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
*/
|
6
6
|
import type * as Schemas from './schemas';
|
7
7
|
export declare type APIKeyNameParam = Schemas.APIKeyName;
|
8
|
+
export declare type InviteIDParam = Schemas.InviteID;
|
8
9
|
export declare type InviteKeyParam = Schemas.InviteKey;
|
9
10
|
export declare type UserIDParam = Schemas.UserID;
|
10
11
|
export declare type WorkspaceIDParam = Schemas.WorkspaceID;
|
package/dist/api/schemas.d.ts
CHANGED
@@ -130,7 +130,7 @@ export declare type Table = {
|
|
130
130
|
*/
|
131
131
|
export declare type Column = {
|
132
132
|
name: string;
|
133
|
-
type: 'bool' | 'int' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
133
|
+
type: 'bool' | 'int' | 'float' | 'string' | 'text' | 'email' | 'multiple' | 'link' | 'object';
|
134
134
|
link?: {
|
135
135
|
table: string;
|
136
136
|
};
|
package/dist/schema/record.d.ts
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
import { Selectable } from './selection';
|
2
2
|
/**
|
3
|
-
* Represents
|
3
|
+
* Represents an identifiable record from the database.
|
4
4
|
*/
|
5
|
-
export interface
|
5
|
+
export interface Identifiable {
|
6
6
|
/**
|
7
7
|
* Unique id of this record.
|
8
8
|
*/
|
9
9
|
id: string;
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* Represents a persisted record from the database.
|
13
|
+
*/
|
14
|
+
export interface XataRecord extends Identifiable {
|
10
15
|
/**
|
11
16
|
* Metadata of this record.
|
12
17
|
*/
|
@@ -26,6 +26,13 @@ export declare abstract class Repository<T extends XataRecord> extends Query<T>
|
|
26
26
|
* @returns The persisted record for the given id or null if the record could not be found.
|
27
27
|
*/
|
28
28
|
abstract read(id: string): Promise<T | null>;
|
29
|
+
/**
|
30
|
+
* Insert a single record with a unique id.
|
31
|
+
* @param id The unique id.
|
32
|
+
* @param object Object containing the column names with their values to be stored in the table.
|
33
|
+
* @returns The full persisted record.
|
34
|
+
*/
|
35
|
+
abstract insert(id: string, object: Selectable<T>): Promise<T>;
|
29
36
|
/**
|
30
37
|
* Partially update a single record given its unique id.
|
31
38
|
* @param id The unique id.
|
@@ -34,13 +41,13 @@ export declare abstract class Repository<T extends XataRecord> extends Query<T>
|
|
34
41
|
*/
|
35
42
|
abstract update(id: string, object: Partial<Selectable<T>>): Promise<T>;
|
36
43
|
/**
|
37
|
-
* Updates or
|
44
|
+
* Updates or inserts a single record. If a record exists with the given id,
|
38
45
|
* it will be update, otherwise a new record will be created.
|
39
46
|
* @param id A unique id.
|
40
47
|
* @param object The column names and the values to be persisted.
|
41
48
|
* @returns The full persisted record.
|
42
49
|
*/
|
43
|
-
abstract
|
50
|
+
abstract updateOrInsert(id: string, object: Selectable<T>): Promise<T>;
|
44
51
|
/**
|
45
52
|
* Deletes a record given its unique id.
|
46
53
|
* @param id The unique id.
|
@@ -58,7 +65,8 @@ export declare class RestRepository<T extends XataRecord> extends Repository<T>
|
|
58
65
|
createMany(objects: T[]): Promise<T[]>;
|
59
66
|
read(recordId: string): Promise<T | null>;
|
60
67
|
update(recordId: string, object: Partial<Selectable<T>>): Promise<T>;
|
61
|
-
|
68
|
+
insert(recordId: string, object: Selectable<T>): Promise<T>;
|
69
|
+
updateOrInsert(recordId: string, object: Selectable<T>): Promise<T>;
|
62
70
|
delete(recordId: string): Promise<void>;
|
63
71
|
query<R extends XataRecord, Options extends QueryOptions<T>>(query: Query<T, R>, options?: Options): Promise<Page<T, typeof options extends {
|
64
72
|
columns: SelectableColumn<T>[];
|
@@ -59,18 +59,11 @@ class RestRepository extends Repository {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
60
60
|
const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
|
61
61
|
const record = transformObjectLinks(object);
|
62
|
-
const response =
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
recordId: object.id
|
68
|
-
}, body: record }, fetchProps))
|
69
|
-
: yield (0, api_1.insertRecord)(Object.assign({ pathParams: {
|
70
|
-
workspace: '{workspaceId}',
|
71
|
-
dbBranchName: '{dbBranch}',
|
72
|
-
tableName: __classPrivateFieldGet(this, _RestRepository_table, "f")
|
73
|
-
}, body: record }, fetchProps));
|
62
|
+
const response = yield (0, api_1.insertRecord)(Object.assign({ pathParams: {
|
63
|
+
workspace: '{workspaceId}',
|
64
|
+
dbBranchName: '{dbBranch}',
|
65
|
+
tableName: __classPrivateFieldGet(this, _RestRepository_table, "f")
|
66
|
+
}, body: record }, fetchProps));
|
74
67
|
const finalObject = yield this.read(response.id);
|
75
68
|
if (!finalObject) {
|
76
69
|
throw new Error('The server failed to save the record');
|
@@ -83,10 +76,9 @@ class RestRepository extends Repository {
|
|
83
76
|
const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
|
84
77
|
const records = objects.map((object) => transformObjectLinks(object));
|
85
78
|
const response = yield (0, api_1.bulkInsertTableRecords)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}', tableName: __classPrivateFieldGet(this, _RestRepository_table, "f") }, body: { records } }, fetchProps));
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
throw new Error('The server failed to save the record');
|
79
|
+
const finalObjects = yield this.any(...response.recordIDs.map((id) => this.filter('id', id))).getMany();
|
80
|
+
if (finalObjects.length !== objects.length) {
|
81
|
+
throw new Error('The server failed to save some records');
|
90
82
|
}
|
91
83
|
return finalObjects;
|
92
84
|
});
|
@@ -108,7 +100,24 @@ class RestRepository extends Repository {
|
|
108
100
|
return item;
|
109
101
|
});
|
110
102
|
}
|
111
|
-
|
103
|
+
insert(recordId, object) {
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
105
|
+
const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
|
106
|
+
const record = transformObjectLinks(object);
|
107
|
+
const response = yield (0, api_1.insertRecordWithID)(Object.assign({ pathParams: {
|
108
|
+
workspace: '{workspaceId}',
|
109
|
+
dbBranchName: '{dbBranch}',
|
110
|
+
tableName: __classPrivateFieldGet(this, _RestRepository_table, "f"),
|
111
|
+
recordId
|
112
|
+
}, body: record }, fetchProps));
|
113
|
+
const finalObject = yield this.read(response.id);
|
114
|
+
if (!finalObject) {
|
115
|
+
throw new Error('The server failed to save the record');
|
116
|
+
}
|
117
|
+
return finalObject;
|
118
|
+
});
|
119
|
+
}
|
120
|
+
updateOrInsert(recordId, object) {
|
112
121
|
return __awaiter(this, void 0, void 0, function* () {
|
113
122
|
const fetchProps = yield __classPrivateFieldGet(this, _RestRepository_instances, "m", _RestRepository_getFetchProps).call(this);
|
114
123
|
const response = yield (0, api_1.upsertRecordWithID)(Object.assign({ pathParams: { workspace: '{workspaceId}', dbBranchName: '{dbBranch}', tableName: __classPrivateFieldGet(this, _RestRepository_table, "f"), recordId }, body: object }, fetchProps));
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { XataRecord } from '..';
|
2
|
-
import { PartialBy } from '../util/lang';
|
3
2
|
import { StringKeys, UnionToIntersection, Values } from '../util/types';
|
4
3
|
import { Query } from './query';
|
4
|
+
import { Identifiable } from './record';
|
5
5
|
declare type Queries<T> = {
|
6
6
|
[key in keyof T as T[key] extends Query<any> ? key : never]: T[key];
|
7
7
|
};
|
8
|
-
declare type InternalProperties = keyof
|
9
|
-
export declare type Selectable<T extends XataRecord> = Omit<
|
8
|
+
declare type InternalProperties = keyof XataRecord;
|
9
|
+
export declare type Selectable<T extends XataRecord> = Omit<T, InternalProperties> & Identifiable;
|
10
10
|
export declare type SelectableColumn<O> = '*' | (O extends Array<unknown> ? never : O extends Record<string, any> ? '*' | Values<{
|
11
11
|
[K in StringKeys<O>]: O[K] extends Record<string, any> ? `${K}.${SelectableColumn<O[K]>}` : K;
|
12
12
|
}> : '');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@xata.io/client",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-beta.103e462",
|
4
4
|
"description": "Xata.io SDK for TypeScript and JavaScript",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.ts",
|
@@ -20,5 +20,5 @@
|
|
20
20
|
"url": "https://github.com/xataio/client-ts/issues"
|
21
21
|
},
|
22
22
|
"homepage": "https://github.com/xataio/client-ts/blob/main/client/README.md",
|
23
|
-
"gitHead": "
|
23
|
+
"gitHead": "103e46248cb25543e29be8405a122762109a4b0f"
|
24
24
|
}
|