@fedify/vocab 2.0.0-dev.0 → 2.0.0-dev.158

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 ADDED
@@ -0,0 +1,139 @@
1
+ <!-- deno-fmt-ignore-file -->
2
+
3
+ @fedify/vocab: ActivityPub vocabulary for Fedify
4
+ ================================================
5
+
6
+ [![JSR][JSR badge]][JSR]
7
+ [![npm][npm badge]][npm]
8
+
9
+ This package provides a collection of type-safe objects that represent the
10
+ [Activity Vocabulary] and vendor-specific extensions for the [Fedify] framework.
11
+ It is the core vocabulary library that powers ActivityPub object handling in
12
+ Fedify applications.
13
+
14
+ [JSR]: https://jsr.io/@fedify/vocab
15
+ [JSR badge]: https://jsr.io/badges/@fedify/vocab
16
+ [npm]: https://www.npmjs.com/package/@fedify/vocab
17
+ [npm badge]: https://img.shields.io/npm/v/@fedify/vocab?logo=npm
18
+ [Activity Vocabulary]: https://www.w3.org/TR/activitystreams-vocabulary/
19
+ [Fedify]: https://fedify.dev/
20
+
21
+
22
+ Features
23
+ --------
24
+
25
+ - Type-safe objects for [Activity Vocabulary] types (`Create`, `Note`,
26
+ `Person`, etc.)
27
+ - Vendor-specific extensions (Mastodon, Misskey, etc.)
28
+ - JSON-LD serialization and deserialization
29
+ - Immutable object design with `clone()` method for modifications
30
+ - Support for looking up remote objects
31
+ - Actor handle resolution via WebFinger
32
+
33
+
34
+ Installation
35
+ ------------
36
+
37
+ ~~~~ bash
38
+ deno add jsr:@fedify/vocab # Deno
39
+ npm add @fedify/vocab # npm
40
+ pnpm add @fedify/vocab # pnpm
41
+ yarn add @fedify/vocab # Yarn
42
+ bun add @fedify/vocab # Bun
43
+ ~~~~
44
+
45
+
46
+ Usage
47
+ -----
48
+
49
+ ### Instantiation
50
+
51
+ You can instantiate an object by calling the constructor with properties:
52
+
53
+ ~~~~ typescript
54
+ import { Create, Note } from "@fedify/vocab";
55
+
56
+ const create = new Create({
57
+ id: new URL("https://example.com/activities/123"),
58
+ actor: new URL("https://example.com/users/alice"),
59
+ object: new Note({
60
+ id: new URL("https://example.com/notes/456"),
61
+ content: "Hello, world!",
62
+ }),
63
+ });
64
+ ~~~~
65
+
66
+ ### JSON-LD serialization
67
+
68
+ Deserialize from JSON-LD:
69
+
70
+ ~~~~ typescript
71
+ import { Create } from "@fedify/vocab";
72
+
73
+ const create = await Create.fromJsonLd({
74
+ "@context": "https://www.w3.org/ns/activitystreams",
75
+ "type": "Create",
76
+ "id": "https://example.com/activities/123",
77
+ "actor": "https://example.com/users/alice",
78
+ "object": {
79
+ "type": "Note",
80
+ "id": "https://example.com/notes/456",
81
+ "content": "Hello, world!",
82
+ }
83
+ });
84
+ ~~~~
85
+
86
+ Serialize to JSON-LD:
87
+
88
+ ~~~~ typescript
89
+ const jsonLd = await create.toJsonLd();
90
+ ~~~~
91
+
92
+ ### Immutability
93
+
94
+ All objects are immutable. Use `clone()` to create modified copies:
95
+
96
+ ~~~~ typescript
97
+ import { Note } from "@fedify/vocab";
98
+ import { LanguageString } from "@fedify/vocab-runtime";
99
+
100
+ const noteInEnglish = new Note({
101
+ id: new URL("https://example.com/notes/123"),
102
+ content: new LanguageString("Hello, world!", "en"),
103
+ });
104
+
105
+ const noteInChinese = noteInEnglish.clone({
106
+ content: new LanguageString("你好,世界!", "zh"),
107
+ });
108
+ ~~~~
109
+
110
+ ### Looking up remote objects
111
+
112
+ ~~~~ typescript
113
+ import { lookupObject } from "@fedify/vocab";
114
+
115
+ const object = await lookupObject("https://example.com/users/alice");
116
+ ~~~~
117
+
118
+
119
+ Documentation
120
+ -------------
121
+
122
+ For comprehensive documentation, please refer to:
123
+
124
+ - [Vocabulary documentation](https://fedify.dev/manual/vocab)
125
+ - [API reference](https://jsr.io/@fedify/vocab/doc/~)
126
+
127
+
128
+ Related packages
129
+ ----------------
130
+
131
+ - *@fedify/fedify*: The main Fedify framework
132
+ - *@fedify/vocab-runtime*: Runtime utilities for vocabulary objects
133
+ - *@fedify/vocab-tools*: Code generation tools for Activity Vocabulary
134
+
135
+
136
+ License
137
+ -------
138
+
139
+ [MIT License](https://github.com/fedify-dev/fedify/blob/main/LICENSE)
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.0.0",
3
+ "version": "2.0.0-dev.158+628cd89e",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
@@ -2,13 +2,13 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
 
5
- import { Application, Group, Organization, Person, Service, __export } from "./vocab-DBispxj5.js";
6
- import { deno_default, esm_default } from "./deno-B-ypIMwF.js";
7
- import { getTypeId } from "./type-CNuABalk.js";
8
- import { test } from "@fedify/fixture";
5
+ import { __export } from "./chunk-BeeFIeNn.js";
6
+ import { Application, Group, Organization, Person, Service, test } from "./vocab-BCnUNobC.js";
7
+ import { deno_default, esm_default } from "./deno-CDgxQSI_.js";
8
+ import { getTypeId } from "./type-Dnf0m2yO.js";
9
+ import { SpanStatusCode, trace } from "@opentelemetry/api";
9
10
  import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
10
11
  import { lookupWebFinger } from "@fedify/webfinger";
11
- import { SpanStatusCode, trace } from "@opentelemetry/api";
12
12
  import { domainToASCII, domainToUnicode } from "node:url";
13
13
 
14
14
  //#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
@@ -0,0 +1,45 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ globalThis.addEventListener = () => {};
4
+
5
+ import { createRequire } from "node:module";
6
+
7
+ //#region rolldown:runtime
8
+ var __create = Object.create;
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
12
+ var __getProtoOf = Object.getPrototypeOf;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __esm = (fn, res) => function() {
15
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
+ };
17
+ var __commonJS = (cb, mod) => function() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all) __defProp(target, name, {
22
+ get: all[name],
23
+ enumerable: true
24
+ });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
28
+ key = keys[i];
29
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
30
+ get: ((k) => from[k]).bind(null, key),
31
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
32
+ });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
37
+ value: mod,
38
+ enumerable: true
39
+ }) : target, mod));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
42
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
43
+
44
+ //#endregion
45
+ export { __commonJS, __esm, __export, __require, __toCommonJS, __toDynamicImportESM, __toESM };
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
 
5
- import { __commonJS, __toESM } from "./vocab-DBispxj5.js";
5
+ import { __commonJS, __toESM } from "./chunk-BeeFIeNn.js";
6
6
 
7
7
  //#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
8
8
  var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js"(exports, module) {
@@ -1240,7 +1240,7 @@ var esm_default = FetchMock_default;
1240
1240
  //#endregion
1241
1241
  //#region deno.json
1242
1242
  var name = "@fedify/vocab";
1243
- var version = "2.0.0";
1243
+ var version = "2.0.0-dev.158+628cd89e";
1244
1244
  var license = "MIT";
1245
1245
  var exports = { ".": "./src/mod.ts" };
1246
1246
  var description = "Vocabularies library for @fedify/fedify";
@@ -0,0 +1,17 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ globalThis.addEventListener = () => {};
4
+
5
+ import { __commonJS, __require } from "./chunk-BeeFIeNn.js";
6
+
7
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.js
8
+ var require_execAsync = __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/execAsync.js"(exports) {
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.execAsync = void 0;
11
+ const child_process = __require("child_process");
12
+ const util = __require("util");
13
+ exports.execAsync = util.promisify(child_process.exec);
14
+ } });
15
+
16
+ //#endregion
17
+ export { require_execAsync };
@@ -0,0 +1,34 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ globalThis.addEventListener = () => {};
4
+
5
+ import { __commonJS, __require } from "./chunk-BeeFIeNn.js";
6
+ import { require_execAsync } from "./execAsync-DrQE_9g2.js";
7
+
8
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js
9
+ var require_getMachineId_bsd = __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-bsd.js"(exports) {
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getMachineId = void 0;
12
+ const fs_1 = __require("fs");
13
+ const execAsync_1 = require_execAsync();
14
+ const api_1 = __require("@opentelemetry/api");
15
+ async function getMachineId() {
16
+ try {
17
+ const result = await fs_1.promises.readFile("/etc/hostid", { encoding: "utf8" });
18
+ return result.trim();
19
+ } catch (e) {
20
+ api_1.diag.debug(`error reading machine id: ${e}`);
21
+ }
22
+ try {
23
+ const result = await (0, execAsync_1.execAsync)("kenv -q smbios.system.uuid");
24
+ return result.stdout.trim();
25
+ } catch (e) {
26
+ api_1.diag.debug(`error reading machine id: ${e}`);
27
+ }
28
+ return void 0;
29
+ }
30
+ exports.getMachineId = getMachineId;
31
+ } });
32
+
33
+ //#endregion
34
+ export default require_getMachineId_bsd();
@@ -0,0 +1,30 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ globalThis.addEventListener = () => {};
4
+
5
+ import { __commonJS, __require } from "./chunk-BeeFIeNn.js";
6
+ import { require_execAsync } from "./execAsync-DrQE_9g2.js";
7
+
8
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js
9
+ var require_getMachineId_darwin = __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-darwin.js"(exports) {
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getMachineId = void 0;
12
+ const execAsync_1 = require_execAsync();
13
+ const api_1 = __require("@opentelemetry/api");
14
+ async function getMachineId() {
15
+ try {
16
+ const result = await (0, execAsync_1.execAsync)("ioreg -rd1 -c \"IOPlatformExpertDevice\"");
17
+ const idLine = result.stdout.split("\n").find((line) => line.includes("IOPlatformUUID"));
18
+ if (!idLine) return void 0;
19
+ const parts = idLine.split("\" = \"");
20
+ if (parts.length === 2) return parts[1].slice(0, -1);
21
+ } catch (e) {
22
+ api_1.diag.debug(`error reading machine id: ${e}`);
23
+ }
24
+ return void 0;
25
+ }
26
+ exports.getMachineId = getMachineId;
27
+ } });
28
+
29
+ //#endregion
30
+ export default require_getMachineId_darwin();
@@ -0,0 +1,27 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ globalThis.addEventListener = () => {};
4
+
5
+ import { __commonJS, __require } from "./chunk-BeeFIeNn.js";
6
+
7
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-linux.js
8
+ var require_getMachineId_linux = __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-linux.js"(exports) {
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getMachineId = void 0;
11
+ const fs_1 = __require("fs");
12
+ const api_1 = __require("@opentelemetry/api");
13
+ async function getMachineId() {
14
+ const paths = ["/etc/machine-id", "/var/lib/dbus/machine-id"];
15
+ for (const path of paths) try {
16
+ const result = await fs_1.promises.readFile(path, { encoding: "utf8" });
17
+ return result.trim();
18
+ } catch (e) {
19
+ api_1.diag.debug(`error reading machine id: ${e}`);
20
+ }
21
+ return void 0;
22
+ }
23
+ exports.getMachineId = getMachineId;
24
+ } });
25
+
26
+ //#endregion
27
+ export default require_getMachineId_linux();
@@ -0,0 +1,20 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ globalThis.addEventListener = () => {};
4
+
5
+ import { __commonJS, __require } from "./chunk-BeeFIeNn.js";
6
+
7
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-unsupported.js
8
+ var require_getMachineId_unsupported = __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-unsupported.js"(exports) {
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getMachineId = void 0;
11
+ const api_1 = __require("@opentelemetry/api");
12
+ async function getMachineId() {
13
+ api_1.diag.debug("could not read machine-id: unsupported platform");
14
+ return void 0;
15
+ }
16
+ exports.getMachineId = getMachineId;
17
+ } });
18
+
19
+ //#endregion
20
+ export default require_getMachineId_unsupported();
@@ -0,0 +1,32 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ globalThis.addEventListener = () => {};
4
+
5
+ import { __commonJS, __require } from "./chunk-BeeFIeNn.js";
6
+ import { require_execAsync } from "./execAsync-DrQE_9g2.js";
7
+
8
+ //#region ../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-win.js
9
+ var require_getMachineId_win = __commonJS({ "../../node_modules/.pnpm/@opentelemetry+resources@2.2.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/src/detectors/platform/node/machine-id/getMachineId-win.js"(exports) {
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getMachineId = void 0;
12
+ const process = __require("process");
13
+ const execAsync_1 = require_execAsync();
14
+ const api_1 = __require("@opentelemetry/api");
15
+ async function getMachineId() {
16
+ const args = "QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid";
17
+ let command = "%windir%\\System32\\REG.exe";
18
+ if (process.arch === "ia32" && "PROCESSOR_ARCHITEW6432" in process.env) command = "%windir%\\sysnative\\cmd.exe /c " + command;
19
+ try {
20
+ const result = await (0, execAsync_1.execAsync)(`${command} ${args}`);
21
+ const parts = result.stdout.split("REG_SZ");
22
+ if (parts.length === 2) return parts[1].trim();
23
+ } catch (e) {
24
+ api_1.diag.debug(`error reading machine id: ${e}`);
25
+ }
26
+ return void 0;
27
+ }
28
+ exports.getMachineId = getMachineId;
29
+ } });
30
+
31
+ //#endregion
32
+ export default require_getMachineId_win();
@@ -2,16 +2,14 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
 
5
- import { Collection, Note, Object as Object$1, Person } from "./vocab-DBispxj5.js";
6
- import { deno_default, esm_default } from "./deno-B-ypIMwF.js";
7
- import { getTypeId } from "./type-CNuABalk.js";
8
- import { assertInstanceOf } from "./utils-BSWXlrig.js";
9
- import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
5
+ import { Collection, Note, Object as Object$1, Person, createTestTracerProvider, getDocumentLoader, mockDocumentLoader, test } from "./vocab-BCnUNobC.js";
6
+ import { deno_default, esm_default } from "./deno-CDgxQSI_.js";
7
+ import { getTypeId } from "./type-Dnf0m2yO.js";
8
+ import { assertInstanceOf } from "./utils-Dm0Onkcz.js";
9
+ import { getLogger } from "@logtape/logtape";
10
+ import { SpanStatusCode, trace } from "@opentelemetry/api";
10
11
  import { deepStrictEqual, equal, ok, rejects } from "node:assert/strict";
11
12
  import { lookupWebFinger } from "@fedify/webfinger";
12
- import { SpanStatusCode, trace } from "@opentelemetry/api";
13
- import { getLogger } from "@logtape/logtape";
14
- import { getDocumentLoader } from "@fedify/vocab-runtime";
15
13
  import { delay } from "es-toolkit";
16
14
 
17
15
  //#region src/handle.ts