New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@almaclaine/cdk

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@almaclaine/cdk - npm Package Compare versions

Comparing version 0.0.48 to 0.0.49

3

cjs/package.json
{
"name": "@almaclaine/cdk",
"version": "0.0.47",
"version": "0.0.48",
"type": "commonjs",

@@ -14,3 +14,2 @@ "main": "cjs/src/index.js",

"@almaclaine/no-op": "0.0.6",
"@almaclaine/option": "0.0.17",
"@almaclaine/string": "0.0.2",

@@ -17,0 +16,0 @@ "@almaclaine/types": "0.0.17",

@@ -8,4 +8,8 @@ import { z } from 'zod';

type Stages = z.infer<typeof StageSchema>;
declare const StagesEnum: import("../../../../dist/libs/types/cjs/src/lib/literal-enum").LiteralEnum<"DEVE" | "TEST" | "PROD">;
export { DYNAMO_PRIMARY_KEY_NAME, DYNAMO_SORT_KEY_NAME, TAG_STAGE, StagesEnum, StageValues, StageSchema, };
declare const StagesEnum: import("../../../../dist/libs/types/esm/src/lib/literal-enum").LiteralEnum<"DEVE" | "TEST" | "PROD">;
declare function isStage(value: unknown): value is Stages;
declare function isProd(stage: Stages): boolean;
declare function isTest(stage: Stages): boolean;
declare function isDeve(stage: Stages): boolean;
export { DYNAMO_PRIMARY_KEY_NAME, DYNAMO_SORT_KEY_NAME, TAG_STAGE, StagesEnum, StageValues, StageSchema, isDeve, isProd, isTest, isStage, };
export type { Stages };

@@ -26,2 +26,14 @@ "use strict";

return StageSchema;
},
isDeve: function() {
return isDeve;
},
isProd: function() {
return isProd;
},
isTest: function() {
return isTest;
},
isStage: function() {
return isStage;
}

@@ -41,3 +53,15 @@ });

const StagesEnum = (0, _zod1.castEnum)(StageSchema);
function isStage(value) {
return StageSchema.safeParse(value).success;
}
function isProd(stage) {
return stage === StagesEnum.PROD;
}
function isTest(stage) {
return stage === StagesEnum.TEST;
}
function isDeve(stage) {
return stage === StagesEnum.DEVE;
}
//# sourceMappingURL=constants.js.map

@@ -14,4 +14,3 @@ "use strict";

const { value , name , scope } = options;
const tagManager = new _tags.Tags(scope);
const stage = tagManager.getStage();
const stage = _tags.Tags.getStage(scope);
new _awscdklib.CfnOutput(scope, (0, _cfnoutputsutils.concatStage)(name, stage), {

@@ -18,0 +17,0 @@ value

@@ -16,3 +16,3 @@ import type { UserPoolClient } from 'aws-cdk-lib/aws-cognito';

get userPool(): UserPool;
constructor(scope: Construct, { stackName, prod, userPoolName, }: CognitoConstructOptions<StackName, UserPoolName>);
constructor(scope: Construct, { stackName, userPoolName, }: CognitoConstructOptions<StackName, UserPoolName>);
private initialize;

@@ -19,0 +19,0 @@ private createUserPool;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let CognitoConstruct = class CognitoConstruct extends _constructs.Construct {

@@ -62,5 +63,5 @@ get userPoolClient() {

}
constructor(scope, { stackName , prod , userPoolName }){
constructor(scope, { stackName , userPoolName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -67,0 +68,0 @@ this.name = (0, _generateconstructnames.generateAuthName)(stackName, userPoolName);

@@ -21,3 +21,3 @@ import { Construct } from 'constructs';

get deadQueue(): DeadQueueConstruct<StackName, QueueName>;
constructor(scope: Construct, { stackName, prod, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, queueName, fifo, }: QueuePairConstructOptions<StackName, QueueName>);
constructor(scope: Construct, { stackName, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, queueName, fifo, }: QueuePairConstructOptions<StackName, QueueName>);
private initialize;

@@ -24,0 +24,0 @@ private createDeadQueue;

@@ -12,2 +12,3 @@ "use strict";

const _queueconstruct = require("./queue.construct");
const _tags = require("../../utils/tags");
let QueuePairConstruct = class QueuePairConstruct extends _constructs.Construct {

@@ -32,3 +33,2 @@ get queue() {

this._deadQueue = new _deadqueueconstruct.DeadQueueConstruct(this, {
prod: this.prod,
queueName: this.queueName,

@@ -46,3 +46,2 @@ stackName: this.name,

this._queue = new _queueconstruct.QueueConstruct(this, {
prod: this.prod,
stackName: this.name,

@@ -59,6 +58,6 @@ queueName: this.queueName,

}
constructor(scope, { stackName , prod , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , queueName , fifo }){
constructor(scope, { stackName , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , queueName , fifo }){
const _name = `${stackName}-queue-pair`;
super(scope, _name);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -65,0 +64,0 @@ this.name = _name;

@@ -28,3 +28,3 @@ import { Construct } from 'constructs';

get queue(): Queue;
constructor(scope: Construct, { stackName, prod, deadQueue, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, fifo, queueName, }: QueueConstructOptions<StackName, QueueName>);
constructor(scope: Construct, { stackName, deadQueue, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, fifo, queueName, }: QueueConstructOptions<StackName, QueueName>);
private initialize;

@@ -31,0 +31,0 @@ private createQueue;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../../utils/generate-construct-names");
const _tags = require("../../utils/tags");
let QueueConstruct = class QueueConstruct extends _constructs.Construct {

@@ -34,6 +35,6 @@ get queue() {

}
constructor(scope, { stackName , prod , deadQueue , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , fifo , queueName }){
constructor(scope, { stackName , deadQueue , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , fifo , queueName }){
const _name = (0, _generateconstructnames.generateQueueName)(stackName, queueName);
super(scope, _name);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -40,0 +41,0 @@ this.deadQueue = deadQueue;

@@ -15,3 +15,3 @@ import { Construct } from 'constructs';

get bucket(): Bucket;
constructor(scope: Construct, { stackName, prod, versioned, bucketName, }: S3ConstructOptions<StackName, BucketName>);
constructor(scope: Construct, { stackName, versioned, bucketName, }: S3ConstructOptions<StackName, BucketName>);
private initialize;

@@ -18,0 +18,0 @@ private createS3;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let S3Construct = class S3Construct extends _constructs.Construct {

@@ -32,5 +33,5 @@ get bucket() {

}
constructor(scope, { stackName , prod , versioned , bucketName }){
constructor(scope, { stackName , versioned , bucketName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -37,0 +38,0 @@ this.name = (0, _generateconstructnames.generateS3Name)(stackName, bucketName);

@@ -13,3 +13,3 @@ import { Construct } from 'constructs';

get table(): Table;
constructor(scope: Construct, { stackName, prod, tableName }: TableConstructProps<StackName, TableName>);
constructor(scope: Construct, { stackName, tableName }: TableConstructProps<StackName, TableName>);
private initialize;

@@ -16,0 +16,0 @@ private createTable;

@@ -13,2 +13,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let TableConstruct = class TableConstruct extends _constructs.Construct {

@@ -39,5 +40,5 @@ get table() {

}
constructor(scope, { stackName , prod , tableName }){
constructor(scope, { stackName , tableName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -44,0 +45,0 @@ this.name = (0, _generateconstructnames.generateTableName)(stackName, tableName);

@@ -11,2 +11,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let UserConstruct = class UserConstruct extends _constructs.Construct {

@@ -28,4 +29,3 @@ get user() {

super(scope, stackName);
var _options_prod;
this.prod = (_options_prod = options == null ? void 0 : options.prod) != null ? _options_prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -32,0 +32,0 @@ this.name = (0, _generateconstructnames.generateUserName)(stackName, userName);

type ConstructDefaultTypes<StackName extends string> = {
prod: boolean;
stackName: StackName;

@@ -4,0 +3,0 @@ };

import type { Construct } from 'constructs';
import type { TagManager } from 'aws-cdk-lib';
import type { Option } from '@almaclaine/option';
import type { Stages } from '../constants';
declare class Tags extends Map<string, string> {
constructor(struct: Construct);
private static setToMap;
fromTagManager(tags: TagManager): Tags;
declare class TagsMap extends Map<string, string> {
static fromTagsManager(tagManager: TagManager): TagsMap;
static addTagsToMap(tags: TagManager, map: TagsMap): TagsMap;
}
declare class Tags {
private tags;
private static getTagManager;
constructor(scope: Construct);
static addTagsToMap(tags: TagManager, map: TagsMap): TagsMap;
static fromTagsToMap(tags: TagManager): TagsMap;
isProd(): boolean;
static fromScopeToMap(scope: Construct): Map<string, string>;
static isProd(scope: Construct): boolean;
isDeve(): boolean;
static isDeve(scope: Construct): boolean;
isTest(): boolean;
static isTest(scope: Construct): boolean;
getOrError(key: string): string;
static getStageFromMap(map: TagsMap): Stages;
static getStage(scope: Construct): Stages;
getStage(): Stages;
static getMap(tags: TagManager): Map<string, string>;
static staticGetProp(tags: TagManager, key: string): Option<string>;
static getMapFromManager(tags: TagManager): TagsMap;
}
export { Tags };

@@ -9,21 +9,55 @@ "use strict";

const _awscdklib = require("aws-cdk-lib");
const _option = require("@almaclaine/option");
const _constants = require("../constants");
let Tags = class Tags extends Map {
static setToMap(tags, map) {
for (const obj of Object.values(tags)){
let TagsMap = class TagsMap extends Map {
static fromTagsManager(tagManager) {
const map = new TagsMap();
for (const obj of Object.values(tagManager)){
const { Key , Value } = obj;
map.set(Key, Value);
}
return map;
}
fromTagManager(tags) {
static addTagsToMap(tags, map) {
for (const obj of Object.values(tags)){
const { Key , Value } = obj;
this.set(Key, Value);
map.set(Key, Value);
}
Tags.setToMap(tags, this);
return this;
return map;
}
};
let Tags = class Tags {
static getTagManager(scope) {
const stack = _awscdklib.Stack.of(scope);
return stack.tags.renderTags();
}
static addTagsToMap(tags, map) {
return TagsMap.addTagsToMap(tags, map);
}
static fromTagsToMap(tags) {
return TagsMap.fromTagsManager(tags);
}
isProd() {
return this.getStage() === _constants.StagesEnum.PROD;
}
static fromScopeToMap(scope) {
const tags = Tags.getTagManager(scope);
return Tags.fromTagsToMap(tags);
}
static isProd(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.PROD;
}
isDeve() {
return this.getStage() === _constants.StagesEnum.DEVE;
}
static isDeve(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.DEVE;
}
isTest() {
return this.getStage() === _constants.StagesEnum.TEST;
}
static isTest(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.TEST;
}
getOrError(key) {
const value = this.get(key);
const value = this.tags.get(key);
if (!value) {

@@ -34,31 +68,24 @@ throw new Error(`Tag ${key} does not exist`);

}
getStage() {
const value = this.get(_constants.TAG_STAGE);
if (!value) {
throw new Error(`stage was not added as a tag`);
}
static getStageFromMap(map) {
const value = map.get(_constants.TAG_STAGE);
return _constants.StageSchema.parse(value);
}
static getMap(tags) {
const map = new Map();
Tags.setToMap(tags, map);
return map;
static getStage(scope) {
const map = Tags.fromScopeToMap(scope);
return Tags.getStageFromMap(map);
}
static staticGetProp(tags, key) {
const map = Tags.getMap(tags);
const res = map.get(key);
if (res) {
return (0, _option.some)(res);
} else {
return (0, _option.none)();
}
getStage() {
return Tags.getStageFromMap(this.tags);
}
constructor(struct){
super();
const stack = _awscdklib.Stack.of(struct);
const tags = stack.tags.renderTags();
this.fromTagManager(tags);
static getMapFromManager(tags) {
const map = new TagsMap();
return Tags.addTagsToMap(tags, map);
}
constructor(scope){
this.tags = new TagsMap();
const tagsManager = Tags.getTagManager(scope);
this.tags = TagsMap.fromTagsManager(tagsManager);
}
};
//# sourceMappingURL=tags.js.map
{
"name": "@almaclaine/cdk",
"version": "0.0.47",
"version": "0.0.48",
"type": "commonjs",

@@ -14,3 +14,2 @@ "main": "cjs/src/index.js",

"@almaclaine/no-op": "0.0.6",
"@almaclaine/option": "0.0.17",
"@almaclaine/string": "0.0.2",

@@ -17,0 +16,0 @@ "@almaclaine/types": "0.0.17",

@@ -9,3 +9,7 @@ import { z } from 'zod';

declare const StagesEnum: import("../../../../dist/libs/types/esm/src/lib/literal-enum").LiteralEnum<"DEVE" | "TEST" | "PROD">;
export { DYNAMO_PRIMARY_KEY_NAME, DYNAMO_SORT_KEY_NAME, TAG_STAGE, StagesEnum, StageValues, StageSchema, };
declare function isStage(value: unknown): value is Stages;
declare function isProd(stage: Stages): boolean;
declare function isTest(stage: Stages): boolean;
declare function isDeve(stage: Stages): boolean;
export { DYNAMO_PRIMARY_KEY_NAME, DYNAMO_SORT_KEY_NAME, TAG_STAGE, StagesEnum, StageValues, StageSchema, isDeve, isProd, isTest, isStage, };
export type { Stages };

@@ -26,2 +26,14 @@ "use strict";

return StageSchema;
},
isDeve: function() {
return isDeve;
},
isProd: function() {
return isProd;
},
isTest: function() {
return isTest;
},
isStage: function() {
return isStage;
}

@@ -41,3 +53,15 @@ });

const StagesEnum = (0, _zod1.castEnum)(StageSchema);
function isStage(value) {
return StageSchema.safeParse(value).success;
}
function isProd(stage) {
return stage === StagesEnum.PROD;
}
function isTest(stage) {
return stage === StagesEnum.TEST;
}
function isDeve(stage) {
return stage === StagesEnum.DEVE;
}
//# sourceMappingURL=constants.js.map

@@ -14,4 +14,3 @@ "use strict";

const { value , name , scope } = options;
const tagManager = new _tags.Tags(scope);
const stage = tagManager.getStage();
const stage = _tags.Tags.getStage(scope);
new _awscdklib.CfnOutput(scope, (0, _cfnoutputsutils.concatStage)(name, stage), {

@@ -18,0 +17,0 @@ value

@@ -16,3 +16,3 @@ import type { UserPoolClient } from 'aws-cdk-lib/aws-cognito';

get userPool(): UserPool;
constructor(scope: Construct, { stackName, prod, userPoolName, }: CognitoConstructOptions<StackName, UserPoolName>);
constructor(scope: Construct, { stackName, userPoolName, }: CognitoConstructOptions<StackName, UserPoolName>);
private initialize;

@@ -19,0 +19,0 @@ private createUserPool;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let CognitoConstruct = class CognitoConstruct extends _constructs.Construct {

@@ -62,5 +63,5 @@ get userPoolClient() {

}
constructor(scope, { stackName , prod , userPoolName }){
constructor(scope, { stackName , userPoolName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -67,0 +68,0 @@ this.name = (0, _generateconstructnames.generateAuthName)(stackName, userPoolName);

@@ -21,3 +21,3 @@ import { Construct } from 'constructs';

get deadQueue(): DeadQueueConstruct<StackName, QueueName>;
constructor(scope: Construct, { stackName, prod, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, queueName, fifo, }: QueuePairConstructOptions<StackName, QueueName>);
constructor(scope: Construct, { stackName, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, queueName, fifo, }: QueuePairConstructOptions<StackName, QueueName>);
private initialize;

@@ -24,0 +24,0 @@ private createDeadQueue;

@@ -12,2 +12,3 @@ "use strict";

const _queueconstruct = require("./queue.construct");
const _tags = require("../../utils/tags");
let QueuePairConstruct = class QueuePairConstruct extends _constructs.Construct {

@@ -32,3 +33,2 @@ get queue() {

this._deadQueue = new _deadqueueconstruct.DeadQueueConstruct(this, {
prod: this.prod,
queueName: this.queueName,

@@ -46,3 +46,2 @@ stackName: this.name,

this._queue = new _queueconstruct.QueueConstruct(this, {
prod: this.prod,
stackName: this.name,

@@ -59,6 +58,6 @@ queueName: this.queueName,

}
constructor(scope, { stackName , prod , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , queueName , fifo }){
constructor(scope, { stackName , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , queueName , fifo }){
const _name = `${stackName}-queue-pair`;
super(scope, _name);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -65,0 +64,0 @@ this.name = _name;

@@ -28,3 +28,3 @@ import { Construct } from 'constructs';

get queue(): Queue;
constructor(scope: Construct, { stackName, prod, deadQueue, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, fifo, queueName, }: QueueConstructOptions<StackName, QueueName>);
constructor(scope: Construct, { stackName, deadQueue, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, fifo, queueName, }: QueueConstructOptions<StackName, QueueName>);
private initialize;

@@ -31,0 +31,0 @@ private createQueue;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../../utils/generate-construct-names");
const _tags = require("../../utils/tags");
let QueueConstruct = class QueueConstruct extends _constructs.Construct {

@@ -34,6 +35,6 @@ get queue() {

}
constructor(scope, { stackName , prod , deadQueue , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , fifo , queueName }){
constructor(scope, { stackName , deadQueue , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , fifo , queueName }){
const _name = (0, _generateconstructnames.generateQueueName)(stackName, queueName);
super(scope, _name);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -40,0 +41,0 @@ this.deadQueue = deadQueue;

@@ -15,3 +15,3 @@ import { Construct } from 'constructs';

get bucket(): Bucket;
constructor(scope: Construct, { stackName, prod, versioned, bucketName, }: S3ConstructOptions<StackName, BucketName>);
constructor(scope: Construct, { stackName, versioned, bucketName, }: S3ConstructOptions<StackName, BucketName>);
private initialize;

@@ -18,0 +18,0 @@ private createS3;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let S3Construct = class S3Construct extends _constructs.Construct {

@@ -32,5 +33,5 @@ get bucket() {

}
constructor(scope, { stackName , prod , versioned , bucketName }){
constructor(scope, { stackName , versioned , bucketName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -37,0 +38,0 @@ this.name = (0, _generateconstructnames.generateS3Name)(stackName, bucketName);

@@ -13,3 +13,3 @@ import { Construct } from 'constructs';

get table(): Table;
constructor(scope: Construct, { stackName, prod, tableName }: TableConstructProps<StackName, TableName>);
constructor(scope: Construct, { stackName, tableName }: TableConstructProps<StackName, TableName>);
private initialize;

@@ -16,0 +16,0 @@ private createTable;

@@ -13,2 +13,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let TableConstruct = class TableConstruct extends _constructs.Construct {

@@ -39,5 +40,5 @@ get table() {

}
constructor(scope, { stackName , prod , tableName }){
constructor(scope, { stackName , tableName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -44,0 +45,0 @@ this.name = (0, _generateconstructnames.generateTableName)(stackName, tableName);

@@ -11,2 +11,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let UserConstruct = class UserConstruct extends _constructs.Construct {

@@ -28,4 +29,3 @@ get user() {

super(scope, stackName);
var _options_prod;
this.prod = (_options_prod = options == null ? void 0 : options.prod) != null ? _options_prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -32,0 +32,0 @@ this.name = (0, _generateconstructnames.generateUserName)(stackName, userName);

type ConstructDefaultTypes<StackName extends string> = {
prod: boolean;
stackName: StackName;

@@ -4,0 +3,0 @@ };

import type { Construct } from 'constructs';
import type { TagManager } from 'aws-cdk-lib';
import type { Option } from '@almaclaine/option';
import type { Stages } from '../constants';
declare class Tags extends Map<string, string> {
constructor(struct: Construct);
private static setToMap;
fromTagManager(tags: TagManager): Tags;
declare class TagsMap extends Map<string, string> {
static fromTagsManager(tagManager: TagManager): TagsMap;
static addTagsToMap(tags: TagManager, map: TagsMap): TagsMap;
}
declare class Tags {
private tags;
private static getTagManager;
constructor(scope: Construct);
static addTagsToMap(tags: TagManager, map: TagsMap): TagsMap;
static fromTagsToMap(tags: TagManager): TagsMap;
isProd(): boolean;
static fromScopeToMap(scope: Construct): Map<string, string>;
static isProd(scope: Construct): boolean;
isDeve(): boolean;
static isDeve(scope: Construct): boolean;
isTest(): boolean;
static isTest(scope: Construct): boolean;
getOrError(key: string): string;
static getStageFromMap(map: TagsMap): Stages;
static getStage(scope: Construct): Stages;
getStage(): Stages;
static getMap(tags: TagManager): Map<string, string>;
static staticGetProp(tags: TagManager, key: string): Option<string>;
static getMapFromManager(tags: TagManager): TagsMap;
}
export { Tags };

@@ -9,21 +9,55 @@ "use strict";

const _awscdklib = require("aws-cdk-lib");
const _option = require("@almaclaine/option");
const _constants = require("../constants");
let Tags = class Tags extends Map {
static setToMap(tags, map) {
for (const obj of Object.values(tags)){
let TagsMap = class TagsMap extends Map {
static fromTagsManager(tagManager) {
const map = new TagsMap();
for (const obj of Object.values(tagManager)){
const { Key , Value } = obj;
map.set(Key, Value);
}
return map;
}
fromTagManager(tags) {
static addTagsToMap(tags, map) {
for (const obj of Object.values(tags)){
const { Key , Value } = obj;
this.set(Key, Value);
map.set(Key, Value);
}
Tags.setToMap(tags, this);
return this;
return map;
}
};
let Tags = class Tags {
static getTagManager(scope) {
const stack = _awscdklib.Stack.of(scope);
return stack.tags.renderTags();
}
static addTagsToMap(tags, map) {
return TagsMap.addTagsToMap(tags, map);
}
static fromTagsToMap(tags) {
return TagsMap.fromTagsManager(tags);
}
isProd() {
return this.getStage() === _constants.StagesEnum.PROD;
}
static fromScopeToMap(scope) {
const tags = Tags.getTagManager(scope);
return Tags.fromTagsToMap(tags);
}
static isProd(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.PROD;
}
isDeve() {
return this.getStage() === _constants.StagesEnum.DEVE;
}
static isDeve(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.DEVE;
}
isTest() {
return this.getStage() === _constants.StagesEnum.TEST;
}
static isTest(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.TEST;
}
getOrError(key) {
const value = this.get(key);
const value = this.tags.get(key);
if (!value) {

@@ -34,31 +68,24 @@ throw new Error(`Tag ${key} does not exist`);

}
getStage() {
const value = this.get(_constants.TAG_STAGE);
if (!value) {
throw new Error(`stage was not added as a tag`);
}
static getStageFromMap(map) {
const value = map.get(_constants.TAG_STAGE);
return _constants.StageSchema.parse(value);
}
static getMap(tags) {
const map = new Map();
Tags.setToMap(tags, map);
return map;
static getStage(scope) {
const map = Tags.fromScopeToMap(scope);
return Tags.getStageFromMap(map);
}
static staticGetProp(tags, key) {
const map = Tags.getMap(tags);
const res = map.get(key);
if (res) {
return (0, _option.some)(res);
} else {
return (0, _option.none)();
}
getStage() {
return Tags.getStageFromMap(this.tags);
}
constructor(struct){
super();
const stack = _awscdklib.Stack.of(struct);
const tags = stack.tags.renderTags();
this.fromTagManager(tags);
static getMapFromManager(tags) {
const map = new TagsMap();
return Tags.addTagsToMap(tags, map);
}
constructor(scope){
this.tags = new TagsMap();
const tagsManager = Tags.getTagManager(scope);
this.tags = TagsMap.fromTagsManager(tagsManager);
}
};
//# sourceMappingURL=tags.js.map
{
"name": "@almaclaine/cdk",
"version": "0.0.48",
"version": "0.0.49",
"type": "commonjs",

@@ -14,3 +14,2 @@ "main": "cjs/src/index.js",

"@almaclaine/no-op": "0.0.6",
"@almaclaine/option": "0.0.17",
"@almaclaine/string": "0.0.2",

@@ -17,0 +16,0 @@ "@almaclaine/types": "0.0.17",

@@ -9,3 +9,7 @@ import { z } from 'zod';

declare const StagesEnum: import("../../../../dist/libs/types/src/lib/literal-enum").LiteralEnum<"DEVE" | "TEST" | "PROD">;
export { DYNAMO_PRIMARY_KEY_NAME, DYNAMO_SORT_KEY_NAME, TAG_STAGE, StagesEnum, StageValues, StageSchema, };
declare function isStage(value: unknown): value is Stages;
declare function isProd(stage: Stages): boolean;
declare function isTest(stage: Stages): boolean;
declare function isDeve(stage: Stages): boolean;
export { DYNAMO_PRIMARY_KEY_NAME, DYNAMO_SORT_KEY_NAME, TAG_STAGE, StagesEnum, StageValues, StageSchema, isDeve, isProd, isTest, isStage, };
export type { Stages };

@@ -26,2 +26,14 @@ "use strict";

return StageSchema;
},
isDeve: function() {
return isDeve;
},
isProd: function() {
return isProd;
},
isTest: function() {
return isTest;
},
isStage: function() {
return isStage;
}

@@ -41,3 +53,15 @@ });

const StagesEnum = (0, _zod1.castEnum)(StageSchema);
function isStage(value) {
return StageSchema.safeParse(value).success;
}
function isProd(stage) {
return stage === StagesEnum.PROD;
}
function isTest(stage) {
return stage === StagesEnum.TEST;
}
function isDeve(stage) {
return stage === StagesEnum.DEVE;
}
//# sourceMappingURL=constants.js.map

@@ -14,4 +14,3 @@ "use strict";

const { value , name , scope } = options;
const tagManager = new _tags.Tags(scope);
const stage = tagManager.getStage();
const stage = _tags.Tags.getStage(scope);
new _awscdklib.CfnOutput(scope, (0, _cfnoutputsutils.concatStage)(name, stage), {

@@ -18,0 +17,0 @@ value

@@ -16,3 +16,3 @@ import type { UserPoolClient } from 'aws-cdk-lib/aws-cognito';

get userPool(): UserPool;
constructor(scope: Construct, { stackName, prod, userPoolName, }: CognitoConstructOptions<StackName, UserPoolName>);
constructor(scope: Construct, { stackName, userPoolName, }: CognitoConstructOptions<StackName, UserPoolName>);
private initialize;

@@ -19,0 +19,0 @@ private createUserPool;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let CognitoConstruct = class CognitoConstruct extends _constructs.Construct {

@@ -62,5 +63,5 @@ get userPoolClient() {

}
constructor(scope, { stackName , prod , userPoolName }){
constructor(scope, { stackName , userPoolName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -67,0 +68,0 @@ this.name = (0, _generateconstructnames.generateAuthName)(stackName, userPoolName);

@@ -21,3 +21,3 @@ import { Construct } from 'constructs';

get deadQueue(): DeadQueueConstruct<StackName, QueueName>;
constructor(scope: Construct, { stackName, prod, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, queueName, fifo, }: QueuePairConstructOptions<StackName, QueueName>);
constructor(scope: Construct, { stackName, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, queueName, fifo, }: QueuePairConstructOptions<StackName, QueueName>);
private initialize;

@@ -24,0 +24,0 @@ private createDeadQueue;

@@ -12,2 +12,3 @@ "use strict";

const _queueconstruct = require("./queue.construct");
const _tags = require("../../utils/tags");
let QueuePairConstruct = class QueuePairConstruct extends _constructs.Construct {

@@ -32,3 +33,2 @@ get queue() {

this._deadQueue = new _deadqueueconstruct.DeadQueueConstruct(this, {
prod: this.prod,
queueName: this.queueName,

@@ -46,3 +46,2 @@ stackName: this.name,

this._queue = new _queueconstruct.QueueConstruct(this, {
prod: this.prod,
stackName: this.name,

@@ -59,6 +58,6 @@ queueName: this.queueName,

}
constructor(scope, { stackName , prod , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , queueName , fifo }){
constructor(scope, { stackName , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , queueName , fifo }){
const _name = `${stackName}-queue-pair`;
super(scope, _name);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -65,0 +64,0 @@ this.name = _name;

@@ -28,3 +28,3 @@ import { Construct } from 'constructs';

get queue(): Queue;
constructor(scope: Construct, { stackName, prod, deadQueue, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, fifo, queueName, }: QueueConstructOptions<StackName, QueueName>);
constructor(scope: Construct, { stackName, deadQueue, retentionPeriod, visibilityTimeout, receiveMessageWaitTime, fifo, queueName, }: QueueConstructOptions<StackName, QueueName>);
private initialize;

@@ -31,0 +31,0 @@ private createQueue;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../../utils/generate-construct-names");
const _tags = require("../../utils/tags");
let QueueConstruct = class QueueConstruct extends _constructs.Construct {

@@ -34,6 +35,6 @@ get queue() {

}
constructor(scope, { stackName , prod , deadQueue , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , fifo , queueName }){
constructor(scope, { stackName , deadQueue , retentionPeriod , visibilityTimeout , receiveMessageWaitTime , fifo , queueName }){
const _name = (0, _generateconstructnames.generateQueueName)(stackName, queueName);
super(scope, _name);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -40,0 +41,0 @@ this.deadQueue = deadQueue;

@@ -15,3 +15,3 @@ import { Construct } from 'constructs';

get bucket(): Bucket;
constructor(scope: Construct, { stackName, prod, versioned, bucketName, }: S3ConstructOptions<StackName, BucketName>);
constructor(scope: Construct, { stackName, versioned, bucketName, }: S3ConstructOptions<StackName, BucketName>);
private initialize;

@@ -18,0 +18,0 @@ private createS3;

@@ -12,2 +12,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let S3Construct = class S3Construct extends _constructs.Construct {

@@ -32,5 +33,5 @@ get bucket() {

}
constructor(scope, { stackName , prod , versioned , bucketName }){
constructor(scope, { stackName , versioned , bucketName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -37,0 +38,0 @@ this.name = (0, _generateconstructnames.generateS3Name)(stackName, bucketName);

@@ -13,3 +13,3 @@ import { Construct } from 'constructs';

get table(): Table;
constructor(scope: Construct, { stackName, prod, tableName }: TableConstructProps<StackName, TableName>);
constructor(scope: Construct, { stackName, tableName }: TableConstructProps<StackName, TableName>);
private initialize;

@@ -16,0 +16,0 @@ private createTable;

@@ -13,2 +13,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let TableConstruct = class TableConstruct extends _constructs.Construct {

@@ -39,5 +40,5 @@ get table() {

}
constructor(scope, { stackName , prod , tableName }){
constructor(scope, { stackName , tableName }){
super(scope, stackName);
this.prod = prod != null ? prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -44,0 +45,0 @@ this.name = (0, _generateconstructnames.generateTableName)(stackName, tableName);

@@ -11,2 +11,3 @@ "use strict";

const _generateconstructnames = require("../utils/generate-construct-names");
const _tags = require("../utils/tags");
let UserConstruct = class UserConstruct extends _constructs.Construct {

@@ -28,4 +29,3 @@ get user() {

super(scope, stackName);
var _options_prod;
this.prod = (_options_prod = options == null ? void 0 : options.prod) != null ? _options_prod : false;
this.prod = _tags.Tags.isProd(scope);
this.scope = scope;

@@ -32,0 +32,0 @@ this.name = (0, _generateconstructnames.generateUserName)(stackName, userName);

type ConstructDefaultTypes<StackName extends string> = {
prod: boolean;
stackName: StackName;

@@ -4,0 +3,0 @@ };

import type { Construct } from 'constructs';
import type { TagManager } from 'aws-cdk-lib';
import type { Option } from '@almaclaine/option';
import type { Stages } from '../constants';
declare class Tags extends Map<string, string> {
constructor(struct: Construct);
private static setToMap;
fromTagManager(tags: TagManager): Tags;
declare class TagsMap extends Map<string, string> {
static fromTagsManager(tagManager: TagManager): TagsMap;
static addTagsToMap(tags: TagManager, map: TagsMap): TagsMap;
}
declare class Tags {
private tags;
private static getTagManager;
constructor(scope: Construct);
static addTagsToMap(tags: TagManager, map: TagsMap): TagsMap;
static fromTagsToMap(tags: TagManager): TagsMap;
isProd(): boolean;
static fromScopeToMap(scope: Construct): Map<string, string>;
static isProd(scope: Construct): boolean;
isDeve(): boolean;
static isDeve(scope: Construct): boolean;
isTest(): boolean;
static isTest(scope: Construct): boolean;
getOrError(key: string): string;
static getStageFromMap(map: TagsMap): Stages;
static getStage(scope: Construct): Stages;
getStage(): Stages;
static getMap(tags: TagManager): Map<string, string>;
static staticGetProp(tags: TagManager, key: string): Option<string>;
static getMapFromManager(tags: TagManager): TagsMap;
}
export { Tags };

@@ -9,21 +9,55 @@ "use strict";

const _awscdklib = require("aws-cdk-lib");
const _option = require("@almaclaine/option");
const _constants = require("../constants");
let Tags = class Tags extends Map {
static setToMap(tags, map) {
for (const obj of Object.values(tags)){
let TagsMap = class TagsMap extends Map {
static fromTagsManager(tagManager) {
const map = new TagsMap();
for (const obj of Object.values(tagManager)){
const { Key , Value } = obj;
map.set(Key, Value);
}
return map;
}
fromTagManager(tags) {
static addTagsToMap(tags, map) {
for (const obj of Object.values(tags)){
const { Key , Value } = obj;
this.set(Key, Value);
map.set(Key, Value);
}
Tags.setToMap(tags, this);
return this;
return map;
}
};
let Tags = class Tags {
static getTagManager(scope) {
const stack = _awscdklib.Stack.of(scope);
return stack.tags.renderTags();
}
static addTagsToMap(tags, map) {
return TagsMap.addTagsToMap(tags, map);
}
static fromTagsToMap(tags) {
return TagsMap.fromTagsManager(tags);
}
isProd() {
return this.getStage() === _constants.StagesEnum.PROD;
}
static fromScopeToMap(scope) {
const tags = Tags.getTagManager(scope);
return Tags.fromTagsToMap(tags);
}
static isProd(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.PROD;
}
isDeve() {
return this.getStage() === _constants.StagesEnum.DEVE;
}
static isDeve(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.DEVE;
}
isTest() {
return this.getStage() === _constants.StagesEnum.TEST;
}
static isTest(scope) {
return Tags.getStage(scope) === _constants.StagesEnum.TEST;
}
getOrError(key) {
const value = this.get(key);
const value = this.tags.get(key);
if (!value) {

@@ -34,31 +68,24 @@ throw new Error(`Tag ${key} does not exist`);

}
getStage() {
const value = this.get(_constants.TAG_STAGE);
if (!value) {
throw new Error(`stage was not added as a tag`);
}
static getStageFromMap(map) {
const value = map.get(_constants.TAG_STAGE);
return _constants.StageSchema.parse(value);
}
static getMap(tags) {
const map = new Map();
Tags.setToMap(tags, map);
return map;
static getStage(scope) {
const map = Tags.fromScopeToMap(scope);
return Tags.getStageFromMap(map);
}
static staticGetProp(tags, key) {
const map = Tags.getMap(tags);
const res = map.get(key);
if (res) {
return (0, _option.some)(res);
} else {
return (0, _option.none)();
}
getStage() {
return Tags.getStageFromMap(this.tags);
}
constructor(struct){
super();
const stack = _awscdklib.Stack.of(struct);
const tags = stack.tags.renderTags();
this.fromTagManager(tags);
static getMapFromManager(tags) {
const map = new TagsMap();
return Tags.addTagsToMap(tags, map);
}
constructor(scope){
this.tags = new TagsMap();
const tagsManager = Tags.getTagManager(scope);
this.tags = TagsMap.fromTagsManager(tagsManager);
}
};
//# sourceMappingURL=tags.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc