@nymphjs/guid 1.0.0-beta.12 → 1.0.0-beta.121
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/CHANGELOG.md +452 -0
- package/README.md +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -7525
- package/dist/index.js.map +1 -0
- package/dist/index.test.js +31 -0
- package/dist/index.test.js.map +1 -0
- package/jest.config.js +31 -5
- package/package.json +34 -29
- package/src/index.test.ts +1 -1
- package/src/index.ts +3 -5
- package/tsconfig.json +6 -3
- package/typedoc.json +4 -0
- package/rollup.config.mjs +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,UAAU,GAAG,cAAc,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAC1D,MAAM,UAAU,IAAI;IAClB,OAAO,GAAG,IAAI,CACZ,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,CACzD,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAC3C,sCAAsC,EACtC,EAAE,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { nanoid as realNanoid, customAlphabet as realCustomAlphabet, } from 'nanoid';
|
|
2
|
+
import { guid, makeTableSuffix, humanSecret, nanoid, customAlphabet, } from './index.js';
|
|
3
|
+
describe('GUID', () => {
|
|
4
|
+
it('exports nanoid and customAlphabet', () => {
|
|
5
|
+
expect(nanoid).toBe(realNanoid);
|
|
6
|
+
expect(customAlphabet).toBe(realCustomAlphabet);
|
|
7
|
+
});
|
|
8
|
+
it('generates GUIDs', () => {
|
|
9
|
+
let guid1 = guid();
|
|
10
|
+
let guid2 = guid();
|
|
11
|
+
expect(guid1.length).toBe(24);
|
|
12
|
+
expect(guid2.length).toBe(24);
|
|
13
|
+
expect(guid1).not.toEqual(guid2);
|
|
14
|
+
expect(guid1.substring(0, 4)).toEqual(guid2.substring(0, 4));
|
|
15
|
+
});
|
|
16
|
+
it('generates table suffixes', () => {
|
|
17
|
+
let tableSuffix1 = makeTableSuffix();
|
|
18
|
+
let tableSuffix2 = makeTableSuffix();
|
|
19
|
+
expect(tableSuffix1.length).toBe(20);
|
|
20
|
+
expect(tableSuffix2.length).toBe(20);
|
|
21
|
+
expect(tableSuffix1).not.toEqual(tableSuffix2);
|
|
22
|
+
});
|
|
23
|
+
it('generates human readable secrets', () => {
|
|
24
|
+
let secret1 = humanSecret();
|
|
25
|
+
let secret2 = humanSecret();
|
|
26
|
+
expect(secret1.length).toBe(10);
|
|
27
|
+
expect(secret2.length).toBe(10);
|
|
28
|
+
expect(secret1).not.toEqual(secret2);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,cAAc,IAAI,kBAAkB,GACrC,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,IAAI,EACJ,eAAe,EACf,WAAW,EACX,MAA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,kCAAkC,EAAE,GAAG,EAAE;QAC1C,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;QAC5B,IAAI,OAAO,GAAG,WAAW,EAAE,CAAC;QAE5B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/jest.config.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const jestConfig = {
|
|
2
|
+
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
|
3
|
+
testMatch: [
|
|
4
|
+
'<rootDir>/src/**/__tests__/**/*.{js,ts,jsx,tsx,mjs,mts}',
|
|
5
|
+
'<rootDir>/src/**/?(*.)(spec|test).{js,ts,jsx,tsx,mjs,mts}',
|
|
6
|
+
],
|
|
7
|
+
transform: {
|
|
8
|
+
'^.+\\.(ts|tsx|mts)$': [
|
|
9
|
+
'@swc/jest',
|
|
10
|
+
{
|
|
11
|
+
jsc: {
|
|
12
|
+
parser: {
|
|
13
|
+
syntax: 'typescript',
|
|
14
|
+
tsx: true,
|
|
15
|
+
decorators: true,
|
|
16
|
+
},
|
|
17
|
+
target: 'es2023',
|
|
18
|
+
},
|
|
19
|
+
module: {
|
|
20
|
+
type: 'commonjs',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$'],
|
|
26
|
+
moduleDirectories: ['node_modules', 'src'],
|
|
27
|
+
moduleNameMapper: {
|
|
28
|
+
'^(\\.|\\.\\.)\\/(.+)\\.js': '$1/$2',
|
|
29
|
+
},
|
|
6
30
|
};
|
|
31
|
+
|
|
32
|
+
export default jestConfig;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymphjs/guid",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "
|
|
3
|
+
"version": "1.0.0-beta.121",
|
|
4
|
+
"description": "Nymph.js - GUID and Unique Code Generators",
|
|
5
|
+
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"keywords": [
|
|
@@ -13,42 +13,47 @@
|
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"clean": "test -d dist && rm -r dist || true",
|
|
16
|
-
"build": "
|
|
17
|
-
"watch": "
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"test
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"watch": "tsc --watch",
|
|
18
|
+
"prepublish": "npm run clean && npm run build",
|
|
19
|
+
"typecheck": "npx tsc --noEmit",
|
|
20
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
|
|
21
|
+
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests --watch"
|
|
21
22
|
},
|
|
22
23
|
"publishConfig": {
|
|
23
24
|
"access": "public"
|
|
24
25
|
},
|
|
26
|
+
"homepage": "https://nymph.io",
|
|
25
27
|
"repository": {
|
|
26
28
|
"type": "git",
|
|
27
|
-
"url": "
|
|
29
|
+
"url": "https://forge.sciactive.com/sciactive/nymphjs.git",
|
|
30
|
+
"directory": "packages/guid"
|
|
28
31
|
},
|
|
29
|
-
"author": "Hunter Perrin <hperrin@
|
|
32
|
+
"author": "Hunter Perrin <hperrin@port87.com>",
|
|
30
33
|
"bugs": {
|
|
31
|
-
"url": "https://
|
|
34
|
+
"url": "https://forge.sciactive.com/sciactive/nymphjs/issues"
|
|
32
35
|
},
|
|
33
36
|
"license": "Apache-2.0",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"luxon": "^3.7.2",
|
|
39
|
+
"nanoid": "^6.0.1",
|
|
40
|
+
"nanoid-dictionary": "^5.0.0",
|
|
41
|
+
"sha1": "^1.1.1"
|
|
42
|
+
},
|
|
34
43
|
"devDependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@types/
|
|
40
|
-
"@types/
|
|
41
|
-
"@types/
|
|
42
|
-
"@types/sha1": "^1.1.
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"sha1": "^1.1.1",
|
|
49
|
-
"ts-jest": "^29.0.5",
|
|
50
|
-
"tslib": "^2.5.0",
|
|
51
|
-
"typescript": "^4.9.5"
|
|
44
|
+
"@swc/core": "^1.16.1",
|
|
45
|
+
"@swc/jest": "^0.2.39",
|
|
46
|
+
"@tsconfig/recommended": "^1.0.13",
|
|
47
|
+
"@types/jest": "^30.0.0",
|
|
48
|
+
"@types/luxon": "^3.7.5",
|
|
49
|
+
"@types/nanoid-dictionary": "^4.2.3",
|
|
50
|
+
"@types/node": "^26.2.0",
|
|
51
|
+
"@types/sha1": "^1.1.5",
|
|
52
|
+
"cross-env": "^10.1.0",
|
|
53
|
+
"jest": "^30.4.2",
|
|
54
|
+
"ts-node": "^10.9.2",
|
|
55
|
+
"tslib": "^2.8.1",
|
|
56
|
+
"typescript": "^7.0.2"
|
|
52
57
|
},
|
|
53
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "74e39aff81353d16831656431e97b66ac6effc18"
|
|
54
59
|
}
|
package/src/index.test.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { nanoid, customAlphabet } from 'nanoid';
|
|
2
2
|
import { DateTime } from 'luxon';
|
|
3
3
|
import sha1 from 'sha1';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const { nolookalikesSafe } = dictionary;
|
|
4
|
+
import { nolookalikesSafe } from 'nanoid-dictionary';
|
|
7
5
|
|
|
8
6
|
const guidSuffix = customAlphabet('0123456789abcdef', 20);
|
|
9
7
|
export function guid() {
|
|
10
8
|
return `${sha1(
|
|
11
|
-
`${DateTime.now().weekYear}${DateTime.now().weekNumber}
|
|
9
|
+
`${DateTime.now().weekYear}${DateTime.now().weekNumber}`,
|
|
12
10
|
).slice(0, 4)}${guidSuffix()}`;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export const makeTableSuffix = customAlphabet(
|
|
16
14
|
'0123456789abcdefghijklmnopqrstuvwxyz',
|
|
17
|
-
20
|
|
15
|
+
20,
|
|
18
16
|
);
|
|
19
17
|
|
|
20
18
|
export const humanSecret = customAlphabet(nolookalikesSafe, 10);
|
package/tsconfig.json
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
"extends": "@tsconfig/recommended/tsconfig.json",
|
|
3
3
|
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"types": ["node", "jest"],
|
|
6
|
+
"module": "nodenext",
|
|
7
|
+
"moduleResolution": "nodenext",
|
|
8
|
+
"lib": ["es2023"],
|
|
9
|
+
"target": "es2023",
|
|
7
10
|
"noImplicitAny": true,
|
|
8
|
-
"removeComments":
|
|
11
|
+
"removeComments": false,
|
|
9
12
|
"sourceMap": true,
|
|
10
13
|
"outDir": "dist",
|
|
11
14
|
"resolveJsonModule": true,
|
package/typedoc.json
ADDED
package/rollup.config.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import typescript from '@rollup/plugin-typescript';
|
|
2
|
-
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
3
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
input: 'src/index.ts',
|
|
7
|
-
output: {
|
|
8
|
-
file: 'dist/index.js',
|
|
9
|
-
format: 'cjs',
|
|
10
|
-
},
|
|
11
|
-
plugins: [nodeResolve(), commonjs(), typescript()],
|
|
12
|
-
};
|