@tunasand/sdk 0.7.0 → 0.11.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 +233 -88
- package/README.md +296 -273
- package/dist/analytics.js +657 -10
- package/dist/app.js +323 -96
- package/dist/apps-DIxAWBSZ.js +318 -0
- package/dist/astro-image.d.ts +1 -0
- package/dist/astro-image.js +33 -0
- package/dist/astro-server-Bwau8F6d.js +99 -0
- package/dist/astro-server.d.ts +1 -0
- package/dist/astro-server.js +1 -0
- package/dist/astro.d.ts +1 -0
- package/dist/astro.js +306 -0
- package/dist/bridge-Dv4NxGZ7.js +81 -0
- package/dist/bridge.js +2 -14
- package/dist/build-file-DNi0PHC5.js +31 -0
- package/dist/cli.js +6214 -9
- package/dist/{client-Derrexwr.js → client-C8STAw9T.js} +43 -24
- package/dist/code-N8pBUDbq.js +30 -0
- package/dist/code.d.ts +1 -0
- package/dist/code.js +1 -0
- package/dist/collection-nUz1RetA.js +264 -0
- package/dist/{declared-C_GvPiGF.js → declared-CE4a61qb.js} +124 -36
- package/dist/delivery.js +124 -132
- package/dist/dev-operations-Tutwi1On.js +46 -0
- package/dist/dev.js +9 -16
- package/dist/embeds-B-Dbn64k.js +29 -0
- package/dist/end-users.d.ts +1 -0
- package/dist/end-users.js +185 -0
- package/dist/{customers-C_vJY2_v.js → endUsers-DODfjnv1.js} +31 -38
- package/dist/{errorLabels-CPKiPabZ.js → errorLabels-aT2bnMsO.js} +593 -460
- package/dist/i18n.js +4 -4
- package/dist/ids-DmtIoqBX.js +109 -0
- package/dist/integrations.js +95 -49
- package/dist/{ja-C6lX0CeJ.js → ja-CrY_72Tn.js} +99 -54
- package/dist/{ja-C1HEWWTQ.js → ja-axQPxMJ-.js} +6 -6
- package/dist/operations-CIB99rIY.js +95 -0
- package/dist/operations.d.ts +1 -0
- package/dist/operations.js +1 -0
- package/dist/{page-E_cYgZx-.js → page-yo1cw1kW.js} +5 -5
- package/dist/preview.js +8 -1
- package/dist/{profile-D6t1QMQh.js → profile-DBsXLvvI.js} +52 -52
- package/dist/rich-text.d.ts +1 -0
- package/dist/{body.js → rich-text.js} +20 -21
- package/dist/schema-Dcg1ajnW.js +1267 -0
- package/dist/schema.js +324 -1
- package/dist/types/access/src/handoff.d.ts +22 -17
- package/dist/types/access/src/index.d.ts +2 -2
- package/dist/types/access/src/jws.d.ts +41 -0
- package/dist/types/access/src/jwt.d.ts +1 -1
- package/dist/types/access/src/oidc.d.ts +11 -3
- package/dist/types/access/src/signed.d.ts +0 -2
- package/dist/types/adapter-cloudflare/src/eventLog/viewSchema.d.ts +11 -0
- package/dist/types/contract/src/accountProfile.d.ts +7 -0
- package/dist/types/{cms-contract → contract}/src/apiKeys.d.ts +7 -3
- package/dist/types/contract/src/app.d.ts +38 -0
- package/dist/types/contract/src/appChannels.d.ts +114 -0
- package/dist/types/contract/src/appDefinition.d.ts +133 -0
- package/dist/types/{cms-contract → contract}/src/appDependencies.d.ts +91 -35
- package/dist/types/contract/src/appIdentities.d.ts +21 -0
- package/dist/types/contract/src/appInbound.d.ts +28 -0
- package/dist/types/contract/src/appMail.d.ts +106 -0
- package/dist/types/contract/src/appSecrets.d.ts +45 -0
- package/dist/types/contract/src/appServer.d.ts +501 -0
- package/dist/types/contract/src/approvalLabels.d.ts +26 -0
- package/dist/types/contract/src/approvals.d.ts +63 -0
- package/dist/types/contract/src/apps.d.ts +295 -0
- package/dist/types/contract/src/auditActions.d.ts +18 -0
- package/dist/types/contract/src/auditLabels.d.ts +223 -0
- package/dist/types/contract/src/authorize.d.ts +133 -0
- package/dist/types/{cms-contract → contract}/src/bridge.d.ts +39 -40
- package/dist/types/{cms-contract → contract}/src/consents.d.ts +32 -25
- package/dist/types/contract/src/deletion.d.ts +18 -0
- package/dist/types/contract/src/embeds.d.ts +105 -0
- package/dist/types/{cms-contract/src/customerLabels.d.ts → contract/src/endUserLabels.d.ts} +6 -9
- package/dist/types/contract/src/endUsers.d.ts +241 -0
- package/dist/types/{cms-contract → contract}/src/errorLabels.d.ts +76 -47
- package/dist/types/{cms-contract → contract}/src/errorLabelsEn.d.ts +52 -36
- package/dist/types/contract/src/errors.d.ts +117 -0
- package/dist/types/contract/src/eventSchemas.d.ts +70 -0
- package/dist/types/contract/src/eventTraces.d.ts +43 -0
- package/dist/types/{cms-contract → contract}/src/failureStatus.d.ts +16 -23
- package/dist/types/contract/src/fieldAccess.d.ts +45 -0
- package/dist/types/contract/src/fieldRules.d.ts +41 -0
- package/dist/types/{cms-contract/src/assets.d.ts → contract/src/files.d.ts} +5 -5
- package/dist/types/contract/src/formLabels.d.ts +3 -0
- package/dist/types/contract/src/forms.d.ts +4 -0
- package/dist/types/{cms-contract → contract}/src/functions.d.ts +3 -3
- package/dist/types/contract/src/grants.d.ts +26 -0
- package/dist/types/contract/src/headers.d.ts +5 -0
- package/dist/types/contract/src/hostingRpc.d.ts +149 -0
- package/dist/types/contract/src/hostnames.d.ts +30 -0
- package/dist/types/contract/src/identifiers.d.ts +148 -0
- package/dist/types/contract/src/ids.d.ts +112 -0
- package/dist/types/{cms-contract → contract}/src/import.d.ts +20 -19
- package/dist/types/contract/src/importLabels.d.ts +3 -0
- package/dist/types/contract/src/index.d.ts +92 -0
- package/dist/types/contract/src/integrationGraph.d.ts +83 -0
- package/dist/types/{cms-contract → contract}/src/issueLabels.d.ts +135 -99
- package/dist/types/{cms-contract → contract}/src/issueLabelsEn.d.ts +70 -52
- package/dist/types/contract/src/labels.d.ts +11 -0
- package/dist/types/contract/src/legacyAuditLabels.d.ts +10 -0
- package/dist/types/contract/src/livePeriods.d.ts +18 -0
- package/dist/types/contract/src/manage.d.ts +51 -0
- package/dist/types/contract/src/manageLabels.d.ts +11 -0
- package/dist/types/contract/src/manifestText.d.ts +66 -0
- package/dist/types/contract/src/mcpAuth.d.ts +139 -0
- package/dist/types/contract/src/mcpLabels.d.ts +5 -0
- package/dist/types/contract/src/messagePort.d.ts +208 -0
- package/dist/types/{cms-contract → contract}/src/migration.d.ts +3 -3
- package/dist/types/contract/src/notices.d.ts +38 -0
- package/dist/types/contract/src/operatorOperations.d.ts +640 -0
- package/dist/types/contract/src/operators.d.ts +33 -0
- package/dist/types/contract/src/outbound.d.ts +29 -0
- package/dist/types/contract/src/paths.d.ts +34 -0
- package/dist/types/contract/src/pending.d.ts +6 -0
- package/dist/types/{cms-contract → contract}/src/permissions.d.ts +9 -11
- package/dist/types/contract/src/perspective.d.ts +26 -0
- package/dist/types/contract/src/powers.d.ts +5 -0
- package/dist/types/contract/src/principal.d.ts +181 -0
- package/dist/types/{cms-contract → contract}/src/problems.d.ts +4 -4
- package/dist/types/contract/src/projectRole.d.ts +6 -0
- package/dist/types/contract/src/recordLabels.d.ts +6 -0
- package/dist/types/{cms-contract → contract}/src/roles.d.ts +10 -6
- package/dist/types/contract/src/ruleLabels.d.ts +16 -0
- package/dist/types/contract/src/ruleProblems.d.ts +16 -0
- package/dist/types/contract/src/schemaLabels.d.ts +8 -0
- package/dist/types/{cms-contract → contract}/src/settingProblems.d.ts +3 -3
- package/dist/types/{cms-contract → contract}/src/settings.d.ts +6 -8
- package/dist/types/contract/src/settingsLabels.d.ts +3 -0
- package/dist/types/{cms-contract → contract}/src/siteDeclaration.d.ts +7 -7
- package/dist/types/contract/src/siteIndex.d.ts +76 -0
- package/dist/types/contract/src/slugs.d.ts +6 -0
- package/dist/types/{cms-contract → contract}/src/transfer.d.ts +4 -4
- package/dist/types/contract/src/trial.d.ts +13 -0
- package/dist/types/contract/src/versions.d.ts +7 -0
- package/dist/types/{analytics/src/view.d.ts → contract/src/viewEvent.d.ts} +0 -9
- package/dist/types/contract/src/webhooks.d.ts +135 -0
- package/dist/types/contract/src/workflow.d.ts +43 -0
- package/dist/types/contract/src/workspaceItems.d.ts +87 -0
- package/dist/types/contract/src/workspacePaths.d.ts +4 -0
- package/dist/types/{body → rich-text}/src/declared.d.ts +2 -2
- package/dist/types/{body → rich-text}/src/embed.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/html.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/index.d.ts +8 -7
- package/dist/types/{body → rich-text}/src/labels/en.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/labels/ja.d.ts +4 -4
- package/dist/types/{body → rich-text}/src/library.d.ts +1 -1
- package/dist/types/rich-text/src/media.d.ts +2 -0
- package/dist/types/{body → rich-text}/src/normalize.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/problems.d.ts +5 -5
- package/dist/types/{body → rich-text}/src/profile.d.ts +11 -11
- package/dist/types/{body → rich-text}/src/render.d.ts +1 -1
- package/dist/types/{body → rich-text}/src/schema.d.ts +2 -2
- package/dist/types/{body → rich-text}/src/standard.d.ts +4 -4
- package/dist/types/{body → rich-text}/src/types.d.ts +2 -2
- package/dist/types/schema/src/audience.d.ts +36 -0
- package/dist/types/schema/src/brand.d.ts +5 -0
- package/dist/types/schema/src/capabilities.d.ts +19 -0
- package/dist/types/{model → schema}/src/changes.d.ts +9 -7
- package/dist/types/{model → schema}/src/check.d.ts +2 -2
- package/dist/types/{model/src/model.d.ts → schema/src/collection.d.ts} +150 -121
- package/dist/types/schema/src/defaultSchema.d.ts +15 -0
- package/dist/types/schema/src/fieldIds.d.ts +18 -0
- package/dist/types/{model/src/asset.d.ts → schema/src/file.d.ts} +36 -25
- package/dist/types/schema/src/fileRefs.d.ts +14 -0
- package/dist/types/schema/src/fileSignature.d.ts +20 -0
- package/dist/types/schema/src/filesCollection.d.ts +7 -0
- package/dist/types/schema/src/forms.d.ts +43 -0
- package/dist/types/{model → schema}/src/image.d.ts +3 -3
- package/dist/types/schema/src/imageMetadata.d.ts +9 -0
- package/dist/types/schema/src/index.d.ts +35 -0
- package/dist/types/{model → schema}/src/input.d.ts +3 -3
- package/dist/types/{model → schema}/src/integrity.d.ts +9 -8
- package/dist/types/schema/src/kinds.d.ts +26 -0
- package/dist/types/{model → schema}/src/labels/en.d.ts +93 -51
- package/dist/types/{model → schema}/src/labels/ja.d.ts +97 -52
- package/dist/types/schema/src/mediaUrl.d.ts +60 -0
- package/dist/types/{model → schema}/src/page.d.ts +6 -6
- package/dist/types/{model → schema}/src/problems.d.ts +95 -53
- package/dist/types/{model → schema}/src/refs.d.ts +1 -10
- package/dist/types/{model → schema}/src/rules.d.ts +2 -2
- package/dist/types/{model → schema}/src/schema.d.ts +25 -20
- package/dist/types/schema/src/selfOps.d.ts +31 -0
- package/dist/types/{model/src/capabilities.d.ts → schema/src/traits.d.ts} +6 -6
- package/dist/types/schema/src/typesSource.d.ts +16 -0
- package/dist/types/{model → schema}/src/values.d.ts +7 -4
- package/dist/types/schema/src/widening.d.ts +3 -0
- package/dist/types/sdk/src/analytics.d.ts +3 -2
- package/dist/types/sdk/src/app.d.ts +70 -16
- package/dist/types/sdk/src/astro-image.d.ts +19 -0
- package/dist/types/sdk/src/astro-response.d.ts +6 -0
- package/dist/types/sdk/src/astro-server.d.ts +16 -0
- package/dist/types/sdk/src/astro.d.ts +19 -0
- package/dist/types/sdk/src/bridge.d.ts +13 -15
- package/dist/types/sdk/src/code.d.ts +61 -0
- package/dist/types/sdk/src/delegation.d.ts +49 -0
- package/dist/types/sdk/src/delivery/changes.d.ts +4 -4
- package/dist/types/sdk/src/delivery/client.d.ts +40 -28
- package/dist/types/sdk/src/delivery/fields.d.ts +5 -5
- package/dist/types/sdk/src/delivery/index.d.ts +3 -3
- package/dist/types/sdk/src/delivery/media.d.ts +8 -11
- package/dist/types/sdk/src/delivery/query.d.ts +16 -12
- package/dist/types/sdk/src/delivery/schema.d.ts +5 -5
- package/dist/types/sdk/src/delivery/values.d.ts +16 -20
- package/dist/types/sdk/src/delivery.d.ts +3 -3
- package/dist/types/sdk/src/dev-operations.d.ts +20 -0
- package/dist/types/sdk/src/dev.d.ts +6 -5
- package/dist/types/sdk/src/end-users.d.ts +190 -0
- package/dist/types/sdk/src/i18n.d.ts +11 -11
- package/dist/types/sdk/src/integrations.d.ts +20 -27
- package/dist/types/sdk/src/operations.d.ts +17 -0
- package/dist/types/sdk/src/preview.d.ts +2 -1
- package/dist/types/sdk/src/rich-text.d.ts +2 -0
- package/dist/types/sdk/src/schema.d.ts +5 -21
- package/dist/types/sdk/src/site/artifact.d.ts +64 -0
- package/dist/types/sdk/src/site/build-file.d.ts +30 -0
- package/dist/types/sdk/src/site/check-code.d.ts +14 -0
- package/dist/types/sdk/src/site/check-text.d.ts +19 -0
- package/dist/types/sdk/src/site/cli.d.ts +52 -0
- package/dist/types/sdk/src/site/content-type.d.ts +2 -0
- package/dist/types/sdk/src/site/labels.d.ts +14 -0
- package/dist/types/sdk/src/site.d.ts +1 -1
- package/dist/types/sdk/src/types.d.ts +21 -0
- package/dist/{schema-BPHL7Qr-.js → types-DkO2N7u2.js} +9 -9
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/dist/typesSource-VJIxtN9b.js +136 -0
- package/dist/workflow-CUpl6hO_.js +148 -0
- package/package.json +42 -16
- package/dist/apps-9u4XMi7E.js +0 -114
- package/dist/body.d.ts +0 -1
- package/dist/bridge-DYAYGV7t.js +0 -74
- package/dist/customers.d.ts +0 -1
- package/dist/customers.js +0 -185
- package/dist/embed-R-OvDYAw.js +0 -90
- package/dist/model-pmXzGX12.js +0 -152
- package/dist/model.d.ts +0 -1
- package/dist/model.js +0 -345
- package/dist/schema-UQJWRyfJ.js +0 -995
- package/dist/src-sazhzYui.js +0 -71
- package/dist/types/analytics/src/index.d.ts +0 -5
- package/dist/types/analytics/src/schedule.d.ts +0 -2
- package/dist/types/analytics/src/shared.d.ts +0 -21
- package/dist/types/analytics/src/source.d.ts +0 -19
- package/dist/types/analytics/src/store.d.ts +0 -24
- package/dist/types/cms-contract/src/app.d.ts +0 -35
- package/dist/types/cms-contract/src/apps.d.ts +0 -195
- package/dist/types/cms-contract/src/authorize.d.ts +0 -146
- package/dist/types/cms-contract/src/customers.d.ts +0 -266
- package/dist/types/cms-contract/src/embeds.d.ts +0 -165
- package/dist/types/cms-contract/src/errors.d.ts +0 -105
- package/dist/types/cms-contract/src/identifiers.d.ts +0 -117
- package/dist/types/cms-contract/src/paths.d.ts +0 -23
- package/dist/types/cms-contract/src/urlLabel.d.ts +0 -13
- package/dist/types/cms-contract/src/webhooks.d.ts +0 -139
- package/dist/types/model/src/audience.d.ts +0 -38
- package/dist/types/model/src/brand.d.ts +0 -25
- package/dist/types/model/src/index.d.ts +0 -26
- package/dist/types/model/src/legacy.d.ts +0 -2
- package/dist/types/model/src/media.d.ts +0 -5
- package/dist/types/model/src/mediaUrl.d.ts +0 -67
- package/dist/types/model/src/selfOps.d.ts +0 -30
- package/dist/types/model/src/typesSource.d.ts +0 -8
- package/dist/types/platform/src/defaultModel.d.ts +0 -8
- package/dist/types/sdk/src/body.d.ts +0 -2
- package/dist/types/sdk/src/customers.d.ts +0 -190
- package/dist/types/sdk/src/model.d.ts +0 -5
- package/dist/typesSource-bO0jFw1I.js +0 -88
- /package/dist/types/{cms-contract → contract}/src/appProblems.d.ts +0 -0
- /package/dist/types/{analytics → contract}/src/day.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/functionLabels.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/permissionLabels.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/siteArtifact.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/views.d.ts +0 -0
- /package/dist/types/{cms-contract → contract}/src/webhookLabels.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/components.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/derive.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/description.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/href.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/inline.d.ts +0 -0
- /package/dist/types/{body → rich-text}/src/markdown.d.ts +0 -0
- /package/dist/types/{model → schema}/src/contact.d.ts +0 -0
- /package/dist/types/{model → schema}/src/json.d.ts +0 -0
- /package/dist/types/{model → schema}/src/screens.d.ts +0 -0
- /package/dist/types/{model → schema}/src/time.d.ts +0 -0
package/dist/schema.js
CHANGED
|
@@ -1 +1,324 @@
|
|
|
1
|
-
|
|
1
|
+
import { C as isListCollection, F as FILES_COLLECTION, M as optionLabelOf, N as optionsOf, O as isStoredCollection, P as roleFieldOf, m as collectionOf, v as hasPublication, y as initialValueOf } from "./collection-nUz1RetA.js";
|
|
2
|
+
import { a as cropRect, c as stillOf, i as coverStart, l as createClock, n as publicPathOf, o as croppedHotspot, r as coverPosition, s as objectPosition, t as pagePathOf, u as isDateOnly } from "./page-yo1cw1kW.js";
|
|
3
|
+
import { c as schemaProblemText, i as parseSchema } from "./schema-Dcg1ajnW.js";
|
|
4
|
+
import { n as typesSourceOf, r as valueFieldsOf } from "./typesSource-VJIxtN9b.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
// ../schema/src/file.ts
|
|
7
|
+
const unit = z.number().min(0).max(1);
|
|
8
|
+
/** 見せたい点の検査 */
|
|
9
|
+
const hotspotSchema = z.object({
|
|
10
|
+
x: unit,
|
|
11
|
+
y: unit,
|
|
12
|
+
width: unit.optional(),
|
|
13
|
+
height: unit.optional()
|
|
14
|
+
});
|
|
15
|
+
z.object({
|
|
16
|
+
top: unit,
|
|
17
|
+
bottom: unit,
|
|
18
|
+
left: unit,
|
|
19
|
+
right: unit
|
|
20
|
+
}).refine((c) => c.left + c.right <= .9 && c.top + c.bottom <= .9, schemaProblemText("crop_too_large"));
|
|
21
|
+
const mediaBase = z.object({
|
|
22
|
+
src: z.string().min(1),
|
|
23
|
+
width: z.number().int().positive(),
|
|
24
|
+
height: z.number().int().positive(),
|
|
25
|
+
alt: z.string(),
|
|
26
|
+
hotspot: hotspotSchema.optional()
|
|
27
|
+
});
|
|
28
|
+
/** 解決後の素材の検査(src は URL、ビルドで読み込んだ画像は JSON に含めないため対象外) */
|
|
29
|
+
const mediaSchema = z.union([mediaBase.extend({ kind: z.literal("image") }), mediaBase.extend({
|
|
30
|
+
kind: z.literal("video"),
|
|
31
|
+
poster: mediaBase
|
|
32
|
+
})]);
|
|
33
|
+
/** 使用する側が保存する実体の参照の検査 */
|
|
34
|
+
const fileRefSchema = z.object({ id: z.string().min(1) });
|
|
35
|
+
// ../schema/src/traits.ts
|
|
36
|
+
/** 出典の項目と、内側の項目の key */
|
|
37
|
+
const SOURCES_FIELD = {
|
|
38
|
+
key: "sources",
|
|
39
|
+
source: "source",
|
|
40
|
+
note: "note"
|
|
41
|
+
};
|
|
42
|
+
/** 主のコレクションか(公開の管理と本文の項目を持つ一覧のコレクション) */
|
|
43
|
+
const isPrimaryCandidate = (collection) => isListCollection(collection) && hasPublication(collection) && roleFieldOf(collection, "body") !== null;
|
|
44
|
+
/** 主のコレクション(スキーマの順で先頭、なければ null) */
|
|
45
|
+
const primaryCollectionOf = (schema) => schema.collections.find(isPrimaryCandidate) ?? null;
|
|
46
|
+
/** 主のコレクション(なければ例外: そのコレクションを前提にする画面・処理だけが使用) */
|
|
47
|
+
function requiredPrimaryCollectionOf(collectionSchema) {
|
|
48
|
+
const collection = primaryCollectionOf(collectionSchema);
|
|
49
|
+
if (!collection) throw new Error("content schema has no collection with publishing and a body field");
|
|
50
|
+
return collection;
|
|
51
|
+
}
|
|
52
|
+
/** 暦の日付(日付の役割の項目を持つ一覧のコレクションと項目の key、スキーマの順、役割は宣言だけで推測なし) */
|
|
53
|
+
const dateRoleFieldsOf = (schema) => schema.collections.filter(isListCollection).flatMap((t) => {
|
|
54
|
+
const f = roleFieldOf(t, "date");
|
|
55
|
+
return f ? [{
|
|
56
|
+
collection: t.id,
|
|
57
|
+
field: f.key
|
|
58
|
+
}] : [];
|
|
59
|
+
});
|
|
60
|
+
/** コレクションの出典の項目(なければ null) */
|
|
61
|
+
function sourcesFieldOf(collection) {
|
|
62
|
+
const f = collection.fields.find((x) => x.key === SOURCES_FIELD.key);
|
|
63
|
+
if (f?.type !== "object" || !f.multiple) return null;
|
|
64
|
+
const source = f.fields.find((x) => x.key === SOURCES_FIELD.source);
|
|
65
|
+
return source?.type === "reference" && !source.multiple ? {
|
|
66
|
+
...f,
|
|
67
|
+
to: source.to
|
|
68
|
+
} : null;
|
|
69
|
+
}
|
|
70
|
+
/** 出典の値にある参照の ID(注の順、空と形の誤りは除外) */
|
|
71
|
+
const sourceIdsOf = (value) => (Array.isArray(value) ? value : []).flatMap((item) => {
|
|
72
|
+
const id = item && typeof item === "object" ? item[SOURCES_FIELD.source] : void 0;
|
|
73
|
+
return typeof id === "string" && id ? [id] : [];
|
|
74
|
+
});
|
|
75
|
+
// ../schema/src/screens.ts
|
|
76
|
+
/** メニューのグループの id(運用のサイドバーのグループはこの1つだけ) */
|
|
77
|
+
const MENU_GROUP_ID = "collections";
|
|
78
|
+
const COLLECTION_PREFIX = "collection:";
|
|
79
|
+
/** メニュー項目の id(コレクション) */
|
|
80
|
+
const collectionItem = (collection) => `${COLLECTION_PREFIX}${collection}`;
|
|
81
|
+
/** メニューにある全項目の id(グループの中も、上から順) */
|
|
82
|
+
const menuItemsOf = (menu) => menu.flatMap((e) => typeof e === "string" ? [e] : e.items);
|
|
83
|
+
/** 編集画面に配置した項目の id(セクションの順) */
|
|
84
|
+
const placedItemsOf = (layout) => layout.sections.flatMap((s) => s.items);
|
|
85
|
+
const id = z.string().regex(/^[a-z][a-z0-9_:-]*$/, schemaProblemText("invalid_screen_id"));
|
|
86
|
+
const item = z.string().min(1);
|
|
87
|
+
const unique = (values) => new Set(values).size === values.length;
|
|
88
|
+
const group = z.object({
|
|
89
|
+
id: z.literal(MENU_GROUP_ID),
|
|
90
|
+
collapsed: z.boolean().optional(),
|
|
91
|
+
items: z.array(item)
|
|
92
|
+
});
|
|
93
|
+
const section = z.object({
|
|
94
|
+
id,
|
|
95
|
+
label: z.string().trim(),
|
|
96
|
+
collapsed: z.boolean().optional(),
|
|
97
|
+
items: z.array(item)
|
|
98
|
+
});
|
|
99
|
+
const layout = z.object({
|
|
100
|
+
sections: z.array(section),
|
|
101
|
+
hidden: z.array(item).optional()
|
|
102
|
+
}).refine((l) => unique(l.sections.map((s) => s.id)), { message: schemaProblemText("duplicate_section_id") }).refine((l) => unique([...placedItemsOf(l), ...l.hidden ?? []]), { message: schemaProblemText("duplicate_placement") });
|
|
103
|
+
const screensSchema = z.object({
|
|
104
|
+
menu: z.array(z.union([item, group])).refine((m) => m.filter((e) => typeof e !== "string").length <= 1, { message: schemaProblemText("duplicate_menu_group") }).refine((m) => unique(menuItemsOf(m)), { message: schemaProblemText("duplicate_menu_item") }),
|
|
105
|
+
editors: z.record(z.string(), layout).default({}),
|
|
106
|
+
columns: z.record(z.string(), z.array(item).refine(unique, { message: schemaProblemText("duplicate_column") })).default({})
|
|
107
|
+
});
|
|
108
|
+
/** 画面の設定の JSON を検査(形の誤りは ZodError) */
|
|
109
|
+
const parseScreens = (json) => screensSchema.parse(json);
|
|
110
|
+
// ../schema/src/defaultSchema.ts
|
|
111
|
+
/** 既定のコレクションの id(`uuidV5Of('default-collection:<スラッグ>')`、contract の ids.test.ts で照合。どのプロジェクトでも同じ値) */
|
|
112
|
+
const DEFAULT_COLLECTION_IDS = {
|
|
113
|
+
post: "41917a55-2583-5bfa-94ca-0438bb7ab713",
|
|
114
|
+
author: "36cfb207-54bd-5174-9d00-e41a1dba5255",
|
|
115
|
+
tag: "30f0228b-3a53-5cc1-b4f2-b9669de2c373"
|
|
116
|
+
};
|
|
117
|
+
/** 中立の既定のスキーマ(新しいプロジェクトの作成で適用するコレクション: post・author・tag・image・video、設定の移入の土台) */
|
|
118
|
+
const DEFAULT_SCHEMA = { collections: [
|
|
119
|
+
{
|
|
120
|
+
id: DEFAULT_COLLECTION_IDS.post,
|
|
121
|
+
slug: "post",
|
|
122
|
+
label: "投稿",
|
|
123
|
+
publication: true,
|
|
124
|
+
roles: {
|
|
125
|
+
title: "title",
|
|
126
|
+
image: "image",
|
|
127
|
+
body: "body"
|
|
128
|
+
},
|
|
129
|
+
fields: [
|
|
130
|
+
{
|
|
131
|
+
key: "title",
|
|
132
|
+
label: "タイトル",
|
|
133
|
+
type: "text",
|
|
134
|
+
required: "save"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: "writers",
|
|
138
|
+
label: "著者",
|
|
139
|
+
type: "reference",
|
|
140
|
+
to: DEFAULT_COLLECTION_IDS.author,
|
|
141
|
+
multiple: true
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
key: "image",
|
|
145
|
+
label: "メインの画像",
|
|
146
|
+
type: "file",
|
|
147
|
+
accept: ["image"]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
key: "body",
|
|
151
|
+
label: "本文",
|
|
152
|
+
type: "rich_text",
|
|
153
|
+
profile: {
|
|
154
|
+
headings: [
|
|
155
|
+
2,
|
|
156
|
+
3,
|
|
157
|
+
4
|
|
158
|
+
],
|
|
159
|
+
marks: [
|
|
160
|
+
"strong",
|
|
161
|
+
"em",
|
|
162
|
+
"code",
|
|
163
|
+
"strike"
|
|
164
|
+
],
|
|
165
|
+
list: {
|
|
166
|
+
ordered: true,
|
|
167
|
+
nested: true
|
|
168
|
+
},
|
|
169
|
+
quote: {
|
|
170
|
+
multiple: true,
|
|
171
|
+
cite: true
|
|
172
|
+
},
|
|
173
|
+
code: { caption: false },
|
|
174
|
+
table: {
|
|
175
|
+
head: "optional",
|
|
176
|
+
caption: "optional"
|
|
177
|
+
},
|
|
178
|
+
divider: true,
|
|
179
|
+
components: ["gallery", "link-card"]
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
key: "revised_at",
|
|
184
|
+
label: "更新日時",
|
|
185
|
+
type: "datetime"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
key: "tags",
|
|
189
|
+
label: "タグ",
|
|
190
|
+
type: "reference",
|
|
191
|
+
to: DEFAULT_COLLECTION_IDS.tag,
|
|
192
|
+
multiple: true
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
key: "excerpt",
|
|
196
|
+
label: "抜粋",
|
|
197
|
+
type: "long_text",
|
|
198
|
+
computed: {
|
|
199
|
+
kind: "excerpt",
|
|
200
|
+
from: "body"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
key: "read_min",
|
|
205
|
+
label: "読了の分",
|
|
206
|
+
type: "number",
|
|
207
|
+
computed: {
|
|
208
|
+
kind: "read_min",
|
|
209
|
+
from: "body"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: "links",
|
|
214
|
+
label: "リンク先",
|
|
215
|
+
type: "text",
|
|
216
|
+
multiple: true,
|
|
217
|
+
computed: {
|
|
218
|
+
kind: "links",
|
|
219
|
+
from: "body"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
pages: [{
|
|
224
|
+
path: "/posts/{slug}",
|
|
225
|
+
public: [{
|
|
226
|
+
key: "status",
|
|
227
|
+
in: ["published"]
|
|
228
|
+
}, {
|
|
229
|
+
key: "published_at",
|
|
230
|
+
not_future: true
|
|
231
|
+
}]
|
|
232
|
+
}]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: DEFAULT_COLLECTION_IDS.author,
|
|
236
|
+
slug: "author",
|
|
237
|
+
label: "著者",
|
|
238
|
+
roles: {
|
|
239
|
+
title: "name",
|
|
240
|
+
image: "portrait"
|
|
241
|
+
},
|
|
242
|
+
fields: [
|
|
243
|
+
{
|
|
244
|
+
key: "name",
|
|
245
|
+
label: "名前",
|
|
246
|
+
type: "text",
|
|
247
|
+
required: "save"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
key: "bio",
|
|
251
|
+
label: "紹介",
|
|
252
|
+
type: "long_text"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
key: "portrait",
|
|
256
|
+
label: "顔の画像",
|
|
257
|
+
type: "file",
|
|
258
|
+
accept: ["image"]
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
pages: [{ path: "/authors/{slug}" }]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
id: DEFAULT_COLLECTION_IDS.tag,
|
|
265
|
+
slug: "tag",
|
|
266
|
+
label: "タグ",
|
|
267
|
+
roles: { title: "label" },
|
|
268
|
+
fields: [{
|
|
269
|
+
key: "label",
|
|
270
|
+
label: "名前",
|
|
271
|
+
type: "text",
|
|
272
|
+
required: "save"
|
|
273
|
+
}]
|
|
274
|
+
},
|
|
275
|
+
FILES_COLLECTION
|
|
276
|
+
] };
|
|
277
|
+
/** 既定の画面設定(新しいプロジェクトの作成で適用する中立の値、移入する screens の土台) */
|
|
278
|
+
const DEFAULT_SCREENS = {
|
|
279
|
+
menu: [
|
|
280
|
+
"calendar",
|
|
281
|
+
{
|
|
282
|
+
id: "collections",
|
|
283
|
+
items: [
|
|
284
|
+
collectionItem(DEFAULT_COLLECTION_IDS.post),
|
|
285
|
+
collectionItem(DEFAULT_COLLECTION_IDS.tag),
|
|
286
|
+
collectionItem(DEFAULT_COLLECTION_IDS.author)
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
"files"
|
|
290
|
+
],
|
|
291
|
+
editors: { [DEFAULT_COLLECTION_IDS.post]: { sections: [
|
|
292
|
+
{
|
|
293
|
+
id: "classify",
|
|
294
|
+
label: "分類",
|
|
295
|
+
items: ["writers", "tags"]
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: "publish",
|
|
299
|
+
label: "公開",
|
|
300
|
+
items: ["published_at", "revised_at"]
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
id: "excerpt",
|
|
304
|
+
label: "説明",
|
|
305
|
+
items: ["excerpt"]
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: "image",
|
|
309
|
+
label: "メインの画像",
|
|
310
|
+
items: ["image"]
|
|
311
|
+
}
|
|
312
|
+
] } },
|
|
313
|
+
columns: { [DEFAULT_COLLECTION_IDS.post]: [
|
|
314
|
+
"status",
|
|
315
|
+
"writers",
|
|
316
|
+
"assignee",
|
|
317
|
+
"published_at",
|
|
318
|
+
"updated_at"
|
|
319
|
+
] }
|
|
320
|
+
};
|
|
321
|
+
// ../contract/src/transfer.ts
|
|
322
|
+
/** スキーマと設定の形式の名前 */
|
|
323
|
+
const CONFIG_FORMAT = "tunasand-config";
|
|
324
|
+
export { CONFIG_FORMAT, DEFAULT_SCHEMA, DEFAULT_SCREENS, FILES_COLLECTION, collectionOf, coverPosition, coverStart, createClock, cropRect, croppedHotspot, dateRoleFieldsOf, fileRefSchema, initialValueOf, isDateOnly, isStoredCollection, mediaSchema, objectPosition, optionLabelOf, optionsOf, pagePathOf, parseSchema, parseScreens, publicPathOf, requiredPrimaryCollectionOf, roleFieldOf, sourceIdsOf, sourcesFieldOf, stillOf, typesSourceOf, valueFieldsOf };
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import type { LoginAuth } from './oidc.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* ワークスペースのセッションの Cookie の値(issuedAt は発行の時刻でミリ秒)
|
|
4
|
+
* - sessionId はレジストリの sessions の行
|
|
5
|
+
* - host は発行した CMS のホスト名、project はそのときのホスト名のプロジェクトの ID
|
|
6
|
+
*/
|
|
3
7
|
export type HostSession = Readonly<{
|
|
4
|
-
|
|
8
|
+
sessionId: string;
|
|
9
|
+
accountId: string;
|
|
5
10
|
host: string;
|
|
6
11
|
project: string;
|
|
7
12
|
issuedAt: number;
|
|
8
13
|
}>;
|
|
9
|
-
/** ホスト名のプロジェクトの ID
|
|
14
|
+
/** ホスト名のプロジェクトの ID(レジストリにないホスト名は null) */
|
|
10
15
|
export type ProjectOfHost = (host: string) => Promise<string | null>;
|
|
11
|
-
/**
|
|
12
|
-
export type
|
|
16
|
+
/** ログインのセッション(レジストリの sessions の行と、そのアカウント) */
|
|
17
|
+
export type StartedSession = Readonly<{
|
|
18
|
+
sessionId: string;
|
|
19
|
+
accountId: string;
|
|
20
|
+
}>;
|
|
13
21
|
/**
|
|
14
|
-
*
|
|
15
|
-
* -
|
|
16
|
-
* - validAfter があれば、その時刻より後に発行したセッションだけ
|
|
22
|
+
* リクエストのホスト名に結び付いたセッション(なし・別のホスト・別のプロジェクト・形の違う値は null)
|
|
23
|
+
* - 行とアカウントと取り消しの照合は、カーネルがメンバーシップと同じ問い合わせで行う(ここでは Cookie とホストだけ)
|
|
17
24
|
*/
|
|
18
|
-
export declare function
|
|
25
|
+
export declare function hostSession(request: Request, secret: string, cookie: string | null, projectOf: ProjectOfHost): Promise<HostSession | null>;
|
|
19
26
|
/** セッションの Cookie の名前(https は __Host- の接頭辞) */
|
|
20
27
|
export declare const sessionCookieName: (url: URL) => string;
|
|
21
28
|
/** セッションの Cookie の Set-Cookie の値(maxAgeSec が0は削除) */
|
|
@@ -28,14 +35,12 @@ export declare const openSession: <T>(request: Request, secret: string) => Promi
|
|
|
28
35
|
export type HandoffLoginOptions = Readonly<{
|
|
29
36
|
/** Cookie の署名の鍵 */
|
|
30
37
|
secret: string;
|
|
31
|
-
/**
|
|
38
|
+
/** console のログインの URL(例: https://console.example.com/login) */
|
|
32
39
|
loginUrl: string;
|
|
33
|
-
/**
|
|
34
|
-
consume(token: string, host: string): Promise<
|
|
40
|
+
/** トークンを消して使い、console のセッションを返す(使えないトークンは null、host は CMS のホスト名) */
|
|
41
|
+
consume(token: string, host: string): Promise<StartedSession | null>;
|
|
35
42
|
/** ホスト名のプロジェクトの ID(セッションの発行と照合の両方で引く) */
|
|
36
43
|
projectOf: ProjectOfHost;
|
|
37
|
-
/** プロジェクトの一括の取り消しの時刻(照合で引く。なしは取り消しを見ない) */
|
|
38
|
-
validAfter?: SessionsValidAfter;
|
|
39
44
|
/** 入り口のパスの頭(既定 /auth) */
|
|
40
45
|
basePath?: string;
|
|
41
46
|
/** セッションの秒数(既定は12時間) */
|
|
@@ -43,10 +48,10 @@ export type HandoffLoginOptions = Readonly<{
|
|
|
43
48
|
/** 今の時刻(ミリ秒、試験で差し替える) */
|
|
44
49
|
now?: () => number;
|
|
45
50
|
}>;
|
|
46
|
-
/**
|
|
47
|
-
export declare function handoffLogin({ secret, loginUrl, consume, projectOf,
|
|
51
|
+
/** console からの引き継ぎのログイン */
|
|
52
|
+
export declare function handoffLogin({ secret, loginUrl, consume, projectOf, basePath, sessionTtlSec, now }: HandoffLoginOptions): LoginAuth;
|
|
48
53
|
/**
|
|
49
|
-
* 2つのログインを順に試す(emailOf は first が null なら second
|
|
54
|
+
* 2つのログインを順に試す(emailOf は first が null なら second、ほかは first)
|
|
50
55
|
* - 用途: 引き継ぎのログインに加えて、運営者のログイン(apps/api の operator.ts)を受け付ける
|
|
51
56
|
*/
|
|
52
57
|
export declare function eitherLogin(first: LoginAuth, second: LoginAuth): LoginAuth;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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';
|
|
2
|
+
export { cookieValue, eitherLogin, handoffLogin, type HandoffLoginOptions, type HostSession, openSession, type ProjectOfHost, sessionCookie, sessionCookieName, type StartedSession } from './handoff.js';
|
|
3
3
|
export { emailOfClaims, type LoginAuth, oidcLogin, type OidcLoginOptions, safeNext, tokenAuth, type TokenAuthOptions } from './oidc.js';
|
|
4
4
|
export { mcpSigningKey, openValue, sealValue, SIGNED_HEADERS, type SigningSecrets } from './signed.js';
|
|
5
|
-
export { signHs256Jwt, verifyHs256Jwt } from './jws.js';
|
|
5
|
+
export { type AsymmetricAlg, type JwsSigner, jwsKidOf, type PublicJwk, signHs256Jwt, signJws, verifyHs256Jwt, verifyJws } from './jws.js';
|
|
@@ -3,3 +3,44 @@ import type { SigningSecrets } from './signed.js';
|
|
|
3
3
|
export declare function signHs256Jwt(secret: string, claims: Readonly<Record<string, unknown>>): Promise<string>;
|
|
4
4
|
/** HS256 の JWT のクレーム(鍵のどれかで署名が合えばクレーム、形の誤り、alg の違い、署名の不一致は null。期限などは見ない) */
|
|
5
5
|
export declare function verifyHs256Jwt(secret: SigningSecrets, token: string | null | undefined): Promise<Record<string, unknown> | null>;
|
|
6
|
+
/** JWK の AKP の形(ML-DSA の公開鍵、draft-ietf-cose-dilithium) */
|
|
7
|
+
type AkpJwk = JsonWebKey & Readonly<{
|
|
8
|
+
pub?: string;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* 公開鍵の JWS の方式(JWKS の鍵の alg と JWS のヘッダーの alg。方式を足すときはここに足し、受ける側は許可の一覧で絞る)
|
|
12
|
+
* - ML-DSA-44: Workers は互換フラグ webcrypto_modern_algorithms、Node は24.7から Web Crypto で扱える
|
|
13
|
+
*/
|
|
14
|
+
declare const ASYMMETRIC_ALGS: {
|
|
15
|
+
readonly 'ML-DSA-44': {
|
|
16
|
+
readonly params: {
|
|
17
|
+
readonly name: "ML-DSA-44";
|
|
18
|
+
};
|
|
19
|
+
readonly publicOf: (k: AkpJwk) => JsonWebKey | null;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** 公開鍵の JWS の方式 */
|
|
23
|
+
export type AsymmetricAlg = keyof typeof ASYMMETRIC_ALGS;
|
|
24
|
+
/** 署名の鍵の世代(方式は鍵ごとに持つ。kid は JWKS の鍵の選択に使う) */
|
|
25
|
+
export type JwsSigner = Readonly<{
|
|
26
|
+
alg: AsymmetricAlg;
|
|
27
|
+
kid: string;
|
|
28
|
+
key: CryptoKey;
|
|
29
|
+
}>;
|
|
30
|
+
/** JWKS の公開鍵の1件(kid と alg を必ず持つ) */
|
|
31
|
+
export type PublicJwk = JsonWebKey & Readonly<{
|
|
32
|
+
kid: string;
|
|
33
|
+
alg: AsymmetricAlg;
|
|
34
|
+
use: 'sig';
|
|
35
|
+
}>;
|
|
36
|
+
/** 鍵の世代の方式で署名した JWS のコンパクトな形(ヘッダーは alg、typ、kid) */
|
|
37
|
+
export declare function signJws(signer: JwsSigner, typ: string, claims: Readonly<Record<string, unknown>>): Promise<string>;
|
|
38
|
+
/** JWS のヘッダーの kid(形の誤り、typ の違い、許可の一覧 algs にない alg は null。署名は見ない) */
|
|
39
|
+
export declare function jwsKidOf(token: string, typ: string, algs: readonly AsymmetricAlg[]): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* JWKS の公開鍵で検証した JWS のクレーム(ほかは null。クレームは見ない)
|
|
42
|
+
* - ヘッダーの typ が合い、alg が許可の一覧 algs にあり、kid の鍵の alg がヘッダーの alg と同じで、署名が合うこと
|
|
43
|
+
* - 実行環境の Web Crypto がその方式を持たなければ例外(jws_alg_unsupported)
|
|
44
|
+
*/
|
|
45
|
+
export declare function verifyJws(keys: readonly JsonWebKey[], token: string, typ: string, algs: readonly AsymmetricAlg[]): Promise<Record<string, unknown> | null>;
|
|
46
|
+
export {};
|
|
@@ -20,7 +20,7 @@ export type JwtOptions = Readonly<{
|
|
|
20
20
|
export declare function verifyJwt(token: string, options: JwtOptions): Promise<JwtClaims | null>;
|
|
21
21
|
/**
|
|
22
22
|
* Cloudflare Access の JWT を検証する設定(teamDomain は <チーム>.cloudflareaccess.com、aud はアプリの AUD)
|
|
23
|
-
* - aud:
|
|
23
|
+
* - aud: カンマ区切りで複数のアプリ(ホスト名ごとにアプリが分かれるワークスペース、どのアプリを通すかは Access がホスト名で判定)
|
|
24
24
|
*/
|
|
25
25
|
export declare const accessJwtOptions: ({ teamDomain, aud }: Readonly<{
|
|
26
26
|
teamDomain: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { type FetchCerts, type JwtClaims, type JwtOptions } from './jwt.js';
|
|
2
|
-
import { type ProjectOfHost } from './handoff.js';
|
|
3
|
-
/** ログイン(Auth
|
|
2
|
+
import { type HostSession, type ProjectOfHost, type StartedSession } from './handoff.js';
|
|
3
|
+
/** ログイン(Auth のインターフェースと同じ形) */
|
|
4
4
|
export type LoginAuth = {
|
|
5
|
+
/** 前段が要求ごとに確認した本人のメールアドレス(ヘッダーの JWT、手元の開発) */
|
|
5
6
|
emailOf(request: Request): Promise<string | null>;
|
|
7
|
+
/** Cookie のセッション(行と取り消しの照合はカーネル) */
|
|
8
|
+
sessionOf?(request: Request): Promise<HostSession | null>;
|
|
6
9
|
/** ログインの入り口の応答(対象外のパスは null) */
|
|
7
10
|
handle?(request: Request): Promise<Response | null>;
|
|
8
11
|
/** ログアウトの応答 */
|
|
@@ -35,6 +38,11 @@ export type OidcLoginOptions = Readonly<{
|
|
|
35
38
|
secret: string;
|
|
36
39
|
/** ホスト名のプロジェクトの ID(セッションの発行と照合の両方で引く。handoff.ts と同じ) */
|
|
37
40
|
projectOf: ProjectOfHost;
|
|
41
|
+
/** ログインのセッションの行を作る */
|
|
42
|
+
startSession(request: Request, signIn: Readonly<{
|
|
43
|
+
email: string;
|
|
44
|
+
method: string;
|
|
45
|
+
}>): Promise<StartedSession>;
|
|
38
46
|
/** 入り口のパスの頭(既定 /auth) */
|
|
39
47
|
basePath?: string;
|
|
40
48
|
/** 要求するスコープ(既定 openid email) */
|
|
@@ -47,4 +55,4 @@ export type OidcLoginOptions = Readonly<{
|
|
|
47
55
|
/** 同じオリジンの戻り先(外のオリジンへの転送を防ぐ) */
|
|
48
56
|
export declare const safeNext: (next: string | null) => string;
|
|
49
57
|
/** アプリ自身の OIDC のログイン(認可コードのフローと署名つきの Cookie のセッション) */
|
|
50
|
-
export declare function oidcLogin({ issuer, clientId, clientSecret, secret, projectOf, basePath, scope, sessionTtlSec, certs, fetch: fetcher }: OidcLoginOptions): LoginAuth;
|
|
58
|
+
export declare function oidcLogin({ issuer, clientId, clientSecret, secret, projectOf, startSession, basePath, scope, sessionTtlSec, certs, fetch: fetcher }: OidcLoginOptions): LoginAuth;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
export declare const SIGNED_HEADERS: {
|
|
3
3
|
/** MCP → CMS の署名(鍵は MCP_TOKEN、主体は Authorization のアクセストークン。Worker を通ったことの証明だけで、主体はトークンから CMS が決める) */
|
|
4
4
|
readonly mcp: "x-mcp-signature";
|
|
5
|
-
/** CMS ⇄ サイトのプレビューと下書きの署名(鍵は PREVIEW_TOKEN) */
|
|
6
|
-
readonly preview: "x-preview-signature";
|
|
7
5
|
};
|
|
8
6
|
/** 署名の鍵(1つか、移行の期間は新しい鍵を先・古い鍵を最後に並べた複数) */
|
|
9
7
|
export type SigningSecrets = string | readonly string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 閲覧のイベントの Analytics Engine の形(toolkit の analyticsEngineRecorder・analyticsEngineCounts に渡す)
|
|
3
|
+
* - blobs: VIEW_COLUMNS の順に blob1〜blob6
|
|
4
|
+
* - index: プロジェクト、指定なしは種類(Analytics Engine は index ごとに標本を抽出するため、共有のデータセットで小さなプロジェクトの記録が間引かれないように)
|
|
5
|
+
* - 公開の SDK の analytics がサイトの記録の側に同じ値を公開する
|
|
6
|
+
*/
|
|
7
|
+
export declare const VIEW_SCHEMA: Readonly<{
|
|
8
|
+
blobs: readonly ("id" | "kind" | "date" | "path" | "project" | "event")[];
|
|
9
|
+
doubles?: readonly never[] | undefined;
|
|
10
|
+
index?: ((event: Readonly<Partial<Record<"id" | "kind" | "date" | "path" | "project" | "event", string>> & Partial<Record<never, number>>>) => string) | undefined;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** プロフィールの上限(displayNameMax は表示名の文字数、iconMaxBytes はアイコンの画像のバイト数) */
|
|
2
|
+
export declare const ACCOUNT_PROFILE_LIMITS: {
|
|
3
|
+
readonly displayNameMax: 50;
|
|
4
|
+
readonly iconMaxBytes: number;
|
|
5
|
+
};
|
|
6
|
+
/** アイコンに受け付ける画像の種類 */
|
|
7
|
+
export declare const ACCOUNT_ICON_TYPES: readonly ["image/webp", "image/png", "image/jpeg"];
|
|
@@ -3,7 +3,7 @@ export declare const API_KEY_KINDS: readonly ["server"];
|
|
|
3
3
|
/** 鍵の種類 */
|
|
4
4
|
export type ApiKeyKind = (typeof API_KEY_KINDS)[number];
|
|
5
5
|
/** 鍵の操作 */
|
|
6
|
-
export declare const API_KEY_OPERATIONS: readonly ["read", "read_drafts", "
|
|
6
|
+
export declare const API_KEY_OPERATIONS: readonly ["read", "read_drafts", "read_entitled", "verify_end_users", "submit", "create", "update", "publish", "delete"];
|
|
7
7
|
/** 鍵の操作 */
|
|
8
8
|
export type ApiKeyOperation = (typeof API_KEY_OPERATIONS)[number];
|
|
9
9
|
/** 書き込みの操作(書き込みの API(#500)まで画面で選べない) */
|
|
@@ -16,9 +16,9 @@ export type ApiKeyPermissions = Readonly<Record<string, readonly ApiKeyOperation
|
|
|
16
16
|
export declare const DEFAULT_API_KEY_PERMISSIONS: {
|
|
17
17
|
readonly "*": readonly ["read"];
|
|
18
18
|
};
|
|
19
|
-
/** 鍵の権限がコレクションの操作を許すか(read は read_drafts でも満たす、
|
|
19
|
+
/** 鍵の権限がコレクションの操作を許すか(read は read_drafts でも満たす、verify_end_users は鍵の操作そのもの。新しい判定は判定の関数 authorize) */
|
|
20
20
|
export declare function apiKeyAllows(permissions: ApiKeyPermissions, collection: string, operation: ApiKeyOperation): boolean;
|
|
21
|
-
/** 一覧に表示する API の鍵(environments は読める環境で live か環境の
|
|
21
|
+
/** 一覧に表示する API の鍵(environments は読める環境で live か環境の ID、tail は鍵の末尾、revokedAt は失効の日時で有効なら null) */
|
|
22
22
|
export type ApiKey = Readonly<{
|
|
23
23
|
id: string;
|
|
24
24
|
label: string;
|
|
@@ -28,7 +28,11 @@ export type ApiKey = Readonly<{
|
|
|
28
28
|
tail: string;
|
|
29
29
|
createdAt: string;
|
|
30
30
|
revokedAt: string | null;
|
|
31
|
+
expiresAt: string | null;
|
|
31
32
|
}>;
|
|
33
|
+
/** 作成のときに選べる有効期限の日数(ほかに期限なし) */
|
|
34
|
+
export declare const API_KEY_EXPIRY_DAYS: readonly [30, 90, 365];
|
|
35
|
+
export type ApiKeyExpiryDays = (typeof API_KEY_EXPIRY_DAYS)[number];
|
|
32
36
|
/** 公開のエンドポイントで鍵ごとの回数の上限(period は秒) */
|
|
33
37
|
export declare const API_KEY_RATE: {
|
|
34
38
|
readonly limit: 600;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AppScope } from './appServer.js';
|
|
2
|
+
import type { SettingsArea } from './settings.js';
|
|
3
|
+
/** 経路を呼べる主体の種類(person はログイン中の人のアカウントだけ、delegable は加えて人の代理のアプリと MCP の接続) */
|
|
4
|
+
export type AppRoutePolicy = 'person' | 'delegable';
|
|
5
|
+
/** 経路の領域(設定の領域か管理の領域 admin。主体の種類で通った呼び出しを、さらに領域の権限で絞る。広げない) */
|
|
6
|
+
export type AppRouteArea = `settings:${SettingsArea}` | 'admin';
|
|
7
|
+
/** アプリの経路のメソッド */
|
|
8
|
+
export type AppRouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
9
|
+
/** 管理の API を呼ぶクライアント(path は /api から、呼んだ人の資格のまま) */
|
|
10
|
+
export type CmsClient = Readonly<{
|
|
11
|
+
fetch(path: `/api/${string}`, init?: RequestInit): Promise<Response>;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* 管理の API の一覧を、続きのカーソル next_cursor が尽きるまで読む(読めなければその応答)
|
|
15
|
+
* - path は一覧の経路(クエリを含めてよい)。1要求ごとに件数と走査の上限は効く
|
|
16
|
+
*/
|
|
17
|
+
export declare function cmsListAll<T>(cms: CmsClient, path: `/api/${string}`): Promise<T[] | Response>;
|
|
18
|
+
/** 経路の処理に渡す文脈(params は経路の名前つきの区間の値、egress はマニフェストの outbound の宣言に当たる要求だけ、scope は呼び出しのプロジェクトの文脈) */
|
|
19
|
+
export type AppContext = Readonly<{
|
|
20
|
+
cms: CmsClient;
|
|
21
|
+
scope: AppScope;
|
|
22
|
+
egress: (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
23
|
+
params: Readonly<Record<string, string>>;
|
|
24
|
+
/** 応答の後へ回す処理(実行の文脈がない呼び出しではなし) */
|
|
25
|
+
defer?: (task: Promise<unknown>) => void;
|
|
26
|
+
}>;
|
|
27
|
+
/** アプリの経路の管理の API のパス(アプリの経路は /api/apps/<名前空間> の下) */
|
|
28
|
+
export declare const appRoutePathOf: (namespace: string, path: `/${string}`) => `/${string}`;
|
|
29
|
+
/** アプリの経路(path はアプリの名前空間 /api/apps/<名前空間> からの経路、`:<名前>` は1つの区間。組み立ての後は appRoutePathOf のパス) */
|
|
30
|
+
export type AppRoute = Readonly<{
|
|
31
|
+
method: AppRouteMethod;
|
|
32
|
+
path: `/${string}`;
|
|
33
|
+
policy: AppRoutePolicy;
|
|
34
|
+
area?: AppRouteArea;
|
|
35
|
+
handle: (request: Request, ctx: AppContext) => Promise<Response>;
|
|
36
|
+
}>;
|
|
37
|
+
/** 外への読み込みの宛先の宣言に URL が当たるか(宣言は https のオリジン、ホスト名の先頭の `*.` は1つ以上の区間。https だけ、ポートの指定なし) */
|
|
38
|
+
export declare function egressAllows(declared: readonly string[], url: URL): boolean;
|