@tunasand/sdk 0.8.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.
Files changed (215) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +162 -143
  3. package/dist/analytics.js +76 -65
  4. package/dist/app.js +184 -163
  5. package/dist/apps-DIxAWBSZ.js +318 -0
  6. package/dist/astro-image.d.ts +1 -0
  7. package/dist/astro-image.js +33 -0
  8. package/dist/astro-server-Bwau8F6d.js +99 -0
  9. package/dist/astro-server.d.ts +1 -0
  10. package/dist/astro-server.js +1 -0
  11. package/dist/astro.d.ts +1 -0
  12. package/dist/astro.js +306 -0
  13. package/dist/bridge-Dv4NxGZ7.js +81 -0
  14. package/dist/bridge.js +1 -13
  15. package/dist/build-file-DNi0PHC5.js +31 -0
  16. package/dist/cli.js +6212 -8
  17. package/dist/{client-Derrexwr.js → client-C8STAw9T.js} +43 -24
  18. package/dist/code-N8pBUDbq.js +30 -0
  19. package/dist/code.d.ts +1 -0
  20. package/dist/code.js +1 -0
  21. package/dist/collection-nUz1RetA.js +264 -0
  22. package/dist/{declared-DuNMsdXw.js → declared-CE4a61qb.js} +35 -35
  23. package/dist/delivery.js +121 -114
  24. package/dist/dev-operations-Tutwi1On.js +46 -0
  25. package/dist/dev.js +9 -16
  26. package/dist/embeds-B-Dbn64k.js +29 -0
  27. package/dist/end-users.d.ts +1 -0
  28. package/dist/end-users.js +185 -0
  29. package/dist/endUsers-DODfjnv1.js +77 -0
  30. package/dist/{errorLabels-BgtQ_zUn.js → errorLabels-aT2bnMsO.js} +355 -235
  31. package/dist/i18n.js +4 -4
  32. package/dist/ids-DmtIoqBX.js +109 -0
  33. package/dist/integrations.js +95 -24
  34. package/dist/{ja-Du6ooL6i.js → ja-CrY_72Tn.js} +88 -44
  35. package/dist/{ja-CeHU0EaY.js → ja-axQPxMJ-.js} +3 -3
  36. package/dist/operations-CIB99rIY.js +95 -0
  37. package/dist/operations.d.ts +1 -0
  38. package/dist/operations.js +1 -0
  39. package/dist/{page-Bzrj24sJ.js → page-yo1cw1kW.js} +1 -1
  40. package/dist/preview.js +8 -1
  41. package/dist/{profile-1em_lcxq.js → profile-DBsXLvvI.js} +48 -48
  42. package/dist/rich-text.js +16 -16
  43. package/dist/{schema-WnobuwLg.js → schema-Dcg1ajnW.js} +496 -263
  44. package/dist/schema.js +66 -88
  45. package/dist/types/access/src/handoff.d.ts +19 -14
  46. package/dist/types/access/src/index.d.ts +2 -2
  47. package/dist/types/access/src/jws.d.ts +41 -0
  48. package/dist/types/access/src/oidc.d.ts +10 -2
  49. package/dist/types/access/src/signed.d.ts +0 -2
  50. package/dist/types/adapter-cloudflare/src/eventLog/viewSchema.d.ts +11 -0
  51. package/dist/types/contract/src/accountProfile.d.ts +7 -0
  52. package/dist/types/contract/src/apiKeys.d.ts +6 -2
  53. package/dist/types/contract/src/app.d.ts +15 -5
  54. package/dist/types/contract/src/appChannels.d.ts +114 -0
  55. package/dist/types/contract/src/appDefinition.d.ts +11 -5
  56. package/dist/types/contract/src/appDependencies.d.ts +87 -24
  57. package/dist/types/contract/src/appIdentities.d.ts +21 -0
  58. package/dist/types/contract/src/appInbound.d.ts +28 -0
  59. package/dist/types/contract/src/appMail.d.ts +106 -0
  60. package/dist/types/contract/src/appSecrets.d.ts +45 -0
  61. package/dist/types/contract/src/appServer.d.ts +408 -43
  62. package/dist/types/contract/src/approvals.d.ts +1 -1
  63. package/dist/types/contract/src/apps.d.ts +112 -55
  64. package/dist/types/contract/src/auditActions.d.ts +2 -2
  65. package/dist/types/contract/src/auditLabels.d.ts +111 -15
  66. package/dist/types/contract/src/authorize.d.ts +42 -14
  67. package/dist/types/contract/src/bridge.d.ts +34 -35
  68. package/dist/types/contract/src/consents.d.ts +32 -25
  69. package/dist/types/contract/src/deletion.d.ts +18 -0
  70. package/dist/types/contract/src/embeds.d.ts +16 -82
  71. package/dist/types/contract/src/{customerLabels.d.ts → endUserLabels.d.ts} +6 -9
  72. package/dist/types/contract/src/endUsers.d.ts +241 -0
  73. package/dist/types/contract/src/errorLabels.d.ts +63 -36
  74. package/dist/types/contract/src/errorLabelsEn.d.ts +46 -32
  75. package/dist/types/contract/src/errors.d.ts +28 -16
  76. package/dist/types/contract/src/eventSchemas.d.ts +70 -0
  77. package/dist/types/contract/src/eventTraces.d.ts +43 -0
  78. package/dist/types/contract/src/failureStatus.d.ts +14 -22
  79. package/dist/types/contract/src/fieldAccess.d.ts +8 -8
  80. package/dist/types/contract/src/formLabels.d.ts +3 -0
  81. package/dist/types/contract/src/forms.d.ts +4 -0
  82. package/dist/types/contract/src/grants.d.ts +26 -0
  83. package/dist/types/contract/src/headers.d.ts +5 -0
  84. package/dist/types/contract/src/hostingRpc.d.ts +23 -17
  85. package/dist/types/contract/src/identifiers.d.ts +45 -17
  86. package/dist/types/contract/src/ids.d.ts +18 -10
  87. package/dist/types/contract/src/import.d.ts +17 -16
  88. package/dist/types/contract/src/index.d.ts +52 -27
  89. package/dist/types/contract/src/integrationGraph.d.ts +83 -0
  90. package/dist/types/contract/src/issueLabels.d.ts +113 -81
  91. package/dist/types/contract/src/issueLabelsEn.d.ts +57 -41
  92. package/dist/types/contract/src/manage.d.ts +11 -7
  93. package/dist/types/contract/src/manageLabels.d.ts +2 -0
  94. package/dist/types/contract/src/manifestText.d.ts +66 -0
  95. package/dist/types/contract/src/messagePort.d.ts +208 -0
  96. package/dist/types/contract/src/migration.d.ts +2 -2
  97. package/dist/types/contract/src/notices.d.ts +38 -0
  98. package/dist/types/contract/src/operatorOperations.d.ts +0 -63
  99. package/dist/types/contract/src/outbound.d.ts +29 -0
  100. package/dist/types/contract/src/paths.d.ts +13 -0
  101. package/dist/types/contract/src/pending.d.ts +2 -0
  102. package/dist/types/contract/src/permissions.d.ts +7 -11
  103. package/dist/types/contract/src/perspective.d.ts +26 -0
  104. package/dist/types/contract/src/powers.d.ts +5 -0
  105. package/dist/types/contract/src/principal.d.ts +127 -56
  106. package/dist/types/contract/src/recordLabels.d.ts +6 -0
  107. package/dist/types/contract/src/roles.d.ts +7 -4
  108. package/dist/types/contract/src/ruleLabels.d.ts +16 -0
  109. package/dist/types/contract/src/ruleProblems.d.ts +16 -0
  110. package/dist/types/contract/src/schemaLabels.d.ts +8 -0
  111. package/dist/types/contract/src/settingProblems.d.ts +1 -1
  112. package/dist/types/contract/src/settings.d.ts +5 -7
  113. package/dist/types/contract/src/siteDeclaration.d.ts +7 -7
  114. package/dist/types/contract/src/siteIndex.d.ts +76 -0
  115. package/dist/types/contract/src/transfer.d.ts +1 -1
  116. package/dist/types/contract/src/trial.d.ts +4 -1
  117. package/dist/types/contract/src/versions.d.ts +1 -3
  118. package/dist/types/contract/src/viewEvent.d.ts +0 -9
  119. package/dist/types/contract/src/webhooks.d.ts +24 -3
  120. package/dist/types/contract/src/workflow.d.ts +13 -19
  121. package/dist/types/contract/src/workspaceItems.d.ts +20 -6
  122. package/dist/types/rich-text/src/html.d.ts +1 -1
  123. package/dist/types/rich-text/src/index.d.ts +8 -7
  124. package/dist/types/rich-text/src/labels/en.d.ts +1 -1
  125. package/dist/types/rich-text/src/labels/ja.d.ts +2 -2
  126. package/dist/types/rich-text/src/library.d.ts +1 -1
  127. package/dist/types/rich-text/src/media.d.ts +2 -0
  128. package/dist/types/rich-text/src/normalize.d.ts +1 -1
  129. package/dist/types/rich-text/src/problems.d.ts +5 -5
  130. package/dist/types/rich-text/src/profile.d.ts +10 -10
  131. package/dist/types/rich-text/src/render.d.ts +1 -1
  132. package/dist/types/rich-text/src/schema.d.ts +2 -2
  133. package/dist/types/rich-text/src/standard.d.ts +4 -4
  134. package/dist/types/rich-text/src/types.d.ts +2 -2
  135. package/dist/types/schema/src/audience.d.ts +1 -3
  136. package/dist/types/schema/src/capabilities.d.ts +18 -27
  137. package/dist/types/schema/src/changes.d.ts +3 -1
  138. package/dist/types/schema/src/collection.d.ts +138 -111
  139. package/dist/types/schema/src/defaultSchema.d.ts +8 -2
  140. package/dist/types/schema/src/fieldIds.d.ts +18 -0
  141. package/dist/types/schema/src/file.d.ts +22 -11
  142. package/dist/types/schema/src/fileRefs.d.ts +14 -0
  143. package/dist/types/schema/src/fileSignature.d.ts +20 -0
  144. package/dist/types/schema/src/filesCollection.d.ts +7 -0
  145. package/dist/types/schema/src/forms.d.ts +43 -0
  146. package/dist/types/schema/src/imageMetadata.d.ts +9 -0
  147. package/dist/types/schema/src/index.d.ts +18 -10
  148. package/dist/types/schema/src/input.d.ts +1 -1
  149. package/dist/types/schema/src/integrity.d.ts +8 -7
  150. package/dist/types/schema/src/kinds.d.ts +26 -0
  151. package/dist/types/schema/src/labels/en.d.ts +87 -46
  152. package/dist/types/schema/src/labels/ja.d.ts +89 -45
  153. package/dist/types/schema/src/mediaUrl.d.ts +26 -33
  154. package/dist/types/schema/src/page.d.ts +4 -4
  155. package/dist/types/schema/src/problems.d.ts +82 -41
  156. package/dist/types/schema/src/refs.d.ts +0 -9
  157. package/dist/types/schema/src/schema.d.ts +17 -12
  158. package/dist/types/schema/src/selfOps.d.ts +20 -19
  159. package/dist/types/schema/src/traits.d.ts +28 -0
  160. package/dist/types/schema/src/typesSource.d.ts +1 -1
  161. package/dist/types/schema/src/values.d.ts +5 -2
  162. package/dist/types/schema/src/widening.d.ts +3 -0
  163. package/dist/types/sdk/src/analytics.d.ts +2 -1
  164. package/dist/types/sdk/src/app.d.ts +40 -14
  165. package/dist/types/sdk/src/astro-image.d.ts +19 -0
  166. package/dist/types/sdk/src/astro-response.d.ts +6 -0
  167. package/dist/types/sdk/src/astro-server.d.ts +16 -0
  168. package/dist/types/sdk/src/astro.d.ts +19 -0
  169. package/dist/types/sdk/src/bridge.d.ts +2 -4
  170. package/dist/types/sdk/src/code.d.ts +61 -0
  171. package/dist/types/sdk/src/delegation.d.ts +13 -3
  172. package/dist/types/sdk/src/delivery/changes.d.ts +4 -4
  173. package/dist/types/sdk/src/delivery/client.d.ts +33 -22
  174. package/dist/types/sdk/src/delivery/fields.d.ts +3 -3
  175. package/dist/types/sdk/src/delivery/index.d.ts +3 -3
  176. package/dist/types/sdk/src/delivery/media.d.ts +5 -8
  177. package/dist/types/sdk/src/delivery/query.d.ts +15 -11
  178. package/dist/types/sdk/src/delivery/schema.d.ts +1 -1
  179. package/dist/types/sdk/src/delivery/values.d.ts +10 -14
  180. package/dist/types/sdk/src/delivery.d.ts +2 -2
  181. package/dist/types/sdk/src/dev-operations.d.ts +20 -0
  182. package/dist/types/sdk/src/dev.d.ts +6 -5
  183. package/dist/types/sdk/src/end-users.d.ts +190 -0
  184. package/dist/types/sdk/src/i18n.d.ts +2 -2
  185. package/dist/types/sdk/src/integrations.d.ts +14 -21
  186. package/dist/types/sdk/src/operations.d.ts +17 -0
  187. package/dist/types/sdk/src/preview.d.ts +2 -1
  188. package/dist/types/sdk/src/rich-text.d.ts +2 -2
  189. package/dist/types/sdk/src/schema.d.ts +1 -1
  190. package/dist/types/sdk/src/site/artifact.d.ts +64 -0
  191. package/dist/types/sdk/src/site/build-file.d.ts +30 -0
  192. package/dist/types/sdk/src/site/check-code.d.ts +14 -0
  193. package/dist/types/sdk/src/site/check-text.d.ts +19 -0
  194. package/dist/types/sdk/src/site/cli.d.ts +52 -0
  195. package/dist/types/sdk/src/site/content-type.d.ts +2 -0
  196. package/dist/types/sdk/src/site/labels.d.ts +14 -0
  197. package/dist/types/sdk/src/types.d.ts +1 -1
  198. package/dist/{types-B77qvqPJ.js → types-DkO2N7u2.js} +5 -6
  199. package/dist/types.js +1 -1
  200. package/dist/{typesSource-CWybQYus.js → typesSource-VJIxtN9b.js} +17 -15
  201. package/dist/workflow-CUpl6hO_.js +148 -0
  202. package/package.json +32 -6
  203. package/dist/apps-BxnJ1RlU.js +0 -435
  204. package/dist/bridge-DtHw9hS6.js +0 -74
  205. package/dist/collection-BEOxeISR.js +0 -189
  206. package/dist/customers-DTbL0qn6.js +0 -86
  207. package/dist/customers.d.ts +0 -1
  208. package/dist/customers.js +0 -185
  209. package/dist/embeds-B5V54Zur.js +0 -34
  210. package/dist/ids--RF7hGyC.js +0 -36
  211. package/dist/src-sazhzYui.js +0 -71
  212. package/dist/types/contract/src/customers.d.ts +0 -266
  213. package/dist/types/schema/src/legacy.d.ts +0 -2
  214. package/dist/types/schema/src/media.d.ts +0 -5
  215. package/dist/types/sdk/src/customers.d.ts +0 -184
package/dist/schema.js CHANGED
@@ -1,8 +1,7 @@
1
- import { M as usesReview, O as optionLabelOf, T as isStoredCollection, g as initialValueOf, j as roleFieldOf, k as optionsOf, p as collectionOf } from "./collection-BEOxeISR.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-Bzrj24sJ.js";
3
- import { a as requiredPrimaryCollectionOf, i as dateRoleFieldsOf, l as schemaProblemText, o as sourceIdsOf, r as parseSchema, s as sourcesFieldOf } from "./schema-WnobuwLg.js";
4
- import { t as PRODUCT_FIELD_LABELS } from "./ja-Du6ooL6i.js";
5
- import { n as typesSourceOf, r as valueFieldsOf } from "./typesSource-CWybQYus.js";
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";
6
5
  import { z } from "zod";
7
6
  // ../schema/src/file.ts
8
7
  const unit = z.number().min(0).max(1);
@@ -32,74 +31,47 @@ const mediaSchema = z.union([mediaBase.extend({ kind: z.literal("image") }), med
32
31
  poster: mediaBase
33
32
  })]);
34
33
  /** 使用する側が保存する実体の参照の検査 */
35
- const fileRefSchema = z.object({ file: z.string().min(1) });
36
- // ../schema/src/media.ts
37
- const file = [
38
- {
39
- key: "mime_type",
40
- label: PRODUCT_FIELD_LABELS.mimeType,
41
- type: "text",
42
- required: "save",
43
- description: PRODUCT_FIELD_LABELS.mimeTypeDescription
44
- },
45
- {
46
- key: "size",
47
- label: PRODUCT_FIELD_LABELS.size,
48
- type: "number",
49
- required: "save",
50
- description: PRODUCT_FIELD_LABELS.sizeDescription
51
- },
52
- {
53
- key: "width",
54
- label: PRODUCT_FIELD_LABELS.width,
55
- type: "number",
56
- required: "save",
57
- description: "px"
58
- },
59
- {
60
- key: "height",
61
- label: PRODUCT_FIELD_LABELS.height,
62
- type: "number",
63
- required: "save",
64
- description: "px"
65
- },
66
- {
67
- key: "alt",
68
- label: PRODUCT_FIELD_LABELS.alt,
69
- type: "text",
70
- description: PRODUCT_FIELD_LABELS.altDescription
71
- }
72
- ];
73
- /** 画像のコレクション */
74
- const IMAGE_TYPE = {
75
- id: "image",
76
- slug: "image",
77
- label: PRODUCT_FIELD_LABELS.image,
78
- description: PRODUCT_FIELD_LABELS.imageDescription,
79
- fields: file
80
- };
81
- /** 動画のコレクション(配信と再生は最初に使用する場所が決まったときに実装) */
82
- const VIDEO_TYPE = {
83
- id: "video",
84
- slug: "video",
85
- label: PRODUCT_FIELD_LABELS.video,
86
- fields: [
87
- ...file,
88
- {
89
- key: "duration",
90
- label: PRODUCT_FIELD_LABELS.duration,
91
- type: "number",
92
- description: PRODUCT_FIELD_LABELS.durationDescription
93
- },
94
- {
95
- key: "poster",
96
- label: PRODUCT_FIELD_LABELS.poster,
97
- type: "file",
98
- accept: ["image"],
99
- description: PRODUCT_FIELD_LABELS.posterDescription
100
- }
101
- ]
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"
102
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
+ });
103
75
  // ../schema/src/screens.ts
104
76
  /** メニューのグループの id(運用のサイドバーのグループはこの1つだけ) */
105
77
  const MENU_GROUP_ID = "collections";
@@ -135,13 +107,20 @@ const screensSchema = z.object({
135
107
  });
136
108
  /** 画面の設定の JSON を検査(形の誤りは ZodError) */
137
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
+ };
138
117
  /** 中立の既定のスキーマ(新しいプロジェクトの作成で適用するコレクション: post・author・tag・image・video、設定の移入の土台) */
139
118
  const DEFAULT_SCHEMA = { collections: [
140
119
  {
141
- id: "post",
120
+ id: DEFAULT_COLLECTION_IDS.post,
142
121
  slug: "post",
143
122
  label: "投稿",
144
- publishing: "review",
123
+ publication: true,
145
124
  roles: {
146
125
  title: "title",
147
126
  image: "image",
@@ -158,7 +137,7 @@ const DEFAULT_SCHEMA = { collections: [
158
137
  key: "writers",
159
138
  label: "著者",
160
139
  type: "reference",
161
- to: "author",
140
+ to: DEFAULT_COLLECTION_IDS.author,
162
141
  multiple: true
163
142
  },
164
143
  {
@@ -209,7 +188,7 @@ const DEFAULT_SCHEMA = { collections: [
209
188
  key: "tags",
210
189
  label: "タグ",
211
190
  type: "reference",
212
- to: "tag",
191
+ to: DEFAULT_COLLECTION_IDS.tag,
213
192
  multiple: true
214
193
  },
215
194
  {
@@ -248,12 +227,12 @@ const DEFAULT_SCHEMA = { collections: [
248
227
  in: ["published"]
249
228
  }, {
250
229
  key: "published_at",
251
- notFuture: true
230
+ not_future: true
252
231
  }]
253
232
  }]
254
233
  },
255
234
  {
256
- id: "author",
235
+ id: DEFAULT_COLLECTION_IDS.author,
257
236
  slug: "author",
258
237
  label: "著者",
259
238
  roles: {
@@ -282,7 +261,7 @@ const DEFAULT_SCHEMA = { collections: [
282
261
  pages: [{ path: "/authors/{slug}" }]
283
262
  },
284
263
  {
285
- id: "tag",
264
+ id: DEFAULT_COLLECTION_IDS.tag,
286
265
  slug: "tag",
287
266
  label: "タグ",
288
267
  roles: { title: "label" },
@@ -293,8 +272,7 @@ const DEFAULT_SCHEMA = { collections: [
293
272
  required: "save"
294
273
  }]
295
274
  },
296
- IMAGE_TYPE,
297
- VIDEO_TYPE
275
+ FILES_COLLECTION
298
276
  ] };
299
277
  /** 既定の画面設定(新しいプロジェクトの作成で適用する中立の値、移入する screens の土台) */
300
278
  const DEFAULT_SCREENS = {
@@ -303,14 +281,14 @@ const DEFAULT_SCREENS = {
303
281
  {
304
282
  id: "collections",
305
283
  items: [
306
- collectionItem("post"),
307
- collectionItem("tag"),
308
- collectionItem("author")
284
+ collectionItem(DEFAULT_COLLECTION_IDS.post),
285
+ collectionItem(DEFAULT_COLLECTION_IDS.tag),
286
+ collectionItem(DEFAULT_COLLECTION_IDS.author)
309
287
  ]
310
288
  },
311
289
  "files"
312
290
  ],
313
- editors: { post: { sections: [
291
+ editors: { [DEFAULT_COLLECTION_IDS.post]: { sections: [
314
292
  {
315
293
  id: "classify",
316
294
  label: "分類",
@@ -332,7 +310,7 @@ const DEFAULT_SCREENS = {
332
310
  items: ["image"]
333
311
  }
334
312
  ] } },
335
- columns: { post: [
313
+ columns: { [DEFAULT_COLLECTION_IDS.post]: [
336
314
  "status",
337
315
  "writers",
338
316
  "assignee",
@@ -342,5 +320,5 @@ const DEFAULT_SCREENS = {
342
320
  };
343
321
  // ../contract/src/transfer.ts
344
322
  /** スキーマと設定の形式の名前 */
345
- const CONFIG_FORMAT = "cms-config";
346
- export { CONFIG_FORMAT, DEFAULT_SCHEMA, DEFAULT_SCREENS, IMAGE_TYPE, VIDEO_TYPE, 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, usesReview, valueFieldsOf };
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
- /** プロジェクトに結び付いたセッションの値(host は発行した CMS のホスト名、project はそのときのホスト名のプロジェクトの ID、issuedAt は発行の時刻でミリ秒) */
2
+ /**
3
+ * ワークスペースのセッションの Cookie の値(issuedAt は発行の時刻でミリ秒)
4
+ * - sessionId はレジストリの sessions の行
5
+ * - host は発行した CMS のホスト名、project はそのときのホスト名のプロジェクトの ID
6
+ */
3
7
  export type HostSession = Readonly<{
4
- email: string;
8
+ sessionId: string;
9
+ accountId: string;
5
10
  host: string;
6
11
  project: string;
7
12
  issuedAt: number;
8
13
  }>;
9
14
  /** ホスト名のプロジェクトの ID(レジストリにないホスト名は null) */
10
15
  export type ProjectOfHost = (host: string) => Promise<string | null>;
11
- /** プロジェクトの一括の取り消しの時刻(ミリ秒、取り消しなしは null) */
12
- export type SessionsValidAfter = (project: string) => Promise<number | null>;
16
+ /** ログインのセッション(レジストリの sessions の行と、そのアカウント) */
17
+ export type StartedSession = Readonly<{
18
+ sessionId: string;
19
+ accountId: string;
20
+ }>;
13
21
  /**
14
- * リクエストのホスト名に結び付いたセッションのメールアドレス(なし・別のホスト・古い形・取り消した後は null)
15
- * - ホスト名を projectOf で引いたプロジェクトと、セッションのプロジェクトが同じときだけ(値にプロジェクトのない古い形は通さない)
16
- * - validAfter があれば、その時刻より後に発行したセッションだけ
22
+ * リクエストのホスト名に結び付いたセッション(なし・別のホスト・別のプロジェクト・形の違う値は null)
23
+ * - 行とアカウントと取り消しの照合は、カーネルがメンバーシップと同じ問い合わせで行う(ここでは Cookie とホストだけ)
17
24
  */
18
- export declare function hostSessionEmail(request: Request, secret: string, cookie: string | null, projectOf: ProjectOfHost, validAfter?: SessionsValidAfter): Promise<string | null>;
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は削除) */
@@ -30,12 +37,10 @@ export type HandoffLoginOptions = Readonly<{
30
37
  secret: string;
31
38
  /** console のログインの URL(例: https://console.example.com/login) */
32
39
  loginUrl: string;
33
- /** トークンを消して使い、メールアドレスを返す(使えないトークンは null、host は CMS のホスト名) */
34
- consume(token: string, host: string): Promise<string | null>;
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時間) */
@@ -44,9 +49,9 @@ export type HandoffLoginOptions = Readonly<{
44
49
  now?: () => number;
45
50
  }>;
46
51
  /** console からの引き継ぎのログイン */
47
- export declare function handoffLogin({ secret, loginUrl, consume, projectOf, validAfter, basePath, sessionTtlSec, now }: HandoffLoginOptions): LoginAuth;
52
+ export declare function handoffLogin({ secret, loginUrl, consume, projectOf, basePath, sessionTtlSec, now }: HandoffLoginOptions): LoginAuth;
48
53
  /**
49
- * 2つのログインを順に試す(emailOf は first が null なら second、入り口とログアウトは first)
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 {};
@@ -1,8 +1,11 @@
1
1
  import { type FetchCerts, type JwtClaims, type JwtOptions } from './jwt.js';
2
- import { type ProjectOfHost } from './handoff.js';
2
+ import { type HostSession, type ProjectOfHost, type StartedSession } from './handoff.js';
3
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", "read_customers", "verify_customers", "create", "update", "publish", "delete"];
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,7 +16,7 @@ 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 でも満たす、verify_customers は鍵の操作そのもの。新しい判定は判定の関数 authorize) */
19
+ /** 鍵の権限がコレクションの操作を許すか(read は read_drafts でも満たす、verify_end_users は鍵の操作そのもの。新しい判定は判定の関数 authorize) */
20
20
  export declare function apiKeyAllows(permissions: ApiKeyPermissions, collection: string, operation: ApiKeyOperation): boolean;
21
21
  /** 一覧に表示する API の鍵(environments は読める環境で live か環境の ID、tail は鍵の末尾、revokedAt は失効の日時で有効なら null) */
22
22
  export type ApiKey = Readonly<{
@@ -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;
@@ -1,14 +1,21 @@
1
1
  import type { AppScope } from './appServer.js';
2
2
  import type { SettingsArea } from './settings.js';
3
- /** 経路の権限の判定の種類(account はログイン中のすべて、own は本人か管理者で持ち主の判定は handle、admin は管理者だけ、settings:<領域> は設定の領域の権限) */
4
- export type AppRoutePolicy = 'account' | 'own' | 'permission' | 'admin' | `settings:${SettingsArea}`;
3
+ /** 経路を呼べる主体の種類(person はログイン中の人のアカウントだけ、delegable は加えて人の代理のアプリと MCP の接続) */
4
+ export type AppRoutePolicy = 'person' | 'delegable';
5
+ /** 経路の領域(設定の領域か管理の領域 admin。主体の種類で通った呼び出しを、さらに領域の権限で絞る。広げない) */
6
+ export type AppRouteArea = `settings:${SettingsArea}` | 'admin';
5
7
  /** アプリの経路のメソッド */
6
8
  export type AppRouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
7
9
  /** 管理の API を呼ぶクライアント(path は /api から、呼んだ人の資格のまま) */
8
10
  export type CmsClient = Readonly<{
9
11
  fetch(path: `/api/${string}`, init?: RequestInit): Promise<Response>;
10
12
  }>;
11
- /** 経路の処理に渡す文脈(params は経路の名前つきの区間の値、egress はサーバーの宣言の egress の宛先だけへの GET と HEAD、scope は呼び出しのプロジェクトの文脈) */
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 は呼び出しのプロジェクトの文脈) */
12
19
  export type AppContext = Readonly<{
13
20
  cms: CmsClient;
14
21
  scope: AppScope;
@@ -17,11 +24,14 @@ export type AppContext = Readonly<{
17
24
  /** 応答の後へ回す処理(実行の文脈がない呼び出しではなし) */
18
25
  defer?: (task: Promise<unknown>) => void;
19
26
  }>;
20
- /** アプリの経路(path は /api からの経路、`:<名前>` は1つの区間) */
27
+ /** アプリの経路の管理の API のパス(アプリの経路は /api/apps/<名前空間> の下) */
28
+ export declare const appRoutePathOf: (namespace: string, path: `/${string}`) => `/${string}`;
29
+ /** アプリの経路(path はアプリの名前空間 /api/apps/<名前空間> からの経路、`:<名前>` は1つの区間。組み立ての後は appRoutePathOf のパス) */
21
30
  export type AppRoute = Readonly<{
22
31
  method: AppRouteMethod;
23
- path: `/api/${string}`;
32
+ path: `/${string}`;
24
33
  policy: AppRoutePolicy;
34
+ area?: AppRouteArea;
25
35
  handle: (request: Request, ctx: AppContext) => Promise<Response>;
26
36
  }>;
27
37
  /** 外への読み込みの宛先の宣言に URL が当たるか(宣言は https のオリジン、ホスト名の先頭の `*.` は1つ以上の区間。https だけ、ポートの指定なし) */
@@ -0,0 +1,114 @@
1
+ import type { AppSettingDef, AppSettingValue } from './appDependencies.js';
2
+ import { type AppIdentityDeclaration } from './appIdentities.js';
3
+ import { type AppInboundDeclaration } from './appInbound.js';
4
+ import { type AppHmacCheck, type AppSecretDeclaration, type AppSecretState } from './appSecrets.js';
5
+ import type { AppPortResult, AppScope } from './appServer.js';
6
+ /** チャネルの能力(送信、受信) */
7
+ export declare const CHANNEL_CAPABILITIES: readonly ["send", "receive"];
8
+ export type ChannelCapability = (typeof CHANNEL_CAPABILITIES)[number];
9
+ /** チャネルのアドレスの形(registered_domain: プロジェクトの登録したドメインの上のローカル部) */
10
+ export declare const CHANNEL_ADDRESS_KINDS: readonly ["registered_domain"];
11
+ export type ChannelAddressKind = (typeof CHANNEL_ADDRESS_KINDS)[number];
12
+ /** チャネルの種類の名前の形 */
13
+ export declare const CHANNEL_KIND: RegExp;
14
+ /** チャネルの設定の型(コレクションの選択はチャネルの設定にしない) */
15
+ export declare const CHANNEL_SETTING_TYPES: readonly ["boolean", "text", "number", "select"];
16
+ /** 宣言の上限(種類の数、見出しの字数、種類ごとの設定の数) */
17
+ export declare const APP_CHANNEL_KIND_LIMITS: {
18
+ readonly kindsMax: 10;
19
+ readonly labelMaxChars: 80;
20
+ readonly settingsMax: 30;
21
+ };
22
+ /** チャネルの値の上限(名前の字数、文字の設定の値の字数、アドレスのローカル部の字数) */
23
+ export declare const APP_CHANNEL_LIMITS: {
24
+ readonly nameMaxChars: 80;
25
+ readonly textSettingMaxChars: 2000;
26
+ readonly localMaxChars: 64;
27
+ };
28
+ /**
29
+ * マニフェストのチャネルの種類の宣言(channel_kinds の要素)
30
+ * - capabilities: 種類のチャネルが持てる能力。チャネルごとに、この中から使う能力を選ぶ
31
+ * - address: アドレスを持つ種類だけ(形は CHANNEL_ADDRESS_KINDS)
32
+ * - settings、secrets: チャネルごとの設定と秘密値(形はアプリの settings と secrets と同じ)
33
+ * - inbound: 外のサービスから受ける経路(受信の能力が要る)、identities: 本人の証明の発行者
34
+ */
35
+ export type AppChannelKind = Readonly<{
36
+ kind: string;
37
+ label: string;
38
+ capabilities: readonly ChannelCapability[];
39
+ address?: ChannelAddressKind;
40
+ settings?: readonly AppSettingDef[];
41
+ secrets?: readonly AppSecretDeclaration[];
42
+ inbound?: readonly AppInboundDeclaration[];
43
+ identities?: readonly AppIdentityDeclaration[];
44
+ }>;
45
+ /** マニフェストの channel_kinds の誤りの箇所(マニフェストの道) */
46
+ export declare function appChannelKindsProblems(kinds: unknown): string[];
47
+ /** マニフェストの channel_kinds の種類の宣言(なければ null) */
48
+ export declare const channelKindOf: (kinds: readonly AppChannelKind[] | undefined, kind: string) => AppChannelKind | null;
49
+ /** チャネルのアドレス(ローカル部とドメインは小文字) */
50
+ export type ChannelAddress = Readonly<{
51
+ local: string;
52
+ domain: string;
53
+ }>;
54
+ /**
55
+ * アプリが読むチャネル
56
+ * - capabilities: このチャネルで使う能力(種類の宣言の能力の部分集合)
57
+ * - isDefault: プロジェクトのこの種類の既定のチャネル(送る側がチャネルを指定しないときに使う。種類ごとに1つまで)
58
+ * - settings: チャネルの設定の値(種類の宣言の settings のキーだけ。未入力のキーは含めない)
59
+ */
60
+ export type AppChannel = Readonly<{
61
+ id: string;
62
+ kind: string;
63
+ name: string;
64
+ capabilities: readonly ChannelCapability[];
65
+ address: ChannelAddress | null;
66
+ isDefault: boolean;
67
+ settings: Readonly<Record<string, AppSettingValue>>;
68
+ }>;
69
+ /**
70
+ * チャネルの作成と変更の値(変更は全部の値を渡す)
71
+ * - capabilities: 種類の宣言の能力の部分集合(1つ以上)
72
+ * - address: registered_domain の種類では必須で、プロジェクトの検証済みのドメインの上のアドレス。ほかの種類は渡さない
73
+ * - settings: 種類の宣言の settings のキーと型の値だけ(未入力のキーは含めない)
74
+ */
75
+ export type AppChannelInput = Readonly<{
76
+ name: string;
77
+ capabilities: readonly ChannelCapability[];
78
+ address?: ChannelAddress;
79
+ isDefault: boolean;
80
+ settings: Readonly<Record<string, AppSettingValue>>;
81
+ }>;
82
+ /**
83
+ * チャネルの口(マニフェストの channel_kinds で宣言した種類の、このアプリのインストールに結んだチャネルだけ)
84
+ * - list: プロジェクトのチャネル(止めたチャネルは含めない)、get: 1つ(ほかのアプリのチャネルと止めたチャネルは null)
85
+ * - channelId がこのインストールに結んだ宣言の種類のチャネルでなければ not_found(target は channel)
86
+ * - verifyHmac、configured: チャネルのこの環境の秘密値(種類の宣言の secrets のキーだけ。ほかは app_secret_undeclared の UsageError)
87
+ * - egress: マニフェストの outbound の宣言に当たる外への要求で、auth にチャネルのこの環境の秘密値を載せる
88
+ * - create、update、remove、secrets、setSecret、deleteSecret: 経路を呼んだ人の操作(主体のない文脈は forbidden)
89
+ * チャネルの作成、変更、削除は設定の領域 integrations の権限、秘密値の入力と削除はそれに加えて連携の秘密値の管理の権限が要り、委任できない
90
+ * 作成と変更と削除はプロジェクトの全部の環境に効き、レジストリを書ける環境だけで行う(ほかは not_live)
91
+ * 値の誤りは invalid_input と issues、アドレスがほかのチャネルにあれば in_use、宣言のない種類は app_channel_undeclared の UsageError
92
+ * remove はチャネルを止め、この環境のチャネルの秘密値を消す(ほかの環境の秘密値は定期の処理が消す)
93
+ * secrets と setSecret は値を返さず、末尾だけを返す
94
+ * - inboundUrl: 種類の inbound の name の、このチャネルの受信の URL(外のサービスの管理画面に貼る値)
95
+ * 配信 API の公開の基点がない配置は null、宣言のない name は app_channel_undeclared の UsageError
96
+ */
97
+ export type AppChannelsPort = Readonly<{
98
+ list: (scope: AppScope) => Promise<readonly AppChannel[]>;
99
+ get: (scope: AppScope, channelId: string) => Promise<AppChannel | null>;
100
+ verifyHmac: (scope: AppScope, channelId: string, key: string, check: AppHmacCheck) => Promise<AppPortResult<boolean>>;
101
+ configured: (scope: AppScope, channelId: string, key: string) => Promise<AppPortResult<boolean>>;
102
+ egress: (scope: AppScope, channelId: string, input: string | URL, init?: RequestInit) => Promise<AppPortResult<Response>>;
103
+ create: (scope: AppScope, kind: string, input: AppChannelInput) => Promise<AppPortResult<AppChannel>>;
104
+ update: (scope: AppScope, channelId: string, input: AppChannelInput) => Promise<AppPortResult<AppChannel>>;
105
+ remove: (scope: AppScope, channelId: string) => Promise<AppPortResult<void>>;
106
+ secrets: (scope: AppScope, channelId: string) => Promise<AppPortResult<readonly AppSecretState[]>>;
107
+ setSecret: (scope: AppScope, channelId: string, key: string, value: string) => Promise<AppPortResult<Readonly<{
108
+ tail: string | null;
109
+ }>>>;
110
+ deleteSecret: (scope: AppScope, channelId: string, key: string) => Promise<AppPortResult<void>>;
111
+ inboundUrl: (scope: AppScope, channelId: string, name: string) => Promise<AppPortResult<string | null>>;
112
+ }>;
113
+ /** 種類の宣言の秘密値のキー(outbound の auth が指せるキー) */
114
+ export declare const channelSecretKeysOf: (kinds: unknown) => string[];