@ntbjs/ntb-dam-utils 1.0.0
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/.editorconfig +17 -0
- package/.eslintrc.js +31 -0
- package/.husky/pre-commit +9 -0
- package/.lintstagedrc.js +26 -0
- package/.prettierrc +29 -0
- package/README.md +4 -0
- package/index.js +5 -0
- package/package.json +31 -0
- package/src/config/indexes.js +37 -0
- package/src/config/origins.js +44 -0
- package/src/config/owners.js +53 -0
- package/src/services/README.md +1 -0
- package/src/utils/README.md +1 -0
- package/test.js +6 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
indent_size = 2
|
|
7
|
+
indent_style = space
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
max_line_length = 100
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
|
|
12
|
+
[*.md]
|
|
13
|
+
max_line_length = 0
|
|
14
|
+
trim_trailing_whitespace = false
|
|
15
|
+
|
|
16
|
+
[COMMIT_EDITMSG]
|
|
17
|
+
max_line_length = 0
|
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
parser: "@babel/eslint-parser",
|
|
4
|
+
env: {
|
|
5
|
+
node: true,
|
|
6
|
+
es6: true
|
|
7
|
+
},
|
|
8
|
+
extends: ["eslint:recommended", "plugin:import/errors", "plugin:import/warnings"],
|
|
9
|
+
plugins: ["prettier", "import"],
|
|
10
|
+
rules: {
|
|
11
|
+
// Eslint importer rules for sorting imports
|
|
12
|
+
"import/no-unresolved": 1,
|
|
13
|
+
"import/named": 1,
|
|
14
|
+
"import/namespace": 1,
|
|
15
|
+
"import/no-named-as-default": 0,
|
|
16
|
+
"import/export": 1,
|
|
17
|
+
"import/no-cycle": 2,
|
|
18
|
+
"import/no-useless-path-segments": 1,
|
|
19
|
+
"import/order": [
|
|
20
|
+
1,
|
|
21
|
+
{
|
|
22
|
+
groups: ["builtin", "external", "parent", "sibling", "index"],
|
|
23
|
+
"newlines-between": "always-and-inside-groups",
|
|
24
|
+
alphabetize: {
|
|
25
|
+
order: "asc",
|
|
26
|
+
caseInsensitive: true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
# Fixes issues with running the git commit hook when using nvm in WSL2 or installed with Homebrew
|
|
5
|
+
# This loads nvm.sh and sets the correct PATH before running hook
|
|
6
|
+
export NVM_DIR="$HOME/.nvm"
|
|
7
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
8
|
+
|
|
9
|
+
npx lint-staged
|
package/.lintstagedrc.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { ESLint } = require("eslint");
|
|
2
|
+
|
|
3
|
+
const removeIgnoredFiles = async files => {
|
|
4
|
+
const eslint = new ESLint();
|
|
5
|
+
const isIgnored = await Promise.all(
|
|
6
|
+
files.map(file => {
|
|
7
|
+
return eslint.isPathIgnored(file);
|
|
8
|
+
})
|
|
9
|
+
);
|
|
10
|
+
const filteredFiles = files.filter((_, i) => !isIgnored[i]);
|
|
11
|
+
return filteredFiles.length ? filteredFiles.join(" ") : null;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
"**/*.js": async files => {
|
|
16
|
+
const filesToLint = await removeIgnoredFiles(files);
|
|
17
|
+
if (filesToLint) return [`eslint --fix --max-warnings=0 ${filesToLint}`];
|
|
18
|
+
return [];
|
|
19
|
+
},
|
|
20
|
+
"*.{css,scss}": "prettier --write",
|
|
21
|
+
"**/*.json": async files => {
|
|
22
|
+
const filesToLint = await removeIgnoredFiles(files);
|
|
23
|
+
if (filesToLint) return [`prettier --write ${filesToLint}`];
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
};
|
package/.prettierrc
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tabWidth": 2,
|
|
3
|
+
"singleQuote": false,
|
|
4
|
+
"trailingComma": "none",
|
|
5
|
+
"printWidth": 100,
|
|
6
|
+
"bracketSpacing": true,
|
|
7
|
+
"jsxBracketSameLine": false,
|
|
8
|
+
"semi": true,
|
|
9
|
+
"requirePragma": false,
|
|
10
|
+
"proseWrap": "preserve",
|
|
11
|
+
"arrowParens": "avoid",
|
|
12
|
+
"htmlWhitespaceSensitivity": "css",
|
|
13
|
+
"quoteProps": "as-needed",
|
|
14
|
+
"overrides": [
|
|
15
|
+
{
|
|
16
|
+
"files": "*.js",
|
|
17
|
+
"options": {
|
|
18
|
+
"parser": "babel"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"files": "*.json",
|
|
23
|
+
"options": {
|
|
24
|
+
"parser": "json",
|
|
25
|
+
"printWidth": 80
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
package/README.md
ADDED
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ntbjs/ntb-dam-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared components for NTB Mediebank",
|
|
5
|
+
"main": "index",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test.js",
|
|
8
|
+
"prepare": "husky"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://bitbucket.org/NTB-NO/ntb-dam-utils.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "NTB",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://bitbucket.org/NTB-NO/ntb-dam-utils/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://bitbucket.org/NTB-NO/ntb-dam-utils#readme",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"eslint": "^9.5.0",
|
|
22
|
+
"eslint-plugin-import": "^2.29.1",
|
|
23
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
24
|
+
"husky": "^9.0.11",
|
|
25
|
+
"lint-staged": "^15.2.7",
|
|
26
|
+
"prettier": "^3.3.2"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"lodash": "^4.17.21"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { reduce } = require("lodash");
|
|
2
|
+
const { ownerConfig } = require("./owners");
|
|
3
|
+
|
|
4
|
+
const DEFAULT_SHARDS = 5;
|
|
5
|
+
|
|
6
|
+
const ownerIndexes = reduce(
|
|
7
|
+
ownerConfig,
|
|
8
|
+
(res = [], a) => {
|
|
9
|
+
const owner = a.value;
|
|
10
|
+
const existingAlias = res.findIndex(r => r.alias === a.index);
|
|
11
|
+
if (existingAlias > -1) {
|
|
12
|
+
res[existingAlias].owners.push(a.value);
|
|
13
|
+
} else {
|
|
14
|
+
res.push({
|
|
15
|
+
owners: [owner],
|
|
16
|
+
alias: a.index,
|
|
17
|
+
numberOfShards: DEFAULT_SHARDS
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return res;
|
|
21
|
+
},
|
|
22
|
+
[]
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const indexes = {
|
|
26
|
+
indexes: ownerIndexes,
|
|
27
|
+
reindexSettings: {
|
|
28
|
+
refresh_interval: "-1",
|
|
29
|
+
number_of_replicas: "0"
|
|
30
|
+
},
|
|
31
|
+
normalSettings: {
|
|
32
|
+
refresh_interval: "1s",
|
|
33
|
+
number_of_replicas: "1"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = { indexes };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const origins = {
|
|
2
|
+
UPLOAD: {
|
|
3
|
+
key: "UPLOAD",
|
|
4
|
+
name: "Upload direct",
|
|
5
|
+
},
|
|
6
|
+
GUEST: {
|
|
7
|
+
key: "GUEST",
|
|
8
|
+
name: "Guest upload",
|
|
9
|
+
},
|
|
10
|
+
GUESTFTP: {
|
|
11
|
+
key: "GUESTFTP",
|
|
12
|
+
name: "Guest FTP upload",
|
|
13
|
+
},
|
|
14
|
+
EMAIL: {
|
|
15
|
+
key: "EMAIL",
|
|
16
|
+
name: "Email upload",
|
|
17
|
+
},
|
|
18
|
+
IMPORT: {
|
|
19
|
+
key: "IMPORT",
|
|
20
|
+
name: "Initial import",
|
|
21
|
+
},
|
|
22
|
+
FTP: {
|
|
23
|
+
key: "FTP",
|
|
24
|
+
name: "FTP Upload",
|
|
25
|
+
},
|
|
26
|
+
LTR: {
|
|
27
|
+
key: "LTR",
|
|
28
|
+
name: "Adobe Lightroom",
|
|
29
|
+
},
|
|
30
|
+
PS: {
|
|
31
|
+
key: "PS",
|
|
32
|
+
name: "Adobe Photoshop",
|
|
33
|
+
},
|
|
34
|
+
CMS: {
|
|
35
|
+
key: "CMS",
|
|
36
|
+
name: "Content management system",
|
|
37
|
+
},
|
|
38
|
+
NTBIMAGEPORTAL: {
|
|
39
|
+
key: "NTBIMAGEPORTAL",
|
|
40
|
+
name: "NTB Images",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = { origins };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const ownerConfig = [
|
|
2
|
+
{
|
|
3
|
+
value: "DAM",
|
|
4
|
+
index: "dam",
|
|
5
|
+
locale: "en"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
value: "TTDAM",
|
|
9
|
+
index: "ttdam",
|
|
10
|
+
locale: "en"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
value: "STTDAM",
|
|
14
|
+
index: "sttdam",
|
|
15
|
+
locale: "en"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: "AMEDIA",
|
|
19
|
+
index: "amedia",
|
|
20
|
+
locale: "nb"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: "MENTOR",
|
|
24
|
+
index: "mentor",
|
|
25
|
+
locale: "nb"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: "SCHIBSTED",
|
|
29
|
+
index: "schibsted",
|
|
30
|
+
locale: "nb"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: "VG",
|
|
34
|
+
index: "schibsted",
|
|
35
|
+
locale: "nb"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
value: "POLARIS",
|
|
39
|
+
index: "polaris",
|
|
40
|
+
locale: "nb"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
value: "DNMG",
|
|
44
|
+
index: "dnmg",
|
|
45
|
+
locale: "nb"
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const owners = ownerConfig.map(o => o.value);
|
|
50
|
+
|
|
51
|
+
const ownersLocale = ownerConfig.reduce((a, v) => ({ ...a, [v.value]: v.locale }), {});
|
|
52
|
+
|
|
53
|
+
module.exports = { owners, ownerConfig, ownersLocale };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
For shared services
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
For shared util functions
|