@open-mercato/onboarding 0.6.6-develop.5431.1.384a97c7a2 → 0.6.6-develop.5483.1.a1129165ea
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/onboarding/__integration__/TC-ONB-002-multi-tenant-parallel-login.spec.js +158 -0
- package/dist/modules/onboarding/__integration__/TC-ONB-002-multi-tenant-parallel-login.spec.js.map +7 -0
- package/dist/modules/onboarding/api/get/onboarding/status.js +2 -1
- package/dist/modules/onboarding/api/get/onboarding/status.js.map +2 -2
- package/dist/modules/onboarding/data/entities.js +3 -0
- package/dist/modules/onboarding/data/entities.js.map +2 -2
- package/dist/modules/onboarding/lib/deferred-provisioning.js +29 -13
- package/dist/modules/onboarding/lib/deferred-provisioning.js.map +2 -2
- package/dist/modules/onboarding/lib/preparation-claim.js +10 -0
- package/dist/modules/onboarding/lib/preparation-claim.js.map +7 -0
- package/dist/modules/onboarding/lib/service.js +31 -0
- package/dist/modules/onboarding/lib/service.js.map +2 -2
- package/dist/modules/onboarding/migrations/Migration20260611120000.js +13 -0
- package/dist/modules/onboarding/migrations/Migration20260611120000.js.map +7 -0
- package/generated/entities/onboarding_request/index.ts +1 -0
- package/generated/entity-fields-registry.ts +1 -0
- package/package.json +3 -3
- package/src/__tests__/deferred-provisioning.test.ts +210 -0
- package/src/__tests__/status-endpoint-auth.test.ts +38 -0
- package/src/modules/onboarding/__integration__/TC-ONB-002-multi-tenant-parallel-login.spec.ts +198 -0
- package/src/modules/onboarding/api/get/onboarding/status.ts +11 -1
- package/src/modules/onboarding/data/entities.ts +3 -0
- package/src/modules/onboarding/lib/deferred-provisioning.ts +50 -13
- package/src/modules/onboarding/lib/preparation-claim.ts +6 -0
- package/src/modules/onboarding/lib/service.ts +33 -0
- package/src/modules/onboarding/migrations/.snapshot-open-mercato.json +10 -0
- package/src/modules/onboarding/migrations/Migration20260611120000.ts +13 -0
|
@@ -43,6 +43,7 @@ export class OnboardingService {
|
|
|
43
43
|
existing.organizationId = null
|
|
44
44
|
existing.userId = null
|
|
45
45
|
existing.lastEmailSentAt = now
|
|
46
|
+
existing.preparationStartedAt = null
|
|
46
47
|
existing.preparationCompletedAt = null
|
|
47
48
|
existing.readyEmailSentAt = null
|
|
48
49
|
await this.em.flush()
|
|
@@ -144,8 +145,40 @@ export class OnboardingService {
|
|
|
144
145
|
await this.em.flush()
|
|
145
146
|
}
|
|
146
147
|
|
|
148
|
+
async claimPreparation(requestId: string, claimedAt: Date, staleBefore: Date): Promise<boolean> {
|
|
149
|
+
const claimedRows = await this.em.nativeUpdate(
|
|
150
|
+
OnboardingRequest,
|
|
151
|
+
{
|
|
152
|
+
id: requestId,
|
|
153
|
+
status: 'completed',
|
|
154
|
+
preparationCompletedAt: null,
|
|
155
|
+
$or: [
|
|
156
|
+
{ preparationStartedAt: null },
|
|
157
|
+
{ preparationStartedAt: { $lt: staleBefore } },
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
{ preparationStartedAt: claimedAt, updatedAt: new Date() },
|
|
161
|
+
)
|
|
162
|
+
return claimedRows > 0
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async renewPreparation(requestId: string, renewedAt: Date): Promise<boolean> {
|
|
166
|
+
const renewedRows = await this.em.nativeUpdate(
|
|
167
|
+
OnboardingRequest,
|
|
168
|
+
{
|
|
169
|
+
id: requestId,
|
|
170
|
+
status: 'completed',
|
|
171
|
+
preparationCompletedAt: null,
|
|
172
|
+
preparationStartedAt: { $ne: null },
|
|
173
|
+
},
|
|
174
|
+
{ preparationStartedAt: renewedAt, updatedAt: new Date() },
|
|
175
|
+
)
|
|
176
|
+
return renewedRows > 0
|
|
177
|
+
}
|
|
178
|
+
|
|
147
179
|
async markPreparationCompleted(request: OnboardingRequest, completedAt: Date) {
|
|
148
180
|
request.preparationCompletedAt = completedAt
|
|
181
|
+
request.preparationStartedAt = null
|
|
149
182
|
await this.em.flush()
|
|
150
183
|
}
|
|
151
184
|
}
|
|
@@ -176,6 +176,16 @@
|
|
|
176
176
|
"length": 6,
|
|
177
177
|
"mappedType": "datetime"
|
|
178
178
|
},
|
|
179
|
+
"preparation_started_at": {
|
|
180
|
+
"name": "preparation_started_at",
|
|
181
|
+
"type": "timestamptz",
|
|
182
|
+
"unsigned": false,
|
|
183
|
+
"autoincrement": false,
|
|
184
|
+
"primary": false,
|
|
185
|
+
"nullable": true,
|
|
186
|
+
"length": 6,
|
|
187
|
+
"mappedType": "datetime"
|
|
188
|
+
},
|
|
179
189
|
"preparation_completed_at": {
|
|
180
190
|
"name": "preparation_completed_at",
|
|
181
191
|
"type": "timestamptz",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
|
|
3
|
+
export class Migration20260611120000 extends Migration {
|
|
4
|
+
|
|
5
|
+
override async up(): Promise<void> {
|
|
6
|
+
this.addSql(`alter table "onboarding_requests" add column "preparation_started_at" timestamptz null;`);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
override async down(): Promise<void> {
|
|
10
|
+
this.addSql(`alter table "onboarding_requests" drop column "preparation_started_at";`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|