@revisium/client 0.2.0 → 0.3.0
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/README.md +13 -1
- package/dist/data-operations.d.ts +10 -3
- package/dist/data-operations.d.ts.map +1 -1
- package/dist/index.cjs +69 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +69 -22
- package/dist/index.mjs.map +1 -1
- package/dist/revisium-client.d.ts +10 -3
- package/dist/revisium-client.d.ts.map +1 -1
- package/dist/revisium-scope.d.ts +9 -3
- package/dist/revisium-scope.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,8 @@ await client.login('username', 'password');
|
|
|
77
77
|
client.loginWithToken('jwt-token');
|
|
78
78
|
|
|
79
79
|
client.isAuthenticated(); // boolean
|
|
80
|
+
|
|
81
|
+
const user = await client.me(); // { id, username, email, hasPassword }
|
|
80
82
|
```
|
|
81
83
|
|
|
82
84
|
### Context
|
|
@@ -105,6 +107,7 @@ await client.getTableSchema('posts');
|
|
|
105
107
|
await client.getRows('posts', { first: 100 });
|
|
106
108
|
await client.getRow('posts', 'post-1');
|
|
107
109
|
await client.getChanges();
|
|
110
|
+
await client.getMigrations();
|
|
108
111
|
```
|
|
109
112
|
|
|
110
113
|
### Write Operations (draft only)
|
|
@@ -121,19 +124,26 @@ await client.renameTable('posts', 'articles');
|
|
|
121
124
|
// Rows
|
|
122
125
|
await client.createRow('posts', 'row-1', data);
|
|
123
126
|
await client.createRows('posts', [{ rowId: 'r1', data }, { rowId: 'r2', data }]);
|
|
127
|
+
await client.createRows('posts', rows, { isRestore: true }); // restore mode
|
|
124
128
|
await client.updateRow('posts', 'row-1', data);
|
|
125
129
|
await client.updateRows('posts', [{ rowId: 'r1', data }]);
|
|
130
|
+
await client.updateRows('posts', rows, { isRestore: true }); // restore mode
|
|
126
131
|
await client.patchRow('posts', 'row-1', [{ op: 'replace', path: 'title', value: 'New' }]);
|
|
127
132
|
await client.deleteRow('posts', 'row-1');
|
|
128
133
|
await client.deleteRows('posts', ['row-1', 'row-2']);
|
|
129
134
|
await client.renameRow('posts', 'row-1', 'post-1');
|
|
135
|
+
|
|
136
|
+
// Migrations
|
|
137
|
+
await client.applyMigrations([
|
|
138
|
+
{ type: 'init', tableId: 'posts', schema },
|
|
139
|
+
]);
|
|
130
140
|
```
|
|
131
141
|
|
|
132
142
|
### Version Control (draft only)
|
|
133
143
|
|
|
134
144
|
```typescript
|
|
135
145
|
const revision = await client.commit('my changes'); // auto-refreshes draftRevisionId
|
|
136
|
-
await client.revertChanges();
|
|
146
|
+
await client.revertChanges(); // auto-refreshes draftRevisionId
|
|
137
147
|
```
|
|
138
148
|
|
|
139
149
|
### Isolated Scopes (`withContext`)
|
|
@@ -196,6 +206,8 @@ scope.client; // underlying HTTP client (shared with parent)
|
|
|
196
206
|
// Same data methods as RevisiumClient
|
|
197
207
|
await scope.getTables();
|
|
198
208
|
await scope.createRow('posts', 'row-1', data);
|
|
209
|
+
await scope.getMigrations();
|
|
210
|
+
await scope.applyMigrations(migrations);
|
|
199
211
|
await scope.commit('message');
|
|
200
212
|
// ... all other read/write/version-control methods
|
|
201
213
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Client } from './generated/client/index.js';
|
|
2
|
-
import type { CreateRowResponse, CreateRowsResponse, CreateTableResponse, GetTableRowsDto, PatchRow, PatchRowResponse, RenameRowResponse, RenameTableResponse, RevisionChangesResponse, RevisionModel, RowModel, RowsConnection, TableModel, TablesConnection, UpdateRowResponse, UpdateRowsResponse, UpdateTableResponse } from './generated/types.gen.js';
|
|
2
|
+
import type { CreateRowResponse, CreateRowsResponse, CreateTableResponse, GetTableRowsDto, InitMigrationDto, MeModel, MigrationsResponse, PatchRow, PatchRowResponse, RemoveMigrationDto, RenameMigrationDto, RenameRowResponse, RenameTableResponse, RevisionChangesResponse, RevisionModel, RowModel, RowsConnection, TableModel, TablesConnection, UpdateMigrationDto, UpdateRowResponse, UpdateRowsResponse, UpdateTableResponse } from './generated/types.gen.js';
|
|
3
3
|
export interface BranchContext {
|
|
4
4
|
readonly organizationId: string;
|
|
5
5
|
readonly projectName: string;
|
|
@@ -17,6 +17,9 @@ export declare function unwrap<T>(result: {
|
|
|
17
17
|
}): T;
|
|
18
18
|
export declare function assertDraft(ctx: ScopeContext): void;
|
|
19
19
|
export declare function assertContext(ctx: ScopeContext): void;
|
|
20
|
+
export declare function me(client: Client): Promise<MeModel>;
|
|
21
|
+
export declare function getMigrations(ctx: ScopeContext): Promise<MigrationsResponse>;
|
|
22
|
+
export declare function applyMigrations(ctx: ScopeContext, migrations: Array<InitMigrationDto | UpdateMigrationDto | RenameMigrationDto | RemoveMigrationDto>): Promise<void>;
|
|
20
23
|
export declare function getTables(ctx: ScopeContext, options?: {
|
|
21
24
|
first?: number;
|
|
22
25
|
after?: string;
|
|
@@ -34,12 +37,16 @@ export declare function createRow(ctx: ScopeContext, tableId: string, rowId: str
|
|
|
34
37
|
export declare function createRows(ctx: ScopeContext, tableId: string, rows: Array<{
|
|
35
38
|
rowId: string;
|
|
36
39
|
data: object;
|
|
37
|
-
}
|
|
40
|
+
}>, options?: {
|
|
41
|
+
isRestore?: boolean;
|
|
42
|
+
}): Promise<CreateRowsResponse>;
|
|
38
43
|
export declare function updateRow(ctx: ScopeContext, tableId: string, rowId: string, data: object): Promise<UpdateRowResponse>;
|
|
39
44
|
export declare function updateRows(ctx: ScopeContext, tableId: string, rows: Array<{
|
|
40
45
|
rowId: string;
|
|
41
46
|
data: object;
|
|
42
|
-
}
|
|
47
|
+
}>, options?: {
|
|
48
|
+
isRestore?: boolean;
|
|
49
|
+
}): Promise<UpdateRowsResponse>;
|
|
43
50
|
export declare function patchRow(ctx: ScopeContext, tableId: string, rowId: string, patches: PatchRow[]): Promise<PatchRowResponse>;
|
|
44
51
|
export declare function deleteRow(ctx: ScopeContext, tableId: string, rowId: string): Promise<void>;
|
|
45
52
|
export declare function deleteRows(ctx: ScopeContext, tableId: string, rowIds: string[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-operations.d.ts","sourceRoot":"","sources":["../src/data-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,CAAC,CAQlE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAOnD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAIrD;AAED,wBAAsB,SAAS,CAC7B,GAAG,EAAE,YAAY,EACjB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,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
|
|
|
658
658
|
var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
659
659
|
addUserToOrganization: () => addUserToOrganization,
|
|
660
660
|
addUserToProject: () => addUserToProject,
|
|
661
|
-
applyMigrations: () => applyMigrations,
|
|
661
|
+
applyMigrations: () => applyMigrations$1,
|
|
662
662
|
branch: () => branch,
|
|
663
663
|
branchTouched: () => branchTouched,
|
|
664
664
|
branches: () => branches,
|
|
@@ -685,7 +685,7 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
685
685
|
headRevision: () => headRevision,
|
|
686
686
|
liveness: () => liveness,
|
|
687
687
|
login: () => login,
|
|
688
|
-
me: () => me,
|
|
688
|
+
me: () => me$1,
|
|
689
689
|
migrations: () => migrations,
|
|
690
690
|
parentBranch: () => parentBranch,
|
|
691
691
|
parentRevision: () => parentRevision,
|
|
@@ -777,7 +777,7 @@ const updatePassword = (options) => (options.client ?? client).put({
|
|
|
777
777
|
/**
|
|
778
778
|
* Get current authenticated user
|
|
779
779
|
*/
|
|
780
|
-
const me = (options) => (options?.client ?? client).get({
|
|
780
|
+
const me$1 = (options) => (options?.client ?? client).get({
|
|
781
781
|
security: [{
|
|
782
782
|
scheme: "bearer",
|
|
783
783
|
type: "http"
|
|
@@ -1220,7 +1220,7 @@ const rowChanges = (options) => (options.client ?? client).get({
|
|
|
1220
1220
|
/**
|
|
1221
1221
|
* Apply schema migrations to this revision
|
|
1222
1222
|
*/
|
|
1223
|
-
const applyMigrations = (options) => (options.client ?? client).post({
|
|
1223
|
+
const applyMigrations$1 = (options) => (options.client ?? client).post({
|
|
1224
1224
|
security: [{
|
|
1225
1225
|
scheme: "bearer",
|
|
1226
1226
|
type: "http"
|
|
@@ -1621,6 +1621,26 @@ function assertDraft(ctx) {
|
|
|
1621
1621
|
function assertContext(ctx) {
|
|
1622
1622
|
if (!ctx.branch.organizationId) throw new Error("Context not set. Call setContext() first.");
|
|
1623
1623
|
}
|
|
1624
|
+
async function me(client) {
|
|
1625
|
+
return unwrap(await me$1({ client }));
|
|
1626
|
+
}
|
|
1627
|
+
async function getMigrations(ctx) {
|
|
1628
|
+
assertContext(ctx);
|
|
1629
|
+
const revisionId = await ctx.getRevisionId();
|
|
1630
|
+
return unwrap(await migrations({
|
|
1631
|
+
client: ctx.client,
|
|
1632
|
+
path: { revisionId }
|
|
1633
|
+
}));
|
|
1634
|
+
}
|
|
1635
|
+
async function applyMigrations(ctx, migrations) {
|
|
1636
|
+
assertDraft(ctx);
|
|
1637
|
+
const revisionId = await ctx.getRevisionId();
|
|
1638
|
+
unwrap(await applyMigrations$1({
|
|
1639
|
+
client: ctx.client,
|
|
1640
|
+
path: { revisionId },
|
|
1641
|
+
body: migrations
|
|
1642
|
+
}));
|
|
1643
|
+
}
|
|
1624
1644
|
async function getTables(ctx, options) {
|
|
1625
1645
|
const revisionId = await ctx.getRevisionId();
|
|
1626
1646
|
return unwrap(await tables({
|
|
@@ -1743,7 +1763,7 @@ async function createRow(ctx, tableId, rowId, data) {
|
|
|
1743
1763
|
}
|
|
1744
1764
|
}));
|
|
1745
1765
|
}
|
|
1746
|
-
async function createRows(ctx, tableId, rows) {
|
|
1766
|
+
async function createRows(ctx, tableId, rows, options) {
|
|
1747
1767
|
assertDraft(ctx);
|
|
1748
1768
|
const revisionId = await ctx.getRevisionId();
|
|
1749
1769
|
return unwrap(await createRows$1({
|
|
@@ -1752,10 +1772,13 @@ async function createRows(ctx, tableId, rows) {
|
|
|
1752
1772
|
revisionId,
|
|
1753
1773
|
tableId
|
|
1754
1774
|
},
|
|
1755
|
-
body: {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1775
|
+
body: {
|
|
1776
|
+
rows: rows.map((r) => ({
|
|
1777
|
+
rowId: r.rowId,
|
|
1778
|
+
data: r.data
|
|
1779
|
+
})),
|
|
1780
|
+
isRestore: options?.isRestore
|
|
1781
|
+
}
|
|
1759
1782
|
}));
|
|
1760
1783
|
}
|
|
1761
1784
|
async function updateRow(ctx, tableId, rowId, data) {
|
|
@@ -1771,7 +1794,7 @@ async function updateRow(ctx, tableId, rowId, data) {
|
|
|
1771
1794
|
body: { data }
|
|
1772
1795
|
}));
|
|
1773
1796
|
}
|
|
1774
|
-
async function updateRows(ctx, tableId, rows) {
|
|
1797
|
+
async function updateRows(ctx, tableId, rows, options) {
|
|
1775
1798
|
assertDraft(ctx);
|
|
1776
1799
|
const revisionId = await ctx.getRevisionId();
|
|
1777
1800
|
return unwrap(await updateRows$1({
|
|
@@ -1780,10 +1803,13 @@ async function updateRows(ctx, tableId, rows) {
|
|
|
1780
1803
|
revisionId,
|
|
1781
1804
|
tableId
|
|
1782
1805
|
},
|
|
1783
|
-
body: {
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1806
|
+
body: {
|
|
1807
|
+
rows: rows.map((r) => ({
|
|
1808
|
+
rowId: r.rowId,
|
|
1809
|
+
data: r.data
|
|
1810
|
+
})),
|
|
1811
|
+
isRestore: options?.isRestore
|
|
1812
|
+
}
|
|
1787
1813
|
}));
|
|
1788
1814
|
}
|
|
1789
1815
|
async function patchRow(ctx, tableId, rowId, patches) {
|
|
@@ -1997,6 +2023,16 @@ var RevisiumScope = class {
|
|
|
1997
2023
|
async getChanges() {
|
|
1998
2024
|
return getChanges(this._scopeContext);
|
|
1999
2025
|
}
|
|
2026
|
+
async getMigrations() {
|
|
2027
|
+
return getMigrations(this._scopeContext);
|
|
2028
|
+
}
|
|
2029
|
+
async applyMigrations(migrations) {
|
|
2030
|
+
this.assertNotDisposed();
|
|
2031
|
+
await applyMigrations(this._scopeContext, migrations);
|
|
2032
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2033
|
+
this._stale = false;
|
|
2034
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2035
|
+
}
|
|
2000
2036
|
async createTable(tableId, schema) {
|
|
2001
2037
|
return createTable(this._scopeContext, tableId, schema);
|
|
2002
2038
|
}
|
|
@@ -2012,14 +2048,14 @@ var RevisiumScope = class {
|
|
|
2012
2048
|
async createRow(tableId, rowId, data) {
|
|
2013
2049
|
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2014
2050
|
}
|
|
2015
|
-
async createRows(tableId, rows) {
|
|
2016
|
-
return createRows(this._scopeContext, tableId, rows);
|
|
2051
|
+
async createRows(tableId, rows, options) {
|
|
2052
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
2017
2053
|
}
|
|
2018
2054
|
async updateRow(tableId, rowId, data) {
|
|
2019
2055
|
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2020
2056
|
}
|
|
2021
|
-
async updateRows(tableId, rows) {
|
|
2022
|
-
return updateRows(this._scopeContext, tableId, rows);
|
|
2057
|
+
async updateRows(tableId, rows, options) {
|
|
2058
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
2023
2059
|
}
|
|
2024
2060
|
async patchRow(tableId, rowId, patches) {
|
|
2025
2061
|
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
@@ -2107,6 +2143,9 @@ var RevisiumClient = class {
|
|
|
2107
2143
|
this._client.setConfig({ auth: token });
|
|
2108
2144
|
this._isAuthenticated = true;
|
|
2109
2145
|
}
|
|
2146
|
+
async me() {
|
|
2147
|
+
return me(this._client);
|
|
2148
|
+
}
|
|
2110
2149
|
async setContext(options) {
|
|
2111
2150
|
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
2112
2151
|
this._organizationId = organizationId;
|
|
@@ -2214,6 +2253,14 @@ var RevisiumClient = class {
|
|
|
2214
2253
|
async getChanges() {
|
|
2215
2254
|
return getChanges(this._scopeContext);
|
|
2216
2255
|
}
|
|
2256
|
+
async getMigrations() {
|
|
2257
|
+
return getMigrations(this._scopeContext);
|
|
2258
|
+
}
|
|
2259
|
+
async applyMigrations(migrations) {
|
|
2260
|
+
await applyMigrations(this._scopeContext, migrations);
|
|
2261
|
+
await this.refreshDraftRevisionId();
|
|
2262
|
+
this.notifyScopesOnCurrentBranch();
|
|
2263
|
+
}
|
|
2217
2264
|
async createTable(tableId, schema) {
|
|
2218
2265
|
return createTable(this._scopeContext, tableId, schema);
|
|
2219
2266
|
}
|
|
@@ -2229,14 +2276,14 @@ var RevisiumClient = class {
|
|
|
2229
2276
|
async createRow(tableId, rowId, data) {
|
|
2230
2277
|
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2231
2278
|
}
|
|
2232
|
-
async createRows(tableId, rows) {
|
|
2233
|
-
return createRows(this._scopeContext, tableId, rows);
|
|
2279
|
+
async createRows(tableId, rows, options) {
|
|
2280
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
2234
2281
|
}
|
|
2235
2282
|
async updateRow(tableId, rowId, data) {
|
|
2236
2283
|
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2237
2284
|
}
|
|
2238
|
-
async updateRows(tableId, rows) {
|
|
2239
|
-
return updateRows(this._scopeContext, tableId, rows);
|
|
2285
|
+
async updateRows(tableId, rows, options) {
|
|
2286
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
2240
2287
|
}
|
|
2241
2288
|
async patchRow(tableId, rowId, patches) {
|
|
2242
2289
|
return patchRow(this._scopeContext, tableId, rowId, patches);
|