@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/dist/index.mjs
CHANGED
|
@@ -656,7 +656,7 @@ const client = createClient(createConfig());
|
|
|
656
656
|
var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
657
657
|
addUserToOrganization: () => addUserToOrganization,
|
|
658
658
|
addUserToProject: () => addUserToProject,
|
|
659
|
-
applyMigrations: () => applyMigrations,
|
|
659
|
+
applyMigrations: () => applyMigrations$1,
|
|
660
660
|
branch: () => branch,
|
|
661
661
|
branchTouched: () => branchTouched,
|
|
662
662
|
branches: () => branches,
|
|
@@ -683,7 +683,7 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
683
683
|
headRevision: () => headRevision,
|
|
684
684
|
liveness: () => liveness,
|
|
685
685
|
login: () => login,
|
|
686
|
-
me: () => me,
|
|
686
|
+
me: () => me$1,
|
|
687
687
|
migrations: () => migrations,
|
|
688
688
|
parentBranch: () => parentBranch,
|
|
689
689
|
parentRevision: () => parentRevision,
|
|
@@ -775,7 +775,7 @@ const updatePassword = (options) => (options.client ?? client).put({
|
|
|
775
775
|
/**
|
|
776
776
|
* Get current authenticated user
|
|
777
777
|
*/
|
|
778
|
-
const me = (options) => (options?.client ?? client).get({
|
|
778
|
+
const me$1 = (options) => (options?.client ?? client).get({
|
|
779
779
|
security: [{
|
|
780
780
|
scheme: "bearer",
|
|
781
781
|
type: "http"
|
|
@@ -1218,7 +1218,7 @@ const rowChanges = (options) => (options.client ?? client).get({
|
|
|
1218
1218
|
/**
|
|
1219
1219
|
* Apply schema migrations to this revision
|
|
1220
1220
|
*/
|
|
1221
|
-
const applyMigrations = (options) => (options.client ?? client).post({
|
|
1221
|
+
const applyMigrations$1 = (options) => (options.client ?? client).post({
|
|
1222
1222
|
security: [{
|
|
1223
1223
|
scheme: "bearer",
|
|
1224
1224
|
type: "http"
|
|
@@ -1619,6 +1619,26 @@ function assertDraft(ctx) {
|
|
|
1619
1619
|
function assertContext(ctx) {
|
|
1620
1620
|
if (!ctx.branch.organizationId) throw new Error("Context not set. Call setContext() first.");
|
|
1621
1621
|
}
|
|
1622
|
+
async function me(client) {
|
|
1623
|
+
return unwrap(await me$1({ client }));
|
|
1624
|
+
}
|
|
1625
|
+
async function getMigrations(ctx) {
|
|
1626
|
+
assertContext(ctx);
|
|
1627
|
+
const revisionId = await ctx.getRevisionId();
|
|
1628
|
+
return unwrap(await migrations({
|
|
1629
|
+
client: ctx.client,
|
|
1630
|
+
path: { revisionId }
|
|
1631
|
+
}));
|
|
1632
|
+
}
|
|
1633
|
+
async function applyMigrations(ctx, migrations) {
|
|
1634
|
+
assertDraft(ctx);
|
|
1635
|
+
const revisionId = await ctx.getRevisionId();
|
|
1636
|
+
unwrap(await applyMigrations$1({
|
|
1637
|
+
client: ctx.client,
|
|
1638
|
+
path: { revisionId },
|
|
1639
|
+
body: migrations
|
|
1640
|
+
}));
|
|
1641
|
+
}
|
|
1622
1642
|
async function getTables(ctx, options) {
|
|
1623
1643
|
const revisionId = await ctx.getRevisionId();
|
|
1624
1644
|
return unwrap(await tables({
|
|
@@ -1741,7 +1761,7 @@ async function createRow(ctx, tableId, rowId, data) {
|
|
|
1741
1761
|
}
|
|
1742
1762
|
}));
|
|
1743
1763
|
}
|
|
1744
|
-
async function createRows(ctx, tableId, rows) {
|
|
1764
|
+
async function createRows(ctx, tableId, rows, options) {
|
|
1745
1765
|
assertDraft(ctx);
|
|
1746
1766
|
const revisionId = await ctx.getRevisionId();
|
|
1747
1767
|
return unwrap(await createRows$1({
|
|
@@ -1750,10 +1770,13 @@ async function createRows(ctx, tableId, rows) {
|
|
|
1750
1770
|
revisionId,
|
|
1751
1771
|
tableId
|
|
1752
1772
|
},
|
|
1753
|
-
body: {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1773
|
+
body: {
|
|
1774
|
+
rows: rows.map((r) => ({
|
|
1775
|
+
rowId: r.rowId,
|
|
1776
|
+
data: r.data
|
|
1777
|
+
})),
|
|
1778
|
+
isRestore: options?.isRestore
|
|
1779
|
+
}
|
|
1757
1780
|
}));
|
|
1758
1781
|
}
|
|
1759
1782
|
async function updateRow(ctx, tableId, rowId, data) {
|
|
@@ -1769,7 +1792,7 @@ async function updateRow(ctx, tableId, rowId, data) {
|
|
|
1769
1792
|
body: { data }
|
|
1770
1793
|
}));
|
|
1771
1794
|
}
|
|
1772
|
-
async function updateRows(ctx, tableId, rows) {
|
|
1795
|
+
async function updateRows(ctx, tableId, rows, options) {
|
|
1773
1796
|
assertDraft(ctx);
|
|
1774
1797
|
const revisionId = await ctx.getRevisionId();
|
|
1775
1798
|
return unwrap(await updateRows$1({
|
|
@@ -1778,10 +1801,13 @@ async function updateRows(ctx, tableId, rows) {
|
|
|
1778
1801
|
revisionId,
|
|
1779
1802
|
tableId
|
|
1780
1803
|
},
|
|
1781
|
-
body: {
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1804
|
+
body: {
|
|
1805
|
+
rows: rows.map((r) => ({
|
|
1806
|
+
rowId: r.rowId,
|
|
1807
|
+
data: r.data
|
|
1808
|
+
})),
|
|
1809
|
+
isRestore: options?.isRestore
|
|
1810
|
+
}
|
|
1785
1811
|
}));
|
|
1786
1812
|
}
|
|
1787
1813
|
async function patchRow(ctx, tableId, rowId, patches) {
|
|
@@ -1995,6 +2021,16 @@ var RevisiumScope = class {
|
|
|
1995
2021
|
async getChanges() {
|
|
1996
2022
|
return getChanges(this._scopeContext);
|
|
1997
2023
|
}
|
|
2024
|
+
async getMigrations() {
|
|
2025
|
+
return getMigrations(this._scopeContext);
|
|
2026
|
+
}
|
|
2027
|
+
async applyMigrations(migrations) {
|
|
2028
|
+
this.assertNotDisposed();
|
|
2029
|
+
await applyMigrations(this._scopeContext, migrations);
|
|
2030
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2031
|
+
this._stale = false;
|
|
2032
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2033
|
+
}
|
|
1998
2034
|
async createTable(tableId, schema) {
|
|
1999
2035
|
return createTable(this._scopeContext, tableId, schema);
|
|
2000
2036
|
}
|
|
@@ -2010,14 +2046,14 @@ var RevisiumScope = class {
|
|
|
2010
2046
|
async createRow(tableId, rowId, data) {
|
|
2011
2047
|
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2012
2048
|
}
|
|
2013
|
-
async createRows(tableId, rows) {
|
|
2014
|
-
return createRows(this._scopeContext, tableId, rows);
|
|
2049
|
+
async createRows(tableId, rows, options) {
|
|
2050
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
2015
2051
|
}
|
|
2016
2052
|
async updateRow(tableId, rowId, data) {
|
|
2017
2053
|
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2018
2054
|
}
|
|
2019
|
-
async updateRows(tableId, rows) {
|
|
2020
|
-
return updateRows(this._scopeContext, tableId, rows);
|
|
2055
|
+
async updateRows(tableId, rows, options) {
|
|
2056
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
2021
2057
|
}
|
|
2022
2058
|
async patchRow(tableId, rowId, patches) {
|
|
2023
2059
|
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
@@ -2105,6 +2141,9 @@ var RevisiumClient = class {
|
|
|
2105
2141
|
this._client.setConfig({ auth: token });
|
|
2106
2142
|
this._isAuthenticated = true;
|
|
2107
2143
|
}
|
|
2144
|
+
async me() {
|
|
2145
|
+
return me(this._client);
|
|
2146
|
+
}
|
|
2108
2147
|
async setContext(options) {
|
|
2109
2148
|
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
2110
2149
|
this._organizationId = organizationId;
|
|
@@ -2212,6 +2251,14 @@ var RevisiumClient = class {
|
|
|
2212
2251
|
async getChanges() {
|
|
2213
2252
|
return getChanges(this._scopeContext);
|
|
2214
2253
|
}
|
|
2254
|
+
async getMigrations() {
|
|
2255
|
+
return getMigrations(this._scopeContext);
|
|
2256
|
+
}
|
|
2257
|
+
async applyMigrations(migrations) {
|
|
2258
|
+
await applyMigrations(this._scopeContext, migrations);
|
|
2259
|
+
await this.refreshDraftRevisionId();
|
|
2260
|
+
this.notifyScopesOnCurrentBranch();
|
|
2261
|
+
}
|
|
2215
2262
|
async createTable(tableId, schema) {
|
|
2216
2263
|
return createTable(this._scopeContext, tableId, schema);
|
|
2217
2264
|
}
|
|
@@ -2227,14 +2274,14 @@ var RevisiumClient = class {
|
|
|
2227
2274
|
async createRow(tableId, rowId, data) {
|
|
2228
2275
|
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2229
2276
|
}
|
|
2230
|
-
async createRows(tableId, rows) {
|
|
2231
|
-
return createRows(this._scopeContext, tableId, rows);
|
|
2277
|
+
async createRows(tableId, rows, options) {
|
|
2278
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
2232
2279
|
}
|
|
2233
2280
|
async updateRow(tableId, rowId, data) {
|
|
2234
2281
|
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2235
2282
|
}
|
|
2236
|
-
async updateRows(tableId, rows) {
|
|
2237
|
-
return updateRows(this._scopeContext, tableId, rows);
|
|
2283
|
+
async updateRows(tableId, rows, options) {
|
|
2284
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
2238
2285
|
}
|
|
2239
2286
|
async patchRow(tableId, rowId, patches) {
|
|
2240
2287
|
return patchRow(this._scopeContext, tableId, rowId, patches);
|