@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
@@ -1,5 +1,5 @@
1
- import { type Collection, type FieldDef } from './model.js';
2
- /** 配信する項目(本人とスタッフの項目と顧客フィールドを除く、まとまりの中も) */
1
+ import { type Collection, type FieldDef } from './collection.js';
2
+ /** 配信する項目(本人とスタッフの項目とエンドユーザーへの参照のフィールドを除く、まとまりの中も) */
3
3
  export declare const deliveredFields: (collection: Pick<Collection, "private" | "fields">) => FieldDef[];
4
4
  /** 空の値(複数の値は空の配列、まとまりは項目ごとに空の値、ほかは null) */
5
5
  export declare const emptyValues: (fields: readonly FieldDef[]) => Record<string, unknown>;
@@ -8,13 +8,16 @@ export declare const emptyValues: (fields: readonly FieldDef[]) => Record<string
8
8
  * - 定義の項目だけを残し、文字は前後の空白を除いて空は null
9
9
  * - 省略: 複数の値は空の配列、まとまりは項目ごとに空の値
10
10
  * - 複数の値の null: そのまま(空の配列と未定を区別する導入先のため)
11
- * - 項目を定義しないまとまり: 値をそのまま(形は拡張機能が保存前に検査、例: データセットのグラフ)
11
+ * - 項目を定義しないまとまり: 値をそのまま(形はアプリが保存前に検査、例: データセットのグラフ)
12
12
  */
13
13
  export declare function pickValues(fields: readonly FieldDef[], input: unknown): Record<string, unknown>;
14
- /** 値の中で参照している ID(to のコレクションへの参照だけ、まとまりの中も含む、labels は外側のまとまりから参照の項目までの表示名) */
14
+ /** 値の中で参照している ID(to のコレクションへの参照だけ、まとまりの中も含む、labels は外側のまとまりから参照の項目までの表示名、field は参照の項目の定義) */
15
15
  export declare function referencedIds(fields: readonly FieldDef[], values: unknown, to: string): {
16
16
  labels: string[];
17
17
  id: string;
18
+ field: Extract<FieldDef, {
19
+ type: 'reference';
20
+ }>;
18
21
  }[];
19
22
  /** コレクションの参照の項目(to を指定すると、そのコレクションへの参照だけ) */
20
23
  export declare const referencesOf: (collection: Collection, to?: string) => Extract<FieldDef, {
@@ -0,0 +1,3 @@
1
+ import type { SchemaChange } from './changes.js';
2
+ /** 範囲を広げる変更か */
3
+ export declare function isWidening({ kind, path, params, readded }: SchemaChange): boolean;
@@ -1,2 +1,3 @@
1
- export { VIEW_COLUMNS, VIEW_SCHEMA, viewOf } from '../../analytics/src/index.js';
2
- export type { Classify, ViewEvent, ViewOptions } from '../../analytics/src/index.js';
1
+ export { VIEW_COLUMNS, viewOf } from '../../contract/src/index.js';
2
+ export { VIEW_SCHEMA } from '../../adapter-cloudflare/src/eventLog/viewSchema.js';
3
+ export type { Classify, ViewEvent, ViewOptions } from '../../contract/src/index.js';
@@ -1,20 +1,74 @@
1
- import type { ErrorCode, ErrorParams, Issue, IssueInput } from '../../cms-contract/src/errors.js';
2
- export { defineAppServer } from '../../cms-contract/src/app.js';
3
- export { type AppProblem, appProblems } from '../../cms-contract/src/appProblems.js';
4
- export type { AppContext, AppServer, AppRoute, AppRouteMethod, AppRoutePolicy, CmsClient } from '../../cms-contract/src/app.js';
5
- export type { ErrorBody, ErrorCode, ErrorParams, Issue, IssueInput, IssueSeverity } from '../../cms-contract/src/errors.js';
6
- export { JSON_BODY_MAX } from '../../cms-contract/src/errors.js';
7
- export { IMPORT_ITEMS_MAX, importIdOf, importItemOfRow, cyclicCollections, ORIGIN_REF, CUSTOMER_REF } from '../../cms-contract/src/import.js';
8
- export { CUSTOMER_STATUSES } from '../../cms-contract/src/customers.js';
9
- export type { ImportItem, ImportItemReport, ImportProblem, ImportReport, ImportRowLine, SourceContentResult, SourceDropped, SourceDroppedRow, SourceLinesResult, SourceNote, SourceVerifyResult } from '../../cms-contract/src/import.js';
10
- export type { ReadbackReport } from '../../cms-contract/src/migration.js';
11
- export { bodyFromHtml } from '../../body/src/index.js';
12
- export type { Body, BodyProfile, Dropped } from '../../body/src/index.js';
13
- export { AUDIENCES, isPublishable } from '../../model/src/index.js';
14
- export type { Audience, ContentModel, Collection, FieldDef } from '../../model/src/index.js';
1
+ import type { AppContext } from '../../contract/src/app.js';
2
+ import type { AppPortFailure, AppPortResult } from '../../contract/src/appServer.js';
3
+ import type { User } from '../../contract/src/roles.js';
4
+ import type { ErrorCode, ErrorParams, Issue, IssueInput } from '../../contract/src/errors.js';
5
+ import { newUuidV7 } from '../../contract/src/ids.js';
6
+ export { newUuidV7 };
7
+ import type { z } from 'zod';
8
+ export { egressAllows } from '../../contract/src/app.js';
9
+ export { appAssertion, type AppSigningKey, bearerClient, type DelegationExchange, type DelegationExchangeResult, exchangeDelegation, exchangeSessionToken, type SessionTokenExchange } from './delegation.js';
10
+ export { type AppProblem, appProblems } from '../../contract/src/appProblems.js';
11
+ export type { AggregateExtent, AggregateRange, AggregateRebuild, AggregateRollup, AggregateValues, AppChannelConsent, AppConnections, AppEndUserIdentity, AppEndUserIssuer, AppEndUsersPort, AppEventsPort, AppFilesPort, AppDeliveryContext, AppDeliveryRoute, AppJob, AppNoticeKind, AppNotifyPort, AppNotifyRequest, AppNotifyResult, AppRecord, AppRecordCondition, AppRecordQuery, AppRecordsPort, AppRow, AppMessageProvider, AppMessagesPort, AppSavedContext, AppScope, AppSecretsPort, AppServer, AppServerContext, AppServerParts, AppCollectionTarget, AppStatePort, DailyViews, ResolvedSlugs, VisibleRecords, CollectionRule, Problem, RecordRuleContext, Rule, RuleStage, SaveCheck, SaveCheckContext, SaveCheckResult, AppPageRequest, AppRecordPage, AppPortErrorCode, AppPortFailure, AppPortResult } from '../../contract/src/appServer.js';
12
+ export type { AppContext, AppRoute, AppRouteArea, AppRouteMethod, AppRoutePolicy, CmsClient } from '../../contract/src/app.js';
13
+ export { cmsListAll } from '../../contract/src/app.js';
14
+ export type { ErrorBody, ErrorCode, ErrorParams, Issue, IssueInput, IssueSeverity } from '../../contract/src/errors.js';
15
+ export { JSON_BODY_MAX } from '../../contract/src/errors.js';
16
+ export { type AppNotice, type AppNotices, NOTICES_PORT } from '../../contract/src/notices.js';
17
+ export { BUNDLED_APP_IDS } from '../../contract/src/appDependencies.js';
18
+ export { aggregateJobIdOf, APP_FILE_LIMITS, APP_NOTICE_KINDS, APP_NOTIFY_LIMITS, APP_USAGE_ERRORS, APP_STATE_LIMITS, allRecordPages } from '../../contract/src/appServer.js';
19
+ export { type AppDefinition, type AppSettings, NO_SETTINGS } from '../../contract/src/appDefinition.js';
20
+ export type { AppManifest, AppUi, AppUiIcon } from '../../contract/src/apps.js';
21
+ export { appToolPrefixOf } from '../../contract/src/apps.js';
22
+ export { type AppManifestDocument, type AppManifestText, manifestDocumentOf } from '../../contract/src/manifestText.js';
23
+ export type { AppOutbound, AppOutboundAuth, AppOutboundMethod } from '../../contract/src/outbound.js';
24
+ export type { AppHmacCheck, AppHmacHash, AppSecretDeclaration, AppSecretState, AppSignatureEncoding } from '../../contract/src/appSecrets.js';
25
+ export type { AppIdentityDeclaration } from '../../contract/src/appIdentities.js';
26
+ export type { AppInboundDeclaration, AppInboundRequest } from '../../contract/src/appInbound.js';
27
+ export { APP_CHANNEL_KIND_LIMITS, APP_CHANNEL_LIMITS, CHANNEL_ADDRESS_KINDS, CHANNEL_CAPABILITIES } from '../../contract/src/appChannels.js';
28
+ export type { AppChannel, AppChannelInput, AppChannelKind, AppChannelsPort, ChannelAddress, ChannelAddressKind, ChannelCapability } from '../../contract/src/appChannels.js';
29
+ export { APP_MAIL_SKIP_REASONS, MAIL_CAPABILITIES } from '../../contract/src/appMail.js';
30
+ export type { AppInboundMail, AppMailDeclaration, AppMailDomain, AppMailPort, AppMailSendRequest, AppMailSendResult, AppMailSkipReason, MailAuthentication, MailAuthResult } from '../../contract/src/appMail.js';
31
+ export { MESSAGE_LIMITS, MESSAGE_PORT, MESSAGE_RECEIVED, MESSAGE_SKIP_REASONS } from '../../contract/src/messagePort.js';
32
+ export type { MessageProblem, MessageProviderResult, MessageReceived, MessageAddress, MessageReceivedInput, MessageRecipient, MessageSender, MessageSendRequest, MessageSendResult, MessageSkipReason, PortMessage, ReceivedItem } from '../../contract/src/messagePort.js';
33
+ export { SettingProblem, settingProblemText } from '../../contract/src/settingProblems.js';
34
+ export { ADMIN_AREA_OPERATION } from '../../contract/src/roles.js';
35
+ export { calendarFieldSource, type CalendarField, type CalendarItem } from '../../contract/src/workspaceItems.js';
36
+ export { workspaceRecordPath } from '../../contract/src/workspacePaths.js';
37
+ export { isLiveState, type RecordRow, recordStateOf } from '../../contract/src/workflow.js';
38
+ export type { CallApi, McpApp, McpParts, McpProjectContext, McpPrompt, McpTool } from '../../contract/src/appDefinition.js';
39
+ export type { User };
40
+ export { IMPORT_ITEMS_MAX, importIdOf, importItemOfRow, cyclicCollections, ORIGIN_REF, END_USER_REF } from '../../contract/src/import.js';
41
+ export { END_USER_STATUSES, END_USERS_KEY_TARGET } from '../../contract/src/endUsers.js';
42
+ export type { ImportItem, ImportItemReport, ImportProblem, ImportReport, ImportRowLine, SourceContentResult, SourceDropped, SourceDroppedRow, SourceLinesResult, SourceNote, SourceVerifyResult } from '../../contract/src/import.js';
43
+ export type { ReadbackReport } from '../../contract/src/migration.js';
44
+ export { richTextFromHtml } from '../../rich-text/src/index.js';
45
+ export type { Body, RichTextProfile, Dropped } from '../../rich-text/src/index.js';
46
+ export { AUDIENCES, isPublishable } from '../../schema/src/index.js';
47
+ export type { Audience, CollectionSchema, Collection, FieldDef } from '../../schema/src/index.js';
15
48
  /** 検査の結果の形にそろえる(code の既定は invalid、severity の既定は error) */
16
49
  export declare const appIssue: (i: IssueInput) => Issue;
17
50
  /** エラーの応答(CMS の API と同じ形、相関の ID は要求の x-request-id。extra は issues などの足し) */
18
- export declare function appFailure(request: Request, code: Exclude<ErrorCode, 'network_error'>, params?: ErrorParams, extra?: Readonly<{
51
+ export declare const appFailure: (request: Request, code: Exclude<ErrorCode, "network_error">, params?: ErrorParams, extra?: Readonly<{
19
52
  issues?: readonly Issue[];
20
- }> & Readonly<Record<string, unknown>>): Response;
53
+ }> & Readonly<Record<string, unknown>>) => Response;
54
+ /** エラーの応答を作る関数(targets はアプリの対象の英語の名前、キーは対象の id。message の対象の名前に使う) */
55
+ export declare function appFailureOf(targets: Readonly<Record<string, string>>): (request: Request, code: Exclude<ErrorCode, "network_error">, params?: ErrorParams, extra?: Readonly<{
56
+ issues?: readonly Issue[];
57
+ }> & Readonly<Record<string, unknown>>) => Response;
58
+ /** アプリの口の拒否の応答(CMS の API と同じ problem+json。状態はコードから) */
59
+ export declare const appPortResponse: (request: Request, failure: AppPortFailure) => Response;
60
+ /** 値のない成功の結果 */
61
+ export declare const PORT_DONE: AppPortResult<void>;
62
+ /**
63
+ * 結果の値(拒否は app_port_refused: <コード> の Error で投げる)
64
+ * - 拒否を想定しない処理(定期の処理が自分のコレクションを読むなど)だけで使う。利用者の操作の拒否は appPortResponse で返す
65
+ */
66
+ export declare function portValue<T>(result: AppPortResult<T>): T;
67
+ /** 本文の JSON(空の本文は empty、壊れた JSON は400の応答) */
68
+ export declare function appJson(request: Request, empty?: unknown): Promise<unknown>;
69
+ /** 入力の誤りの応答(zod の問題を CMS の API と同じ issues の形に。problems はアプリの英語の問題の文、キーは問題のコード) */
70
+ export declare function appInvalid(request: Request, error: z.ZodError, problems?: Readonly<Record<string, string>>): Response;
71
+ /** 呼んだ人がコレクションに行える操作の ID(管理の API の /api/schema の viewer_can。record.list、record.create など、失敗は例外) */
72
+ export declare function appCollectionCan(ctx: Pick<AppContext, 'cms'>, collection: string): Promise<readonly string[]>;
73
+ /** 呼んだ人のアカウント(管理の API の /api/me、can は操作の ID ごとの可否。失敗は例外) */
74
+ export declare function appUser(ctx: Pick<AppContext, 'cms'>): Promise<User>;
@@ -0,0 +1,19 @@
1
+ type Imported = Readonly<{
2
+ src: string;
3
+ width: number;
4
+ height: number;
5
+ format: string;
6
+ }>;
7
+ type Options = Readonly<{
8
+ src: string | Imported;
9
+ width?: number;
10
+ height?: number;
11
+ [key: string]: unknown;
12
+ }>;
13
+ declare const service: {
14
+ getURL: ({ src }: Options) => string;
15
+ getHTMLAttributes: (options: Options) => Record<string, unknown>;
16
+ };
17
+ export default service;
18
+ /** 画像の変換の経路(持たない) */
19
+ export declare const GET: () => Response;
@@ -0,0 +1,6 @@
1
+ /** 終わりまで受ける本文の上限(これを超えるものは流したまま) */
2
+ export declare const BUFFERED_MAX: number;
3
+ /** 保存を許す応答か(s-maxage の明示があり、保存を拒む指定と Set-Cookie がない、200の応答) */
4
+ export declare function isStorable(method: string, { status, headers }: Response): boolean;
5
+ /** 長さを宣言した応答 */
6
+ export declare function withLength(method: string, response: Response, max?: number): Promise<Response>;
@@ -0,0 +1,16 @@
1
+ import { type CodeHandler, type CodeHandlers } from './code.js';
2
+ /** Astro の描画のうち、入口が使う部分 */
3
+ export type AstroApp = Readonly<{
4
+ match: (request: Request, allowPrerendered?: boolean) => unknown;
5
+ render: (request: Request, options: Readonly<{
6
+ routeData?: never;
7
+ prerenderedErrorPageFetch: (url: string) => Promise<Response>;
8
+ }>) => Promise<Response>;
9
+ setCookieHeaders: (response: Response) => Iterable<string>;
10
+ }>;
11
+ /** サイトが登録する、要求のほかの種類の処理 */
12
+ export type SiteHandlers = Partial<Pick<CodeHandlers, 'event' | 'check' | 'schedule'>>;
13
+ /** 配信する静的ファイルの操作の名前 */
14
+ export declare const STATIC_FILE_OPERATION = "files.static";
15
+ /** 入口 */
16
+ export declare function siteCode(app: AstroApp, handlers?: SiteHandlers): CodeHandler;
@@ -0,0 +1,19 @@
1
+ import type { AstroIntegration } from 'astro';
2
+ import type { CodeOperations } from './code.js';
3
+ import { type Reviewed } from './site/build-file.js';
4
+ export type TunasandOptions = Readonly<{
5
+ /** 要求のほかの種類の処理を export するモジュール(event、check、schedule。サイトのルートからのパス) */
6
+ handlers?: string;
7
+ /** 開発サーバーの操作(sdk/dev の fixtureOperations など)。ビルドには入らない */
8
+ operations?: CodeOperations;
9
+ /** 成果物に含めてはいけないオリジン(公開の段階で変わるもの。成果物には入らない) */
10
+ origins?: readonly string[];
11
+ /** 要求の間に通らないことを確かめた、ライブラリの式 */
12
+ reviewed?: readonly Reviewed[];
13
+ }>;
14
+ /** 事前に描画したページのファイルと、その URL のパス */
15
+ export declare function prerenderedPages(files: readonly string[], pathnames: readonly string[]): Record<string, string>;
16
+ /** ビルドした PC のパス(利用者の名前を含む)を、固定の名前に替える */
17
+ export declare const withoutLocalPaths: (code: string, root: string) => string;
18
+ /** Tunasand のアダプター */
19
+ export default function tunasand({ handlers, operations, origins, reviewed }?: TunasandOptions): AstroIntegration;
@@ -1,6 +1,6 @@
1
- import { type BridgeApiMethod, type BridgeContext, type BridgeDialogSize, type BridgeError, type BridgeEventName, type BridgeEvents, type BridgeResults, type BridgeTarget, type BridgeToastTone } from '../../cms-contract/src/bridge.js';
2
- export { BRIDGE_API_METHODS, BRIDGE_ERRORS, BRIDGE_NAMESPACE, BRIDGE_THEME_TOKENS, BRIDGE_THEME_VAR_PREFIX, BRIDGE_VERSION } from '../../cms-contract/src/bridge.js';
3
- export type { BridgeApiMethod, BridgeContext, BridgeDialogSize, BridgeError, BridgeEventName, BridgeEvents, BridgeRequestKind, BridgeRequests, BridgeResults, BridgeTarget, BridgeTheme, BridgeThemeToken, BridgeToastTone } from '../../cms-contract/src/bridge.js';
1
+ import { type BridgeApiMethod, type BridgeContext, type BridgeDialogSize, type BridgeError, type BridgeEventName, type BridgeEvents, type BridgeTarget, type BridgeToastTone } from '../../contract/src/bridge.js';
2
+ export { BRIDGE_API_METHODS, BRIDGE_ERRORS, BRIDGE_NAMESPACE, BRIDGE_THEME_TOKENS, BRIDGE_THEME_VAR_PREFIX, BRIDGE_VERSION } from '../../contract/src/bridge.js';
3
+ export type { BridgeApiMethod, BridgeContext, BridgeDialogSize, BridgeError, BridgeEventName, BridgeEvents, BridgeRequestKind, BridgeRequests, BridgeResults, BridgeTarget, BridgeTheme, BridgeThemeToken, BridgeToastTone } from '../../contract/src/bridge.js';
4
4
  /** 依頼の失敗(code は理由) */
5
5
  export declare class BridgeRequestError extends Error {
6
6
  readonly code: BridgeError;
@@ -21,7 +21,7 @@ export type BridgeWindow = Readonly<{
21
21
  }>;
22
22
  /** 握手の設定 */
23
23
  export type BridgeOptions = Readonly<{
24
- /** 受ける管理画面のオリジン(省くと window.parent ならどのオリジンでも受ける) */
24
+ /** 受けるワークスペースのオリジン(省くと window.parent ならどのオリジンでも受ける) */
25
25
  expectedOrigins?: readonly string[];
26
26
  /** 握手の待ち時間(ミリ秒、既定は10秒) */
27
27
  timeoutMs?: number;
@@ -30,30 +30,28 @@ export type BridgeOptions = Readonly<{
30
30
  /** テストで差し替える window */
31
31
  window?: BridgeWindow;
32
32
  }>;
33
- /** 管理画面との橋渡し */
33
+ /** ワークスペースとの橋渡し */
34
34
  export type Bridge = Readonly<{
35
35
  /** 今の文脈(取り直しと見た目とパスの知らせで更新) */
36
36
  readonly context: BridgeContext;
37
- /** 管理画面のオリジン */
37
+ /** ワークスペースのオリジン */
38
38
  hostOrigin: string;
39
39
  /** 知らせの受け手(戻り値で解除) */
40
40
  on: <E extends BridgeEventName>(name: E, listener: (data: BridgeEvents[E]) => void) => () => void;
41
- /** 管理画面の中の遷移 */
41
+ /** ワークスペースの中の遷移 */
42
42
  navigate: (to: BridgeTarget) => Promise<void>;
43
- /** メニューのページの中の遷移を管理画面の URL に写す(先頭の / なしのパス、クエリは可) */
43
+ /** メニューのページの中の遷移をワークスペースの URL に写す(先頭の / なしのパス、クエリは可) */
44
44
  history: (path: string) => Promise<void>;
45
- /** 知らせ(管理画面のトースト、頭にアプリ名、回数の上限あり) */
45
+ /** 知らせ(ワークスペースのトースト、頭にアプリ名、回数の上限あり) */
46
46
  toast: (text: string, tone?: BridgeToastTone) => Promise<void>;
47
- /** 確認のダイアログ(管理画面が描く) */
47
+ /** 確認のダイアログ(ワークスペースが描く) */
48
48
  confirm: (message: string, options?: Readonly<{
49
49
  destructive?: boolean;
50
50
  }>) => Promise<boolean>;
51
- /** 外のページを新しいタブで開く(管理画面が行き先を出して確認する) */
51
+ /** 外のページを新しいタブで開く(ワークスペースが行き先を出して確認する) */
52
52
  open: (url: string) => Promise<boolean>;
53
53
  /** 編集中のレコードの値の変更(パネルだけ、反映した項目の key を返す) */
54
54
  setValues: (values: Readonly<Record<string, unknown>>) => Promise<readonly string[]>;
55
- /** 署名つきの文脈の取り直し */
56
- refreshContext: () => Promise<BridgeResults['refreshContext']>;
57
55
  /** 同じ登録の画面をダイアログで開き、閉じたときの値を返す(人が閉じたら null、ダイアログの中からは開けない) */
58
56
  openDialog: (options?: Readonly<{
59
57
  path?: string;
@@ -62,7 +60,7 @@ export type Bridge = Readonly<{
62
60
  }>) => Promise<unknown>;
63
61
  /** ダイアログを閉じて開いた側へ値を返す(ダイアログの中だけ、開いた側の値は context.dialog.data) */
64
62
  closeDialog: (result?: unknown) => Promise<void>;
65
- /** 顧客の ID(100件まで)の表示名。見ている人の権限とアプリの能力(`@customers` の `read_display_name`)が許す分だけ返り、許されなければ空 */
63
+ /** エンドユーザーの ID(100件まで)の表示名。見ている人の権限とアプリの能力(`@end_users` の `read_display_name`)が許す分だけ返り、許されなければ空 */
66
64
  displayNames: (ids: readonly string[]) => Promise<Readonly<Record<string, string>>>;
67
65
  /**
68
66
  * 画面のトークン(見ている人とアプリを示す1分の JWT)。アプリのサーバーへの要求ごとに取り、`Authorization: Bearer` に付ける
@@ -88,5 +86,5 @@ export type Bridge = Readonly<{
88
86
  /** 接続を閉じる */
89
87
  close: () => void;
90
88
  }>;
91
- /** 管理画面とつなぐ(iframe の外、時間切れは BridgeConnectError) */
89
+ /** ワークスペースとつなぐ(iframe の外、時間切れは BridgeConnectError) */
92
90
  export declare function connectBridge(options?: BridgeOptions): Promise<Bridge>;
@@ -0,0 +1,61 @@
1
+ import type { IssueInput } from '../../contract/src/errors.js';
2
+ export type CodeRequest = Readonly<{
3
+ trigger: 'request';
4
+ request: Request;
5
+ }>;
6
+ /** イベント(id は届け直しでも変わらない。data は JSON の値) */
7
+ export type CodeEvent = Readonly<{
8
+ trigger: 'event';
9
+ name: string;
10
+ id: string;
11
+ occurredAt: string;
12
+ data: unknown;
13
+ }>;
14
+ /** 保存と公開の前の検査(input は JSON の値) */
15
+ export type CodeCheck = Readonly<{
16
+ trigger: 'check';
17
+ name: string;
18
+ input: unknown;
19
+ }>;
20
+ export type CodeSchedule = Readonly<{
21
+ trigger: 'schedule';
22
+ name: string;
23
+ scheduledAt: string;
24
+ }>;
25
+ /** コードの1回の呼び出し */
26
+ export type CodeCall = CodeRequest | CodeEvent | CodeCheck | CodeSchedule;
27
+ /** 検査の答え(values は補正する値だけ。補正がなければ null) */
28
+ export type CodeChecked = Readonly<{
29
+ issues: readonly IssueInput[];
30
+ values: Readonly<Record<string, unknown>> | null;
31
+ }>;
32
+ /** イベントと定期の処理の成否 */
33
+ export type CodeDone = Readonly<{
34
+ ok: boolean;
35
+ }>;
36
+ /** 渡された操作 */
37
+ export type CodeOperations = Readonly<{
38
+ /** 同意した操作を呼ぶ(入力と結果は JSON の値。業務の失敗は結果の JSON、口の失敗だけが codeErrorOf で読める例外) */
39
+ call: (name: string, input?: unknown) => Promise<unknown>;
40
+ /** 同意したバイトの操作を呼ぶ(状態、ヘッダー、バイト。口の失敗は call と同じ) */
41
+ open: (name: string, input?: unknown) => Promise<Response>;
42
+ /** 宣言した宛先へ送る */
43
+ fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
44
+ /** プロジェクトのログに書く(本文、URL の秘密値、個人情報を書かない) */
45
+ log: (level: 'info' | 'warn' | 'error', message: string) => Promise<void>;
46
+ }>;
47
+ /** 種類ごとの処理。受けない種類は null と書く(その種類の呼び出しは失敗になる) */
48
+ export type CodeHandlers = Readonly<{
49
+ request: ((call: CodeRequest, operations: CodeOperations) => Response | Promise<Response>) | null;
50
+ event: ((call: CodeEvent, operations: CodeOperations) => CodeDone | Promise<CodeDone>) | null;
51
+ check: ((call: CodeCheck, operations: CodeOperations) => CodeChecked | Promise<CodeChecked>) | null;
52
+ schedule: ((call: CodeSchedule, operations: CodeOperations) => CodeDone | Promise<CodeDone>) | null;
53
+ }>;
54
+ /** コードの入口 */
55
+ export type CodeHandler = (call: CodeCall, operations: CodeOperations) => Promise<Response | CodeDone | CodeChecked>;
56
+ /** 操作の失敗 */
57
+ export type CodeError = 'closed' | 'revoked' | 'limit' | 'denied' | 'unknown_operation' | 'invalid_input' | 'failed';
58
+ /** コードを宣言する。モジュールの既定の export にする */
59
+ export declare const defineCode: (handlers: CodeHandlers) => CodeHandler;
60
+ /** 操作の例外の種類(操作の例外でなければ null) */
61
+ export declare function codeErrorOf(error: unknown): CodeError | null;
@@ -0,0 +1,49 @@
1
+ /** 交換の秘密鍵(ES256 か ML-DSA-44 の JWK の秘密鍵、kid は登録した公開鍵の kid) */
2
+ export type AppSigningKey = Readonly<{
3
+ jwk: JsonWebKey & {
4
+ kid?: string;
5
+ };
6
+ }>;
7
+ /** アプリの JWT(iss はアプリの ID、aud は配信の基点) */
8
+ export declare function appAssertion(key: AppSigningKey, claims: Readonly<{
9
+ appId: string;
10
+ audience: string;
11
+ }>, nowMs?: number): Promise<string>;
12
+ /** 交換の入力(base は環境の CMS の URL、delegation は人から受け取った代理の委任の主張、fetch は管理 API への運び手) */
13
+ export type DelegationExchange = Readonly<{
14
+ base: string;
15
+ appId: string;
16
+ key: AppSigningKey;
17
+ delegation: string;
18
+ fetch?: (request: Request) => Promise<Response>;
19
+ }>;
20
+ /** 画面のトークンの交換の入力(sessionToken はアプリの画面から受け取った画面のトークン) */
21
+ export type SessionTokenExchange = Readonly<{
22
+ base: string;
23
+ appId: string;
24
+ key: AppSigningKey;
25
+ sessionToken: string;
26
+ fetch?: (request: Request) => Promise<Response>;
27
+ }>;
28
+ /** 交換の結果(error は OAuth の error の値か、応答が形に合わない upstream) */
29
+ export type DelegationExchangeResult = Readonly<{
30
+ ok: true;
31
+ token: string;
32
+ expiresIn: number;
33
+ }> | Readonly<{
34
+ ok: false;
35
+ error: string;
36
+ status: number;
37
+ }>;
38
+ /** 代理の委任の主張をアカウントの資格のトークンに替える */
39
+ export declare const exchangeDelegation: (input: DelegationExchange) => Promise<DelegationExchangeResult>;
40
+ /** 画面のトークンをアカウントの資格のトークンに替える(結果の形は exchangeDelegation と同じ) */
41
+ export declare const exchangeSessionToken: (input: SessionTokenExchange) => Promise<DelegationExchangeResult>;
42
+ /** アカウントの資格のトークンで管理 API を呼ぶクライアント(path は /api の下、base は環境の CMS の URL) */
43
+ export declare const bearerClient: (input: Readonly<{
44
+ base: string;
45
+ token: string;
46
+ fetch?: (request: Request) => Promise<Response>;
47
+ }>) => {
48
+ fetch: (path: `/api/${string}`, init?: RequestInit) => Promise<Response>;
49
+ };
@@ -14,12 +14,12 @@ export type Change = Readonly<{
14
14
  }>;
15
15
  /** 変更の一覧の1ページ */
16
16
  export type ChangesPage = Readonly<{
17
- changes: readonly Change[];
18
- next: string;
19
- more: boolean;
17
+ data: readonly Change[];
18
+ next_cursor: string;
19
+ has_more: boolean;
20
20
  }>;
21
21
  /**
22
- * since から more がなくなるまで読み、ページごとに apply を呼ぶ(戻り値は次回の since)
22
+ * since から has_more がなくなるまで読み、ページごとに apply を呼ぶ(戻り値は次回の since)
23
23
  * - apply が成功してから次のページへ進む(失敗したら例外で止まり、保存済みの since から再開できる)
24
24
  * - 410(保存の期間を過ぎた cursor): DeliveryError、since を null にして全件から取り直す
25
25
  */
@@ -1,10 +1,14 @@
1
- import type { Collection } from '../../../model/src/index.js';
2
- import { type ListQuery, type Page } from './query.js';
1
+ import type { Collection } from '../../../schema/src/index.js';
2
+ import { type ListQuery, type Page, type QueryParams } from './query.js';
3
3
  import type { ChangesPage } from './changes.js';
4
- /** 配信 API のパスの前半 */
5
- export declare const DELIVERY_PATH = "/content/v1";
6
- /** 配信 API への接続(path は /content/v1 から始まるパスとクエリ) */
4
+ import { type PerspectiveName } from '../../../contract/src/perspective.js';
5
+ /**
6
+ * 公開の API への接続(path は公開の API の基点からのパスとクエリ、例: /collections/post/records?limit=10)
7
+ * - 基点: https://<プロジェクトの ID>--api.tunasand.app/v1、本番以外の環境は /v1/environments/<環境の ID>。接続の側が基点を前に付ける
8
+ */
7
9
  export type Delivery = (path: string, init?: RequestInit) => Promise<Response>;
10
+ /** コレクションのレコードの経路(id なしは一覧) */
11
+ export declare const recordsPath: (collection: string, id?: string) => string;
8
12
  /** 一式の経路ごとの結果(body は経路の応答の JSON) */
9
13
  export type BundleResult = Readonly<{
10
14
  status: number;
@@ -13,7 +17,7 @@ export type BundleResult = Readonly<{
13
17
  /**
14
18
  * 一式の取得の結果
15
19
  * - notModified: ETag が一致、etag: 応答の ETag、stale: 失敗のため最後に成功した値
16
- * - partial: 一部の経路が 5xx の一式 x-partial(最後に成功した値や描画の結果として保存しない)
20
+ * - partial: 一部の経路が 5xx の一式 tunasand-partial(最後に成功した値や描画の結果として保存しない)
17
21
  */
18
22
  export type Prefetched = Readonly<{
19
23
  notModified: boolean;
@@ -32,7 +36,7 @@ type Issue = Readonly<{
32
36
  /**
33
37
  * 配信 API の取得の失敗
34
38
  * - call: 失敗した経路、status: 応答のステータス
35
- * - code・params・issues・requestId: エラーの本文({ code, message, params?, issues?, requestId })の値
39
+ * - code・params・issues・requestId: エラーの本文(problem+json の code、params、issues、request_id)の値
36
40
  * 本文が JSON でなければ undefined
37
41
  */
38
42
  export declare class DeliveryError extends Error {
@@ -45,39 +49,47 @@ export declare class DeliveryError extends Error {
45
49
  constructor(call: string, status: number, body: string);
46
50
  }
47
51
  /** 配信 API の中のパスとクエリ(一式の path と結果のキー) */
48
- export declare const subPath: (path: string, params?: Readonly<Record<string, string>>) => string;
52
+ export declare const subPath: (path: string, params?: QueryParams) => string;
49
53
  /**
50
54
  * 配信 API の読み取り
51
- * - drafts: 下書き・予約なども含める(プレビュー用、署名は接続の側で付与)
52
- * - at: 公開の基準の日時(なしは今)
55
+ * - perspective: 読む版(latest は公開していない編集を含む最新の版、なしは公開中)
56
+ * - at: 指定の時刻(今以後、その時刻に公開中になる版)
53
57
  */
54
- export declare function createDeliveryClient(delivery: Delivery, { drafts, at }?: {
55
- drafts?: boolean;
58
+ export declare function createDeliveryClient(delivery: Delivery, { perspective, at }?: {
59
+ perspective?: PerspectiveName;
56
60
  at?: string;
57
61
  }): {
58
- find: <T>(path: string, params?: Readonly<Record<string, string>>) => Promise<T | undefined>;
59
- get: <T>(path: string, params?: Readonly<Record<string, string>>) => Promise<T>;
62
+ find: <T>(path: string, params?: QueryParams) => Promise<T | undefined>;
63
+ get: <T>(path: string, params?: QueryParams) => Promise<T>;
60
64
  page: <I = Readonly<Record<string, unknown>>, T extends Collection = Readonly<{
61
65
  id: string;
62
66
  slug: string;
63
67
  label: string;
64
68
  description?: string;
65
- format?: import("../../../model/src/model.js").ContentFormat;
66
- publishing?: import("../../../model/src/model.js").Publishing;
67
- fields: readonly import("../model.js").FieldDef[];
68
- pages?: readonly import("../model.js").PageDef[];
69
- counts?: readonly import("../../../model/src/model.js").CountDef[];
69
+ format?: import("../../../schema/src/collection.js").ContentFormat;
70
+ publication?: boolean;
71
+ fields: readonly import("../schema.js").FieldDef[];
72
+ pages?: readonly import("../schema.js").PageDef[];
73
+ counts?: readonly import("../../../schema/src/collection.js").CountDef[];
70
74
  og?: string;
71
- slugMode?: import("../../../model/src/model.js").SlugMode;
72
- roles?: import("../../../model/src/model.js").FieldRoles;
73
- grant?: string;
75
+ slug_mode?: import("../../../schema/src/collection.js").SlugMode;
76
+ roles?: import("../../../schema/src/collection.js").FieldRoles;
77
+ entitlement?: string;
74
78
  private?: boolean;
75
- unique?: readonly import("../../../model/src/integrity.js").UniqueDef[];
76
- selfOps?: readonly import("../../../model/src/model.js").SelfOp[];
77
- retentionDays?: number;
78
- }>>(path: string, query: ListQuery<T> & Readonly<{
79
- limit: number;
80
- }>) => Promise<Page<I>>;
79
+ unique?: readonly import("../../../schema/src/integrity.js").UniqueDef[];
80
+ self_ops?: readonly import("../../../schema/src/collection.js").SelfOp[];
81
+ form?: import("../../../schema/src/forms.js").FormDef;
82
+ retention_days?: number;
83
+ kind?: import("../../../schema/src/kinds.js").DeclaredCollectionKind;
84
+ time?: string;
85
+ dimensions?: readonly string[];
86
+ subject?: string;
87
+ source?: string;
88
+ bucket?: import("../../../schema/src/kinds.js").AggregateBucket;
89
+ measures?: readonly import("../../../schema/src/kinds.js").AggregateMeasure[];
90
+ publish_checks?: readonly string[];
91
+ trash?: boolean;
92
+ }>>(path: string, query?: ListQuery<T>) => Promise<Page<I>>;
81
93
  prefetch: (paths: readonly string[], { ifNoneMatch }?: {
82
94
  ifNoneMatch?: string;
83
95
  }) => Promise<Prefetched>;
@@ -1,5 +1,5 @@
1
- import type { ContentModel, Collection, FieldDef } from '../../../model/src/index.js';
2
- import type { GrantedField, FieldsOf, FieldValue, ItemMeta, ItemOf, UndeliveredField } from './values.js';
1
+ import type { CollectionSchema, Collection, FieldDef } from '../../../schema/src/index.js';
2
+ import type { EntitledField, FieldsOf, FieldValue, ItemMeta, ItemOf, UndeliveredField } from './values.js';
3
3
  type PublicField<T extends Collection> = Exclude<FieldsOf<T>, UndeliveredField>;
4
4
  type KeyOf<T extends Collection> = PublicField<T>['key'];
5
5
  type RefField<T extends Collection> = Extract<PublicField<T>, {
@@ -12,7 +12,7 @@ type Head<P> = P extends `${infer K}.${string}` ? K : P;
12
12
  /** 参照の項目 K の展開の指定(`K.sub` の sub) */
13
13
  type SubOf<P, K extends string> = P extends `${K}.${infer S}` ? S : never;
14
14
  /** 参照先のコレクション(M がなければ汎用のコレクション) */
15
- type TargetOf<F extends FieldDef, M> = M extends ContentModel ? (F extends {
15
+ type TargetOf<F extends FieldDef, M> = M extends CollectionSchema ? (F extends {
16
16
  to: infer To;
17
17
  } ? Extract<M['collections'][number], {
18
18
  id: To;
@@ -41,8 +41,8 @@ export type Selected<T extends Collection, P extends string, M = never> = Readon
41
41
  } : '*' extends P ? {
42
42
  _meta: ItemMeta;
43
43
  } : unknown) & {
44
- [F in Exclude<PublicField<T>, GrantedField> as F['key'] extends Head<P> ? F['key'] : '*' extends P ? F['key'] : never]: SelectedValue<F, P, M>;
44
+ [F in Exclude<PublicField<T>, EntitledField> as F['key'] extends Head<P> ? F['key'] : '*' extends P ? F['key'] : never]: SelectedValue<F, P, M>;
45
45
  } & {
46
- [F in Extract<PublicField<T>, GrantedField> as F['key'] extends Head<P> ? F['key'] : '*' extends P ? F['key'] : never]?: SelectedValue<F, P, M>;
46
+ [F in Extract<PublicField<T>, EntitledField> as F['key'] extends Head<P> ? F['key'] : '*' extends P ? F['key'] : never]?: SelectedValue<F, P, M>;
47
47
  }>;
48
48
  export {};
@@ -1,9 +1,9 @@
1
1
  export { cachedDelivery, memoryDeliveryCache, type DeliveryCache } from './cache.js';
2
2
  export { readChanges, type Change, type ChangesPage } from './changes.js';
3
- export { createDeliveryClient, DELIVERY_PATH, DeliveryError, subPath, type BundleResult, type Delivery, type DeliveryClient, type Prefetched } from './client.js';
3
+ export { createDeliveryClient, DeliveryError, recordsPath, subPath, type BundleResult, type Delivery, type DeliveryClient, type Prefetched } from './client.js';
4
4
  export { deliveredImageUrl, mediaOf, mediaUrlOf, type ImageUrl, type MediaOf, type MediaUrlInput } from './media.js';
5
- export { imageParamsOf, parseMediaPath, signMediaUrl, withImageParams, type DeliveredAsset, type ImageParams, type MediaPath } from '../../../model/src/index.js';
5
+ export { imageParamsOf, parseMediaPath, SIGNATURE_MAX_TTL_SEC, signMediaUrl, withImageParams, type SignatureScope, type DeliveredFile, type ImageParams, type MediaPath } from '../../../schema/src/index.js';
6
6
  export type { FieldPath, Selected } from './fields.js';
7
- export { listParams, type ListFilter, type ListQuery, type Page } from './query.js';
7
+ export { listParams, type ListFilter, type ListQuery, type Page, type QueryParams } from './query.js';
8
8
  export { createDeliveryClock, fieldOf, limitOf, optionLabels, pagePath, type DeliveryClock } from './schema.js';
9
9
  export type { FieldValue, Item, ItemMeta, ItemOf, RecordRef } from './values.js';
@@ -1,27 +1,24 @@
1
- import { type CropRect, type Media } from '../../../model/src/index.js';
2
- /** 実体の配信の URL の材料(project はプロジェクトの ID、id は実体の ID で、どちらも UUID のまま渡す。width・height は画像の元の画素) */
1
+ import { type CropRect, type Media } from '../../../schema/src/index.js';
2
+ /** 実体の配信の URL の材料(project はプロジェクトの ID(base32)、id は実体の ID(UUID)) */
3
3
  export type MediaUrlInput = Readonly<{
4
4
  project: string;
5
5
  id: string;
6
- mimeType: string;
7
- width?: number;
8
- height?: number;
9
6
  }>;
10
7
  /**
11
- * 実体の ID から配信の URL を作る(origin は配信のオリジン、#776)
12
- * - パスのプロジェクトと ID は URL のラベル(base32 の26文字)。配信 API の url と同じ値になる
13
- * - 配信しない形式、ID の形が違うときは null。非公開の実体は signMediaUrl で署名してから使う
8
+ * 実体の ID から配信の URL を作る(origin は配信のオリジンのひな形 https://{project}.tunasandusercontent.com)
9
+ * - 配信 API の url と同じ値になる。寸法は URL になく、配信 API の応答から読む
10
+ * - ひな形に {project} がないとき、ID の形が違うとき(プロジェクトの UUID の形を含む)は null。非公開の実体は signMediaUrl で署名してから使う
14
11
  */
15
- export declare function mediaUrlOf(origin: string, { project, id, mimeType, width, height }: MediaUrlInput): string | null;
12
+ export declare function mediaUrlOf(origin: string, { project, id }: MediaUrlInput): string | null;
16
13
  /** 配信する画像の URL(元の URL と、元画像の画素での切り抜きの範囲から、配信の側で変換する URL) */
17
14
  export type ImageUrl = (src: string, rect?: CropRect) => string;
18
15
  /** 配信 URL の画像の切り抜き(クエリ rect、範囲なしは元の URL) */
19
16
  export declare const deliveredImageUrl: ImageUrl;
20
17
  /** 実体から表示の素材(見つからない実体はなし) */
21
- export type MediaOf = (asset: unknown) => Media | undefined;
18
+ export type MediaOf = (file: unknown) => Media | undefined;
22
19
  /**
23
20
  * 実体から表示の素材への変換(動画は代わりの画像も)
24
- * - URL: 実体の url、なしは base/<ID のラベル>(base は実体の URL の前半、手元の CMS の /media。ID は base32 のラベル、#776)
21
+ * - URL: 実体の url、なしは base/<ID>(base は実体の URL の前半、手元の CMS の /media。ID は実体の UUID)
25
22
  * - 画像の変換: imageUrl で画像(動画の実体は除く)を変換の URL に、url のある実体の既定は deliveredImageUrl、切り抜きは切り抜いた画像の URL・寸法・見せたい点
26
23
  * - url も imageUrl もない: 元の画像のまま(手元の開発)
27
24
  */