@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.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,
|
|
@@ -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,
|
|
@@ -683,20 +683,20 @@ 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,
|
|
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
|
|
@@ -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"
|
|
@@ -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"
|
|
@@ -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"
|
|
@@ -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,487 @@ 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 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
|
+
}
|
|
1642
|
+
async function getTables(ctx, options) {
|
|
1643
|
+
const revisionId = await ctx.getRevisionId();
|
|
1644
|
+
return unwrap(await tables({
|
|
1645
|
+
client: ctx.client,
|
|
1646
|
+
path: { revisionId },
|
|
1647
|
+
query: {
|
|
1648
|
+
first: options?.first ?? 100,
|
|
1649
|
+
after: options?.after
|
|
1650
|
+
}
|
|
1651
|
+
}));
|
|
1652
|
+
}
|
|
1653
|
+
async function getTable(ctx, tableId) {
|
|
1654
|
+
const revisionId = await ctx.getRevisionId();
|
|
1655
|
+
return unwrap(await table({
|
|
1656
|
+
client: ctx.client,
|
|
1657
|
+
path: {
|
|
1658
|
+
revisionId,
|
|
1659
|
+
tableId
|
|
1660
|
+
}
|
|
1661
|
+
}));
|
|
1662
|
+
}
|
|
1663
|
+
async function getTableSchema(ctx, tableId) {
|
|
1664
|
+
const revisionId = await ctx.getRevisionId();
|
|
1665
|
+
return unwrap(await tableSchema({
|
|
1666
|
+
client: ctx.client,
|
|
1667
|
+
path: {
|
|
1668
|
+
revisionId,
|
|
1669
|
+
tableId
|
|
1670
|
+
}
|
|
1671
|
+
}));
|
|
1672
|
+
}
|
|
1673
|
+
async function getRows(ctx, tableId, options) {
|
|
1674
|
+
const revisionId = await ctx.getRevisionId();
|
|
1675
|
+
return unwrap(await rows({
|
|
1676
|
+
client: ctx.client,
|
|
1677
|
+
path: {
|
|
1678
|
+
revisionId,
|
|
1679
|
+
tableId
|
|
1680
|
+
},
|
|
1681
|
+
body: options ?? { first: 100 }
|
|
1682
|
+
}));
|
|
1683
|
+
}
|
|
1684
|
+
async function getRow(ctx, tableId, rowId) {
|
|
1685
|
+
const revisionId = await ctx.getRevisionId();
|
|
1686
|
+
return unwrap(await row({
|
|
1687
|
+
client: ctx.client,
|
|
1688
|
+
path: {
|
|
1689
|
+
revisionId,
|
|
1690
|
+
tableId,
|
|
1691
|
+
rowId
|
|
1692
|
+
}
|
|
1693
|
+
}));
|
|
1694
|
+
}
|
|
1695
|
+
async function getChanges(ctx) {
|
|
1696
|
+
const revisionId = await ctx.getRevisionId();
|
|
1697
|
+
return unwrap(await revisionChanges({
|
|
1698
|
+
client: ctx.client,
|
|
1699
|
+
path: { revisionId }
|
|
1700
|
+
}));
|
|
1701
|
+
}
|
|
1702
|
+
async function createTable(ctx, tableId, schema) {
|
|
1703
|
+
assertDraft(ctx);
|
|
1704
|
+
const revisionId = await ctx.getRevisionId();
|
|
1705
|
+
return unwrap(await createTable$1({
|
|
1706
|
+
client: ctx.client,
|
|
1707
|
+
path: { revisionId },
|
|
1708
|
+
body: {
|
|
1709
|
+
tableId,
|
|
1710
|
+
schema
|
|
1711
|
+
}
|
|
1712
|
+
}));
|
|
1713
|
+
}
|
|
1714
|
+
async function updateTable(ctx, tableId, patches) {
|
|
1715
|
+
assertDraft(ctx);
|
|
1716
|
+
const revisionId = await ctx.getRevisionId();
|
|
1717
|
+
return unwrap(await updateTable$1({
|
|
1718
|
+
client: ctx.client,
|
|
1719
|
+
path: {
|
|
1720
|
+
revisionId,
|
|
1721
|
+
tableId
|
|
1722
|
+
},
|
|
1723
|
+
body: { patches }
|
|
1724
|
+
}));
|
|
1725
|
+
}
|
|
1726
|
+
async function deleteTable(ctx, tableId) {
|
|
1727
|
+
assertDraft(ctx);
|
|
1728
|
+
const revisionId = await ctx.getRevisionId();
|
|
1729
|
+
unwrap(await deleteTable$1({
|
|
1730
|
+
client: ctx.client,
|
|
1731
|
+
path: {
|
|
1732
|
+
revisionId,
|
|
1733
|
+
tableId
|
|
1734
|
+
}
|
|
1735
|
+
}));
|
|
1736
|
+
}
|
|
1737
|
+
async function renameTable(ctx, tableId, nextTableId) {
|
|
1738
|
+
assertDraft(ctx);
|
|
1739
|
+
const revisionId = await ctx.getRevisionId();
|
|
1740
|
+
return unwrap(await renameTable$1({
|
|
1741
|
+
client: ctx.client,
|
|
1742
|
+
path: {
|
|
1743
|
+
revisionId,
|
|
1744
|
+
tableId
|
|
1745
|
+
},
|
|
1746
|
+
body: { nextTableId }
|
|
1747
|
+
}));
|
|
1748
|
+
}
|
|
1749
|
+
async function createRow(ctx, tableId, rowId, data) {
|
|
1750
|
+
assertDraft(ctx);
|
|
1751
|
+
const revisionId = await ctx.getRevisionId();
|
|
1752
|
+
return unwrap(await createRow$1({
|
|
1753
|
+
client: ctx.client,
|
|
1754
|
+
path: {
|
|
1755
|
+
revisionId,
|
|
1756
|
+
tableId
|
|
1757
|
+
},
|
|
1758
|
+
body: {
|
|
1759
|
+
rowId,
|
|
1760
|
+
data
|
|
1761
|
+
}
|
|
1762
|
+
}));
|
|
1763
|
+
}
|
|
1764
|
+
async function createRows(ctx, tableId, rows, options) {
|
|
1765
|
+
assertDraft(ctx);
|
|
1766
|
+
const revisionId = await ctx.getRevisionId();
|
|
1767
|
+
return unwrap(await createRows$1({
|
|
1768
|
+
client: ctx.client,
|
|
1769
|
+
path: {
|
|
1770
|
+
revisionId,
|
|
1771
|
+
tableId
|
|
1772
|
+
},
|
|
1773
|
+
body: {
|
|
1774
|
+
rows: rows.map((r) => ({
|
|
1775
|
+
rowId: r.rowId,
|
|
1776
|
+
data: r.data
|
|
1777
|
+
})),
|
|
1778
|
+
isRestore: options?.isRestore
|
|
1779
|
+
}
|
|
1780
|
+
}));
|
|
1781
|
+
}
|
|
1782
|
+
async function updateRow(ctx, tableId, rowId, data) {
|
|
1783
|
+
assertDraft(ctx);
|
|
1784
|
+
const revisionId = await ctx.getRevisionId();
|
|
1785
|
+
return unwrap(await updateRow$1({
|
|
1786
|
+
client: ctx.client,
|
|
1787
|
+
path: {
|
|
1788
|
+
revisionId,
|
|
1789
|
+
tableId,
|
|
1790
|
+
rowId
|
|
1791
|
+
},
|
|
1792
|
+
body: { data }
|
|
1793
|
+
}));
|
|
1794
|
+
}
|
|
1795
|
+
async function updateRows(ctx, tableId, rows, options) {
|
|
1796
|
+
assertDraft(ctx);
|
|
1797
|
+
const revisionId = await ctx.getRevisionId();
|
|
1798
|
+
return unwrap(await updateRows$1({
|
|
1799
|
+
client: ctx.client,
|
|
1800
|
+
path: {
|
|
1801
|
+
revisionId,
|
|
1802
|
+
tableId
|
|
1803
|
+
},
|
|
1804
|
+
body: {
|
|
1805
|
+
rows: rows.map((r) => ({
|
|
1806
|
+
rowId: r.rowId,
|
|
1807
|
+
data: r.data
|
|
1808
|
+
})),
|
|
1809
|
+
isRestore: options?.isRestore
|
|
1810
|
+
}
|
|
1811
|
+
}));
|
|
1812
|
+
}
|
|
1813
|
+
async function patchRow(ctx, tableId, rowId, patches) {
|
|
1814
|
+
assertDraft(ctx);
|
|
1815
|
+
const revisionId = await ctx.getRevisionId();
|
|
1816
|
+
return unwrap(await patchRow$1({
|
|
1817
|
+
client: ctx.client,
|
|
1818
|
+
path: {
|
|
1819
|
+
revisionId,
|
|
1820
|
+
tableId,
|
|
1821
|
+
rowId
|
|
1822
|
+
},
|
|
1823
|
+
body: { patches }
|
|
1824
|
+
}));
|
|
1825
|
+
}
|
|
1826
|
+
async function deleteRow(ctx, tableId, rowId) {
|
|
1827
|
+
assertDraft(ctx);
|
|
1828
|
+
const revisionId = await ctx.getRevisionId();
|
|
1829
|
+
unwrap(await deleteRow$1({
|
|
1830
|
+
client: ctx.client,
|
|
1831
|
+
path: {
|
|
1832
|
+
revisionId,
|
|
1833
|
+
tableId,
|
|
1834
|
+
rowId
|
|
1835
|
+
}
|
|
1836
|
+
}));
|
|
1837
|
+
}
|
|
1838
|
+
async function deleteRows(ctx, tableId, rowIds) {
|
|
1839
|
+
assertDraft(ctx);
|
|
1840
|
+
const revisionId = await ctx.getRevisionId();
|
|
1841
|
+
unwrap(await deleteRows$1({
|
|
1842
|
+
client: ctx.client,
|
|
1843
|
+
path: {
|
|
1844
|
+
revisionId,
|
|
1845
|
+
tableId
|
|
1846
|
+
},
|
|
1847
|
+
body: { rowIds }
|
|
1848
|
+
}));
|
|
1849
|
+
}
|
|
1850
|
+
async function renameRow(ctx, tableId, rowId, nextRowId) {
|
|
1851
|
+
assertDraft(ctx);
|
|
1852
|
+
const revisionId = await ctx.getRevisionId();
|
|
1853
|
+
return unwrap(await renameRow$1({
|
|
1854
|
+
client: ctx.client,
|
|
1855
|
+
path: {
|
|
1856
|
+
revisionId,
|
|
1857
|
+
tableId,
|
|
1858
|
+
rowId
|
|
1859
|
+
},
|
|
1860
|
+
body: { nextRowId }
|
|
1861
|
+
}));
|
|
1862
|
+
}
|
|
1863
|
+
async function commit(ctx, comment) {
|
|
1864
|
+
assertDraft(ctx);
|
|
1865
|
+
return unwrap(await createRevision({
|
|
1866
|
+
client: ctx.client,
|
|
1867
|
+
path: {
|
|
1868
|
+
organizationId: ctx.branch.organizationId,
|
|
1869
|
+
projectName: ctx.branch.projectName,
|
|
1870
|
+
branchName: ctx.branch.branchName
|
|
1871
|
+
},
|
|
1872
|
+
body: { comment }
|
|
1873
|
+
}));
|
|
1874
|
+
}
|
|
1875
|
+
async function revertChanges(ctx) {
|
|
1876
|
+
assertDraft(ctx);
|
|
1877
|
+
unwrap(await revertChanges$1({
|
|
1878
|
+
client: ctx.client,
|
|
1879
|
+
path: {
|
|
1880
|
+
organizationId: ctx.branch.organizationId,
|
|
1881
|
+
projectName: ctx.branch.projectName,
|
|
1882
|
+
branchName: ctx.branch.branchName
|
|
1883
|
+
}
|
|
1884
|
+
}));
|
|
1885
|
+
}
|
|
1886
|
+
async function fetchDraftRevisionId(client, branch) {
|
|
1887
|
+
return unwrap(await draftRevision({
|
|
1888
|
+
client,
|
|
1889
|
+
path: {
|
|
1890
|
+
organizationId: branch.organizationId,
|
|
1891
|
+
projectName: branch.projectName,
|
|
1892
|
+
branchName: branch.branchName
|
|
1893
|
+
}
|
|
1894
|
+
})).id;
|
|
1895
|
+
}
|
|
1896
|
+
async function fetchHeadRevisionId(client, branch) {
|
|
1897
|
+
return unwrap(await headRevision({
|
|
1898
|
+
client,
|
|
1899
|
+
path: {
|
|
1900
|
+
organizationId: branch.organizationId,
|
|
1901
|
+
projectName: branch.projectName,
|
|
1902
|
+
branchName: branch.branchName
|
|
1903
|
+
}
|
|
1904
|
+
})).id;
|
|
1905
|
+
}
|
|
1906
|
+
async function validateRevisionId(client, revisionId) {
|
|
1907
|
+
unwrap(await revision({
|
|
1908
|
+
client,
|
|
1909
|
+
path: { revisionId }
|
|
1910
|
+
}));
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
//#endregion
|
|
1914
|
+
//#region src/revisium-scope.ts
|
|
1915
|
+
var RevisiumScope = class {
|
|
1916
|
+
_client;
|
|
1917
|
+
_branch;
|
|
1918
|
+
_revisionMode;
|
|
1919
|
+
_owner;
|
|
1920
|
+
_revisionId;
|
|
1921
|
+
_isDraft;
|
|
1922
|
+
_stale = false;
|
|
1923
|
+
_disposed = false;
|
|
1924
|
+
_refreshPromise = null;
|
|
1925
|
+
constructor(init) {
|
|
1926
|
+
this._client = init.client;
|
|
1927
|
+
this._branch = init.branch;
|
|
1928
|
+
this._revisionId = init.revisionId;
|
|
1929
|
+
this._isDraft = init.isDraft;
|
|
1930
|
+
this._revisionMode = init.revisionMode;
|
|
1931
|
+
this._owner = init.owner;
|
|
1932
|
+
}
|
|
1933
|
+
get organizationId() {
|
|
1934
|
+
return this._branch.organizationId;
|
|
1935
|
+
}
|
|
1936
|
+
get projectName() {
|
|
1937
|
+
return this._branch.projectName;
|
|
1938
|
+
}
|
|
1939
|
+
get branchName() {
|
|
1940
|
+
return this._branch.branchName;
|
|
1941
|
+
}
|
|
1942
|
+
get revisionId() {
|
|
1943
|
+
return this._revisionId;
|
|
1944
|
+
}
|
|
1945
|
+
get isDraft() {
|
|
1946
|
+
return this._isDraft;
|
|
1947
|
+
}
|
|
1948
|
+
get isStale() {
|
|
1949
|
+
return this._stale;
|
|
1950
|
+
}
|
|
1951
|
+
get isDisposed() {
|
|
1952
|
+
return this._disposed;
|
|
1953
|
+
}
|
|
1954
|
+
get client() {
|
|
1955
|
+
return this._client;
|
|
1956
|
+
}
|
|
1957
|
+
markStale() {
|
|
1958
|
+
if (this._revisionMode === "explicit") return;
|
|
1959
|
+
this._stale = true;
|
|
1960
|
+
}
|
|
1961
|
+
async refresh() {
|
|
1962
|
+
this.assertNotDisposed();
|
|
1963
|
+
if (this._revisionMode === "explicit") return;
|
|
1964
|
+
this._revisionId = await this.fetchRevisionId();
|
|
1965
|
+
this._stale = false;
|
|
1966
|
+
}
|
|
1967
|
+
dispose() {
|
|
1968
|
+
if (this._disposed) return;
|
|
1969
|
+
this._disposed = true;
|
|
1970
|
+
this._owner.unregisterScope(this);
|
|
1971
|
+
}
|
|
1972
|
+
assertNotDisposed() {
|
|
1973
|
+
if (this._disposed) throw new Error("Scope has been disposed.");
|
|
1974
|
+
}
|
|
1975
|
+
get _branchKey() {
|
|
1976
|
+
return `${this._branch.organizationId}/${this._branch.projectName}/${this._branch.branchName}`;
|
|
1977
|
+
}
|
|
1978
|
+
async fetchRevisionId() {
|
|
1979
|
+
if (this._revisionMode === "draft") return fetchDraftRevisionId(this._client, this._branch);
|
|
1980
|
+
return fetchHeadRevisionId(this._client, this._branch);
|
|
1981
|
+
}
|
|
1982
|
+
async getRevisionId() {
|
|
1983
|
+
this.assertNotDisposed();
|
|
1984
|
+
if (this._stale) {
|
|
1985
|
+
this._refreshPromise ??= this.fetchRevisionId().then((id) => {
|
|
1986
|
+
this._revisionId = id;
|
|
1987
|
+
this._stale = false;
|
|
1988
|
+
this._refreshPromise = null;
|
|
1989
|
+
return id;
|
|
1990
|
+
}, (err) => {
|
|
1991
|
+
this._refreshPromise = null;
|
|
1992
|
+
throw err;
|
|
1993
|
+
});
|
|
1994
|
+
return this._refreshPromise;
|
|
1995
|
+
}
|
|
1996
|
+
return this._revisionId;
|
|
1997
|
+
}
|
|
1998
|
+
get _scopeContext() {
|
|
1999
|
+
return {
|
|
2000
|
+
client: this._client,
|
|
2001
|
+
branch: this._branch,
|
|
2002
|
+
isDraft: this._isDraft,
|
|
2003
|
+
getRevisionId: () => this.getRevisionId()
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
async getTables(options) {
|
|
2007
|
+
return getTables(this._scopeContext, options);
|
|
2008
|
+
}
|
|
2009
|
+
async getTable(tableId) {
|
|
2010
|
+
return getTable(this._scopeContext, tableId);
|
|
2011
|
+
}
|
|
2012
|
+
async getTableSchema(tableId) {
|
|
2013
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
2014
|
+
}
|
|
2015
|
+
async getRows(tableId, options) {
|
|
2016
|
+
return getRows(this._scopeContext, tableId, options);
|
|
2017
|
+
}
|
|
2018
|
+
async getRow(tableId, rowId) {
|
|
2019
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
2020
|
+
}
|
|
2021
|
+
async getChanges() {
|
|
2022
|
+
return getChanges(this._scopeContext);
|
|
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
|
+
}
|
|
2034
|
+
async createTable(tableId, schema) {
|
|
2035
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
2036
|
+
}
|
|
2037
|
+
async updateTable(tableId, patches) {
|
|
2038
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
2039
|
+
}
|
|
2040
|
+
async deleteTable(tableId) {
|
|
2041
|
+
return deleteTable(this._scopeContext, tableId);
|
|
2042
|
+
}
|
|
2043
|
+
async renameTable(tableId, nextTableId) {
|
|
2044
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
2045
|
+
}
|
|
2046
|
+
async createRow(tableId, rowId, data) {
|
|
2047
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
2048
|
+
}
|
|
2049
|
+
async createRows(tableId, rows, options) {
|
|
2050
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
2051
|
+
}
|
|
2052
|
+
async updateRow(tableId, rowId, data) {
|
|
2053
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
2054
|
+
}
|
|
2055
|
+
async updateRows(tableId, rows, options) {
|
|
2056
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
2057
|
+
}
|
|
2058
|
+
async patchRow(tableId, rowId, patches) {
|
|
2059
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
2060
|
+
}
|
|
2061
|
+
async deleteRow(tableId, rowId) {
|
|
2062
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
2063
|
+
}
|
|
2064
|
+
async deleteRows(tableId, rowIds) {
|
|
2065
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
2066
|
+
}
|
|
2067
|
+
async renameRow(tableId, rowId, nextRowId) {
|
|
2068
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
2069
|
+
}
|
|
2070
|
+
async commit(comment) {
|
|
2071
|
+
this.assertNotDisposed();
|
|
2072
|
+
const data = await commit(this._scopeContext, comment);
|
|
2073
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2074
|
+
this._stale = false;
|
|
2075
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2076
|
+
return data;
|
|
2077
|
+
}
|
|
2078
|
+
async revertChanges() {
|
|
2079
|
+
this.assertNotDisposed();
|
|
2080
|
+
await revertChanges(this._scopeContext);
|
|
2081
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2082
|
+
this._stale = false;
|
|
2083
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
|
|
1606
2087
|
//#endregion
|
|
1607
2088
|
//#region src/revisium-client.ts
|
|
1608
2089
|
var RevisiumClient = class {
|
|
@@ -1614,6 +2095,7 @@ var RevisiumClient = class {
|
|
|
1614
2095
|
_revisionId = null;
|
|
1615
2096
|
_isDraft = false;
|
|
1616
2097
|
_isAuthenticated = false;
|
|
2098
|
+
_scopes = /* @__PURE__ */ new Map();
|
|
1617
2099
|
constructor(options) {
|
|
1618
2100
|
const url = options.baseUrl;
|
|
1619
2101
|
this._baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
|
|
@@ -1651,7 +2133,7 @@ var RevisiumClient = class {
|
|
|
1651
2133
|
password
|
|
1652
2134
|
}
|
|
1653
2135
|
});
|
|
1654
|
-
const data =
|
|
2136
|
+
const data = unwrap(result);
|
|
1655
2137
|
this._client.setConfig({ auth: data.accessToken });
|
|
1656
2138
|
this._isAuthenticated = true;
|
|
1657
2139
|
}
|
|
@@ -1659,315 +2141,186 @@ var RevisiumClient = class {
|
|
|
1659
2141
|
this._client.setConfig({ auth: token });
|
|
1660
2142
|
this._isAuthenticated = true;
|
|
1661
2143
|
}
|
|
2144
|
+
async me() {
|
|
2145
|
+
return me(this._client);
|
|
2146
|
+
}
|
|
1662
2147
|
async setContext(options) {
|
|
1663
|
-
const { organizationId, projectName, branchName = "master", revision
|
|
2148
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
1664
2149
|
this._organizationId = organizationId;
|
|
1665
2150
|
this._projectName = projectName;
|
|
1666
2151
|
this._branchName = branchName;
|
|
1667
|
-
const
|
|
2152
|
+
const branch = {
|
|
1668
2153
|
organizationId,
|
|
1669
2154
|
projectName,
|
|
1670
2155
|
branchName
|
|
1671
2156
|
};
|
|
1672
|
-
if (revision
|
|
1673
|
-
|
|
1674
|
-
client: this._client,
|
|
1675
|
-
path: branchPath
|
|
1676
|
-
});
|
|
1677
|
-
this._revisionId = this.unwrap(result).id;
|
|
2157
|
+
if (revision === "draft") {
|
|
2158
|
+
this._revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
1678
2159
|
this._isDraft = true;
|
|
1679
|
-
} else if (revision
|
|
1680
|
-
|
|
1681
|
-
client: this._client,
|
|
1682
|
-
path: branchPath
|
|
1683
|
-
});
|
|
1684
|
-
this._revisionId = this.unwrap(result).id;
|
|
2160
|
+
} else if (revision === "head") {
|
|
2161
|
+
this._revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
1685
2162
|
this._isDraft = false;
|
|
1686
2163
|
} else {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
path: { revisionId: revision$1 }
|
|
1690
|
-
});
|
|
1691
|
-
this.unwrap(result);
|
|
1692
|
-
this._revisionId = revision$1;
|
|
2164
|
+
await validateRevisionId(this._client, revision);
|
|
2165
|
+
this._revisionId = revision;
|
|
1693
2166
|
this._isDraft = false;
|
|
1694
2167
|
}
|
|
1695
2168
|
}
|
|
1696
|
-
async
|
|
1697
|
-
|
|
1698
|
-
const
|
|
2169
|
+
async withContext(options) {
|
|
2170
|
+
const { organizationId, projectName, branchName = "master", revision = "draft" } = options;
|
|
2171
|
+
const branch = {
|
|
2172
|
+
organizationId,
|
|
2173
|
+
projectName,
|
|
2174
|
+
branchName
|
|
2175
|
+
};
|
|
2176
|
+
let revisionId;
|
|
2177
|
+
let isDraft;
|
|
2178
|
+
let revisionMode;
|
|
2179
|
+
if (revision === "draft") {
|
|
2180
|
+
revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
2181
|
+
isDraft = true;
|
|
2182
|
+
revisionMode = "draft";
|
|
2183
|
+
} else if (revision === "head") {
|
|
2184
|
+
revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
2185
|
+
isDraft = false;
|
|
2186
|
+
revisionMode = "head";
|
|
2187
|
+
} else {
|
|
2188
|
+
await validateRevisionId(this._client, revision);
|
|
2189
|
+
revisionId = revision;
|
|
2190
|
+
isDraft = false;
|
|
2191
|
+
revisionMode = "explicit";
|
|
2192
|
+
}
|
|
2193
|
+
const scope = new RevisiumScope({
|
|
1699
2194
|
client: this._client,
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
2195
|
+
branch,
|
|
2196
|
+
revisionId,
|
|
2197
|
+
isDraft,
|
|
2198
|
+
revisionMode,
|
|
2199
|
+
owner: this
|
|
1705
2200
|
});
|
|
1706
|
-
|
|
2201
|
+
const branchKey = `${organizationId}/${projectName}/${branchName}`;
|
|
2202
|
+
let scopeSet = this._scopes.get(branchKey);
|
|
2203
|
+
if (!scopeSet) {
|
|
2204
|
+
scopeSet = /* @__PURE__ */ new Set();
|
|
2205
|
+
this._scopes.set(branchKey, scopeSet);
|
|
2206
|
+
}
|
|
2207
|
+
scopeSet.add(scope);
|
|
2208
|
+
return scope;
|
|
2209
|
+
}
|
|
2210
|
+
notifyBranchChanged(branchKey, excludeScope) {
|
|
2211
|
+
const scopeSet = this._scopes.get(branchKey);
|
|
2212
|
+
if (!scopeSet) return;
|
|
2213
|
+
for (const scope of scopeSet) if (scope !== excludeScope) scope.markStale();
|
|
2214
|
+
}
|
|
2215
|
+
unregisterScope(scope) {
|
|
2216
|
+
for (const [key, scopeSet] of this._scopes) {
|
|
2217
|
+
scopeSet.delete(scope);
|
|
2218
|
+
if (scopeSet.size === 0) this._scopes.delete(key);
|
|
2219
|
+
}
|
|
1707
2220
|
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
const result = await table({
|
|
2221
|
+
get _scopeContext() {
|
|
2222
|
+
return {
|
|
1711
2223
|
client: this._client,
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
2224
|
+
branch: {
|
|
2225
|
+
organizationId: this._organizationId ?? "",
|
|
2226
|
+
projectName: this._projectName ?? "",
|
|
2227
|
+
branchName: this._branchName ?? ""
|
|
2228
|
+
},
|
|
2229
|
+
isDraft: this._isDraft,
|
|
2230
|
+
getRevisionId: () => {
|
|
2231
|
+
if (this._revisionId === null) return Promise.reject(/* @__PURE__ */ new Error("Context not set. Call setContext() first."));
|
|
2232
|
+
return Promise.resolve(this._revisionId);
|
|
1715
2233
|
}
|
|
1716
|
-
}
|
|
1717
|
-
|
|
2234
|
+
};
|
|
2235
|
+
}
|
|
2236
|
+
async getTables(options) {
|
|
2237
|
+
return getTables(this._scopeContext, options);
|
|
2238
|
+
}
|
|
2239
|
+
async getTable(tableId) {
|
|
2240
|
+
return getTable(this._scopeContext, tableId);
|
|
1718
2241
|
}
|
|
1719
2242
|
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);
|
|
2243
|
+
return getTableSchema(this._scopeContext, tableId);
|
|
1729
2244
|
}
|
|
1730
2245
|
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);
|
|
2246
|
+
return getRows(this._scopeContext, tableId, options);
|
|
1741
2247
|
}
|
|
1742
2248
|
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);
|
|
2249
|
+
return getRow(this._scopeContext, tableId, rowId);
|
|
1753
2250
|
}
|
|
1754
2251
|
async getChanges() {
|
|
1755
|
-
this.
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
2252
|
+
return getChanges(this._scopeContext);
|
|
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();
|
|
1761
2261
|
}
|
|
1762
2262
|
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);
|
|
2263
|
+
return createTable(this._scopeContext, tableId, schema);
|
|
1773
2264
|
}
|
|
1774
2265
|
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);
|
|
2266
|
+
return updateTable(this._scopeContext, tableId, patches);
|
|
1785
2267
|
}
|
|
1786
2268
|
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);
|
|
2269
|
+
return deleteTable(this._scopeContext, tableId);
|
|
1796
2270
|
}
|
|
1797
2271
|
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);
|
|
2272
|
+
return renameTable(this._scopeContext, tableId, nextTableId);
|
|
1808
2273
|
}
|
|
1809
2274
|
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);
|
|
2275
|
+
return createRow(this._scopeContext, tableId, rowId, data);
|
|
1823
2276
|
}
|
|
1824
|
-
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);
|
|
2277
|
+
async createRows(tableId, rows, options) {
|
|
2278
|
+
return createRows(this._scopeContext, tableId, rows, options);
|
|
1838
2279
|
}
|
|
1839
2280
|
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);
|
|
2281
|
+
return updateRow(this._scopeContext, tableId, rowId, data);
|
|
1851
2282
|
}
|
|
1852
|
-
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);
|
|
2283
|
+
async updateRows(tableId, rows, options) {
|
|
2284
|
+
return updateRows(this._scopeContext, tableId, rows, options);
|
|
1866
2285
|
}
|
|
1867
2286
|
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);
|
|
2287
|
+
return patchRow(this._scopeContext, tableId, rowId, patches);
|
|
1879
2288
|
}
|
|
1880
2289
|
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);
|
|
2290
|
+
return deleteRow(this._scopeContext, tableId, rowId);
|
|
1891
2291
|
}
|
|
1892
2292
|
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);
|
|
2293
|
+
return deleteRows(this._scopeContext, tableId, rowIds);
|
|
1903
2294
|
}
|
|
1904
2295
|
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);
|
|
2296
|
+
return renameRow(this._scopeContext, tableId, rowId, nextRowId);
|
|
1916
2297
|
}
|
|
1917
2298
|
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);
|
|
2299
|
+
const data = await commit(this._scopeContext, comment);
|
|
1929
2300
|
await this.refreshDraftRevisionId();
|
|
2301
|
+
this.notifyScopesOnCurrentBranch();
|
|
1930
2302
|
return data;
|
|
1931
2303
|
}
|
|
1932
2304
|
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
|
-
});
|
|
2305
|
+
await revertChanges(this._scopeContext);
|
|
1942
2306
|
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.");
|
|
2307
|
+
this.notifyScopesOnCurrentBranch();
|
|
1950
2308
|
}
|
|
1951
2309
|
async refreshDraftRevisionId() {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
projectName: this._projectName,
|
|
1957
|
-
branchName: this._branchName
|
|
1958
|
-
}
|
|
2310
|
+
this._revisionId = await fetchDraftRevisionId(this._client, {
|
|
2311
|
+
organizationId: this._organizationId,
|
|
2312
|
+
projectName: this._projectName,
|
|
2313
|
+
branchName: this._branchName
|
|
1959
2314
|
});
|
|
1960
|
-
this._revisionId = this.unwrap(result).id;
|
|
1961
2315
|
}
|
|
1962
|
-
|
|
1963
|
-
if (
|
|
1964
|
-
const
|
|
1965
|
-
|
|
2316
|
+
notifyScopesOnCurrentBranch() {
|
|
2317
|
+
if (this._organizationId && this._projectName && this._branchName) {
|
|
2318
|
+
const branchKey = `${this._organizationId}/${this._projectName}/${this._branchName}`;
|
|
2319
|
+
this.notifyBranchChanged(branchKey);
|
|
1966
2320
|
}
|
|
1967
|
-
return result.data;
|
|
1968
2321
|
}
|
|
1969
2322
|
};
|
|
1970
2323
|
|
|
1971
2324
|
//#endregion
|
|
1972
|
-
export { RevisiumClient, client, sdk_gen_exports as sdk };
|
|
2325
|
+
export { RevisiumClient, RevisiumScope, client, sdk_gen_exports as sdk };
|
|
1973
2326
|
//# sourceMappingURL=index.mjs.map
|