changeledger 0.5.0 → 0.6.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.
@@ -41,9 +41,37 @@ const postProject = (route, body) =>
41
41
  body: JSON.stringify(body),
42
42
  });
43
43
 
44
+ const jsonOrThrow = async (response) => {
45
+ const body = await response.json();
46
+ if (!response.ok) throw new Error(body.error || `HTTP ${response.status}`);
47
+ return body;
48
+ };
49
+
44
50
  export const postProjectConfig = (project, content, revision) =>
45
51
  postProject('/api/project-config', { project, content, revision });
46
52
 
53
+ export const getProjectConfigStructured = (project) =>
54
+ fetch(`/api/project-config-structured?project=${encodeURIComponent(project)}`).then(async (r) => {
55
+ const body = await r.json();
56
+ if (!r.ok) throw new Error(body.error || `HTTP ${r.status}`);
57
+ return body;
58
+ });
59
+
60
+ export const patchProjectConfigApi = (project, patch, revision) =>
61
+ postProject('/api/project-config-patch', { project, patch, revision });
62
+
63
+ export const getConfigMigrationPreview = (project, revision) =>
64
+ fetch(
65
+ `/api/project-config-migrate-preview?project=${encodeURIComponent(project)}&revision=${encodeURIComponent(revision ?? '')}`,
66
+ ).then(async (r) => {
67
+ const body = await r.json();
68
+ if (!r.ok) throw new Error(body.error || `HTTP ${r.status}`);
69
+ return body;
70
+ });
71
+
72
+ export const postConfigMigrationApply = (project, revision) =>
73
+ postProject('/api/project-config-migrate-apply', { project, revision }).then(jsonOrThrow);
74
+
47
75
  export const postProjectPath = (project, path) =>
48
76
  postProject('/api/project-path', { project, path });
49
77