@tunasand/sdk 0.0.0-stage → 0.6.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/CHANGELOG.md +106 -0
- package/README.md +506 -2
- package/dist/analytics.d.ts +1 -0
- package/dist/analytics.js +43 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +825 -0
- package/dist/apps-9u4XMi7E.js +114 -0
- package/dist/body.d.ts +1 -0
- package/dist/body.js +455 -0
- package/dist/bridge-DYAYGV7t.js +74 -0
- package/dist/bridge.d.ts +1 -0
- package/dist/bridge.js +189 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +283 -0
- package/dist/client-Derrexwr.js +159 -0
- package/dist/customers-C_vJY2_v.js +84 -0
- package/dist/customers.d.ts +1 -0
- package/dist/customers.js +185 -0
- package/dist/declared-C_GvPiGF.js +397 -0
- package/dist/delivery.d.ts +1 -0
- package/dist/delivery.js +348 -0
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +93 -0
- package/dist/embed-R-OvDYAw.js +90 -0
- package/dist/errorLabels-BcyRbv_i.js +1510 -0
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.js +4 -0
- package/dist/integrations.d.ts +1 -0
- package/dist/integrations.js +62 -0
- package/dist/ja-C1HEWWTQ.js +241 -0
- package/dist/ja-C6lX0CeJ.js +213 -0
- package/dist/model-pmXzGX12.js +152 -0
- package/dist/model.d.ts +1 -0
- package/dist/model.js +345 -0
- package/dist/page-E_cYgZx-.js +138 -0
- package/dist/preview.d.ts +1 -0
- package/dist/preview.js +1 -0
- package/dist/profile-D6t1QMQh.js +223 -0
- package/dist/schema-BPHL7Qr-.js +115 -0
- package/dist/schema-UQJWRyfJ.js +995 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +1 -0
- package/dist/src-sazhzYui.js +71 -0
- package/dist/types/access/src/handoff.d.ts +52 -0
- package/dist/types/access/src/index.d.ts +5 -0
- package/dist/types/access/src/jws.d.ts +5 -0
- package/dist/types/access/src/jwt.d.ts +35 -0
- package/dist/types/access/src/oidc.d.ts +50 -0
- package/dist/types/access/src/signed.d.ts +15 -0
- package/dist/types/analytics/src/day.d.ts +2 -0
- package/dist/types/analytics/src/index.d.ts +5 -0
- package/dist/types/analytics/src/schedule.d.ts +2 -0
- package/dist/types/analytics/src/shared.d.ts +21 -0
- package/dist/types/analytics/src/source.d.ts +19 -0
- package/dist/types/analytics/src/store.d.ts +24 -0
- package/dist/types/analytics/src/view.d.ts +33 -0
- package/dist/types/body/src/components.d.ts +25 -0
- package/dist/types/body/src/declared.d.ts +34 -0
- package/dist/types/body/src/derive.d.ts +13 -0
- package/dist/types/body/src/description.d.ts +8 -0
- package/dist/types/body/src/embed.d.ts +16 -0
- package/dist/types/body/src/href.d.ts +4 -0
- package/dist/types/body/src/html.d.ts +30 -0
- package/dist/types/body/src/index.d.ts +19 -0
- package/dist/types/body/src/inline.d.ts +20 -0
- package/dist/types/body/src/labels/en.d.ts +90 -0
- package/dist/types/body/src/labels/ja.d.ts +153 -0
- package/dist/types/body/src/library.d.ts +113 -0
- package/dist/types/body/src/markdown.d.ts +14 -0
- package/dist/types/body/src/normalize.d.ts +5 -0
- package/dist/types/body/src/problems.d.ts +103 -0
- package/dist/types/body/src/profile.d.ts +80 -0
- package/dist/types/body/src/render.d.ts +29 -0
- package/dist/types/body/src/schema.d.ts +6 -0
- package/dist/types/body/src/standard.d.ts +20 -0
- package/dist/types/body/src/types.d.ts +140 -0
- package/dist/types/cms-contract/src/apiKeys.d.ts +41 -0
- package/dist/types/cms-contract/src/app.d.ts +35 -0
- package/dist/types/cms-contract/src/appDependencies.d.ts +265 -0
- package/dist/types/cms-contract/src/appProblems.d.ts +22 -0
- package/dist/types/cms-contract/src/apps.d.ts +195 -0
- package/dist/types/cms-contract/src/assets.d.ts +12 -0
- package/dist/types/cms-contract/src/authorize.d.ts +146 -0
- package/dist/types/cms-contract/src/bridge.d.ts +318 -0
- package/dist/types/cms-contract/src/consents.d.ts +97 -0
- package/dist/types/cms-contract/src/customerLabels.d.ts +33 -0
- package/dist/types/cms-contract/src/customers.d.ts +266 -0
- package/dist/types/cms-contract/src/embeds.d.ts +165 -0
- package/dist/types/cms-contract/src/errorLabels.d.ts +269 -0
- package/dist/types/cms-contract/src/errorLabelsEn.d.ts +228 -0
- package/dist/types/cms-contract/src/errors.d.ts +105 -0
- package/dist/types/cms-contract/src/failureStatus.d.ts +124 -0
- package/dist/types/cms-contract/src/functionLabels.d.ts +5 -0
- package/dist/types/cms-contract/src/functions.d.ts +144 -0
- package/dist/types/cms-contract/src/identifiers.d.ts +117 -0
- package/dist/types/cms-contract/src/import.d.ts +277 -0
- package/dist/types/cms-contract/src/issueLabels.d.ts +435 -0
- package/dist/types/cms-contract/src/issueLabelsEn.d.ts +217 -0
- package/dist/types/cms-contract/src/migration.d.ts +103 -0
- package/dist/types/cms-contract/src/paths.d.ts +23 -0
- package/dist/types/cms-contract/src/permissionLabels.d.ts +8 -0
- package/dist/types/cms-contract/src/permissions.d.ts +77 -0
- package/dist/types/cms-contract/src/problems.d.ts +34 -0
- package/dist/types/cms-contract/src/roles.d.ts +57 -0
- package/dist/types/cms-contract/src/settingProblems.d.ts +13 -0
- package/dist/types/cms-contract/src/settings.d.ts +19 -0
- package/dist/types/cms-contract/src/siteArtifact.d.ts +45 -0
- package/dist/types/cms-contract/src/siteDeclaration.d.ts +70 -0
- package/dist/types/cms-contract/src/transfer.d.ts +57 -0
- package/dist/types/cms-contract/src/views.d.ts +21 -0
- package/dist/types/cms-contract/src/webhookLabels.d.ts +7 -0
- package/dist/types/cms-contract/src/webhooks.d.ts +139 -0
- package/dist/types/i18n/src/index.d.ts +50 -0
- package/dist/types/i18n/src/problems.d.ts +21 -0
- package/dist/types/model/src/asset.d.ts +111 -0
- package/dist/types/model/src/audience.d.ts +38 -0
- package/dist/types/model/src/brand.d.ts +25 -0
- package/dist/types/model/src/capabilities.d.ts +28 -0
- package/dist/types/model/src/changes.d.ts +34 -0
- package/dist/types/model/src/check.d.ts +15 -0
- package/dist/types/model/src/contact.d.ts +22 -0
- package/dist/types/model/src/image.d.ts +38 -0
- package/dist/types/model/src/index.d.ts +26 -0
- package/dist/types/model/src/input.d.ts +26 -0
- package/dist/types/model/src/integrity.d.ts +79 -0
- package/dist/types/model/src/json.d.ts +2 -0
- package/dist/types/model/src/labels/en.d.ts +169 -0
- package/dist/types/model/src/labels/ja.d.ts +198 -0
- package/dist/types/model/src/legacy.d.ts +2 -0
- package/dist/types/model/src/media.d.ts +5 -0
- package/dist/types/model/src/mediaUrl.d.ts +67 -0
- package/dist/types/model/src/model.d.ts +415 -0
- package/dist/types/model/src/page.d.ts +52 -0
- package/dist/types/model/src/problems.d.ts +184 -0
- package/dist/types/model/src/refs.d.ts +27 -0
- package/dist/types/model/src/rules.d.ts +15 -0
- package/dist/types/model/src/schema.d.ts +58 -0
- package/dist/types/model/src/screens.d.ts +76 -0
- package/dist/types/model/src/selfOps.d.ts +30 -0
- package/dist/types/model/src/time.d.ts +25 -0
- package/dist/types/model/src/typesSource.d.ts +8 -0
- package/dist/types/model/src/values.d.ts +24 -0
- package/dist/types/platform/src/defaultModel.d.ts +8 -0
- package/dist/types/sdk/src/analytics.d.ts +2 -0
- package/dist/types/sdk/src/app.d.ts +20 -0
- package/dist/types/sdk/src/body.d.ts +2 -0
- package/dist/types/sdk/src/bridge.d.ts +92 -0
- package/dist/types/sdk/src/cli.d.ts +2 -0
- package/dist/types/sdk/src/customers.d.ts +190 -0
- package/dist/types/sdk/src/delivery/cache.d.ts +18 -0
- package/dist/types/sdk/src/delivery/changes.d.ts +28 -0
- package/dist/types/sdk/src/delivery/client.d.ts +90 -0
- package/dist/types/sdk/src/delivery/fields.d.ts +48 -0
- package/dist/types/sdk/src/delivery/index.d.ts +9 -0
- package/dist/types/sdk/src/delivery/media.d.ts +14 -0
- package/dist/types/sdk/src/delivery/query.d.ts +85 -0
- package/dist/types/sdk/src/delivery/schema.d.ts +19 -0
- package/dist/types/sdk/src/delivery/values.d.ts +82 -0
- package/dist/types/sdk/src/delivery.d.ts +3 -0
- package/dist/types/sdk/src/dev.d.ts +29 -0
- package/dist/types/sdk/src/i18n.d.ts +12 -0
- package/dist/types/sdk/src/integrations.d.ts +33 -0
- package/dist/types/sdk/src/model.d.ts +5 -0
- package/dist/types/sdk/src/preview.d.ts +1 -0
- package/dist/types/sdk/src/schema.d.ts +21 -0
- package/dist/types/sdk/src/site.d.ts +43 -0
- package/dist/typesSource-bO0jFw1I.js +88 -0
- package/package.json +86 -3
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/sdk/src/schema.js';
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as TYPES_EXIT_CODES, n as fetchDeliveredCollections, r as runTypesCli } from "./schema-BPHL7Qr-.js";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// ../access/src/signed.ts
|
|
2
|
+
const enc$1 = new TextEncoder();
|
|
3
|
+
/** base64url の復号 */
|
|
4
|
+
const decodeBase64Url = (s) => Uint8Array.from(atob(s.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(s.length / 4) * 4, "=")), (c) => c.charCodeAt(0));
|
|
5
|
+
/** 経路ごとのヘッダーの名前(署名と主体) */
|
|
6
|
+
const SIGNED_HEADERS = {
|
|
7
|
+
/** MCP → CMS の署名(鍵は MCP_TOKEN、主体は Authorization のアクセストークン。Worker を通ったことの証明だけで、主体はトークンから CMS が決める) */
|
|
8
|
+
mcp: "x-mcp-signature",
|
|
9
|
+
/** CMS ⇄ サイトのプレビューと下書きの署名(鍵は PREVIEW_TOKEN) */
|
|
10
|
+
preview: "x-preview-signature"
|
|
11
|
+
};
|
|
12
|
+
const hmacKey$1 = (secret) => crypto.subtle.importKey("raw", enc$1.encode(secret), {
|
|
13
|
+
name: "HMAC",
|
|
14
|
+
hash: "SHA-256"
|
|
15
|
+
}, false, ["sign", "verify"]);
|
|
16
|
+
/** 鍵の一覧(空の値を除く) */
|
|
17
|
+
const secretsOf = (secret) => (typeof secret === "string" ? [secret] : [...secret ?? []]).filter(Boolean);
|
|
18
|
+
/** 封印した値(鍵のどれかで署名が合えば値、署名の不一致・期限切れ・形の誤りは null) */
|
|
19
|
+
async function openValue(secret, token, now = Date.now()) {
|
|
20
|
+
const [body, sig] = token?.split(".") ?? [];
|
|
21
|
+
const secrets = secretsOf(secret);
|
|
22
|
+
if (!secrets.length || !body || !sig) return null;
|
|
23
|
+
try {
|
|
24
|
+
let matched = false;
|
|
25
|
+
for (const s of secrets) if (!matched) matched = await crypto.subtle.verify("HMAC", await hmacKey$1(s), decodeBase64Url(sig), enc$1.encode(body));
|
|
26
|
+
if (!matched) return null;
|
|
27
|
+
const { v, exp } = JSON.parse(new TextDecoder().decode(decodeBase64Url(body)));
|
|
28
|
+
return typeof exp === "number" && exp * 1e3 > now ? v : null;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// ../access/src/jws.ts
|
|
34
|
+
const enc = new TextEncoder();
|
|
35
|
+
const fromBase64Url = (text) => {
|
|
36
|
+
if (!/^[A-Za-z0-9_-]*$/.test(text)) return null;
|
|
37
|
+
try {
|
|
38
|
+
return Uint8Array.from(atob(text.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(text.length / 4) * 4, "=")), (c) => c.charCodeAt(0));
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
44
|
+
const decodePart = (part) => {
|
|
45
|
+
const bytes = fromBase64Url(part);
|
|
46
|
+
if (!bytes) return null;
|
|
47
|
+
try {
|
|
48
|
+
const value = JSON.parse(new TextDecoder().decode(bytes));
|
|
49
|
+
return isRecord(value) ? value : null;
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const hmacKey = (secret) => crypto.subtle.importKey("raw", enc.encode(secret), {
|
|
55
|
+
name: "HMAC",
|
|
56
|
+
hash: "SHA-256"
|
|
57
|
+
}, false, ["sign", "verify"]);
|
|
58
|
+
/** HS256 の JWT のクレーム(鍵のどれかで署名が合えばクレーム、形の誤り、alg の違い、署名の不一致は null。期限などは見ない) */
|
|
59
|
+
async function verifyHs256Jwt(secret, token) {
|
|
60
|
+
const parts = token?.split(".") ?? [];
|
|
61
|
+
if (parts.length !== 3) return null;
|
|
62
|
+
const [head, body, sig] = parts;
|
|
63
|
+
const header = decodePart(head);
|
|
64
|
+
const claims = decodePart(body);
|
|
65
|
+
const signature = fromBase64Url(sig);
|
|
66
|
+
if (header?.alg !== "HS256" || !claims || !signature) return null;
|
|
67
|
+
const data = enc.encode(`${head}.${body}`);
|
|
68
|
+
for (const s of (typeof secret === "string" ? [secret] : secret).filter(Boolean)) if (await crypto.subtle.verify("HMAC", await hmacKey(s), signature, data)) return claims;
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
export { SIGNED_HEADERS as n, openValue as r, verifyHs256Jwt as t };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { LoginAuth } from './oidc.js';
|
|
2
|
+
/** プロジェクトに結び付いたセッションの値(host は発行した CMS のホスト名、project はそのときのホスト名のプロジェクトの ID、issuedAt は発行の時刻でミリ秒) */
|
|
3
|
+
export type HostSession = Readonly<{
|
|
4
|
+
email: string;
|
|
5
|
+
host: string;
|
|
6
|
+
project: string;
|
|
7
|
+
issuedAt: number;
|
|
8
|
+
}>;
|
|
9
|
+
/** ホスト名のプロジェクトの ID(台帳にないホスト名は null) */
|
|
10
|
+
export type ProjectOfHost = (host: string) => Promise<string | null>;
|
|
11
|
+
/** プロジェクトの一括の取り消しの時刻(ミリ秒、取り消しなしは null) */
|
|
12
|
+
export type SessionsValidAfter = (project: string) => Promise<number | null>;
|
|
13
|
+
/**
|
|
14
|
+
* リクエストのホスト名に結び付いたセッションのメールアドレス(なし・別のホスト・古い形・取り消した後は null)
|
|
15
|
+
* - ホスト名を projectOf で引いたプロジェクトと、セッションのプロジェクトが同じときだけ(値にプロジェクトのない古い形は通さない)
|
|
16
|
+
* - validAfter があれば、その時刻より後に発行したセッションだけ
|
|
17
|
+
*/
|
|
18
|
+
export declare function hostSessionEmail(request: Request, secret: string, cookie: string | null, projectOf: ProjectOfHost, validAfter?: SessionsValidAfter): Promise<string | null>;
|
|
19
|
+
/** セッションの Cookie の名前(https は __Host- の接頭辞) */
|
|
20
|
+
export declare const sessionCookieName: (url: URL) => string;
|
|
21
|
+
/** セッションの Cookie の Set-Cookie の値(maxAgeSec が0は削除) */
|
|
22
|
+
export declare const sessionCookie: (url: URL, value: string, maxAgeSec: number) => string;
|
|
23
|
+
/** リクエストの Cookie の値(なければ null) */
|
|
24
|
+
export declare const cookieValue: (request: Request, name: string) => string | null;
|
|
25
|
+
/** セッションの値(なし・署名の不一致・期限切れは null) */
|
|
26
|
+
export declare const openSession: <T>(request: Request, secret: string) => Promise<T | null>;
|
|
27
|
+
/** 引き継ぎのログインの設定 */
|
|
28
|
+
export type HandoffLoginOptions = Readonly<{
|
|
29
|
+
/** Cookie の署名の鍵 */
|
|
30
|
+
secret: string;
|
|
31
|
+
/** manage のログインの URL(例: https://console.example.com/login) */
|
|
32
|
+
loginUrl: string;
|
|
33
|
+
/** トークンを消して使い、メールアドレスを返す(使えないトークンは null、host は CMS のホスト名) */
|
|
34
|
+
consume(token: string, host: string): Promise<string | null>;
|
|
35
|
+
/** ホスト名のプロジェクトの ID(セッションの発行と照合の両方で引く) */
|
|
36
|
+
projectOf: ProjectOfHost;
|
|
37
|
+
/** プロジェクトの一括の取り消しの時刻(照合で引く。なしは取り消しを見ない) */
|
|
38
|
+
validAfter?: SessionsValidAfter;
|
|
39
|
+
/** 入り口のパスの頭(既定 /auth) */
|
|
40
|
+
basePath?: string;
|
|
41
|
+
/** セッションの秒数(既定は12時間) */
|
|
42
|
+
sessionTtlSec?: number;
|
|
43
|
+
/** 今の時刻(ミリ秒、試験で差し替える) */
|
|
44
|
+
now?: () => number;
|
|
45
|
+
}>;
|
|
46
|
+
/** manage からの引き継ぎのログイン */
|
|
47
|
+
export declare function handoffLogin({ secret, loginUrl, consume, projectOf, validAfter, basePath, sessionTtlSec, now }: HandoffLoginOptions): LoginAuth;
|
|
48
|
+
/**
|
|
49
|
+
* 2つのログインを順に試す(emailOf は first が null なら second、入り口とログアウトは first)
|
|
50
|
+
* - 用途: 引き継ぎのログインに加えて、運営者のログイン(apps/api の operator.ts)を受け付ける
|
|
51
|
+
*/
|
|
52
|
+
export declare function eitherLogin(first: LoginAuth, second: LoginAuth): LoginAuth;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { accessJwtOptions, type FetchCerts, type JwtClaims, type JwtOptions, verifyAccessJwt, verifyJwt } from './jwt.js';
|
|
2
|
+
export { cookieValue, eitherLogin, handoffLogin, type HandoffLoginOptions, openSession, type ProjectOfHost, sessionCookie, sessionCookieName } from './handoff.js';
|
|
3
|
+
export { emailOfClaims, type LoginAuth, oidcLogin, type OidcLoginOptions, safeNext, tokenAuth, type TokenAuthOptions } from './oidc.js';
|
|
4
|
+
export { mcpSigningKey, openValue, sealValue, SIGNED_HEADERS, type SigningSecrets } from './signed.js';
|
|
5
|
+
export { signHs256Jwt, verifyHs256Jwt } from './jws.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SigningSecrets } from './signed.js';
|
|
2
|
+
/** HS256 で署名した JWT(typ は JWT) */
|
|
3
|
+
export declare function signHs256Jwt(secret: string, claims: Readonly<Record<string, unknown>>): Promise<string>;
|
|
4
|
+
/** HS256 の JWT のクレーム(鍵のどれかで署名が合えばクレーム、形の誤り、alg の違い、署名の不一致は null。期限などは見ない) */
|
|
5
|
+
export declare function verifyHs256Jwt(secret: SigningSecrets, token: string | null | undefined): Promise<Record<string, unknown> | null>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** JWT のクレーム(検証を通った値) */
|
|
2
|
+
export type JwtClaims = Readonly<Record<string, unknown>>;
|
|
3
|
+
/** 公開鍵の一覧の取得の差し替え(テスト用、引数は JWKS の URL) */
|
|
4
|
+
export type FetchCerts = (jwksUrl: string) => Promise<{
|
|
5
|
+
keys: JsonWebKey[];
|
|
6
|
+
}>;
|
|
7
|
+
/** JWT の検証の設定 */
|
|
8
|
+
export type JwtOptions = Readonly<{
|
|
9
|
+
/** 発行元(iss と完全に一致) */
|
|
10
|
+
issuer: string;
|
|
11
|
+
/** 宛先(aud のどれかと一致、一覧はどれか1つと一致) */
|
|
12
|
+
audience: string | readonly string[];
|
|
13
|
+
/** 公開鍵の一覧の URL */
|
|
14
|
+
jwksUrl: string;
|
|
15
|
+
/** 現在時刻(ミリ秒、テスト用) */
|
|
16
|
+
now?: number;
|
|
17
|
+
certs?: FetchCerts;
|
|
18
|
+
}>;
|
|
19
|
+
/** 検証を通った JWT のクレーム(署名・発行元・宛先・期限のどれかが違えば null) */
|
|
20
|
+
export declare function verifyJwt(token: string, options: JwtOptions): Promise<JwtClaims | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Cloudflare Access の JWT を検証する設定(teamDomain は <チーム>.cloudflareaccess.com、aud はアプリの AUD)
|
|
23
|
+
* - aud: カンマ区切りで複数のアプリ(ホスト名ごとにアプリが分かれる管理画面、どのアプリを通すかは Access がホスト名で判定)
|
|
24
|
+
*/
|
|
25
|
+
export declare const accessJwtOptions: ({ teamDomain, aud }: Readonly<{
|
|
26
|
+
teamDomain: string;
|
|
27
|
+
aud: string;
|
|
28
|
+
}>) => Pick<JwtOptions, "issuer" | "audience" | "jwksUrl">;
|
|
29
|
+
/** Access の検証を通ったログインのメールアドレス、サービストークンは service:<クライアントの ID>(通らなければ null) */
|
|
30
|
+
export declare function verifyAccessJwt(token: string, { teamDomain, aud, now, certs }: {
|
|
31
|
+
teamDomain: string;
|
|
32
|
+
aud: string;
|
|
33
|
+
now?: number;
|
|
34
|
+
certs?: FetchCerts;
|
|
35
|
+
}): Promise<string | null>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type FetchCerts, type JwtClaims, type JwtOptions } from './jwt.js';
|
|
2
|
+
import { type ProjectOfHost } from './handoff.js';
|
|
3
|
+
/** ログイン(Auth のポートと同じ形) */
|
|
4
|
+
export type LoginAuth = {
|
|
5
|
+
emailOf(request: Request): Promise<string | null>;
|
|
6
|
+
/** ログインの入り口の応答(対象外のパスは null) */
|
|
7
|
+
handle?(request: Request): Promise<Response | null>;
|
|
8
|
+
/** ログアウトの応答 */
|
|
9
|
+
logout?(request: Request): Promise<Response>;
|
|
10
|
+
};
|
|
11
|
+
/** クレームのメールアドレス(なし・未検証は null、小文字に統一) */
|
|
12
|
+
export declare function emailOfClaims(claims: JwtClaims | null, claim?: string): string | null;
|
|
13
|
+
/** ヘッダーの JWT で判定するログインの設定 */
|
|
14
|
+
export type TokenAuthOptions = Readonly<{
|
|
15
|
+
issuer: string;
|
|
16
|
+
audience: JwtOptions['audience'];
|
|
17
|
+
/** 公開鍵の一覧の URL(なしは発行元の OIDC の設定から) */
|
|
18
|
+
jwksUrl?: string;
|
|
19
|
+
/** JWT のヘッダー(既定 authorization、authorization は Bearer を除外) */
|
|
20
|
+
header?: string;
|
|
21
|
+
/** メールアドレスのクレーム(既定 email) */
|
|
22
|
+
emailClaim?: string;
|
|
23
|
+
certs?: FetchCerts;
|
|
24
|
+
fetch?: typeof fetch;
|
|
25
|
+
}>;
|
|
26
|
+
/** ヘッダーの JWT を検証するログイン */
|
|
27
|
+
export declare function tokenAuth({ issuer, audience, jwksUrl, header, emailClaim, certs, fetch: fetcher }: TokenAuthOptions): LoginAuth;
|
|
28
|
+
/** アプリ自身が行う OIDC のログインの設定 */
|
|
29
|
+
export type OidcLoginOptions = Readonly<{
|
|
30
|
+
issuer: string;
|
|
31
|
+
clientId: string;
|
|
32
|
+
/** クライアントの秘密の値(公開のクライアントは なし、PKCE だけ) */
|
|
33
|
+
clientSecret?: string;
|
|
34
|
+
/** Cookie の署名の鍵 */
|
|
35
|
+
secret: string;
|
|
36
|
+
/** ホスト名のプロジェクトの ID(セッションの発行と照合の両方で引く。handoff.ts と同じ) */
|
|
37
|
+
projectOf: ProjectOfHost;
|
|
38
|
+
/** 入り口のパスの頭(既定 /auth) */
|
|
39
|
+
basePath?: string;
|
|
40
|
+
/** 要求するスコープ(既定 openid email) */
|
|
41
|
+
scope?: string;
|
|
42
|
+
/** セッションの秒数(既定は8時間) */
|
|
43
|
+
sessionTtlSec?: number;
|
|
44
|
+
certs?: FetchCerts;
|
|
45
|
+
fetch?: typeof fetch;
|
|
46
|
+
}>;
|
|
47
|
+
/** 同じオリジンの戻り先(外のオリジンへの転送を防ぐ) */
|
|
48
|
+
export declare const safeNext: (next: string | null) => string;
|
|
49
|
+
/** アプリ自身の OIDC のログイン(認可コードのフローと署名つきの Cookie のセッション) */
|
|
50
|
+
export declare function oidcLogin({ issuer, clientId, clientSecret, secret, projectOf, basePath, scope, sessionTtlSec, certs, fetch: fetcher }: OidcLoginOptions): LoginAuth;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 経路ごとのヘッダーの名前(署名と主体) */
|
|
2
|
+
export declare const SIGNED_HEADERS: {
|
|
3
|
+
/** MCP → CMS の署名(鍵は MCP_TOKEN、主体は Authorization のアクセストークン。Worker を通ったことの証明だけで、主体はトークンから CMS が決める) */
|
|
4
|
+
readonly mcp: "x-mcp-signature";
|
|
5
|
+
/** CMS ⇄ サイトのプレビューと下書きの署名(鍵は PREVIEW_TOKEN) */
|
|
6
|
+
readonly preview: "x-preview-signature";
|
|
7
|
+
};
|
|
8
|
+
/** 署名の鍵(1つか、移行の期間は新しい鍵を先・古い鍵を最後に並べた複数) */
|
|
9
|
+
export type SigningSecrets = string | readonly string[];
|
|
10
|
+
/** MCP → CMS の署名の鍵(MCP_TOKEN と呼ぶ先のホスト名から HMAC で導いた値、ホスト名は小文字に統一) */
|
|
11
|
+
export declare function mcpSigningKey(token: string, hostname: string): Promise<string>;
|
|
12
|
+
/** 期限と署名を付けた値(JSON にできる値、ttlSec は有効な秒数) */
|
|
13
|
+
export declare function sealValue(secret: string, value: unknown, ttlSec: number, now?: number): Promise<string>;
|
|
14
|
+
/** 封印した値(鍵のどれかで署名が合えば値、署名の不一致・期限切れ・形の誤りは null) */
|
|
15
|
+
export declare function openValue<T = unknown>(secret: SigningSecrets, token: string | null | undefined, now?: number): Promise<T | null>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type Classify, VIEW_COLUMNS, VIEW_SCHEMA, type ViewEvent, viewOf, type ViewOptions } from './view.js';
|
|
2
|
+
export { syncCron } from './schedule.js';
|
|
3
|
+
export { isViewsCron, sharedViews, viewsFor, viewsSince, viewsSyncOf } from './shared.js';
|
|
4
|
+
export { type DailyRow, fixedSource, type ProjectSource, renamedSource, type Source } from './source.js';
|
|
5
|
+
export { readDaily, syncDaily } from './store.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type DailyRow, type ProjectSource, type Source } from './source.js';
|
|
2
|
+
/** 全プロジェクトを問い合わせる範囲の最初の日付(UTC の日付、どの時間帯のプロジェクトの直近3日も含む) */
|
|
3
|
+
export declare const viewsSince: (now: number) => string;
|
|
4
|
+
/** 全プロジェクトの問い合わせを行う Cron か(minutes は集計の間隔の分) */
|
|
5
|
+
export declare const isViewsCron: (minutes: string | undefined, cron: string) => boolean;
|
|
6
|
+
/** 全プロジェクトの閲覧数の問い合わせ(対象の Cron で設定があるときだけ、なしは null) */
|
|
7
|
+
export declare const viewsSyncOf: (source: ProjectSource | null, minutes: string | undefined, cron: string, scheduledTime: number) => Readonly<{
|
|
8
|
+
source: ProjectSource;
|
|
9
|
+
since: string;
|
|
10
|
+
}> | null;
|
|
11
|
+
/** プロジェクトごとの読み込み元の作成 */
|
|
12
|
+
type ViewsOf = (projectId: string) => Source | null;
|
|
13
|
+
/**
|
|
14
|
+
* Queues なしの構成のプロジェクトごとの読み込み元(全プロジェクトの問い合わせ結果の行)
|
|
15
|
+
* - 結果にないプロジェクト: 行なし
|
|
16
|
+
* - 問い合わせの失敗: 各プロジェクトの集計の処理が失敗として記録(ログ・実行の記録)
|
|
17
|
+
*/
|
|
18
|
+
export declare function sharedViews(source: ProjectSource, since: string): Promise<ViewsOf>;
|
|
19
|
+
/** メッセージに載った行の読み込み元(なしはプロジェクトごとの問い合わせ live) */
|
|
20
|
+
export declare const viewsFor: (rows: readonly DailyRow[] | undefined, live: ViewsOf) => ViewsOf;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** 日ごと・種類・ID の閲覧数 */
|
|
2
|
+
export type DailyRow = {
|
|
3
|
+
date: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
id: string;
|
|
6
|
+
views: number;
|
|
7
|
+
};
|
|
8
|
+
/** 読み込み元の接続のコレクション(since 以降の日付の閲覧数) */
|
|
9
|
+
export type Source = {
|
|
10
|
+
daily(since: string): Promise<DailyRow[]>;
|
|
11
|
+
};
|
|
12
|
+
/** 全プロジェクトの読み込み元のコレクション(since 以降の日付の閲覧数をプロジェクトの識別子ごとに) */
|
|
13
|
+
export type ProjectSource = {
|
|
14
|
+
dailyByProject(since: string): Promise<ReadonlyMap<string, DailyRow[]>>;
|
|
15
|
+
};
|
|
16
|
+
/** 集計済みの行の読み込み元(定期の集計で全プロジェクトの問い合わせ結果をプロジェクトごとに受け渡し、daily は since 以降の行) */
|
|
17
|
+
export declare const fixedSource: (rows: readonly DailyRow[]) => Source;
|
|
18
|
+
/** 種類を付け替えた読み込み元(renames は旧の種類 → 今の種類、付け替えで重なった行は閲覧数を合計) */
|
|
19
|
+
export declare function renamedSource(source: Source, renames: Readonly<Record<string, string>>): Source;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DailyRow, Source } from './source.js';
|
|
2
|
+
type Statement = {
|
|
3
|
+
bind(...values: unknown[]): Statement;
|
|
4
|
+
all<T = Record<string, unknown>>(): Promise<{
|
|
5
|
+
results: T[];
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
/** D1 の接続のコレクション(D1Database と互換) */
|
|
9
|
+
export type Db = {
|
|
10
|
+
prepare(sql: string): Statement;
|
|
11
|
+
batch(statements: Statement[]): Promise<unknown>;
|
|
12
|
+
};
|
|
13
|
+
/** 読み込み元の since 以降の閲覧数を表へ(戻り値は行の数) */
|
|
14
|
+
export declare function syncDaily(source: Source, db: Db, since: string): Promise<number>;
|
|
15
|
+
/** 日付が after より後の閲覧数(live は今日の行を読み込み元から、失敗は表の値のままで failure に例外) */
|
|
16
|
+
export declare function readDaily(db: Db, after: string, live?: {
|
|
17
|
+
source: Source;
|
|
18
|
+
today: string;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
rows: DailyRow[];
|
|
21
|
+
live: boolean;
|
|
22
|
+
failure?: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** パスから種類と ID への対応(利用側が定義、例: /articles/<id> は記事) */
|
|
2
|
+
export type Classify = (path: string) => {
|
|
3
|
+
kind: string;
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
/** 閲覧のイベント(project はプロジェクトの識別子) */
|
|
7
|
+
export type ViewEvent = Readonly<{
|
|
8
|
+
kind: string;
|
|
9
|
+
id: string;
|
|
10
|
+
path: string;
|
|
11
|
+
date: string;
|
|
12
|
+
event: 'view';
|
|
13
|
+
project?: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** 位置で持つ記録先の列の順 */
|
|
16
|
+
export declare const VIEW_COLUMNS: readonly ["kind", "id", "path", "date", "event", "project"];
|
|
17
|
+
/**
|
|
18
|
+
* 閲覧のイベントの形(toolkit の analyticsEngineRecorder・analyticsEngineCounts に渡す)
|
|
19
|
+
* - index: プロジェクト、指定なしは種類(Analytics Engine は index ごとに標本を抽出するため、共有のデータセットで小さなプロジェクトの記録が間引かれないように)
|
|
20
|
+
*/
|
|
21
|
+
export declare const VIEW_SCHEMA: Readonly<{
|
|
22
|
+
blobs: readonly ("id" | "kind" | "date" | "path" | "project" | "event")[];
|
|
23
|
+
doubles?: readonly never[] | undefined;
|
|
24
|
+
index?: ((event: Readonly<Partial<Record<"id" | "kind" | "date" | "path" | "project" | "event", string>> & Partial<Record<never, number>>>) => string) | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
/** イベントにする設定(project はプロジェクトの識別子) */
|
|
27
|
+
export type ViewOptions = Readonly<{
|
|
28
|
+
classify: Classify;
|
|
29
|
+
timeZone: string;
|
|
30
|
+
project?: string;
|
|
31
|
+
}>;
|
|
32
|
+
/** 閲覧のイベント(対象: GET で応答が200の HTML・ボット以外、ほかは null) */
|
|
33
|
+
export declare function viewOf(request: Request, response: Response, { classify, timeZone, project }: ViewOptions): ViewEvent | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Body } from './types.js';
|
|
2
|
+
/** 属性(Markdown の `{…}`、値は文字列) */
|
|
3
|
+
export type Attributes = Readonly<Record<string, string>>;
|
|
4
|
+
/** コンポーネントの Markdown の記法(to と from で往復して同じ props に戻ること) */
|
|
5
|
+
export type ComponentMarkdown<M> = Readonly<{
|
|
6
|
+
to(props: unknown): Readonly<{
|
|
7
|
+
attributes?: Attributes;
|
|
8
|
+
content?: Body<M>;
|
|
9
|
+
}>;
|
|
10
|
+
from(attributes: Attributes, content: Body<M>): unknown;
|
|
11
|
+
}>;
|
|
12
|
+
/** カスタムコンポーネントの定義(inline はインラインのコンポーネント、description と example は Markdown の説明に使用) */
|
|
13
|
+
export type ComponentDef<M> = Readonly<{
|
|
14
|
+
name: string;
|
|
15
|
+
inline?: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
example?: string;
|
|
18
|
+
markdown?: ComponentMarkdown<M>;
|
|
19
|
+
}>;
|
|
20
|
+
/** 予約の名前(ブロック) */
|
|
21
|
+
export declare const RESERVED_BLOCK_NAMES: ReadonlySet<string>;
|
|
22
|
+
/** 予約の名前(インライン) */
|
|
23
|
+
export declare const RESERVED_INLINE_NAMES: ReadonlySet<string>;
|
|
24
|
+
/** 既定の記法: props を JSON のコードブロックに */
|
|
25
|
+
export declare const jsonMarkdown: ComponentMarkdown<never>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ComponentDef } from './components.js';
|
|
3
|
+
/** 引数の型 */
|
|
4
|
+
export type PropType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
5
|
+
/** 1つの引数の形(title は管理画面の項目名、enum は文字列の選択肢、items は配列の要素、properties・required はオブジェクトの中) */
|
|
6
|
+
export type PropSchema = Readonly<{
|
|
7
|
+
type: PropType;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
enum?: readonly string[];
|
|
11
|
+
items?: PropSchema;
|
|
12
|
+
properties?: Readonly<Record<string, PropSchema>>;
|
|
13
|
+
required?: readonly string[];
|
|
14
|
+
}>;
|
|
15
|
+
/** 引数の全体の形(最上位はオブジェクト) */
|
|
16
|
+
export type PropsSchema = Readonly<{
|
|
17
|
+
type: 'object';
|
|
18
|
+
properties: Readonly<Record<string, PropSchema>>;
|
|
19
|
+
required?: readonly string[];
|
|
20
|
+
}>;
|
|
21
|
+
/** 導入先が宣言する部品(label は管理画面の表示名、inline の省略はブロック) */
|
|
22
|
+
export type DeclaredComponent = Readonly<{
|
|
23
|
+
name: string;
|
|
24
|
+
label: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
inline?: boolean;
|
|
27
|
+
props: PropsSchema;
|
|
28
|
+
}>;
|
|
29
|
+
/** 宣言の一覧の検査(名前の重複も拒否) */
|
|
30
|
+
export declare const declaredComponentsSchema: z.ZodType<readonly DeclaredComponent[]>;
|
|
31
|
+
/** 宣言した部品の引数の検査(宣言ごとに作成を再利用) */
|
|
32
|
+
export declare function declaredPropsZod(d: DeclaredComponent): z.ZodType;
|
|
33
|
+
/** 宣言から Markdown の変換と説明に使用する部品の定義(記法は既定の JSON) */
|
|
34
|
+
export declare const declaredDefOf: (d: DeclaredComponent) => ComponentDef<never>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Body, type Rich } from './types.js';
|
|
2
|
+
/** 読了時間の既定の分速(字/分) */
|
|
3
|
+
export declare const READING_SPEED = 500;
|
|
4
|
+
/** 断片の列の文字(装飾・リンクは文字、インラインのコンポーネントは中の文字) */
|
|
5
|
+
export declare const plainOf: (rich: Rich) => string;
|
|
6
|
+
/** 本文の注が参照する出典の ID(出現の順、重複あり) */
|
|
7
|
+
export declare function citesOf<M>(body: Body<M>): string[];
|
|
8
|
+
/** 本文の導入の文字(最初の見出しまでの段落をつなげたもの、導入がなければ空) */
|
|
9
|
+
export declare function excerptOf<M>(body: Body<M>): string;
|
|
10
|
+
/** 読了時間(分、本文の文字列の字数を分速 speed で割った概算、1分以上) */
|
|
11
|
+
export declare const readMinOf: <M>(body: Body<M>, speed?: number) => number;
|
|
12
|
+
/** 本文にあるサイト内へのリンク先(`/` で始まる href、重複なし) */
|
|
13
|
+
export declare const linksOf: <M>(body: Body<M>) => string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** meta description の長さの上限(検索結果で省略されにくい字数の目安) */
|
|
2
|
+
export declare const DESCRIPTION_MAX = 120;
|
|
3
|
+
/**
|
|
4
|
+
* 説明を meta description の長さに調整
|
|
5
|
+
* - 上限を超える場合: 上限までの最後の句点まで
|
|
6
|
+
* - 句点がない場合: 上限で切って省略の記号
|
|
7
|
+
*/
|
|
8
|
+
export declare function descriptionOf(excerpt: string, max?: number): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** 埋め込めるサービス */
|
|
2
|
+
export declare const EMBED_PROVIDERS: readonly ["youtube", "vimeo", "x", "instagram", "spotify", "apple-podcasts"];
|
|
3
|
+
/** 埋め込めるサービス */
|
|
4
|
+
export type EmbedProvider = (typeof EMBED_PROVIDERS)[number];
|
|
5
|
+
/** URL から決めた埋め込み(start は開始の秒) */
|
|
6
|
+
export type EmbedTarget = Readonly<{
|
|
7
|
+
provider: EmbedProvider;
|
|
8
|
+
id: string;
|
|
9
|
+
start?: number;
|
|
10
|
+
}>;
|
|
11
|
+
/** URL から埋め込み(埋め込めるサービスでなければ null) */
|
|
12
|
+
export declare function embedOfUrl(raw: string): EmbedTarget | null;
|
|
13
|
+
/** 描画の iframe のオリジン(embedSrcOf が組み立てる URL のオリジン、管理画面の CSP の frame-src) */
|
|
14
|
+
export declare const EMBED_FRAME_ORIGINS: readonly ["https://www.youtube-nocookie.com", "https://player.vimeo.com", "https://platform.twitter.com", "https://www.instagram.com", "https://open.spotify.com", "https://embed.podcasts.apple.com"];
|
|
15
|
+
/** 描画の iframe の URL(サービスと ID から組み立てる、X と Instagram は埋め込みのページ) */
|
|
16
|
+
export declare function embedSrcOf(target: EmbedTarget): `https://${string}`;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Body } from './types.js';
|
|
2
|
+
/** 変換の設定 */
|
|
3
|
+
export type HtmlOptions<M> = Readonly<{
|
|
4
|
+
/** 画像の参照(src は元の URL) */
|
|
5
|
+
image(src: string, info: Readonly<{
|
|
6
|
+
alt?: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
}>): M;
|
|
10
|
+
/** ファイルの参照(href は元の URL、mime は data-mime-type) */
|
|
11
|
+
file?(href: string, info: Readonly<{
|
|
12
|
+
mime?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
}>): M;
|
|
15
|
+
/** 名前のついた装飾として残す class(なしは class をすべて捨てる) */
|
|
16
|
+
styleClass?(name: string): boolean;
|
|
17
|
+
/** 元の CSS の値に対応する名前(本文の設定の宣言、なしは名前なし) */
|
|
18
|
+
nameOf?(kind: 'color' | 'background' | 'size', value: string): string | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export type Dropped = Readonly<{
|
|
21
|
+
what: string;
|
|
22
|
+
count: number;
|
|
23
|
+
}>;
|
|
24
|
+
/** 変換の結果 */
|
|
25
|
+
export type HtmlResult<M> = Readonly<{
|
|
26
|
+
body: Body<M>;
|
|
27
|
+
dropped: readonly Dropped[];
|
|
28
|
+
}>;
|
|
29
|
+
/** HTML を本文に(コピーできないものは dropped) */
|
|
30
|
+
export declare function bodyFromHtml<M>(html: string, options: HtmlOptions<M>): HtmlResult<M>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { ComponentDef } from './components.js';
|
|
2
|
+
export { type DeclaredComponent, declaredComponentsSchema, declaredDefOf, declaredPropsZod, type PropSchema, type PropsSchema, type PropType } from './declared.js';
|
|
3
|
+
export { DESCRIPTION_MAX, descriptionOf } from './description.js';
|
|
4
|
+
export { citesOf, excerptOf, linksOf, plainOf, READING_SPEED, readMinOf } from './derive.js';
|
|
5
|
+
export { CORE_COMPONENTS, coreComponentOf, type Chart, type ChartColor, type ChartDatum, type ComponentName, type ComponentProps, type CoreComponent } from './library.js';
|
|
6
|
+
export { isSafeHref } from './href.js';
|
|
7
|
+
export { bodyFromHtml, type Dropped, type HtmlOptions, type HtmlResult } from './html.js';
|
|
8
|
+
export { EMBED_FRAME_ORIGINS, EMBED_PROVIDERS, embedOfUrl, embedSrcOf, type EmbedProvider, type EmbedTarget } from './embed.js';
|
|
9
|
+
export { fromMarkdown, toMarkdown, type MarkdownOptions } from './markdown.js';
|
|
10
|
+
export { checkBody, describeMarkdown, isSafeCssValue, type BodyProfile, type NamedStyle, type NamedValue } from './profile.js';
|
|
11
|
+
export { bodyToHtml, type RenderedImage, type RenderOptions } from './render.js';
|
|
12
|
+
export { blockSchemaOf } from './schema.js';
|
|
13
|
+
export { sortMarks } from './inline.js';
|
|
14
|
+
export { normalizeRich } from './normalize.js';
|
|
15
|
+
export { bodyFromMarkdown, bodyToMarkdown, markdownGuide, type MarkdownResult, type MediaSyntax } from './standard.js';
|
|
16
|
+
export { ALIGNS, cellParagraphs, IMAGE_ALIGNS, isTableCell, STYLE_KINDS, type StyleKind, type Align, type Block, type Body, type Cell, type ComponentBlock, type HeadingLevel, type ImageAlign, type Inline, type InlineComponent, type Link, type List, type ListItem, type Mark, type Named, type Rich, type StandardBlock, type TableCell, type Text, type TextStyle } from './types.js';
|
|
17
|
+
export { BODY_PROBLEM_MESSAGES } from './labels/ja.js';
|
|
18
|
+
export { type BodyProblemCode, bodyProblemText } from './problems.js';
|
|
19
|
+
export { BODY_PROBLEM_MESSAGES_EN } from './labels/en.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Mark, TextStyle } from './types.js';
|
|
2
|
+
/** 装飾の順序(外側から内側、Markdown と HTML の入れ子の順) */
|
|
3
|
+
export declare const MARK_ORDER: readonly ["strong", "em", "strike", "underline", "mark", "sup", "sub", "code"];
|
|
4
|
+
/** 装飾を MARK_ORDER の順に並べる(重複は1つ) */
|
|
5
|
+
export declare const sortMarks: (marks: readonly Mark[] | undefined) => Mark[];
|
|
6
|
+
/** 装飾の描画の HTML の要素 */
|
|
7
|
+
export declare const MARK_HTML_TAGS: {
|
|
8
|
+
readonly strong: "strong";
|
|
9
|
+
readonly em: "em";
|
|
10
|
+
readonly code: "code";
|
|
11
|
+
readonly strike: "s";
|
|
12
|
+
readonly mark: "mark";
|
|
13
|
+
readonly sup: "sup";
|
|
14
|
+
readonly sub: "sub";
|
|
15
|
+
readonly underline: "u";
|
|
16
|
+
};
|
|
17
|
+
/** HTML の要素の装飾(描画の要素と、リッチエディタが使うほかの要素) */
|
|
18
|
+
export declare const HTML_TAG_MARKS: Readonly<Record<string, Mark>>;
|
|
19
|
+
/** 内側の見た目に外側の見た目を重ねる(内側を優先、名前のついた装飾は合わせる) */
|
|
20
|
+
export declare const mergeStyle: (outer: TextStyle | undefined, inner: TextStyle | undefined) => TextStyle | undefined;
|