@revisium/client 0.1.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 +89 -1
- package/dist/data-operations.d.ts +59 -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 +630 -276
- 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 +630 -277
- package/dist/index.mjs.map +1 -1
- package/dist/revisium-client.d.ts +23 -7
- package/dist/revisium-client.d.ts.map +1 -1
- package/dist/revisium-scope.d.ts +82 -0
- package/dist/revisium-scope.d.ts.map +1 -0
- package/package.json +8 -3
package/dist/index.cjs
CHANGED
|
@@ -658,7 +658,7 @@ const client = createClient(createConfig());
|
|
|
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,
|
|
@@ -668,16 +668,16 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
668
668
|
createEndpoint: () => createEndpoint,
|
|
669
669
|
createProject: () => createProject,
|
|
670
670
|
createRevision: () => createRevision,
|
|
671
|
-
createRow: () => createRow,
|
|
672
|
-
createRows: () => createRows,
|
|
673
|
-
createTable: () => createTable,
|
|
671
|
+
createRow: () => createRow$1,
|
|
672
|
+
createRows: () => createRows$1,
|
|
673
|
+
createTable: () => createTable$1,
|
|
674
674
|
createUser: () => createUser,
|
|
675
675
|
deleteBranch: () => deleteBranch,
|
|
676
676
|
deleteEndpoint: () => deleteEndpoint,
|
|
677
677
|
deleteProject: () => deleteProject,
|
|
678
|
-
deleteRow: () => deleteRow,
|
|
679
|
-
deleteRows: () => deleteRows,
|
|
680
|
-
deleteTable: () => deleteTable,
|
|
678
|
+
deleteRow: () => deleteRow$1,
|
|
679
|
+
deleteRows: () => deleteRows$1,
|
|
680
|
+
deleteTable: () => deleteTable$1,
|
|
681
681
|
draftRevision: () => draftRevision,
|
|
682
682
|
endpointRelatives: () => endpointRelatives,
|
|
683
683
|
endpoints: () => endpoints,
|
|
@@ -685,20 +685,20 @@ 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,
|
|
692
|
-
patchRow: () => patchRow,
|
|
692
|
+
patchRow: () => patchRow$1,
|
|
693
693
|
patchRows: () => patchRows,
|
|
694
694
|
project: () => project,
|
|
695
695
|
projects: () => projects,
|
|
696
696
|
readiness: () => readiness,
|
|
697
697
|
removeUserFromOrganization: () => removeUserFromOrganization,
|
|
698
698
|
removeUserFromProject: () => removeUserFromProject,
|
|
699
|
-
renameRow: () => renameRow,
|
|
700
|
-
renameTable: () => renameTable,
|
|
701
|
-
revertChanges: () => revertChanges,
|
|
699
|
+
renameRow: () => renameRow$1,
|
|
700
|
+
renameTable: () => renameTable$1,
|
|
701
|
+
revertChanges: () => revertChanges$1,
|
|
702
702
|
revision: () => revision,
|
|
703
703
|
revisionChanges: () => revisionChanges,
|
|
704
704
|
revisions: () => revisions,
|
|
@@ -722,9 +722,9 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
722
722
|
tables: () => tables,
|
|
723
723
|
updatePassword: () => updatePassword,
|
|
724
724
|
updateProject: () => updateProject,
|
|
725
|
-
updateRow: () => updateRow,
|
|
726
|
-
updateRows: () => updateRows,
|
|
727
|
-
updateTable: () => updateTable,
|
|
725
|
+
updateRow: () => updateRow$1,
|
|
726
|
+
updateRows: () => updateRows$1,
|
|
727
|
+
updateTable: () => updateTable$1,
|
|
728
728
|
uploadFile: () => uploadFile,
|
|
729
729
|
usersOrganization: () => usersOrganization,
|
|
730
730
|
usersProject: () => usersProject
|
|
@@ -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"
|
|
@@ -1054,7 +1054,7 @@ const createRevision = (options) => (options.client ?? client).post({
|
|
|
1054
1054
|
/**
|
|
1055
1055
|
* Discard all uncommitted changes
|
|
1056
1056
|
*/
|
|
1057
|
-
const revertChanges = (options) => (options.client ?? client).post({
|
|
1057
|
+
const revertChanges$1 = (options) => (options.client ?? client).post({
|
|
1058
1058
|
security: [{
|
|
1059
1059
|
scheme: "bearer",
|
|
1060
1060
|
type: "http"
|
|
@@ -1135,7 +1135,7 @@ const tables = (options) => (options.client ?? client).get({
|
|
|
1135
1135
|
/**
|
|
1136
1136
|
* Create a new table
|
|
1137
1137
|
*/
|
|
1138
|
-
const createTable = (options) => (options.client ?? client).post({
|
|
1138
|
+
const createTable$1 = (options) => (options.client ?? client).post({
|
|
1139
1139
|
security: [{
|
|
1140
1140
|
scheme: "bearer",
|
|
1141
1141
|
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"
|
|
@@ -1235,7 +1235,7 @@ const applyMigrations = (options) => (options.client ?? client).post({
|
|
|
1235
1235
|
/**
|
|
1236
1236
|
* Delete a table
|
|
1237
1237
|
*/
|
|
1238
|
-
const deleteTable = (options) => (options.client ?? client).delete({
|
|
1238
|
+
const deleteTable$1 = (options) => (options.client ?? client).delete({
|
|
1239
1239
|
security: [{
|
|
1240
1240
|
scheme: "bearer",
|
|
1241
1241
|
type: "http"
|
|
@@ -1257,7 +1257,7 @@ const table = (options) => (options.client ?? client).get({
|
|
|
1257
1257
|
/**
|
|
1258
1258
|
* Update table schema using JSON Patch
|
|
1259
1259
|
*/
|
|
1260
|
-
const updateTable = (options) => (options.client ?? client).patch({
|
|
1260
|
+
const updateTable$1 = (options) => (options.client ?? client).patch({
|
|
1261
1261
|
security: [{
|
|
1262
1262
|
scheme: "bearer",
|
|
1263
1263
|
type: "http"
|
|
@@ -1283,7 +1283,7 @@ const tableCountRows = (options) => (options.client ?? client).get({
|
|
|
1283
1283
|
/**
|
|
1284
1284
|
* Delete multiple rows
|
|
1285
1285
|
*/
|
|
1286
|
-
const deleteRows = (options) => (options.client ?? client).delete({
|
|
1286
|
+
const deleteRows$1 = (options) => (options.client ?? client).delete({
|
|
1287
1287
|
security: [{
|
|
1288
1288
|
scheme: "bearer",
|
|
1289
1289
|
type: "http"
|
|
@@ -1313,7 +1313,7 @@ const rows = (options) => (options.client ?? client).post({
|
|
|
1313
1313
|
/**
|
|
1314
1314
|
* Create a new row
|
|
1315
1315
|
*/
|
|
1316
|
-
const createRow = (options) => (options.client ?? client).post({
|
|
1316
|
+
const createRow$1 = (options) => (options.client ?? client).post({
|
|
1317
1317
|
security: [{
|
|
1318
1318
|
scheme: "bearer",
|
|
1319
1319
|
type: "http"
|
|
@@ -1328,7 +1328,7 @@ const createRow = (options) => (options.client ?? client).post({
|
|
|
1328
1328
|
/**
|
|
1329
1329
|
* Create multiple rows
|
|
1330
1330
|
*/
|
|
1331
|
-
const createRows = (options) => (options.client ?? client).post({
|
|
1331
|
+
const createRows$1 = (options) => (options.client ?? client).post({
|
|
1332
1332
|
security: [{
|
|
1333
1333
|
scheme: "bearer",
|
|
1334
1334
|
type: "http"
|
|
@@ -1343,7 +1343,7 @@ const createRows = (options) => (options.client ?? client).post({
|
|
|
1343
1343
|
/**
|
|
1344
1344
|
* Replace data for multiple rows
|
|
1345
1345
|
*/
|
|
1346
|
-
const updateRows = (options) => (options.client ?? client).put({
|
|
1346
|
+
const updateRows$1 = (options) => (options.client ?? client).put({
|
|
1347
1347
|
security: [{
|
|
1348
1348
|
scheme: "bearer",
|
|
1349
1349
|
type: "http"
|
|
@@ -1428,7 +1428,7 @@ const tableForeignKeysTo = (options) => (options.client ?? client).get({
|
|
|
1428
1428
|
/**
|
|
1429
1429
|
* Rename a table
|
|
1430
1430
|
*/
|
|
1431
|
-
const renameTable = (options) => (options.client ?? client).patch({
|
|
1431
|
+
const renameTable$1 = (options) => (options.client ?? client).patch({
|
|
1432
1432
|
security: [{
|
|
1433
1433
|
scheme: "bearer",
|
|
1434
1434
|
type: "http"
|
|
@@ -1443,7 +1443,7 @@ const renameTable = (options) => (options.client ?? client).patch({
|
|
|
1443
1443
|
/**
|
|
1444
1444
|
* Delete a row
|
|
1445
1445
|
*/
|
|
1446
|
-
const deleteRow = (options) => (options.client ?? client).delete({
|
|
1446
|
+
const deleteRow$1 = (options) => (options.client ?? client).delete({
|
|
1447
1447
|
security: [{
|
|
1448
1448
|
scheme: "bearer",
|
|
1449
1449
|
type: "http"
|
|
@@ -1465,7 +1465,7 @@ const row = (options) => (options.client ?? client).get({
|
|
|
1465
1465
|
/**
|
|
1466
1466
|
* Patch row data using JSON Patch
|
|
1467
1467
|
*/
|
|
1468
|
-
const patchRow = (options) => (options.client ?? client).patch({
|
|
1468
|
+
const patchRow$1 = (options) => (options.client ?? client).patch({
|
|
1469
1469
|
security: [{
|
|
1470
1470
|
scheme: "bearer",
|
|
1471
1471
|
type: "http"
|
|
@@ -1480,7 +1480,7 @@ const patchRow = (options) => (options.client ?? client).patch({
|
|
|
1480
1480
|
/**
|
|
1481
1481
|
* Replace row data
|
|
1482
1482
|
*/
|
|
1483
|
-
const updateRow = (options) => (options.client ?? client).put({
|
|
1483
|
+
const updateRow$1 = (options) => (options.client ?? client).put({
|
|
1484
1484
|
security: [{
|
|
1485
1485
|
scheme: "bearer",
|
|
1486
1486
|
type: "http"
|
|
@@ -1539,7 +1539,7 @@ const rowForeignKeysTo = (options) => (options.client ?? client).get({
|
|
|
1539
1539
|
/**
|
|
1540
1540
|
* Rename a row
|
|
1541
1541
|
*/
|
|
1542
|
-
const renameRow = (options) => (options.client ?? client).patch({
|
|
1542
|
+
const renameRow$1 = (options) => (options.client ?? client).patch({
|
|
1543
1543
|
security: [{
|
|
1544
1544
|
scheme: "bearer",
|
|
1545
1545
|
type: "http"
|
|
@@ -1605,6 +1605,487 @@ const liveness = (options) => (options?.client ?? client).get({
|
|
|
1605
1605
|
...options
|
|
1606
1606
|
});
|
|
1607
1607
|
|
|
1608
|
+
//#endregion
|
|
1609
|
+
//#region src/data-operations.ts
|
|
1610
|
+
function unwrap(result) {
|
|
1611
|
+
if (result.error) {
|
|
1612
|
+
const err = result.error;
|
|
1613
|
+
throw new Error(err.message ?? `API error: ${JSON.stringify(result.error)}`);
|
|
1614
|
+
}
|
|
1615
|
+
return result.data;
|
|
1616
|
+
}
|
|
1617
|
+
function assertDraft(ctx) {
|
|
1618
|
+
assertContext(ctx);
|
|
1619
|
+
if (!ctx.isDraft) throw new Error("Mutations are only allowed in draft revision. Use setContext({ revision: \"draft\" }).");
|
|
1620
|
+
}
|
|
1621
|
+
function assertContext(ctx) {
|
|
1622
|
+
if (!ctx.branch.organizationId) throw new Error("Context not set. Call setContext() first.");
|
|
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
|
+
}
|
|
1644
|
+
async function getTables(ctx, options) {
|
|
1645
|
+
const revisionId = await ctx.getRevisionId();
|
|
1646
|
+
return unwrap(await tables({
|
|
1647
|
+
client: ctx.client,
|
|
1648
|
+
path: { revisionId },
|
|
1649
|
+
query: {
|
|
1650
|
+
first: options?.first ?? 100,
|
|
1651
|
+
after: options?.after
|
|
1652
|
+
}
|
|
1653
|
+
}));
|
|
1654
|
+
}
|
|
1655
|
+
async function getTable(ctx, tableId) {
|
|
1656
|
+
const revisionId = await ctx.getRevisionId();
|
|
1657
|
+
return unwrap(await table({
|
|
1658
|
+
client: ctx.client,
|
|
1659
|
+
path: {
|
|
1660
|
+
revisionId,
|
|
1661
|
+
tableId
|
|
1662
|
+
}
|
|
1663
|
+
}));
|
|
1664
|
+
}
|
|
1665
|
+
async function getTableSchema(ctx, tableId) {
|
|
1666
|
+
const revisionId = await ctx.getRevisionId();
|
|
1667
|
+
return unwrap(await tableSchema({
|
|
1668
|
+
client: ctx.client,
|
|
1669
|
+
path: {
|
|
1670
|
+
revisionId,
|
|
1671
|
+
tableId
|
|
1672
|
+
}
|
|
1673
|
+
}));
|
|
1674
|
+
}
|
|
1675
|
+
async function getRows(ctx, tableId, options) {
|
|
1676
|
+
const revisionId = await ctx.getRevisionId();
|
|
1677
|
+
return unwrap(await rows({
|
|
1678
|
+
client: ctx.client,
|
|
1679
|
+
path: {
|
|
1680
|
+
revisionId,
|
|
1681
|
+
tableId
|
|
1682
|
+
},
|
|
1683
|
+
body: options ?? { first: 100 }
|
|
1684
|
+
}));
|
|
1685
|
+
}
|
|
1686
|
+
async function getRow(ctx, tableId, rowId) {
|
|
1687
|
+
const revisionId = await ctx.getRevisionId();
|
|
1688
|
+
return unwrap(await row({
|
|
1689
|
+
client: ctx.client,
|
|
1690
|
+
path: {
|
|
1691
|
+
revisionId,
|
|
1692
|
+
tableId,
|
|
1693
|
+
rowId
|
|
1694
|
+
}
|
|
1695
|
+
}));
|
|
1696
|
+
}
|
|
1697
|
+
async function getChanges(ctx) {
|
|
1698
|
+
const revisionId = await ctx.getRevisionId();
|
|
1699
|
+
return unwrap(await revisionChanges({
|
|
1700
|
+
client: ctx.client,
|
|
1701
|
+
path: { revisionId }
|
|
1702
|
+
}));
|
|
1703
|
+
}
|
|
1704
|
+
async function createTable(ctx, tableId, schema) {
|
|
1705
|
+
assertDraft(ctx);
|
|
1706
|
+
const revisionId = await ctx.getRevisionId();
|
|
1707
|
+
return unwrap(await createTable$1({
|
|
1708
|
+
client: ctx.client,
|
|
1709
|
+
path: { revisionId },
|
|
1710
|
+
body: {
|
|
1711
|
+
tableId,
|
|
1712
|
+
schema
|
|
1713
|
+
}
|
|
1714
|
+
}));
|
|
1715
|
+
}
|
|
1716
|
+
async function updateTable(ctx, tableId, patches) {
|
|
1717
|
+
assertDraft(ctx);
|
|
1718
|
+
const revisionId = await ctx.getRevisionId();
|
|
1719
|
+
return unwrap(await updateTable$1({
|
|
1720
|
+
client: ctx.client,
|
|
1721
|
+
path: {
|
|
1722
|
+
revisionId,
|
|
1723
|
+
tableId
|
|
1724
|
+
},
|
|
1725
|
+
body: { patches }
|
|
1726
|
+
}));
|
|
1727
|
+
}
|
|
1728
|
+
async function deleteTable(ctx, tableId) {
|
|
1729
|
+
assertDraft(ctx);
|
|
1730
|
+
const revisionId = await ctx.getRevisionId();
|
|
1731
|
+
unwrap(await deleteTable$1({
|
|
1732
|
+
client: ctx.client,
|
|
1733
|
+
path: {
|
|
1734
|
+
revisionId,
|
|
1735
|
+
tableId
|
|
1736
|
+
}
|
|
1737
|
+
}));
|
|
1738
|
+
}
|
|
1739
|
+
async function renameTable(ctx, tableId, nextTableId) {
|
|
1740
|
+
assertDraft(ctx);
|
|
1741
|
+
const revisionId = await ctx.getRevisionId();
|
|
1742
|
+
return unwrap(await renameTable$1({
|
|
1743
|
+
client: ctx.client,
|
|
1744
|
+
path: {
|
|
1745
|
+
revisionId,
|
|
1746
|
+
tableId
|
|
1747
|
+
},
|
|
1748
|
+
body: { nextTableId }
|
|
1749
|
+
}));
|
|
1750
|
+
}
|
|
1751
|
+
async function createRow(ctx, tableId, rowId, data) {
|
|
1752
|
+
assertDraft(ctx);
|
|
1753
|
+
const revisionId = await ctx.getRevisionId();
|
|
1754
|
+
return unwrap(await createRow$1({
|
|
1755
|
+
client: ctx.client,
|
|
1756
|
+
path: {
|
|
1757
|
+
revisionId,
|
|
1758
|
+
tableId
|
|
1759
|
+
},
|
|
1760
|
+
body: {
|
|
1761
|
+
rowId,
|
|
1762
|
+
data
|
|
1763
|
+
}
|
|
1764
|
+
}));
|
|
1765
|
+
}
|
|
1766
|
+
async function createRows(ctx, tableId, rows, options) {
|
|
1767
|
+
assertDraft(ctx);
|
|
1768
|
+
const revisionId = await ctx.getRevisionId();
|
|
1769
|
+
return unwrap(await createRows$1({
|
|
1770
|
+
client: ctx.client,
|
|
1771
|
+
path: {
|
|
1772
|
+
revisionId,
|
|
1773
|
+
tableId
|
|
1774
|
+
},
|
|
1775
|
+
body: {
|
|
1776
|
+
rows: rows.map((r) => ({
|
|
1777
|
+
rowId: r.rowId,
|
|
1778
|
+
data: r.data
|
|
1779
|
+
})),
|
|
1780
|
+
isRestore: options?.isRestore
|
|
1781
|
+
}
|
|
1782
|
+
}));
|
|
1783
|
+
}
|
|
1784
|
+
async function updateRow(ctx, tableId, rowId, data) {
|
|
1785
|
+
assertDraft(ctx);
|
|
1786
|
+
const revisionId = await ctx.getRevisionId();
|
|
1787
|
+
return unwrap(await updateRow$1({
|
|
1788
|
+
client: ctx.client,
|
|
1789
|
+
path: {
|
|
1790
|
+
revisionId,
|
|
1791
|
+
tableId,
|
|
1792
|
+
rowId
|
|
1793
|
+
},
|
|
1794
|
+
body: { data }
|
|
1795
|
+
}));
|
|
1796
|
+
}
|
|
1797
|
+
async function updateRows(ctx, tableId, rows, options) {
|
|
1798
|
+
assertDraft(ctx);
|
|
1799
|
+
const revisionId = await ctx.getRevisionId();
|
|
1800
|
+
return unwrap(await updateRows$1({
|
|
1801
|
+
client: ctx.client,
|
|
1802
|
+
path: {
|
|
1803
|
+
revisionId,
|
|
1804
|
+
tableId
|
|
1805
|
+
},
|
|
1806
|
+
body: {
|
|
1807
|
+
rows: rows.map((r) => ({
|
|
1808
|
+
rowId: r.rowId,
|
|
1809
|
+
data: r.data
|
|
1810
|
+
})),
|
|
1811
|
+
isRestore: options?.isRestore
|
|
1812
|
+
}
|
|
1813
|
+
}));
|
|
1814
|
+
}
|
|
1815
|
+
async function patchRow(ctx, tableId, rowId, patches) {
|
|
1816
|
+
assertDraft(ctx);
|
|
1817
|
+
const revisionId = await ctx.getRevisionId();
|
|
1818
|
+
return unwrap(await patchRow$1({
|
|
1819
|
+
client: ctx.client,
|
|
1820
|
+
path: {
|
|
1821
|
+
revisionId,
|
|
1822
|
+
tableId,
|
|
1823
|
+
rowId
|
|
1824
|
+
},
|
|
1825
|
+
body: { patches }
|
|
1826
|
+
}));
|
|
1827
|
+
}
|
|
1828
|
+
async function deleteRow(ctx, tableId, rowId) {
|
|
1829
|
+
assertDraft(ctx);
|
|
1830
|
+
const revisionId = await ctx.getRevisionId();
|
|
1831
|
+
unwrap(await deleteRow$1({
|
|
1832
|
+
client: ctx.client,
|
|
1833
|
+
path: {
|
|
1834
|
+
revisionId,
|
|
1835
|
+
tableId,
|
|
1836
|
+
rowId
|
|
1837
|
+
}
|
|
1838
|
+
}));
|
|
1839
|
+
}
|
|
1840
|
+
async function deleteRows(ctx, tableId, rowIds) {
|
|
1841
|
+
assertDraft(ctx);
|
|
1842
|
+
const revisionId = await ctx.getRevisionId();
|
|
1843
|
+
unwrap(await deleteRows$1({
|
|
1844
|
+
client: ctx.client,
|
|
1845
|
+
path: {
|
|
1846
|
+
revisionId,
|
|
1847
|
+
tableId
|
|
1848
|
+
},
|
|
1849
|
+
body: { rowIds }
|
|
1850
|
+
}));
|
|
1851
|
+
}
|
|
1852
|
+
async function renameRow(ctx, tableId, rowId, nextRowId) {
|
|
1853
|
+
assertDraft(ctx);
|
|
1854
|
+
const revisionId = await ctx.getRevisionId();
|
|
1855
|
+
return unwrap(await renameRow$1({
|
|
1856
|
+
client: ctx.client,
|
|
1857
|
+
path: {
|
|
1858
|
+
revisionId,
|
|
1859
|
+
tableId,
|
|
1860
|
+
rowId
|
|
1861
|
+
},
|
|
1862
|
+
body: { nextRowId }
|
|
1863
|
+
}));
|
|
1864
|
+
}
|
|
1865
|
+
async function commit(ctx, comment) {
|
|
1866
|
+
assertDraft(ctx);
|
|
1867
|
+
return unwrap(await createRevision({
|
|
1868
|
+
client: ctx.client,
|
|
1869
|
+
path: {
|
|
1870
|
+
organizationId: ctx.branch.organizationId,
|
|
1871
|
+
projectName: ctx.branch.projectName,
|
|
1872
|
+
branchName: ctx.branch.branchName
|
|
1873
|
+
},
|
|
1874
|
+
body: { comment }
|
|
1875
|
+
}));
|
|
1876
|
+
}
|
|
1877
|
+
async function revertChanges(ctx) {
|
|
1878
|
+
assertDraft(ctx);
|
|
1879
|
+
unwrap(await revertChanges$1({
|
|
1880
|
+
client: ctx.client,
|
|
1881
|
+
path: {
|
|
1882
|
+
organizationId: ctx.branch.organizationId,
|
|
1883
|
+
projectName: ctx.branch.projectName,
|
|
1884
|
+
branchName: ctx.branch.branchName
|
|
1885
|
+
}
|
|
1886
|
+
}));
|
|
1887
|
+
}
|
|
1888
|
+
async function fetchDraftRevisionId(client, branch) {
|
|
1889
|
+
return unwrap(await draftRevision({
|
|
1890
|
+
client,
|
|
1891
|
+
path: {
|
|
1892
|
+
organizationId: branch.organizationId,
|
|
1893
|
+
projectName: branch.projectName,
|
|
1894
|
+
branchName: branch.branchName
|
|
1895
|
+
}
|
|
1896
|
+
})).id;
|
|
1897
|
+
}
|
|
1898
|
+
async function fetchHeadRevisionId(client, branch) {
|
|
1899
|
+
return unwrap(await headRevision({
|
|
1900
|
+
client,
|
|
1901
|
+
path: {
|
|
1902
|
+
organizationId: branch.organizationId,
|
|
1903
|
+
projectName: branch.projectName,
|
|
1904
|
+
branchName: branch.branchName
|
|
1905
|
+
}
|
|
1906
|
+
})).id;
|
|
1907
|
+
}
|
|
1908
|
+
async function validateRevisionId(client, revisionId) {
|
|
1909
|
+
unwrap(await revision({
|
|
1910
|
+
client,
|
|
1911
|
+
path: { revisionId }
|
|
1912
|
+
}));
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
//#endregion
|
|
1916
|
+
//#region src/revisium-scope.ts
|
|
1917
|
+
var RevisiumScope = class {
|
|
1918
|
+
_client;
|
|
1919
|
+
_branch;
|
|
1920
|
+
_revisionMode;
|
|
1921
|
+
_owner;
|
|
1922
|
+
_revisionId;
|
|
1923
|
+
_isDraft;
|
|
1924
|
+
_stale = false;
|
|
1925
|
+
_disposed = false;
|
|
1926
|
+
_refreshPromise = null;
|
|
1927
|
+
constructor(init) {
|
|
1928
|
+
this._client = init.client;
|
|
1929
|
+
this._branch = init.branch;
|
|
1930
|
+
this._revisionId = init.revisionId;
|
|
1931
|
+
this._isDraft = init.isDraft;
|
|
1932
|
+
this._revisionMode = init.revisionMode;
|
|
1933
|
+
this._owner = init.owner;
|
|
1934
|
+
}
|
|
1935
|
+
get organizationId() {
|
|
1936
|
+
return this._branch.organizationId;
|
|
1937
|
+
}
|
|
1938
|
+
get projectName() {
|
|
1939
|
+
return this._branch.projectName;
|
|
1940
|
+
}
|
|
1941
|
+
get branchName() {
|
|
1942
|
+
return this._branch.branchName;
|
|
1943
|
+
}
|
|
1944
|
+
get revisionId() {
|
|
1945
|
+
return this._revisionId;
|
|
1946
|
+
}
|
|
1947
|
+
get isDraft() {
|
|
1948
|
+
return this._isDraft;
|
|
1949
|
+
}
|
|
1950
|
+
get isStale() {
|
|
1951
|
+
return this._stale;
|
|
1952
|
+
}
|
|
1953
|
+
get isDisposed() {
|
|
1954
|
+
return this._disposed;
|
|
1955
|
+
}
|
|
1956
|
+
get client() {
|
|
1957
|
+
return this._client;
|
|
1958
|
+
}
|
|
1959
|
+
markStale() {
|
|
1960
|
+
if (this._revisionMode === "explicit") return;
|
|
1961
|
+
this._stale = true;
|
|
1962
|
+
}
|
|
1963
|
+
async refresh() {
|
|
1964
|
+
this.assertNotDisposed();
|
|
1965
|
+
if (this._revisionMode === "explicit") return;
|
|
1966
|
+
this._revisionId = await this.fetchRevisionId();
|
|
1967
|
+
this._stale = false;
|
|
1968
|
+
}
|
|
1969
|
+
dispose() {
|
|
1970
|
+
if (this._disposed) return;
|
|
1971
|
+
this._disposed = true;
|
|
1972
|
+
this._owner.unregisterScope(this);
|
|
1973
|
+
}
|
|
1974
|
+
assertNotDisposed() {
|
|
1975
|
+
if (this._disposed) throw new Error("Scope has been disposed.");
|
|
1976
|
+
}
|
|
1977
|
+
get _branchKey() {
|
|
1978
|
+
return `${this._branch.organizationId}/${this._branch.projectName}/${this._branch.branchName}`;
|
|
1979
|
+
}
|
|
1980
|
+
async fetchRevisionId() {
|
|
1981
|
+
if (this._revisionMode === "draft") return fetchDraftRevisionId(this._client, this._branch);
|
|
1982
|
+
return fetchHeadRevisionId(this._client, this._branch);
|
|
1983
|
+
}
|
|
1984
|
+
async getRevisionId() {
|
|
1985
|
+
this.assertNotDisposed();
|
|
1986
|
+
if (this._stale) {
|
|
1987
|
+
this._refreshPromise ??= this.fetchRevisionId().then((id) => {
|
|
1988
|
+
this._revisionId = id;
|
|
1989
|
+
this._stale = false;
|
|
1990
|
+
this._refreshPromise = null;
|
|
1991
|
+
return id;
|
|
1992
|
+
}, (err) => {
|
|
1993
|
+
this._refreshPromise = null;
|
|
1994
|
+
throw err;
|
|
1995
|
+
});
|
|
1996
|
+
return this._refreshPromise;
|
|
1997
|
+
}
|
|
1998
|
+
return this._revisionId;
|
|
1999
|
+
}
|
|
2000
|
+
get _scopeContext() {
|
|
2001
|
+
return {
|
|
2002
|
+
client: this._client,
|
|
2003
|
+
branch: this._branch,
|
|
2004
|
+
isDraft: this._isDraft,
|
|
2005
|
+
getRevisionId: () => this.getRevisionId()
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
async getTables(options) {
|
|
2009
|
+
return getTables(this._scopeContext, options);
|
|
2010
|
+
}
|
|
2011
|
+
async getTable(tableId) {
|
|
2012
|
+
return getTable(this._scopeContext, tableId);
|
|
2013
|
+
}
|
|
2014
|
+
async getTableSchema(tableId) {
|
|
2015
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
2016
|
+
}
|
|
2017
|
+
async getRows(tableId, options) {
|
|
2018
|
+
return getRows(this._scopeContext, tableId, options);
|
|
2019
|
+
}
|
|
2020
|
+
async getRow(tableId, rowId) {
|
|
2021
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
2022
|
+
}
|
|
2023
|
+
async getChanges() {
|
|
2024
|
+
return getChanges(this._scopeContext);
|
|
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
|
+
}
|
|
2036
|
+
async createTable(tableId, schema) {
|
|
2037
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
2038
|
+
}
|
|
2039
|
+
async updateTable(tableId, patches) {
|
|
2040
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
2041
|
+
}
|
|
2042
|
+
async deleteTable(tableId) {
|
|
2043
|
+
return deleteTable(this._scopeContext, tableId);
|
|
2044
|
+
}
|
|
2045
|
+
async renameTable(tableId, nextTableId) {
|
|
2046
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
2047
|
+
}
|
|
2048
|
+
async createRow(tableId, rowId, data) {
|
|
2049
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2050
|
+
}
|
|
2051
|
+
async createRows(tableId, rows, options) {
|
|
2052
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
2053
|
+
}
|
|
2054
|
+
async updateRow(tableId, rowId, data) {
|
|
2055
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2056
|
+
}
|
|
2057
|
+
async updateRows(tableId, rows, options) {
|
|
2058
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
2059
|
+
}
|
|
2060
|
+
async patchRow(tableId, rowId, patches) {
|
|
2061
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
2062
|
+
}
|
|
2063
|
+
async deleteRow(tableId, rowId) {
|
|
2064
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
2065
|
+
}
|
|
2066
|
+
async deleteRows(tableId, rowIds) {
|
|
2067
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
2068
|
+
}
|
|
2069
|
+
async renameRow(tableId, rowId, nextRowId) {
|
|
2070
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
2071
|
+
}
|
|
2072
|
+
async commit(comment) {
|
|
2073
|
+
this.assertNotDisposed();
|
|
2074
|
+
const data = await commit(this._scopeContext, comment);
|
|
2075
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2076
|
+
this._stale = false;
|
|
2077
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2078
|
+
return data;
|
|
2079
|
+
}
|
|
2080
|
+
async revertChanges() {
|
|
2081
|
+
this.assertNotDisposed();
|
|
2082
|
+
await revertChanges(this._scopeContext);
|
|
2083
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2084
|
+
this._stale = false;
|
|
2085
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
|
|
1608
2089
|
//#endregion
|
|
1609
2090
|
//#region src/revisium-client.ts
|
|
1610
2091
|
var RevisiumClient = class {
|
|
@@ -1616,6 +2097,7 @@ var RevisiumClient = class {
|
|
|
1616
2097
|
_revisionId = null;
|
|
1617
2098
|
_isDraft = false;
|
|
1618
2099
|
_isAuthenticated = false;
|
|
2100
|
+
_scopes = /* @__PURE__ */ new Map();
|
|
1619
2101
|
constructor(options) {
|
|
1620
2102
|
const url = options.baseUrl;
|
|
1621
2103
|
this._baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
|
|
@@ -1653,7 +2135,7 @@ var RevisiumClient = class {
|
|
|
1653
2135
|
password
|
|
1654
2136
|
}
|
|
1655
2137
|
});
|
|
1656
|
-
const data =
|
|
2138
|
+
const data = unwrap(result);
|
|
1657
2139
|
this._client.setConfig({ auth: data.accessToken });
|
|
1658
2140
|
this._isAuthenticated = true;
|
|
1659
2141
|
}
|
|
@@ -1661,317 +2143,189 @@ var RevisiumClient = class {
|
|
|
1661
2143
|
this._client.setConfig({ auth: token });
|
|
1662
2144
|
this._isAuthenticated = true;
|
|
1663
2145
|
}
|
|
2146
|
+
async me() {
|
|
2147
|
+
return me(this._client);
|
|
2148
|
+
}
|
|
1664
2149
|
async setContext(options) {
|
|
1665
|
-
const { organizationId, projectName, branchName = "master", revision
|
|
2150
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
1666
2151
|
this._organizationId = organizationId;
|
|
1667
2152
|
this._projectName = projectName;
|
|
1668
2153
|
this._branchName = branchName;
|
|
1669
|
-
const
|
|
2154
|
+
const branch = {
|
|
1670
2155
|
organizationId,
|
|
1671
2156
|
projectName,
|
|
1672
2157
|
branchName
|
|
1673
2158
|
};
|
|
1674
|
-
if (revision
|
|
1675
|
-
|
|
1676
|
-
client: this._client,
|
|
1677
|
-
path: branchPath
|
|
1678
|
-
});
|
|
1679
|
-
this._revisionId = this.unwrap(result).id;
|
|
2159
|
+
if (revision === "draft") {
|
|
2160
|
+
this._revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
1680
2161
|
this._isDraft = true;
|
|
1681
|
-
} else if (revision
|
|
1682
|
-
|
|
1683
|
-
client: this._client,
|
|
1684
|
-
path: branchPath
|
|
1685
|
-
});
|
|
1686
|
-
this._revisionId = this.unwrap(result).id;
|
|
2162
|
+
} else if (revision === "head") {
|
|
2163
|
+
this._revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
1687
2164
|
this._isDraft = false;
|
|
1688
2165
|
} else {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
path: { revisionId: revision$1 }
|
|
1692
|
-
});
|
|
1693
|
-
this.unwrap(result);
|
|
1694
|
-
this._revisionId = revision$1;
|
|
2166
|
+
await validateRevisionId(this._client, revision);
|
|
2167
|
+
this._revisionId = revision;
|
|
1695
2168
|
this._isDraft = false;
|
|
1696
2169
|
}
|
|
1697
2170
|
}
|
|
1698
|
-
async
|
|
1699
|
-
|
|
1700
|
-
const
|
|
2171
|
+
async withContext(options) {
|
|
2172
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
2173
|
+
const branch = {
|
|
2174
|
+
organizationId,
|
|
2175
|
+
projectName,
|
|
2176
|
+
branchName
|
|
2177
|
+
};
|
|
2178
|
+
let revisionId;
|
|
2179
|
+
let isDraft;
|
|
2180
|
+
let revisionMode;
|
|
2181
|
+
if (revision === "draft") {
|
|
2182
|
+
revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
2183
|
+
isDraft = true;
|
|
2184
|
+
revisionMode = "draft";
|
|
2185
|
+
} else if (revision === "head") {
|
|
2186
|
+
revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
2187
|
+
isDraft = false;
|
|
2188
|
+
revisionMode = "head";
|
|
2189
|
+
} else {
|
|
2190
|
+
await validateRevisionId(this._client, revision);
|
|
2191
|
+
revisionId = revision;
|
|
2192
|
+
isDraft = false;
|
|
2193
|
+
revisionMode = "explicit";
|
|
2194
|
+
}
|
|
2195
|
+
const scope = new RevisiumScope({
|
|
1701
2196
|
client: this._client,
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
2197
|
+
branch,
|
|
2198
|
+
revisionId,
|
|
2199
|
+
isDraft,
|
|
2200
|
+
revisionMode,
|
|
2201
|
+
owner: this
|
|
1707
2202
|
});
|
|
1708
|
-
|
|
2203
|
+
const branchKey = `${organizationId}/${projectName}/${branchName}`;
|
|
2204
|
+
let scopeSet = this._scopes.get(branchKey);
|
|
2205
|
+
if (!scopeSet) {
|
|
2206
|
+
scopeSet = /* @__PURE__ */ new Set();
|
|
2207
|
+
this._scopes.set(branchKey, scopeSet);
|
|
2208
|
+
}
|
|
2209
|
+
scopeSet.add(scope);
|
|
2210
|
+
return scope;
|
|
2211
|
+
}
|
|
2212
|
+
notifyBranchChanged(branchKey, excludeScope) {
|
|
2213
|
+
const scopeSet = this._scopes.get(branchKey);
|
|
2214
|
+
if (!scopeSet) return;
|
|
2215
|
+
for (const scope of scopeSet) if (scope !== excludeScope) scope.markStale();
|
|
2216
|
+
}
|
|
2217
|
+
unregisterScope(scope) {
|
|
2218
|
+
for (const [key, scopeSet] of this._scopes) {
|
|
2219
|
+
scopeSet.delete(scope);
|
|
2220
|
+
if (scopeSet.size === 0) this._scopes.delete(key);
|
|
2221
|
+
}
|
|
1709
2222
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
const result = await table({
|
|
2223
|
+
get _scopeContext() {
|
|
2224
|
+
return {
|
|
1713
2225
|
client: this._client,
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
2226
|
+
branch: {
|
|
2227
|
+
organizationId: this._organizationId ?? "",
|
|
2228
|
+
projectName: this._projectName ?? "",
|
|
2229
|
+
branchName: this._branchName ?? ""
|
|
2230
|
+
},
|
|
2231
|
+
isDraft: this._isDraft,
|
|
2232
|
+
getRevisionId: () => {
|
|
2233
|
+
if (this._revisionId === null) return Promise.reject(/* @__PURE__ */ new Error("Context not set. Call setContext() first."));
|
|
2234
|
+
return Promise.resolve(this._revisionId);
|
|
1717
2235
|
}
|
|
1718
|
-
}
|
|
1719
|
-
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
async getTables(options) {
|
|
2239
|
+
return getTables(this._scopeContext, options);
|
|
2240
|
+
}
|
|
2241
|
+
async getTable(tableId) {
|
|
2242
|
+
return getTable(this._scopeContext, tableId);
|
|
1720
2243
|
}
|
|
1721
2244
|
async getTableSchema(tableId) {
|
|
1722
|
-
this.
|
|
1723
|
-
const result = await tableSchema({
|
|
1724
|
-
client: this._client,
|
|
1725
|
-
path: {
|
|
1726
|
-
revisionId: this._revisionId,
|
|
1727
|
-
tableId
|
|
1728
|
-
}
|
|
1729
|
-
});
|
|
1730
|
-
return this.unwrap(result);
|
|
2245
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
1731
2246
|
}
|
|
1732
2247
|
async getRows(tableId, options) {
|
|
1733
|
-
this.
|
|
1734
|
-
const result = await rows({
|
|
1735
|
-
client: this._client,
|
|
1736
|
-
path: {
|
|
1737
|
-
revisionId: this._revisionId,
|
|
1738
|
-
tableId
|
|
1739
|
-
},
|
|
1740
|
-
body: options ?? { first: 100 }
|
|
1741
|
-
});
|
|
1742
|
-
return this.unwrap(result);
|
|
2248
|
+
return getRows(this._scopeContext, tableId, options);
|
|
1743
2249
|
}
|
|
1744
2250
|
async getRow(tableId, rowId) {
|
|
1745
|
-
this.
|
|
1746
|
-
const result = await row({
|
|
1747
|
-
client: this._client,
|
|
1748
|
-
path: {
|
|
1749
|
-
revisionId: this._revisionId,
|
|
1750
|
-
tableId,
|
|
1751
|
-
rowId
|
|
1752
|
-
}
|
|
1753
|
-
});
|
|
1754
|
-
return this.unwrap(result);
|
|
2251
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
1755
2252
|
}
|
|
1756
2253
|
async getChanges() {
|
|
1757
|
-
this.
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
2254
|
+
return getChanges(this._scopeContext);
|
|
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();
|
|
1763
2263
|
}
|
|
1764
2264
|
async createTable(tableId, schema) {
|
|
1765
|
-
this.
|
|
1766
|
-
const result = await createTable({
|
|
1767
|
-
client: this._client,
|
|
1768
|
-
path: { revisionId: this._revisionId },
|
|
1769
|
-
body: {
|
|
1770
|
-
tableId,
|
|
1771
|
-
schema
|
|
1772
|
-
}
|
|
1773
|
-
});
|
|
1774
|
-
return this.unwrap(result);
|
|
2265
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
1775
2266
|
}
|
|
1776
2267
|
async updateTable(tableId, patches) {
|
|
1777
|
-
this.
|
|
1778
|
-
const result = await updateTable({
|
|
1779
|
-
client: this._client,
|
|
1780
|
-
path: {
|
|
1781
|
-
revisionId: this._revisionId,
|
|
1782
|
-
tableId
|
|
1783
|
-
},
|
|
1784
|
-
body: { patches }
|
|
1785
|
-
});
|
|
1786
|
-
return this.unwrap(result);
|
|
2268
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
1787
2269
|
}
|
|
1788
2270
|
async deleteTable(tableId) {
|
|
1789
|
-
this.
|
|
1790
|
-
const result = await deleteTable({
|
|
1791
|
-
client: this._client,
|
|
1792
|
-
path: {
|
|
1793
|
-
revisionId: this._revisionId,
|
|
1794
|
-
tableId
|
|
1795
|
-
}
|
|
1796
|
-
});
|
|
1797
|
-
this.unwrap(result);
|
|
2271
|
+
return deleteTable(this._scopeContext, tableId);
|
|
1798
2272
|
}
|
|
1799
2273
|
async renameTable(tableId, nextTableId) {
|
|
1800
|
-
this.
|
|
1801
|
-
const result = await renameTable({
|
|
1802
|
-
client: this._client,
|
|
1803
|
-
path: {
|
|
1804
|
-
revisionId: this._revisionId,
|
|
1805
|
-
tableId
|
|
1806
|
-
},
|
|
1807
|
-
body: { nextTableId }
|
|
1808
|
-
});
|
|
1809
|
-
return this.unwrap(result);
|
|
2274
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
1810
2275
|
}
|
|
1811
2276
|
async createRow(tableId, rowId, data) {
|
|
1812
|
-
this.
|
|
1813
|
-
const result = await createRow({
|
|
1814
|
-
client: this._client,
|
|
1815
|
-
path: {
|
|
1816
|
-
revisionId: this._revisionId,
|
|
1817
|
-
tableId
|
|
1818
|
-
},
|
|
1819
|
-
body: {
|
|
1820
|
-
rowId,
|
|
1821
|
-
data
|
|
1822
|
-
}
|
|
1823
|
-
});
|
|
1824
|
-
return this.unwrap(result);
|
|
2277
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
1825
2278
|
}
|
|
1826
|
-
async createRows(tableId, rows) {
|
|
1827
|
-
this.
|
|
1828
|
-
const result = await createRows({
|
|
1829
|
-
client: this._client,
|
|
1830
|
-
path: {
|
|
1831
|
-
revisionId: this._revisionId,
|
|
1832
|
-
tableId
|
|
1833
|
-
},
|
|
1834
|
-
body: { rows: rows.map((r) => ({
|
|
1835
|
-
rowId: r.rowId,
|
|
1836
|
-
data: r.data
|
|
1837
|
-
})) }
|
|
1838
|
-
});
|
|
1839
|
-
return this.unwrap(result);
|
|
2279
|
+
async createRows(tableId, rows, options) {
|
|
2280
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
1840
2281
|
}
|
|
1841
2282
|
async updateRow(tableId, rowId, data) {
|
|
1842
|
-
this.
|
|
1843
|
-
const result = await updateRow({
|
|
1844
|
-
client: this._client,
|
|
1845
|
-
path: {
|
|
1846
|
-
revisionId: this._revisionId,
|
|
1847
|
-
tableId,
|
|
1848
|
-
rowId
|
|
1849
|
-
},
|
|
1850
|
-
body: { data }
|
|
1851
|
-
});
|
|
1852
|
-
return this.unwrap(result);
|
|
2283
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
1853
2284
|
}
|
|
1854
|
-
async updateRows(tableId, rows) {
|
|
1855
|
-
this.
|
|
1856
|
-
const result = await updateRows({
|
|
1857
|
-
client: this._client,
|
|
1858
|
-
path: {
|
|
1859
|
-
revisionId: this._revisionId,
|
|
1860
|
-
tableId
|
|
1861
|
-
},
|
|
1862
|
-
body: { rows: rows.map((r) => ({
|
|
1863
|
-
rowId: r.rowId,
|
|
1864
|
-
data: r.data
|
|
1865
|
-
})) }
|
|
1866
|
-
});
|
|
1867
|
-
return this.unwrap(result);
|
|
2285
|
+
async updateRows(tableId, rows, options) {
|
|
2286
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
1868
2287
|
}
|
|
1869
2288
|
async patchRow(tableId, rowId, patches) {
|
|
1870
|
-
this.
|
|
1871
|
-
const result = await patchRow({
|
|
1872
|
-
client: this._client,
|
|
1873
|
-
path: {
|
|
1874
|
-
revisionId: this._revisionId,
|
|
1875
|
-
tableId,
|
|
1876
|
-
rowId
|
|
1877
|
-
},
|
|
1878
|
-
body: { patches }
|
|
1879
|
-
});
|
|
1880
|
-
return this.unwrap(result);
|
|
2289
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
1881
2290
|
}
|
|
1882
2291
|
async deleteRow(tableId, rowId) {
|
|
1883
|
-
this.
|
|
1884
|
-
const result = await deleteRow({
|
|
1885
|
-
client: this._client,
|
|
1886
|
-
path: {
|
|
1887
|
-
revisionId: this._revisionId,
|
|
1888
|
-
tableId,
|
|
1889
|
-
rowId
|
|
1890
|
-
}
|
|
1891
|
-
});
|
|
1892
|
-
this.unwrap(result);
|
|
2292
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
1893
2293
|
}
|
|
1894
2294
|
async deleteRows(tableId, rowIds) {
|
|
1895
|
-
this.
|
|
1896
|
-
const result = await deleteRows({
|
|
1897
|
-
client: this._client,
|
|
1898
|
-
path: {
|
|
1899
|
-
revisionId: this._revisionId,
|
|
1900
|
-
tableId
|
|
1901
|
-
},
|
|
1902
|
-
body: { rowIds }
|
|
1903
|
-
});
|
|
1904
|
-
this.unwrap(result);
|
|
2295
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
1905
2296
|
}
|
|
1906
2297
|
async renameRow(tableId, rowId, nextRowId) {
|
|
1907
|
-
this.
|
|
1908
|
-
const result = await renameRow({
|
|
1909
|
-
client: this._client,
|
|
1910
|
-
path: {
|
|
1911
|
-
revisionId: this._revisionId,
|
|
1912
|
-
tableId,
|
|
1913
|
-
rowId
|
|
1914
|
-
},
|
|
1915
|
-
body: { nextRowId }
|
|
1916
|
-
});
|
|
1917
|
-
return this.unwrap(result);
|
|
2298
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
1918
2299
|
}
|
|
1919
2300
|
async commit(comment) {
|
|
1920
|
-
this.
|
|
1921
|
-
const result = await createRevision({
|
|
1922
|
-
client: this._client,
|
|
1923
|
-
path: {
|
|
1924
|
-
organizationId: this._organizationId,
|
|
1925
|
-
projectName: this._projectName,
|
|
1926
|
-
branchName: this._branchName
|
|
1927
|
-
},
|
|
1928
|
-
body: { comment }
|
|
1929
|
-
});
|
|
1930
|
-
const data = this.unwrap(result);
|
|
2301
|
+
const data = await commit(this._scopeContext, comment);
|
|
1931
2302
|
await this.refreshDraftRevisionId();
|
|
2303
|
+
this.notifyScopesOnCurrentBranch();
|
|
1932
2304
|
return data;
|
|
1933
2305
|
}
|
|
1934
2306
|
async revertChanges() {
|
|
1935
|
-
this.
|
|
1936
|
-
await revertChanges({
|
|
1937
|
-
client: this._client,
|
|
1938
|
-
path: {
|
|
1939
|
-
organizationId: this._organizationId,
|
|
1940
|
-
projectName: this._projectName,
|
|
1941
|
-
branchName: this._branchName
|
|
1942
|
-
}
|
|
1943
|
-
});
|
|
2307
|
+
await revertChanges(this._scopeContext);
|
|
1944
2308
|
await this.refreshDraftRevisionId();
|
|
1945
|
-
|
|
1946
|
-
assertDraft() {
|
|
1947
|
-
this.assertContext();
|
|
1948
|
-
if (!this._isDraft) throw new Error("Mutations are only allowed in draft revision. Use setContext({ revision: \"draft\" }).");
|
|
1949
|
-
}
|
|
1950
|
-
assertContext() {
|
|
1951
|
-
if (this._revisionId === null) throw new Error("Context not set. Call setContext() first.");
|
|
2309
|
+
this.notifyScopesOnCurrentBranch();
|
|
1952
2310
|
}
|
|
1953
2311
|
async refreshDraftRevisionId() {
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
projectName: this._projectName,
|
|
1959
|
-
branchName: this._branchName
|
|
1960
|
-
}
|
|
2312
|
+
this._revisionId = await fetchDraftRevisionId(this._client, {
|
|
2313
|
+
organizationId: this._organizationId,
|
|
2314
|
+
projectName: this._projectName,
|
|
2315
|
+
branchName: this._branchName
|
|
1961
2316
|
});
|
|
1962
|
-
this._revisionId = this.unwrap(result).id;
|
|
1963
2317
|
}
|
|
1964
|
-
|
|
1965
|
-
if (
|
|
1966
|
-
const
|
|
1967
|
-
|
|
2318
|
+
notifyScopesOnCurrentBranch() {
|
|
2319
|
+
if (this._organizationId && this._projectName && this._branchName) {
|
|
2320
|
+
const branchKey = `${this._organizationId}/${this._projectName}/${this._branchName}`;
|
|
2321
|
+
this.notifyBranchChanged(branchKey);
|
|
1968
2322
|
}
|
|
1969
|
-
return result.data;
|
|
1970
2323
|
}
|
|
1971
2324
|
};
|
|
1972
2325
|
|
|
1973
2326
|
//#endregion
|
|
1974
2327
|
exports.RevisiumClient = RevisiumClient;
|
|
2328
|
+
exports.RevisiumScope = RevisiumScope;
|
|
1975
2329
|
exports.client = client;
|
|
1976
2330
|
Object.defineProperty(exports, 'sdk', {
|
|
1977
2331
|
enumerable: true,
|