Skip to content

Commit

Permalink
fix: allow custom attributes for extensible types (#365)
Browse files Browse the repository at this point in the history
OKTA-550323 fix: allow custom attributes for extensible types
  • Loading branch information
oleksandrpravosudko-okta authored Dec 7, 2022
1 parent 79fbab9 commit 0956b83
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

### Bug Fixes

- [#329](https://github.com/okta/okta-sdk-nodejs/pull/360) Fixes path and type signature issues for MemoryStore.

- [#360](https://github.com/okta/okta-sdk-nodejs/pull/360) Fixes path and type signature issues for MemoryStore.
- [#365](https://github.com/okta/okta-sdk-nodejs/pull/365) Adds support for custom attributes in UserProfile and GroupProfile

# 6.5.0

Expand Down
18 changes: 18 additions & 0 deletions src/types/custom-attributes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*!
* Copyright (c) 2017-present, Okta, Inc. and/or its affiliates. All rights reserved.
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and limitations under the License.
*/


type CustomAttributeValue = boolean | number | string;

export {
CustomAttributeValue
};
2 changes: 2 additions & 0 deletions src/types/models/GroupProfile.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/types/models/InlineHookPayload.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/types/models/SmsTemplateTranslations.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/types/models/UserProfile.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions templates/model.d.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { {{extends}} } from './{{extends}}';
{{else}}
import { Resource } from '../resource';
{{/if}}
{{#if this.isExtensible}}
import { CustomAttributeValue } from '../custom-attributes';
{{/if}}
import { Client } from '../client';
{{#if (shouldGenerateOptionsType modelName)}}
{{#if properties.length}}
Expand Down Expand Up @@ -36,6 +39,9 @@ declare class {{modelName}} extends Resource {
{{/if}}
{{/unless}}
{{/each}}
{{#if this.isExtensible}}
[key: string]: CustomAttributeValue | CustomAttributeValue[]
{{/if}}

{{#each crud}}
{{#if (eq alias 'update')}}
Expand Down
10 changes: 10 additions & 0 deletions test/type/user-profile.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expectType } from 'tsd';

import { Client } from '../../src/types/client';
import { CustomAttributeValue } from '../../src/types/custom-attributes';
import { UserProfile } from './../../src/types/models/UserProfile.d';

const client = new Client();
const userProfile = new UserProfile({}, client);
expectType<CustomAttributeValue | CustomAttributeValue[]>(userProfile.customAttribute);
expectType<string>(userProfile.costCenter);
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4799,4 +4799,4 @@ z-schema@^4.2.2:
lodash.isequal "^4.5.0"
validator "^13.6.0"
optionalDependencies:
commander "^2.7.1"
commander "^2.7.1"

0 comments on commit 0956b83

Please sign in to comment.