@fedify/vocab-tools 2.4.5 → 2.4.6-dev.2837
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/deno.json +1 -1
- package/dist/mod.cjs +57 -4
- package/dist/mod.js +57 -4
- package/package.json +1 -1
- package/src/__snapshots__/class.test.ts.deno.snap +3310 -258
- package/src/__snapshots__/class.test.ts.node.snap +3310 -258
- package/src/__snapshots__/class.test.ts.snap +3310 -258
- package/src/class.ts +6 -0
- package/src/constructor.ts +52 -3
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -8,7 +8,7 @@ let yaml = require("yaml");
|
|
|
8
8
|
let es_toolkit = require("es-toolkit");
|
|
9
9
|
//#region deno.json
|
|
10
10
|
var name = "@fedify/vocab-tools";
|
|
11
|
-
var version = "2.4.
|
|
11
|
+
var version = "2.4.6-dev.2837+bb303087";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/type.ts
|
|
14
14
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -1428,8 +1428,33 @@ async function* generateCloner(typeUri, types) {
|
|
|
1428
1428
|
* would be wrong. Sign the clone again if it has to be embedded as a
|
|
1429
1429
|
* secured child.
|
|
1430
1430
|
*
|
|
1431
|
+
* The clone does not inherit this instance's default FEP-ef61 portable
|
|
1432
|
+
* object verifier, i.e., the \`verifyPortableObject\` option given when this
|
|
1433
|
+
* instance was constructed, parsed, or fetched by an accessor, nor its
|
|
1434
|
+
* \`documentLoader\` or \`contextLoader\`. Without a verifier, the clone's
|
|
1435
|
+
* accessors no longer verify embedded portable objects, and refuse to
|
|
1436
|
+
* dereference portable references. To keep verifying them, pass
|
|
1437
|
+
* \`verifyPortableObject\` in \`options\`, or serialize this instance and
|
|
1438
|
+
* re-parse it with \`fromJsonLd()\` and the verifier. A verifier is only
|
|
1439
|
+
* a policy for dereferencing; passing one does not verify the clone itself.
|
|
1440
|
+
*
|
|
1441
|
+
* Cloning an instance that has a default verifier without passing
|
|
1442
|
+
* the \`verifyPortableObject\` option logs a warning in the
|
|
1443
|
+
* \`["fedify", "vocab", "portable"]\` category. Pass
|
|
1444
|
+
* \`verifyPortableObject: undefined\` to drop the verifier deliberately
|
|
1445
|
+
* without the warning. Either way, nested objects shared with this
|
|
1446
|
+
* instance keep their own defaults.
|
|
1447
|
+
*
|
|
1431
1448
|
* @param values The values to update the clone with.
|
|
1432
1449
|
* @param options The options to use for cloning.
|
|
1450
|
+
*
|
|
1451
|
+
* - \`documentLoader\`: The document loader for the clone.
|
|
1452
|
+
* - \`contextLoader\`: The JSON-LD context loader for
|
|
1453
|
+
* the clone.
|
|
1454
|
+
* - \`verifyPortableObject\`: The default FEP-ef61 portable
|
|
1455
|
+
* object verifier for the clone. It is not inherited from
|
|
1456
|
+
* this instance. Pass \`undefined\` explicitly to clone
|
|
1457
|
+
* without a verifier and without a warning.
|
|
1433
1458
|
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1434
1459
|
* and URLs are shared with this instance.
|
|
1435
1460
|
*/
|
|
@@ -1442,7 +1467,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1442
1467
|
options: {
|
|
1443
1468
|
documentLoader?: DocumentLoader,
|
|
1444
1469
|
contextLoader?: DocumentLoader,
|
|
1445
|
-
verifyPortableObject?: PortableObjectVerifier,
|
|
1470
|
+
verifyPortableObject?: PortableObjectVerifier | undefined,
|
|
1446
1471
|
} = {}
|
|
1447
1472
|
): ${type.name} {
|
|
1448
1473
|
if (this._warning != null) {
|
|
@@ -1450,8 +1475,15 @@ async function* generateCloner(typeUri, types) {
|
|
|
1450
1475
|
this._warning.message,
|
|
1451
1476
|
this._warning.values
|
|
1452
1477
|
);
|
|
1453
|
-
//
|
|
1454
|
-
|
|
1478
|
+
// Keep an explicit verifyPortableObject option, even an inherited or
|
|
1479
|
+
// non-enumerable one, since its presence decides whether to warn below:
|
|
1480
|
+
options = {
|
|
1481
|
+
...options,
|
|
1482
|
+
...("verifyPortableObject" in options
|
|
1483
|
+
? { verifyPortableObject: options.verifyPortableObject }
|
|
1484
|
+
: {}),
|
|
1485
|
+
$warning: this._warning,
|
|
1486
|
+
} as typeof options;
|
|
1455
1487
|
}
|
|
1456
1488
|
`;
|
|
1457
1489
|
if (type.extends == null) yield `
|
|
@@ -1537,6 +1569,21 @@ async function* generateCloner(typeUri, types) {
|
|
|
1537
1569
|
`;
|
|
1538
1570
|
}
|
|
1539
1571
|
}
|
|
1572
|
+
if (type.extends == null) yield `
|
|
1573
|
+
if (
|
|
1574
|
+
this._verifyPortableObject != null &&
|
|
1575
|
+
!("verifyPortableObject" in options)
|
|
1576
|
+
) {
|
|
1577
|
+
getLogger(["fedify", "vocab", "portable"]).warn(
|
|
1578
|
+
"Cloning {typeName} {objectId} drops its default portable object " +
|
|
1579
|
+
"verifier, since clone() does not inherit it. Pass " +
|
|
1580
|
+
"the verifyPortableObject option to clone() to keep verifying " +
|
|
1581
|
+
"portable objects, or verifyPortableObject: undefined to drop " +
|
|
1582
|
+
"the verifier deliberately without this warning.",
|
|
1583
|
+
{ typeName: this.constructor.name, objectId: this.id?.href ?? "(no id)" },
|
|
1584
|
+
);
|
|
1585
|
+
}
|
|
1586
|
+
`;
|
|
1540
1587
|
yield `
|
|
1541
1588
|
return clone;
|
|
1542
1589
|
}
|
|
@@ -2414,6 +2461,12 @@ async function* generateClass(typeUri, types, moduleVarNames) {
|
|
|
2414
2461
|
return this.#tracerProvider;
|
|
2415
2462
|
}
|
|
2416
2463
|
|
|
2464
|
+
/**
|
|
2465
|
+
* Internal cross-package contract with @fedify/fedify and @fedify/testing,
|
|
2466
|
+
* which read this through \`Reflect.get()\` to pass an object's default
|
|
2467
|
+
* verifier on to its clones. Keep this accessor name and its semantics
|
|
2468
|
+
* stable.
|
|
2469
|
+
*/
|
|
2417
2470
|
protected get _verifyPortableObject(): PortableObjectVerifier | undefined {
|
|
2418
2471
|
return this.#verifyPortableObject;
|
|
2419
2472
|
}
|
package/dist/mod.js
CHANGED
|
@@ -7,7 +7,7 @@ import { parse } from "yaml";
|
|
|
7
7
|
import { pascalCase } from "es-toolkit";
|
|
8
8
|
//#region deno.json
|
|
9
9
|
var name = "@fedify/vocab-tools";
|
|
10
|
-
var version = "2.4.
|
|
10
|
+
var version = "2.4.6-dev.2837+bb303087";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/type.ts
|
|
13
13
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -1427,8 +1427,33 @@ async function* generateCloner(typeUri, types) {
|
|
|
1427
1427
|
* would be wrong. Sign the clone again if it has to be embedded as a
|
|
1428
1428
|
* secured child.
|
|
1429
1429
|
*
|
|
1430
|
+
* The clone does not inherit this instance's default FEP-ef61 portable
|
|
1431
|
+
* object verifier, i.e., the \`verifyPortableObject\` option given when this
|
|
1432
|
+
* instance was constructed, parsed, or fetched by an accessor, nor its
|
|
1433
|
+
* \`documentLoader\` or \`contextLoader\`. Without a verifier, the clone's
|
|
1434
|
+
* accessors no longer verify embedded portable objects, and refuse to
|
|
1435
|
+
* dereference portable references. To keep verifying them, pass
|
|
1436
|
+
* \`verifyPortableObject\` in \`options\`, or serialize this instance and
|
|
1437
|
+
* re-parse it with \`fromJsonLd()\` and the verifier. A verifier is only
|
|
1438
|
+
* a policy for dereferencing; passing one does not verify the clone itself.
|
|
1439
|
+
*
|
|
1440
|
+
* Cloning an instance that has a default verifier without passing
|
|
1441
|
+
* the \`verifyPortableObject\` option logs a warning in the
|
|
1442
|
+
* \`["fedify", "vocab", "portable"]\` category. Pass
|
|
1443
|
+
* \`verifyPortableObject: undefined\` to drop the verifier deliberately
|
|
1444
|
+
* without the warning. Either way, nested objects shared with this
|
|
1445
|
+
* instance keep their own defaults.
|
|
1446
|
+
*
|
|
1430
1447
|
* @param values The values to update the clone with.
|
|
1431
1448
|
* @param options The options to use for cloning.
|
|
1449
|
+
*
|
|
1450
|
+
* - \`documentLoader\`: The document loader for the clone.
|
|
1451
|
+
* - \`contextLoader\`: The JSON-LD context loader for
|
|
1452
|
+
* the clone.
|
|
1453
|
+
* - \`verifyPortableObject\`: The default FEP-ef61 portable
|
|
1454
|
+
* object verifier for the clone. It is not inherited from
|
|
1455
|
+
* this instance. Pass \`undefined\` explicitly to clone
|
|
1456
|
+
* without a verifier and without a warning.
|
|
1432
1457
|
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1433
1458
|
* and URLs are shared with this instance.
|
|
1434
1459
|
*/
|
|
@@ -1441,7 +1466,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1441
1466
|
options: {
|
|
1442
1467
|
documentLoader?: DocumentLoader,
|
|
1443
1468
|
contextLoader?: DocumentLoader,
|
|
1444
|
-
verifyPortableObject?: PortableObjectVerifier,
|
|
1469
|
+
verifyPortableObject?: PortableObjectVerifier | undefined,
|
|
1445
1470
|
} = {}
|
|
1446
1471
|
): ${type.name} {
|
|
1447
1472
|
if (this._warning != null) {
|
|
@@ -1449,8 +1474,15 @@ async function* generateCloner(typeUri, types) {
|
|
|
1449
1474
|
this._warning.message,
|
|
1450
1475
|
this._warning.values
|
|
1451
1476
|
);
|
|
1452
|
-
//
|
|
1453
|
-
|
|
1477
|
+
// Keep an explicit verifyPortableObject option, even an inherited or
|
|
1478
|
+
// non-enumerable one, since its presence decides whether to warn below:
|
|
1479
|
+
options = {
|
|
1480
|
+
...options,
|
|
1481
|
+
...("verifyPortableObject" in options
|
|
1482
|
+
? { verifyPortableObject: options.verifyPortableObject }
|
|
1483
|
+
: {}),
|
|
1484
|
+
$warning: this._warning,
|
|
1485
|
+
} as typeof options;
|
|
1454
1486
|
}
|
|
1455
1487
|
`;
|
|
1456
1488
|
if (type.extends == null) yield `
|
|
@@ -1536,6 +1568,21 @@ async function* generateCloner(typeUri, types) {
|
|
|
1536
1568
|
`;
|
|
1537
1569
|
}
|
|
1538
1570
|
}
|
|
1571
|
+
if (type.extends == null) yield `
|
|
1572
|
+
if (
|
|
1573
|
+
this._verifyPortableObject != null &&
|
|
1574
|
+
!("verifyPortableObject" in options)
|
|
1575
|
+
) {
|
|
1576
|
+
getLogger(["fedify", "vocab", "portable"]).warn(
|
|
1577
|
+
"Cloning {typeName} {objectId} drops its default portable object " +
|
|
1578
|
+
"verifier, since clone() does not inherit it. Pass " +
|
|
1579
|
+
"the verifyPortableObject option to clone() to keep verifying " +
|
|
1580
|
+
"portable objects, or verifyPortableObject: undefined to drop " +
|
|
1581
|
+
"the verifier deliberately without this warning.",
|
|
1582
|
+
{ typeName: this.constructor.name, objectId: this.id?.href ?? "(no id)" },
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
`;
|
|
1539
1586
|
yield `
|
|
1540
1587
|
return clone;
|
|
1541
1588
|
}
|
|
@@ -2413,6 +2460,12 @@ async function* generateClass(typeUri, types, moduleVarNames) {
|
|
|
2413
2460
|
return this.#tracerProvider;
|
|
2414
2461
|
}
|
|
2415
2462
|
|
|
2463
|
+
/**
|
|
2464
|
+
* Internal cross-package contract with @fedify/fedify and @fedify/testing,
|
|
2465
|
+
* which read this through \`Reflect.get()\` to pass an object's default
|
|
2466
|
+
* verifier on to its clones. Keep this accessor name and its semantics
|
|
2467
|
+
* stable.
|
|
2468
|
+
*/
|
|
2416
2469
|
protected get _verifyPortableObject(): PortableObjectVerifier | undefined {
|
|
2417
2470
|
return this.#verifyPortableObject;
|
|
2418
2471
|
}
|