@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.
Files changed (285) hide show
  1. package/CHANGELOG.md +233 -88
  2. package/README.md +296 -273
  3. package/dist/analytics.js +657 -10
  4. package/dist/app.js +323 -96
  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 +2 -14
  15. package/dist/build-file-DNi0PHC5.js +31 -0
  16. package/dist/cli.js +6214 -9
  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-C_GvPiGF.js → declared-CE4a61qb.js} +124 -36
  23. package/dist/delivery.js +124 -132
  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/{customers-C_vJY2_v.js → endUsers-DODfjnv1.js} +31 -38
  30. package/dist/{errorLabels-CPKiPabZ.js → errorLabels-aT2bnMsO.js} +593 -460
  31. package/dist/i18n.js +4 -4
  32. package/dist/ids-DmtIoqBX.js +109 -0
  33. package/dist/integrations.js +95 -49
  34. package/dist/{ja-C6lX0CeJ.js → ja-CrY_72Tn.js} +99 -54
  35. package/dist/{ja-C1HEWWTQ.js → ja-axQPxMJ-.js} +6 -6
  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-E_cYgZx-.js → page-yo1cw1kW.js} +5 -5
  40. package/dist/preview.js +8 -1
  41. package/dist/{profile-D6t1QMQh.js → profile-DBsXLvvI.js} +52 -52
  42. package/dist/rich-text.d.ts +1 -0
  43. package/dist/{body.js → rich-text.js} +20 -21
  44. package/dist/schema-Dcg1ajnW.js +1267 -0
  45. package/dist/schema.js +324 -1
  46. package/dist/types/access/src/handoff.d.ts +22 -17
  47. package/dist/types/access/src/index.d.ts +2 -2
  48. package/dist/types/access/src/jws.d.ts +41 -0
  49. package/dist/types/access/src/jwt.d.ts +1 -1
  50. package/dist/types/access/src/oidc.d.ts +11 -3
  51. package/dist/types/access/src/signed.d.ts +0 -2
  52. package/dist/types/adapter-cloudflare/src/eventLog/viewSchema.d.ts +11 -0
  53. package/dist/types/contract/src/accountProfile.d.ts +7 -0
  54. package/dist/types/{cms-contract → contract}/src/apiKeys.d.ts +7 -3
  55. package/dist/types/contract/src/app.d.ts +38 -0
  56. package/dist/types/contract/src/appChannels.d.ts +114 -0
  57. package/dist/types/contract/src/appDefinition.d.ts +133 -0
  58. package/dist/types/{cms-contract → contract}/src/appDependencies.d.ts +91 -35
  59. package/dist/types/contract/src/appIdentities.d.ts +21 -0
  60. package/dist/types/contract/src/appInbound.d.ts +28 -0
  61. package/dist/types/contract/src/appMail.d.ts +106 -0
  62. package/dist/types/contract/src/appSecrets.d.ts +45 -0
  63. package/dist/types/contract/src/appServer.d.ts +501 -0
  64. package/dist/types/contract/src/approvalLabels.d.ts +26 -0
  65. package/dist/types/contract/src/approvals.d.ts +63 -0
  66. package/dist/types/contract/src/apps.d.ts +295 -0
  67. package/dist/types/contract/src/auditActions.d.ts +18 -0
  68. package/dist/types/contract/src/auditLabels.d.ts +223 -0
  69. package/dist/types/contract/src/authorize.d.ts +133 -0
  70. package/dist/types/{cms-contract → contract}/src/bridge.d.ts +39 -40
  71. package/dist/types/{cms-contract → contract}/src/consents.d.ts +32 -25
  72. package/dist/types/contract/src/deletion.d.ts +18 -0
  73. package/dist/types/contract/src/embeds.d.ts +105 -0
  74. package/dist/types/{cms-contract/src/customerLabels.d.ts → contract/src/endUserLabels.d.ts} +6 -9
  75. package/dist/types/contract/src/endUsers.d.ts +241 -0
  76. package/dist/types/{cms-contract → contract}/src/errorLabels.d.ts +76 -47
  77. package/dist/types/{cms-contract → contract}/src/errorLabelsEn.d.ts +52 -36
  78. package/dist/types/contract/src/errors.d.ts +117 -0
  79. package/dist/types/contract/src/eventSchemas.d.ts +70 -0
  80. package/dist/types/contract/src/eventTraces.d.ts +43 -0
  81. package/dist/types/{cms-contract → contract}/src/failureStatus.d.ts +16 -23
  82. package/dist/types/contract/src/fieldAccess.d.ts +45 -0
  83. package/dist/types/contract/src/fieldRules.d.ts +41 -0
  84. package/dist/types/{cms-contract/src/assets.d.ts → contract/src/files.d.ts} +5 -5
  85. package/dist/types/contract/src/formLabels.d.ts +3 -0
  86. package/dist/types/contract/src/forms.d.ts +4 -0
  87. package/dist/types/{cms-contract → contract}/src/functions.d.ts +3 -3
  88. package/dist/types/contract/src/grants.d.ts +26 -0
  89. package/dist/types/contract/src/headers.d.ts +5 -0
  90. package/dist/types/contract/src/hostingRpc.d.ts +149 -0
  91. package/dist/types/contract/src/hostnames.d.ts +30 -0
  92. package/dist/types/contract/src/identifiers.d.ts +148 -0
  93. package/dist/types/contract/src/ids.d.ts +112 -0
  94. package/dist/types/{cms-contract → contract}/src/import.d.ts +20 -19
  95. package/dist/types/contract/src/importLabels.d.ts +3 -0
  96. package/dist/types/contract/src/index.d.ts +92 -0
  97. package/dist/types/contract/src/integrationGraph.d.ts +83 -0
  98. package/dist/types/{cms-contract → contract}/src/issueLabels.d.ts +135 -99
  99. package/dist/types/{cms-contract → contract}/src/issueLabelsEn.d.ts +70 -52
  100. package/dist/types/contract/src/labels.d.ts +11 -0
  101. package/dist/types/contract/src/legacyAuditLabels.d.ts +10 -0
  102. package/dist/types/contract/src/livePeriods.d.ts +18 -0
  103. package/dist/types/contract/src/manage.d.ts +51 -0
  104. package/dist/types/contract/src/manageLabels.d.ts +11 -0
  105. package/dist/types/contract/src/manifestText.d.ts +66 -0
  106. package/dist/types/contract/src/mcpAuth.d.ts +139 -0
  107. package/dist/types/contract/src/mcpLabels.d.ts +5 -0
  108. package/dist/types/contract/src/messagePort.d.ts +208 -0
  109. package/dist/types/{cms-contract → contract}/src/migration.d.ts +3 -3
  110. package/dist/types/contract/src/notices.d.ts +38 -0
  111. package/dist/types/contract/src/operatorOperations.d.ts +640 -0
  112. package/dist/types/contract/src/operators.d.ts +33 -0
  113. package/dist/types/contract/src/outbound.d.ts +29 -0
  114. package/dist/types/contract/src/paths.d.ts +34 -0
  115. package/dist/types/contract/src/pending.d.ts +6 -0
  116. package/dist/types/{cms-contract → contract}/src/permissions.d.ts +9 -11
  117. package/dist/types/contract/src/perspective.d.ts +26 -0
  118. package/dist/types/contract/src/powers.d.ts +5 -0
  119. package/dist/types/contract/src/principal.d.ts +181 -0
  120. package/dist/types/{cms-contract → contract}/src/problems.d.ts +4 -4
  121. package/dist/types/contract/src/projectRole.d.ts +6 -0
  122. package/dist/types/contract/src/recordLabels.d.ts +6 -0
  123. package/dist/types/{cms-contract → contract}/src/roles.d.ts +10 -6
  124. package/dist/types/contract/src/ruleLabels.d.ts +16 -0
  125. package/dist/types/contract/src/ruleProblems.d.ts +16 -0
  126. package/dist/types/contract/src/schemaLabels.d.ts +8 -0
  127. package/dist/types/{cms-contract → contract}/src/settingProblems.d.ts +3 -3
  128. package/dist/types/{cms-contract → contract}/src/settings.d.ts +6 -8
  129. package/dist/types/contract/src/settingsLabels.d.ts +3 -0
  130. package/dist/types/{cms-contract → contract}/src/siteDeclaration.d.ts +7 -7
  131. package/dist/types/contract/src/siteIndex.d.ts +76 -0
  132. package/dist/types/contract/src/slugs.d.ts +6 -0
  133. package/dist/types/{cms-contract → contract}/src/transfer.d.ts +4 -4
  134. package/dist/types/contract/src/trial.d.ts +13 -0
  135. package/dist/types/contract/src/versions.d.ts +7 -0
  136. package/dist/types/{analytics/src/view.d.ts → contract/src/viewEvent.d.ts} +0 -9
  137. package/dist/types/contract/src/webhooks.d.ts +135 -0
  138. package/dist/types/contract/src/workflow.d.ts +43 -0
  139. package/dist/types/contract/src/workspaceItems.d.ts +87 -0
  140. package/dist/types/contract/src/workspacePaths.d.ts +4 -0
  141. package/dist/types/{body → rich-text}/src/declared.d.ts +2 -2
  142. package/dist/types/{body → rich-text}/src/embed.d.ts +1 -1
  143. package/dist/types/{body → rich-text}/src/html.d.ts +1 -1
  144. package/dist/types/{body → rich-text}/src/index.d.ts +8 -7
  145. package/dist/types/{body → rich-text}/src/labels/en.d.ts +1 -1
  146. package/dist/types/{body → rich-text}/src/labels/ja.d.ts +4 -4
  147. package/dist/types/{body → rich-text}/src/library.d.ts +1 -1
  148. package/dist/types/rich-text/src/media.d.ts +2 -0
  149. package/dist/types/{body → rich-text}/src/normalize.d.ts +1 -1
  150. package/dist/types/{body → rich-text}/src/problems.d.ts +5 -5
  151. package/dist/types/{body → rich-text}/src/profile.d.ts +11 -11
  152. package/dist/types/{body → rich-text}/src/render.d.ts +1 -1
  153. package/dist/types/{body → rich-text}/src/schema.d.ts +2 -2
  154. package/dist/types/{body → rich-text}/src/standard.d.ts +4 -4
  155. package/dist/types/{body → rich-text}/src/types.d.ts +2 -2
  156. package/dist/types/schema/src/audience.d.ts +36 -0
  157. package/dist/types/schema/src/brand.d.ts +5 -0
  158. package/dist/types/schema/src/capabilities.d.ts +19 -0
  159. package/dist/types/{model → schema}/src/changes.d.ts +9 -7
  160. package/dist/types/{model → schema}/src/check.d.ts +2 -2
  161. package/dist/types/{model/src/model.d.ts → schema/src/collection.d.ts} +150 -121
  162. package/dist/types/schema/src/defaultSchema.d.ts +15 -0
  163. package/dist/types/schema/src/fieldIds.d.ts +18 -0
  164. package/dist/types/{model/src/asset.d.ts → schema/src/file.d.ts} +36 -25
  165. package/dist/types/schema/src/fileRefs.d.ts +14 -0
  166. package/dist/types/schema/src/fileSignature.d.ts +20 -0
  167. package/dist/types/schema/src/filesCollection.d.ts +7 -0
  168. package/dist/types/schema/src/forms.d.ts +43 -0
  169. package/dist/types/{model → schema}/src/image.d.ts +3 -3
  170. package/dist/types/schema/src/imageMetadata.d.ts +9 -0
  171. package/dist/types/schema/src/index.d.ts +35 -0
  172. package/dist/types/{model → schema}/src/input.d.ts +3 -3
  173. package/dist/types/{model → schema}/src/integrity.d.ts +9 -8
  174. package/dist/types/schema/src/kinds.d.ts +26 -0
  175. package/dist/types/{model → schema}/src/labels/en.d.ts +93 -51
  176. package/dist/types/{model → schema}/src/labels/ja.d.ts +97 -52
  177. package/dist/types/schema/src/mediaUrl.d.ts +60 -0
  178. package/dist/types/{model → schema}/src/page.d.ts +6 -6
  179. package/dist/types/{model → schema}/src/problems.d.ts +95 -53
  180. package/dist/types/{model → schema}/src/refs.d.ts +1 -10
  181. package/dist/types/{model → schema}/src/rules.d.ts +2 -2
  182. package/dist/types/{model → schema}/src/schema.d.ts +25 -20
  183. package/dist/types/schema/src/selfOps.d.ts +31 -0
  184. package/dist/types/{model/src/capabilities.d.ts → schema/src/traits.d.ts} +6 -6
  185. package/dist/types/schema/src/typesSource.d.ts +16 -0
  186. package/dist/types/{model → schema}/src/values.d.ts +7 -4
  187. package/dist/types/schema/src/widening.d.ts +3 -0
  188. package/dist/types/sdk/src/analytics.d.ts +3 -2
  189. package/dist/types/sdk/src/app.d.ts +70 -16
  190. package/dist/types/sdk/src/astro-image.d.ts +19 -0
  191. package/dist/types/sdk/src/astro-response.d.ts +6 -0
  192. package/dist/types/sdk/src/astro-server.d.ts +16 -0
  193. package/dist/types/sdk/src/astro.d.ts +19 -0
  194. package/dist/types/sdk/src/bridge.d.ts +13 -15
  195. package/dist/types/sdk/src/code.d.ts +61 -0
  196. package/dist/types/sdk/src/delegation.d.ts +49 -0
  197. package/dist/types/sdk/src/delivery/changes.d.ts +4 -4
  198. package/dist/types/sdk/src/delivery/client.d.ts +40 -28
  199. package/dist/types/sdk/src/delivery/fields.d.ts +5 -5
  200. package/dist/types/sdk/src/delivery/index.d.ts +3 -3
  201. package/dist/types/sdk/src/delivery/media.d.ts +8 -11
  202. package/dist/types/sdk/src/delivery/query.d.ts +16 -12
  203. package/dist/types/sdk/src/delivery/schema.d.ts +5 -5
  204. package/dist/types/sdk/src/delivery/values.d.ts +16 -20
  205. package/dist/types/sdk/src/delivery.d.ts +3 -3
  206. package/dist/types/sdk/src/dev-operations.d.ts +20 -0
  207. package/dist/types/sdk/src/dev.d.ts +6 -5
  208. package/dist/types/sdk/src/end-users.d.ts +190 -0
  209. package/dist/types/sdk/src/i18n.d.ts +11 -11
  210. package/dist/types/sdk/src/integrations.d.ts +20 -27
  211. package/dist/types/sdk/src/operations.d.ts +17 -0
  212. package/dist/types/sdk/src/preview.d.ts +2 -1
  213. package/dist/types/sdk/src/rich-text.d.ts +2 -0
  214. package/dist/types/sdk/src/schema.d.ts +5 -21
  215. package/dist/types/sdk/src/site/artifact.d.ts +64 -0
  216. package/dist/types/sdk/src/site/build-file.d.ts +30 -0
  217. package/dist/types/sdk/src/site/check-code.d.ts +14 -0
  218. package/dist/types/sdk/src/site/check-text.d.ts +19 -0
  219. package/dist/types/sdk/src/site/cli.d.ts +52 -0
  220. package/dist/types/sdk/src/site/content-type.d.ts +2 -0
  221. package/dist/types/sdk/src/site/labels.d.ts +14 -0
  222. package/dist/types/sdk/src/site.d.ts +1 -1
  223. package/dist/types/sdk/src/types.d.ts +21 -0
  224. package/dist/{schema-BPHL7Qr-.js → types-DkO2N7u2.js} +9 -9
  225. package/dist/types.d.ts +1 -0
  226. package/dist/types.js +1 -0
  227. package/dist/typesSource-VJIxtN9b.js +136 -0
  228. package/dist/workflow-CUpl6hO_.js +148 -0
  229. package/package.json +42 -16
  230. package/dist/apps-9u4XMi7E.js +0 -114
  231. package/dist/body.d.ts +0 -1
  232. package/dist/bridge-DYAYGV7t.js +0 -74
  233. package/dist/customers.d.ts +0 -1
  234. package/dist/customers.js +0 -185
  235. package/dist/embed-R-OvDYAw.js +0 -90
  236. package/dist/model-pmXzGX12.js +0 -152
  237. package/dist/model.d.ts +0 -1
  238. package/dist/model.js +0 -345
  239. package/dist/schema-UQJWRyfJ.js +0 -995
  240. package/dist/src-sazhzYui.js +0 -71
  241. package/dist/types/analytics/src/index.d.ts +0 -5
  242. package/dist/types/analytics/src/schedule.d.ts +0 -2
  243. package/dist/types/analytics/src/shared.d.ts +0 -21
  244. package/dist/types/analytics/src/source.d.ts +0 -19
  245. package/dist/types/analytics/src/store.d.ts +0 -24
  246. package/dist/types/cms-contract/src/app.d.ts +0 -35
  247. package/dist/types/cms-contract/src/apps.d.ts +0 -195
  248. package/dist/types/cms-contract/src/authorize.d.ts +0 -146
  249. package/dist/types/cms-contract/src/customers.d.ts +0 -266
  250. package/dist/types/cms-contract/src/embeds.d.ts +0 -165
  251. package/dist/types/cms-contract/src/errors.d.ts +0 -105
  252. package/dist/types/cms-contract/src/identifiers.d.ts +0 -117
  253. package/dist/types/cms-contract/src/paths.d.ts +0 -23
  254. package/dist/types/cms-contract/src/urlLabel.d.ts +0 -13
  255. package/dist/types/cms-contract/src/webhooks.d.ts +0 -139
  256. package/dist/types/model/src/audience.d.ts +0 -38
  257. package/dist/types/model/src/brand.d.ts +0 -25
  258. package/dist/types/model/src/index.d.ts +0 -26
  259. package/dist/types/model/src/legacy.d.ts +0 -2
  260. package/dist/types/model/src/media.d.ts +0 -5
  261. package/dist/types/model/src/mediaUrl.d.ts +0 -67
  262. package/dist/types/model/src/selfOps.d.ts +0 -30
  263. package/dist/types/model/src/typesSource.d.ts +0 -8
  264. package/dist/types/platform/src/defaultModel.d.ts +0 -8
  265. package/dist/types/sdk/src/body.d.ts +0 -2
  266. package/dist/types/sdk/src/customers.d.ts +0 -190
  267. package/dist/types/sdk/src/model.d.ts +0 -5
  268. package/dist/typesSource-bO0jFw1I.js +0 -88
  269. /package/dist/types/{cms-contract → contract}/src/appProblems.d.ts +0 -0
  270. /package/dist/types/{analytics → contract}/src/day.d.ts +0 -0
  271. /package/dist/types/{cms-contract → contract}/src/functionLabels.d.ts +0 -0
  272. /package/dist/types/{cms-contract → contract}/src/permissionLabels.d.ts +0 -0
  273. /package/dist/types/{cms-contract → contract}/src/siteArtifact.d.ts +0 -0
  274. /package/dist/types/{cms-contract → contract}/src/views.d.ts +0 -0
  275. /package/dist/types/{cms-contract → contract}/src/webhookLabels.d.ts +0 -0
  276. /package/dist/types/{body → rich-text}/src/components.d.ts +0 -0
  277. /package/dist/types/{body → rich-text}/src/derive.d.ts +0 -0
  278. /package/dist/types/{body → rich-text}/src/description.d.ts +0 -0
  279. /package/dist/types/{body → rich-text}/src/href.d.ts +0 -0
  280. /package/dist/types/{body → rich-text}/src/inline.d.ts +0 -0
  281. /package/dist/types/{body → rich-text}/src/markdown.d.ts +0 -0
  282. /package/dist/types/{model → schema}/src/contact.d.ts +0 -0
  283. /package/dist/types/{model → schema}/src/json.d.ts +0 -0
  284. /package/dist/types/{model → schema}/src/screens.d.ts +0 -0
  285. /package/dist/types/{model → schema}/src/time.d.ts +0 -0
@@ -0,0 +1,34 @@
1
+ /** サーバーが受け持つパスの頭(API・画像・プレビュー・ログインの入り口) */
2
+ export declare const SERVER_PATHS: readonly ["/api", "/media", "/preview", "/auth"];
3
+ /** ヘルスチェックのパス(どのホストでもサーバー。運営者の経路は運営者のホストの全部のパスで、ワークスペースの Worker がホストで振り分ける) */
4
+ export declare const ADMIN_PATHS: readonly ["/healthz"];
5
+ /** MCP の認可の窓口の CMS の側(MCP の Worker が service binding でだけ呼ぶ。ワークスペースの Worker は転送しない) */
6
+ export declare const MCP_OAUTH_PATH = "/mcp/oauth";
7
+ /** 環境を選ぶパスの頭(/env/<live か環境の ID>/…)。省略は live。ワークスペース、API、配信 API で共通 */
8
+ export declare const ENV_PATH = "/env";
9
+ /** 環境を選ぶパスの分解(label は live か環境の ID、rest は残りのパス、prefix は除いた頭。環境の指定のないパスは null) */
10
+ export declare function envPathOf(pathname: string): Readonly<{
11
+ label: string;
12
+ rest: string;
13
+ prefix: string;
14
+ }> | null;
15
+ /**
16
+ * ワークスペースのパス(画面の経路、API、画像、プレビュー)に、開いた画面の URL(opened)の環境の頭を付ける(外の URL、// で始まる URL、/auth はそのまま)
17
+ * - 付け済みの頭は開いた画面の頭に置き換える(環境の切り替えはページの読み直しで、この関数からは別の環境へ出ない)
18
+ */
19
+ export declare function withEnvPrefix(path: string, opened: string): string;
20
+ /** サーバーが受け持つパスか(パスの頭と一致、または頭の下、運営者の経路を含む。環境を選ぶ頭の下は運営者の経路を除く) */
21
+ export declare const isServerPath: (pathname: string) => boolean;
22
+ /** プロジェクトの公開の API のホスト名(publicHost はカンマ区切りの先頭が正) */
23
+ export declare const publicApiHostOf: (publicHost: string, projectId: string) => string;
24
+ /** 公開の API のホスト名のプロジェクトの ID(公開の API のホストでなければ null。publicHost はカンマ区切り) */
25
+ export declare function projectOfPublicHost(hostname: string, publicHost: string | undefined): string | null;
26
+ /** 公開の API の基点のパス */
27
+ export declare const PUBLIC_API_BASE = "/v1";
28
+ /** 公開の API の環境を選ぶ段(/v1/environments/<環境の ID>/…、省略は本番) */
29
+ export declare const PUBLIC_ENV_SEGMENT = "/environments";
30
+ /** 公開の API のパスの分解(environment は環境の段の値で省略は null、path は環境の段を除いたパス。/v1 の外は null) */
31
+ export declare function publicApiPathOf(pathname: string): Readonly<{
32
+ environment: string | null;
33
+ path: string;
34
+ }> | null;
@@ -0,0 +1,6 @@
1
+ /** 承認待ちの値の接頭辞 */
2
+ export declare const PENDING_PREFIX = "req:";
3
+ /** 追加の依頼を記事に付ける値 */
4
+ export declare const pendingValue: (requestId: string) => string;
5
+ /** 記事の値のうち、承認待ちの依頼の ID */
6
+ export declare const pendingIds: (values: readonly string[]) => string[];
@@ -1,4 +1,4 @@
1
- import type { User } from './roles.js';
1
+ import { type Subject } from './principal.js';
2
2
  /** 操作 */
3
3
  export declare const ACTIONS: readonly ["read", "create", "update", "publish", "delete"];
4
4
  /** 操作 */
@@ -13,13 +13,14 @@ export declare const ACTION_LEVELS: Readonly<Record<Action, readonly Level[]>>;
13
13
  export type Permissions = Readonly<Record<string, Readonly<Partial<Record<Action, Level>>>>>;
14
14
  /** 表にない対象の既定のキー */
15
15
  export declare const ANY_TARGET = "*";
16
- type Holder = Pick<User, 'permissions'> & Partial<Pick<User, 'role' | 'operator' | 'app' | 'mcp'>>;
16
+ /** 権限の表の和(対象と操作ごとに、LEVELS の並びで先の段階。付与ごとのロールの実効の権限) */
17
+ export declare function permissionsUnion(tables: readonly Permissions[]): Permissions;
17
18
  /** 対象と操作の段階 */
18
- export declare const levelOf: (user: Holder, target: string, action: Action) => Level;
19
+ export declare const levelOf: (user: Subject, target: string, action: Action) => Level;
19
20
  /** 対象の操作に、どれかの段階(自分のものだけ、承認が必要を含む)で届くか(レコードを読む前の入口の判定、判定は authorizeReach) */
20
- export declare const reaches: (user: Holder, target: string, action: Action) => boolean;
21
+ export declare const reaches: (user: Subject, target: string, action: Action) => boolean;
21
22
  /** 操作できるか(owned は自分が持ち主の行か、承認が必要は不可。判定は判定の関数 authorize) */
22
- export declare const allows: (user: Holder, target: string, action: Action, owned?: boolean) => boolean;
23
+ export declare const allows: (user: Subject, target: string, action: Action, owned?: boolean) => boolean;
23
24
  /**
24
25
  * 非公開のコレクション(個人の情報を持つコレクション)の権限: 表にない操作に既定の '*' を当てない
25
26
  * - closed: すべての操作を不可にする(MCP からの要求、AI に個人の情報を渡さない)
@@ -32,9 +33,9 @@ export type RowAccess = Readonly<{
32
33
  published: boolean;
33
34
  }>;
34
35
  /** レコードを閲覧できるか */
35
- export declare const canReadRow: (user: Holder, target: string, row: RowAccess) => boolean;
36
+ export declare const canReadRow: (user: Subject, target: string, row: RowAccess) => boolean;
36
37
  /** レコードを変更・削除できるか(公開中のレコードは公開の権限も必要) */
37
- export declare const canChangeRow: (user: Holder, target: string, action: "update" | "delete", row: RowAccess) => boolean;
38
+ export declare const canChangeRow: (user: Subject, target: string, action: "update" | "delete", row: RowAccess) => boolean;
38
39
  /**
39
40
  * 権限の表の検査(不正な値は理由の文の配列)
40
41
  * - targets: 対象の id('*' は常に可)
@@ -49,15 +50,13 @@ export type AccountLink = Readonly<{
49
50
  collection: string | null;
50
51
  owners: Readonly<Record<string, string>>;
51
52
  }>;
52
- type Owner = Pick<User, 'id' | 'recordId' | 'link'>;
53
53
  /**
54
54
  * レコードの持ち主か
55
55
  * - 持ち主の項目がある対象: 項目の値に、アカウントが結び付くレコードを含む
56
56
  * - 結び付くコレクションのレコード: 結び付くレコードそのもの
57
57
  * - ほかの対象: 作成したアカウント(レコードの created_by、アカウントの ID)
58
58
  */
59
- export declare const ownsRow: (user: Owner, target: string, row: Readonly<Record<string, unknown>>) => boolean;
60
- type Subject = Pick<User, 'permissions' | 'id' | 'recordId' | 'link'>;
59
+ export declare const ownsRow: (user: Subject, target: string, row: Readonly<Record<string, unknown>>) => boolean;
61
60
  /** 権限の判定で使用するレコードの値(レコードのまま、持ち主の項目を含む) */
62
61
  export type ContentAccess = Readonly<Record<string, unknown>> & Readonly<{
63
62
  status: string;
@@ -74,4 +73,3 @@ export declare const canPublishContent: (user: Subject, target: string, a: Conte
74
73
  export declare const canSubmitContent: (user: Subject, target: string, a: ContentAccess) => boolean;
75
74
  /** レコードを削除できるか */
76
75
  export declare const canDeleteContent: (user: Subject, target: string, a: ContentAccess) => boolean;
77
- export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 配信 API の読む版の選択(クエリ)
3
+ * - perspective: published(既定、公開中の版)か latest(公開していない編集を含む最新の版)
4
+ * - revision: 1件の経路だけ、変更の履歴の ID の版
5
+ * - at: 指定の時刻(今以後)に公開中になる版(公開中に、その時刻までに当たる予約を重ねる)
6
+ * - published 以外は未公開の読み取りの権限(read_drafts)が要る
7
+ */
8
+ export declare const PERSPECTIVES: readonly ["published", "latest"];
9
+ export type PerspectiveName = (typeof PERSPECTIVES)[number];
10
+ /** 読む版の選択のクエリの名前 */
11
+ export declare const PERSPECTIVE_QUERY: {
12
+ readonly perspective: "perspective";
13
+ readonly revision: "revision";
14
+ readonly at: "at";
15
+ };
16
+ /** 管理の API と画面の読み取りのトークン(collections はコレクションの id、* はすべて。tail は末尾だけ) */
17
+ export type ReadToken = Readonly<{
18
+ id: string;
19
+ label: string;
20
+ collections: readonly string[];
21
+ tail: string;
22
+ expiresAt: string;
23
+ createdBy: string | null;
24
+ createdAt: string;
25
+ revokedAt: string | null;
26
+ }>;
@@ -0,0 +1,5 @@
1
+ import type { Capabilities, PrincipalContext } from './principal.js';
2
+ /** 主体の権限を超える能力(<対象>:<操作>。管理者は超えない。知らない操作は、管理者のほかは超えるとする) */
3
+ export declare function capabilitiesBeyond(principal: PrincipalContext, capabilities: Capabilities): string[];
4
+ /** 別名を含む鍵の操作のすべてが、判定の操作に展開できるか(操作を足したときの検査) */
5
+ export declare const unknownKeyOperations: () => string[];
@@ -0,0 +1,181 @@
1
+ import type { EndUserProof } from '../../schema/src/index.js';
2
+ import type { ActorKind, AuditVia } from './identifiers.js';
3
+ import type { Ceiling } from './grants.js';
4
+ import type { InfraId } from './ids.js';
5
+ import type { AccountLink, Permissions } from './permissions.js';
6
+ /** アカウントの種類(レジストリの accounts.kind) */
7
+ export declare const ACCOUNT_KINDS: readonly ["person", "agent", "app"];
8
+ /** アカウントの種類 */
9
+ export type AccountKind = (typeof ACCOUNT_KINDS)[number];
10
+ /** 鍵とアプリのアカウントの能力(対象から操作の配列) */
11
+ export type Capabilities = Readonly<Record<string, readonly string[]>>;
12
+ /** 人とエージェントのアカウント(recordId は結び付くレコード、link は結び付きの設定、support はサポートのアクセスの許可の ID) */
13
+ export type PersonAccount = Readonly<{
14
+ kind: Exclude<AccountKind, 'app'>;
15
+ id: string;
16
+ email: string;
17
+ role: string;
18
+ roleLabel: string;
19
+ recordId: string | null;
20
+ link: AccountLink;
21
+ support: string | null;
22
+ }>;
23
+ /** アプリのアカウント(インストール済みアプリと1対1) */
24
+ export type AppAccount = Readonly<{
25
+ kind: 'app';
26
+ installationId: InfraId<'installation'>;
27
+ }>;
28
+ /** インストール済みアプリに属さない資格(API キー、読み取りのトークン、プレビューのチケット。id は資格の ID) */
29
+ export type CredentialAccount = Readonly<{
30
+ kind: 'credential';
31
+ id: string;
32
+ }>;
33
+ /** 処理ごとに宣言した主体(id は処理の名前) */
34
+ export type ProcessAccount = Readonly<{
35
+ kind: 'process';
36
+ id: string;
37
+ }>;
38
+ /** 主体のアカウント */
39
+ export type PrincipalAccount = PersonAccount | AppAccount | CredentialAccount | ProcessAccount;
40
+ /** 委任の付与(ロール、ロールの権限の表、その付与と親の付与の上限) */
41
+ export type DelegatedGrant = Readonly<{
42
+ role: string;
43
+ permissions: Permissions;
44
+ ceilings: readonly Ceiling[];
45
+ }>;
46
+ /** ロールの表の実効の権限(permissions と admin は直接の付与だけ。delegated は委任の付与で、委任を認める操作の判定だけが使う) */
47
+ export type RoleEffective = Readonly<{
48
+ form: 'roles';
49
+ permissions: Permissions;
50
+ admin: boolean;
51
+ delegated: readonly DelegatedGrant[];
52
+ }>;
53
+ /** 能力の実効の権限 */
54
+ export type CapabilityEffective = Readonly<{
55
+ form: 'capabilities';
56
+ capabilities: Capabilities;
57
+ }>;
58
+ /** アプリのアカウントの資格の代理(consented は同意の記録の能力で * を残した形、項目の見える範囲の判定でコレクションの名指しを見る。withheld は閲覧を外した対象) */
59
+ export type AppDelegation = Readonly<{
60
+ kind: 'app';
61
+ client: string;
62
+ installationId: InfraId<'installation'>;
63
+ capabilities: Capabilities;
64
+ consented: Capabilities;
65
+ withheld: readonly string[];
66
+ }>;
67
+ /** MCP の接続の代理(rolePermissions は範囲で絞る前のロールの表、staffCollections は MCP にスタッフの項目を出すコレクション) */
68
+ export type McpDelegation = Readonly<{
69
+ kind: 'mcp_client';
70
+ grant: string;
71
+ client: string;
72
+ capabilities: Capabilities;
73
+ rolePermissions: Permissions;
74
+ staffCollections: readonly string[];
75
+ }>;
76
+ /** アカウントの代理(委ねた能力でロールの表を狭める) */
77
+ export type AccountDelegation = AppDelegation | McpDelegation;
78
+ /** エンドユーザーの代理(endUserId は本人の ID、proof は本人の確認の方法。名前と形は tunasand#812) */
79
+ export type EndUserPrincipal = Readonly<{
80
+ kind: 'on_behalf_of_end_user';
81
+ capabilities: Capabilities;
82
+ endUserId: string;
83
+ proof: EndUserProof;
84
+ }>;
85
+ declare class Seal {
86
+ #private;
87
+ }
88
+ /** 人とエージェントの主体の形 */
89
+ export type PersonShape = Readonly<{
90
+ account: PersonAccount;
91
+ effective: RoleEffective;
92
+ chain: readonly [] | readonly [AccountDelegation];
93
+ via: AuditVia;
94
+ }>;
95
+ /** 能力を持つ主体の形 */
96
+ export type CapabilityShape = Readonly<{
97
+ account: AppAccount | CredentialAccount | ProcessAccount;
98
+ effective: CapabilityEffective;
99
+ chain: readonly [] | readonly [EndUserPrincipal];
100
+ via: AuditVia | null;
101
+ }>;
102
+ /** 人とエージェントの主体の文脈 */
103
+ export type PersonPrincipal = Seal & PersonShape;
104
+ /** 能力の主体の文脈(インストール済みアプリ、資格、処理) */
105
+ export type CapabilityPrincipal = Seal & CapabilityShape;
106
+ /** アプリのアカウントの主体の文脈 */
107
+ export type AppPrincipal = CapabilityPrincipal & Readonly<{
108
+ account: AppAccount;
109
+ }>;
110
+ /** 処理の主体の文脈 */
111
+ export type ProcessPrincipal = CapabilityPrincipal & Readonly<{
112
+ account: ProcessAccount;
113
+ chain: readonly [];
114
+ via: null;
115
+ }>;
116
+ /** エンドユーザーの代理の主体の文脈 */
117
+ export type EndUserContext = CapabilityPrincipal & Readonly<{
118
+ chain: readonly [EndUserPrincipal];
119
+ }>;
120
+ /** 主体の文脈(ロールの表を持つのは人とエージェント、ほかは能力を持つ) */
121
+ export type PrincipalContext = PersonPrincipal | CapabilityPrincipal;
122
+ /** 封じる前の主体の形(判定の関数の内側とカーネルの principal だけが使う) */
123
+ export type PrincipalShape = PersonShape | CapabilityShape;
124
+ /** 判定で主体を絞る種類(操作の記録の主体の種類の値。installation は資格とアプリのアカウントの操作) */
125
+ export type ActingKind = Extract<ActorKind, 'account' | 'installation' | 'on_behalf_of_account' | 'on_behalf_of_end_user' | 'system'>;
126
+ /** 判定で主体を絞る種類(エンドユーザーの操作の選べる主体と、判定の観測) */
127
+ export declare const actingKindOf: (principal: PrincipalShape) => ActingKind;
128
+ /** 主体の文脈のアカウントの代理(なければ null) */
129
+ export declare const accountDelegationOf: (principal: PrincipalShape) => AccountDelegation | null;
130
+ /** 主体の文脈のアプリの代理(なければ null) */
131
+ export declare const appDelegationOf: (principal: PrincipalShape) => AppDelegation | null;
132
+ /** 主体の文脈の MCP の接続の代理(なければ null) */
133
+ export declare const mcpDelegationOf: (principal: PrincipalShape) => McpDelegation | null;
134
+ /** 主体の文脈のエンドユーザーの代理(なければ null) */
135
+ export declare const endUserOf: (principal: PrincipalShape) => EndUserPrincipal | null;
136
+ /** 人とエージェントのアカウント(ほかの主体は null) */
137
+ /** 人の主体か(ロールの権限の表を持つ主体) */
138
+ export declare const isPersonPrincipal: (principal: PrincipalContext) => principal is PersonPrincipal;
139
+ export declare const personOf: (principal: PrincipalShape) => PersonAccount | null;
140
+ /** 主体のインストール済みアプリ(アプリのアカウントと、アプリの代理。なければ null) */
141
+ export declare const installationOf: (principal: PrincipalShape) => InfraId<"installation"> | null;
142
+ /** 主体の ID(本人の代理は本人、ほかはアカウント) */
143
+ export declare const principalIdOf: (principal: PrincipalShape) => string;
144
+ /** 持ち主の判定に使うアカウントの値(結び付くレコードを持つのは人とエージェントだけ) */
145
+ export declare const ownerOf: (subject: PrincipalShape | AccountView) => Readonly<{
146
+ id: string;
147
+ recordId: string | null;
148
+ link: AccountLink;
149
+ }>;
150
+ /** 画面が持つアカウントの値(/api/me の形。表示の判定だけに使い、サーバーの判定の主体にしない) */
151
+ export type AccountView = Readonly<{
152
+ id?: string;
153
+ permissions?: Permissions;
154
+ role?: string;
155
+ recordId?: string | null;
156
+ link?: AccountLink;
157
+ operator?: true;
158
+ app?: Readonly<{
159
+ client?: string;
160
+ installation: InfraId<'installation'>;
161
+ capabilities: Capabilities;
162
+ consented?: Capabilities;
163
+ withheld?: readonly string[];
164
+ }>;
165
+ mcp?: Readonly<{
166
+ grant?: string;
167
+ client?: string;
168
+ capabilities: Capabilities;
169
+ rolePermissions?: Permissions;
170
+ staffCollections: readonly string[];
171
+ }>;
172
+ }>;
173
+ /** 判定の主体(サーバーは封じた主体の文脈、画面はアカウントの値) */
174
+ export type Subject = PrincipalContext | AccountView;
175
+ /** 判定の主体の形(画面の値は代理を含めて同じ形にする) */
176
+ export declare function shapeOf(subject: Subject): PrincipalShape;
177
+ /** 主体のロールの ID(人とエージェントでなければ空の文字) */
178
+ export declare const roleOf: (principal: PrincipalShape) => string;
179
+ /** 主体のメールアドレス(人とエージェントでなければ空の文字) */
180
+ export declare const emailOf: (principal: PrincipalShape) => string;
181
+ export {};
@@ -2,14 +2,14 @@ import { type ParamValue } from '../../i18n/src/index.js';
2
2
  import type { ImportProblem } from './import.js';
3
3
  export declare const PROBLEM_MESSAGES: Readonly<Record<string, string>>;
4
4
  export declare const PROBLEM_MESSAGES_EN: Readonly<Record<string, string>>;
5
- /** 既定の形を日本語の文に(問題でない文はそのまま、差し込みの中の問題も文に。extra はモジュールとアプリの表) */
5
+ /** 既定の形を日本語の文に(問題でない文はそのまま、差し込みの中の問題も文に。extra はアプリの表) */
6
6
  export declare const problemLabel: (text: string, extra?: Readonly<Record<string, string>>) => string;
7
- /** 既定の形を英語の文に(問題でない文はそのまま。extra はモジュールとアプリの英語の表) */
7
+ /** 既定の形を英語の文に(問題でない文はそのまま。extra はアプリの英語の表) */
8
8
  export declare const problemEnglish: (text: string, extra?: Readonly<Record<string, string>>) => string;
9
9
  /**
10
10
  * コードと差し込みを持つ結果の画面の文(issues、スキーマの変更、取り込みの問題)
11
11
  * - コードが表にあり差し込みがそろえば表の文、ほかは message(既定の形なら表の文)
12
- * - extra: モジュールとアプリの表(コードは `<id>_` で始まり、コアの表と重ならない)
12
+ * - extra: アプリの表(コードは `<id>_` で始まり、コアの表と重ならない)
13
13
  */
14
14
  export declare function issueLabel(issue: Readonly<{
15
15
  message: string;
@@ -21,7 +21,7 @@ export declare const importProblemLabel: (p: Pick<ImportProblem, "message" | "pr
21
21
  /** 取り込みの問題の種類の名前(ImportProblem の code) */
22
22
  export declare const importKindLabel: (code: ImportProblem["code"]) => string;
23
23
  type Table = Readonly<Record<string, string>>;
24
- /** モジュールとアプリの文言の表の誤り(問題のコードの接頭辞 `<id>_`、コアの問題の表との重なり、英語の表のキーの過不足) */
24
+ /** アプリの文言の表の誤り(問題のコードの接頭辞 `<id>_`(id の `-` は `_`)、コアの問題の表との重なり、英語の表のキーの過不足) */
25
25
  export declare function labelTableProblems(tables: Readonly<{
26
26
  id: string;
27
27
  targets?: Table;
@@ -0,0 +1,6 @@
1
+ import type { OrganizationRole } from './authorize.js';
2
+ /**
3
+ * プロジェクトの中のロール(組織の owner はプロジェクトの管理者を継ぎ、プロジェクトの側で下げられない。member はプロジェクトのアカウントのロールだけ)
4
+ * - メンバーの表に owner をコピーせず、入口(console の一覧と引き継ぎと同意、CMS のログイン)がこの関数で決める。なしは入れない
5
+ */
6
+ export declare const projectRoleOf: (organizationRole: OrganizationRole | null, accountRole: string | null) => string | null;
@@ -0,0 +1,6 @@
1
+ export declare const RECORD_LABELS: {
2
+ readonly transitionNotAllowed: (from: string | null, to: string) => string;
3
+ readonly uniqueTaken: (labels: readonly string[]) => string;
4
+ readonly uniqueDuplicates: (collection: string, labels: readonly string[], count: number) => string;
5
+ readonly useAt: (collection: string, labels: readonly string[]) => string;
6
+ };
@@ -1,4 +1,5 @@
1
- import type { Capabilities } from './authorize.js';
1
+ import { type Capabilities, type Subject } from './principal.js';
2
+ import type { InfraId } from './ids.js';
2
3
  import { type AccountLink, type Permissions } from './permissions.js';
3
4
  /** 管理者のロールの ID */
4
5
  export declare const ADMIN_ROLE = "admin";
@@ -20,7 +21,7 @@ export type Role = Readonly<{
20
21
  }>;
21
22
  /**
22
23
  * ログイン中のアカウント
23
- * - id: アカウントの ID(操作の履歴・版の作成者・担当者などに保存する値、メールアドレスは表 accounts だけ)
24
+ * - id: アカウントの ID(操作の履歴・版の作成者・担当者などに保存する値、メールアドレスは表 memberships だけ)
24
25
  * - role: ロールの ID、recordId: 結び付くレコード(なしは null)、link: 結び付きの設定
25
26
  * - operator: 運営者のサポートのアクセスの許可で入った運営者(操作の履歴の主体は運営者)
26
27
  * - app: アプリのアカウントの資格(client はクライアントの ID、installation はインストールの ID)
@@ -32,15 +33,14 @@ export type Role = Readonly<{
32
33
  export type User = Readonly<{
33
34
  id: string;
34
35
  email: string;
35
- role: string;
36
36
  roleLabel: string;
37
- permissions: Permissions;
37
+ can: Readonly<Record<string, boolean>>;
38
38
  recordId: string | null;
39
39
  link: AccountLink;
40
40
  operator?: true;
41
41
  app?: Readonly<{
42
42
  client: string;
43
- installation: string;
43
+ installation: InfraId<'installation'>;
44
44
  capabilities: Capabilities;
45
45
  consented?: Capabilities;
46
46
  withheld?: readonly string[];
@@ -53,5 +53,9 @@ export type User = Readonly<{
53
53
  staffCollections: readonly string[];
54
54
  }>;
55
55
  }>;
56
+ /** 管理の領域 admin だけを条件にする操作の ID(/api/me の can でこの操作を見て、管理の領域を扱えるかを決める) */
57
+ export declare const ADMIN_AREA_OPERATION = "job.run";
58
+ /** ロールの表示の確認で、確かめるロールの ID を送るヘッダー(画面のログインの GET だけ。主体をそのロールの権限の表に替える) */
59
+ export declare const VIEW_AS_HEADER = "tunasand-view-as";
56
60
  /** 設定を扱える(管理者のロールの)アカウントか */
57
- export declare const isAdmin: (user: Pick<User, "role" | "app" | "mcp">) => boolean;
61
+ export declare const isAdmin: (subject: Subject) => boolean;
@@ -0,0 +1,16 @@
1
+ export declare const CORE_RULE_LABELS: {
2
+ readonly requiredFields: "提出で必須の項目";
3
+ readonly citedSources: "注の参考資料";
4
+ readonly imageAlt: "画像の代替テキスト";
5
+ readonly pendingMasters: "承認待ちのマスタ";
6
+ readonly pageFields: "ページの公開で必須の項目";
7
+ };
8
+ export declare const FILE_SYNTAX_EXAMPLE = "file/<\u753B\u50CF\u306E ID>";
9
+ export declare const PREVIEW_LABELS: {
10
+ readonly noTicketKey: "プレビューのチケットの鍵(SECRETS_KEY)が未設定";
11
+ readonly ogFailed: (status: number) => string;
12
+ readonly noOg: "OG 画像のないコレクション";
13
+ readonly noPage: "サイトのページがないコレクション";
14
+ readonly noTarget: "プレビューするコレクションと ID の指定がない";
15
+ readonly renderFailed: (status: number) => string;
16
+ };
@@ -0,0 +1,16 @@
1
+ export declare const RULE_PROBLEMS: {
2
+ readonly referenceMissing: (field: string, id: string) => string;
3
+ readonly referenceAfterCreate: (field: string) => string;
4
+ readonly referenceUnmatched: (field: string, id: string) => string;
5
+ readonly pendingMasters: (labels: readonly string[]) => string;
6
+ readonly uncitedSources: (collection: string, count: number) => string;
7
+ readonly imagesWithoutAlt: (count: number) => string;
8
+ readonly pageFieldRequired: (field: string) => string;
9
+ readonly referencedPageFields: (target: string, fields: readonly string[]) => string;
10
+ readonly fixedValue: (target: string, collection: string, field: string, option: string) => string;
11
+ readonly blockProps: (index: number, problem: string) => string;
12
+ readonly richTextFieldMissing: (collection: string, field: string) => string;
13
+ };
14
+ export declare const RULE_ISSUES: {
15
+ readonly dateTime: string;
16
+ };
@@ -0,0 +1,8 @@
1
+ export declare const SCHEMA_LABELS: {
2
+ readonly firstNote: "最初のバージョン(コードの定義)";
3
+ readonly deleteCollection: (label: string) => string;
4
+ readonly restoreCollection: (label: string) => string;
5
+ readonly appCollections: (label: string) => string;
6
+ readonly appData: (label: string) => string;
7
+ readonly promoted: (environmentLabel: string) => string;
8
+ };
@@ -1,8 +1,8 @@
1
1
  import { type ParamValue } from '../../i18n/src/index.js';
2
- /** モジュールの設定値の問題のコード */
3
- export declare const SETTING_PROBLEMS: readonly ["text", "integer_min", "boolean", "text_list", "choice", "duplicate", "required", "shape"];
2
+ /** アプリの設定値の問題のコード */
3
+ export declare const SETTING_PROBLEMS: readonly ["text", "integer_min", "integer_max", "boolean", "text_list", "choice", "duplicate", "required", "shape"];
4
4
  export type SettingProblemCode = (typeof SETTING_PROBLEMS)[number];
5
- /** モジュールの設定値の問題(key は設定値のキー、params は文に差し込む値) */
5
+ /** アプリの設定値の問題(key は設定値のキー、params は文に差し込む値) */
6
6
  export declare class SettingProblem extends Error {
7
7
  readonly key: string;
8
8
  readonly problem: SettingProblemCode;
@@ -1,19 +1,17 @@
1
- import type { User } from './roles.js';
1
+ import type { Subject } from './principal.js';
2
2
  /**
3
3
  * 設定の領域
4
- * - general: 一般、content: コレクション・メニュー・画像サイズ、extensions: 拡張機能
5
- * - integrations: 連携・プレビューとデプロイ、data: インポート・エクスポート、customers: 顧客の設定
4
+ * - general: 一般、content: コレクション・メニュー・画像サイズ、apps: インストール済みアプリと標準の機能
5
+ * - integrations: 連携・プレビューとデプロイ、data: インポート・エクスポート、endUsers: エンドユーザーの設定
6
6
  */
7
- export declare const SETTINGS_AREAS: readonly ["general", "content", "extensions", "integrations", "data", "customers"];
7
+ export declare const SETTINGS_AREAS: readonly ["general", "content", "apps", "integrations", "data", "end_users"];
8
8
  /** 設定の領域 */
9
9
  export type SettingsArea = (typeof SETTINGS_AREAS)[number];
10
10
  /** 権限の表での設定の領域の id */
11
11
  export declare const settingsTarget: (area: SettingsArea) => string;
12
12
  /** 権限の表の対象が設定の領域か */
13
13
  export declare const isSettingsTarget: (id: string) => boolean;
14
- type Holder = Pick<User, 'role' | 'permissions'> & Partial<Pick<User, 'mcp' | 'operator' | 'app'>>;
15
14
  /** 設定の領域を扱えるか(判定は authorize。管理者は可、ほかは対象の更新が可のときだけ、人の代わりとアプリは不可) */
16
- export declare const canManageSettings: (user: Holder, area: SettingsArea) => boolean;
15
+ export declare const canManageSettings: (user: Subject, area: SettingsArea) => boolean;
17
16
  /** 扱える設定の領域(空は設定の層を開けない) */
18
- export declare const managedAreasOf: (user: Holder) => readonly SettingsArea[];
19
- export {};
17
+ export declare const managedAreasOf: (user: Subject) => readonly SettingsArea[];
@@ -0,0 +1,3 @@
1
+ import type { SettingsArea } from './settings.js';
2
+ /** 設定の領域の表示名 */
3
+ export declare const SETTINGS_AREA_LABELS: Readonly<Record<SettingsArea, string>>;
@@ -1,5 +1,5 @@
1
- /** サイトの資源の種類(D1 と R2) */
2
- export declare const SITE_RESOURCE_KINDS: readonly ["d1", "r2"];
1
+ /** サイトの資源の種類(SQL のデータベースとオブジェクトの保存先) */
2
+ export declare const SITE_RESOURCE_KINDS: readonly ["database", "storage"];
3
3
  export type SiteResourceKind = (typeof SITE_RESOURCE_KINDS)[number];
4
4
  /** 宣言の上限(資源の数、Cron の式の数と1つの式の文字数) */
5
5
  export declare const SITE_DECLARATION_LIMITS: {
@@ -7,7 +7,7 @@ export declare const SITE_DECLARATION_LIMITS: {
7
7
  readonly crons: 5;
8
8
  readonly cronLength: 64;
9
9
  };
10
- /** bind の名前の形と長さ(R2 のバケットの名前の63文字に、接頭辞と持ち主のハッシュと合わせて収まる長さ) */
10
+ /** bind の名前の形と長さ(保存先の名前の上限の63文字に、接頭辞と持ち主のハッシュと合わせて収まる長さ) */
11
11
  export declare const SITE_BINDING_NAME: {
12
12
  readonly pattern: RegExp;
13
13
  readonly maxLength: 32;
@@ -16,14 +16,14 @@ export declare const SITE_BINDING_NAME: {
16
16
  export declare const SITE_ASSETS_BINDING: "ASSETS";
17
17
  /** 能力の要素の頭 */
18
18
  export declare const SITE_CAPABILITY_PREFIXES: {
19
- readonly d1: "site_d1:";
20
- readonly r2: "site_r2:";
19
+ readonly database: "site_database:";
20
+ readonly storage: "site_storage:";
21
21
  readonly cron: "site_cron:";
22
22
  };
23
23
  /** マニフェストの `hosting` の宣言の形(`true` は資源も Cron もない宣言) */
24
24
  export type SiteHostingManifest = Readonly<{
25
- d1?: readonly string[];
26
- r2?: readonly string[];
25
+ database?: readonly string[];
26
+ storage?: readonly string[];
27
27
  crons?: readonly string[];
28
28
  }>;
29
29
  /** 資源の宣言の1つ */
@@ -0,0 +1,76 @@
1
+ /** 索引の形のバージョン */
2
+ export declare const SITE_INDEX_VERSION = 1;
3
+ /** 中立の実行環境の版(固有の互換の設定は、アダプターが版から決める) */
4
+ export declare const SITE_RUNTIMES: readonly ["web-1"];
5
+ export type SiteRuntime = (typeof SITE_RUNTIMES)[number];
6
+ export declare const SITE_MODULE_TYPES: readonly ["js", "wasm", "text", "data"];
7
+ /** 失敗の応答に使う静的ファイルを置ける状態コード */
8
+ export declare const SITE_ERROR_STATUSES: readonly ["404", "500"];
9
+ export type SiteErrorStatus = (typeof SITE_ERROR_STATUSES)[number];
10
+ /** 上限(大きさはバイト。modules と codeBytes は、カーネルの束の上限と同じ値) */
11
+ export declare const SITE_INDEX_MAX: {
12
+ readonly indexBytes: number;
13
+ readonly modules: 1000;
14
+ readonly codeBytes: number;
15
+ readonly files: 20000;
16
+ readonly fileBytes: number;
17
+ readonly filesBytes: number;
18
+ readonly pathLength: 1024;
19
+ readonly contentTypeLength: 128;
20
+ };
21
+ /** コードの1つのファイル */
22
+ export type SiteModule = Readonly<{
23
+ path: string;
24
+ type: (typeof SITE_MODULE_TYPES)[number];
25
+ sha256: string;
26
+ bytes: number;
27
+ }>;
28
+ /** 静的ファイル(path は返す URL のパスそのもの。immutable は内容が変わらないもの) */
29
+ export type SiteFile = Readonly<{
30
+ path: string;
31
+ sha256: string;
32
+ bytes: number;
33
+ content_type: string;
34
+ immutable: boolean;
35
+ }>;
36
+ export type SiteIndex = Readonly<{
37
+ version: typeof SITE_INDEX_VERSION;
38
+ runtime: SiteRuntime;
39
+ entry: string;
40
+ modules: readonly SiteModule[];
41
+ files: readonly SiteFile[];
42
+ errors: Readonly<Partial<Record<SiteErrorStatus, string>>>;
43
+ manifest_version: number;
44
+ }>;
45
+ /** 索引の誤り(at は索引の中の場所) */
46
+ export type SiteIndexProblem = 'index_too_large' | 'not_json' | 'not_canonical' | 'invalid_shape' | 'unknown_version' | 'unknown_runtime' | 'invalid_path' | 'duplicate_path' | 'invalid_sha256' | 'invalid_bytes' | 'conflicting_content' | 'invalid_type' | 'too_many_modules' | 'code_too_large' | 'too_many_files' | 'file_too_large' | 'files_too_large' | 'missing_entry' | 'missing_error_file' | 'invalid_manifest_version';
47
+ export type SiteIndexResult = Readonly<{
48
+ ok: true;
49
+ index: SiteIndex;
50
+ } | {
51
+ ok: false;
52
+ problem: SiteIndexProblem;
53
+ at: string;
54
+ }>;
55
+ /** コードのパスか */
56
+ export declare const isSiteModulePath: (path: string) => boolean;
57
+ /** 復号した静的ファイルのパスを、索引に書く形にする(正しくなければ null) */
58
+ export declare function siteFilePathOf(decoded: string): string | null;
59
+ /** 要求の URL のパスを、索引と比べる形にする(復号した文字で比べる。対応するものがなければ null) */
60
+ export declare function siteRequestPathOf(pathname: string): string | null;
61
+ /** キーと、パスを持つものの順によらない、索引の正規形 */
62
+ export declare function siteIndexJson({ version, runtime, entry, modules, files, errors, manifest_version }: SiteIndex): string;
63
+ /** バイトの SHA-256(16進) */
64
+ export declare function sha256Hex(bytes: Uint8Array): Promise<string>;
65
+ /** 成果物のハッシュ(索引の正規形の SHA-256) */
66
+ export declare const siteDigestOf: (index: SiteIndex) => Promise<string>;
67
+ /** 索引の値を確かめる(パスの順に並べて返す) */
68
+ export declare const checkSiteIndex: (value: unknown) => SiteIndexResult;
69
+ /** 受けた索引のバイトを確かめる(正規形のバイトと1つでも違えば拒む) */
70
+ export declare const parseSiteIndex: (bytes: Uint8Array) => SiteIndexResult;
71
+ /** 束の中のコードの範囲(索引の順に隙間なくつなぐ) */
72
+ export type SiteCodeRange = SiteModule & Readonly<{
73
+ start: number;
74
+ }>;
75
+ /** 索引から、束の中の範囲を作る */
76
+ export declare function siteCodeRanges({ modules }: Pick<SiteIndex, 'modules'>): readonly SiteCodeRange[];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * スラッグの予約語(プロジェクトとチャネルのスラッグに当てる、1か所の定数)
3
+ * - 製品と会社の名前、Tunasand のホスト名と経路の名前、インフラの名前、運用の名前、デプロイの後の確認のラベル
4
+ */
5
+ export declare const RESERVED_SLUGS: readonly ["tunasand", "ryusenkei", "www", "api", "mcp", "console", "admin", "docs", "status", "app", "apps", "auth", "login", "mail", "cms", "media", "files", "cdn", "edge", "fallback", "static", "sites", "preview", "help", "support", "blog", "news", "ops", "security", "abuse", "postmaster", "hostmaster", "webmaster", "root", "tunasand-deploy-check"];
6
+ export declare const isReservedSlug: (slug: string) => boolean;