@valbuild/server 0.68.0 → 0.68.1

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.
@@ -3073,6 +3073,11 @@ class ValOpsFS extends ValOps {
3073
3073
  return fp.result.ok(Object.fromEntries(Object.entries(patches.patches).map(([patchId, value]) => [patchId, this.getParentPatchIdFromParentRef(value.parentRef)])));
3074
3074
  }
3075
3075
 
3076
+ // #region profiles
3077
+ async getProfiles() {
3078
+ throw new Error("Configuration error: cannot get profiles in local / development file system mode");
3079
+ }
3080
+
3076
3081
  // #region fs file path helpers
3077
3082
  getPatchesDir() {
3078
3083
  return fsPath__namespace["default"].join(this.rootDir, ValOpsFS.VAL_DIR, "patches");
@@ -3264,6 +3269,15 @@ const CommitResponse = zod.z.object({
3264
3269
  commit: CommitSha,
3265
3270
  branch: zod.z.string()
3266
3271
  });
3272
+ const ProfilesResponse = zod.z.object({
3273
+ profiles: zod.z.array(zod.z.object({
3274
+ profileId: zod.z.string(),
3275
+ fullName: zod.z.string(),
3276
+ avatar: zod.z.object({
3277
+ url: zod.z.string()
3278
+ }).nullable()
3279
+ }))
3280
+ });
3267
3281
  class ValOpsHttp extends ValOps {
3268
3282
  constructor(hostUrl, project, commitSha,
3269
3283
  // TODO: CommitSha
@@ -3416,8 +3430,8 @@ class ValOpsHttp extends ValOps {
3416
3430
  for (let i = 0; i < patchIds.length; i += chunkSize) {
3417
3431
  patchIdChunks.push(patchIds.slice(i, i + chunkSize));
3418
3432
  }
3419
- let allPatches = [];
3420
- let allErrors = [];
3433
+ const allPatches = [];
3434
+ const allErrors = [];
3421
3435
  if (patchIds === undefined || patchIds.length === 0) {
3422
3436
  return this.fetchPatchesInternal({
3423
3437
  patchIds: patchIds,
@@ -3435,12 +3449,9 @@ class ValOpsHttp extends ValOps {
3435
3449
  if ("error" in res) {
3436
3450
  return res;
3437
3451
  }
3438
- allPatches = {
3439
- ...allPatches,
3440
- ...res.patches
3441
- };
3452
+ allPatches.push(...res.patches);
3442
3453
  if (res.errors) {
3443
- allErrors = [...allErrors, ...res.errors];
3454
+ allErrors.push(...res.errors);
3444
3455
  }
3445
3456
  }
3446
3457
  return {
@@ -3842,6 +3853,30 @@ class ValOpsHttp extends ValOps {
3842
3853
  };
3843
3854
  }
3844
3855
  }
3856
+
3857
+ // #region profiles
3858
+ async getProfiles() {
3859
+ var _res$headers$get3;
3860
+ const res = await fetch(`${this.hostUrl}/v1/${this.project}/profiles`, {
3861
+ headers: {
3862
+ ...this.authHeaders,
3863
+ "Content-Type": "application/json"
3864
+ }
3865
+ });
3866
+ if (res.ok) {
3867
+ const parsed = ProfilesResponse.safeParse(await res.json());
3868
+ if (parsed.error) {
3869
+ console.error("Could not parse profiles response", parsed.error);
3870
+ throw Error(`Could not get profiles from remote server: wrong format. You might need to upgrade Val.`);
3871
+ }
3872
+ return parsed.data.profiles;
3873
+ }
3874
+ if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
3875
+ const json = await res.json();
3876
+ throw Error(`Could not get profiles (status: ${res.status}): ${"message" in json ? json.message : "Unknown error"}`);
3877
+ }
3878
+ throw Error(`Could not get profiles. Got status: ${res.status}`);
3879
+ }
3845
3880
  }
3846
3881
 
3847
3882
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -4704,6 +4739,28 @@ const ValServer = (valModules, options, callbacks) => {
4704
4739
  return res;
4705
4740
  }
4706
4741
  },
4742
+ "/profiles": {
4743
+ GET: async req => {
4744
+ // const cookies = req.cookies;
4745
+ // const auth = getAuth(cookies);
4746
+ // if (auth.error) {
4747
+ // return {
4748
+ // status: 401,
4749
+ // json: {
4750
+ // message: auth.error,
4751
+ // },
4752
+ // };
4753
+ // }
4754
+
4755
+ const profiles = await serverOps.getProfiles();
4756
+ return {
4757
+ status: 200,
4758
+ json: {
4759
+ profiles
4760
+ }
4761
+ };
4762
+ }
4763
+ },
4707
4764
  "/save": {
4708
4765
  POST: async req => {
4709
4766
  const cookies = req.cookies;
@@ -3073,6 +3073,11 @@ class ValOpsFS extends ValOps {
3073
3073
  return fp.result.ok(Object.fromEntries(Object.entries(patches.patches).map(([patchId, value]) => [patchId, this.getParentPatchIdFromParentRef(value.parentRef)])));
3074
3074
  }
3075
3075
 
3076
+ // #region profiles
3077
+ async getProfiles() {
3078
+ throw new Error("Configuration error: cannot get profiles in local / development file system mode");
3079
+ }
3080
+
3076
3081
  // #region fs file path helpers
3077
3082
  getPatchesDir() {
3078
3083
  return fsPath__namespace["default"].join(this.rootDir, ValOpsFS.VAL_DIR, "patches");
@@ -3264,6 +3269,15 @@ const CommitResponse = zod.z.object({
3264
3269
  commit: CommitSha,
3265
3270
  branch: zod.z.string()
3266
3271
  });
3272
+ const ProfilesResponse = zod.z.object({
3273
+ profiles: zod.z.array(zod.z.object({
3274
+ profileId: zod.z.string(),
3275
+ fullName: zod.z.string(),
3276
+ avatar: zod.z.object({
3277
+ url: zod.z.string()
3278
+ }).nullable()
3279
+ }))
3280
+ });
3267
3281
  class ValOpsHttp extends ValOps {
3268
3282
  constructor(hostUrl, project, commitSha,
3269
3283
  // TODO: CommitSha
@@ -3416,8 +3430,8 @@ class ValOpsHttp extends ValOps {
3416
3430
  for (let i = 0; i < patchIds.length; i += chunkSize) {
3417
3431
  patchIdChunks.push(patchIds.slice(i, i + chunkSize));
3418
3432
  }
3419
- let allPatches = [];
3420
- let allErrors = [];
3433
+ const allPatches = [];
3434
+ const allErrors = [];
3421
3435
  if (patchIds === undefined || patchIds.length === 0) {
3422
3436
  return this.fetchPatchesInternal({
3423
3437
  patchIds: patchIds,
@@ -3435,12 +3449,9 @@ class ValOpsHttp extends ValOps {
3435
3449
  if ("error" in res) {
3436
3450
  return res;
3437
3451
  }
3438
- allPatches = {
3439
- ...allPatches,
3440
- ...res.patches
3441
- };
3452
+ allPatches.push(...res.patches);
3442
3453
  if (res.errors) {
3443
- allErrors = [...allErrors, ...res.errors];
3454
+ allErrors.push(...res.errors);
3444
3455
  }
3445
3456
  }
3446
3457
  return {
@@ -3842,6 +3853,30 @@ class ValOpsHttp extends ValOps {
3842
3853
  };
3843
3854
  }
3844
3855
  }
3856
+
3857
+ // #region profiles
3858
+ async getProfiles() {
3859
+ var _res$headers$get3;
3860
+ const res = await fetch(`${this.hostUrl}/v1/${this.project}/profiles`, {
3861
+ headers: {
3862
+ ...this.authHeaders,
3863
+ "Content-Type": "application/json"
3864
+ }
3865
+ });
3866
+ if (res.ok) {
3867
+ const parsed = ProfilesResponse.safeParse(await res.json());
3868
+ if (parsed.error) {
3869
+ console.error("Could not parse profiles response", parsed.error);
3870
+ throw Error(`Could not get profiles from remote server: wrong format. You might need to upgrade Val.`);
3871
+ }
3872
+ return parsed.data.profiles;
3873
+ }
3874
+ if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
3875
+ const json = await res.json();
3876
+ throw Error(`Could not get profiles (status: ${res.status}): ${"message" in json ? json.message : "Unknown error"}`);
3877
+ }
3878
+ throw Error(`Could not get profiles. Got status: ${res.status}`);
3879
+ }
3845
3880
  }
3846
3881
 
3847
3882
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -4704,6 +4739,28 @@ const ValServer = (valModules, options, callbacks) => {
4704
4739
  return res;
4705
4740
  }
4706
4741
  },
4742
+ "/profiles": {
4743
+ GET: async req => {
4744
+ // const cookies = req.cookies;
4745
+ // const auth = getAuth(cookies);
4746
+ // if (auth.error) {
4747
+ // return {
4748
+ // status: 401,
4749
+ // json: {
4750
+ // message: auth.error,
4751
+ // },
4752
+ // };
4753
+ // }
4754
+
4755
+ const profiles = await serverOps.getProfiles();
4756
+ return {
4757
+ status: 200,
4758
+ json: {
4759
+ profiles
4760
+ }
4761
+ };
4762
+ }
4763
+ },
4707
4764
  "/save": {
4708
4765
  POST: async req => {
4709
4766
  const cookies = req.cookies;
@@ -3044,6 +3044,11 @@ class ValOpsFS extends ValOps {
3044
3044
  return result.ok(Object.fromEntries(Object.entries(patches.patches).map(([patchId, value]) => [patchId, this.getParentPatchIdFromParentRef(value.parentRef)])));
3045
3045
  }
3046
3046
 
3047
+ // #region profiles
3048
+ async getProfiles() {
3049
+ throw new Error("Configuration error: cannot get profiles in local / development file system mode");
3050
+ }
3051
+
3047
3052
  // #region fs file path helpers
3048
3053
  getPatchesDir() {
3049
3054
  return fsPath__default.join(this.rootDir, ValOpsFS.VAL_DIR, "patches");
@@ -3235,6 +3240,15 @@ const CommitResponse = z.object({
3235
3240
  commit: CommitSha,
3236
3241
  branch: z.string()
3237
3242
  });
3243
+ const ProfilesResponse = z.object({
3244
+ profiles: z.array(z.object({
3245
+ profileId: z.string(),
3246
+ fullName: z.string(),
3247
+ avatar: z.object({
3248
+ url: z.string()
3249
+ }).nullable()
3250
+ }))
3251
+ });
3238
3252
  class ValOpsHttp extends ValOps {
3239
3253
  constructor(hostUrl, project, commitSha,
3240
3254
  // TODO: CommitSha
@@ -3387,8 +3401,8 @@ class ValOpsHttp extends ValOps {
3387
3401
  for (let i = 0; i < patchIds.length; i += chunkSize) {
3388
3402
  patchIdChunks.push(patchIds.slice(i, i + chunkSize));
3389
3403
  }
3390
- let allPatches = [];
3391
- let allErrors = [];
3404
+ const allPatches = [];
3405
+ const allErrors = [];
3392
3406
  if (patchIds === undefined || patchIds.length === 0) {
3393
3407
  return this.fetchPatchesInternal({
3394
3408
  patchIds: patchIds,
@@ -3406,12 +3420,9 @@ class ValOpsHttp extends ValOps {
3406
3420
  if ("error" in res) {
3407
3421
  return res;
3408
3422
  }
3409
- allPatches = {
3410
- ...allPatches,
3411
- ...res.patches
3412
- };
3423
+ allPatches.push(...res.patches);
3413
3424
  if (res.errors) {
3414
- allErrors = [...allErrors, ...res.errors];
3425
+ allErrors.push(...res.errors);
3415
3426
  }
3416
3427
  }
3417
3428
  return {
@@ -3813,6 +3824,30 @@ class ValOpsHttp extends ValOps {
3813
3824
  };
3814
3825
  }
3815
3826
  }
3827
+
3828
+ // #region profiles
3829
+ async getProfiles() {
3830
+ var _res$headers$get3;
3831
+ const res = await fetch(`${this.hostUrl}/v1/${this.project}/profiles`, {
3832
+ headers: {
3833
+ ...this.authHeaders,
3834
+ "Content-Type": "application/json"
3835
+ }
3836
+ });
3837
+ if (res.ok) {
3838
+ const parsed = ProfilesResponse.safeParse(await res.json());
3839
+ if (parsed.error) {
3840
+ console.error("Could not parse profiles response", parsed.error);
3841
+ throw Error(`Could not get profiles from remote server: wrong format. You might need to upgrade Val.`);
3842
+ }
3843
+ return parsed.data.profiles;
3844
+ }
3845
+ if ((_res$headers$get3 = res.headers.get("Content-Type")) !== null && _res$headers$get3 !== void 0 && _res$headers$get3.includes("application/json")) {
3846
+ const json = await res.json();
3847
+ throw Error(`Could not get profiles (status: ${res.status}): ${"message" in json ? json.message : "Unknown error"}`);
3848
+ }
3849
+ throw Error(`Could not get profiles. Got status: ${res.status}`);
3850
+ }
3816
3851
  }
3817
3852
 
3818
3853
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -4675,6 +4710,28 @@ const ValServer = (valModules, options, callbacks) => {
4675
4710
  return res;
4676
4711
  }
4677
4712
  },
4713
+ "/profiles": {
4714
+ GET: async req => {
4715
+ // const cookies = req.cookies;
4716
+ // const auth = getAuth(cookies);
4717
+ // if (auth.error) {
4718
+ // return {
4719
+ // status: 401,
4720
+ // json: {
4721
+ // message: auth.error,
4722
+ // },
4723
+ // };
4724
+ // }
4725
+
4726
+ const profiles = await serverOps.getProfiles();
4727
+ return {
4728
+ status: 200,
4729
+ json: {
4730
+ profiles
4731
+ }
4732
+ };
4733
+ }
4734
+ },
4678
4735
  "/save": {
4679
4736
  POST: async req => {
4680
4737
  const cookies = req.cookies;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "types": "dist/valbuild-server.cjs.d.ts",
15
- "version": "0.68.0",
15
+ "version": "0.68.1",
16
16
  "scripts": {
17
17
  "typecheck": "tsc --noEmit",
18
18
  "test": "jest",
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@valbuild/core": "~0.68.0",
27
- "@valbuild/shared": "~0.68.0",
28
- "@valbuild/ui": "~0.68.0",
27
+ "@valbuild/shared": "~0.68.1",
28
+ "@valbuild/ui": "~0.68.1",
29
29
  "chokidar": "^4.0.1",
30
30
  "image-size": "^1.0.2",
31
31
  "minimatch": "^3.0.4",