From 4b8df890c76cb521605b6a8860b7f61e5cfe79ae Mon Sep 17 00:00:00 2001 From: fangming-ning-sp <42616890+fangming-ning-sp@users.noreply.github.com> Date: Thu, 27 Apr 2023 16:53:13 -0500 Subject: [PATCH 1/3] PLTCONN-2932: Add schema to inputs --- lib/commands/command.ts | 16 ++++++++++++++++ lib/commands/std-account-create.ts | 3 ++- lib/commands/std-account-delete.ts | 6 ++++-- lib/commands/std-account-disable.ts | 6 ++++-- lib/commands/std-account-discover-schema.ts | 9 ++------- lib/commands/std-account-enable.ts | 6 ++++-- lib/commands/std-account-list.ts | 3 ++- lib/commands/std-account-read.ts | 6 ++++-- lib/commands/std-account-unlock.ts | 6 ++++-- lib/commands/std-account-update.ts | 3 ++- lib/commands/std-entitlement-list.ts | 3 ++- lib/commands/std-entitlement-read.ts | 3 ++- 12 files changed, 48 insertions(+), 22 deletions(-) diff --git a/lib/commands/command.ts b/lib/commands/command.ts index a574699..bf69fed 100644 --- a/lib/commands/command.ts +++ b/lib/commands/command.ts @@ -41,6 +41,7 @@ export type SchemaAttribute = { name: string, description: string, type: string, + required: boolean, multi?: boolean, managed?: boolean, entitlement?: boolean @@ -132,3 +133,18 @@ export type ObjectOutput = { identity: string, uuid?: string } | { key: Key } export type CommandState = { [key: string]: any } + +/** + * Account schema + */ +export type AccountSchema = { groupAttribute: string } & EntitlementSchema + +/** + * Entitlement schema + */ +export type EntitlementSchema = { + type: string + displayAttribute: string + identityAttribute: string + attributes: SchemaAttribute[] +} diff --git a/lib/commands/std-account-create.ts b/lib/commands/std-account-create.ts index ecf5a38..5cc884b 100644 --- a/lib/commands/std-account-create.ts +++ b/lib/commands/std-account-create.ts @@ -1,6 +1,6 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, ObjectOutput } from './command' +import { AccountSchema, Attributes, ObjectOutput } from './command' /** * Input object of `std:account:create` command @@ -8,6 +8,7 @@ import { Attributes, ObjectOutput } from './command' export type StdAccountCreateInput = { identity?: string attributes: any + schema?: AccountSchema } /** diff --git a/lib/commands/std-account-delete.ts b/lib/commands/std-account-delete.ts index 58983a9..0c85ff1 100644 --- a/lib/commands/std-account-delete.ts +++ b/lib/commands/std-account-delete.ts @@ -1,11 +1,13 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import {ObjectInput} from "./command" +import {AccountSchema, ObjectInput} from "./command" /** * Input object of `std:account:delete` command */ -export type StdAccountDeleteInput = ObjectInput +export type StdAccountDeleteInput = ObjectInput & { + schema?: AccountSchema +} /** * Output object of `std:account:delete` command diff --git a/lib/commands/std-account-disable.ts b/lib/commands/std-account-disable.ts index 1aec456..30ce169 100644 --- a/lib/commands/std-account-disable.ts +++ b/lib/commands/std-account-disable.ts @@ -1,11 +1,13 @@ /* Copyright (c) 2022. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, ObjectInput, ObjectOutput } from './command' +import { AccountSchema, Attributes, ObjectInput, ObjectOutput } from './command' /** * Input object of `std:account:disable` command */ -export type StdAccountDisableInput = ObjectInput +export type StdAccountDisableInput = ObjectInput & { + schema?: AccountSchema +} /** * Output object of `std:account:disable` command diff --git a/lib/commands/std-account-discover-schema.ts b/lib/commands/std-account-discover-schema.ts index 9f6e15c..a2c9ed8 100644 --- a/lib/commands/std-account-discover-schema.ts +++ b/lib/commands/std-account-discover-schema.ts @@ -1,13 +1,8 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import { SchemaAttribute } from "./command"; +import { AccountSchema } from "./command"; /** * Output object of `std:account:discover-schema` command */ -export type StdAccountDiscoverSchemaOutput = { - displayAttribute: string - groupAttribute: string - identityAttribute: string - attributes: SchemaAttribute[] -} +export type StdAccountDiscoverSchemaOutput = AccountSchema diff --git a/lib/commands/std-account-enable.ts b/lib/commands/std-account-enable.ts index 3418933..0c73445 100644 --- a/lib/commands/std-account-enable.ts +++ b/lib/commands/std-account-enable.ts @@ -1,11 +1,13 @@ /* Copyright (c) 2022. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, ObjectInput, ObjectOutput } from './command' +import { AccountSchema, Attributes, ObjectInput, ObjectOutput } from './command' /** * Input object of `std:account:enable` command */ -export type StdAccountEnableInput = ObjectInput +export type StdAccountEnableInput = ObjectInput & { + schema?: AccountSchema +} /** * Output object of `std:account:enable` command diff --git a/lib/commands/std-account-list.ts b/lib/commands/std-account-list.ts index e00fab9..9917f13 100644 --- a/lib/commands/std-account-list.ts +++ b/lib/commands/std-account-list.ts @@ -1,6 +1,6 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, CommandState, ObjectOutput } from './command' +import { AccountSchema, Attributes, CommandState, ObjectOutput } from './command' /** * Input object of `std:account:list` command @@ -8,6 +8,7 @@ import { Attributes, CommandState, ObjectOutput } from './command' export type StdAccountListInput = { stateful?: boolean state?: CommandState + schema?: AccountSchema } /** diff --git a/lib/commands/std-account-read.ts b/lib/commands/std-account-read.ts index ac11f72..86d2ae1 100644 --- a/lib/commands/std-account-read.ts +++ b/lib/commands/std-account-read.ts @@ -1,11 +1,13 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, ObjectInput, ObjectOutput } from './command' +import { AccountSchema, Attributes, ObjectInput, ObjectOutput } from './command' /** * Input object of `std:account:read` command */ -export type StdAccountReadInput = ObjectInput +export type StdAccountReadInput = ObjectInput & { + schema?: AccountSchema +} /** * Output object of `std:account:read` command diff --git a/lib/commands/std-account-unlock.ts b/lib/commands/std-account-unlock.ts index 85b67af..844f339 100644 --- a/lib/commands/std-account-unlock.ts +++ b/lib/commands/std-account-unlock.ts @@ -1,11 +1,13 @@ /* Copyright (c) 2022. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, ObjectInput, ObjectOutput } from './command' +import { AccountSchema, Attributes, ObjectInput, ObjectOutput } from './command' /** * Input object of `std:account:unlock` command */ -export type StdAccountUnlockInput = ObjectInput +export type StdAccountUnlockInput = ObjectInput & { + schema?: AccountSchema +} /** * Output object of `std:account:unlock` command diff --git a/lib/commands/std-account-update.ts b/lib/commands/std-account-update.ts index dd2b977..4efdd64 100644 --- a/lib/commands/std-account-update.ts +++ b/lib/commands/std-account-update.ts @@ -1,6 +1,6 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, ObjectInput, ObjectOutput } from './command' +import { AccountSchema, Attributes, ObjectInput, ObjectOutput } from './command' export enum AttributeChangeOp { Add = 'Add', @@ -22,6 +22,7 @@ export type AttributeChange = { */ export type StdAccountUpdateInput = ObjectInput & { changes: AttributeChange[] + schema?: AccountSchema } /** diff --git a/lib/commands/std-entitlement-list.ts b/lib/commands/std-entitlement-list.ts index d18eae2..fa92831 100644 --- a/lib/commands/std-entitlement-list.ts +++ b/lib/commands/std-entitlement-list.ts @@ -1,6 +1,6 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, CommandState, ObjectOutput } from './command' +import { Attributes, CommandState, EntitlementSchema, ObjectOutput } from './command' /** * Input object of `std:entitlement:list` command @@ -9,6 +9,7 @@ export type StdEntitlementListInput = { type: string stateful?: boolean state?: CommandState + schema?: EntitlementSchema } /** diff --git a/lib/commands/std-entitlement-read.ts b/lib/commands/std-entitlement-read.ts index 95a7e1d..1a47543 100644 --- a/lib/commands/std-entitlement-read.ts +++ b/lib/commands/std-entitlement-read.ts @@ -1,12 +1,13 @@ /* Copyright (c) 2021. SailPoint Technologies, Inc. All rights reserved. */ -import { Attributes, ObjectInput, ObjectOutput } from './command' +import { Attributes, EntitlementSchema, ObjectInput, ObjectOutput } from './command' /** * Input object of `std:entitlement:read` command */ export type StdEntitlementReadInput = ObjectInput & { type: string + schema?: EntitlementSchema } /** From 9ea55c4026d06e995a860913556cbe887e980ada Mon Sep 17 00:00:00 2001 From: fangming-ning-sp <42616890+fangming-ning-sp@users.noreply.github.com> Date: Thu, 27 Apr 2023 17:05:35 -0500 Subject: [PATCH 2/3] PLTCONN-2932: Make required field optional --- lib/commands/command.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/command.ts b/lib/commands/command.ts index bf69fed..7f88a38 100644 --- a/lib/commands/command.ts +++ b/lib/commands/command.ts @@ -41,7 +41,7 @@ export type SchemaAttribute = { name: string, description: string, type: string, - required: boolean, + required?: boolean, multi?: boolean, managed?: boolean, entitlement?: boolean From 45303f5901165073b0174cee1b224d59af0a9cf7 Mon Sep 17 00:00:00 2001 From: fangming-ning-sp <42616890+fangming-ning-sp@users.noreply.github.com> Date: Thu, 27 Apr 2023 17:08:00 -0500 Subject: [PATCH 3/3] PLTCONN-2932: Extract common schema --- lib/commands/command.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/commands/command.ts b/lib/commands/command.ts index 7f88a38..4748d40 100644 --- a/lib/commands/command.ts +++ b/lib/commands/command.ts @@ -134,17 +134,25 @@ export type CommandState = { [key: string]: any } +/** + * The common schema + */ +export type Schema = { + displayAttribute: string + identityAttribute: string + attributes: SchemaAttribute[] +} + /** * Account schema */ -export type AccountSchema = { groupAttribute: string } & EntitlementSchema +export type AccountSchema = Schema & { + groupAttribute: string +} /** * Entitlement schema */ -export type EntitlementSchema = { +export type EntitlementSchema = Schema & { type: string - displayAttribute: string - identityAttribute: string - attributes: SchemaAttribute[] }