Skip to content

Commit 6e0f707

Browse files
authored
feat: Add salto_ks_user_not_subscribed warning (#1056)
1 parent 0158f7d commit 6e0f707

File tree

3 files changed

+298
-72
lines changed

3 files changed

+298
-72
lines changed

src/lib/seam/connect/models/acs/acs-user.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,30 @@ const acs_users_being_deleted = common_acs_users_warning.extend({
2222
warning_code: z.literal('being_deleted'),
2323
})
2424

25+
const acs_users_salto_ks_user_not_subscribed = common_acs_users_warning.extend({
26+
warning_code: z.literal('salto_ks_user_not_subscribed'),
27+
})
28+
29+
// TODO: Some acs_users already have this warning, so we need to keep it here until we migrate
30+
const acs_users_salto_site_user_suspended = common_acs_users_warning.extend({
31+
warning_code: z.literal('salto_site_user_suspended'),
32+
})
33+
2534
export const acs_users_warning_map = z.object({
2635
being_deleted: acs_users_being_deleted.optional().nullable(),
36+
salto_ks_user_not_subscribed: acs_users_salto_ks_user_not_subscribed
37+
.optional()
38+
.nullable(),
39+
salto_site_user_suspended: acs_users_salto_site_user_suspended
40+
.optional()
41+
.nullable(),
2742
})
2843

29-
export const acs_users_warning =
30-
// TODO: once we have more than one warning we should use z.union
31-
// z.union([
32-
acs_users_being_deleted
33-
// ])
44+
export const acs_users_warning = z.union([
45+
acs_users_being_deleted,
46+
acs_users_salto_ks_user_not_subscribed,
47+
acs_users_salto_site_user_suspended,
48+
])
3449

3550
export type AcsUsersWarningMap = z.infer<typeof acs_users_warning_map>
3651

@@ -67,6 +82,7 @@ const common_acs_user = z
6782
.optional(),
6883
is_latest_desired_state_synced_with_provider: z.boolean().optional(),
6984
warnings: z.array(acs_users_warning),
85+
errors: z.any(),
7086
})
7187
.merge(user_fields)
7288

src/lib/seam/connect/openapi.ts

Lines changed: 151 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ export default {
695695
'x-deprecated': 'use email_address.',
696696
},
697697
email_address: { format: 'email', type: 'string' },
698+
errors: {},
698699
external_type: {
699700
enum: [
700701
'pti_user',
@@ -722,13 +723,41 @@ export default {
722723
user_identity_phone_number: { nullable: true, type: 'string' },
723724
warnings: {
724725
items: {
725-
properties: {
726-
created_at: { format: 'date-time', type: 'string' },
727-
message: { type: 'string' },
728-
warning_code: { enum: ['being_deleted'], type: 'string' },
729-
},
730-
required: ['created_at', 'message', 'warning_code'],
731-
type: 'object',
726+
oneOf: [
727+
{
728+
properties: {
729+
created_at: { format: 'date-time', type: 'string' },
730+
message: { type: 'string' },
731+
warning_code: { enum: ['being_deleted'], type: 'string' },
732+
},
733+
required: ['created_at', 'message', 'warning_code'],
734+
type: 'object',
735+
},
736+
{
737+
properties: {
738+
created_at: { format: 'date-time', type: 'string' },
739+
message: { type: 'string' },
740+
warning_code: {
741+
enum: ['salto_ks_user_not_subscribed'],
742+
type: 'string',
743+
},
744+
},
745+
required: ['created_at', 'message', 'warning_code'],
746+
type: 'object',
747+
},
748+
{
749+
properties: {
750+
created_at: { format: 'date-time', type: 'string' },
751+
message: { type: 'string' },
752+
warning_code: {
753+
enum: ['salto_site_user_suspended'],
754+
type: 'string',
755+
},
756+
},
757+
required: ['created_at', 'message', 'warning_code'],
758+
type: 'object',
759+
},
760+
],
732761
},
733762
type: 'array',
734763
},
@@ -7630,6 +7659,7 @@ export default {
76307659
'x-deprecated': 'use email_address.',
76317660
},
76327661
email_address: { format: 'email', type: 'string' },
7662+
errors: { $ref: '#/components/schemas/access_code' },
76337663
external_type: {
76347664
enum: [
76357665
'pti_user',
@@ -7668,19 +7698,65 @@ export default {
76687698
},
76697699
warnings: {
76707700
items: {
7671-
properties: {
7672-
created_at: {
7673-
format: 'date-time',
7674-
type: 'string',
7701+
oneOf: [
7702+
{
7703+
properties: {
7704+
created_at: {
7705+
format: 'date-time',
7706+
type: 'string',
7707+
},
7708+
message: { type: 'string' },
7709+
warning_code: {
7710+
enum: ['being_deleted'],
7711+
type: 'string',
7712+
},
7713+
},
7714+
required: [
7715+
'created_at',
7716+
'message',
7717+
'warning_code',
7718+
],
7719+
type: 'object',
76757720
},
7676-
message: { type: 'string' },
7677-
warning_code: {
7678-
enum: ['being_deleted'],
7679-
type: 'string',
7721+
{
7722+
properties: {
7723+
created_at: {
7724+
format: 'date-time',
7725+
type: 'string',
7726+
},
7727+
message: { type: 'string' },
7728+
warning_code: {
7729+
enum: ['salto_ks_user_not_subscribed'],
7730+
type: 'string',
7731+
},
7732+
},
7733+
required: [
7734+
'created_at',
7735+
'message',
7736+
'warning_code',
7737+
],
7738+
type: 'object',
76807739
},
7681-
},
7682-
required: ['created_at', 'message', 'warning_code'],
7683-
type: 'object',
7740+
{
7741+
properties: {
7742+
created_at: {
7743+
format: 'date-time',
7744+
type: 'string',
7745+
},
7746+
message: { type: 'string' },
7747+
warning_code: {
7748+
enum: ['salto_site_user_suspended'],
7749+
type: 'string',
7750+
},
7751+
},
7752+
required: [
7753+
'created_at',
7754+
'message',
7755+
'warning_code',
7756+
],
7757+
type: 'object',
7758+
},
7759+
],
76847760
},
76857761
type: 'array',
76867762
},
@@ -7772,6 +7848,7 @@ export default {
77727848
'x-deprecated': 'use email_address.',
77737849
},
77747850
email_address: { format: 'email', type: 'string' },
7851+
errors: { $ref: '#/components/schemas/access_code' },
77757852
external_type: {
77767853
enum: [
77777854
'pti_user',
@@ -7810,23 +7887,65 @@ export default {
78107887
},
78117888
warnings: {
78127889
items: {
7813-
properties: {
7814-
created_at: {
7815-
format: 'date-time',
7816-
type: 'string',
7890+
oneOf: [
7891+
{
7892+
properties: {
7893+
created_at: {
7894+
format: 'date-time',
7895+
type: 'string',
7896+
},
7897+
message: { type: 'string' },
7898+
warning_code: {
7899+
enum: ['being_deleted'],
7900+
type: 'string',
7901+
},
7902+
},
7903+
required: [
7904+
'created_at',
7905+
'message',
7906+
'warning_code',
7907+
],
7908+
type: 'object',
78177909
},
7818-
message: { type: 'string' },
7819-
warning_code: {
7820-
enum: ['being_deleted'],
7821-
type: 'string',
7910+
{
7911+
properties: {
7912+
created_at: {
7913+
format: 'date-time',
7914+
type: 'string',
7915+
},
7916+
message: { type: 'string' },
7917+
warning_code: {
7918+
enum: ['salto_ks_user_not_subscribed'],
7919+
type: 'string',
7920+
},
7921+
},
7922+
required: [
7923+
'created_at',
7924+
'message',
7925+
'warning_code',
7926+
],
7927+
type: 'object',
7928+
},
7929+
{
7930+
properties: {
7931+
created_at: {
7932+
format: 'date-time',
7933+
type: 'string',
7934+
},
7935+
message: { type: 'string' },
7936+
warning_code: {
7937+
enum: ['salto_site_user_suspended'],
7938+
type: 'string',
7939+
},
7940+
},
7941+
required: [
7942+
'created_at',
7943+
'message',
7944+
'warning_code',
7945+
],
7946+
type: 'object',
78227947
},
7823-
},
7824-
required: [
7825-
'created_at',
7826-
'message',
7827-
'warning_code',
78287948
],
7829-
type: 'object',
78307949
},
78317950
type: 'array',
78327951
},

0 commit comments

Comments
 (0)