s3db.js 19.3.21 → 19.3.23
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/README.md +1 -1
- package/dist/concerns/id.js +0 -24
- package/dist/core/resource-id-generator.class.js +1 -1
- package/dist/core/resource-persistence.class.js +3 -1
- package/dist/lite.js +1 -1
- package/dist/s3db-lite.cjs +267 -286
- package/dist/s3db-lite.d.ts +1 -2
- package/dist/s3db-lite.es.js +268 -286
- package/dist/s3db.cjs +342 -368
- package/dist/s3db.d.ts +1 -3
- package/dist/s3db.es.js +343 -367
- package/dist/tasks/tasks-pool.class.js +3 -3
- package/dist/tasks/tasks-runner.class.js +2 -2
- package/dist/types/concerns/id.d.ts +0 -2
- package/dist/types/core/resource-persistence.class.d.ts +2 -0
- package/dist/types/lite.d.ts +1 -1
- package/package.json +1 -2
- package/src/concerns/id.ts +0 -42
- package/src/core/resource-id-generator.class.ts +1 -1
- package/src/core/resource-persistence.class.ts +5 -1
- package/src/lite.ts +1 -1
- package/src/plugins/tfstate/README.md +3 -3
- package/src/tasks/tasks-pool.class.ts +3 -3
- package/src/tasks/tasks-runner.class.ts +2 -2
package/README.md
CHANGED
|
@@ -2425,7 +2425,7 @@ This project is licensed under the [Unlicense](LICENSE) - see the LICENSE file f
|
|
|
2425
2425
|
|
|
2426
2426
|
- Built with [AWS SDK for JavaScript](https://aws.amazon.com/sdk-for-javascript/)
|
|
2427
2427
|
- Validation powered by [@icebob/fastest-validator](https://github.com/icebob/fastest-validator)
|
|
2428
|
-
- ID generation using
|
|
2428
|
+
- ID generation using the built-in generator
|
|
2429
2429
|
|
|
2430
2430
|
---
|
|
2431
2431
|
|
package/dist/concerns/id.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { randomFillSync } from 'node:crypto';
|
|
2
|
-
import { createLogger } from './logger.js';
|
|
3
|
-
const logger = createLogger({ name: 'IdGenerator', level: 'info' });
|
|
4
2
|
const FALLBACK_URL_ALPHABET = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
5
3
|
const PASSWORD_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789';
|
|
6
4
|
const POOL_SIZE_MULTIPLIER = 128;
|
|
@@ -48,28 +46,6 @@ let activeCustomAlphabet = customAlphabetFallback;
|
|
|
48
46
|
let activeUrlAlphabet = FALLBACK_URL_ALPHABET;
|
|
49
47
|
let idGeneratorImpl = activeCustomAlphabet(activeUrlAlphabet, 22);
|
|
50
48
|
let passwordGeneratorImpl = activeCustomAlphabet(PASSWORD_ALPHABET, 16);
|
|
51
|
-
let nanoidInitializationError = null;
|
|
52
|
-
const nanoidReadyPromise = import('nanoid')
|
|
53
|
-
.then((mod) => {
|
|
54
|
-
const resolvedCustomAlphabet = mod?.customAlphabet ?? activeCustomAlphabet;
|
|
55
|
-
const resolvedUrlAlphabet = mod?.urlAlphabet ?? activeUrlAlphabet;
|
|
56
|
-
activeCustomAlphabet = resolvedCustomAlphabet;
|
|
57
|
-
activeUrlAlphabet = resolvedUrlAlphabet;
|
|
58
|
-
idGeneratorImpl = activeCustomAlphabet(activeUrlAlphabet, 22);
|
|
59
|
-
passwordGeneratorImpl = activeCustomAlphabet(PASSWORD_ALPHABET, 16);
|
|
60
|
-
})
|
|
61
|
-
.catch((error) => {
|
|
62
|
-
nanoidInitializationError = error;
|
|
63
|
-
if (typeof process !== 'undefined' && process?.env?.S3DB_DEBUG) {
|
|
64
|
-
logger.warn({ error: error.message }, 'Failed to dynamically import "nanoid". Using fallback implementation.');
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
export function initializeNanoid() {
|
|
68
|
-
return nanoidReadyPromise;
|
|
69
|
-
}
|
|
70
|
-
export function getNanoidInitializationError() {
|
|
71
|
-
return nanoidInitializationError;
|
|
72
|
-
}
|
|
73
49
|
export const idGenerator = (size) => idGeneratorImpl(size);
|
|
74
50
|
export const passwordGenerator = (size) => passwordGeneratorImpl(size);
|
|
75
51
|
export const getUrlAlphabet = () => activeUrlAlphabet;
|
|
@@ -54,7 +54,9 @@ export class ResourcePersistence {
|
|
|
54
54
|
Object.assign(validatedAttributes, extraData);
|
|
55
55
|
let finalId = validatedId || preProcessedData.id || id;
|
|
56
56
|
if (!finalId) {
|
|
57
|
-
|
|
57
|
+
const shouldUseData = this.resource.idGeneratorType === 'custom';
|
|
58
|
+
const generatedId = shouldUseData ? this.idGenerator(preProcessedData) : this.idGenerator();
|
|
59
|
+
finalId = await Promise.resolve(generatedId);
|
|
58
60
|
if (!finalId || String(finalId).trim() === '') {
|
|
59
61
|
const { idGenerator } = await import('#src/concerns/id.js');
|
|
60
62
|
finalId = idGenerator();
|
package/dist/lite.js
CHANGED
|
@@ -56,7 +56,7 @@ export { tryFn, tryFnSync } from './concerns/try-fn.js';
|
|
|
56
56
|
// Crypto
|
|
57
57
|
export { encrypt, decrypt } from './concerns/crypto.js';
|
|
58
58
|
// ID generation
|
|
59
|
-
export { idGenerator, passwordGenerator, createCustomGenerator
|
|
59
|
+
export { idGenerator, passwordGenerator, createCustomGenerator } from './concerns/id.js';
|
|
60
60
|
// Base62 encoding
|
|
61
61
|
export { encode, decode, encodeDecimal, decodeDecimal } from './concerns/base62.js';
|
|
62
62
|
// Binary encoding
|