@camox/api-contract 0.56.0 → 0.58.0
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/index.d.ts +6 -0
- package/dist/index.js +12 -1
- package/dist/patrol.d.ts +114 -0
- package/dist/patrol.js +8 -0
- package/dist/query-keys.d.ts +3 -0
- package/dist/query-keys.js +2 -1
- package/dist/router.d.ts +294 -138
- package/dist/threads.d.ts +79 -26
- package/dist/threads.js +90 -24
- package/package.json +5 -1
- package/src/artifact.ts +12 -0
- package/src/patrol.ts +113 -0
- package/src/query-keys.ts +4 -0
- package/src/threads.ts +131 -34
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export declare const UNTITLED_ARTIFACT = "Untitled artifact";
|
|
|
10
10
|
export declare function artifactSourceTitle(source: string): string | undefined;
|
|
11
11
|
/** The artifact's name: its source's `<title>`, or "Untitled artifact". */
|
|
12
12
|
export declare function artifactTitle(source: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* The hash an artifact source is stored and served under: the SHA-256 of its UTF-8 bytes, in
|
|
15
|
+
* URL-safe base64 without padding. Shared by the API, which stores sources under it, and the SDK,
|
|
16
|
+
* which names the URLs public pages load artifacts from.
|
|
17
|
+
*/
|
|
18
|
+
export declare function artifactSourceHash(source: string): Promise<string>;
|
|
13
19
|
//#endregion
|
|
14
20
|
//#region src/record-templates.d.ts
|
|
15
21
|
/**
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,17 @@ function artifactSourceTitle(source) {
|
|
|
31
31
|
function artifactTitle(source) {
|
|
32
32
|
return artifactSourceTitle(source) ?? "Untitled artifact";
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The hash an artifact source is stored and served under: the SHA-256 of its UTF-8 bytes, in
|
|
36
|
+
* URL-safe base64 without padding. Shared by the API, which stores sources under it, and the SDK,
|
|
37
|
+
* which names the URLs public pages load artifacts from.
|
|
38
|
+
*/
|
|
39
|
+
async function artifactSourceHash(source) {
|
|
40
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(source));
|
|
41
|
+
let binary = "";
|
|
42
|
+
for (const byte of new Uint8Array(digest)) binary += String.fromCharCode(byte);
|
|
43
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
44
|
+
}
|
|
34
45
|
|
|
35
46
|
//#endregion
|
|
36
47
|
//#region src/record-templates.ts
|
|
@@ -133,4 +144,4 @@ function isSettingCondition(value) {
|
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
//#endregion
|
|
136
|
-
export { ARTICLE_TYPES, ICON_CATALOG_VERSION, PAGE_TEXT_LINK_PREFIX, QUERY_LIMIT_CAP, SYSTEM_ORDER_KEYS, UNTITLED_ARTIFACT, artifactSourceTitle, artifactTitle, generateUuidv7, isPageUrlMarker, isQueryBacked, isSettingCondition, isSystemOrderKey, linkedRecordId, nonStringTemplateFields, projectIdSchema, recordLink, recordText, referenceQueryProblem, scopeIconSvgIds, templateFields, uuidv7JsonSchema, uuidv7Schema, validateIconValue };
|
|
147
|
+
export { ARTICLE_TYPES, ICON_CATALOG_VERSION, PAGE_TEXT_LINK_PREFIX, QUERY_LIMIT_CAP, SYSTEM_ORDER_KEYS, UNTITLED_ARTIFACT, artifactSourceHash, artifactSourceTitle, artifactTitle, generateUuidv7, isPageUrlMarker, isQueryBacked, isSettingCondition, isSystemOrderKey, linkedRecordId, nonStringTemplateFields, projectIdSchema, recordLink, recordText, referenceQueryProblem, scopeIconSvgIds, templateFields, uuidv7JsonSchema, uuidv7Schema, validateIconValue };
|
package/dist/patrol.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//#region src/patrol.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The Patrol (ADR 0024): every patroller of a project, the work each did as reports, as the
|
|
4
|
+
* studio shows it at the top of the Agent Sidebar. The API reads it for one scope, a draft or
|
|
5
|
+
* Live, and names each report's subject, so the studio needs no entity loaded to show it.
|
|
6
|
+
*/
|
|
7
|
+
/** A patroller's stable id. The registry in the API lists them all. */
|
|
8
|
+
export type PatrollerId = "translator" | "seoManager";
|
|
9
|
+
/**
|
|
10
|
+
* What a structured report says was done. Each has a failed form, by the report's outcome. A
|
|
11
|
+
* merge with Live's localization reads as a translation.
|
|
12
|
+
*/
|
|
13
|
+
export type ReportVerb = "translated" | "mergedWithLive" | "wroteSeo" | "describedFile" | "publishedCatchUp";
|
|
14
|
+
/** What a report can be about. */
|
|
15
|
+
export type ReportEntity = "page" | "block" | "sharedContent" | "repeatableItem" | "record" | "file";
|
|
16
|
+
/** A report's subject, named as the Canvas names it, read when the Patrol is. */
|
|
17
|
+
export type ReportSubject = {
|
|
18
|
+
entity: ReportEntity;
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* What a report says: structured facts the studio turns into a sentence, in the studio's
|
|
24
|
+
* language, or text an AI wrote, shown as is. `locale` is a locale's tag.
|
|
25
|
+
*/
|
|
26
|
+
export type ReportSummary = {
|
|
27
|
+
kind: "structured";
|
|
28
|
+
verb: ReportVerb;
|
|
29
|
+
subject: ReportSubject | null;
|
|
30
|
+
locale: string | null;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "text";
|
|
33
|
+
text: string;
|
|
34
|
+
};
|
|
35
|
+
/** The locale a summary's work was in: a structured summary's, if any. A text summary has none. */
|
|
36
|
+
export declare const reportLocale: (summary: {
|
|
37
|
+
kind: "structured";
|
|
38
|
+
locale: string | null;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "text";
|
|
41
|
+
}) => string | null;
|
|
42
|
+
/** Whether the work was done, or failed. A failure shows in its report only. */
|
|
43
|
+
export type ReportOutcome = "done" | "failed";
|
|
44
|
+
/** Whether a report needs a human. Nothing raises one yet. */
|
|
45
|
+
export type AttentionLevel = "none" | "needed";
|
|
46
|
+
/**
|
|
47
|
+
* Where the studio shows a report's subject: a page on the Canvas, with the block and repeatable
|
|
48
|
+
* item to select on it, a collection record, or a file.
|
|
49
|
+
*/
|
|
50
|
+
export type ReportPlace = {
|
|
51
|
+
kind: "page";
|
|
52
|
+
pageId: string;
|
|
53
|
+
blockId: string | null;
|
|
54
|
+
itemId: string | null;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "record";
|
|
57
|
+
collectionId: string;
|
|
58
|
+
recordId: string;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "file";
|
|
61
|
+
fileId: string;
|
|
62
|
+
};
|
|
63
|
+
export type ReportView = {
|
|
64
|
+
/** Unique among the patroller's reports in the view. */
|
|
65
|
+
id: string;
|
|
66
|
+
summary: ReportSummary;
|
|
67
|
+
outcome: ReportOutcome;
|
|
68
|
+
attention: AttentionLevel;
|
|
69
|
+
/** When the work last settled, in milliseconds since the epoch. */
|
|
70
|
+
at: number;
|
|
71
|
+
/** Whether the report is Live's, seen from a draft or from Live. */
|
|
72
|
+
live: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Where its subject shows, in the report's scope and locale. Null without a subject, or for one
|
|
75
|
+
* with no single place, such as a synced block's shared content or a layout's block.
|
|
76
|
+
*/
|
|
77
|
+
place: ReportPlace | null;
|
|
78
|
+
};
|
|
79
|
+
/** How many subjects a patroller is on in one locale, a locale's tag. */
|
|
80
|
+
export type LocaleCount = {
|
|
81
|
+
locale: string;
|
|
82
|
+
count: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* What a patroller is on: the one subject when there's one, and how many subjects in each
|
|
86
|
+
* locale, the most first. A subject in several locales counts in each.
|
|
87
|
+
*/
|
|
88
|
+
export type PatrollerWorking = {
|
|
89
|
+
subject: ReportSubject | null;
|
|
90
|
+
locales: LocaleCount[];
|
|
91
|
+
};
|
|
92
|
+
export type PatrollerView = {
|
|
93
|
+
id: PatrollerId;
|
|
94
|
+
/** Its role, as editors know it: "Translator", "SEO manager". */
|
|
95
|
+
role: string;
|
|
96
|
+
/** Null when it isn't working in the scope. */
|
|
97
|
+
working: PatrollerWorking | null;
|
|
98
|
+
/** Its latest activity in the scope, or null when it never worked there. */
|
|
99
|
+
lastActivityAt: number | null;
|
|
100
|
+
/** Its newest reports, newest first. */
|
|
101
|
+
reports: ReportView[];
|
|
102
|
+
/** How many more reports it has than `reports` shows, per locale, the most first. */
|
|
103
|
+
more: {
|
|
104
|
+
locale: string | null;
|
|
105
|
+
count: number;
|
|
106
|
+
}[];
|
|
107
|
+
};
|
|
108
|
+
/** Every patroller of the registry, the latest activity first; never-worked ones last. */
|
|
109
|
+
export type PatrolView = {
|
|
110
|
+
patrollers: PatrollerView[];
|
|
111
|
+
};
|
|
112
|
+
/** How many reports the Patrol shows of each patroller; the rest are counted. */
|
|
113
|
+
export declare const REPORTS_SHOWN = 5;
|
|
114
|
+
//#endregion
|
package/dist/patrol.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/patrol.ts
|
|
2
|
+
/** The locale a summary's work was in: a structured summary's, if any. A text summary has none. */
|
|
3
|
+
const reportLocale = (summary) => summary.kind === "structured" ? summary.locale : null;
|
|
4
|
+
/** How many reports the Patrol shows of each patroller; the rest are counted. */
|
|
5
|
+
const REPORTS_SHOWN = 5;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { REPORTS_SHOWN, reportLocale };
|
package/dist/query-keys.d.ts
CHANGED
|
@@ -40,6 +40,9 @@ export declare const queryKeys: {
|
|
|
40
40
|
list: ["camox", string, string];
|
|
41
41
|
get: ["camox", string, string];
|
|
42
42
|
};
|
|
43
|
+
patrol: {
|
|
44
|
+
get: ["camox", string];
|
|
45
|
+
};
|
|
43
46
|
};
|
|
44
47
|
/** The last segment of a query key: what the query reads, Live or a draft (ADR 0011). */
|
|
45
48
|
export declare const LIVE_KEY_SCOPE = "live";
|
package/dist/query-keys.js
CHANGED