@revisium/client 0.3.0 → 0.4.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 +188 -134
- package/dist/branch-scope.d.ts +37 -0
- package/dist/branch-scope.d.ts.map +1 -0
- package/dist/data-operations.d.ts +99 -8
- package/dist/data-operations.d.ts.map +1 -1
- package/dist/index.cjs +759 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +756 -270
- package/dist/index.mjs.map +1 -1
- package/dist/org-scope.d.ts +24 -0
- package/dist/org-scope.d.ts.map +1 -0
- package/dist/project-scope.d.ts +34 -0
- package/dist/project-scope.d.ts.map +1 -0
- package/dist/revision-scope.d.ts +122 -0
- package/dist/revision-scope.d.ts.map +1 -0
- package/dist/revisium-client.d.ts +14 -65
- package/dist/revisium-client.d.ts.map +1 -1
- package/dist/scope-owner.d.ts +7 -0
- package/dist/scope-owner.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/revisium-scope.d.ts +0 -82
- package/dist/revisium-scope.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -662,17 +662,17 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
662
662
|
branches: () => branches,
|
|
663
663
|
childBranches: () => childBranches,
|
|
664
664
|
childRevision: () => childRevision,
|
|
665
|
-
createBranch: () => createBranch,
|
|
666
|
-
createEndpoint: () => createEndpoint,
|
|
667
|
-
createProject: () => createProject,
|
|
665
|
+
createBranch: () => createBranch$1,
|
|
666
|
+
createEndpoint: () => createEndpoint$1,
|
|
667
|
+
createProject: () => createProject$1,
|
|
668
668
|
createRevision: () => createRevision,
|
|
669
669
|
createRow: () => createRow$1,
|
|
670
670
|
createRows: () => createRows$1,
|
|
671
671
|
createTable: () => createTable$1,
|
|
672
672
|
createUser: () => createUser,
|
|
673
|
-
deleteBranch: () => deleteBranch,
|
|
674
|
-
deleteEndpoint: () => deleteEndpoint,
|
|
675
|
-
deleteProject: () => deleteProject,
|
|
673
|
+
deleteBranch: () => deleteBranch$1,
|
|
674
|
+
deleteEndpoint: () => deleteEndpoint$1,
|
|
675
|
+
deleteProject: () => deleteProject$1,
|
|
676
676
|
deleteRow: () => deleteRow$1,
|
|
677
677
|
deleteRows: () => deleteRows$1,
|
|
678
678
|
deleteTable: () => deleteTable$1,
|
|
@@ -688,7 +688,7 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
688
688
|
parentBranch: () => parentBranch,
|
|
689
689
|
parentRevision: () => parentRevision,
|
|
690
690
|
patchRow: () => patchRow$1,
|
|
691
|
-
patchRows: () => patchRows,
|
|
691
|
+
patchRows: () => patchRows$1,
|
|
692
692
|
project: () => project,
|
|
693
693
|
projects: () => projects,
|
|
694
694
|
readiness: () => readiness,
|
|
@@ -719,11 +719,11 @@ var sdk_gen_exports = /* @__PURE__ */ __exportAll({
|
|
|
719
719
|
tableSchema: () => tableSchema,
|
|
720
720
|
tables: () => tables,
|
|
721
721
|
updatePassword: () => updatePassword,
|
|
722
|
-
updateProject: () => updateProject,
|
|
722
|
+
updateProject: () => updateProject$1,
|
|
723
723
|
updateRow: () => updateRow$1,
|
|
724
724
|
updateRows: () => updateRows$1,
|
|
725
725
|
updateTable: () => updateTable$1,
|
|
726
|
-
uploadFile: () => uploadFile,
|
|
726
|
+
uploadFile: () => uploadFile$1,
|
|
727
727
|
usersOrganization: () => usersOrganization,
|
|
728
728
|
usersProject: () => usersProject
|
|
729
729
|
});
|
|
@@ -797,7 +797,7 @@ const projects = (options) => (options.client ?? client).get({
|
|
|
797
797
|
/**
|
|
798
798
|
* Create a new project
|
|
799
799
|
*/
|
|
800
|
-
const createProject = (options) => (options.client ?? client).post({
|
|
800
|
+
const createProject$1 = (options) => (options.client ?? client).post({
|
|
801
801
|
security: [{
|
|
802
802
|
scheme: "bearer",
|
|
803
803
|
type: "http"
|
|
@@ -853,7 +853,7 @@ const addUserToOrganization = (options) => (options.client ?? client).post({
|
|
|
853
853
|
/**
|
|
854
854
|
* Delete a project
|
|
855
855
|
*/
|
|
856
|
-
const deleteProject = (options) => (options.client ?? client).delete({
|
|
856
|
+
const deleteProject$1 = (options) => (options.client ?? client).delete({
|
|
857
857
|
security: [{
|
|
858
858
|
scheme: "bearer",
|
|
859
859
|
type: "http"
|
|
@@ -875,7 +875,7 @@ const project = (options) => (options.client ?? client).get({
|
|
|
875
875
|
/**
|
|
876
876
|
* Update project settings
|
|
877
877
|
*/
|
|
878
|
-
const updateProject = (options) => (options.client ?? client).put({
|
|
878
|
+
const updateProject$1 = (options) => (options.client ?? client).put({
|
|
879
879
|
security: [{
|
|
880
880
|
scheme: "bearer",
|
|
881
881
|
type: "http"
|
|
@@ -949,7 +949,7 @@ const removeUserFromProject = (options) => (options.client ?? client).delete({
|
|
|
949
949
|
/**
|
|
950
950
|
* Delete a non-root branch
|
|
951
951
|
*/
|
|
952
|
-
const deleteBranch = (options) => (options.client ?? client).delete({
|
|
952
|
+
const deleteBranch$1 = (options) => (options.client ?? client).delete({
|
|
953
953
|
security: [{
|
|
954
954
|
scheme: "bearer",
|
|
955
955
|
type: "http"
|
|
@@ -1107,7 +1107,7 @@ const childBranches = (options) => (options.client ?? client).get({
|
|
|
1107
1107
|
/**
|
|
1108
1108
|
* Create a new branch from this revision
|
|
1109
1109
|
*/
|
|
1110
|
-
const createBranch = (options) => (options.client ?? client).post({
|
|
1110
|
+
const createBranch$1 = (options) => (options.client ?? client).post({
|
|
1111
1111
|
security: [{
|
|
1112
1112
|
scheme: "bearer",
|
|
1113
1113
|
type: "http"
|
|
@@ -1159,7 +1159,7 @@ const endpoints = (options) => (options.client ?? client).get({
|
|
|
1159
1159
|
/**
|
|
1160
1160
|
* Create an API endpoint for this revision
|
|
1161
1161
|
*/
|
|
1162
|
-
const createEndpoint = (options) => (options.client ?? client).post({
|
|
1162
|
+
const createEndpoint$1 = (options) => (options.client ?? client).post({
|
|
1163
1163
|
security: [{
|
|
1164
1164
|
scheme: "bearer",
|
|
1165
1165
|
type: "http"
|
|
@@ -1356,7 +1356,7 @@ const updateRows$1 = (options) => (options.client ?? client).put({
|
|
|
1356
1356
|
/**
|
|
1357
1357
|
* Patch multiple rows using JSON Patch
|
|
1358
1358
|
*/
|
|
1359
|
-
const patchRows = (options) => (options.client ?? client).patch({
|
|
1359
|
+
const patchRows$1 = (options) => (options.client ?? client).patch({
|
|
1360
1360
|
security: [{
|
|
1361
1361
|
scheme: "bearer",
|
|
1362
1362
|
type: "http"
|
|
@@ -1552,7 +1552,7 @@ const renameRow$1 = (options) => (options.client ?? client).patch({
|
|
|
1552
1552
|
/**
|
|
1553
1553
|
* Upload a file to a row field
|
|
1554
1554
|
*/
|
|
1555
|
-
const uploadFile = (options) => (options.client ?? client).post({
|
|
1555
|
+
const uploadFile$1 = (options) => (options.client ?? client).post({
|
|
1556
1556
|
...formDataBodySerializer,
|
|
1557
1557
|
security: [{
|
|
1558
1558
|
scheme: "bearer",
|
|
@@ -1579,7 +1579,7 @@ const endpointRelatives = (options) => (options.client ?? client).get({
|
|
|
1579
1579
|
/**
|
|
1580
1580
|
* Delete an endpoint
|
|
1581
1581
|
*/
|
|
1582
|
-
const deleteEndpoint = (options) => (options.client ?? client).delete({
|
|
1582
|
+
const deleteEndpoint$1 = (options) => (options.client ?? client).delete({
|
|
1583
1583
|
security: [{
|
|
1584
1584
|
scheme: "bearer",
|
|
1585
1585
|
type: "http"
|
|
@@ -1614,7 +1614,7 @@ function unwrap(result) {
|
|
|
1614
1614
|
}
|
|
1615
1615
|
function assertDraft(ctx) {
|
|
1616
1616
|
assertContext(ctx);
|
|
1617
|
-
if (!ctx.isDraft) throw new Error("Mutations are only allowed in draft revision.
|
|
1617
|
+
if (!ctx.isDraft) throw new Error("Mutations are only allowed in draft revision.");
|
|
1618
1618
|
}
|
|
1619
1619
|
function assertContext(ctx) {
|
|
1620
1620
|
if (!ctx.branch.organizationId) throw new Error("Context not set. Call setContext() first.");
|
|
@@ -1622,6 +1622,223 @@ function assertContext(ctx) {
|
|
|
1622
1622
|
async function me(client) {
|
|
1623
1623
|
return unwrap(await me$1({ client }));
|
|
1624
1624
|
}
|
|
1625
|
+
async function getProjects(ctx, options) {
|
|
1626
|
+
return unwrap(await projects({
|
|
1627
|
+
client: ctx.client,
|
|
1628
|
+
path: { organizationId: ctx.organizationId },
|
|
1629
|
+
query: {
|
|
1630
|
+
first: options?.first ?? 100,
|
|
1631
|
+
after: options?.after
|
|
1632
|
+
}
|
|
1633
|
+
}));
|
|
1634
|
+
}
|
|
1635
|
+
async function createProject(ctx, body) {
|
|
1636
|
+
return unwrap(await createProject$1({
|
|
1637
|
+
client: ctx.client,
|
|
1638
|
+
path: { organizationId: ctx.organizationId },
|
|
1639
|
+
body
|
|
1640
|
+
}));
|
|
1641
|
+
}
|
|
1642
|
+
async function getOrgUsers(ctx, options) {
|
|
1643
|
+
return unwrap(await usersOrganization({
|
|
1644
|
+
client: ctx.client,
|
|
1645
|
+
path: { organizationId: ctx.organizationId },
|
|
1646
|
+
query: {
|
|
1647
|
+
first: options?.first ?? 100,
|
|
1648
|
+
after: options?.after
|
|
1649
|
+
}
|
|
1650
|
+
}));
|
|
1651
|
+
}
|
|
1652
|
+
async function addOrgUser(ctx, userId, roleId) {
|
|
1653
|
+
unwrap(await addUserToOrganization({
|
|
1654
|
+
client: ctx.client,
|
|
1655
|
+
path: { organizationId: ctx.organizationId },
|
|
1656
|
+
body: {
|
|
1657
|
+
userId,
|
|
1658
|
+
roleId
|
|
1659
|
+
}
|
|
1660
|
+
}));
|
|
1661
|
+
}
|
|
1662
|
+
async function removeOrgUser(ctx, userId) {
|
|
1663
|
+
unwrap(await removeUserFromOrganization({
|
|
1664
|
+
client: ctx.client,
|
|
1665
|
+
path: { organizationId: ctx.organizationId },
|
|
1666
|
+
body: { userId }
|
|
1667
|
+
}));
|
|
1668
|
+
}
|
|
1669
|
+
async function getProject(ctx) {
|
|
1670
|
+
return unwrap(await project({
|
|
1671
|
+
client: ctx.client,
|
|
1672
|
+
path: {
|
|
1673
|
+
organizationId: ctx.organizationId,
|
|
1674
|
+
projectName: ctx.projectName
|
|
1675
|
+
}
|
|
1676
|
+
}));
|
|
1677
|
+
}
|
|
1678
|
+
async function updateProject(ctx, body) {
|
|
1679
|
+
unwrap(await updateProject$1({
|
|
1680
|
+
client: ctx.client,
|
|
1681
|
+
path: {
|
|
1682
|
+
organizationId: ctx.organizationId,
|
|
1683
|
+
projectName: ctx.projectName
|
|
1684
|
+
},
|
|
1685
|
+
body
|
|
1686
|
+
}));
|
|
1687
|
+
}
|
|
1688
|
+
async function deleteProject(ctx) {
|
|
1689
|
+
unwrap(await deleteProject$1({
|
|
1690
|
+
client: ctx.client,
|
|
1691
|
+
path: {
|
|
1692
|
+
organizationId: ctx.organizationId,
|
|
1693
|
+
projectName: ctx.projectName
|
|
1694
|
+
}
|
|
1695
|
+
}));
|
|
1696
|
+
}
|
|
1697
|
+
async function getBranches(ctx, options) {
|
|
1698
|
+
return unwrap(await branches({
|
|
1699
|
+
client: ctx.client,
|
|
1700
|
+
path: {
|
|
1701
|
+
organizationId: ctx.organizationId,
|
|
1702
|
+
projectName: ctx.projectName
|
|
1703
|
+
},
|
|
1704
|
+
query: {
|
|
1705
|
+
first: options?.first ?? 100,
|
|
1706
|
+
after: options?.after
|
|
1707
|
+
}
|
|
1708
|
+
}));
|
|
1709
|
+
}
|
|
1710
|
+
async function getRootBranch(ctx) {
|
|
1711
|
+
return unwrap(await rootBranch({
|
|
1712
|
+
client: ctx.client,
|
|
1713
|
+
path: {
|
|
1714
|
+
organizationId: ctx.organizationId,
|
|
1715
|
+
projectName: ctx.projectName
|
|
1716
|
+
}
|
|
1717
|
+
}));
|
|
1718
|
+
}
|
|
1719
|
+
async function getProjectUsers(ctx, options) {
|
|
1720
|
+
return unwrap(await usersProject({
|
|
1721
|
+
client: ctx.client,
|
|
1722
|
+
path: {
|
|
1723
|
+
organizationId: ctx.organizationId,
|
|
1724
|
+
projectName: ctx.projectName
|
|
1725
|
+
},
|
|
1726
|
+
query: {
|
|
1727
|
+
first: options?.first ?? 100,
|
|
1728
|
+
after: options?.after
|
|
1729
|
+
}
|
|
1730
|
+
}));
|
|
1731
|
+
}
|
|
1732
|
+
async function addProjectUser(ctx, userId, roleId) {
|
|
1733
|
+
unwrap(await addUserToProject({
|
|
1734
|
+
client: ctx.client,
|
|
1735
|
+
path: {
|
|
1736
|
+
organizationId: ctx.organizationId,
|
|
1737
|
+
projectName: ctx.projectName
|
|
1738
|
+
},
|
|
1739
|
+
body: {
|
|
1740
|
+
userId,
|
|
1741
|
+
roleId
|
|
1742
|
+
}
|
|
1743
|
+
}));
|
|
1744
|
+
}
|
|
1745
|
+
async function removeProjectUser(ctx, userId) {
|
|
1746
|
+
unwrap(await removeUserFromProject({
|
|
1747
|
+
client: ctx.client,
|
|
1748
|
+
path: {
|
|
1749
|
+
organizationId: ctx.organizationId,
|
|
1750
|
+
projectName: ctx.projectName,
|
|
1751
|
+
userId
|
|
1752
|
+
}
|
|
1753
|
+
}));
|
|
1754
|
+
}
|
|
1755
|
+
async function getBranch(client, branch$1) {
|
|
1756
|
+
return unwrap(await branch({
|
|
1757
|
+
client,
|
|
1758
|
+
path: {
|
|
1759
|
+
organizationId: branch$1.organizationId,
|
|
1760
|
+
projectName: branch$1.projectName,
|
|
1761
|
+
branchName: branch$1.branchName
|
|
1762
|
+
}
|
|
1763
|
+
}));
|
|
1764
|
+
}
|
|
1765
|
+
async function createBranch(client, revisionId, branchName) {
|
|
1766
|
+
return unwrap(await createBranch$1({
|
|
1767
|
+
client,
|
|
1768
|
+
path: { revisionId },
|
|
1769
|
+
body: { branchName }
|
|
1770
|
+
}));
|
|
1771
|
+
}
|
|
1772
|
+
async function deleteBranch(client, branch) {
|
|
1773
|
+
unwrap(await deleteBranch$1({
|
|
1774
|
+
client,
|
|
1775
|
+
path: {
|
|
1776
|
+
organizationId: branch.organizationId,
|
|
1777
|
+
projectName: branch.projectName,
|
|
1778
|
+
branchName: branch.branchName
|
|
1779
|
+
}
|
|
1780
|
+
}));
|
|
1781
|
+
}
|
|
1782
|
+
async function getBranchTouched(client, branch) {
|
|
1783
|
+
return unwrap(await branchTouched({
|
|
1784
|
+
client,
|
|
1785
|
+
path: {
|
|
1786
|
+
organizationId: branch.organizationId,
|
|
1787
|
+
projectName: branch.projectName,
|
|
1788
|
+
branchName: branch.branchName
|
|
1789
|
+
}
|
|
1790
|
+
}));
|
|
1791
|
+
}
|
|
1792
|
+
async function getRevisions(client, branch, options) {
|
|
1793
|
+
return unwrap(await revisions({
|
|
1794
|
+
client,
|
|
1795
|
+
path: {
|
|
1796
|
+
organizationId: branch.organizationId,
|
|
1797
|
+
projectName: branch.projectName,
|
|
1798
|
+
branchName: branch.branchName
|
|
1799
|
+
},
|
|
1800
|
+
query: {
|
|
1801
|
+
...options,
|
|
1802
|
+
first: options?.first ?? 100
|
|
1803
|
+
}
|
|
1804
|
+
}));
|
|
1805
|
+
}
|
|
1806
|
+
async function getStartRevision(client, branch) {
|
|
1807
|
+
return unwrap(await startRevision({
|
|
1808
|
+
client,
|
|
1809
|
+
path: {
|
|
1810
|
+
organizationId: branch.organizationId,
|
|
1811
|
+
projectName: branch.projectName,
|
|
1812
|
+
branchName: branch.branchName
|
|
1813
|
+
}
|
|
1814
|
+
}));
|
|
1815
|
+
}
|
|
1816
|
+
async function fetchDraftRevisionId(client, branch) {
|
|
1817
|
+
return unwrap(await draftRevision({
|
|
1818
|
+
client,
|
|
1819
|
+
path: {
|
|
1820
|
+
organizationId: branch.organizationId,
|
|
1821
|
+
projectName: branch.projectName,
|
|
1822
|
+
branchName: branch.branchName
|
|
1823
|
+
}
|
|
1824
|
+
})).id;
|
|
1825
|
+
}
|
|
1826
|
+
async function fetchHeadRevisionId(client, branch) {
|
|
1827
|
+
return unwrap(await headRevision({
|
|
1828
|
+
client,
|
|
1829
|
+
path: {
|
|
1830
|
+
organizationId: branch.organizationId,
|
|
1831
|
+
projectName: branch.projectName,
|
|
1832
|
+
branchName: branch.branchName
|
|
1833
|
+
}
|
|
1834
|
+
})).id;
|
|
1835
|
+
}
|
|
1836
|
+
async function validateRevisionId(client, revisionId) {
|
|
1837
|
+
unwrap(await revision({
|
|
1838
|
+
client,
|
|
1839
|
+
path: { revisionId }
|
|
1840
|
+
}));
|
|
1841
|
+
}
|
|
1625
1842
|
async function getMigrations(ctx) {
|
|
1626
1843
|
assertContext(ctx);
|
|
1627
1844
|
const revisionId = await ctx.getRevisionId();
|
|
@@ -1639,6 +1856,15 @@ async function applyMigrations(ctx, migrations) {
|
|
|
1639
1856
|
body: migrations
|
|
1640
1857
|
}));
|
|
1641
1858
|
}
|
|
1859
|
+
async function applyMigrationsWithStatus(ctx, migrations) {
|
|
1860
|
+
assertDraft(ctx);
|
|
1861
|
+
const revisionId = await ctx.getRevisionId();
|
|
1862
|
+
return unwrap(await applyMigrations$1({
|
|
1863
|
+
client: ctx.client,
|
|
1864
|
+
path: { revisionId },
|
|
1865
|
+
body: migrations
|
|
1866
|
+
}));
|
|
1867
|
+
}
|
|
1642
1868
|
async function getTables(ctx, options) {
|
|
1643
1869
|
const revisionId = await ctx.getRevisionId();
|
|
1644
1870
|
return unwrap(await tables({
|
|
@@ -1670,33 +1896,62 @@ async function getTableSchema(ctx, tableId) {
|
|
|
1670
1896
|
}
|
|
1671
1897
|
}));
|
|
1672
1898
|
}
|
|
1673
|
-
async function
|
|
1899
|
+
async function getTableCountRows(ctx, tableId) {
|
|
1674
1900
|
const revisionId = await ctx.getRevisionId();
|
|
1675
|
-
return unwrap(await
|
|
1901
|
+
return unwrap(await tableCountRows({
|
|
1902
|
+
client: ctx.client,
|
|
1903
|
+
path: {
|
|
1904
|
+
revisionId,
|
|
1905
|
+
tableId
|
|
1906
|
+
}
|
|
1907
|
+
}));
|
|
1908
|
+
}
|
|
1909
|
+
async function getTableForeignKeysBy(ctx, tableId, options) {
|
|
1910
|
+
const revisionId = await ctx.getRevisionId();
|
|
1911
|
+
return unwrap(await tableForeignKeysBy({
|
|
1676
1912
|
client: ctx.client,
|
|
1677
1913
|
path: {
|
|
1678
1914
|
revisionId,
|
|
1679
1915
|
tableId
|
|
1680
1916
|
},
|
|
1681
|
-
|
|
1917
|
+
query: {
|
|
1918
|
+
first: options?.first ?? 100,
|
|
1919
|
+
after: options?.after
|
|
1920
|
+
}
|
|
1682
1921
|
}));
|
|
1683
1922
|
}
|
|
1684
|
-
async function
|
|
1923
|
+
async function getTableForeignKeysTo(ctx, tableId, options) {
|
|
1685
1924
|
const revisionId = await ctx.getRevisionId();
|
|
1686
|
-
return unwrap(await
|
|
1925
|
+
return unwrap(await tableForeignKeysTo({
|
|
1687
1926
|
client: ctx.client,
|
|
1688
1927
|
path: {
|
|
1689
1928
|
revisionId,
|
|
1690
|
-
tableId
|
|
1691
|
-
|
|
1929
|
+
tableId
|
|
1930
|
+
},
|
|
1931
|
+
query: {
|
|
1932
|
+
first: options?.first ?? 100,
|
|
1933
|
+
after: options?.after
|
|
1692
1934
|
}
|
|
1693
1935
|
}));
|
|
1694
1936
|
}
|
|
1695
|
-
async function
|
|
1937
|
+
async function getTableCountForeignKeysBy(ctx, tableId) {
|
|
1696
1938
|
const revisionId = await ctx.getRevisionId();
|
|
1697
|
-
return unwrap(await
|
|
1939
|
+
return unwrap(await tableCountForeignKeysBy({
|
|
1698
1940
|
client: ctx.client,
|
|
1699
|
-
path: {
|
|
1941
|
+
path: {
|
|
1942
|
+
revisionId,
|
|
1943
|
+
tableId
|
|
1944
|
+
}
|
|
1945
|
+
}));
|
|
1946
|
+
}
|
|
1947
|
+
async function getTableCountForeignKeysTo(ctx, tableId) {
|
|
1948
|
+
const revisionId = await ctx.getRevisionId();
|
|
1949
|
+
return unwrap(await tableCountForeignKeysTo({
|
|
1950
|
+
client: ctx.client,
|
|
1951
|
+
path: {
|
|
1952
|
+
revisionId,
|
|
1953
|
+
tableId
|
|
1954
|
+
}
|
|
1700
1955
|
}));
|
|
1701
1956
|
}
|
|
1702
1957
|
async function createTable(ctx, tableId, schema) {
|
|
@@ -1746,6 +2001,82 @@ async function renameTable(ctx, tableId, nextTableId) {
|
|
|
1746
2001
|
body: { nextTableId }
|
|
1747
2002
|
}));
|
|
1748
2003
|
}
|
|
2004
|
+
async function getRows(ctx, tableId, options) {
|
|
2005
|
+
const revisionId = await ctx.getRevisionId();
|
|
2006
|
+
return unwrap(await rows({
|
|
2007
|
+
client: ctx.client,
|
|
2008
|
+
path: {
|
|
2009
|
+
revisionId,
|
|
2010
|
+
tableId
|
|
2011
|
+
},
|
|
2012
|
+
body: options ?? { first: 100 }
|
|
2013
|
+
}));
|
|
2014
|
+
}
|
|
2015
|
+
async function getRow(ctx, tableId, rowId) {
|
|
2016
|
+
const revisionId = await ctx.getRevisionId();
|
|
2017
|
+
return unwrap(await row({
|
|
2018
|
+
client: ctx.client,
|
|
2019
|
+
path: {
|
|
2020
|
+
revisionId,
|
|
2021
|
+
tableId,
|
|
2022
|
+
rowId
|
|
2023
|
+
}
|
|
2024
|
+
}));
|
|
2025
|
+
}
|
|
2026
|
+
async function getRowForeignKeysBy(ctx, tableId, rowId, foreignKeyByTableId, options) {
|
|
2027
|
+
const revisionId = await ctx.getRevisionId();
|
|
2028
|
+
return unwrap(await rowForeignKeysBy({
|
|
2029
|
+
client: ctx.client,
|
|
2030
|
+
path: {
|
|
2031
|
+
revisionId,
|
|
2032
|
+
tableId,
|
|
2033
|
+
rowId
|
|
2034
|
+
},
|
|
2035
|
+
query: {
|
|
2036
|
+
foreignKeyByTableId,
|
|
2037
|
+
first: options?.first ?? 100,
|
|
2038
|
+
after: options?.after
|
|
2039
|
+
}
|
|
2040
|
+
}));
|
|
2041
|
+
}
|
|
2042
|
+
async function getRowForeignKeysTo(ctx, tableId, rowId, foreignKeyToTableId, options) {
|
|
2043
|
+
const revisionId = await ctx.getRevisionId();
|
|
2044
|
+
return unwrap(await rowForeignKeysTo({
|
|
2045
|
+
client: ctx.client,
|
|
2046
|
+
path: {
|
|
2047
|
+
revisionId,
|
|
2048
|
+
tableId,
|
|
2049
|
+
rowId
|
|
2050
|
+
},
|
|
2051
|
+
query: {
|
|
2052
|
+
foreignKeyToTableId,
|
|
2053
|
+
first: options?.first ?? 100,
|
|
2054
|
+
after: options?.after
|
|
2055
|
+
}
|
|
2056
|
+
}));
|
|
2057
|
+
}
|
|
2058
|
+
async function getRowCountForeignKeysBy(ctx, tableId, rowId) {
|
|
2059
|
+
const revisionId = await ctx.getRevisionId();
|
|
2060
|
+
return unwrap(await rowCountForeignKeysBy({
|
|
2061
|
+
client: ctx.client,
|
|
2062
|
+
path: {
|
|
2063
|
+
revisionId,
|
|
2064
|
+
tableId,
|
|
2065
|
+
rowId
|
|
2066
|
+
}
|
|
2067
|
+
}));
|
|
2068
|
+
}
|
|
2069
|
+
async function getRowCountForeignKeysTo(ctx, tableId, rowId) {
|
|
2070
|
+
const revisionId = await ctx.getRevisionId();
|
|
2071
|
+
return unwrap(await rowCountForeignKeysTo({
|
|
2072
|
+
client: ctx.client,
|
|
2073
|
+
path: {
|
|
2074
|
+
revisionId,
|
|
2075
|
+
tableId,
|
|
2076
|
+
rowId
|
|
2077
|
+
}
|
|
2078
|
+
}));
|
|
2079
|
+
}
|
|
1749
2080
|
async function createRow(ctx, tableId, rowId, data) {
|
|
1750
2081
|
assertDraft(ctx);
|
|
1751
2082
|
const revisionId = await ctx.getRevisionId();
|
|
@@ -1823,6 +2154,18 @@ async function patchRow(ctx, tableId, rowId, patches) {
|
|
|
1823
2154
|
body: { patches }
|
|
1824
2155
|
}));
|
|
1825
2156
|
}
|
|
2157
|
+
async function patchRows(ctx, tableId, body) {
|
|
2158
|
+
assertDraft(ctx);
|
|
2159
|
+
const revisionId = await ctx.getRevisionId();
|
|
2160
|
+
return unwrap(await patchRows$1({
|
|
2161
|
+
client: ctx.client,
|
|
2162
|
+
path: {
|
|
2163
|
+
revisionId,
|
|
2164
|
+
tableId
|
|
2165
|
+
},
|
|
2166
|
+
body
|
|
2167
|
+
}));
|
|
2168
|
+
}
|
|
1826
2169
|
async function deleteRow(ctx, tableId, rowId) {
|
|
1827
2170
|
assertDraft(ctx);
|
|
1828
2171
|
const revisionId = await ctx.getRevisionId();
|
|
@@ -1850,14 +2193,43 @@ async function deleteRows(ctx, tableId, rowIds) {
|
|
|
1850
2193
|
async function renameRow(ctx, tableId, rowId, nextRowId) {
|
|
1851
2194
|
assertDraft(ctx);
|
|
1852
2195
|
const revisionId = await ctx.getRevisionId();
|
|
1853
|
-
return unwrap(await renameRow$1({
|
|
2196
|
+
return unwrap(await renameRow$1({
|
|
2197
|
+
client: ctx.client,
|
|
2198
|
+
path: {
|
|
2199
|
+
revisionId,
|
|
2200
|
+
tableId,
|
|
2201
|
+
rowId
|
|
2202
|
+
},
|
|
2203
|
+
body: { nextRowId }
|
|
2204
|
+
}));
|
|
2205
|
+
}
|
|
2206
|
+
async function getChanges(ctx) {
|
|
2207
|
+
const revisionId = await ctx.getRevisionId();
|
|
2208
|
+
return unwrap(await revisionChanges({
|
|
2209
|
+
client: ctx.client,
|
|
2210
|
+
path: { revisionId }
|
|
2211
|
+
}));
|
|
2212
|
+
}
|
|
2213
|
+
async function getTableChanges(ctx, options) {
|
|
2214
|
+
const revisionId = await ctx.getRevisionId();
|
|
2215
|
+
return unwrap(await tableChanges({
|
|
2216
|
+
client: ctx.client,
|
|
2217
|
+
path: { revisionId },
|
|
2218
|
+
query: {
|
|
2219
|
+
...options,
|
|
2220
|
+
first: options?.first ?? 100
|
|
2221
|
+
}
|
|
2222
|
+
}));
|
|
2223
|
+
}
|
|
2224
|
+
async function getRowChanges(ctx, options) {
|
|
2225
|
+
const revisionId = await ctx.getRevisionId();
|
|
2226
|
+
return unwrap(await rowChanges({
|
|
1854
2227
|
client: ctx.client,
|
|
1855
|
-
path: {
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
}
|
|
1860
|
-
body: { nextRowId }
|
|
2228
|
+
path: { revisionId },
|
|
2229
|
+
query: {
|
|
2230
|
+
...options,
|
|
2231
|
+
first: options?.first ?? 100
|
|
2232
|
+
}
|
|
1861
2233
|
}));
|
|
1862
2234
|
}
|
|
1863
2235
|
async function commit(ctx, comment) {
|
|
@@ -1883,36 +2255,51 @@ async function revertChanges(ctx) {
|
|
|
1883
2255
|
}
|
|
1884
2256
|
}));
|
|
1885
2257
|
}
|
|
1886
|
-
async function
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
branchName: branch.branchName
|
|
1893
|
-
}
|
|
1894
|
-
})).id;
|
|
2258
|
+
async function getEndpoints(ctx) {
|
|
2259
|
+
const revisionId = await ctx.getRevisionId();
|
|
2260
|
+
return unwrap(await endpoints({
|
|
2261
|
+
client: ctx.client,
|
|
2262
|
+
path: { revisionId }
|
|
2263
|
+
}));
|
|
1895
2264
|
}
|
|
1896
|
-
async function
|
|
1897
|
-
|
|
2265
|
+
async function createEndpoint(ctx, body) {
|
|
2266
|
+
const revisionId = await ctx.getRevisionId();
|
|
2267
|
+
return unwrap(await createEndpoint$1({
|
|
2268
|
+
client: ctx.client,
|
|
2269
|
+
path: { revisionId },
|
|
2270
|
+
body
|
|
2271
|
+
}));
|
|
2272
|
+
}
|
|
2273
|
+
async function deleteEndpoint(client, endpointId) {
|
|
2274
|
+
unwrap(await deleteEndpoint$1({
|
|
1898
2275
|
client,
|
|
1899
|
-
path: {
|
|
1900
|
-
|
|
1901
|
-
projectName: branch.projectName,
|
|
1902
|
-
branchName: branch.branchName
|
|
1903
|
-
}
|
|
1904
|
-
})).id;
|
|
2276
|
+
path: { endpointId }
|
|
2277
|
+
}));
|
|
1905
2278
|
}
|
|
1906
|
-
async function
|
|
1907
|
-
unwrap(await
|
|
2279
|
+
async function getEndpointRelatives(client, endpointId) {
|
|
2280
|
+
return unwrap(await endpointRelatives({
|
|
1908
2281
|
client,
|
|
1909
|
-
path: {
|
|
2282
|
+
path: { endpointId }
|
|
2283
|
+
}));
|
|
2284
|
+
}
|
|
2285
|
+
async function uploadFile(ctx, tableId, rowId, fileId, file) {
|
|
2286
|
+
assertDraft(ctx);
|
|
2287
|
+
const revisionId = await ctx.getRevisionId();
|
|
2288
|
+
return unwrap(await uploadFile$1({
|
|
2289
|
+
client: ctx.client,
|
|
2290
|
+
path: {
|
|
2291
|
+
revisionId,
|
|
2292
|
+
tableId,
|
|
2293
|
+
rowId,
|
|
2294
|
+
fileId
|
|
2295
|
+
},
|
|
2296
|
+
body: { file }
|
|
1910
2297
|
}));
|
|
1911
2298
|
}
|
|
1912
2299
|
|
|
1913
2300
|
//#endregion
|
|
1914
|
-
//#region src/
|
|
1915
|
-
var
|
|
2301
|
+
//#region src/revision-scope.ts
|
|
2302
|
+
var RevisionScope = class {
|
|
1916
2303
|
_client;
|
|
1917
2304
|
_branch;
|
|
1918
2305
|
_revisionMode;
|
|
@@ -1995,7 +2382,7 @@ var RevisiumScope = class {
|
|
|
1995
2382
|
}
|
|
1996
2383
|
return this._revisionId;
|
|
1997
2384
|
}
|
|
1998
|
-
get
|
|
2385
|
+
get context() {
|
|
1999
2386
|
return {
|
|
2000
2387
|
client: this._client,
|
|
2001
2388
|
branch: this._branch,
|
|
@@ -2004,72 +2391,119 @@ var RevisiumScope = class {
|
|
|
2004
2391
|
};
|
|
2005
2392
|
}
|
|
2006
2393
|
async getTables(options) {
|
|
2007
|
-
return getTables(this.
|
|
2394
|
+
return getTables(this.context, options);
|
|
2008
2395
|
}
|
|
2009
2396
|
async getTable(tableId) {
|
|
2010
|
-
return getTable(this.
|
|
2397
|
+
return getTable(this.context, tableId);
|
|
2011
2398
|
}
|
|
2012
2399
|
async getTableSchema(tableId) {
|
|
2013
|
-
return getTableSchema(this.
|
|
2400
|
+
return getTableSchema(this.context, tableId);
|
|
2014
2401
|
}
|
|
2015
|
-
async
|
|
2016
|
-
return
|
|
2402
|
+
async getTableCountRows(tableId) {
|
|
2403
|
+
return getTableCountRows(this.context, tableId);
|
|
2017
2404
|
}
|
|
2018
|
-
async
|
|
2019
|
-
return
|
|
2405
|
+
async getTableForeignKeysBy(tableId, options) {
|
|
2406
|
+
return getTableForeignKeysBy(this.context, tableId, options);
|
|
2020
2407
|
}
|
|
2021
|
-
async
|
|
2022
|
-
return
|
|
2408
|
+
async getTableForeignKeysTo(tableId, options) {
|
|
2409
|
+
return getTableForeignKeysTo(this.context, tableId, options);
|
|
2023
2410
|
}
|
|
2024
|
-
async
|
|
2025
|
-
return
|
|
2411
|
+
async getTableCountForeignKeysBy(tableId) {
|
|
2412
|
+
return getTableCountForeignKeysBy(this.context, tableId);
|
|
2026
2413
|
}
|
|
2027
|
-
async
|
|
2028
|
-
this.
|
|
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);
|
|
2414
|
+
async getTableCountForeignKeysTo(tableId) {
|
|
2415
|
+
return getTableCountForeignKeysTo(this.context, tableId);
|
|
2033
2416
|
}
|
|
2034
2417
|
async createTable(tableId, schema) {
|
|
2035
|
-
return createTable(this.
|
|
2418
|
+
return createTable(this.context, tableId, schema);
|
|
2036
2419
|
}
|
|
2037
2420
|
async updateTable(tableId, patches) {
|
|
2038
|
-
return updateTable(this.
|
|
2421
|
+
return updateTable(this.context, tableId, patches);
|
|
2039
2422
|
}
|
|
2040
2423
|
async deleteTable(tableId) {
|
|
2041
|
-
return deleteTable(this.
|
|
2424
|
+
return deleteTable(this.context, tableId);
|
|
2042
2425
|
}
|
|
2043
2426
|
async renameTable(tableId, nextTableId) {
|
|
2044
|
-
return renameTable(this.
|
|
2427
|
+
return renameTable(this.context, tableId, nextTableId);
|
|
2428
|
+
}
|
|
2429
|
+
async getRows(tableId, options) {
|
|
2430
|
+
return getRows(this.context, tableId, options);
|
|
2431
|
+
}
|
|
2432
|
+
async getRow(tableId, rowId) {
|
|
2433
|
+
return getRow(this.context, tableId, rowId);
|
|
2434
|
+
}
|
|
2435
|
+
async getRowForeignKeysBy(tableId, rowId, foreignKeyByTableId, options) {
|
|
2436
|
+
return getRowForeignKeysBy(this.context, tableId, rowId, foreignKeyByTableId, options);
|
|
2437
|
+
}
|
|
2438
|
+
async getRowForeignKeysTo(tableId, rowId, foreignKeyToTableId, options) {
|
|
2439
|
+
return getRowForeignKeysTo(this.context, tableId, rowId, foreignKeyToTableId, options);
|
|
2440
|
+
}
|
|
2441
|
+
async getRowCountForeignKeysBy(tableId, rowId) {
|
|
2442
|
+
return getRowCountForeignKeysBy(this.context, tableId, rowId);
|
|
2443
|
+
}
|
|
2444
|
+
async getRowCountForeignKeysTo(tableId, rowId) {
|
|
2445
|
+
return getRowCountForeignKeysTo(this.context, tableId, rowId);
|
|
2045
2446
|
}
|
|
2046
2447
|
async createRow(tableId, rowId, data) {
|
|
2047
|
-
return createRow(this.
|
|
2448
|
+
return createRow(this.context, tableId, rowId, data);
|
|
2048
2449
|
}
|
|
2049
2450
|
async createRows(tableId, rows, options) {
|
|
2050
|
-
return createRows(this.
|
|
2451
|
+
return createRows(this.context, tableId, rows, options);
|
|
2051
2452
|
}
|
|
2052
2453
|
async updateRow(tableId, rowId, data) {
|
|
2053
|
-
return updateRow(this.
|
|
2454
|
+
return updateRow(this.context, tableId, rowId, data);
|
|
2054
2455
|
}
|
|
2055
2456
|
async updateRows(tableId, rows, options) {
|
|
2056
|
-
return updateRows(this.
|
|
2457
|
+
return updateRows(this.context, tableId, rows, options);
|
|
2057
2458
|
}
|
|
2058
2459
|
async patchRow(tableId, rowId, patches) {
|
|
2059
|
-
return patchRow(this.
|
|
2460
|
+
return patchRow(this.context, tableId, rowId, patches);
|
|
2461
|
+
}
|
|
2462
|
+
async patchRows(tableId, body) {
|
|
2463
|
+
return patchRows(this.context, tableId, body);
|
|
2060
2464
|
}
|
|
2061
2465
|
async deleteRow(tableId, rowId) {
|
|
2062
|
-
return deleteRow(this.
|
|
2466
|
+
return deleteRow(this.context, tableId, rowId);
|
|
2063
2467
|
}
|
|
2064
2468
|
async deleteRows(tableId, rowIds) {
|
|
2065
|
-
return deleteRows(this.
|
|
2469
|
+
return deleteRows(this.context, tableId, rowIds);
|
|
2066
2470
|
}
|
|
2067
2471
|
async renameRow(tableId, rowId, nextRowId) {
|
|
2068
|
-
return renameRow(this.
|
|
2472
|
+
return renameRow(this.context, tableId, rowId, nextRowId);
|
|
2473
|
+
}
|
|
2474
|
+
async getChanges() {
|
|
2475
|
+
return getChanges(this.context);
|
|
2476
|
+
}
|
|
2477
|
+
async getTableChanges(options) {
|
|
2478
|
+
return getTableChanges(this.context, options);
|
|
2479
|
+
}
|
|
2480
|
+
async getRowChanges(options) {
|
|
2481
|
+
return getRowChanges(this.context, options);
|
|
2482
|
+
}
|
|
2483
|
+
async getMigrations() {
|
|
2484
|
+
return getMigrations(this.context);
|
|
2485
|
+
}
|
|
2486
|
+
async applyMigrations(migrations) {
|
|
2487
|
+
this.assertNotDisposed();
|
|
2488
|
+
await applyMigrations(this.context, migrations);
|
|
2489
|
+
await this._owner.refreshRevisionIds();
|
|
2490
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2491
|
+
this._stale = false;
|
|
2492
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2493
|
+
}
|
|
2494
|
+
async applyMigrationsWithStatus(migrations) {
|
|
2495
|
+
this.assertNotDisposed();
|
|
2496
|
+
const result = await applyMigrationsWithStatus(this.context, migrations);
|
|
2497
|
+
await this._owner.refreshRevisionIds();
|
|
2498
|
+
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2499
|
+
this._stale = false;
|
|
2500
|
+
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2501
|
+
return result;
|
|
2069
2502
|
}
|
|
2070
2503
|
async commit(comment) {
|
|
2071
2504
|
this.assertNotDisposed();
|
|
2072
|
-
const data = await commit(this.
|
|
2505
|
+
const data = await commit(this.context, comment);
|
|
2506
|
+
await this._owner.refreshRevisionIds();
|
|
2073
2507
|
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2074
2508
|
this._stale = false;
|
|
2075
2509
|
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
@@ -2077,250 +2511,302 @@ var RevisiumScope = class {
|
|
|
2077
2511
|
}
|
|
2078
2512
|
async revertChanges() {
|
|
2079
2513
|
this.assertNotDisposed();
|
|
2080
|
-
await revertChanges(this.
|
|
2514
|
+
await revertChanges(this.context);
|
|
2515
|
+
await this._owner.refreshRevisionIds();
|
|
2081
2516
|
this._revisionId = await fetchDraftRevisionId(this._client, this._branch);
|
|
2082
2517
|
this._stale = false;
|
|
2083
2518
|
this._owner.notifyBranchChanged(this._branchKey, this);
|
|
2084
2519
|
}
|
|
2520
|
+
async getEndpoints() {
|
|
2521
|
+
return getEndpoints(this.context);
|
|
2522
|
+
}
|
|
2523
|
+
async createEndpoint(body) {
|
|
2524
|
+
return createEndpoint(this.context, body);
|
|
2525
|
+
}
|
|
2526
|
+
async deleteEndpoint(endpointId) {
|
|
2527
|
+
this.assertNotDisposed();
|
|
2528
|
+
return deleteEndpoint(this._client, endpointId);
|
|
2529
|
+
}
|
|
2530
|
+
async getEndpointRelatives(endpointId) {
|
|
2531
|
+
this.assertNotDisposed();
|
|
2532
|
+
return getEndpointRelatives(this._client, endpointId);
|
|
2533
|
+
}
|
|
2534
|
+
async uploadFile(tableId, rowId, fileId, file) {
|
|
2535
|
+
return uploadFile(this.context, tableId, rowId, fileId, file);
|
|
2536
|
+
}
|
|
2085
2537
|
};
|
|
2086
2538
|
|
|
2087
2539
|
//#endregion
|
|
2088
|
-
//#region src/
|
|
2089
|
-
var
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2102
|
-
this._client = createClient(createConfig({ baseUrl: this._baseUrl }));
|
|
2103
|
-
}
|
|
2104
|
-
get baseUrl() {
|
|
2105
|
-
return this._baseUrl;
|
|
2540
|
+
//#region src/branch-scope.ts
|
|
2541
|
+
var BranchScope = class BranchScope {
|
|
2542
|
+
_headRevisionId;
|
|
2543
|
+
_draftRevisionId;
|
|
2544
|
+
_scopes = /* @__PURE__ */ new Set();
|
|
2545
|
+
constructor(_client, _branch, headRevisionId, draftRevisionId) {
|
|
2546
|
+
this._client = _client;
|
|
2547
|
+
this._branch = _branch;
|
|
2548
|
+
this._headRevisionId = headRevisionId;
|
|
2549
|
+
this._draftRevisionId = draftRevisionId;
|
|
2550
|
+
}
|
|
2551
|
+
static async create(client, branch) {
|
|
2552
|
+
const [headId, draftId] = await Promise.all([fetchHeadRevisionId(client, branch), fetchDraftRevisionId(client, branch)]);
|
|
2553
|
+
return new BranchScope(client, branch, headId, draftId);
|
|
2106
2554
|
}
|
|
2107
2555
|
get organizationId() {
|
|
2108
|
-
return this.
|
|
2556
|
+
return this._branch.organizationId;
|
|
2109
2557
|
}
|
|
2110
2558
|
get projectName() {
|
|
2111
|
-
return this.
|
|
2559
|
+
return this._branch.projectName;
|
|
2112
2560
|
}
|
|
2113
2561
|
get branchName() {
|
|
2114
|
-
return this.
|
|
2562
|
+
return this._branch.branchName;
|
|
2115
2563
|
}
|
|
2116
|
-
get
|
|
2117
|
-
return this.
|
|
2564
|
+
get headRevisionId() {
|
|
2565
|
+
return this._headRevisionId;
|
|
2118
2566
|
}
|
|
2119
|
-
get
|
|
2120
|
-
return this.
|
|
2567
|
+
get draftRevisionId() {
|
|
2568
|
+
return this._draftRevisionId;
|
|
2121
2569
|
}
|
|
2122
2570
|
get client() {
|
|
2123
2571
|
return this._client;
|
|
2124
2572
|
}
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
}
|
|
2128
|
-
async login(username, password) {
|
|
2129
|
-
const result = await login({
|
|
2573
|
+
draft() {
|
|
2574
|
+
const scope = new RevisionScope({
|
|
2130
2575
|
client: this._client,
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2576
|
+
branch: this._branch,
|
|
2577
|
+
revisionId: this._draftRevisionId,
|
|
2578
|
+
isDraft: true,
|
|
2579
|
+
revisionMode: "draft",
|
|
2580
|
+
owner: this
|
|
2135
2581
|
});
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
this._isAuthenticated = true;
|
|
2139
|
-
}
|
|
2140
|
-
loginWithToken(token) {
|
|
2141
|
-
this._client.setConfig({ auth: token });
|
|
2142
|
-
this._isAuthenticated = true;
|
|
2143
|
-
}
|
|
2144
|
-
async me() {
|
|
2145
|
-
return me(this._client);
|
|
2582
|
+
this._scopes.add(scope);
|
|
2583
|
+
return scope;
|
|
2146
2584
|
}
|
|
2147
|
-
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
this._revisionId = await fetchDraftRevisionId(this._client, branch);
|
|
2159
|
-
this._isDraft = true;
|
|
2160
|
-
} else if (revision === "head") {
|
|
2161
|
-
this._revisionId = await fetchHeadRevisionId(this._client, branch);
|
|
2162
|
-
this._isDraft = false;
|
|
2163
|
-
} else {
|
|
2164
|
-
await validateRevisionId(this._client, revision);
|
|
2165
|
-
this._revisionId = revision;
|
|
2166
|
-
this._isDraft = false;
|
|
2167
|
-
}
|
|
2585
|
+
head() {
|
|
2586
|
+
const scope = new RevisionScope({
|
|
2587
|
+
client: this._client,
|
|
2588
|
+
branch: this._branch,
|
|
2589
|
+
revisionId: this._headRevisionId,
|
|
2590
|
+
isDraft: false,
|
|
2591
|
+
revisionMode: "head",
|
|
2592
|
+
owner: this
|
|
2593
|
+
});
|
|
2594
|
+
this._scopes.add(scope);
|
|
2595
|
+
return scope;
|
|
2168
2596
|
}
|
|
2169
|
-
async
|
|
2170
|
-
|
|
2171
|
-
const
|
|
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({
|
|
2597
|
+
async revision(revisionId) {
|
|
2598
|
+
await validateRevisionId(this._client, revisionId);
|
|
2599
|
+
const scope = new RevisionScope({
|
|
2194
2600
|
client: this._client,
|
|
2195
|
-
branch,
|
|
2601
|
+
branch: this._branch,
|
|
2196
2602
|
revisionId,
|
|
2197
|
-
isDraft,
|
|
2198
|
-
revisionMode,
|
|
2603
|
+
isDraft: false,
|
|
2604
|
+
revisionMode: "explicit",
|
|
2199
2605
|
owner: this
|
|
2200
2606
|
});
|
|
2201
|
-
|
|
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);
|
|
2607
|
+
this._scopes.add(scope);
|
|
2208
2608
|
return scope;
|
|
2209
2609
|
}
|
|
2610
|
+
async get() {
|
|
2611
|
+
return getBranch(this._client, this._branch);
|
|
2612
|
+
}
|
|
2613
|
+
async delete() {
|
|
2614
|
+
return deleteBranch(this._client, this._branch);
|
|
2615
|
+
}
|
|
2616
|
+
async getTouched() {
|
|
2617
|
+
return getBranchTouched(this._client, this._branch);
|
|
2618
|
+
}
|
|
2619
|
+
async getRevisions(options) {
|
|
2620
|
+
return getRevisions(this._client, this._branch, options);
|
|
2621
|
+
}
|
|
2622
|
+
async getStartRevision() {
|
|
2623
|
+
return getStartRevision(this._client, this._branch);
|
|
2624
|
+
}
|
|
2210
2625
|
notifyBranchChanged(branchKey, excludeScope) {
|
|
2211
|
-
|
|
2212
|
-
if (
|
|
2213
|
-
for (const scope of scopeSet) if (scope !== excludeScope) scope.markStale();
|
|
2626
|
+
if (branchKey !== `${this._branch.organizationId}/${this._branch.projectName}/${this._branch.branchName}`) return;
|
|
2627
|
+
for (const scope of this._scopes) if (scope !== excludeScope) scope.markStale();
|
|
2214
2628
|
}
|
|
2215
2629
|
unregisterScope(scope) {
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2630
|
+
this._scopes.delete(scope);
|
|
2631
|
+
}
|
|
2632
|
+
async refreshRevisionIds() {
|
|
2633
|
+
const [headId, draftId] = await Promise.all([fetchHeadRevisionId(this._client, this._branch), fetchDraftRevisionId(this._client, this._branch)]);
|
|
2634
|
+
this._headRevisionId = headId;
|
|
2635
|
+
this._draftRevisionId = draftId;
|
|
2636
|
+
}
|
|
2637
|
+
};
|
|
2638
|
+
|
|
2639
|
+
//#endregion
|
|
2640
|
+
//#region src/project-scope.ts
|
|
2641
|
+
var ProjectScope = class {
|
|
2642
|
+
constructor(_client, _organizationId, _projectName) {
|
|
2643
|
+
this._client = _client;
|
|
2644
|
+
this._organizationId = _organizationId;
|
|
2645
|
+
this._projectName = _projectName;
|
|
2646
|
+
}
|
|
2647
|
+
get organizationId() {
|
|
2648
|
+
return this._organizationId;
|
|
2649
|
+
}
|
|
2650
|
+
get projectName() {
|
|
2651
|
+
return this._projectName;
|
|
2652
|
+
}
|
|
2653
|
+
get client() {
|
|
2654
|
+
return this._client;
|
|
2655
|
+
}
|
|
2656
|
+
async branch(branchName) {
|
|
2657
|
+
return BranchScope.create(this._client, {
|
|
2658
|
+
client: this._client,
|
|
2659
|
+
organizationId: this._organizationId,
|
|
2660
|
+
projectName: this._projectName,
|
|
2661
|
+
branchName: branchName ?? "master"
|
|
2662
|
+
});
|
|
2220
2663
|
}
|
|
2221
|
-
get
|
|
2664
|
+
get projectContext() {
|
|
2222
2665
|
return {
|
|
2223
2666
|
client: this._client,
|
|
2224
|
-
|
|
2225
|
-
|
|
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);
|
|
2233
|
-
}
|
|
2667
|
+
organizationId: this._organizationId,
|
|
2668
|
+
projectName: this._projectName
|
|
2234
2669
|
};
|
|
2235
2670
|
}
|
|
2236
|
-
async
|
|
2237
|
-
return
|
|
2671
|
+
async get() {
|
|
2672
|
+
return getProject(this.projectContext);
|
|
2238
2673
|
}
|
|
2239
|
-
async
|
|
2240
|
-
return
|
|
2674
|
+
async update(body) {
|
|
2675
|
+
return updateProject(this.projectContext, body);
|
|
2241
2676
|
}
|
|
2242
|
-
async
|
|
2243
|
-
return
|
|
2677
|
+
async delete() {
|
|
2678
|
+
return deleteProject(this.projectContext);
|
|
2244
2679
|
}
|
|
2245
|
-
async
|
|
2246
|
-
return
|
|
2680
|
+
async getBranches(options) {
|
|
2681
|
+
return getBranches(this.projectContext, options);
|
|
2247
2682
|
}
|
|
2248
|
-
async
|
|
2249
|
-
return
|
|
2683
|
+
async getRootBranch() {
|
|
2684
|
+
return getRootBranch(this.projectContext);
|
|
2250
2685
|
}
|
|
2251
|
-
async
|
|
2252
|
-
return
|
|
2686
|
+
async createBranch(branchName, revisionId) {
|
|
2687
|
+
return createBranch(this._client, revisionId, branchName);
|
|
2253
2688
|
}
|
|
2254
|
-
async
|
|
2255
|
-
return
|
|
2689
|
+
async getUsers(options) {
|
|
2690
|
+
return getProjectUsers(this.projectContext, options);
|
|
2256
2691
|
}
|
|
2257
|
-
async
|
|
2258
|
-
|
|
2259
|
-
await this.refreshDraftRevisionId();
|
|
2260
|
-
this.notifyScopesOnCurrentBranch();
|
|
2692
|
+
async addUser(userId, roleId) {
|
|
2693
|
+
return addProjectUser(this.projectContext, userId, roleId);
|
|
2261
2694
|
}
|
|
2262
|
-
async
|
|
2263
|
-
return
|
|
2695
|
+
async removeUser(userId) {
|
|
2696
|
+
return removeProjectUser(this.projectContext, userId);
|
|
2264
2697
|
}
|
|
2265
|
-
async
|
|
2266
|
-
return
|
|
2698
|
+
async getEndpoints() {
|
|
2699
|
+
return (await this.branch()).draft().getEndpoints();
|
|
2267
2700
|
}
|
|
2268
|
-
async
|
|
2269
|
-
return
|
|
2701
|
+
async createEndpoint(body) {
|
|
2702
|
+
return (await this.branch()).draft().createEndpoint(body);
|
|
2270
2703
|
}
|
|
2271
|
-
async
|
|
2272
|
-
return
|
|
2704
|
+
async deleteEndpoint(endpointId) {
|
|
2705
|
+
return deleteEndpoint(this._client, endpointId);
|
|
2273
2706
|
}
|
|
2274
|
-
async
|
|
2275
|
-
return
|
|
2707
|
+
async getEndpointRelatives(endpointId) {
|
|
2708
|
+
return getEndpointRelatives(this._client, endpointId);
|
|
2276
2709
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2712
|
+
//#endregion
|
|
2713
|
+
//#region src/org-scope.ts
|
|
2714
|
+
var OrgScope = class {
|
|
2715
|
+
constructor(_client, _organizationId) {
|
|
2716
|
+
this._client = _client;
|
|
2717
|
+
this._organizationId = _organizationId;
|
|
2279
2718
|
}
|
|
2280
|
-
|
|
2281
|
-
return
|
|
2719
|
+
get organizationId() {
|
|
2720
|
+
return this._organizationId;
|
|
2282
2721
|
}
|
|
2283
|
-
|
|
2284
|
-
return
|
|
2722
|
+
get client() {
|
|
2723
|
+
return this._client;
|
|
2285
2724
|
}
|
|
2286
|
-
|
|
2287
|
-
return
|
|
2725
|
+
project(projectName) {
|
|
2726
|
+
return new ProjectScope(this._client, this._organizationId, projectName);
|
|
2288
2727
|
}
|
|
2289
|
-
|
|
2290
|
-
return
|
|
2728
|
+
get orgContext() {
|
|
2729
|
+
return {
|
|
2730
|
+
client: this._client,
|
|
2731
|
+
organizationId: this._organizationId
|
|
2732
|
+
};
|
|
2291
2733
|
}
|
|
2292
|
-
async
|
|
2293
|
-
return
|
|
2734
|
+
async getProjects(options) {
|
|
2735
|
+
return getProjects(this.orgContext, options);
|
|
2294
2736
|
}
|
|
2295
|
-
async
|
|
2296
|
-
return
|
|
2737
|
+
async createProject(body) {
|
|
2738
|
+
return createProject(this.orgContext, body);
|
|
2297
2739
|
}
|
|
2298
|
-
async
|
|
2299
|
-
|
|
2300
|
-
await this.refreshDraftRevisionId();
|
|
2301
|
-
this.notifyScopesOnCurrentBranch();
|
|
2302
|
-
return data;
|
|
2740
|
+
async getUsers(options) {
|
|
2741
|
+
return getOrgUsers(this.orgContext, options);
|
|
2303
2742
|
}
|
|
2304
|
-
async
|
|
2305
|
-
|
|
2306
|
-
await this.refreshDraftRevisionId();
|
|
2307
|
-
this.notifyScopesOnCurrentBranch();
|
|
2743
|
+
async addUser(userId, roleId) {
|
|
2744
|
+
return addOrgUser(this.orgContext, userId, roleId);
|
|
2308
2745
|
}
|
|
2309
|
-
async
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2746
|
+
async removeUser(userId) {
|
|
2747
|
+
return removeOrgUser(this.orgContext, userId);
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2750
|
+
|
|
2751
|
+
//#endregion
|
|
2752
|
+
//#region src/revisium-client.ts
|
|
2753
|
+
var RevisiumClient = class {
|
|
2754
|
+
_client;
|
|
2755
|
+
_baseUrl;
|
|
2756
|
+
_isAuthenticated = false;
|
|
2757
|
+
constructor(options) {
|
|
2758
|
+
const url = options.baseUrl;
|
|
2759
|
+
this._baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
|
|
2760
|
+
this._client = createClient(createConfig({ baseUrl: this._baseUrl }));
|
|
2761
|
+
}
|
|
2762
|
+
get baseUrl() {
|
|
2763
|
+
return this._baseUrl;
|
|
2764
|
+
}
|
|
2765
|
+
get client() {
|
|
2766
|
+
return this._client;
|
|
2767
|
+
}
|
|
2768
|
+
isAuthenticated() {
|
|
2769
|
+
return this._isAuthenticated;
|
|
2770
|
+
}
|
|
2771
|
+
async login(username, password) {
|
|
2772
|
+
const result = await login({
|
|
2773
|
+
client: this._client,
|
|
2774
|
+
body: {
|
|
2775
|
+
emailOrUsername: username,
|
|
2776
|
+
password
|
|
2777
|
+
}
|
|
2314
2778
|
});
|
|
2779
|
+
const data = unwrap(result);
|
|
2780
|
+
this._client.setConfig({ auth: data.accessToken });
|
|
2781
|
+
this._isAuthenticated = true;
|
|
2315
2782
|
}
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2783
|
+
loginWithToken(token) {
|
|
2784
|
+
this._client.setConfig({ auth: token });
|
|
2785
|
+
this._isAuthenticated = true;
|
|
2786
|
+
}
|
|
2787
|
+
async me() {
|
|
2788
|
+
return me(this._client);
|
|
2789
|
+
}
|
|
2790
|
+
org(organizationId) {
|
|
2791
|
+
return new OrgScope(this._client, organizationId);
|
|
2792
|
+
}
|
|
2793
|
+
async branch(options) {
|
|
2794
|
+
return BranchScope.create(this._client, {
|
|
2795
|
+
client: this._client,
|
|
2796
|
+
organizationId: options.org,
|
|
2797
|
+
projectName: options.project,
|
|
2798
|
+
branchName: options.branch ?? "master"
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
async revision(options) {
|
|
2802
|
+
const bs = await this.branch(options);
|
|
2803
|
+
const rev = options.revision ?? "draft";
|
|
2804
|
+
if (rev === "draft") return bs.draft();
|
|
2805
|
+
if (rev === "head") return bs.head();
|
|
2806
|
+
return bs.revision(rev);
|
|
2321
2807
|
}
|
|
2322
2808
|
};
|
|
2323
2809
|
|
|
2324
2810
|
//#endregion
|
|
2325
|
-
export {
|
|
2811
|
+
export { BranchScope, OrgScope, ProjectScope, RevisionScope, RevisiumClient, client, sdk_gen_exports as sdk };
|
|
2326
2812
|
//# sourceMappingURL=index.mjs.map
|