@revisium/client 0.1.0 → 0.2.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 +76 -0
- package/dist/data-operations.d.ts +52 -0
- package/dist/data-operations.d.ts.map +1 -0
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/types.gen.d.ts +18 -14
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/index.cjs +577 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +577 -271
- package/dist/index.mjs.map +1 -1
- package/dist/revisium-client.d.ts +13 -4
- package/dist/revisium-client.d.ts.map +1 -1
- package/dist/revisium-scope.d.ts +76 -0
- package/dist/revisium-scope.d.ts.map +1 -0
- package/package.json +8 -3
package/dist/index.mjs
CHANGED
|
@@ -666,16 +666,16 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
666
666
|
createEndpoint: () => createEndpoint,
|
|
667
667
|
createProject: () => createProject,
|
|
668
668
|
createRevision: () => createRevision,
|
|
669
|
-
createRow: () => createRow,
|
|
670
|
-
createRows: () => createRows,
|
|
671
|
-
createTable: () => createTable,
|
|
669
|
+
createRow: () => createRow$1,
|
|
670
|
+
createRows: () => createRows$1,
|
|
671
|
+
createTable: () => createTable$1,
|
|
672
672
|
createUser: () => createUser,
|
|
673
673
|
deleteBranch: () => deleteBranch,
|
|
674
674
|
deleteEndpoint: () => deleteEndpoint,
|
|
675
675
|
deleteProject: () => deleteProject,
|
|
676
|
-
deleteRow: () => deleteRow,
|
|
677
|
-
deleteRows: () => deleteRows,
|
|
678
|
-
deleteTable: () => deleteTable,
|
|
676
|
+
deleteRow: () => deleteRow$1,
|
|
677
|
+
deleteRows: () => deleteRows$1,
|
|
678
|
+
deleteTable: () => deleteTable$1,
|
|
679
679
|
draftRevision: () => draftRevision,
|
|
680
680
|
endpointRelatives: () => endpointRelatives,
|
|
681
681
|
endpoints: () => endpoints,
|
|
@@ -687,16 +687,16 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
687
687
|
migrations: () => migrations,
|
|
688
688
|
parentBranch: () => parentBranch,
|
|
689
689
|
parentRevision: () => parentRevision,
|
|
690
|
-
patchRow: () => patchRow,
|
|
690
|
+
patchRow: () => patchRow$1,
|
|
691
691
|
patchRows: () => patchRows,
|
|
692
692
|
project: () => project,
|
|
693
693
|
projects: () => projects,
|
|
694
694
|
readiness: () => readiness,
|
|
695
695
|
removeUserFromOrganization: () => removeUserFromOrganization,
|
|
696
696
|
removeUserFromProject: () => removeUserFromProject,
|
|
697
|
-
renameRow: () => renameRow,
|
|
698
|
-
renameTable: () => renameTable,
|
|
699
|
-
revertChanges: () => revertChanges,
|
|
697
|
+
renameRow: () => renameRow$1,
|
|
698
|
+
renameTable: () => renameTable$1,
|
|
699
|
+
revertChanges: () => revertChanges$1,
|
|
700
700
|
revision: () => revision,
|
|
701
701
|
revisionChanges: () => revisionChanges,
|
|
702
702
|
revisions: () => revisions,
|
|
@@ -720,9 +720,9 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
720
720
|
tables: () => tables,
|
|
721
721
|
updatePassword: () => updatePassword,
|
|
722
722
|
updateProject: () => updateProject,
|
|
723
|
-
updateRow: () => updateRow,
|
|
724
|
-
updateRows: () => updateRows,
|
|
725
|
-
updateTable: () => updateTable,
|
|
723
|
+
updateRow: () => updateRow$1,
|
|
724
|
+
updateRows: () => updateRows$1,
|
|
725
|
+
updateTable: () => updateTable$1,
|
|
726
726
|
uploadFile: () => uploadFile,
|
|
727
727
|
usersOrganization: () => usersOrganization,
|
|
728
728
|
usersProject: () => usersProject
|
|
@@ -1052,7 +1052,7 @@ const createRevision = (options) => (options.client ?? client).post({
|
|
|
1052
1052
|
/**
|
|
1053
1053
|
* Discard all uncommitted changes
|
|
1054
1054
|
*/
|
|
1055
|
-
const revertChanges = (options) => (options.client ?? client).post({
|
|
1055
|
+
const revertChanges$1 = (options) => (options.client ?? client).post({
|
|
1056
1056
|
security: [{
|
|
1057
1057
|
scheme: "bearer",
|
|
1058
1058
|
type: "http"
|
|
@@ -1133,7 +1133,7 @@ const tables = (options) => (options.client ?? client).get({
|
|
|
1133
1133
|
/**
|
|
1134
1134
|
* Create a new table
|
|
1135
1135
|
*/
|
|
1136
|
-
const createTable = (options) => (options.client ?? client).post({
|
|
1136
|
+
const createTable$1 = (options) => (options.client ?? client).post({
|
|
1137
1137
|
security: [{
|
|
1138
1138
|
scheme: "bearer",
|
|
1139
1139
|
type: "http"
|
|
@@ -1233,7 +1233,7 @@ const applyMigrations = (options) => (options.client ?? client).post({
|
|
|
1233
1233
|
/**
|
|
1234
1234
|
* Delete a table
|
|
1235
1235
|
*/
|
|
1236
|
-
const deleteTable = (options) => (options.client ?? client).delete({
|
|
1236
|
+
const deleteTable$1 = (options) => (options.client ?? client).delete({
|
|
1237
1237
|
security: [{
|
|
1238
1238
|
scheme: "bearer",
|
|
1239
1239
|
type: "http"
|
|
@@ -1255,7 +1255,7 @@ const table = (options) => (options.client ?? client).get({
|
|
|
1255
1255
|
/**
|
|
1256
1256
|
* Update table schema using JSON Patch
|
|
1257
1257
|
*/
|
|
1258
|
-
const updateTable = (options) => (options.client ?? client).patch({
|
|
1258
|
+
const updateTable$1 = (options) => (options.client ?? client).patch({
|
|
1259
1259
|
security: [{
|
|
1260
1260
|
scheme: "bearer",
|
|
1261
1261
|
type: "http"
|
|
@@ -1281,7 +1281,7 @@ const tableCountRows = (options) => (options.client ?? client).get({
|
|
|
1281
1281
|
/**
|
|
1282
1282
|
* Delete multiple rows
|
|
1283
1283
|
*/
|
|
1284
|
-
const deleteRows = (options) => (options.client ?? client).delete({
|
|
1284
|
+
const deleteRows$1 = (options) => (options.client ?? client).delete({
|
|
1285
1285
|
security: [{
|
|
1286
1286
|
scheme: "bearer",
|
|
1287
1287
|
type: "http"
|
|
@@ -1311,7 +1311,7 @@ const rows = (options) => (options.client ?? client).post({
|
|
|
1311
1311
|
/**
|
|
1312
1312
|
* Create a new row
|
|
1313
1313
|
*/
|
|
1314
|
-
const createRow = (options) => (options.client ?? client).post({
|
|
1314
|
+
const createRow$1 = (options) => (options.client ?? client).post({
|
|
1315
1315
|
security: [{
|
|
1316
1316
|
scheme: "bearer",
|
|
1317
1317
|
type: "http"
|
|
@@ -1326,7 +1326,7 @@ const createRow = (options) => (options.client ?? client).post({
|
|
|
1326
1326
|
/**
|
|
1327
1327
|
* Create multiple rows
|
|
1328
1328
|
*/
|
|
1329
|
-
const createRows = (options) => (options.client ?? client).post({
|
|
1329
|
+
const createRows$1 = (options) => (options.client ?? client).post({
|
|
1330
1330
|
security: [{
|
|
1331
1331
|
scheme: "bearer",
|
|
1332
1332
|
type: "http"
|
|
@@ -1341,7 +1341,7 @@ const createRows = (options) => (options.client ?? client).post({
|
|
|
1341
1341
|
/**
|
|
1342
1342
|
* Replace data for multiple rows
|
|
1343
1343
|
*/
|
|
1344
|
-
const updateRows = (options) => (options.client ?? client).put({
|
|
1344
|
+
const updateRows$1 = (options) => (options.client ?? client).put({
|
|
1345
1345
|
security: [{
|
|
1346
1346
|
scheme: "bearer",
|
|
1347
1347
|
type: "http"
|
|
@@ -1426,7 +1426,7 @@ const tableForeignKeysTo = (options) => (options.client ?? client).get({
|
|
|
1426
1426
|
/**
|
|
1427
1427
|
* Rename a table
|
|
1428
1428
|
*/
|
|
1429
|
-
const renameTable = (options) => (options.client ?? client).patch({
|
|
1429
|
+
const renameTable$1 = (options) => (options.client ?? client).patch({
|
|
1430
1430
|
security: [{
|
|
1431
1431
|
scheme: "bearer",
|
|
1432
1432
|
type: "http"
|
|
@@ -1441,7 +1441,7 @@ const renameTable = (options) => (options.client ?? client).patch({
|
|
|
1441
1441
|
/**
|
|
1442
1442
|
* Delete a row
|
|
1443
1443
|
*/
|
|
1444
|
-
const deleteRow = (options) => (options.client ?? client).delete({
|
|
1444
|
+
const deleteRow$1 = (options) => (options.client ?? client).delete({
|
|
1445
1445
|
security: [{
|
|
1446
1446
|
scheme: "bearer",
|
|
1447
1447
|
type: "http"
|
|
@@ -1463,7 +1463,7 @@ const row = (options) => (options.client ?? client).get({
|
|
|
1463
1463
|
/**
|
|
1464
1464
|
* Patch row data using JSON Patch
|
|
1465
1465
|
*/
|
|
1466
|
-
const patchRow = (options) => (options.client ?? client).patch({
|
|
1466
|
+
const patchRow$1 = (options) => (options.client ?? client).patch({
|
|
1467
1467
|
security: [{
|
|
1468
1468
|
scheme: "bearer",
|
|
1469
1469
|
type: "http"
|
|
@@ -1478,7 +1478,7 @@ const patchRow = (options) => (options.client ?? client).patch({
|
|
|
1478
1478
|
/**
|
|
1479
1479
|
* Replace row data
|
|
1480
1480
|
*/
|
|
1481
|
-
const updateRow = (options) => (options.client ?? client).put({
|
|
1481
|
+
const updateRow$1 = (options) => (options.client ?? client).put({
|
|
1482
1482
|
security: [{
|
|
1483
1483
|
scheme: "bearer",
|
|
1484
1484
|
type: "http"
|
|
@@ -1537,7 +1537,7 @@ const rowForeignKeysTo = (options) => (options.client ?? client).get({
|
|
|
1537
1537
|
/**
|
|
1538
1538
|
* Rename a row
|
|
1539
1539
|
*/
|
|
1540
|
-
const renameRow = (options) => (options.client ?? client).patch({
|
|
1540
|
+
const renameRow$1 = (options) => (options.client ?? client).patch({
|
|
1541
1541
|
security: [{
|
|
1542
1542
|
scheme: "bearer",
|
|
1543
1543
|
type: "http"
|
|
@@ -1603,6 +1603,451 @@ const liveness = (options) => (options?.client ?? client).get({
|
|
|
1603
1603
|
...options
|
|
1604
1604
|
});
|
|
1605
1605
|
|
|
1606
|
+
//#endregion
|
|
1607
|
+
//#region src/data-operations.ts
|
|
1608
|
+
function unwrap(result) {
|
|
1609
|
+
if (result.error) {
|
|
1610
|
+
const err = result.error;
|
|
1611
|
+
throw new Error(err.message ?? `API error: ${JSON.stringify(result.error)}`);
|
|
1612
|
+
}
|
|
1613
|
+
return result.data;
|
|
1614
|
+
}
|
|
1615
|
+
function assertDraft(ctx) {
|
|
1616
|
+
assertContext(ctx);
|
|
1617
|
+
if (!ctx.isDraft) throw new Error("Mutations are only allowed in draft revision. Use setContext({ revision: \"draft\" }).");
|
|
1618
|
+
}
|
|
1619
|
+
function assertContext(ctx) {
|
|
1620
|
+
if (!ctx.branch.organizationId) throw new Error("Context not set. Call setContext() first.");
|
|
1621
|
+
}
|
|
1622
|
+
async function getTables(ctx, options) {
|
|
1623
|
+
const revisionId = await ctx.getRevisionId();
|
|
1624
|
+
return unwrap(await tables({
|
|
1625
|
+
client: ctx.client,
|
|
1626
|
+
path: { revisionId },
|
|
1627
|
+
query: {
|
|
1628
|
+
first: options?.first ?? 100,
|
|
1629
|
+
after: options?.after
|
|
1630
|
+
}
|
|
1631
|
+
}));
|
|
1632
|
+
}
|
|
1633
|
+
async function getTable(ctx, tableId) {
|
|
1634
|
+
const revisionId = await ctx.getRevisionId();
|
|
1635
|
+
return unwrap(await table({
|
|
1636
|
+
client: ctx.client,
|
|
1637
|
+
path: {
|
|
1638
|
+
revisionId,
|
|
1639
|
+
tableId
|
|
1640
|
+
}
|
|
1641
|
+
}));
|
|
1642
|
+
}
|
|
1643
|
+
async function getTableSchema(ctx, tableId) {
|
|
1644
|
+
const revisionId = await ctx.getRevisionId();
|
|
1645
|
+
return unwrap(await tableSchema({
|
|
1646
|
+
client: ctx.client,
|
|
1647
|
+
path: {
|
|
1648
|
+
revisionId,
|
|
1649
|
+
tableId
|
|
1650
|
+
}
|
|
1651
|
+
}));
|
|
1652
|
+
}
|
|
1653
|
+
async function getRows(ctx, tableId, options) {
|
|
1654
|
+
const revisionId = await ctx.getRevisionId();
|
|
1655
|
+
return unwrap(await rows({
|
|
1656
|
+
client: ctx.client,
|
|
1657
|
+
path: {
|
|
1658
|
+
revisionId,
|
|
1659
|
+
tableId
|
|
1660
|
+
},
|
|
1661
|
+
body: options ?? { first: 100 }
|
|
1662
|
+
}));
|
|
1663
|
+
}
|
|
1664
|
+
async function getRow(ctx, tableId, rowId) {
|
|
1665
|
+
const revisionId = await ctx.getRevisionId();
|
|
1666
|
+
return unwrap(await row({
|
|
1667
|
+
client: ctx.client,
|
|
1668
|
+
path: {
|
|
1669
|
+
revisionId,
|
|
1670
|
+
tableId,
|
|
1671
|
+
rowId
|
|
1672
|
+
}
|
|
1673
|
+
}));
|
|
1674
|
+
}
|
|
1675
|
+
async function getChanges(ctx) {
|
|
1676
|
+
const revisionId = await ctx.getRevisionId();
|
|
1677
|
+
return unwrap(await revisionChanges({
|
|
1678
|
+
client: ctx.client,
|
|
1679
|
+
path: { revisionId }
|
|
1680
|
+
}));
|
|
1681
|
+
}
|
|
1682
|
+
async function createTable(ctx, tableId, schema) {
|
|
1683
|
+
assertDraft(ctx);
|
|
1684
|
+
const revisionId = await ctx.getRevisionId();
|
|
1685
|
+
return unwrap(await createTable$1({
|
|
1686
|
+
client: ctx.client,
|
|
1687
|
+
path: { revisionId },
|
|
1688
|
+
body: {
|
|
1689
|
+
tableId,
|
|
1690
|
+
schema
|
|
1691
|
+
}
|
|
1692
|
+
}));
|
|
1693
|
+
}
|
|
1694
|
+
async function updateTable(ctx, tableId, patches) {
|
|
1695
|
+
assertDraft(ctx);
|
|
1696
|
+
const revisionId = await ctx.getRevisionId();
|
|
1697
|
+
return unwrap(await updateTable$1({
|
|
1698
|
+
client: ctx.client,
|
|
1699
|
+
path: {
|
|
1700
|
+
revisionId,
|
|
1701
|
+
tableId
|
|
1702
|
+
},
|
|
1703
|
+
body: { patches }
|
|
1704
|
+
}));
|
|
1705
|
+
}
|
|
1706
|
+
async function deleteTable(ctx, tableId) {
|
|
1707
|
+
assertDraft(ctx);
|
|
1708
|
+
const revisionId = await ctx.getRevisionId();
|
|
1709
|
+
unwrap(await deleteTable$1({
|
|
1710
|
+
client: ctx.client,
|
|
1711
|
+
path: {
|
|
1712
|
+
revisionId,
|
|
1713
|
+
tableId
|
|
1714
|
+
}
|
|
1715
|
+
}));
|
|
1716
|
+
}
|
|
1717
|
+
async function renameTable(ctx, tableId, nextTableId) {
|
|
1718
|
+
assertDraft(ctx);
|
|
1719
|
+
const revisionId = await ctx.getRevisionId();
|
|
1720
|
+
return unwrap(await renameTable$1({
|
|
1721
|
+
client: ctx.client,
|
|
1722
|
+
path: {
|
|
1723
|
+
revisionId,
|
|
1724
|
+
tableId
|
|
1725
|
+
},
|
|
1726
|
+
body: { nextTableId }
|
|
1727
|
+
}));
|
|
1728
|
+
}
|
|
1729
|
+
async function createRow(ctx, tableId, rowId, data) {
|
|
1730
|
+
assertDraft(ctx);
|
|
1731
|
+
const revisionId = await ctx.getRevisionId();
|
|
1732
|
+
return unwrap(await createRow$1({
|
|
1733
|
+
client: ctx.client,
|
|
1734
|
+
path: {
|
|
1735
|
+
revisionId,
|
|
1736
|
+
tableId
|
|
1737
|
+
},
|
|
1738
|
+
body: {
|
|
1739
|
+
rowId,
|
|
1740
|
+
data
|
|
1741
|
+
}
|
|
1742
|
+
}));
|
|
1743
|
+
}
|
|
1744
|
+
async function createRows(ctx, tableId, rows) {
|
|
1745
|
+
assertDraft(ctx);
|
|
1746
|
+
const revisionId = await ctx.getRevisionId();
|
|
1747
|
+
return unwrap(await createRows$1({
|
|
1748
|
+
client: ctx.client,
|
|
1749
|
+
path: {
|
|
1750
|
+
revisionId,
|
|
1751
|
+
tableId
|
|
1752
|
+
},
|
|
1753
|
+
body: { rows: rows.map((r) => ({
|
|
1754
|
+
rowId: r.rowId,
|
|
1755
|
+
data: r.data
|
|
1756
|
+
})) }
|
|
1757
|
+
}));
|
|
1758
|
+
}
|
|
1759
|
+
async function updateRow(ctx, tableId, rowId, data) {
|
|
1760
|
+
assertDraft(ctx);
|
|
1761
|
+
const revisionId = await ctx.getRevisionId();
|
|
1762
|
+
return unwrap(await updateRow$1({
|
|
1763
|
+
client: ctx.client,
|
|
1764
|
+
path: {
|
|
1765
|
+
revisionId,
|
|
1766
|
+
tableId,
|
|
1767
|
+
rowId
|
|
1768
|
+
},
|
|
1769
|
+
body: { data }
|
|
1770
|
+
}));
|
|
1771
|
+
}
|
|
1772
|
+
async function updateRows(ctx, tableId, rows) {
|
|
1773
|
+
assertDraft(ctx);
|
|
1774
|
+
const revisionId = await ctx.getRevisionId();
|
|
1775
|
+
return unwrap(await updateRows$1({
|
|
1776
|
+
client: ctx.client,
|
|
1777
|
+
path: {
|
|
1778
|
+
revisionId,
|
|
1779
|
+
tableId
|
|
1780
|
+
},
|
|
1781
|
+
body: { rows: rows.map((r) => ({
|
|
1782
|
+
rowId: r.rowId,
|
|
1783
|
+
data: r.data
|
|
1784
|
+
})) }
|
|
1785
|
+
}));
|
|
1786
|
+
}
|
|
1787
|
+
async function patchRow(ctx, tableId, rowId, patches) {
|
|
1788
|
+
assertDraft(ctx);
|
|
1789
|
+
const revisionId = await ctx.getRevisionId();
|
|
1790
|
+
return unwrap(await patchRow$1({
|
|
1791
|
+
client: ctx.client,
|
|
1792
|
+
path: {
|
|
1793
|
+
revisionId,
|
|
1794
|
+
tableId,
|
|
1795
|
+
rowId
|
|
1796
|
+
},
|
|
1797
|
+
body: { patches }
|
|
1798
|
+
}));
|
|
1799
|
+
}
|
|
1800
|
+
async function deleteRow(ctx, tableId, rowId) {
|
|
1801
|
+
assertDraft(ctx);
|
|
1802
|
+
const revisionId = await ctx.getRevisionId();
|
|
1803
|
+
unwrap(await deleteRow$1({
|
|
1804
|
+
client: ctx.client,
|
|
1805
|
+
path: {
|
|
1806
|
+
revisionId,
|
|
1807
|
+
tableId,
|
|
1808
|
+
rowId
|
|
1809
|
+
}
|
|
1810
|
+
}));
|
|
1811
|
+
}
|
|
1812
|
+
async function deleteRows(ctx, tableId, rowIds) {
|
|
1813
|
+
assertDraft(ctx);
|
|
1814
|
+
const revisionId = await ctx.getRevisionId();
|
|
1815
|
+
unwrap(await deleteRows$1({
|
|
1816
|
+
client: ctx.client,
|
|
1817
|
+
path: {
|
|
1818
|
+
revisionId,
|
|
1819
|
+
tableId
|
|
1820
|
+
},
|
|
1821
|
+
body: { rowIds }
|
|
1822
|
+
}));
|
|
1823
|
+
}
|
|
1824
|
+
async function renameRow(ctx, tableId, rowId, nextRowId) {
|
|
1825
|
+
assertDraft(ctx);
|
|
1826
|
+
const revisionId = await ctx.getRevisionId();
|
|
1827
|
+
return unwrap(await renameRow$1({
|
|
1828
|
+
client: ctx.client,
|
|
1829
|
+
path: {
|
|
1830
|
+
revisionId,
|
|
1831
|
+
tableId,
|
|
1832
|
+
rowId
|
|
1833
|
+
},
|
|
1834
|
+
body: { nextRowId }
|
|
1835
|
+
}));
|
|
1836
|
+
}
|
|
1837
|
+
async function commit(ctx, comment) {
|
|
1838
|
+
assertDraft(ctx);
|
|
1839
|
+
return unwrap(await createRevision({
|
|
1840
|
+
client: ctx.client,
|
|
1841
|
+
path: {
|
|
1842
|
+
organizationId: ctx.branch.organizationId,
|
|
1843
|
+
projectName: ctx.branch.projectName,
|
|
1844
|
+
branchName: ctx.branch.branchName
|
|
1845
|
+
},
|
|
1846
|
+
body: { comment }
|
|
1847
|
+
}));
|
|
1848
|
+
}
|
|
1849
|
+
async function revertChanges(ctx) {
|
|
1850
|
+
assertDraft(ctx);
|
|
1851
|
+
unwrap(await revertChanges$1({
|
|
1852
|
+
client: ctx.client,
|
|
1853
|
+
path: {
|
|
1854
|
+
organizationId: ctx.branch.organizationId,
|
|
1855
|
+
projectName: ctx.branch.projectName,
|
|
1856
|
+
branchName: ctx.branch.branchName
|
|
1857
|
+
}
|
|
1858
|
+
}));
|
|
1859
|
+
}
|
|
1860
|
+
async function fetchDraftRevisionId(client, branch) {
|
|
1861
|
+
return unwrap(await draftRevision({
|
|
1862
|
+
client,
|
|
1863
|
+
path: {
|
|
1864
|
+
organizationId: branch.organizationId,
|
|
1865
|
+
projectName: branch.projectName,
|
|
1866
|
+
branchName: branch.branchName
|
|
1867
|
+
}
|
|
1868
|
+
})).id;
|
|
1869
|
+
}
|
|
1870
|
+
async function fetchHeadRevisionId(client, branch) {
|
|
1871
|
+
return unwrap(await headRevision({
|
|
1872
|
+
client,
|
|
1873
|
+
path: {
|
|
1874
|
+
organizationId: branch.organizationId,
|
|
1875
|
+
projectName: branch.projectName,
|
|
1876
|
+
branchName: branch.branchName
|
|
1877
|
+
}
|
|
1878
|
+
})).id;
|
|
1879
|
+
}
|
|
1880
|
+
async function validateRevisionId(client, revisionId) {
|
|
1881
|
+
unwrap(await revision({
|
|
1882
|
+
client,
|
|
1883
|
+
path: { revisionId }
|
|
1884
|
+
}));
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
//#endregion
|
|
1888
|
+
//#region src/revisium-scope.ts
|
|
1889
|
+
var RevisiumScope = class {
|
|
1890
|
+
_client;
|
|
1891
|
+
_branch;
|
|
1892
|
+
_revisionMode;
|
|
1893
|
+
_owner;
|
|
1894
|
+
_revisionId;
|
|
1895
|
+
_isDraft;
|
|
1896
|
+
_stale = false;
|
|
1897
|
+
_disposed = false;
|
|
1898
|
+
_refreshPromise = null;
|
|
1899
|
+
constructor(init) {
|
|
1900
|
+
this._client = init.client;
|
|
1901
|
+
this._branch = init.branch;
|
|
1902
|
+
this._revisionId = init.revisionId;
|
|
1903
|
+
this._isDraft = init.isDraft;
|
|
1904
|
+
this._revisionMode = init.revisionMode;
|
|
1905
|
+
this._owner = init.owner;
|
|
1906
|
+
}
|
|
1907
|
+
get organizationId() {
|
|
1908
|
+
return this._branch.organizationId;
|
|
1909
|
+
}
|
|
1910
|
+
get projectName() {
|
|
1911
|
+
return this._branch.projectName;
|
|
1912
|
+
}
|
|
1913
|
+
get branchName() {
|
|
1914
|
+
return this._branch.branchName;
|
|
1915
|
+
}
|
|
1916
|
+
get revisionId() {
|
|
1917
|
+
return this._revisionId;
|
|
1918
|
+
}
|
|
1919
|
+
get isDraft() {
|
|
1920
|
+
return this._isDraft;
|
|
1921
|
+
}
|
|
1922
|
+
get isStale() {
|
|
1923
|
+
return this._stale;
|
|
1924
|
+
}
|
|
1925
|
+
get isDisposed() {
|
|
1926
|
+
return this._disposed;
|
|
1927
|
+
}
|
|
1928
|
+
get client() {
|
|
1929
|
+
return this._client;
|
|
1930
|
+
}
|
|
1931
|
+
markStale() {
|
|
1932
|
+
if (this._revisionMode === "explicit") return;
|
|
1933
|
+
this._stale = true;
|
|
1934
|
+
}
|
|
1935
|
+
async refresh() {
|
|
1936
|
+
this.assertNotDisposed();
|
|
1937
|
+
if (this._revisionMode === "explicit") return;
|
|
1938
|
+
this._revisionId = await this.fetchRevisionId();
|
|
1939
|
+
this._stale = false;
|
|
1940
|
+
}
|
|
1941
|
+
dispose() {
|
|
1942
|
+
if (this._disposed) return;
|
|
1943
|
+
this._disposed = true;
|
|
1944
|
+
this._owner.unregisterScope(this);
|
|
1945
|
+
}
|
|
1946
|
+
assertNotDisposed() {
|
|
1947
|
+
if (this._disposed) throw new Error("Scope has been disposed.");
|
|
1948
|
+
}
|
|
1949
|
+
get _branchKey() {
|
|
1950
|
+
return `${this._branch.organizationId}/${this._branch.projectName}/${this._branch.branchName}`;
|
|
1951
|
+
}
|
|
1952
|
+
async fetchRevisionId() {
|
|
1953
|
+
if (this._revisionMode === "draft") return fetchDraftRevisionId(this._client, this._branch);
|
|
1954
|
+
return fetchHeadRevisionId(this._client, this._branch);
|
|
1955
|
+
}
|
|
1956
|
+
async getRevisionId() {
|
|
1957
|
+
this.assertNotDisposed();
|
|
1958
|
+
if (this._stale) {
|
|
1959
|
+
this._refreshPromise ??= this.fetchRevisionId().then((id) => {
|
|
1960
|
+
this._revisionId = id;
|
|
1961
|
+
this._stale = false;
|
|
1962
|
+
this._refreshPromise = null;
|
|
1963
|
+
return id;
|
|
1964
|
+
}, (err) => {
|
|
1965
|
+
this._refreshPromise = null;
|
|
1966
|
+
throw err;
|
|
1967
|
+
});
|
|
1968
|
+
return this._refreshPromise;
|
|
1969
|
+
}
|
|
1970
|
+
return this._revisionId;
|
|
1971
|
+
}
|
|
1972
|
+
get _scopeContext() {
|
|
1973
|
+
return {
|
|
1974
|
+
client: this._client,
|
|
1975
|
+
branch: this._branch,
|
|
1976
|
+
isDraft: this._isDraft,
|
|
1977
|
+
getRevisionId: () => this.getRevisionId()
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
async getTables(options) {
|
|
1981
|
+
return getTables(this._scopeContext, options);
|
|
1982
|
+
}
|
|
1983
|
+
async getTable(tableId) {
|
|
1984
|
+
return getTable(this._scopeContext, tableId);
|
|
1985
|
+
}
|
|
1986
|
+
async getTableSchema(tableId) {
|
|
1987
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
1988
|
+
}
|
|
1989
|
+
async getRows(tableId, options) {
|
|
1990
|
+
return getRows(this._scopeContext, tableId, options);
|
|
1991
|
+
}
|
|
1992
|
+
async getRow(tableId, rowId) {
|
|
1993
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
1994
|
+
}
|
|
1995
|
+
async getChanges() {
|
|
1996
|
+
return getChanges(this._scopeContext);
|
|
1997
|
+
}
|
|
1998
|
+
async createTable(tableId, schema) {
|
|
1999
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
2000
|
+
}
|
|
2001
|
+
async updateTable(tableId, patches) {
|
|
2002
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
2003
|
+
}
|
|
2004
|
+
async deleteTable(tableId) {
|
|
2005
|
+
return deleteTable(this._scopeContext, tableId);
|
|
2006
|
+
}
|
|
2007
|
+
async renameTable(tableId, nextTableId) {
|
|
2008
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
2009
|
+
}
|
|
2010
|
+
async createRow(tableId, rowId, data) {
|
|
2011
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2012
|
+
}
|
|
2013
|
+
async createRows(tableId, rows) {
|
|
2014
|
+
return createRows(this._scopeContext, tableId, rows);
|
|
2015
|
+
}
|
|
2016
|
+
async updateRow(tableId, rowId, data) {
|
|
2017
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2018
|
+
}
|
|
2019
|
+
async updateRows(tableId, rows) {
|
|
2020
|
+
return updateRows(this._scopeContext, tableId, rows);
|
|
2021
|
+
}
|
|
2022
|
+
async patchRow(tableId, rowId, patches) {
|
|
2023
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
2024
|
+
}
|
|
2025
|
+
async deleteRow(tableId, rowId) {
|
|
2026
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
2027
|
+
}
|
|
2028
|
+
async deleteRows(tableId, rowIds) {
|
|
2029
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
2030
|
+
}
|
|
2031
|
+
async renameRow(tableId, rowId, nextRowId) {
|
|
2032
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
2033
|
+
}
|
|
2034
|
+
async commit(comment) {
|
|
2035
|
+
this.assertNotDisposed();
|
|
2036
|
+
const data = await commit(this._scopeContext, comment);
|
|
2037
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2038
|
+
this._stale = false;
|
|
2039
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2040
|
+
return data;
|
|
2041
|
+
}
|
|
2042
|
+
async revertChanges() {
|
|
2043
|
+
this.assertNotDisposed();
|
|
2044
|
+
await revertChanges(this._scopeContext);
|
|
2045
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2046
|
+
this._stale = false;
|
|
2047
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
|
|
1606
2051
|
//#endregion
|
|
1607
2052
|
//#region src/revisium-client.ts
|
|
1608
2053
|
var RevisiumClient = class {
|
|
@@ -1614,6 +2059,7 @@ var RevisiumClient = class {
|
|
|
1614
2059
|
_revisionId = null;
|
|
1615
2060
|
_isDraft = false;
|
|
1616
2061
|
_isAuthenticated = false;
|
|
2062
|
+
_scopes = /* @__PURE__ */ new Map();
|
|
1617
2063
|
constructor(options) {
|
|
1618
2064
|
const url = options.baseUrl;
|
|
1619
2065
|
this._baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
|
|
@@ -1651,7 +2097,7 @@ var RevisiumClient = class {
|
|
|
1651
2097
|
password
|
|
1652
2098
|
}
|
|
1653
2099
|
});
|
|
1654
|
-
const data =
|
|
2100
|
+
const data = unwrap(result);
|
|
1655
2101
|
this._client.setConfig({ auth: data.accessToken });
|
|
1656
2102
|
this._isAuthenticated = true;
|
|
1657
2103
|
}
|
|
@@ -1660,314 +2106,174 @@ var RevisiumClient = class {
|
|
|
1660
2106
|
this._isAuthenticated = true;
|
|
1661
2107
|
}
|
|
1662
2108
|
async setContext(options) {
|
|
1663
|
-
const { organizationId, projectName, branchName = "master", revision
|
|
2109
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
1664
2110
|
this._organizationId = organizationId;
|
|
1665
2111
|
this._projectName = projectName;
|
|
1666
2112
|
this._branchName = branchName;
|
|
1667
|
-
const
|
|
2113
|
+
const branch = {
|
|
1668
2114
|
organizationId,
|
|
1669
2115
|
projectName,
|
|
1670
2116
|
branchName
|
|
1671
2117
|
};
|
|
1672
|
-
if (revision
|
|
1673
|
-
|
|
1674
|
-
client: this._client,
|
|
1675
|
-
path: branchPath
|
|
1676
|
-
});
|
|
1677
|
-
this._revisionId = this.unwrap(result).id;
|
|
2118
|
+
if (revision === "draft") {
|
|
2119
|
+
this._revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
1678
2120
|
this._isDraft = true;
|
|
1679
|
-
} else if (revision
|
|
1680
|
-
|
|
1681
|
-
client: this._client,
|
|
1682
|
-
path: branchPath
|
|
1683
|
-
});
|
|
1684
|
-
this._revisionId = this.unwrap(result).id;
|
|
2121
|
+
} else if (revision === "head") {
|
|
2122
|
+
this._revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
1685
2123
|
this._isDraft = false;
|
|
1686
2124
|
} else {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
path: { revisionId: revision$1 }
|
|
1690
|
-
});
|
|
1691
|
-
this.unwrap(result);
|
|
1692
|
-
this._revisionId = revision$1;
|
|
2125
|
+
await validateRevisionId(this._client, revision);
|
|
2126
|
+
this._revisionId = revision;
|
|
1693
2127
|
this._isDraft = false;
|
|
1694
2128
|
}
|
|
1695
2129
|
}
|
|
1696
|
-
async
|
|
1697
|
-
|
|
1698
|
-
const
|
|
2130
|
+
async withContext(options) {
|
|
2131
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
2132
|
+
const branch = {
|
|
2133
|
+
organizationId,
|
|
2134
|
+
projectName,
|
|
2135
|
+
branchName
|
|
2136
|
+
};
|
|
2137
|
+
let revisionId;
|
|
2138
|
+
let isDraft;
|
|
2139
|
+
let revisionMode;
|
|
2140
|
+
if (revision === "draft") {
|
|
2141
|
+
revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
2142
|
+
isDraft = true;
|
|
2143
|
+
revisionMode = "draft";
|
|
2144
|
+
} else if (revision === "head") {
|
|
2145
|
+
revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
2146
|
+
isDraft = false;
|
|
2147
|
+
revisionMode = "head";
|
|
2148
|
+
} else {
|
|
2149
|
+
await validateRevisionId(this._client, revision);
|
|
2150
|
+
revisionId = revision;
|
|
2151
|
+
isDraft = false;
|
|
2152
|
+
revisionMode = "explicit";
|
|
2153
|
+
}
|
|
2154
|
+
const scope = new RevisiumScope({
|
|
1699
2155
|
client: this._client,
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
2156
|
+
branch,
|
|
2157
|
+
revisionId,
|
|
2158
|
+
isDraft,
|
|
2159
|
+
revisionMode,
|
|
2160
|
+
owner: this
|
|
1705
2161
|
});
|
|
1706
|
-
|
|
2162
|
+
const branchKey = `${organizationId}/${projectName}/${branchName}`;
|
|
2163
|
+
let scopeSet = this._scopes.get(branchKey);
|
|
2164
|
+
if (!scopeSet) {
|
|
2165
|
+
scopeSet = /* @__PURE__ */ new Set();
|
|
2166
|
+
this._scopes.set(branchKey, scopeSet);
|
|
2167
|
+
}
|
|
2168
|
+
scopeSet.add(scope);
|
|
2169
|
+
return scope;
|
|
2170
|
+
}
|
|
2171
|
+
notifyBranchChanged(branchKey, excludeScope) {
|
|
2172
|
+
const scopeSet = this._scopes.get(branchKey);
|
|
2173
|
+
if (!scopeSet) return;
|
|
2174
|
+
for (const scope of scopeSet) if (scope !== excludeScope) scope.markStale();
|
|
2175
|
+
}
|
|
2176
|
+
unregisterScope(scope) {
|
|
2177
|
+
for (const [key, scopeSet] of this._scopes) {
|
|
2178
|
+
scopeSet.delete(scope);
|
|
2179
|
+
if (scopeSet.size === 0) this._scopes.delete(key);
|
|
2180
|
+
}
|
|
1707
2181
|
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
const result = await table({
|
|
2182
|
+
get _scopeContext() {
|
|
2183
|
+
return {
|
|
1711
2184
|
client: this._client,
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
2185
|
+
branch: {
|
|
2186
|
+
organizationId: this._organizationId ?? "",
|
|
2187
|
+
projectName: this._projectName ?? "",
|
|
2188
|
+
branchName: this._branchName ?? ""
|
|
2189
|
+
},
|
|
2190
|
+
isDraft: this._isDraft,
|
|
2191
|
+
getRevisionId: () => {
|
|
2192
|
+
if (this._revisionId === null) return Promise.reject(/* @__PURE__ */ new Error("Context not set. Call setContext() first."));
|
|
2193
|
+
return Promise.resolve(this._revisionId);
|
|
1715
2194
|
}
|
|
1716
|
-
}
|
|
1717
|
-
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
async getTables(options) {
|
|
2198
|
+
return getTables(this._scopeContext, options);
|
|
2199
|
+
}
|
|
2200
|
+
async getTable(tableId) {
|
|
2201
|
+
return getTable(this._scopeContext, tableId);
|
|
1718
2202
|
}
|
|
1719
2203
|
async getTableSchema(tableId) {
|
|
1720
|
-
this.
|
|
1721
|
-
const result = await tableSchema({
|
|
1722
|
-
client: this._client,
|
|
1723
|
-
path: {
|
|
1724
|
-
revisionId: this._revisionId,
|
|
1725
|
-
tableId
|
|
1726
|
-
}
|
|
1727
|
-
});
|
|
1728
|
-
return this.unwrap(result);
|
|
2204
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
1729
2205
|
}
|
|
1730
2206
|
async getRows(tableId, options) {
|
|
1731
|
-
this.
|
|
1732
|
-
const result = await rows({
|
|
1733
|
-
client: this._client,
|
|
1734
|
-
path: {
|
|
1735
|
-
revisionId: this._revisionId,
|
|
1736
|
-
tableId
|
|
1737
|
-
},
|
|
1738
|
-
body: options ?? { first: 100 }
|
|
1739
|
-
});
|
|
1740
|
-
return this.unwrap(result);
|
|
2207
|
+
return getRows(this._scopeContext, tableId, options);
|
|
1741
2208
|
}
|
|
1742
2209
|
async getRow(tableId, rowId) {
|
|
1743
|
-
this.
|
|
1744
|
-
const result = await row({
|
|
1745
|
-
client: this._client,
|
|
1746
|
-
path: {
|
|
1747
|
-
revisionId: this._revisionId,
|
|
1748
|
-
tableId,
|
|
1749
|
-
rowId
|
|
1750
|
-
}
|
|
1751
|
-
});
|
|
1752
|
-
return this.unwrap(result);
|
|
2210
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
1753
2211
|
}
|
|
1754
2212
|
async getChanges() {
|
|
1755
|
-
this.
|
|
1756
|
-
const result = await revisionChanges({
|
|
1757
|
-
client: this._client,
|
|
1758
|
-
path: { revisionId: this._revisionId }
|
|
1759
|
-
});
|
|
1760
|
-
return this.unwrap(result);
|
|
2213
|
+
return getChanges(this._scopeContext);
|
|
1761
2214
|
}
|
|
1762
2215
|
async createTable(tableId, schema) {
|
|
1763
|
-
this.
|
|
1764
|
-
const result = await createTable({
|
|
1765
|
-
client: this._client,
|
|
1766
|
-
path: { revisionId: this._revisionId },
|
|
1767
|
-
body: {
|
|
1768
|
-
tableId,
|
|
1769
|
-
schema
|
|
1770
|
-
}
|
|
1771
|
-
});
|
|
1772
|
-
return this.unwrap(result);
|
|
2216
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
1773
2217
|
}
|
|
1774
2218
|
async updateTable(tableId, patches) {
|
|
1775
|
-
this.
|
|
1776
|
-
const result = await updateTable({
|
|
1777
|
-
client: this._client,
|
|
1778
|
-
path: {
|
|
1779
|
-
revisionId: this._revisionId,
|
|
1780
|
-
tableId
|
|
1781
|
-
},
|
|
1782
|
-
body: { patches }
|
|
1783
|
-
});
|
|
1784
|
-
return this.unwrap(result);
|
|
2219
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
1785
2220
|
}
|
|
1786
2221
|
async deleteTable(tableId) {
|
|
1787
|
-
this.
|
|
1788
|
-
const result = await deleteTable({
|
|
1789
|
-
client: this._client,
|
|
1790
|
-
path: {
|
|
1791
|
-
revisionId: this._revisionId,
|
|
1792
|
-
tableId
|
|
1793
|
-
}
|
|
1794
|
-
});
|
|
1795
|
-
this.unwrap(result);
|
|
2222
|
+
return deleteTable(this._scopeContext, tableId);
|
|
1796
2223
|
}
|
|
1797
2224
|
async renameTable(tableId, nextTableId) {
|
|
1798
|
-
this.
|
|
1799
|
-
const result = await renameTable({
|
|
1800
|
-
client: this._client,
|
|
1801
|
-
path: {
|
|
1802
|
-
revisionId: this._revisionId,
|
|
1803
|
-
tableId
|
|
1804
|
-
},
|
|
1805
|
-
body: { nextTableId }
|
|
1806
|
-
});
|
|
1807
|
-
return this.unwrap(result);
|
|
2225
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
1808
2226
|
}
|
|
1809
2227
|
async createRow(tableId, rowId, data) {
|
|
1810
|
-
this.
|
|
1811
|
-
const result = await createRow({
|
|
1812
|
-
client: this._client,
|
|
1813
|
-
path: {
|
|
1814
|
-
revisionId: this._revisionId,
|
|
1815
|
-
tableId
|
|
1816
|
-
},
|
|
1817
|
-
body: {
|
|
1818
|
-
rowId,
|
|
1819
|
-
data
|
|
1820
|
-
}
|
|
1821
|
-
});
|
|
1822
|
-
return this.unwrap(result);
|
|
2228
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
1823
2229
|
}
|
|
1824
2230
|
async createRows(tableId, rows) {
|
|
1825
|
-
this.
|
|
1826
|
-
const result = await createRows({
|
|
1827
|
-
client: this._client,
|
|
1828
|
-
path: {
|
|
1829
|
-
revisionId: this._revisionId,
|
|
1830
|
-
tableId
|
|
1831
|
-
},
|
|
1832
|
-
body: { rows: rows.map((r) => ({
|
|
1833
|
-
rowId: r.rowId,
|
|
1834
|
-
data: r.data
|
|
1835
|
-
})) }
|
|
1836
|
-
});
|
|
1837
|
-
return this.unwrap(result);
|
|
2231
|
+
return createRows(this._scopeContext, tableId, rows);
|
|
1838
2232
|
}
|
|
1839
2233
|
async updateRow(tableId, rowId, data) {
|
|
1840
|
-
this.
|
|
1841
|
-
const result = await updateRow({
|
|
1842
|
-
client: this._client,
|
|
1843
|
-
path: {
|
|
1844
|
-
revisionId: this._revisionId,
|
|
1845
|
-
tableId,
|
|
1846
|
-
rowId
|
|
1847
|
-
},
|
|
1848
|
-
body: { data }
|
|
1849
|
-
});
|
|
1850
|
-
return this.unwrap(result);
|
|
2234
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
1851
2235
|
}
|
|
1852
2236
|
async updateRows(tableId, rows) {
|
|
1853
|
-
this.
|
|
1854
|
-
const result = await updateRows({
|
|
1855
|
-
client: this._client,
|
|
1856
|
-
path: {
|
|
1857
|
-
revisionId: this._revisionId,
|
|
1858
|
-
tableId
|
|
1859
|
-
},
|
|
1860
|
-
body: { rows: rows.map((r) => ({
|
|
1861
|
-
rowId: r.rowId,
|
|
1862
|
-
data: r.data
|
|
1863
|
-
})) }
|
|
1864
|
-
});
|
|
1865
|
-
return this.unwrap(result);
|
|
2237
|
+
return updateRows(this._scopeContext, tableId, rows);
|
|
1866
2238
|
}
|
|
1867
2239
|
async patchRow(tableId, rowId, patches) {
|
|
1868
|
-
this.
|
|
1869
|
-
const result = await patchRow({
|
|
1870
|
-
client: this._client,
|
|
1871
|
-
path: {
|
|
1872
|
-
revisionId: this._revisionId,
|
|
1873
|
-
tableId,
|
|
1874
|
-
rowId
|
|
1875
|
-
},
|
|
1876
|
-
body: { patches }
|
|
1877
|
-
});
|
|
1878
|
-
return this.unwrap(result);
|
|
2240
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
1879
2241
|
}
|
|
1880
2242
|
async deleteRow(tableId, rowId) {
|
|
1881
|
-
this.
|
|
1882
|
-
const result = await deleteRow({
|
|
1883
|
-
client: this._client,
|
|
1884
|
-
path: {
|
|
1885
|
-
revisionId: this._revisionId,
|
|
1886
|
-
tableId,
|
|
1887
|
-
rowId
|
|
1888
|
-
}
|
|
1889
|
-
});
|
|
1890
|
-
this.unwrap(result);
|
|
2243
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
1891
2244
|
}
|
|
1892
2245
|
async deleteRows(tableId, rowIds) {
|
|
1893
|
-
this.
|
|
1894
|
-
const result = await deleteRows({
|
|
1895
|
-
client: this._client,
|
|
1896
|
-
path: {
|
|
1897
|
-
revisionId: this._revisionId,
|
|
1898
|
-
tableId
|
|
1899
|
-
},
|
|
1900
|
-
body: { rowIds }
|
|
1901
|
-
});
|
|
1902
|
-
this.unwrap(result);
|
|
2246
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
1903
2247
|
}
|
|
1904
2248
|
async renameRow(tableId, rowId, nextRowId) {
|
|
1905
|
-
this.
|
|
1906
|
-
const result = await renameRow({
|
|
1907
|
-
client: this._client,
|
|
1908
|
-
path: {
|
|
1909
|
-
revisionId: this._revisionId,
|
|
1910
|
-
tableId,
|
|
1911
|
-
rowId
|
|
1912
|
-
},
|
|
1913
|
-
body: { nextRowId }
|
|
1914
|
-
});
|
|
1915
|
-
return this.unwrap(result);
|
|
2249
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
1916
2250
|
}
|
|
1917
2251
|
async commit(comment) {
|
|
1918
|
-
this.
|
|
1919
|
-
const result = await createRevision({
|
|
1920
|
-
client: this._client,
|
|
1921
|
-
path: {
|
|
1922
|
-
organizationId: this._organizationId,
|
|
1923
|
-
projectName: this._projectName,
|
|
1924
|
-
branchName: this._branchName
|
|
1925
|
-
},
|
|
1926
|
-
body: { comment }
|
|
1927
|
-
});
|
|
1928
|
-
const data = this.unwrap(result);
|
|
2252
|
+
const data = await commit(this._scopeContext, comment);
|
|
1929
2253
|
await this.refreshDraftRevisionId();
|
|
2254
|
+
this.notifyScopesOnCurrentBranch();
|
|
1930
2255
|
return data;
|
|
1931
2256
|
}
|
|
1932
2257
|
async revertChanges() {
|
|
1933
|
-
this.
|
|
1934
|
-
await revertChanges({
|
|
1935
|
-
client: this._client,
|
|
1936
|
-
path: {
|
|
1937
|
-
organizationId: this._organizationId,
|
|
1938
|
-
projectName: this._projectName,
|
|
1939
|
-
branchName: this._branchName
|
|
1940
|
-
}
|
|
1941
|
-
});
|
|
2258
|
+
await revertChanges(this._scopeContext);
|
|
1942
2259
|
await this.refreshDraftRevisionId();
|
|
1943
|
-
|
|
1944
|
-
assertDraft() {
|
|
1945
|
-
this.assertContext();
|
|
1946
|
-
if (!this._isDraft) throw new Error("Mutations are only allowed in draft revision. Use setContext({ revision: \"draft\" }).");
|
|
1947
|
-
}
|
|
1948
|
-
assertContext() {
|
|
1949
|
-
if (this._revisionId === null) throw new Error("Context not set. Call setContext() first.");
|
|
2260
|
+
this.notifyScopesOnCurrentBranch();
|
|
1950
2261
|
}
|
|
1951
2262
|
async refreshDraftRevisionId() {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
projectName: this._projectName,
|
|
1957
|
-
branchName: this._branchName
|
|
1958
|
-
}
|
|
2263
|
+
this._revisionId = await fetchDraftRevisionId(this._client, {
|
|
2264
|
+
organizationId: this._organizationId,
|
|
2265
|
+
projectName: this._projectName,
|
|
2266
|
+
branchName: this._branchName
|
|
1959
2267
|
});
|
|
1960
|
-
this._revisionId = this.unwrap(result).id;
|
|
1961
2268
|
}
|
|
1962
|
-
|
|
1963
|
-
if (
|
|
1964
|
-
const
|
|
1965
|
-
|
|
2269
|
+
notifyScopesOnCurrentBranch() {
|
|
2270
|
+
if (this._organizationId && this._projectName && this._branchName) {
|
|
2271
|
+
const branchKey = `${this._organizationId}/${this._projectName}/${this._branchName}`;
|
|
2272
|
+
this.notifyBranchChanged(branchKey);
|
|
1966
2273
|
}
|
|
1967
|
-
return result.data;
|
|
1968
2274
|
}
|
|
1969
2275
|
};
|
|
1970
2276
|
|
|
1971
2277
|
//#endregion
|
|
1972
|
-
export { RevisiumClient, client, sdk_gen_exports as sdk };
|
|
2278
|
+
export { RevisiumClient, RevisiumScope, client, sdk_gen_exports as sdk };
|
|
1973
2279
|
//# sourceMappingURL=index.mjs.map
|