s3db.js 4.1.0 → 4.1.2
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/dist/s3db.cjs.js +62 -12
- package/dist/s3db.cjs.min.js +7 -7
- package/dist/s3db.es.js +62 -12
- package/dist/s3db.es.min.js +7 -7
- package/dist/s3db.iife.js +62 -12
- package/dist/s3db.iife.min.js +7 -7
- package/package.json +14 -14
package/dist/s3db.iife.js
CHANGED
|
@@ -930,7 +930,7 @@ ${JSON.stringify(validation, null, 2)}`
|
|
|
930
930
|
Key: this.config.keyPrefix ? path.join(this.config.keyPrefix, key) : key
|
|
931
931
|
};
|
|
932
932
|
try {
|
|
933
|
-
const response = await this.
|
|
933
|
+
const response = await this.sendCommand(new clientS3.HeadObjectCommand(options2));
|
|
934
934
|
this.emit("headObject", response, options2);
|
|
935
935
|
return response;
|
|
936
936
|
} catch (error) {
|
|
@@ -3558,6 +3558,7 @@ ${JSON.stringify(validation, null, 2)}`
|
|
|
3558
3558
|
version,
|
|
3559
3559
|
attributes
|
|
3560
3560
|
} = lodashEs.isString(data) ? JSON.parse(data) : data;
|
|
3561
|
+
attributes = Schema._importAttributes(attributes);
|
|
3561
3562
|
const schema = new Schema({
|
|
3562
3563
|
map,
|
|
3563
3564
|
name,
|
|
@@ -3567,22 +3568,60 @@ ${JSON.stringify(validation, null, 2)}`
|
|
|
3567
3568
|
});
|
|
3568
3569
|
return schema;
|
|
3569
3570
|
}
|
|
3571
|
+
/**
|
|
3572
|
+
* Recursively import attributes, parsing only stringified objects (legacy)
|
|
3573
|
+
*/
|
|
3574
|
+
static _importAttributes(attrs) {
|
|
3575
|
+
if (typeof attrs === "string") {
|
|
3576
|
+
try {
|
|
3577
|
+
const parsed = JSON.parse(attrs);
|
|
3578
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
3579
|
+
return Schema._importAttributes(parsed);
|
|
3580
|
+
}
|
|
3581
|
+
} catch (e) {
|
|
3582
|
+
}
|
|
3583
|
+
return attrs;
|
|
3584
|
+
}
|
|
3585
|
+
if (Array.isArray(attrs)) {
|
|
3586
|
+
return attrs.map((a) => Schema._importAttributes(a));
|
|
3587
|
+
}
|
|
3588
|
+
if (typeof attrs === "object" && attrs !== null) {
|
|
3589
|
+
const out = {};
|
|
3590
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
3591
|
+
out[k] = Schema._importAttributes(v);
|
|
3592
|
+
}
|
|
3593
|
+
return out;
|
|
3594
|
+
}
|
|
3595
|
+
return attrs;
|
|
3596
|
+
}
|
|
3570
3597
|
export() {
|
|
3571
3598
|
const data = {
|
|
3572
3599
|
version: this.version,
|
|
3573
3600
|
name: this.name,
|
|
3574
3601
|
options: this.options,
|
|
3575
|
-
attributes:
|
|
3602
|
+
attributes: this._exportAttributes(this.attributes),
|
|
3576
3603
|
map: this.map
|
|
3577
3604
|
};
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3605
|
+
return data;
|
|
3606
|
+
}
|
|
3607
|
+
/**
|
|
3608
|
+
* Recursively export attributes, keeping objects as objects and only serializing leaves as string
|
|
3609
|
+
*/
|
|
3610
|
+
_exportAttributes(attrs) {
|
|
3611
|
+
if (typeof attrs === "string") {
|
|
3612
|
+
return attrs;
|
|
3613
|
+
}
|
|
3614
|
+
if (Array.isArray(attrs)) {
|
|
3615
|
+
return attrs.map((a) => this._exportAttributes(a));
|
|
3616
|
+
}
|
|
3617
|
+
if (typeof attrs === "object" && attrs !== null) {
|
|
3618
|
+
const out = {};
|
|
3619
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
3620
|
+
out[k] = this._exportAttributes(v);
|
|
3583
3621
|
}
|
|
3622
|
+
return out;
|
|
3584
3623
|
}
|
|
3585
|
-
return
|
|
3624
|
+
return attrs;
|
|
3586
3625
|
}
|
|
3587
3626
|
async applyHooksActions(resourceItem, hook) {
|
|
3588
3627
|
for (const [attribute, actions] of Object.entries(this.options.hooks[hook])) {
|
|
@@ -9559,8 +9598,13 @@ ${JSON.stringify(validation, null, 2)}`
|
|
|
9559
9598
|
* @returns {string} SHA256 hash of the schema definition
|
|
9560
9599
|
*/
|
|
9561
9600
|
getDefinitionHash() {
|
|
9562
|
-
const
|
|
9563
|
-
const
|
|
9601
|
+
const attributes = this.schema.export().attributes;
|
|
9602
|
+
const stableAttributes = { ...attributes };
|
|
9603
|
+
if (this.options.timestamps) {
|
|
9604
|
+
delete stableAttributes.createdAt;
|
|
9605
|
+
delete stableAttributes.updatedAt;
|
|
9606
|
+
}
|
|
9607
|
+
const stableString = jsonStableStringify(stableAttributes);
|
|
9564
9608
|
return `sha256:${crypto.createHash("sha256").update(stableString).digest("hex")}`;
|
|
9565
9609
|
}
|
|
9566
9610
|
/**
|
|
@@ -9754,7 +9798,7 @@ ${JSON.stringify(validation, null, 2)}`
|
|
|
9754
9798
|
this.version = "1";
|
|
9755
9799
|
this.s3dbVersion = (() => {
|
|
9756
9800
|
try {
|
|
9757
|
-
return true ? "4.
|
|
9801
|
+
return true ? "4.1.1" : "latest";
|
|
9758
9802
|
} catch (e) {
|
|
9759
9803
|
return "latest";
|
|
9760
9804
|
}
|
|
@@ -9869,7 +9913,13 @@ ${JSON.stringify(validation, null, 2)}`
|
|
|
9869
9913
|
* @returns {string} SHA256 hash
|
|
9870
9914
|
*/
|
|
9871
9915
|
generateDefinitionHash(definition) {
|
|
9872
|
-
const
|
|
9916
|
+
const attributes = definition.attributes;
|
|
9917
|
+
const stableAttributes = { ...attributes };
|
|
9918
|
+
if (definition.options?.timestamps) {
|
|
9919
|
+
delete stableAttributes.createdAt;
|
|
9920
|
+
delete stableAttributes.updatedAt;
|
|
9921
|
+
}
|
|
9922
|
+
const stableString = jsonStableStringify(stableAttributes);
|
|
9873
9923
|
return `sha256:${crypto.createHash("sha256").update(stableString).digest("hex")}`;
|
|
9874
9924
|
}
|
|
9875
9925
|
/**
|