s3db.js 8.0.2 → 8.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s3db.js",
3
- "version": "8.0.2",
3
+ "version": "8.0.3",
4
4
  "description": "Use AWS S3, the world's most reliable document storage, as a database with this ORM.",
5
5
  "main": "dist/s3db.cjs.js",
6
6
  "module": "dist/s3db.es.js",
@@ -34,7 +34,7 @@ export class Client extends EventEmitter {
34
34
  }) {
35
35
  super();
36
36
  this.verbose = verbose;
37
- this.id = id ?? idGenerator();
37
+ this.id = id ?? idGenerator(77);
38
38
  this.parallelism = parallelism;
39
39
  this.config = new ConnectionString(connectionString);
40
40
  this.httpClientOptions = {
@@ -6,13 +6,15 @@ import jsonStableStringify from "json-stable-stringify";
6
6
  import Client from "./client.class.js";
7
7
  import tryFn from "./concerns/try-fn.js";
8
8
  import Resource from "./resource.class.js";
9
- import { streamToString } from "./stream/index.js";
10
9
  import { ResourceNotFound } from "./errors.js";
10
+ import { idGenerator } from "./concerns/id.js";
11
+ import { streamToString } from "./stream/index.js";
11
12
 
12
13
  export class Database extends EventEmitter {
13
14
  constructor(options) {
14
15
  super();
15
16
 
17
+ this.id = idGenerator(7)
16
18
  this.version = "1";
17
19
  // Version is injected during build, fallback to "latest" for development
18
20
  this.s3dbVersion = (() => {
@@ -7,14 +7,13 @@ import { PromisePool } from "@supercharge/promise-pool";
7
7
  import { chunk, cloneDeep, merge, isEmpty, isObject } from "lodash-es";
8
8
 
9
9
  import Schema from "./schema.class.js";
10
- import tryFn, { tryFnSync } from "./concerns/try-fn.js";
11
10
  import { streamToString } from "./stream/index.js";
12
- import { InvalidResourceItem, ResourceError, PartitionError } from "./errors.js";
11
+ import tryFn, { tryFnSync } from "./concerns/try-fn.js";
13
12
  import { ResourceReader, ResourceWriter } from "./stream/index.js"
14
13
  import { getBehavior, DEFAULT_BEHAVIOR } from "./behaviors/index.js";
15
14
  import { idGenerator as defaultIdGenerator } from "./concerns/id.js";
16
15
  import { calculateTotalSize, calculateEffectiveLimit } from "./concerns/calculator.js";
17
- import { mapAwsError } from "./errors.js";
16
+ import { mapAwsError, InvalidResourceItem, ResourceError, PartitionError } from "./errors.js";
18
17
 
19
18
 
20
19
  export class Resource extends EventEmitter {
@@ -99,12 +98,19 @@ export class Resource extends EventEmitter {
99
98
  */
100
99
  constructor(config = {}) {
101
100
  super();
102
- this._instanceId = Math.random().toString(36).slice(2, 8);
101
+ this._instanceId = defaultIdGenerator(7);
103
102
 
104
103
  // Validate configuration
105
104
  const validation = validateResourceConfig(config);
106
105
  if (!validation.isValid) {
107
- throw new ResourceError(`Invalid Resource ${config.name} configuration`, { resourceName: config.name, validation: validation.errors, operation: 'constructor', suggestion: 'Check resource config and attributes.' });
106
+ const errorDetails = validation.errors.map(err => ` ${err}`).join('\n');
107
+ throw new ResourceError(
108
+ `Invalid Resource ${config.name || '[unnamed]'} configuration:\n${errorDetails}`,
109
+ {
110
+ resourceName: config.name,
111
+ validation: validation.errors,
112
+ }
113
+ );
108
114
  }
109
115
 
110
116
  // Extract configuration with defaults - all at root level