@stamhoofd/backend 2.21.1 → 2.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stamhoofd/backend",
3
- "version": "2.21.1",
3
+ "version": "2.22.0",
4
4
  "main": "./dist/index.js",
5
5
  "exports": {
6
6
  ".": {
@@ -36,14 +36,14 @@
36
36
  "@simonbackx/simple-encoding": "2.15.0",
37
37
  "@simonbackx/simple-endpoints": "1.14.0",
38
38
  "@simonbackx/simple-logging": "^1.0.1",
39
- "@stamhoofd/backend-i18n": "2.21.1",
40
- "@stamhoofd/backend-middleware": "2.21.1",
41
- "@stamhoofd/email": "2.21.1",
42
- "@stamhoofd/models": "2.21.1",
43
- "@stamhoofd/queues": "2.21.1",
44
- "@stamhoofd/sql": "2.21.1",
45
- "@stamhoofd/structures": "2.21.1",
46
- "@stamhoofd/utility": "2.21.1",
39
+ "@stamhoofd/backend-i18n": "2.22.0",
40
+ "@stamhoofd/backend-middleware": "2.22.0",
41
+ "@stamhoofd/email": "2.22.0",
42
+ "@stamhoofd/models": "2.22.0",
43
+ "@stamhoofd/queues": "2.22.0",
44
+ "@stamhoofd/sql": "2.22.0",
45
+ "@stamhoofd/structures": "2.22.0",
46
+ "@stamhoofd/utility": "2.22.0",
47
47
  "archiver": "^7.0.1",
48
48
  "aws-sdk": "^2.885.0",
49
49
  "axios": "1.6.8",
@@ -60,5 +60,5 @@
60
60
  "postmark": "4.0.2",
61
61
  "stripe": "^16.6.0"
62
62
  },
63
- "gitHead": "5762f9e0dc07731e32a5d58fb83e4aa0e3da4fa9"
63
+ "gitHead": "b3590dcb37d7f65be2663b11a6f025cf5f36a278"
64
64
  }
@@ -54,6 +54,7 @@ export class PatchOrganizationEndpoint extends Endpoint<Params, Query, Body, Res
54
54
  }
55
55
 
56
56
  const errors = new SimpleErrors()
57
+ let shouldUpdateSetupSteps = false;
57
58
 
58
59
  if (await Context.auth.hasFullAccess(organization.id)) {
59
60
  organization.name = request.body.name ?? organization.name
@@ -102,7 +103,7 @@ export class PatchOrganizationEndpoint extends Endpoint<Params, Query, Body, Res
102
103
  organization.privateMeta.emails = request.body.privateMeta.emails.applyTo(organization.privateMeta.emails)
103
104
  organization.privateMeta.premises = patchObject(organization.privateMeta.premises, request.body.privateMeta.premises);
104
105
  if(request.body.privateMeta.premises) {
105
- await SetupStepUpdater.updateForOrganization(organization);
106
+ shouldUpdateSetupSteps = true;
106
107
  }
107
108
  organization.privateMeta.roles = request.body.privateMeta.roles.applyTo(organization.privateMeta.roles)
108
109
  organization.privateMeta.responsibilities = request.body.privateMeta.responsibilities.applyTo(organization.privateMeta.responsibilities)
@@ -215,6 +216,7 @@ export class PatchOrganizationEndpoint extends Endpoint<Params, Query, Body, Res
215
216
  if (request.body.meta) {
216
217
  if (request.body.meta.companies) {
217
218
  await this.validateCompanies(organization, request.body.meta.companies)
219
+ shouldUpdateSetupSteps = true
218
220
  }
219
221
 
220
222
  const savedPackages = organization.meta.packages
@@ -373,6 +375,11 @@ export class PatchOrganizationEndpoint extends Endpoint<Params, Query, Body, Res
373
375
  }
374
376
 
375
377
  errors.throwIfNotEmpty()
378
+
379
+ if(shouldUpdateSetupSteps) {
380
+ await SetupStepUpdater.updateForOrganization(organization);
381
+ }
382
+
376
383
  return new Response(await AuthenticatedStructures.organization(organization));
377
384
  }
378
385
 
@@ -21,7 +21,7 @@ export class SetupStepUpdater {
21
21
  SetupStepType,
22
22
  SetupStepOperation
23
23
  > = {
24
- [SetupStepType.Functions]: this.updateStepFunctions,
24
+ [SetupStepType.Responsibilities]: this.updateStepResponsibilities,
25
25
  [SetupStepType.Companies]: this.updateStepCompanies,
26
26
  [SetupStepType.Groups]: this.updateStepGroups,
27
27
  [SetupStepType.Premises]: this.updateStepPremises,
@@ -218,13 +218,20 @@ export class SetupStepUpdater {
218
218
  _organization: Organization,
219
219
  _platform: PlatformStruct
220
220
  ) {
221
+ const totalSteps = 1;
222
+ let finishedSteps = 0;
223
+
224
+ if(_organization.meta.companies.length) {
225
+ finishedSteps = 1;
226
+ }
227
+
221
228
  setupSteps.update(SetupStepType.Companies, {
222
- totalSteps: 0,
223
- finishedSteps: 0,
229
+ totalSteps,
230
+ finishedSteps,
224
231
  });
225
232
  }
226
233
 
227
- private static async updateStepFunctions(
234
+ private static async updateStepResponsibilities(
228
235
  setupSteps: SetupSteps,
229
236
  organization: Organization,
230
237
  platform: PlatformStruct
@@ -304,7 +311,7 @@ export class SetupStepUpdater {
304
311
  finishedSteps++;
305
312
  }
306
313
 
307
- setupSteps.update(SetupStepType.Functions, {
314
+ setupSteps.update(SetupStepType.Responsibilities, {
308
315
  totalSteps,
309
316
  finishedSteps,
310
317
  });