@takeshape/util 10.16.0 → 10.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/naming.d.ts +21 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +76 -0
- package/es/index.js +2 -1
- package/es/naming.js +65 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -46,4 +46,15 @@ Object.keys(_searchParams).forEach(function (key) {
|
|
|
46
46
|
return _searchParams[key];
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
+
});
|
|
50
|
+
var _naming = require("./naming");
|
|
51
|
+
Object.keys(_naming).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _naming[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _naming[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
49
60
|
});
|
package/dist/naming.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type NamingConfig = {
|
|
2
|
+
withVariant: boolean;
|
|
3
|
+
withRegion: boolean;
|
|
4
|
+
separator: string;
|
|
5
|
+
case?: 'kebabCase' | 'camelCase';
|
|
6
|
+
};
|
|
7
|
+
export type NamingParams = {
|
|
8
|
+
appName: string;
|
|
9
|
+
stage: {
|
|
10
|
+
env: string;
|
|
11
|
+
variant?: string;
|
|
12
|
+
};
|
|
13
|
+
region?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function prefixName(config: NamingConfig, params: NamingParams, name: string): string;
|
|
16
|
+
export declare function dynamoTableName(params: NamingParams, name: string): string;
|
|
17
|
+
export declare const sharedResourceName: (params: NamingParams, name: string) => string;
|
|
18
|
+
export declare function sharedBucketName(params: NamingParams, name: string): string;
|
|
19
|
+
export declare const sharedTopicName: (params: NamingParams, name: string) => string;
|
|
20
|
+
export declare function keyName(params: NamingParams, name: string): string;
|
|
21
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/naming.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,UAgClF;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,eAAO,MAAM,kBAAkB,gDAK7B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,eAAO,MAAM,eAAe,gDAAqB,CAAC;AAElD,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAElE"}
|
package/dist/naming.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dynamoTableName = dynamoTableName;
|
|
7
|
+
exports.keyName = keyName;
|
|
8
|
+
exports.prefixName = prefixName;
|
|
9
|
+
exports.sharedBucketName = sharedBucketName;
|
|
10
|
+
exports.sharedTopicName = exports.sharedResourceName = void 0;
|
|
11
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
12
|
+
var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function prefixName(config, params, name) {
|
|
15
|
+
const {
|
|
16
|
+
withVariant,
|
|
17
|
+
withRegion,
|
|
18
|
+
separator
|
|
19
|
+
} = config;
|
|
20
|
+
const {
|
|
21
|
+
appName,
|
|
22
|
+
stage: {
|
|
23
|
+
env,
|
|
24
|
+
variant
|
|
25
|
+
},
|
|
26
|
+
region
|
|
27
|
+
} = params;
|
|
28
|
+
const parts = [appName, env];
|
|
29
|
+
if (withVariant && env !== 'prod' && variant) {
|
|
30
|
+
parts.push(variant);
|
|
31
|
+
}
|
|
32
|
+
if (withRegion) {
|
|
33
|
+
if (!region) {
|
|
34
|
+
throw new Error('Cannot provide a region prefix without a region in context');
|
|
35
|
+
}
|
|
36
|
+
parts.push(region);
|
|
37
|
+
}
|
|
38
|
+
if (name === '*') {
|
|
39
|
+
parts.push(name);
|
|
40
|
+
} else if (config.case === 'kebabCase') {
|
|
41
|
+
parts.push((0, _kebabCase.default)(name));
|
|
42
|
+
} else if (config.case === 'camelCase') {
|
|
43
|
+
parts.push((0, _camelCase.default)(name));
|
|
44
|
+
} else {
|
|
45
|
+
parts.push(name);
|
|
46
|
+
}
|
|
47
|
+
return parts.join(separator);
|
|
48
|
+
}
|
|
49
|
+
function dynamoTableName(params, name) {
|
|
50
|
+
return prefixName({
|
|
51
|
+
withVariant: true,
|
|
52
|
+
withRegion: false,
|
|
53
|
+
separator: '--'
|
|
54
|
+
}, params, name);
|
|
55
|
+
}
|
|
56
|
+
const sharedResourceName = exports.sharedResourceName = prefixName.bind(null, {
|
|
57
|
+
withVariant: false,
|
|
58
|
+
withRegion: false,
|
|
59
|
+
separator: '--',
|
|
60
|
+
case: 'kebabCase'
|
|
61
|
+
});
|
|
62
|
+
function sharedBucketName(params, name) {
|
|
63
|
+
return prefixName({
|
|
64
|
+
withVariant: false,
|
|
65
|
+
withRegion: true,
|
|
66
|
+
separator: '--'
|
|
67
|
+
}, params, name);
|
|
68
|
+
}
|
|
69
|
+
const sharedTopicName = exports.sharedTopicName = sharedResourceName;
|
|
70
|
+
function keyName(params, name) {
|
|
71
|
+
return prefixName({
|
|
72
|
+
withVariant: true,
|
|
73
|
+
withRegion: false,
|
|
74
|
+
separator: '--'
|
|
75
|
+
}, params, name);
|
|
76
|
+
}
|
package/es/index.js
CHANGED
package/es/naming.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import camelCase from 'lodash/camelCase';
|
|
2
|
+
import kebabCase from 'lodash/kebabCase';
|
|
3
|
+
export function prefixName(config, params, name) {
|
|
4
|
+
const {
|
|
5
|
+
withVariant,
|
|
6
|
+
withRegion,
|
|
7
|
+
separator
|
|
8
|
+
} = config;
|
|
9
|
+
const {
|
|
10
|
+
appName,
|
|
11
|
+
stage: {
|
|
12
|
+
env,
|
|
13
|
+
variant
|
|
14
|
+
},
|
|
15
|
+
region
|
|
16
|
+
} = params;
|
|
17
|
+
const parts = [appName, env];
|
|
18
|
+
if (withVariant && env !== 'prod' && variant) {
|
|
19
|
+
parts.push(variant);
|
|
20
|
+
}
|
|
21
|
+
if (withRegion) {
|
|
22
|
+
if (!region) {
|
|
23
|
+
throw new Error('Cannot provide a region prefix without a region in context');
|
|
24
|
+
}
|
|
25
|
+
parts.push(region);
|
|
26
|
+
}
|
|
27
|
+
if (name === '*') {
|
|
28
|
+
parts.push(name);
|
|
29
|
+
} else if (config.case === 'kebabCase') {
|
|
30
|
+
parts.push(kebabCase(name));
|
|
31
|
+
} else if (config.case === 'camelCase') {
|
|
32
|
+
parts.push(camelCase(name));
|
|
33
|
+
} else {
|
|
34
|
+
parts.push(name);
|
|
35
|
+
}
|
|
36
|
+
return parts.join(separator);
|
|
37
|
+
}
|
|
38
|
+
export function dynamoTableName(params, name) {
|
|
39
|
+
return prefixName({
|
|
40
|
+
withVariant: true,
|
|
41
|
+
withRegion: false,
|
|
42
|
+
separator: '--'
|
|
43
|
+
}, params, name);
|
|
44
|
+
}
|
|
45
|
+
export const sharedResourceName = prefixName.bind(null, {
|
|
46
|
+
withVariant: false,
|
|
47
|
+
withRegion: false,
|
|
48
|
+
separator: '--',
|
|
49
|
+
case: 'kebabCase'
|
|
50
|
+
});
|
|
51
|
+
export function sharedBucketName(params, name) {
|
|
52
|
+
return prefixName({
|
|
53
|
+
withVariant: false,
|
|
54
|
+
withRegion: true,
|
|
55
|
+
separator: '--'
|
|
56
|
+
}, params, name);
|
|
57
|
+
}
|
|
58
|
+
export const sharedTopicName = sharedResourceName;
|
|
59
|
+
export function keyName(params, name) {
|
|
60
|
+
return prefixName({
|
|
61
|
+
withVariant: true,
|
|
62
|
+
withRegion: false,
|
|
63
|
+
separator: '--'
|
|
64
|
+
}, params, name);
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/util",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.18.1",
|
|
4
4
|
"description": "Shared utilities",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"shortid": "^2.2.16",
|
|
34
34
|
"tiny-invariant": "^1.2.0",
|
|
35
35
|
"url-parse": "^1.5.3",
|
|
36
|
-
"@takeshape/routing": "10.
|
|
36
|
+
"@takeshape/routing": "10.18.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/classnames": "^2.2.9",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/prismjs": "^1.16.2",
|
|
47
47
|
"@types/shortid": "^0.0.29",
|
|
48
48
|
"stripe": "13.8.0",
|
|
49
|
-
"@takeshape/typescript-jest-junit-reporter": "10.
|
|
49
|
+
"@takeshape/typescript-jest-junit-reporter": "10.18.1"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=18"
|