declapract-typescript-ehmpathy 0.38.0 → 0.39.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.
@@ -0,0 +1,33 @@
1
+ import type { DirectoryToPersistTo } from 'simple-on-disk-cache';
2
+ import { isPresent } from 'type-fns';
3
+
4
+ import { getConfig } from './getConfig';
5
+
6
+ /**
7
+ * .what = gets the project's default s3 bucket, based on config
8
+ */
9
+ export const getProjectBucket = async (): Promise<string> => {
10
+ const config = await getConfig();
11
+ const bucket = [
12
+ config.project,
13
+ config.aws.namespace,
14
+ config.environment.access,
15
+ ].join('-');
16
+ return bucket;
17
+ };
18
+
19
+ /**
20
+ * .what = gets the project's default cache directory, based on config
21
+ */
22
+ export const getCacheDirectory = async (
23
+ input: {
24
+ scope?: string;
25
+ } = {},
26
+ ): Promise<DirectoryToPersistTo> => ({
27
+ s3: {
28
+ bucket: await getProjectBucket(),
29
+ prefix: ['purpose=cache', input.scope ? `scope=${input.scope}` : undefined]
30
+ .filter(isPresent)
31
+ .join('/'),
32
+ },
33
+ });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.38.0",
5
+ "version": "0.39.1",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
@@ -1,19 +0,0 @@
1
- import { paramCase } from 'change-case';
2
- import { DomainObject } from 'domain-objects';
3
- import type { AsyncTask } from 'simple-async-tasks';
4
-
5
- import { getConfig } from './getConfig';
6
-
7
- export type ClassOf<T> = new (...args: any[]) => T;
8
-
9
- export const getQueueUrlForTask = async (
10
- task: ClassOf<DomainObject<AsyncTask>>,
11
- ) => {
12
- const config = await getConfig();
13
- const taskName = task.name;
14
- return [
15
- 'https://sqs.us-east-1.amazonaws.com',
16
- `/${config.aws.account}/`,
17
- `${config.project}-${config.environment.access}-${paramCase(taskName)}-llq`,
18
- ].join('');
19
- };