diff --git a/API.md b/API.md index dce009d..e9af9ba 100644 --- a/API.md +++ b/API.md @@ -1,6 +1,63 @@ # API Reference +## Structs + +### ResourceAutoNaming + +#### Initializer + +```typescript +import { ResourceAutoNaming } from '@gammarers/aws-resource-naming' + +const resourceAutoNaming: ResourceAutoNaming = { ... } +``` + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| type | ResourceNamingType | *No description.* | + +--- + +##### `type`Required + +```typescript +public readonly type: ResourceNamingType; +``` + +- *Type:* ResourceNamingType + +--- + +### ResourceDefaultNaming + +#### Initializer + +```typescript +import { ResourceDefaultNaming } from '@gammarers/aws-resource-naming' + +const resourceDefaultNaming: ResourceDefaultNaming = { ... } +``` + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| type | ResourceNamingType | *No description.* | + +--- + +##### `type`Required + +```typescript +public readonly type: ResourceNamingType; +``` + +- *Type:* ResourceNamingType + +--- diff --git a/src/index.ts b/src/index.ts index 2a6a6e9..327e499 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,11 +14,11 @@ export enum ResourceNamingType { CUSTOM = 'Custom', } -export type ResourceAutoNaming = { +export interface ResourceAutoNaming { readonly type: ResourceNamingType.AUTO; } -export type ResourceDefaultNaming = { +export interface ResourceDefaultNaming { readonly type: ResourceNamingType.DEFAULT; } @@ -64,6 +64,7 @@ export namespace ResourceNaming { // function getValueByKey(obj: MyObject, key: K): MyObject[K] { // return obj[key]; // } + type ResourceNamingOption = ResourceAutoNaming | ResourceDefaultNaming | {type: ResourceNamingType.CUSTOM; [key: string]: string}; // export type NamingOptions = { // naming: ResourceNaming.AutoNaming | ResourceNaming.DefaultNaming | {type: ResourceNaming.NamingType.CUSTOM; names: {[key: string]: string}}; @@ -79,7 +80,7 @@ export namespace ResourceNaming { // resourceNaming?: { // naming: ResourceNaming.AutoNaming | ResourceNaming.DefaultNaming | {type: ResourceNaming.NamingType.CUSTOM; names: {[key: string]: string}}; // }) { - resourceNaming?: ResourceAutoNaming | ResourceDefaultNaming | {type: ResourceNamingType.CUSTOM; [key: string]: string}) { + resourceNaming?: ResourceNamingOption) { return Object.fromEntries( Object.entries(autoNaming).map(([name, value]) => { return [name, (() => { diff --git a/test/naming.test.ts b/test/naming.test.ts index 90e73e7..6eca1bb 100644 --- a/test/naming.test.ts +++ b/test/naming.test.ts @@ -18,7 +18,7 @@ describe('ResouceNaming Testing', () => { functionRoleName: `${random}-func-exc-role`, }; - type CustomNaming = { + interface CustomNaming { readonly type: ResourceNamingType.CUSTOM; readonly functionName: 'example-function'; readonly functionRoleName: 'example-role'; @@ -52,7 +52,7 @@ describe('ResouceNaming Testing', () => { }); it('Is Namings', () => { - const options: ResourceNamingOption = { + const options = { type: ResourceNamingType.CUSTOM, functionName: 'example-function', functionRoleName: 'example-role',